@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.
Files changed (154) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -1
  3. package/dist/apis/index.d.ts +11 -10
  4. package/dist/apis/index.js +3 -11
  5. package/dist/apis/managed-property-state.d.ts +39 -0
  6. package/dist/apis/managed-property-state.js +53 -0
  7. package/dist/apis/root.d.ts +1 -1
  8. package/dist/apis/root.js +18 -11
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.js +1 -1
  11. package/dist/states/index.d.ts +2 -6
  12. package/dist/states/index.js +2 -6
  13. package/dist/states/managed-property-state.d.ts +46 -0
  14. package/dist/states/managed-property-state.js +192 -0
  15. package/dist/system-context.d.ts +11 -11
  16. package/dist/system-context.js +13 -20
  17. package/dist/types/deps.d.ts +2 -10
  18. package/dist/types/index.d.ts +5 -9
  19. package/dist/types/index.js +1 -1
  20. package/dist/types/managed-property-state.d.ts +15 -0
  21. package/package.json +22 -4
  22. package/.turbo/turbo-test$colon$ci.log +0 -77
  23. package/.turbo/turbo-test$colon$local.log +0 -23
  24. package/.turbo/turbo-test.log +0 -359
  25. package/CHANGELOG.md +0 -46
  26. package/coverage/base.css +0 -224
  27. package/coverage/block-navigation.js +0 -87
  28. package/coverage/clover.xml +0 -345
  29. package/coverage/coverage-final.json +0 -5831
  30. package/coverage/favicon.png +0 -0
  31. package/coverage/index.html +0 -176
  32. package/coverage/prettify.css +0 -1
  33. package/coverage/prettify.js +0 -2
  34. package/coverage/sort-arrow-sprite.png +0 -0
  35. package/coverage/sorter.js +0 -196
  36. package/coverage/src/apis/index.html +0 -206
  37. package/coverage/src/apis/index.ts.html +0 -133
  38. package/coverage/src/apis/key-state.ts.html +0 -124
  39. package/coverage/src/apis/mouse-state.ts.html +0 -124
  40. package/coverage/src/apis/primary-tool-state.ts.html +0 -124
  41. package/coverage/src/apis/root.ts.html +0 -139
  42. package/coverage/src/apis/system-state.ts.html +0 -112
  43. package/coverage/src/apis/target-state.ts.html +0 -121
  44. package/coverage/src/index.html +0 -131
  45. package/coverage/src/index.ts.html +0 -97
  46. package/coverage/src/states/index.html +0 -191
  47. package/coverage/src/states/index.ts.html +0 -139
  48. package/coverage/src/states/key-state.ts.html +0 -148
  49. package/coverage/src/states/mouse-state.ts.html +0 -184
  50. package/coverage/src/states/primary-tool-state.ts.html +0 -130
  51. package/coverage/src/states/system-state.ts.html +0 -130
  52. package/coverage/src/states/target-state.ts.html +0 -154
  53. package/coverage/src/subscribe/index.html +0 -191
  54. package/coverage/src/subscribe/index.ts.html +0 -187
  55. package/coverage/src/subscribe/key-state.ts.html +0 -109
  56. package/coverage/src/subscribe/mouse-state.ts.html +0 -109
  57. package/coverage/src/subscribe/primary-tool-state.ts.html +0 -136
  58. package/coverage/src/subscribe/system-state.ts.html +0 -94
  59. package/coverage/src/subscribe/target-state.ts.html +0 -109
  60. package/coverage/src/system-context.ts.html +0 -247
  61. package/coverage/src/types/deps.ts.html +0 -145
  62. package/coverage/src/types/index.html +0 -221
  63. package/coverage/src/types/index.ts.html +0 -157
  64. package/coverage/src/types/key-state.ts.html +0 -118
  65. package/coverage/src/types/mouse-state.ts.html +0 -118
  66. package/coverage/src/types/primary-tool-state.ts.html +0 -121
  67. package/coverage/src/types/root.ts.html +0 -106
  68. package/coverage/src/types/system-state.ts.html +0 -106
  69. package/coverage/src/types/target-state.ts.html +0 -118
  70. package/dist/__tests__/system-context.test.js +0 -63
  71. package/dist/apis/key-state.d.ts +0 -2
  72. package/dist/apis/key-state.js +0 -8
  73. package/dist/apis/mouse-state copy.d.ts +0 -2
  74. package/dist/apis/mouse-state copy.js +0 -8
  75. package/dist/apis/mouse-state.d.ts +0 -2
  76. package/dist/apis/mouse-state.js +0 -8
  77. package/dist/apis/primary-tool-state.d.ts +0 -2
  78. package/dist/apis/primary-tool-state.js +0 -8
  79. package/dist/apis/system-state.d.ts +0 -2
  80. package/dist/apis/system-state.js +0 -5
  81. package/dist/apis/target-state.d.ts +0 -2
  82. package/dist/apis/target-state.js +0 -8
  83. package/dist/states/key-state.d.ts +0 -9
  84. package/dist/states/key-state.js +0 -16
  85. package/dist/states/mouse-state copy.d.ts +0 -9
  86. package/dist/states/mouse-state copy.js +0 -28
  87. package/dist/states/mouse-state.d.ts +0 -9
  88. package/dist/states/mouse-state.js +0 -28
  89. package/dist/states/primary-tool-state.d.ts +0 -8
  90. package/dist/states/primary-tool-state.js +0 -11
  91. package/dist/states/system-state.d.ts +0 -8
  92. package/dist/states/system-state.js +0 -11
  93. package/dist/states/target-state.d.ts +0 -9
  94. package/dist/states/target-state.js +0 -17
  95. package/dist/subscribe/index.d.ts +0 -2
  96. package/dist/subscribe/index.js +0 -24
  97. package/dist/subscribe/key-state.d.ts +0 -2
  98. package/dist/subscribe/key-state.js +0 -6
  99. package/dist/subscribe/mouse-state copy.d.ts +0 -2
  100. package/dist/subscribe/mouse-state copy.js +0 -6
  101. package/dist/subscribe/mouse-state.d.ts +0 -2
  102. package/dist/subscribe/mouse-state.js +0 -6
  103. package/dist/subscribe/primary-tool-state.d.ts +0 -2
  104. package/dist/subscribe/primary-tool-state.js +0 -10
  105. package/dist/subscribe/root.d.ts +0 -2
  106. package/dist/subscribe/root.js +0 -7
  107. package/dist/subscribe/system-state.d.ts +0 -1
  108. package/dist/subscribe/system-state.js +0 -3
  109. package/dist/subscribe/target-state.d.ts +0 -2
  110. package/dist/subscribe/target-state.js +0 -6
  111. package/dist/types/key-state.d.ts +0 -8
  112. package/dist/types/key-state.js +0 -1
  113. package/dist/types/mouse-state copy.d.ts +0 -8
  114. package/dist/types/mouse-state copy.js +0 -1
  115. package/dist/types/mouse-state.d.ts +0 -8
  116. package/dist/types/mouse-state.js +0 -1
  117. package/dist/types/primary-tool-state.d.ts +0 -8
  118. package/dist/types/primary-tool-state.js +0 -1
  119. package/dist/types/system-state.d.ts +0 -5
  120. package/dist/types/system-state.js +0 -1
  121. package/dist/types/target-state.d.ts +0 -8
  122. package/dist/types/target-state.js +0 -1
  123. package/src/__tests__/system-context.test.ts +0 -79
  124. package/src/apis/index.ts +0 -16
  125. package/src/apis/key-state.ts +0 -13
  126. package/src/apis/mouse-state.ts +0 -13
  127. package/src/apis/primary-tool-state.ts +0 -13
  128. package/src/apis/root.ts +0 -18
  129. package/src/apis/system-state.ts +0 -9
  130. package/src/apis/target-state.ts +0 -12
  131. package/src/index.ts +0 -4
  132. package/src/states/index.ts +0 -18
  133. package/src/states/key-state.ts +0 -21
  134. package/src/states/mouse-state.ts +0 -33
  135. package/src/states/primary-tool-state.ts +0 -15
  136. package/src/states/system-state.ts +0 -15
  137. package/src/states/target-state.ts +0 -23
  138. package/src/subscribe/index.ts +0 -34
  139. package/src/subscribe/key-state.ts +0 -8
  140. package/src/subscribe/mouse-state.ts +0 -8
  141. package/src/subscribe/primary-tool-state.ts +0 -17
  142. package/src/subscribe/system-state.ts +0 -3
  143. package/src/subscribe/target-state.ts +0 -8
  144. package/src/system-context.ts +0 -54
  145. package/src/types/deps.ts +0 -20
  146. package/src/types/index.ts +0 -24
  147. package/src/types/key-state.ts +0 -11
  148. package/src/types/mouse-state.ts +0 -11
  149. package/src/types/primary-tool-state.ts +0 -12
  150. package/src/types/root.ts +0 -7
  151. package/src/types/system-state.ts +0 -7
  152. package/src/types/target-state.ts +0 -11
  153. package/tsconfig.json +0 -17
  154. /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()
@@ -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 { subscribeToUpdateKeyState } from '@asyra/reactive-events'
2
- import { KeyStateAPIs } from '../types'
3
-
4
- export const initKeyStateSubscribe = (apis: KeyStateAPIs) => {
5
- subscribeToUpdateKeyState(({ payload }) => {
6
- apis.updateKeyState(payload)
7
- })
8
- }
@@ -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,3 +0,0 @@
1
- export const initSystemStateSubscribe = () => {
2
- // TODO: add SystemMode and FeatureFlags
3
- }
@@ -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
- }
@@ -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
- }
@@ -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'
@@ -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
@@ -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,7 +0,0 @@
1
- import { SystemContextSnapshot } from '@asyra/utils'
2
-
3
- export interface RootRawAPIs {
4
- getSystemContextSnapshot: () => SystemContextSnapshot
5
- }
6
-
7
- export type RootAPIs = RootRawAPIs
@@ -1,7 +0,0 @@
1
- import { SystemMode } from '@asyra/utils'
2
-
3
- export interface SystemStateRawAPIs {
4
- getSystemMode: () => SystemMode
5
- }
6
-
7
- export type SystemStateAPIs = SystemStateRawAPIs
@@ -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
- }