@vyr/engine 0.0.1 → 0.0.2

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 (56) hide show
  1. package/package.json +1 -19
  2. package/src/Category.ts +7 -7
  3. package/src/Engine.ts +12 -12
  4. package/src/actor/AnimationUnitActor.ts +3 -3
  5. package/src/actor/DivActor.ts +6 -6
  6. package/src/actor/FragmentActor.ts +3 -3
  7. package/src/actor/HTMActor.ts +19 -16
  8. package/src/actor/HTMServiceActor.ts +4 -4
  9. package/src/actor/HTMTransformControllerActor.ts +15 -10
  10. package/src/asset/Asset.ts +9 -26
  11. package/src/asset/AssetGraph.ts +4 -4
  12. package/src/descriptor/DatasetDescriptor.ts +20 -22
  13. package/src/descriptor/Descriptor.ts +1 -28
  14. package/src/descriptor/HTMLTransformControllerDescriptor.ts +2 -2
  15. package/src/descriptor/index.ts +0 -1
  16. package/src/graphics/Compilation.ts +19 -30
  17. package/src/graphics/Graphics.ts +79 -66
  18. package/src/graphics/VariableProxy.ts +8 -8
  19. package/src/index.ts +2 -1
  20. package/src/interaction/InteractionDescriptor.ts +96 -0
  21. package/src/interaction/InteractionExecutor.ts +84 -0
  22. package/src/interaction/Scriptable.ts +40 -0
  23. package/src/interaction/index.ts +3 -0
  24. package/src/interpreter/AnimationUnitInterpreter.ts +5 -5
  25. package/src/interpreter/DivInterpreter.ts +15 -15
  26. package/src/interpreter/DynamicInterpreter.ts +9 -9
  27. package/src/interpreter/FragmentInterpreter.ts +10 -10
  28. package/src/interpreter/HTMLServiceInterpreter.ts +15 -15
  29. package/src/interpreter/HTMLTransformControllerInterpreter.ts +15 -15
  30. package/src/interpreter/Interpreter.ts +9 -9
  31. package/src/interpreter/ServiceInterpreter.ts +6 -6
  32. package/src/interpreter/ServiceSchedulerInterpreter.ts +6 -6
  33. package/src/interpreter/StyleInterpreter.ts +7 -7
  34. package/src/interpreter/index.ts +0 -1
  35. package/src/locale/LanguageProvider.ts +4 -2
  36. package/src/preset/execute/dataset/compile.ts +43 -0
  37. package/src/preset/execute/dataset/index.ts +2 -1
  38. package/src/preset/execute/dataset/update.ts +7 -8
  39. package/src/preset/execute/graphics/invoke.ts +5 -6
  40. package/src/preset/execute/net/{request.ts → http.ts} +7 -16
  41. package/src/preset/execute/net/index.ts +1 -1
  42. package/src/preset/execute/scheduler/switch.ts +7 -8
  43. package/src/preset/index.ts +2 -2
  44. package/src/preset/interaction/graphics/invoke.ts +27 -0
  45. package/src/preset/interaction/scheduler/switch.ts +27 -0
  46. package/src/utils/AssetProvider.ts +7 -6
  47. package/src/utils/constants.ts +10 -0
  48. package/src/utils/index.ts +1 -0
  49. package/src/Scriptable.ts +0 -27
  50. package/src/descriptor/RoutineDescriptor.ts +0 -54
  51. package/src/interpreter/RoutineInterpreter.ts +0 -88
  52. package/src/preset/routine/graphics/invoke.ts +0 -27
  53. package/src/preset/routine/scheduler/switch.ts +0 -27
  54. /package/src/preset/{routine → interaction}/graphics/index.ts +0 -0
  55. /package/src/preset/{routine → interaction}/index.ts +0 -0
  56. /package/src/preset/{routine → interaction}/scheduler/index.ts +0 -0
