4.1.0 • Published 11 months ago

@a-morphous/frontispiece-ink-hookstate v4.1.0

Weekly downloads
-
License
MPL 2.0
Repository
-
Last release
11 months ago

Ink Hookstate

Generates a Hookstate hook that links up to ink-processor and can be used to manipulate and display an Ink story with Hookstate and React / Preact.

Usage

See the example for a demo.

import { Story } from 'inkjs'
import { createInkHookState } from '../../src'

const story = new Story(/* story JSON */)

const { InkHookStateController, useInkHookState } = createInkHookState(story)

// InkHookStateController is the global state, and can be manipulated outside of hooks
InkHookStateController.registerCommand('pause', Pause)
InkHookStateController.registerCommand('log', Log)

// useInkHookState is the hook
const InkViewerComponent = () => {
    const inkState = useInkHookState()

    return <div>{inkState.getVisibleLines().map((line) => {
        return <p>{line.text}</p>
    })}</div>
}
4.1.0

11 months ago

4.0.0

11 months ago

3.0.0

1 year ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.3.0

1 year ago

1.2.0

2 years ago