@vyr/engine 0.0.33 → 0.0.34

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 (137) hide show
  1. package/package.json +6 -3
  2. package/src/ArrayUtils.ts +63 -65
  3. package/src/AsyncTask.ts +67 -71
  4. package/src/Category.ts +69 -86
  5. package/src/Color.ts +3 -111
  6. package/src/Engine.ts +12 -24
  7. package/src/Executor.ts +109 -0
  8. package/src/Generate.ts +23 -40
  9. package/src/InputSystem.ts +106 -108
  10. package/src/Listener.ts +58 -59
  11. package/src/ObjectPool.ts +83 -84
  12. package/src/ObjectUtils.ts +97 -49
  13. package/src/Scriptable.ts +82 -0
  14. package/src/Serialization.ts +4 -6
  15. package/src/Traverser.ts +41 -39
  16. package/src/actor/Actor.ts +23 -27
  17. package/src/actor/AnimationUnitActor.ts +22 -36
  18. package/src/actor/DivActor.ts +21 -41
  19. package/src/actor/FragmentActor.ts +1 -5
  20. package/src/actor/HTMLActor.ts +81 -0
  21. package/src/actor/HTMLServiceActor.ts +49 -0
  22. package/src/actor/{HTMTransformControllerActor.ts → HTMLTransformControllerActor.ts} +178 -71
  23. package/src/actor/InputActor.ts +50 -0
  24. package/src/actor/TextActor.ts +51 -0
  25. package/src/actor/index.ts +6 -5
  26. package/src/asset/Asset.ts +23 -68
  27. package/src/asset/AssetGraph.ts +21 -28
  28. package/src/descriptor/AnimationUnit.ts +81 -0
  29. package/src/descriptor/Camera.ts +12 -0
  30. package/src/descriptor/Controller.ts +6 -0
  31. package/src/descriptor/Descriptor.ts +133 -113
  32. package/src/descriptor/Div.ts +29 -0
  33. package/src/descriptor/HTML.ts +22 -0
  34. package/src/descriptor/HTMLService.ts +42 -0
  35. package/src/descriptor/HTMLTransformController.ts +67 -0
  36. package/src/descriptor/Input.ts +29 -0
  37. package/src/descriptor/Interaction.ts +80 -0
  38. package/src/descriptor/Node.ts +98 -0
  39. package/src/descriptor/Scene.ts +110 -0
  40. package/src/descriptor/Service.ts +11 -0
  41. package/src/descriptor/Store.ts +136 -0
  42. package/src/descriptor/Text.ts +36 -0
  43. package/src/descriptor/index.ts +14 -15
  44. package/src/graphics/Collection.ts +1 -5
  45. package/src/graphics/Compilation.ts +15 -19
  46. package/src/graphics/Graphics.ts +41 -54
  47. package/src/graphics/Observer.ts +6 -14
  48. package/src/graphics/Unit.ts +3 -9
  49. package/src/graphics/VariableProxy.ts +11 -15
  50. package/src/index.ts +5 -5
  51. package/src/interpreter/AnimationUnitInterpreter.ts +7 -9
  52. package/src/interpreter/DivInterpreter.ts +10 -13
  53. package/src/interpreter/FragmentInterpreter.ts +2 -6
  54. package/src/interpreter/HTMLServiceInterpreter.ts +25 -15
  55. package/src/interpreter/HTMLTransformControllerInterpreter.ts +9 -12
  56. package/src/interpreter/InputInterpreter.ts +41 -0
  57. package/src/interpreter/Interpreter.ts +3 -4
  58. package/src/interpreter/SceneInterpreter.ts +93 -0
  59. package/src/interpreter/ServiceInterpreter.ts +8 -15
  60. package/src/interpreter/StoreInterpreter.ts +7 -0
  61. package/src/interpreter/TextInterpreter.ts +41 -0
  62. package/src/interpreter/index.ts +5 -7
  63. package/src/locale/Language.ts +1 -5
  64. package/src/locale/LanguageProvider.ts +164 -21
  65. package/src/math/Euler.ts +2 -5
  66. package/src/math/Matrix4.ts +2 -4
  67. package/src/math/Quaternion.ts +2 -4
  68. package/src/math/Vector2.ts +4 -4
  69. package/src/math/Vector3.ts +2 -4
  70. package/src/math/utils.ts +1 -5
  71. package/src/schema/AnimationUnit.ts +68 -0
  72. package/src/schema/Asset.ts +13 -0
  73. package/src/schema/Descriptor.ts +41 -0
  74. package/src/schema/HTML.ts +261 -0
  75. package/src/schema/Interaction.ts +50 -0
  76. package/src/schema/Scene.ts +138 -0
  77. package/src/schema/Store.ts +8 -0
  78. package/src/schema/index.ts +7 -0
  79. package/src/scripts/ConditionScriptable.ts +196 -0
  80. package/src/scripts/FetchScriptable.ts +51 -0
  81. package/src/scripts/FindScriptable.ts +23 -0
  82. package/src/scripts/InvokeScriptable.ts +13 -0
  83. package/src/scripts/SwitchSceneScriptable.ts +18 -0
  84. package/src/scripts/UpdateScriptable.ts +60 -0
  85. package/src/scripts/index.ts +6 -0
  86. package/src/utils/AssetProvider.ts +4 -77
  87. package/src/utils/DOM.ts +37 -0
  88. package/src/utils/HTML.ts +5 -0
  89. package/src/utils/Service.ts +40 -0
  90. package/src/utils/constants.ts +1 -5
  91. package/src/utils/http.ts +2 -21
  92. package/src/utils/index.ts +3 -1
  93. package/src/actor/HTMActor.ts +0 -169
  94. package/src/actor/HTMServiceActor.ts +0 -57
  95. package/src/actor/StyleActor.ts +0 -96
  96. package/src/descriptor/AnimationUnitDescriptor.ts +0 -65
  97. package/src/descriptor/CameraDescriptor.ts +0 -12
  98. package/src/descriptor/ControllerDescriptor.ts +0 -16
  99. package/src/descriptor/DatasetDescriptor.ts +0 -90
  100. package/src/descriptor/DivDescriptor.ts +0 -18
  101. package/src/descriptor/DynamicDescriptor.ts +0 -27
  102. package/src/descriptor/HTMLDescriptor.ts +0 -87
  103. package/src/descriptor/HTMLServiceDescriptor.ts +0 -19
  104. package/src/descriptor/HTMLTransformControllerDescriptor.ts +0 -34
  105. package/src/descriptor/NodeDescriptor.ts +0 -32
  106. package/src/descriptor/PrefabDescriptor.ts +0 -53
  107. package/src/descriptor/PrefabInstanceDescriptor.ts +0 -32
  108. package/src/descriptor/ServiceDescriptor.ts +0 -32
  109. package/src/descriptor/ServiceSchedulerDescriptor.ts +0 -32
  110. package/src/descriptor/StyleDescriptor.ts +0 -213
  111. package/src/interaction/InteractionDescriptor.ts +0 -96
  112. package/src/interaction/InteractionExecutor.ts +0 -84
  113. package/src/interaction/Scriptable.ts +0 -44
  114. package/src/interaction/index.ts +0 -3
  115. package/src/interpreter/DatasetInterpreter.ts +0 -11
  116. package/src/interpreter/DynamicInterpreter.ts +0 -207
  117. package/src/interpreter/PrefaInterpreter.ts +0 -11
  118. package/src/interpreter/PrefabInstanceInterpreter.ts +0 -12
  119. package/src/interpreter/ServiceSchedulerInterpreter.ts +0 -42
  120. package/src/interpreter/StyleInterpreter.ts +0 -66
  121. package/src/preset/execute/dataset/index.ts +0 -1
  122. package/src/preset/execute/dataset/update.ts +0 -51
  123. package/src/preset/execute/graphics/index.ts +0 -1
  124. package/src/preset/execute/graphics/invoke.ts +0 -48
  125. package/src/preset/execute/index.ts +0 -4
  126. package/src/preset/execute/net/http.ts +0 -52
  127. package/src/preset/execute/net/index.ts +0 -1
  128. package/src/preset/execute/scheduler/index.ts +0 -1
  129. package/src/preset/execute/scheduler/switch.ts +0 -46
  130. package/src/preset/index.ts +0 -7
  131. package/src/preset/interaction/graphics/index.ts +0 -1
  132. package/src/preset/interaction/graphics/invoke.ts +0 -27
  133. package/src/preset/interaction/index.ts +0 -2
  134. package/src/preset/interaction/scheduler/index.ts +0 -1
  135. package/src/preset/interaction/scheduler/switch.ts +0 -27
  136. package/src/setup/index.ts +0 -17
  137. package/src/utils/compile.ts +0 -50