@@ -0,0 +1,84 @@
1
+ import { Asset } from "../asset"
2
+ import { Scriptable } from "./Scriptable"
3
+ import { InteractionDescriptor, InteractionInputCollection, InteractionNode } from "./InteractionDescriptor"
4
+ import { Graphics } from "../graphics/Graphics"
5
+
6
+ type ExecuteResult = { [k: string]: any } | null
7
+
8
+ class InteractionExecutor {
9
+ readonly collection = new Map<string, InteractionNode>()
10
+ readonly linkCollection = new Map<string, string[]>()
11
+
12
+ update(interaction: InteractionDescriptor) {
13
+ this.collection.clear()
14
+ this.linkCollection.clear()
15
+
16
+ for (const node of interaction.nodes) {
17
+ this.collection.set(node.id, node)
18
+ }
19
+
20
+ for (const mapper of interaction.mappers) {
21
+ let link = this.linkCollection.get(mapper.source)
22
+ if (link === undefined) {
23
+ link = []
24
+ this.linkCollection.set(mapper.source, link)
25
+ }
26
+ link.push(mapper.target)
27
+ }
28
+ }
29
+
30
+ async doBranch(branch: string, previous: string, customInputs: InteractionInputCollection, interaction: InteractionDescriptor, graphics: Graphics, result: Map<string, ExecuteResult>, trigger: any, otherArgs?: any) {
31
+ await this.doExecute(branch, previous, customInputs, interaction, graphics, result, trigger, otherArgs)
32
+ }
33
+
34
+ async doCondition(condition: string, previous: string, customInputs: InteractionInputCollection, interaction: InteractionDescriptor, graphics: Graphics, result: Map<string, ExecuteResult>, trigger: any, otherArgs?: any) {
35
+ const preResult = result.get(previous)
36
+ const conditionResult = result.get(condition)
37
+ if (preResult !== conditionResult?.condition.value) return
38
+
39
+ await this.doExecute(condition, previous, customInputs, interaction, graphics, result, trigger, otherArgs)
40
+ }
41
+
42
+ async doExecute(execute: string, previous: string, customInputs: InteractionInputCollection, interaction: InteractionDescriptor, graphics: Graphics, result: Map<string, ExecuteResult>, trigger: any, otherArgs?: any) {
43
+ const nexts = this.linkCollection.get(execute)
44
+ if (nexts === undefined) return
45
+
46
+ for (const next of nexts) {
47
+ await this.doNext(next, execute, customInputs, interaction, graphics, result, trigger, otherArgs)
48
+ }
49
+ }
50
+
51
+ async doNext(current: string, previous: string, customInputs: InteractionInputCollection, interaction: InteractionDescriptor, graphics: Graphics, result: Map<string, ExecuteResult>, trigger: any, otherArgs?: any) {
52
+ const active = this.collection.get(current)
53
+ if (active === undefined) return
54
+
55
+ const currentInput = customInputs[current] ?? {}
56
+ const script = Asset.get<Scriptable>(active.url)
57
+ if (script) {
58
+ const args = { input: { previous, default: active.input, user: currentInput }, result, trigger }
59
+ if (otherArgs) Object.assign(args, otherArgs)
60
+ const executeResult = await script.execute(graphics, args)
61
+ result.set(current, executeResult)
62
+ }
63
+
64
+ if (active.interaction === 'Branch') {
65
+ await this.doBranch(current, previous, customInputs, interaction, graphics, result, trigger, otherArgs)
66
+ } else if (active.interaction === 'Condition') {
67
+ if (result.has(current) === false) result.set(current, active.input)
68
+ await this.doCondition(current, previous, customInputs, interaction, graphics, result, trigger, otherArgs)
69
+ } else {
70
+ await this.doExecute(current, previous, customInputs, interaction, graphics, result, trigger, otherArgs)
71
+ }
72
+ }
73
+
74
+ async execute(customInputs: InteractionInputCollection, interaction: InteractionDescriptor, graphics: Graphics, trigger: any, otherArgs?: any) {
75
+ for (const root of interaction.roots) {
76
+ const resultCollection = new Map()
77
+ await this.doNext(root, '', customInputs, interaction, graphics, resultCollection, trigger, otherArgs)
78
+ }
79
+ }
80
+ }
81
+
82
+ export {
83
+ InteractionExecutor
84
+ }
@@ -0,0 +1,40 @@
1
+ import { Descriptor } from "../descriptor"
2
+ import { Graphics } from "../graphics/Graphics"
3
+ import { InteractionInput } from "./InteractionDescriptor";
4
+
5
+ interface ScriptableInput<T = InteractionInput> {
6
+ previous: string;
7
+ default: T,
8
+ user: T
9
+ }
10
+
11
+ interface ScriptableArgs<T = InteractionInput, R = Map<string, any>, I = ScriptableInput<T>> {
12
+ input: I,
13
+ result: R,
14
+ trigger: Descriptor
15
+ }
16
+
17
+ /**
18
+ * 可编程脚本(脚本不会在服务端实例化)
19
+ */
20
+ class Scriptable<T extends ScriptableArgs<any, any, any> = ScriptableArgs> {
21
+ readonly uuid
22
+ /**脚本文件的url路径 */
23
+ get url() {
24
+ return this.uuid
25
+ }
26
+
27
+ constructor(url: string) {
28
+ this.uuid = url
29
+ }
30
+
31
+ /**脚本的准备事件,该方法在脚本被实例化后立即执行
32
+ *
33
+ * 一般在该事件中进行脚本的准备工作,如从服务端获取资源或数据
34
+ */
35
+ async ready() { }
36
+
37
+ execute(graphics: Graphics, args: T): any { }
38
+ }
39
+
40
+ export { ScriptableArgs, Scriptable }
@@ -0,0 +1,3 @@
1
+ export * from './InteractionDescriptor'
2
+ export * from './InteractionExecutor'
3
+ export * from './Scriptable'
@@ -1,4 +1,4 @@
1
- import { AnimationUnitDescriptor, Descriptor, UpdateArgs } from '../descriptor';
1
+ import { AnimationUnitDescriptor, Descriptor } from '../descriptor';
2
2
  import { ArrayUtils } from '../ArrayUtils';
