@asyra/system-context 0.2.5 → 0.5.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/LICENSE +21 -0
- package/README.md +13 -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 +22 -4
- 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,28 +0,0 @@
|
|
|
1
|
-
import { DefaultPosition, MouseButton } from '@asyra/utils';
|
|
2
|
-
export class MouseState {
|
|
3
|
-
_state;
|
|
4
|
-
constructor() {
|
|
5
|
-
this._state = {
|
|
6
|
-
dragStart: DefaultPosition,
|
|
7
|
-
position: DefaultPosition,
|
|
8
|
-
delta: DefaultPosition,
|
|
9
|
-
button: MouseButton.NONE,
|
|
10
|
-
down: false,
|
|
11
|
-
dragging: false
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
set(mouseSnapshot) {
|
|
15
|
-
if (mouseSnapshot.dragStart) {
|
|
16
|
-
this._state.dragStart = { ...mouseSnapshot.dragStart };
|
|
17
|
-
}
|
|
18
|
-
this._state.position = { ...mouseSnapshot.position };
|
|
19
|
-
this._state.delta = { ...mouseSnapshot.delta };
|
|
20
|
-
this._state.button = mouseSnapshot.button;
|
|
21
|
-
this._state.down = mouseSnapshot.down;
|
|
22
|
-
this._state.dragging = mouseSnapshot.dragging;
|
|
23
|
-
}
|
|
24
|
-
get current() {
|
|
25
|
-
return this._state;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export default new MouseState();
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { DefaultPosition, MouseButton } from '@asyra/utils';
|
|
2
|
-
export class MouseState {
|
|
3
|
-
_state;
|
|
4
|
-
constructor() {
|
|
5
|
-
this._state = {
|
|
6
|
-
dragStart: DefaultPosition,
|
|
7
|
-
position: DefaultPosition,
|
|
8
|
-
delta: DefaultPosition,
|
|
9
|
-
button: MouseButton.NONE,
|
|
10
|
-
down: false,
|
|
11
|
-
dragging: false
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
set(mouseSnapshot) {
|
|
15
|
-
if (mouseSnapshot.dragStart) {
|
|
16
|
-
this._state.dragStart = { ...mouseSnapshot.dragStart };
|
|
17
|
-
}
|
|
18
|
-
this._state.position = { ...mouseSnapshot.position };
|
|
19
|
-
this._state.delta = { ...mouseSnapshot.delta };
|
|
20
|
-
this._state.button = mouseSnapshot.button;
|
|
21
|
-
this._state.down = mouseSnapshot.down;
|
|
22
|
-
this._state.dragging = mouseSnapshot.dragging;
|
|
23
|
-
}
|
|
24
|
-
get current() {
|
|
25
|
-
return this._state;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export default new MouseState();
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { TargetSnapshot } from '@asyra/utils';
|
|
2
|
-
export declare class TargetState {
|
|
3
|
-
private _state;
|
|
4
|
-
constructor();
|
|
5
|
-
updateHoveredElementId(elementId: string | null): void;
|
|
6
|
-
get current(): TargetSnapshot;
|
|
7
|
-
}
|
|
8
|
-
declare const _default: TargetState;
|
|
9
|
-
export default _default;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export class TargetState {
|
|
2
|
-
_state;
|
|
3
|
-
constructor() {
|
|
4
|
-
this._state = {
|
|
5
|
-
hoveredElementId: null,
|
|
6
|
-
selectedElementIds: [],
|
|
7
|
-
activeElementId: null
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
updateHoveredElementId(elementId) {
|
|
11
|
-
this._state.hoveredElementId = elementId;
|
|
12
|
-
}
|
|
13
|
-
get current() {
|
|
14
|
-
return this._state;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export default new TargetState();
|
package/dist/subscribe/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { initPrimaryToolStateSubscribe } from './primary-tool-state';
|
|
2
|
-
import { initMouseStateSubscribe } from './mouse-state';
|
|
3
|
-
import { initSystemStateSubscribe } from './system-state';
|
|
4
|
-
import { initKeyStateSubscribe } from './key-state';
|
|
5
|
-
import { initTargetStateSubscribe } from './target-state';
|
|
6
|
-
export const initSystemContextSubscribe = (apis) => {
|
|
7
|
-
initSystemStateSubscribe();
|
|
8
|
-
initPrimaryToolStateSubscribe({
|
|
9
|
-
getCurrentPrimaryTool: () => apis.getCurrentPrimaryTool(),
|
|
10
|
-
switchPrimaryTool: (tool) => apis.switchPrimaryTool(tool)
|
|
11
|
-
});
|
|
12
|
-
initMouseStateSubscribe({
|
|
13
|
-
getMouseState: () => apis.getMouseState(),
|
|
14
|
-
updateMouseState: (mouseSnapshot) => apis.updateMouseState(mouseSnapshot)
|
|
15
|
-
});
|
|
16
|
-
initKeyStateSubscribe({
|
|
17
|
-
getKeyState: () => apis.getKeyState(),
|
|
18
|
-
updateKeyState: (keySnapshot) => apis.updateKeyState(keySnapshot)
|
|
19
|
-
});
|
|
20
|
-
initTargetStateSubscribe({
|
|
21
|
-
getTargetState: () => apis.getTargetState(),
|
|
22
|
-
updateHoveredElementId: (elementId) => apis.updateHoveredElementId(elementId)
|
|
23
|
-
});
|
|
24
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { finishRequestCurrentPrimaryTool, subscribeToRequestCurrentPrimaryTool, subscribeToSwitchPrimaryTool } from '@asyra/reactive-events';
|
|
2
|
-
export const initPrimaryToolStateSubscribe = (apis) => {
|
|
3
|
-
subscribeToSwitchPrimaryTool(({ payload }) => {
|
|
4
|
-
apis.switchPrimaryTool(payload.tool);
|
|
5
|
-
});
|
|
6
|
-
subscribeToRequestCurrentPrimaryTool(({ payload }) => {
|
|
7
|
-
const primaryTool = apis.getCurrentPrimaryTool();
|
|
8
|
-
finishRequestCurrentPrimaryTool(payload.requestId, primaryTool);
|
|
9
|
-
});
|
|
10
|
-
};
|
package/dist/subscribe/root.d.ts
DELETED
package/dist/subscribe/root.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { finishRequestSystemContextSnapshot, subscribeToRequestSystemContextSnapshot } from '@asyra/reactive-events';
|
|
2
|
-
export const initRootSubscribe = (apis) => {
|
|
3
|
-
subscribeToRequestSystemContextSnapshot(({ payload }) => {
|
|
4
|
-
const systemContextSnapshot = apis.getSystemContextSnapshot();
|
|
5
|
-
finishRequestSystemContextSnapshot(payload.requestId, systemContextSnapshot);
|
|
6
|
-
});
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const initSystemStateSubscribe: () => void;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { KeySnapshot } from '@asyra/utils';
|
|
2
|
-
export interface KeyStateRawAPIs {
|
|
3
|
-
getKeyState: () => KeySnapshot;
|
|
4
|
-
}
|
|
5
|
-
export interface KeyStateActionAPIs {
|
|
6
|
-
updateKeyState: (keySnapshot: KeySnapshot) => void;
|
|
7
|
-
}
|
|
8
|
-
export type KeyStateAPIs = KeyStateActionAPIs & KeyStateRawAPIs;
|
package/dist/types/key-state.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MouseSnapshot } from '@asyra/utils';
|
|
2
|
-
export interface MouseStateRawAPIs {
|
|
3
|
-
getMouseState: () => MouseSnapshot;
|
|
4
|
-
}
|
|
5
|
-
export interface MouseStateActionAPIs {
|
|
6
|
-
updateMouseState: (mouseSnapshot: MouseSnapshot) => void;
|
|
7
|
-
}
|
|
8
|
-
export type MouseStateAPIs = MouseStateActionAPIs & MouseStateRawAPIs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { MouseSnapshot } from '@asyra/utils';
|
|
2
|
-
export interface MouseStateRawAPIs {
|
|
3
|
-
getMouseState: () => MouseSnapshot;
|
|
4
|
-
}
|
|
5
|
-
export interface MouseStateActionAPIs {
|
|
6
|
-
updateMouseState: (mouseSnapshot: MouseSnapshot) => void;
|
|
7
|
-
}
|
|
8
|
-
export type MouseStateAPIs = MouseStateActionAPIs & MouseStateRawAPIs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PrimaryToolType } from '@asyra/utils';
|
|
2
|
-
export interface PrimaryToolStateRawAPIs {
|
|
3
|
-
getCurrentPrimaryTool: () => PrimaryToolType;
|
|
4
|
-
}
|
|
5
|
-
export interface PrimaryToolStateActionAPIs {
|
|
6
|
-
switchPrimaryTool: (tool: PrimaryToolType) => void;
|
|
7
|
-
}
|
|
8
|
-
export type PrimaryToolStateAPIs = PrimaryToolStateRawAPIs & PrimaryToolStateActionAPIs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { TargetSnapshot } from '@asyra/utils';
|
|
2
|
-
export interface TargetStateRawAPIs {
|
|
3
|
-
getTargetState: () => TargetSnapshot;
|
|
4
|
-
}
|
|
5
|
-
export interface TargetStateActionAPIs {
|
|
6
|
-
updateHoveredElementId: (elementId: string | null) => void;
|
|
7
|
-
}
|
|
8
|
-
export type TargetStateAPIs = TargetStateActionAPIs & TargetStateRawAPIs;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest'
|
|
2
|
-
import { SystemContext } from '../system-context'
|
|
3
|
-
import { KeyState } from '../states/key-state'
|
|
4
|
-
import { MouseState } from '../states/mouse-state'
|
|
5
|
-
import { PrimaryToolState } from '../states/primary-tool-state'
|
|
6
|
-
import { SystemState } from '../states/system-state'
|
|
7
|
-
import { TargetState } from '../states/target-state'
|
|
8
|
-
import {
|
|
9
|
-
DefaultKeySnapshot,
|
|
10
|
-
DefaultPosition,
|
|
11
|
-
MouseButton,
|
|
12
|
-
PrimaryToolType
|
|
13
|
-
} from '@asyra/utils'
|
|
14
|
-
|
|
15
|
-
describe('SystemContext', () => {
|
|
16
|
-
let systemContext: SystemContext
|
|
17
|
-
let keyState: KeyState
|
|
18
|
-
let mouseState: MouseState
|
|
19
|
-
let primaryToolState: PrimaryToolState
|
|
20
|
-
let systemState: SystemState
|
|
21
|
-
let targetState: TargetState
|
|
22
|
-
|
|
23
|
-
beforeEach(() => {
|
|
24
|
-
keyState = new KeyState()
|
|
25
|
-
mouseState = new MouseState()
|
|
26
|
-
primaryToolState = new PrimaryToolState()
|
|
27
|
-
systemState = new SystemState()
|
|
28
|
-
targetState = new TargetState()
|
|
29
|
-
|
|
30
|
-
systemContext = new SystemContext({
|
|
31
|
-
keyState,
|
|
32
|
-
mouseState,
|
|
33
|
-
primaryToolState,
|
|
34
|
-
systemState,
|
|
35
|
-
targetState
|
|
36
|
-
})
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should initialize with the correct default state', () => {
|
|
40
|
-
expect(systemContext.getKeyState()).toEqual(DefaultKeySnapshot)
|
|
41
|
-
expect(systemContext.getMouseState()).toEqual({
|
|
42
|
-
dragStart: DefaultPosition,
|
|
43
|
-
position: DefaultPosition,
|
|
44
|
-
delta: DefaultPosition,
|
|
45
|
-
button: MouseButton.NONE,
|
|
46
|
-
down: false,
|
|
47
|
-
dragging: false
|
|
48
|
-
})
|
|
49
|
-
expect(systemContext.getCurrentPrimaryTool()).toEqual(
|
|
50
|
-
PrimaryToolType.SELECT
|
|
51
|
-
)
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
it('should update mouse state correctly', () => {
|
|
55
|
-
const newMouseSnapshot = {
|
|
56
|
-
position: { x: 100, y: 200 },
|
|
57
|
-
delta: { x: 1, y: 1 },
|
|
58
|
-
button: MouseButton.LEFT,
|
|
59
|
-
down: true,
|
|
60
|
-
dragging: true,
|
|
61
|
-
dragStart: { x: 99, y: 199 }
|
|
62
|
-
}
|
|
63
|
-
systemContext.updateMouseState(newMouseSnapshot)
|
|
64
|
-
expect(systemContext.getMouseState()).toEqual(newMouseSnapshot)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('should update tool state correctly', () => {
|
|
68
|
-
systemContext.switchPrimaryTool(PrimaryToolType.RECTANGLE)
|
|
69
|
-
expect(systemContext.getCurrentPrimaryTool()).toEqual(
|
|
70
|
-
PrimaryToolType.RECTANGLE
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('should update key state correctly', () => {
|
|
75
|
-
const newKeySnapshot = { ...DefaultKeySnapshot, shift: true }
|
|
76
|
-
systemContext.updateKeyState(newKeySnapshot)
|
|
77
|
-
expect(systemContext.getKeyState()).toEqual(newKeySnapshot)
|
|
78
|
-
})
|
|
79
|
-
})
|
package/src/apis/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createRootAPIs } from './root'
|
|
2
|
-
import { createMouseStateAPIs } from './mouse-state'
|
|
3
|
-
import { createPrimaryToolStateAPIs } from './primary-tool-state'
|
|
4
|
-
import { createSystemAPIs } from './system-state'
|
|
5
|
-
import { createKeyStateAPIs } from './key-state'
|
|
6
|
-
import { createTargetStateAPIs } from './target-state'
|
|
7
|
-
import { HandlerDeps } from '../types'
|
|
8
|
-
|
|
9
|
-
export const createAllAPIs = (deps: HandlerDeps) => ({
|
|
10
|
-
...createRootAPIs(deps),
|
|
11
|
-
...createPrimaryToolStateAPIs(deps.primaryToolState),
|
|
12
|
-
...createMouseStateAPIs(deps.mouseState),
|
|
13
|
-
...createSystemAPIs(deps.systemState),
|
|
14
|
-
...createKeyStateAPIs(deps.keyState),
|
|
15
|
-
...createTargetStateAPIs(deps.targetState)
|
|
16
|
-
})
|
package/src/apis/key-state.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { KeySnapshot } from '@asyra/utils'
|
|
2
|
-
import { HandlerDeps, KeyStateAPIs } from '../types'
|
|
3
|
-
|
|
4
|
-
export const createKeyStateAPIs = (
|
|
5
|
-
keyState: HandlerDeps['keyState']
|
|
6
|
-
): KeyStateAPIs => ({
|
|
7
|
-
updateKeyState(keySnapshot: KeySnapshot) {
|
|
8
|
-
keyState.set(keySnapshot)
|
|
9
|
-
},
|
|
10
|
-
getKeyState() {
|
|
11
|
-
return keyState.current
|
|
12
|
-
}
|
|
13
|
-
})
|
package/src/apis/mouse-state.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
})
|
package/src/apis/system-state.ts
DELETED
package/src/apis/target-state.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
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
DELETED
package/src/states/index.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|
package/src/states/key-state.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
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()
|
|
@@ -1,33 +0,0 @@
|
|
|
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()
|
|
@@ -1,15 +0,0 @@
|
|
|
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()
|
|
@@ -1,15 +0,0 @@
|
|
|
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()
|