@asyra/system-context 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-test$colon$ci.log +77 -0
- package/.turbo/turbo-test$colon$local.log +23 -0
- package/.turbo/turbo-test.log +359 -0
- package/README.md +1 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/clover.xml +345 -0
- package/coverage/coverage-final.json +5831 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +176 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/src/apis/index.html +206 -0
- package/coverage/src/apis/index.ts.html +133 -0
- package/coverage/src/apis/key-state.ts.html +124 -0
- package/coverage/src/apis/mouse-state.ts.html +124 -0
- package/coverage/src/apis/primary-tool-state.ts.html +124 -0
- package/coverage/src/apis/root.ts.html +139 -0
- package/coverage/src/apis/system-state.ts.html +112 -0
- package/coverage/src/apis/target-state.ts.html +121 -0
- package/coverage/src/index.html +131 -0
- package/coverage/src/index.ts.html +97 -0
- package/coverage/src/states/index.html +191 -0
- package/coverage/src/states/index.ts.html +139 -0
- package/coverage/src/states/key-state.ts.html +148 -0
- package/coverage/src/states/mouse-state.ts.html +184 -0
- package/coverage/src/states/primary-tool-state.ts.html +130 -0
- package/coverage/src/states/system-state.ts.html +130 -0
- package/coverage/src/states/target-state.ts.html +154 -0
- package/coverage/src/subscribe/index.html +191 -0
- package/coverage/src/subscribe/index.ts.html +187 -0
- package/coverage/src/subscribe/key-state.ts.html +109 -0
- package/coverage/src/subscribe/mouse-state.ts.html +109 -0
- package/coverage/src/subscribe/primary-tool-state.ts.html +136 -0
- package/coverage/src/subscribe/system-state.ts.html +94 -0
- package/coverage/src/subscribe/target-state.ts.html +109 -0
- package/coverage/src/system-context.ts.html +247 -0
- package/coverage/src/types/deps.ts.html +145 -0
- package/coverage/src/types/index.html +221 -0
- package/coverage/src/types/index.ts.html +157 -0
- package/coverage/src/types/key-state.ts.html +118 -0
- package/coverage/src/types/mouse-state.ts.html +118 -0
- package/coverage/src/types/primary-tool-state.ts.html +121 -0
- package/coverage/src/types/root.ts.html +106 -0
- package/coverage/src/types/system-state.ts.html +106 -0
- package/coverage/src/types/target-state.ts.html +118 -0
- package/dist/__tests__/system-context.test.d.ts +1 -0
- package/dist/__tests__/system-context.test.js +63 -0
- package/dist/apis/index.d.ts +13 -0
- package/dist/apis/index.js +14 -0
- package/dist/apis/key-state.d.ts +2 -0
- package/dist/apis/key-state.js +8 -0
- package/dist/apis/mouse-state copy.d.ts +2 -0
- package/dist/apis/mouse-state copy.js +8 -0
- package/dist/apis/mouse-state.d.ts +2 -0
- package/dist/apis/mouse-state.js +8 -0
- package/dist/apis/primary-tool-state.d.ts +2 -0
- package/dist/apis/primary-tool-state.js +8 -0
- package/dist/apis/root.d.ts +2 -0
- package/dist/apis/root.js +15 -0
- package/dist/apis/system-state.d.ts +2 -0
- package/dist/apis/system-state.js +5 -0
- package/dist/apis/target-state.d.ts +2 -0
- package/dist/apis/target-state.js +8 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/states/index.d.ts +6 -0
- package/dist/states/index.js +6 -0
- package/dist/states/key-state.d.ts +9 -0
- package/dist/states/key-state.js +16 -0
- package/dist/states/mouse-state copy.d.ts +9 -0
- package/dist/states/mouse-state copy.js +28 -0
- package/dist/states/mouse-state.d.ts +9 -0
- package/dist/states/mouse-state.js +28 -0
- package/dist/states/primary-tool-state.d.ts +8 -0
- package/dist/states/primary-tool-state.js +11 -0
- package/dist/states/system-state.d.ts +8 -0
- package/dist/states/system-state.js +11 -0
- package/dist/states/target-state.d.ts +9 -0
- package/dist/states/target-state.js +17 -0
- package/dist/subscribe/index.d.ts +2 -0
- package/dist/subscribe/index.js +24 -0
- package/dist/subscribe/key-state.d.ts +2 -0
- package/dist/subscribe/key-state.js +6 -0
- package/dist/subscribe/mouse-state copy.d.ts +2 -0
- package/dist/subscribe/mouse-state copy.js +6 -0
- package/dist/subscribe/mouse-state.d.ts +2 -0
- package/dist/subscribe/mouse-state.js +6 -0
- package/dist/subscribe/primary-tool-state.d.ts +2 -0
- package/dist/subscribe/primary-tool-state.js +10 -0
- package/dist/subscribe/root.d.ts +2 -0
- package/dist/subscribe/root.js +7 -0
- package/dist/subscribe/system-state.d.ts +1 -0
- package/dist/subscribe/system-state.js +3 -0
- package/dist/subscribe/target-state.d.ts +2 -0
- package/dist/subscribe/target-state.js +6 -0
- package/dist/system-context.d.ts +17 -0
- package/dist/system-context.js +30 -0
- package/dist/types/deps.d.ts +12 -0
- package/dist/types/deps.js +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +1 -0
- package/dist/types/key-state.d.ts +8 -0
- package/dist/types/key-state.js +1 -0
- package/dist/types/mouse-state copy.d.ts +8 -0
- package/dist/types/mouse-state copy.js +1 -0
- package/dist/types/mouse-state.d.ts +8 -0
- package/dist/types/mouse-state.js +1 -0
- package/dist/types/primary-tool-state.d.ts +8 -0
- package/dist/types/primary-tool-state.js +1 -0
- package/dist/types/root.d.ts +5 -0
- package/dist/types/root.js +1 -0
- package/dist/types/system-state.d.ts +5 -0
- package/dist/types/system-state.js +1 -0
- package/dist/types/target-state.d.ts +8 -0
- package/dist/types/target-state.js +1 -0
- package/package.json +28 -0
- package/src/__tests__/system-context.test.ts +79 -0
- package/src/apis/index.ts +16 -0
- package/src/apis/key-state.ts +13 -0
- package/src/apis/mouse-state.ts +13 -0
- package/src/apis/primary-tool-state.ts +13 -0
- package/src/apis/root.ts +18 -0
- package/src/apis/system-state.ts +9 -0
- package/src/apis/target-state.ts +12 -0
- package/src/index.ts +4 -0
- package/src/states/index.ts +18 -0
- package/src/states/key-state.ts +21 -0
- package/src/states/mouse-state.ts +33 -0
- package/src/states/primary-tool-state.ts +15 -0
- package/src/states/system-state.ts +15 -0
- package/src/states/target-state.ts +23 -0
- package/src/subscribe/index.ts +34 -0
- package/src/subscribe/key-state.ts +8 -0
- package/src/subscribe/mouse-state.ts +8 -0
- package/src/subscribe/primary-tool-state.ts +17 -0
- package/src/subscribe/system-state.ts +3 -0
- package/src/subscribe/target-state.ts +8 -0
- package/src/system-context.ts +54 -0
- package/src/types/deps.ts +20 -0
- package/src/types/index.ts +24 -0
- package/src/types/key-state.ts +11 -0
- package/src/types/mouse-state.ts +11 -0
- package/src/types/primary-tool-state.ts +12 -0
- package/src/types/root.ts +7 -0
- package/src/types/system-state.ts +7 -0
- package/src/types/target-state.ts +11 -0
- package/tsconfig.json +17 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { MouseSnapshot } from '@asyra/utils'
|
|
2
|
+
import { HandlerDeps, MouseStateAPIs } from '../types'
|
|
3
|
+
|
|
4
|
+
export const createMouseStateAPIs = (
|
|
5
|
+
mouseState: HandlerDeps['mouseState']
|
|
6
|
+
): MouseStateAPIs => ({
|
|
7
|
+
updateMouseState(mouseSnapshot: MouseSnapshot) {
|
|
8
|
+
mouseState.set(mouseSnapshot)
|
|
9
|
+
},
|
|
10
|
+
getMouseState() {
|
|
11
|
+
return mouseState.current
|
|
12
|
+
}
|
|
13
|
+
})
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PrimaryToolType } from '@asyra/utils'
|
|
2
|
+
import { HandlerDeps, PrimaryToolStateAPIs } from '../types'
|
|
3
|
+
|
|
4
|
+
export const createPrimaryToolStateAPIs = (
|
|
5
|
+
primaryToolState: HandlerDeps['primaryToolState']
|
|
6
|
+
): PrimaryToolStateAPIs => ({
|
|
7
|
+
getCurrentPrimaryTool(): PrimaryToolType {
|
|
8
|
+
return primaryToolState.current
|
|
9
|
+
},
|
|
10
|
+
switchPrimaryTool(tool: PrimaryToolType) {
|
|
11
|
+
primaryToolState.set(tool)
|
|
12
|
+
}
|
|
13
|
+
})
|
package/src/apis/root.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SystemContextSnapshot } from '@asyra/utils'
|
|
2
|
+
import { HandlerDeps, RootAPIs } from '../types'
|
|
3
|
+
|
|
4
|
+
export const createRootAPIs = (deps: HandlerDeps): RootAPIs => ({
|
|
5
|
+
getSystemContextSnapshot(): SystemContextSnapshot {
|
|
6
|
+
return {
|
|
7
|
+
primaryTool: deps.primaryToolState.current,
|
|
8
|
+
mouse: deps.mouseState.current,
|
|
9
|
+
system: {
|
|
10
|
+
mode: deps.systemState.mode,
|
|
11
|
+
featureFlags: {},
|
|
12
|
+
permissions: {}
|
|
13
|
+
},
|
|
14
|
+
key: deps.keyState.current,
|
|
15
|
+
target: deps.targetState.current
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
})
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HandlerDeps, TargetStateAPIs } from '../types'
|
|
2
|
+
|
|
3
|
+
export const createTargetStateAPIs = (
|
|
4
|
+
targetState: HandlerDeps['targetState']
|
|
5
|
+
): TargetStateAPIs => ({
|
|
6
|
+
updateHoveredElementId(elementId: string | null) {
|
|
7
|
+
targetState.updateHoveredElementId(elementId)
|
|
8
|
+
},
|
|
9
|
+
getTargetState() {
|
|
10
|
+
return targetState.current
|
|
11
|
+
}
|
|
12
|
+
})
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import systemState, { SystemState } from './system-state'
|
|
2
|
+
import primaryToolState, { PrimaryToolState } from './primary-tool-state'
|
|
3
|
+
import mouseState, { MouseState } from './mouse-state'
|
|
4
|
+
import keyState, { KeyState } from './key-state'
|
|
5
|
+
import targetState, { TargetState } from './target-state'
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
systemState,
|
|
9
|
+
SystemState,
|
|
10
|
+
primaryToolState,
|
|
11
|
+
PrimaryToolState,
|
|
12
|
+
mouseState,
|
|
13
|
+
MouseState,
|
|
14
|
+
keyState,
|
|
15
|
+
KeyState,
|
|
16
|
+
targetState,
|
|
17
|
+
TargetState
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DefaultKeySnapshot, KeySnapshot } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export class KeyState {
|
|
4
|
+
private _state: KeySnapshot
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
this._state = {
|
|
8
|
+
...DefaultKeySnapshot
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
set(keySnapshot: KeySnapshot) {
|
|
13
|
+
this._state = { ...keySnapshot }
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
get current() {
|
|
17
|
+
return this._state
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default new KeyState()
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DefaultPosition, MouseButton, MouseSnapshot } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export class MouseState {
|
|
4
|
+
private _state: MouseSnapshot
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
this._state = {
|
|
8
|
+
dragStart: DefaultPosition,
|
|
9
|
+
position: DefaultPosition,
|
|
10
|
+
delta: DefaultPosition,
|
|
11
|
+
button: MouseButton.NONE,
|
|
12
|
+
down: false,
|
|
13
|
+
dragging: false
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
set(mouseSnapshot: MouseSnapshot) {
|
|
18
|
+
if (mouseSnapshot.dragStart) {
|
|
19
|
+
this._state.dragStart = { ...mouseSnapshot.dragStart }
|
|
20
|
+
}
|
|
21
|
+
this._state.position = { ...mouseSnapshot.position }
|
|
22
|
+
this._state.delta = { ...mouseSnapshot.delta }
|
|
23
|
+
this._state.button = mouseSnapshot.button
|
|
24
|
+
this._state.down = mouseSnapshot.down
|
|
25
|
+
this._state.dragging = mouseSnapshot.dragging
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get current() {
|
|
29
|
+
return this._state
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default new MouseState()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DefaultPrimaryTool, PrimaryToolType } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export class PrimaryToolState {
|
|
4
|
+
private _state: PrimaryToolType = DefaultPrimaryTool
|
|
5
|
+
|
|
6
|
+
set(tool: PrimaryToolType) {
|
|
7
|
+
this._state = tool
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get current() {
|
|
11
|
+
return this._state
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default new PrimaryToolState()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DefaultSystemSnapshot, SystemMode } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export class SystemState {
|
|
4
|
+
private _mode: SystemMode = DefaultSystemSnapshot.mode
|
|
5
|
+
|
|
6
|
+
set(mode: SystemMode) {
|
|
7
|
+
this._mode = mode
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
get mode() {
|
|
11
|
+
return this._mode
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default new SystemState()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TargetSnapshot } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export class TargetState {
|
|
4
|
+
private _state: TargetSnapshot
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
this._state = {
|
|
8
|
+
hoveredElementId: null,
|
|
9
|
+
selectedElementIds: [],
|
|
10
|
+
activeElementId: null
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
updateHoveredElementId(elementId: string | null) {
|
|
15
|
+
this._state.hoveredElementId = elementId
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get current() {
|
|
19
|
+
return this._state
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default new TargetState()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { KeySnapshot, MouseSnapshot, PrimaryToolType } from '@asyra/utils'
|
|
2
|
+
import { initPrimaryToolStateSubscribe } from './primary-tool-state'
|
|
3
|
+
import { initMouseStateSubscribe } from './mouse-state'
|
|
4
|
+
import { initSystemStateSubscribe } from './system-state'
|
|
5
|
+
import { initKeyStateSubscribe } from './key-state'
|
|
6
|
+
import { initTargetStateSubscribe } from './target-state'
|
|
7
|
+
import { SystemContextAPIs } from '../types'
|
|
8
|
+
|
|
9
|
+
export const initSystemContextSubscribe = (apis: SystemContextAPIs) => {
|
|
10
|
+
initSystemStateSubscribe()
|
|
11
|
+
|
|
12
|
+
initPrimaryToolStateSubscribe({
|
|
13
|
+
getCurrentPrimaryTool: () => apis.getCurrentPrimaryTool(),
|
|
14
|
+
switchPrimaryTool: (tool: PrimaryToolType) => apis.switchPrimaryTool(tool)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
initMouseStateSubscribe({
|
|
18
|
+
getMouseState: () => apis.getMouseState(),
|
|
19
|
+
updateMouseState: (mouseSnapshot: MouseSnapshot) =>
|
|
20
|
+
apis.updateMouseState(mouseSnapshot)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
initKeyStateSubscribe({
|
|
24
|
+
getKeyState: () => apis.getKeyState(),
|
|
25
|
+
updateKeyState: (keySnapshot: KeySnapshot) =>
|
|
26
|
+
apis.updateKeyState(keySnapshot)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
initTargetStateSubscribe({
|
|
30
|
+
getTargetState: () => apis.getTargetState(),
|
|
31
|
+
updateHoveredElementId: (elementId: string | null) =>
|
|
32
|
+
apis.updateHoveredElementId(elementId)
|
|
33
|
+
})
|
|
34
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { subscribeToUpdateMouseState } from '@asyra/reactive-events'
|
|
2
|
+
import { MouseStateAPIs } from '../types'
|
|
3
|
+
|
|
4
|
+
export const initMouseStateSubscribe = (apis: MouseStateAPIs) => {
|
|
5
|
+
subscribeToUpdateMouseState(({ payload }) => {
|
|
6
|
+
apis.updateMouseState(payload)
|
|
7
|
+
})
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
finishRequestCurrentPrimaryTool,
|
|
3
|
+
subscribeToRequestCurrentPrimaryTool,
|
|
4
|
+
subscribeToSwitchPrimaryTool
|
|
5
|
+
} from '@asyra/reactive-events'
|
|
6
|
+
import { PrimaryToolStateAPIs } from '../types'
|
|
7
|
+
|
|
8
|
+
export const initPrimaryToolStateSubscribe = (apis: PrimaryToolStateAPIs) => {
|
|
9
|
+
subscribeToSwitchPrimaryTool(({ payload }) => {
|
|
10
|
+
apis.switchPrimaryTool(payload.tool)
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
subscribeToRequestCurrentPrimaryTool(({ payload }) => {
|
|
14
|
+
const primaryTool = apis.getCurrentPrimaryTool()
|
|
15
|
+
finishRequestCurrentPrimaryTool(payload.requestId, primaryTool)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { subscribeToUpdateHoveredElementId } from '@asyra/reactive-events'
|
|
2
|
+
import { TargetStateAPIs } from '../types'
|
|
3
|
+
|
|
4
|
+
export const initTargetStateSubscribe = (apis: TargetStateAPIs) => {
|
|
5
|
+
subscribeToUpdateHoveredElementId(({ payload }) => {
|
|
6
|
+
apis.updateHoveredElementId(payload.elementId)
|
|
7
|
+
})
|
|
8
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createAllAPIs } from './apis'
|
|
2
|
+
import {
|
|
3
|
+
systemState,
|
|
4
|
+
primaryToolState,
|
|
5
|
+
mouseState,
|
|
6
|
+
keyState,
|
|
7
|
+
targetState
|
|
8
|
+
} from './states'
|
|
9
|
+
import { initSystemContextSubscribe } from './subscribe'
|
|
10
|
+
import {
|
|
11
|
+
HandlerDeps,
|
|
12
|
+
PrimaryToolStateAPIs,
|
|
13
|
+
MouseStateAPIs,
|
|
14
|
+
SystemStateAPIs,
|
|
15
|
+
SystemContextAPIs,
|
|
16
|
+
RootAPIs,
|
|
17
|
+
KeyStateAPIs,
|
|
18
|
+
TargetStateAPIs
|
|
19
|
+
} from './types'
|
|
20
|
+
|
|
21
|
+
export class SystemContext implements SystemContextAPIs {
|
|
22
|
+
getSystemMode!: SystemStateAPIs['getSystemMode']
|
|
23
|
+
|
|
24
|
+
getCurrentPrimaryTool!: PrimaryToolStateAPIs['getCurrentPrimaryTool']
|
|
25
|
+
switchPrimaryTool!: PrimaryToolStateAPIs['switchPrimaryTool']
|
|
26
|
+
|
|
27
|
+
getMouseState!: MouseStateAPIs['getMouseState']
|
|
28
|
+
updateMouseState!: MouseStateAPIs['updateMouseState']
|
|
29
|
+
|
|
30
|
+
getKeyState!: KeyStateAPIs['getKeyState']
|
|
31
|
+
updateKeyState!: KeyStateAPIs['updateKeyState']
|
|
32
|
+
|
|
33
|
+
getTargetState!: TargetStateAPIs['getTargetState']
|
|
34
|
+
updateHoveredElementId!: TargetStateAPIs['updateHoveredElementId']
|
|
35
|
+
|
|
36
|
+
getSystemContextSnapshot!: RootAPIs['getSystemContextSnapshot']
|
|
37
|
+
|
|
38
|
+
constructor(private deps: HandlerDeps) {
|
|
39
|
+
const apis = createAllAPIs(deps)
|
|
40
|
+
|
|
41
|
+
initSystemContextSubscribe(apis)
|
|
42
|
+
|
|
43
|
+
Object.assign(this, apis)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const systemContext = new SystemContext({
|
|
48
|
+
systemState,
|
|
49
|
+
primaryToolState,
|
|
50
|
+
mouseState,
|
|
51
|
+
keyState,
|
|
52
|
+
targetState
|
|
53
|
+
})
|
|
54
|
+
export default systemContext
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
SystemState,
|
|
3
|
+
PrimaryToolState,
|
|
4
|
+
MouseState,
|
|
5
|
+
KeyState,
|
|
6
|
+
TargetState
|
|
7
|
+
} from '../states'
|
|
8
|
+
|
|
9
|
+
export interface HandlerDeps {
|
|
10
|
+
systemState: SystemState
|
|
11
|
+
primaryToolState: PrimaryToolState
|
|
12
|
+
mouseState: MouseState
|
|
13
|
+
keyState: KeyState
|
|
14
|
+
targetState: TargetState
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SystemDeps {
|
|
18
|
+
primaryToolState: PrimaryToolState
|
|
19
|
+
mouseState: MouseState
|
|
20
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RootAPIs } from './root'
|
|
2
|
+
import { SystemStateAPIs } from './system-state'
|
|
3
|
+
import { PrimaryToolStateAPIs } from './primary-tool-state'
|
|
4
|
+
import { MouseStateAPIs } from './mouse-state'
|
|
5
|
+
import { KeyStateAPIs } from './key-state'
|
|
6
|
+
import { TargetStateAPIs } from './target-state'
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
RootAPIs,
|
|
10
|
+
SystemStateAPIs,
|
|
11
|
+
PrimaryToolStateAPIs,
|
|
12
|
+
MouseStateAPIs,
|
|
13
|
+
KeyStateAPIs,
|
|
14
|
+
TargetStateAPIs
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type SystemContextAPIs = RootAPIs &
|
|
18
|
+
SystemStateAPIs &
|
|
19
|
+
PrimaryToolStateAPIs &
|
|
20
|
+
MouseStateAPIs &
|
|
21
|
+
KeyStateAPIs &
|
|
22
|
+
TargetStateAPIs
|
|
23
|
+
|
|
24
|
+
export * from './deps'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { KeySnapshot } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export interface KeyStateRawAPIs {
|
|
4
|
+
getKeyState: () => KeySnapshot
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface KeyStateActionAPIs {
|
|
8
|
+
updateKeyState: (keySnapshot: KeySnapshot) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type KeyStateAPIs = KeyStateActionAPIs & KeyStateRawAPIs
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MouseSnapshot } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export interface MouseStateRawAPIs {
|
|
4
|
+
getMouseState: () => MouseSnapshot
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface MouseStateActionAPIs {
|
|
8
|
+
updateMouseState: (mouseSnapshot: MouseSnapshot) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type MouseStateAPIs = MouseStateActionAPIs & MouseStateRawAPIs
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PrimaryToolType } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export interface PrimaryToolStateRawAPIs {
|
|
4
|
+
getCurrentPrimaryTool: () => PrimaryToolType
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface PrimaryToolStateActionAPIs {
|
|
8
|
+
switchPrimaryTool: (tool: PrimaryToolType) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type PrimaryToolStateAPIs = PrimaryToolStateRawAPIs &
|
|
12
|
+
PrimaryToolStateActionAPIs
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TargetSnapshot } from '@asyra/utils'
|
|
2
|
+
|
|
3
|
+
export interface TargetStateRawAPIs {
|
|
4
|
+
getTargetState: () => TargetSnapshot
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface TargetStateActionAPIs {
|
|
8
|
+
updateHoveredElementId: (elementId: string | null) => void
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type TargetStateAPIs = TargetStateActionAPIs & TargetStateRawAPIs
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "esnext",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"moduleResolution": "node",
|
|
6
|
+
"rootDir": "./src",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"resolveJsonModule": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"noEmit": false,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"declaration": true
|
|
14
|
+
},
|
|
15
|
+
"include": ["src"],
|
|
16
|
+
"exclude": ["node_modules"]
|
|
17
|
+
}
|