3
3
  import { Interpreter } from './Interpreter'
4
4
  import { AnimationUnitActor } from "../actor";
@@ -29,8 +29,8 @@ class AnimationUnitInterpreter extends Interpreter {
29
29
  }
30
30
 
31
31
 
32
- update(descriptor: AnimationUnitDescriptor, args: UpdateArgs) {
33
- super.update(descriptor, args)
32
+ update(descriptor: AnimationUnitDescriptor) {
33
+ super.update(descriptor)
34
34
 
35
35
  this.freeUnit()
36
36
 
@@ -43,9 +43,9 @@ class AnimationUnitInterpreter extends Interpreter {
43
43
  this.animationUnit.listen(this.graphics)
44
44
  }
45
45
 
46
- unmount(descriptor: AnimationUnitDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
46
+ unmount(descriptor: AnimationUnitDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
47
47
  this.freeUnit()
48
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
48
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
49
49
  }
50
50
  }
51
51
  Interpreter.register(AnimationUnitInterpreter)
@@ -1,4 +1,4 @@
1
- import { Descriptor, DivDescriptor, UpdateArgs } from "../descriptor"
1
+ import { Descriptor, DivDescriptor } from "../descriptor"
2
2
  import { Interpreter } from "./Interpreter"
3
3
  import { DivActor, HTMLActor } from "../actor"
4
4
  import { PickupObject } from "../graphics"
@@ -6,36 +6,36 @@ import { PickupObject } from "../graphics"
6
6
  class DivInterpreter extends Interpreter {
7
7
  static type = DivDescriptor.type
8
8
 
9
- protected createActor(descriptor: DivDescriptor, args: UpdateArgs) {
9
+ protected createActor(descriptor: DivDescriptor) {
10
10
  return new DivActor(descriptor.uuid)
11
11
  }
12
12
 
13
- update(descriptor: DivDescriptor, args: UpdateArgs) {
14
- super.update(descriptor, args)
15
- const actor = this.getActor<DivActor>(descriptor, args)
16
- actor.update(descriptor, args)
13
+ update(descriptor: DivDescriptor) {
14
+ super.update(descriptor)
15
+ const actor = this.getActor<DivActor>(descriptor)
16
+ actor.update(descriptor)
17
17
  }
18
18
 
19
- mount(descriptor: DivDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
- super.mount(descriptor, args, parentInterpreter, parentDescriptor)
21
- const actor = this.getActor<DivActor>(descriptor, args)
19
+ mount(descriptor: DivDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
21
+ const actor = this.getActor<DivActor>(descriptor)
22
22
 
23
- const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor, args)
23
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
24
24
  parenActor.add(actor)
25
25
  }
26
26
 
27
- unmount(descriptor: DivDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
28
- const actor = this.getActor<DivActor>(descriptor, args)
27
+ unmount(descriptor: DivDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
28
+ const actor = this.getActor<DivActor>(descriptor)
29
29
  actor.clearStyleClass(actor.DOM)
30
30
  actor.cleanInteraction()
31
31
 
32
- const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor, args)
32
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
33
33
  parenActor.remove(actor)
34
34
 
35
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
35
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
36
36
  }
37
37
 
38
- pickup(descriptor: DivDescriptor, args: UpdateArgs, result: PickupObject[]) {
38
+ pickup(descriptor: DivDescriptor, result: PickupObject[]) {
39
39
  result.push({ uuid: descriptor.uuid, generatedBy: descriptor.generatedBy })
40
40
  }
41
41
  }
@@ -1,6 +1,6 @@
1
1
  import { ArrayUtils } from "../ArrayUtils"
2
2
  import { Asset } from "../asset"
3
- import { DynamicDescriptor, Descriptor, UpdateArgs, Data, DatasetDescriptor, PrefabeDescriptor } from "../descriptor"
3
+ import { DynamicDescriptor, Descriptor, Data, DatasetDescriptor, PrefabeDescriptor } from "../descriptor"
4
4
  import { observer, UpdateWatcherArgs, WatcherArgs } from "../graphics"
5
5
  import { Category } from "../Category"
6
6
  import { FragmentInterpreter, Interpreter } from "."
@@ -158,18 +158,18 @@ class DynamicInterpreter extends FragmentInterpreter {
158
158
  this._cloneCollection.clear()
159
159
  }
160
160
 
161
- mount(descriptor: Descriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor): void {
162
- super.mount(descriptor, args, parentInterpreter, parentDescriptor)
161
+ mount(descriptor: Descriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor): void {
162
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
163
163
  observer.listen('update', this._clearByOnUpdate)
164
164
  }
165
165
 
166
- unmount(descriptor: Descriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
166
+ unmount(descriptor: Descriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
167
167
  observer.unlisten('update', this._clearByOnUpdate)
168
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
168
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
169
169
  }
170
170
 
171
- update(descriptor: DynamicDescriptor, args: UpdateArgs) {
172
- super.update(descriptor, args)
171
+ update(descriptor: DynamicDescriptor) {
172
+ super.update(descriptor)
173
173
 
174
174
  observer.unlisten('add', this._onAdd)
175
175
  observer.unlisten('remove', this._onRemove)
@@ -197,11 +197,11 @@ class DynamicInterpreter extends FragmentInterpreter {
197
197
  observer.listen('update', this._onUpdate)
198
198
  }
199
199
 
200
- free(descriptor: Descriptor, args: UpdateArgs) {
200
+ free(descriptor: Descriptor) {
201
201
  observer.unlisten('add', this._onAdd)
202
202
  observer.unlisten('remove', this._onRemove)
203
203
  observer.unlisten('update', this._onUpdate)
204
- super.free(descriptor, args)
204
+ super.free(descriptor)
205
205
  }
206
206
  }
207
207
  FragmentInterpreter.register(DynamicInterpreter)
@@ -1,30 +1,30 @@
1
1
  import { FragmentActor } from "../actor";
2
- import { Descriptor, UpdateArgs } from "../descriptor";
2
+ import { Descriptor } from "../descriptor";
3
3
  import { Interpreter } from "./Interpreter";
4
4
 
5
5
  class FragmentInterpreter extends Interpreter {
6
6
  static type = Descriptor.type
7
7
 
8
- protected createActor(descriptor: Descriptor, args: UpdateArgs) {
8
+ protected createActor(descriptor: Descriptor) {
9
9
  return new FragmentActor()
10
10
  }
11
11
 
12
12
  /**将节点挂载到场景 */
13
- mount(descriptor: Descriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
14
- super.mount(descriptor, args, parentInterpreter, parentDescriptor)
15
- const actor = this.getActor<FragmentActor>(descriptor, args)
13
+ mount(descriptor: Descriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
14
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
15
+ const actor = this.getActor<FragmentActor>(descriptor)
16
16
  actor.bind(parentDescriptor.uuid)
17
17
  }
18
18
 
19
19
  /**将节点从场景中卸载 */
20
- unmount(descriptor: Descriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
21
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
20
+ unmount(descriptor: Descriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
21
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
22
22
  }
23
23
 
24
- free(descriptor: Descriptor, args: UpdateArgs): void {
25
- const actor = this.getActor<FragmentActor>(descriptor, args)
24
+ free(descriptor: Descriptor): void {
25
+ const actor = this.getActor<FragmentActor>(descriptor)
26
26
  actor.unbind()
27
- super.free(descriptor, args)
27
+ super.free(descriptor)
28
28
  }
29
29
  }
30
30
  Interpreter.register(FragmentInterpreter)
@@ -1,4 +1,4 @@
1
- import { Descriptor, HTMLServiceDescriptor, UpdateArgs } from "../descriptor"
1
+ import { Descriptor, HTMLServiceDescriptor } from "../descriptor"
2
2
  import { Interpreter, ServiceInterpreter } from "."
3
3
  import { HTMLActor, HTMLServiceActor } from "../actor"
4
4
  import { PickupObject } from "../graphics"
@@ -6,39 +6,39 @@ import { PickupObject } from "../graphics"
6
6
  class HTMLServiceInterpreter extends ServiceInterpreter {
7
7
  static type = HTMLServiceDescriptor.type
8
8
 
9
- protected createActor(descriptor: HTMLServiceDescriptor, args: UpdateArgs) {
9
+ protected createActor(descriptor: HTMLServiceDescriptor) {
10
10
  const actor = new HTMLServiceActor(descriptor.uuid)
11
11
  actor.DOM.addEventListener('pointerdown', e => e.stopPropagation())
12
12
  return actor
13
13
  }
14
14
 
15
- update(descriptor: HTMLServiceDescriptor, args: UpdateArgs) {
16
- super.update(descriptor, args)
15
+ update(descriptor: HTMLServiceDescriptor) {
16
+ super.update(descriptor)
17
17
 
18
- const actor = this.getActor<HTMLServiceActor>(descriptor, args)
19
- actor.update(descriptor, args)
18
+ const actor = this.getActor<HTMLServiceActor>(descriptor)
19
+ actor.update(descriptor)
20
20
  }
21
21
 
22
- mount(descriptor: HTMLServiceDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
23
- super.mount(descriptor, args, parentInterpreter, parentDescriptor)
24
- const actor = this.getActor<HTMLServiceActor>(descriptor, args)
22
+ mount(descriptor: HTMLServiceDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
23
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
24
+ const actor = this.getActor<HTMLServiceActor>(descriptor)
25
25
 
26
- const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor, args)
26
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
27
27
  parenActor.add(actor)
28
28
  }
29
29
 
30
- unmount(descriptor: HTMLServiceDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
31
- const actor = this.getActor<HTMLServiceActor>(descriptor, args)
30
+ unmount(descriptor: HTMLServiceDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
31
+ const actor = this.getActor<HTMLServiceActor>(descriptor)
32
32
  actor.clearStyleClass(actor.DOM)
33
33
  actor.cleanInteraction()
34
34
 
35
- const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor, args)
35
+ const parenActor = parentInterpreter.getActor<HTMLActor>(parentDescriptor)
36
36
  parenActor.remove(actor)
37
37
 
38
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
38
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
39
39
  }
40
40
 
41
- pickup(descriptor: HTMLServiceDescriptor, args: UpdateArgs, result: PickupObject[]) {
41
+ pickup(descriptor: HTMLServiceDescriptor, result: PickupObject[]) {
42
42
  result.push({ uuid: descriptor.uuid, generatedBy: descriptor.generatedBy })
43
43
  }
44
44
  }
@@ -1,37 +1,37 @@
1
- import { Descriptor, HTMLTransformControllerDescriptor, UpdateArgs } from "../descriptor"
1
+ import { Descriptor, HTMLTransformControllerDescriptor } from "../descriptor"
2
2
  import { HTMLTransformControllerActor } from "../actor"
3
3
  import { Interpreter } from "./Interpreter"
4
4
 
5
5
  class HTMLTransformControllerInterpreter extends Interpreter {
6
6
  static type = HTMLTransformControllerDescriptor.type
7
7
 
8
- protected createActor(descriptor: HTMLTransformControllerDescriptor, args: UpdateArgs) {
8
+ protected createActor(descriptor: HTMLTransformControllerDescriptor) {
9
9
  const actor = new HTMLTransformControllerActor()
10
10
  return actor
11
11
  }
12
12
 
13
- update(descriptor: HTMLTransformControllerDescriptor, args: UpdateArgs) {
14
- super.update(descriptor, args)
15
- const actor = this.getActor<HTMLTransformControllerActor>(descriptor, args)
16
- actor.update(descriptor, args)
13
+ update(descriptor: HTMLTransformControllerDescriptor) {
14
+ super.update(descriptor)
15
+ const actor = this.getActor<HTMLTransformControllerActor>(descriptor)
16
+ actor.update(descriptor)
17
17
  }
18
18
 
19
- mount(descriptor: HTMLTransformControllerDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
- super.mount(descriptor, args, parentInterpreter, parentDescriptor)
21
- this.getActor<HTMLTransformControllerActor>(descriptor, args)
19
+ mount(descriptor: HTMLTransformControllerDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
20
+ super.mount(descriptor, parentInterpreter, parentDescriptor)
21
+ this.getActor<HTMLTransformControllerActor>(descriptor)
22
22
  }
23
23
 
24
- unmount(descriptor: HTMLTransformControllerDescriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
25
- const actor = this.getActor<HTMLTransformControllerActor>(descriptor, args)
24
+ unmount(descriptor: HTMLTransformControllerDescriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) {
25
+ const actor = this.getActor<HTMLTransformControllerActor>(descriptor)
26
26
  actor.unlisten()
27
27
 
28
- super.unmount(descriptor, args, parentInterpreter, parentDescriptor)
28
+ super.unmount(descriptor, parentInterpreter, parentDescriptor)
29
29
  }
30
30
 
31
- free(descriptor: HTMLTransformControllerDescriptor, args: UpdateArgs) {
32
- const actor = this.getActor<HTMLTransformControllerActor>(descriptor, args)
31
+ free(descriptor: HTMLTransformControllerDescriptor) {
32
+ const actor = this.getActor<HTMLTransformControllerActor>(descriptor)
33
33
  actor.dispose()
34
- super.free(descriptor, args)
34
+ super.free(descriptor)
35
35
  }
36
36
  }
37
37
  Interpreter.register(HTMLTransformControllerInterpreter)
@@ -1,7 +1,7 @@
1
1
  import { language } from '../locale'
2
2
  import { Actor } from '../actor'
3
3
  import { Unit, PickupObject, Graphics } from "../graphics"
4
- import { Descriptor, UpdateArgs } from "../descriptor"
4
+ import { Descriptor } from "../descriptor"
5
5
 
6
6
  const privateState = {
7
7
  factory: false,
@@ -33,37 +33,37 @@ class Interpreter {
33
33
  this.graphics = graphics
34
34
  }
35
35
 
36
- protected createActor(descriptor: Descriptor, args: UpdateArgs) {
36
+ protected createActor(descriptor: Descriptor) {
37
37
  return new Actor()
38
38
  }
39
39
 
40
40
  /**使用描述器获取代理对象,若代理对象不存在则会使用描述器创建一个代理对象 */
41
- getActor<T extends Actor = Actor>(descriptor: Descriptor, args: UpdateArgs): T {
41
+ getActor<T extends Actor = Actor>(descriptor: Descriptor): T {
42
42
  let actor = privateState.actorCollection.get(this)
43
43
  if (actor !== undefined) return actor as T
44
- actor = this.createActor(descriptor, args)
44
+ actor = this.createActor(descriptor)
45
45
  Actor.seGraphics(actor, this.graphics)
46
46
  privateState.actorCollection.set(this, actor)
47
47
  return actor as T
48
48
  }
49
49
 
50
50
  /**使用描述更新节点 */
51
- update(descriptor: Descriptor, args: UpdateArgs) { }
51
+ update(descriptor: Descriptor,) { }
52
52
 
53
53
  /**将节点挂载到场景 */
54
- mount(descriptor: Descriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) { }
54
+ mount(descriptor: Descriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) { }
55
55
 
56
56
  /**将节点从场景中卸载 */
57
- unmount(descriptor: Descriptor, args: UpdateArgs, parentInterpreter: Interpreter, parentDescriptor: Descriptor) { }
57
+ unmount(descriptor: Descriptor, parentInterpreter: Interpreter, parentDescriptor: Descriptor) { }
58
58
 
59
- free(descriptor: Descriptor, args: UpdateArgs) {
59
+ free(descriptor: Descriptor) {
60
60
  const actor = privateState.actorCollection.get(this)
61
61
  if (actor === undefined) return
62
62
  Actor.seGraphics(actor, this.graphics)
63
63
  privateState.actorCollection.delete(this)
64
64
  }
65
65
 
66
- pickup(descriptor: Descriptor, args: UpdateArgs, result: PickupObject[]) { }
66
+ pickup(descriptor: Descriptor, result: PickupObject[]) { }
67
67
  }
68
68
 
69
69
  export { Interpreter, privateState }
@@ -1,19 +1,19 @@
1
- import { ServiceDescriptor, UpdateArgs } from "../descriptor";
1
+ import { ServiceDescriptor } from "../descriptor";
2
2
  import { PickupObject } from "../graphics";
3
3
  import { Interpreter } from "./Interpreter";
4
4
 
5
5
  class ServiceInterpreter extends Interpreter {
6
6
  static type = ServiceDescriptor.type
7
7
 
8
- clear(service: ServiceDescriptor, args: UpdateArgs) { }
8
+ clear(service: ServiceDescriptor) { }
9
9
 
10
- beforeRender(service: ServiceDescriptor, args: UpdateArgs) { }
10
+ beforeRender(service: ServiceDescriptor) { }
11
11
 
12
- render(service: ServiceDescriptor, args: UpdateArgs) { }
12
+ render(service: ServiceDescriptor) { }
13
13
 
14
- afterRender(service: ServiceDescriptor, args: UpdateArgs) { }
14
+ afterRender(service: ServiceDescriptor) { }
15
15
 
16
- beforePickup(mouse: { x: number; y: number }, rect: DOMRect, args: UpdateArgs) { }
16
+ beforePickup(mouse: { x: number; y: number }, rect: DOMRect) { }
17
17
 
18
18
  orderBy(result: PickupObject[]) { }
19
19
  }
@@ -1,11 +1,11 @@
1
- import { Descriptor, ServiceSchedulerDescriptor, UpdateArgs } from "../descriptor"
1
+ import { Descriptor, ServiceSchedulerDescriptor } from "../descriptor"
2
2
  import { DivActor } from "../actor"
3
3
  import { Interpreter } from "./Interpreter"
4
4
 
5
5
  class ServiceSchedulerInterpreter extends Interpreter {
6
6
  static type = ServiceSchedulerDescriptor.type
7
7
 
8
- protected createActor(descriptor: Descriptor, args: UpdateArgs) {
8
+ protected createActor(descriptor: Descriptor) {
9
9
  const actor = new DivActor(descriptor.uuid)
10
10
  return actor
11
11
  }
@@ -13,8 +13,8 @@ class ServiceSchedulerInterpreter extends Interpreter {
13
13
  private resize = () => { }
14
14
  private unresize = () => { }
15
15
 
16
- install(descriptor: ServiceSchedulerDescriptor, args: UpdateArgs) {
17
- const actor = this.getActor<DivActor>(descriptor, args)
16
+ install(descriptor: ServiceSchedulerDescriptor) {
17
+ const actor = this.getActor<DivActor>(descriptor)
18
18
  const wrapper = actor.getWrapper()
19
19
 
20
20
  this.graphics.engine.DOM.appendChild(wrapper)
@@ -30,9 +30,9 @@ class ServiceSchedulerInterpreter extends Interpreter {
30
30
  this.resize()
31
31
  }
32
32
 
33
- uninstall(descriptor: ServiceSchedulerDescriptor, args: UpdateArgs) {
33
+ uninstall(descriptor: ServiceSchedulerDescriptor) {
34
34
  this.unresize()
35
- const actor = this.getActor<DivActor>(descriptor, args)
35
+ const actor = this.getActor<DivActor>(descriptor)
36
36
  const wrapper = actor.getWrapper()
37
37
  wrapper.remove()
38
38
  }
@@ -1,4 +1,4 @@
1
- import { Descriptor, StyleDescriptor, UpdateArgs } from "../descriptor";
1
+ import { Descriptor, StyleDescriptor } from "../descriptor";
2
2
  import { StyleActor } from "../actor";
3
3
  import { Graphics, Unit } from "../graphics";
4
4
  import { Interpreter } from "./Interpreter";
@@ -27,14 +27,14 @@ class StyleInterpreter extends Interpreter {
27
27
  this.className = `vyr_${unit.uuid}`
28
28
  }
29
29
 
30
- protected createActor(descriptor: StyleDescriptor, args: UpdateArgs) {
30
+ protected createActor(descriptor: StyleDescriptor) {
31
31
  return new StyleActor()
32
32
  }
33
33
 
34
- update(descriptor: StyleDescriptor, args: UpdateArgs) {
35
- super.update(descriptor, args)
34
+ update(descriptor: StyleDescriptor) {
35
+ super.update(descriptor)
36
36
 
37
- const actor = this.getActor<StyleActor>(descriptor, args)
37
+ const actor = this.getActor<StyleActor>(descriptor)
38
38
  actor.update(descriptor, this.className)
39
39
 
40
40
  if (actor.updateRule(StyleInterpreter.sheet) === true) return
@@ -43,7 +43,7 @@ class StyleInterpreter extends Interpreter {
43
43
  StyleInterpreter.insertRule(styleValues)
44
44
  }
45
45
 
46
- free(descriptor: Descriptor, args: UpdateArgs) {
46
+ free(descriptor: Descriptor) {
47
47
  const selectorTexts = [`.${this.className}`, `.${this.className}:hover`]
48
48
  for (let i = StyleInterpreter.sheet.cssRules.length - 1; i >= 0; i--) {
49
49
  const rule = StyleInterpreter.sheet.cssRules[i]
@@ -56,7 +56,7 @@ class StyleInterpreter extends Interpreter {
56
56
  }
57
57
  }
58
58
  }
59
- super.free(descriptor, args)
59
+ super.free(descriptor)
60
60
  }
61
61
  }
62
62
  Interpreter.register(StyleInterpreter)
@@ -4,7 +4,6 @@ export * from './StyleInterpreter'
4
4
  export * from './AnimationUnitInterpreter'
5
5
  export * from './FragmentInterpreter'
6
6
  export * from './DynamicInterpreter'
7
- export * from './RoutineInterpreter'
8
7
  export * from './PrefaInterpreter'
9
8
  export * from './PrefabInstanceInterpreter'
10
9
  export * from "./DivInterpreter";
@@ -14,8 +14,9 @@ interface ZhCNLanguageProvider extends LanguageProvider {
14
14
  'graphics.unit.notFound': string
15
15
  'engine.run.container.notFound': string
16
16
 
17
- '/virtual:/preset/net/request.ts': string
17
+ '/virtual:/preset/net/http.ts': string
18
18
  '/virtual:/preset/dataset/update.ts': string
19
+ '/virtual:/preset/dataset/compile.ts': string
19
20
  '/virtual:/preset/scheduler/switch.ts': string
20
21
  '/virtual:/preset/graphics/invoke.ts': string
21
22
  }
@@ -36,8 +37,9 @@ const zhCnLanguageProvider: ZhCNLanguageProvider = {
36
37
  'graphics.unit.notFound': '单元不存在:{{uuid}}',
37
38
  'engine.run.container.notFound': '挂载节点不存在',
38
39
 
39
- '/virtual:/preset/net/request.ts': '网络请求',
40
+ '/virtual:/preset/net/http.ts': '网络请求',
40
41
  '/virtual:/preset/dataset/update.ts': '更新数据集',
42
+ '/virtual:/preset/dataset/compile.ts': '组合数据集',
41
43
  '/virtual:/preset/scheduler/switch.ts': '切换场景',
42
44
  '/virtual:/preset/graphics/invoke.ts': '调用交互',
43
45
  }
@@ -0,0 +1,43 @@
1
+ import { language } from "../../../locale";
2
+ import { Asset } from "../../../asset";
3
+ import { InteractionNode, Scriptable, ScriptableArgs } from "../../../interaction";
4
+ import { Graphics } from "../../../graphics";
5
+
6
+ const scriptable = Asset.createVirtualUrl('preset/dataset/compile.ts')
7
+ class ExecuteScriptable extends Scriptable {
8
+ async execute(graphics: Graphics, args: ScriptableArgs) {
9
+ // const { input, result } = args
10
+ console.log(args)
11
+
12
+ return {}
13
+ }
14
+ }
15
+ Asset.provider(scriptable, async () => ({ default: ExecuteScriptable }))
16
+
17
+ const createExecuteInput = (args: any = {}) => {
18
+ const input = {
19
+
20
+ }
21
+
22
+ return input
23
+ }
24
+
25
+ const createExecuteNode = (options: { id: string; position?: any; input?: any }) => {
26
+ const executeNode: InteractionNode = {
27
+ id: options.id,
28
+ label: language.get(scriptable as any),
29
+ position: { x: options?.position?.x ?? 20, y: options?.position?.y ?? 20 },
30
+ interaction: 'Execute',
31
+ url: scriptable,
32
+ input: createExecuteInput(options.input)
33
+ }
34
+ return executeNode
35
+ }
36
+
37
+ export {
38
+ scriptable,
39
+ createExecuteInput,
40
+ createExecuteNode,
41
+ }
42
+
43
+