@@ -1,27 +1,27 @@
1
1
  import { Engine } from "../Engine";
2
2
  import { Graphics, TickArgs } from "./Graphics";
3
3
  import { Asset } from "../asset";
4
- import { AnimationUnitDescriptor, ServiceSchedulerDescriptor } from "../descriptor";
4
+ import { AnimationUnit, Scene } from "../descriptor";
5
5
 
6
- class Compilation {
6
+ export class Compilation {
7
7
  private collection = new Map<string, Graphics>()
8
8
 
9
- get(scheduler: ServiceSchedulerDescriptor) {
10
- return (this.collection.get(scheduler.uuid) ?? null) as Graphics
9
+ get(scene: Scene) {
10
+ return (this.collection.get(scene.uuid) ?? null) as Graphics
11
11
  }
12
12
 
13
- delete(scheduler: ServiceSchedulerDescriptor) {
14
- const graphics = this.collection.get(scheduler.uuid)
13
+ delete(scene: Scene) {
14
+ const graphics = this.collection.get(scene.uuid)
15
15
  if (graphics === undefined) return
16
16
  graphics.unlisten()
17
- this.collection.delete(scheduler.uuid)
17
+ this.collection.delete(scene.uuid)
18
18
  }
19
19
 
20
- ensureExists(url: string, scheduler: ServiceSchedulerDescriptor, engine: Engine) {
21
- let graphics = this.collection.get(scheduler.uuid)
20
+ ensureExists(url: string, scene: Scene, engine: Engine) {
21
+ let graphics = this.collection.get(scene.uuid)
22
22
  if (graphics === undefined) {
23
- graphics = new Graphics(url, scheduler, engine)
24
- this.collection.set(scheduler.uuid, graphics)
23
+ graphics = new Graphics(url, scene, engine)
24
+ this.collection.set(scene.uuid, graphics)
25
25
  }
26
26
  return graphics
27
27
  }
@@ -30,8 +30,8 @@ class Compilation {
30
30
  graphics.listen()
31
31
  }
32
32
 
33
- unlisten(scheduler: ServiceSchedulerDescriptor) {
34
- this.delete(scheduler)
33
+ unlisten(scene: Scene) {
34
+ this.delete(scene)
35
35
  }
36
36
 
37
37
  foreach(executor: (graphics: Graphics) => void) {
@@ -50,7 +50,7 @@ class Compilation {
50
50
  graphics.clear()
51
51
  })
52
52
 
53
- engine.trigger(AnimationUnitDescriptor.type, args)
53
+ engine.trigger(AnimationUnit.type, args)
54
54
 
55
55
  this.foreach((graphics) => graphics.beforeRender())
56
56
 
@@ -64,11 +64,7 @@ class Compilation {
64
64
  clear() {
65
65
  const collection = this.collection.values()
66
66
  for (const graphics of collection) {
67
- this.unlisten(graphics.scheduler)
67
+ this.unlisten(graphics.scene)
68
68
  }
69
69
  }
70
- }
71
-
72
- export {
73
- Compilation
74
70
  }
@@ -1,30 +1,30 @@
1
1
  import { language } from '../locale'
2
2
  import { ArrayUtils } from "../ArrayUtils";
3
3
  import { Asset, Dependencide } from "../asset";
4
- import { DatasetDescriptor, Descriptor, HTMLDescriptor, HTMLServiceDescriptor, ServiceDescriptor, ServiceSchedulerDescriptor } from "../descriptor";
4
+ import { Descriptor, HTMLService, Service, Scene, Interaction } from "../descriptor";
5
5
  import { privateState } from "../interpreter/Interpreter";
6
- import { Interpreter, ServiceInterpreter, ServiceSchedulerInterpreter } from "../interpreter";
6
+ import { Interpreter, ServiceInterpreter, SceneInterpreter } from "../interpreter";
7
7
  import { observer, UpdateDepsWatcherArgs, UpdateWatcherArgs, WatcherArgs } from "./Observer";
8
8
  import { Operation, Queue, Unit } from "./Unit";
9
9
  import { Actor } from '../actor/Actor';
10
+ import { HTMLActor } from '../actor/HTMLActor';
10
11
  import { UnitCollection } from "./Collection";
11
12
  import { VariableProxy } from "./VariableProxy";
12
13
  import { Engine } from '../Engine';
13
- import { InteractionDescriptor } from '../interaction';
14
+ import { isService, isHTML } from '../utils';
14
15
 
15
- interface TickArgs {
16
+ export interface TickArgs {
16
17
  delta: number
17
18
  }
18
19
 
19
- interface PickupObject {
20
+ export interface PickupObject {
20
21
  [k: string]: any
21
22
  uuid: string
22
- generatedBy: string
23
23
  }
24
24
 
25
- type OverrideUpdate = (descriptor: Descriptor, interpreter: Interpreter) => void
25
+ export type OverrideUpdate = (descriptor: Descriptor, interpreter: Interpreter) => void
26
26
 
27
- class Graphics {
27
+ export class Graphics {
28
28
  static createInterpreter<T extends Interpreter = Interpreter>(descriptor: Descriptor, graphics: Graphics) {
29
29
  const Class = Interpreter.getClass(descriptor.type)
30
30
  if (Class === null) throw new Error(language.get('graphics.interpreter.notRegister', { type: descriptor.type }))
@@ -43,7 +43,7 @@ class Graphics {
43
43
  private readonly _assetCollection = new Map<string, Unit>()
44
44
  private readonly _freeCollection = new Map<string, Unit>()
45
45
  private readonly _dependencide = new Dependencide()
46
- private readonly _services: ServiceDescriptor[] = []
46
+ private readonly _services: Service[] = []
47
47
  private readonly _freeQueue: Unit[] = []
48
48
  private _currentCamera = ''
49
49
  private _currentArgs: TickArgs = { delta: 0 }
@@ -55,12 +55,12 @@ class Graphics {
55
55
  }
56
56
  readonly unitCollection = new UnitCollection()
57
57
  readonly variableProxy = new VariableProxy()
58
- readonly scheduler: ServiceSchedulerDescriptor
58
+ readonly scene: Scene
59
59
  readonly engine: Engine
60
60
  readonly url: string
61
61
 
62
- constructor(url: string, scheduler: ServiceSchedulerDescriptor, engine: Engine) {
63
- this.scheduler = scheduler
62
+ constructor(url: string, scene: Scene, engine: Engine) {
63
+ this.scene = scene
64
64
  this.engine = engine
65
65
  this.url = url
66
66
  }
@@ -83,17 +83,17 @@ class Graphics {
83
83
  }
84
84
  })
85
85
 
86
- const descriptor = this.variableProxy.get<ServiceSchedulerDescriptor>(this.scheduler.uuid, this)
87
- const interpreter = this.getInterpreter<ServiceSchedulerInterpreter>(descriptor)
86
+ const descriptor = this.variableProxy.get<Scene>(this.scene.uuid, this)
87
+ const interpreter = this.getInterpreter<SceneInterpreter>(descriptor)
88
88
  interpreter.install(descriptor)
89
89
  }
90
90
 
91
91
  unlisten() {
92
- const descriptor = this.variableProxy.get<ServiceSchedulerDescriptor>(this.scheduler.uuid, this)
93
- const interpreter = this.getInterpreter<ServiceSchedulerInterpreter>(descriptor)
92
+ const descriptor = this.variableProxy.get<Scene>(this.scene.uuid, this)
93
+ const interpreter = this.getInterpreter<SceneInterpreter>(descriptor)
94
94
  interpreter.uninstall(descriptor)
95
95
 
96
- const master = this.unitCollection.get(this.scheduler.uuid)
96
+ const master = this.unitCollection.get(this.scene.uuid)
97
97
  const assets = [...this._assetCollection.values()]
98
98
  if (master !== undefined) assets.push(master)
99
99
 
@@ -152,7 +152,7 @@ class Graphics {
152
152
  asset.queue.iterator(operation => this.do(operation))
153
153
  }
154
154
 
155
- const master = this.unitCollection.get(this.scheduler.uuid)
155
+ const master = this.unitCollection.get(this.scene.uuid)
156
156
  if (master === undefined) return
157
157
 
158
158
  master.queue.iterator(operation => this.do(operation))
@@ -173,7 +173,7 @@ class Graphics {
173
173
 
174
174
  clear() {
175
175
  for (const service of this._services) {
176
- const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
176
+ const descriptor = this.variableProxy.get<Service>(service.uuid, this)
177
177
  const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
178
178
  interpreter.clear(descriptor)
179
179
  }
@@ -181,7 +181,7 @@ class Graphics {
181
181
 
182
182
  beforeRender() {
183
183
  for (const service of this._services) {
184
- const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
184
+ const descriptor = this.variableProxy.get<Service>(service.uuid, this)
185
185
  const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
186
186
  interpreter.beforeRender(descriptor)
187
187
  }
@@ -189,7 +189,7 @@ class Graphics {
189
189
 
190
190
  render() {
191
191
  for (const service of this._services) {
192
- const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
192
+ const descriptor = this.variableProxy.get<Service>(service.uuid, this)
193
193
  const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
194
194
  interpreter.render(descriptor)
195
195
  }
@@ -197,7 +197,7 @@ class Graphics {
197
197
 
198
198
  afterRender() {
199
199
  for (const service of this._services) {
200
- const descriptor = this.variableProxy.get<ServiceDescriptor>(service.uuid, this)
200
+ const descriptor = this.variableProxy.get<Service>(service.uuid, this)
201
201
  const interpreter = this.getInterpreter<ServiceInterpreter>(descriptor)
202
202
  interpreter.afterRender(descriptor)
203
203
  }
@@ -296,8 +296,8 @@ class Graphics {
296
296
  }
297
297
 
298
298
  private updateStaticAsset() {
299
- if (this.scheduler.camera !== this._currentCamera) {
300
- const descriptor = Descriptor.get<Descriptor>(this.scheduler.camera)
299
+ if (this.scene.camera !== this._currentCamera) {
300
+ const descriptor = Descriptor.get<Descriptor>(this.scene.camera)
301
301
  if (descriptor === null) return
302
302
  const oldNode = this.unitCollection.get(this._currentCamera)
303
303
  if (oldNode) {
@@ -308,7 +308,7 @@ class Graphics {
308
308
  const newNode = new Unit(descriptor.uuid, '', new Queue(Asset.createVirtualUrl('graphics/camera.ts')))
309
309
  this.unitCollection.set(newNode)
310
310
  ArrayUtils.insert(this._staticAssetQueue, newNode)
311
- this._currentCamera = this.scheduler.camera
311
+ this._currentCamera = this.scene.camera
312
312
  }
313
313
  }
314
314
 
@@ -331,7 +331,7 @@ class Graphics {
331
331
  const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
332
332
  const interpreter = this.getInterpreter(descriptor)
333
333
 
334
- if (descriptor instanceof ServiceDescriptor) ArrayUtils.insert(this._services, descriptor)
334
+ if (isService(descriptor)) ArrayUtils.insert(this._services, descriptor)
335
335
 
336
336
  interpreter.mount(descriptor, parentInterpreter, parentDescriptor)
337
337
  }
@@ -343,7 +343,7 @@ class Graphics {
343
343
  const descriptor = this.variableProxy.get<Descriptor>(unit.uuid, this)
344
344
  const interpreter = this.getInterpreter(descriptor)
345
345
 
346
- if (descriptor instanceof ServiceDescriptor) ArrayUtils.remove(this._services, descriptor)
346
+ if (isService(descriptor)) ArrayUtils.remove(this._services, descriptor)
347
347
 
348
348
  interpreter.unmount(descriptor, parentInterpreter, parentDescriptor)
349
349
  }
@@ -408,26 +408,19 @@ class Graphics {
408
408
  interpreter.pickup(target, result)
409
409
  }
410
410
  private _pickupScene(result: PickupObject[]) {
411
- const master = this.unitCollection.get(this.scheduler.uuid)
411
+ const master = this.unitCollection.get(this.scene.uuid)
412
412
  if (master === undefined) return result
413
413
 
414
414
  const units = this.unitCollection.values()
415
415
  for (const unit of units) {
416
416
  const descriptor = Descriptor.get<Descriptor>(unit.uuid)
417
- if (descriptor instanceof HTMLDescriptor) continue
417
+ if (isHTML(descriptor)) continue
418
418
  this._pickupItem(descriptor, result)
419
419
  }
420
420
  }
421
421
 
422
- getMouseAndRect(event: MouseEvent) {
423
- //@ts-ignore
424
- const rect = event.target.getBoundingClientRect()
425
- const mouse = { x: event.clientX - rect.left, y: event.clientY - rect.top }
426
- return { mouse, rect }
427
- }
428
-
429
- traceService(target: Descriptor): ServiceDescriptor | null {
430
- if (target instanceof ServiceDescriptor) return target
422
+ traceService(target: Descriptor): Service | null {
423
+ if (isService(target)) return target
431
424
 
432
425
  const parent = this.getParent(target.uuid)
433
426
  if (parent === null) return null
@@ -435,19 +428,18 @@ class Graphics {
435
428
  return this.traceService(parent)
436
429
  }
437
430
 
438
- pickup(event: MouseEvent) {
431
+ pickup(x: number, y: number, trigger: Element) {
439
432
  const result: PickupObject[] = []
440
-
441
- const isElement = event.target instanceof Element
442
- if (isElement === false) return result
443
- const uuid = event.target.getAttribute('data-vyr-uuid')
433
+ const uuid = trigger.getAttribute(HTMLActor.uuidKey)
444
434
  if (uuid === null) return result
445
435
 
446
- const { mouse, rect } = this.getMouseAndRect(event)
436
+ //@ts-ignore
437
+ const rect = trigger.getBoundingClientRect()
438
+ const mouse = { x: x - rect.left, y: y - rect.top }
447
439
  const target = Descriptor.get<Descriptor>(uuid)
448
- const args = { delta: 0 }
449
- if (target instanceof ServiceDescriptor) {
450
- if (target instanceof HTMLServiceDescriptor) {
440
+
441
+ if (isService(target)) {
442
+ if (target instanceof HTMLService) {
451
443
  this._pickupItem(target, result)
452
444
  } else {
453
445
  const interpreter = this.getInterpreter<ServiceInterpreter>(target)
@@ -466,8 +458,8 @@ class Graphics {
466
458
  if (descriptor.interactions.length === 0) return
467
459
  for (const inter of descriptor.interactions) {
468
460
  if (inter.type === interaction) {
469
- const current = Asset.get<InteractionDescriptor>(inter.url)
470
- if (current !== null) await current.execute(inter.inputs, this, descriptor)
461
+ const current = Asset.get<Interaction>(inter.url)
462
+ if (current !== null) await current.execute(inter.nodes, this, descriptor.uuid)
471
463
  break
472
464
  }
473
465
  }
@@ -481,8 +473,3 @@ class Graphics {
481
473
  }
482
474
  }
483
475
 
484
- export {
485
- PickupObject,
486
- TickArgs,
487
- Graphics,
488
- }
@@ -1,23 +1,23 @@
1
1
  import { Listener } from "../Listener"
2
2
 
3
- interface WatcherArgs {
3
+ export interface WatcherArgs {
4
4
  self: string
5
5
  puid: string
6
6
  }
7
7
 
8
- interface UpdateWatcherArgs {
8
+ export interface UpdateWatcherArgs {
9
9
  self: string
10
10
  }
11
11
 
12
- interface UpdateDepsWatcherArgs {
12
+ export interface UpdateDepsWatcherArgs {
13
13
  self: string
14
14
  }
15
15
 
16
- interface FreeWatcherArgs {
16
+ export interface FreeWatcherArgs {
17
17
  self: string
18
18
  }
19
19
 
20
- interface Observer {
20
+ export interface Observer {
21
21
  add(args: WatcherArgs): void
22
22
  remove(args: WatcherArgs): void
23
23
  update(args: UpdateWatcherArgs): void
@@ -25,12 +25,4 @@ interface Observer {
25
25
  free(args: FreeWatcherArgs): void
26
26
  }
27
27
 
28
- const observer = new Listener<Observer>()
29
-
30
- export {
31
- WatcherArgs,
32
- UpdateWatcherArgs,
33
- UpdateDepsWatcherArgs,
34
- FreeWatcherArgs,
35
- observer,
36
- }
28
+ export const observer = new Listener<Observer>()
@@ -1,11 +1,11 @@
1
1
  import { ArrayUtils } from "../ArrayUtils"
2
2
 
3
- interface Operation {
3
+ export interface Operation {
4
4
  type: number
5
5
  unit: Unit
6
6
  }
7
7
 
8
- class Queue {
8
+ export class Queue {
9
9
  static readonly Add = 1
10
10
  static readonly Remove = 2
11
11
  static readonly Update = 3
@@ -50,7 +50,7 @@ class Queue {
50
50
  }
51
51
  }
52
52
 
53
- class Unit {
53
+ export class Unit {
54
54
  uuid: string
55
55
  parent: string
56
56
  queue: Queue
@@ -74,10 +74,4 @@ class Unit {
74
74
  break
75
75
  }
76
76
  }
77
- }
78
-
79
- export {
80
- Operation,
81
- Queue,
82
- Unit,
83
77
  }
@@ -1,14 +1,14 @@
1
+ import { VariabConfig } from "../schema";
1
2
  import { ObjectUtils } from "../ObjectUtils";
2
- import { Asset } from "../asset";
3
- import { Scriptable, ScriptableArgs } from "../interaction/Scriptable";
4
- import { Data, DatasetDescriptor, Descriptor, VariabConfig } from "../descriptor";
3
+ import { Scriptable } from "../Scriptable";
4
+ import { Data, Store, Descriptor } from "../descriptor";
5
5
  import { Graphics } from "./Graphics";
6
6
 
7
7
  interface ActorCollection { [k: string]: any }
8
8
 
9
- interface Variables { [k: string]: any }
9
+ export interface Variables { [k: string]: any }
10
10
 
11
- class VariableProxy {
11
+ export class VariableProxy {
12
12
  private readonly proxyCollection = new Map<Descriptor, any>()
13
13
  private readonly variablesCollection = new Map<Descriptor, Variables>()
14
14
 
@@ -26,7 +26,7 @@ class VariableProxy {
26
26
 
27
27
  const value = Reflect.get(target, prop)
28
28
 
29
- if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
29
+ if (ObjectUtils.isObject(value) && !Array.isArray(value)) {
30
30
  return this.createNestedProxy(value, root, fullPath)
31
31
  }
32
32
 
@@ -38,10 +38,9 @@ class VariableProxy {
38
38
  if (config.type === 'key') {
39
39
  return ObjectUtils.getValueByKey(data, config.value)
40
40
  } else if (config.type === 'custom') {
41
- const scriptable = Asset.get<Scriptable<ScriptableArgs<undefined, undefined, undefined>>>(config.value)
41
+ const scriptable = Scriptable.use(config.value)
42
42
  if (scriptable === null) return
43
- const currentArgs = { key, config, data, input: undefined, result: undefined, trigger: descriptor }
44
- return scriptable.execute(graphics, currentArgs)
43
+ return scriptable.execute(graphics, descriptor.uuid, { key, config, data })
45
44
  }
46
45
  }
47
46
 
@@ -56,14 +55,15 @@ class VariableProxy {
56
55
  variables = Object.create(null) as Variables
57
56
  variables.version = 0
58
57
 
59
- const data = DatasetDescriptor.getData(descriptor.dataset)
58
+ const data = Store.getData(descriptor.store)
60
59
 
61
60
  if (data !== null) {
62
61
  const keys = Object.keys(descriptor.variables)
63
62
  for (const key of keys) {
64
63
  const variable = descriptor.variables[key]
65
64
  if (variable.enabled === false) continue
66
- const value = this.getVariableValue(descriptor, data, key, variable, graphics)
65
+
66
+ const value = this.getVariableValue(descriptor, descriptor, key, variable, graphics)
67
67
  if (value === undefined) continue
68
68
  variables[key] = value
69
69
  }
@@ -86,7 +86,3 @@ class VariableProxy {
86
86
  }
87
87
  }
88
88
 
89
- export {
90
- Variables,
91
- VariableProxy
92
- }
package/src/index.ts CHANGED
@@ -6,22 +6,22 @@ export * from './locale'
6
6
  export * from './math'
7
7
  export * from './Color'
8
8
  export * from './Serialization'
9
- export { Category } from './Category'
9
+ export { Category, Suffix } from './Category'
10
10
  export { ArrayUtils } from './ArrayUtils'
11
11
  export { ObjectUtils } from './ObjectUtils'
12
12
  export { Generate } from './Generate'
13
13
  export { Traverser } from './Traverser'
14
14
  export { Listener } from './Listener'
15
15
  export { InputSystem } from './InputSystem'
16
- export { destroyInstance } from './ObjectPool'
16
+ export { ObjectPool, destroyInstance } from './ObjectPool'
17
17
  export * from './AsyncTask'
18
- export * from './interaction/Scriptable'
19
- export * from './interaction'
18
+ export * from './schema'
20
19
  export * from './descriptor'
21
20
  export * from './interpreter'
21
+ export * from './Scriptable'
22
+ export * from './scripts'
22
23
  export * from './utils'
23
24
  export * from './actor'
24
25
  export * from './graphics'
25
26
  export * from './asset'
26
- export * from './preset'
27
27
  export * from './Engine'
@@ -1,4 +1,4 @@
1
- import { AnimationUnitDescriptor, Descriptor } from '../descriptor';
1
+ import { AnimationUnit, Descriptor } from '../descriptor';
2
2
  import { ArrayUtils } from '../ArrayUtils';
3
3
  import { Interpreter } from './Interpreter'
4
4
  import { AnimationUnitActor } from "../actor";
@@ -7,8 +7,8 @@ const privateState = {
7
7
  collection: [] as AnimationUnitActor[],
8
8
  }
9
9
 
10
- class AnimationUnitInterpreter extends Interpreter {
11
- static type = AnimationUnitDescriptor.type
10
+ export class AnimationUnitInterpreter extends Interpreter {
11
+ static type = AnimationUnit.type
12
12
  static enabled = true
13
13
  static reset(time = 0) {
14
14
  const enabled = AnimationUnitInterpreter.enabled
@@ -29,12 +29,12 @@ class AnimationUnitInterpreter extends Interpreter {
29
29
  }
30
30
 
31
31
 
32
- update(descriptor: AnimationUnitDescriptor) {
32
+ update(descriptor: AnimationUnit) {
33
33
  super.update(descriptor)
34
34
 
35
35
  this.freeUnit()
36
36
 
37
- const parentDescriptor = AnimationUnitDescriptor.get<AnimationUnitDescriptor>(this.unit.parent)
37
+ const parentDescriptor = AnimationUnit.get<AnimationUnit>(this.unit.parent)
38
38
  if (parentDescriptor === null) return
39
39
 
40
40
  this.animationUnit = AnimationUnitActor.parse(descriptor)
@@ -43,11 +43,9 @@ class AnimationUnitInterpreter extends Interpreter {
43
43
  this.animationUnit.listen(this.graphics)
44
44
  }
45
45
 
46
- unmount(descriptor: AnimationUnitDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
46
+ unmount(descriptor: AnimationUnit, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
47
47
  this.freeUnit()
48
48
  super.unmount(descriptor, parentInterpreter, parentDescriptor)
49
49
  }
50
50
  }
51
- Interpreter.register(AnimationUnitInterpreter)
52
-
53
- export { AnimationUnitInterpreter }
51
+ Interpreter.register(AnimationUnitInterpreter)
@@ -1,22 +1,22 @@
1
- import { Descriptor, DivDescriptor } from "../descriptor"
1
+ import { Descriptor, Div } from "../descriptor"
2
2
  import { Interpreter } from "./Interpreter"
3
3
  import { DivActor, HTMLActor } from "../actor"
4
4
  import { PickupObject } from "../graphics"
5
5
 
6
- class DivInterpreter extends Interpreter {
7
- static type = DivDescriptor.type
6
+ export class DivInterpreter extends Interpreter {
7
+ static type = Div.type
8
8
 
9
- protected createActor(descriptor: DivDescriptor) {
9
+ protected createActor(descriptor: Div) {
10
10
  return new DivActor(descriptor.uuid)
11
11
  }
12
12
 
13
- update(descriptor: DivDescriptor) {
13
+ update(descriptor: Div) {
14
14
  super.update(descriptor)
15
15
  const actor = this.getActor<DivActor>(descriptor)
16
16
  actor.update(descriptor)
17
17
  }
18
18
 
19
- mount(descriptor: DivDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
19
+ mount(descriptor: Div, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
20
  super.mount(descriptor, parentInterpreter, parentDescriptor)
21
21
  const actor = this.getActor<DivActor>(descriptor)
22
22
 
@@ -24,9 +24,8 @@ class DivInterpreter extends Interpreter {
24
24
  parenActor.add(actor)
25
25
  }
26
26
 
27
- unmount(descriptor: DivDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
27
+ unmount(descriptor: Div, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
28
28
  const actor = this.getActor<DivActor>(descriptor)
29
- actor.clearStyleClass(actor.DOM)
30
29
  actor.cleanInteraction()
31
30
 
32
31
  const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
@@ -35,10 +34,8 @@ class DivInterpreter extends Interpreter {
35
34
  super.unmount(descriptor, parentInterpreter, parentDescriptor)
36
35
  }
37
36
 
38
- pickup(descriptor: DivDescriptor, result: PickupObject[]) {
39
- result.push({ uuid: descriptor.uuid, generatedBy: descriptor.generatedBy })
37
+ pickup(descriptor: Div, result: PickupObject[]) {
38
+ result.push({ uuid: descriptor.uuid })
40
39
  }
41
40
  }
42
- Interpreter.register(DivInterpreter)
43
-
44
- export { DivInterpreter }
41
+ Interpreter.register(DivInterpreter)
@@ -2,7 +2,7 @@ import { FragmentActor } from "../actor";
2
2
  import { Descriptor } from "../descriptor";
3
3
  import { Interpreter } from "./Interpreter";
4
4
 
5
- class FragmentInterpreter extends Interpreter {
5
+ export class FragmentInterpreter extends Interpreter {
6
6
  static type = Descriptor.type
7
7
 
8
8
  protected createActor(descriptor: Descriptor) {
@@ -27,8 +27,4 @@ class FragmentInterpreter extends Interpreter {
27
27
  super.free(descriptor)
28
28
  }
29
29
  }
30
- Interpreter.register(FragmentInterpreter)
31
-
32
- export {
33
- FragmentInterpreter
34
- }
30
+ Interpreter.register(FragmentInterpreter)