@asyra/system-context 0.2.5 → 0.5.1
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/LICENSE +21 -0
- package/README.md +49 -1
- package/dist/apis/index.d.ts +11 -10
- package/dist/apis/index.js +3 -11
- package/dist/apis/managed-property-state.d.ts +39 -0
- package/dist/apis/managed-property-state.js +53 -0
- package/dist/apis/root.d.ts +1 -1
- package/dist/apis/root.js +18 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/states/index.d.ts +2 -6
- package/dist/states/index.js +2 -6
- package/dist/states/managed-property-state.d.ts +46 -0
- package/dist/states/managed-property-state.js +192 -0
- package/dist/system-context.d.ts +11 -11
- package/dist/system-context.js +13 -20
- package/dist/types/deps.d.ts +2 -10
- package/dist/types/index.d.ts +5 -9
- package/dist/types/index.js +1 -1
- package/dist/types/managed-property-state.d.ts +15 -0
- package/package.json +30 -6
- package/.turbo/turbo-test$colon$ci.log +0 -77
- package/.turbo/turbo-test$colon$local.log +0 -23
- package/.turbo/turbo-test.log +0 -359
- package/CHANGELOG.md +0 -46
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -345
- package/coverage/coverage-final.json +0 -5831
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +0 -176
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
- package/coverage/src/apis/index.html +0 -206
- package/coverage/src/apis/index.ts.html +0 -133
- package/coverage/src/apis/key-state.ts.html +0 -124
- package/coverage/src/apis/mouse-state.ts.html +0 -124
- package/coverage/src/apis/primary-tool-state.ts.html +0 -124
- package/coverage/src/apis/root.ts.html +0 -139
- package/coverage/src/apis/system-state.ts.html +0 -112
- package/coverage/src/apis/target-state.ts.html +0 -121
- package/coverage/src/index.html +0 -131
- package/coverage/src/index.ts.html +0 -97
- package/coverage/src/states/index.html +0 -191
- package/coverage/src/states/index.ts.html +0 -139
- package/coverage/src/states/key-state.ts.html +0 -148
- package/coverage/src/states/mouse-state.ts.html +0 -184
- package/coverage/src/states/primary-tool-state.ts.html +0 -130
- package/coverage/src/states/system-state.ts.html +0 -130
- package/coverage/src/states/target-state.ts.html +0 -154
- package/coverage/src/subscribe/index.html +0 -191
- package/coverage/src/subscribe/index.ts.html +0 -187
- package/coverage/src/subscribe/key-state.ts.html +0 -109
- package/coverage/src/subscribe/mouse-state.ts.html +0 -109
- package/coverage/src/subscribe/primary-tool-state.ts.html +0 -136
- package/coverage/src/subscribe/system-state.ts.html +0 -94
- package/coverage/src/subscribe/target-state.ts.html +0 -109
- package/coverage/src/system-context.ts.html +0 -247
- package/coverage/src/types/deps.ts.html +0 -145
- package/coverage/src/types/index.html +0 -221
- package/coverage/src/types/index.ts.html +0 -157
- package/coverage/src/types/key-state.ts.html +0 -118
- package/coverage/src/types/mouse-state.ts.html +0 -118
- package/coverage/src/types/primary-tool-state.ts.html +0 -121
- package/coverage/src/types/root.ts.html +0 -106
- package/coverage/src/types/system-state.ts.html +0 -106
- package/coverage/src/types/target-state.ts.html +0 -118
- package/dist/__tests__/system-context.test.js +0 -63
- package/dist/apis/key-state.d.ts +0 -2
- package/dist/apis/key-state.js +0 -8
- package/dist/apis/mouse-state copy.d.ts +0 -2
- package/dist/apis/mouse-state copy.js +0 -8
- package/dist/apis/mouse-state.d.ts +0 -2
- package/dist/apis/mouse-state.js +0 -8
- package/dist/apis/primary-tool-state.d.ts +0 -2
- package/dist/apis/primary-tool-state.js +0 -8
- package/dist/apis/system-state.d.ts +0 -2
- package/dist/apis/system-state.js +0 -5
- package/dist/apis/target-state.d.ts +0 -2
- package/dist/apis/target-state.js +0 -8
- package/dist/states/key-state.d.ts +0 -9
- package/dist/states/key-state.js +0 -16
- package/dist/states/mouse-state copy.d.ts +0 -9
- package/dist/states/mouse-state copy.js +0 -28
- package/dist/states/mouse-state.d.ts +0 -9
- package/dist/states/mouse-state.js +0 -28
- package/dist/states/primary-tool-state.d.ts +0 -8
- package/dist/states/primary-tool-state.js +0 -11
- package/dist/states/system-state.d.ts +0 -8
- package/dist/states/system-state.js +0 -11
- package/dist/states/target-state.d.ts +0 -9
- package/dist/states/target-state.js +0 -17
- package/dist/subscribe/index.d.ts +0 -2
- package/dist/subscribe/index.js +0 -24
- package/dist/subscribe/key-state.d.ts +0 -2
- package/dist/subscribe/key-state.js +0 -6
- package/dist/subscribe/mouse-state copy.d.ts +0 -2
- package/dist/subscribe/mouse-state copy.js +0 -6
- package/dist/subscribe/mouse-state.d.ts +0 -2
- package/dist/subscribe/mouse-state.js +0 -6
- package/dist/subscribe/primary-tool-state.d.ts +0 -2
- package/dist/subscribe/primary-tool-state.js +0 -10
- package/dist/subscribe/root.d.ts +0 -2
- package/dist/subscribe/root.js +0 -7
- package/dist/subscribe/system-state.d.ts +0 -1
- package/dist/subscribe/system-state.js +0 -3
- package/dist/subscribe/target-state.d.ts +0 -2
- package/dist/subscribe/target-state.js +0 -6
- package/dist/types/key-state.d.ts +0 -8
- package/dist/types/key-state.js +0 -1
- package/dist/types/mouse-state copy.d.ts +0 -8
- package/dist/types/mouse-state copy.js +0 -1
- package/dist/types/mouse-state.d.ts +0 -8
- package/dist/types/mouse-state.js +0 -1
- package/dist/types/primary-tool-state.d.ts +0 -8
- package/dist/types/primary-tool-state.js +0 -1
- package/dist/types/system-state.d.ts +0 -5
- package/dist/types/system-state.js +0 -1
- package/dist/types/target-state.d.ts +0 -8
- package/dist/types/target-state.js +0 -1
- package/src/__tests__/system-context.test.ts +0 -79
- package/src/apis/index.ts +0 -16
- package/src/apis/key-state.ts +0 -13
- package/src/apis/mouse-state.ts +0 -13
- package/src/apis/primary-tool-state.ts +0 -13
- package/src/apis/root.ts +0 -18
- package/src/apis/system-state.ts +0 -9
- package/src/apis/target-state.ts +0 -12
- package/src/index.ts +0 -4
- package/src/states/index.ts +0 -18
- package/src/states/key-state.ts +0 -21
- package/src/states/mouse-state.ts +0 -33
- package/src/states/primary-tool-state.ts +0 -15
- package/src/states/system-state.ts +0 -15
- package/src/states/target-state.ts +0 -23
- package/src/subscribe/index.ts +0 -34
- package/src/subscribe/key-state.ts +0 -8
- package/src/subscribe/mouse-state.ts +0 -8
- package/src/subscribe/primary-tool-state.ts +0 -17
- package/src/subscribe/system-state.ts +0 -3
- package/src/subscribe/target-state.ts +0 -8
- package/src/system-context.ts +0 -54
- package/src/types/deps.ts +0 -20
- package/src/types/index.ts +0 -24
- package/src/types/key-state.ts +0 -11
- package/src/types/mouse-state.ts +0 -11
- package/src/types/primary-tool-state.ts +0 -12
- package/src/types/root.ts +0 -7
- package/src/types/system-state.ts +0 -7
- package/src/types/target-state.ts +0 -11
- package/tsconfig.json +0 -17
- /package/dist/{__tests__/system-context.test.d.ts → types/managed-property-state.js} +0 -0
|
@@ -1,23 +0,0 @@
|
|
|
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()
|
package/src/subscribe/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
}
|
package/src/system-context.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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
|
package/src/types/deps.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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'
|
package/src/types/key-state.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
package/src/types/mouse-state.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
package/src/types/root.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
File without changes
|