@vyr/engine 0.0.1 → 0.0.3
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/package.json +1 -19
- package/src/Category.ts +7 -7
- package/src/Engine.ts +29 -15
- package/src/actor/AnimationUnitActor.ts +3 -3
- package/src/actor/DivActor.ts +6 -6
- package/src/actor/FragmentActor.ts +3 -3
- package/src/actor/HTMActor.ts +19 -16
- package/src/actor/HTMServiceActor.ts +4 -4
- package/src/actor/HTMTransformControllerActor.ts +15 -10
- package/src/asset/Asset.ts +25 -27
- package/src/asset/AssetGraph.ts +4 -4
- package/src/descriptor/DatasetDescriptor.ts +20 -22
- package/src/descriptor/Descriptor.ts +1 -28
- package/src/descriptor/HTMLTransformControllerDescriptor.ts +2 -2
- package/src/descriptor/index.ts +0 -1
- package/src/graphics/Compilation.ts +37 -45
- package/src/graphics/Graphics.ts +80 -68
- package/src/graphics/VariableProxy.ts +8 -8
- package/src/index.ts +2 -1
- package/src/interaction/InteractionDescriptor.ts +96 -0
- package/src/interaction/InteractionExecutor.ts +84 -0
- package/src/interaction/Scriptable.ts +40 -0
- package/src/interaction/index.ts +3 -0
- package/src/interpreter/AnimationUnitInterpreter.ts +5 -5
- package/src/interpreter/DivInterpreter.ts +15 -15
- package/src/interpreter/DynamicInterpreter.ts +9 -9
- package/src/interpreter/FragmentInterpreter.ts +10 -10
- package/src/interpreter/HTMLServiceInterpreter.ts +15 -15
- package/src/interpreter/HTMLTransformControllerInterpreter.ts +15 -15
- package/src/interpreter/Interpreter.ts +9 -9
- package/src/interpreter/ServiceInterpreter.ts +6 -6
- package/src/interpreter/ServiceSchedulerInterpreter.ts +6 -6
- package/src/interpreter/StyleInterpreter.ts +7 -7
- package/src/interpreter/index.ts +0 -1
- package/src/locale/LanguageProvider.ts +4 -2
- package/src/preset/execute/dataset/compile.ts +99 -0
- package/src/preset/execute/dataset/index.ts +2 -1
- package/src/preset/execute/dataset/update.ts +7 -8
- package/src/preset/execute/graphics/invoke.ts +5 -6
- package/src/preset/execute/net/{request.ts → http.ts} +9 -17
- package/src/preset/execute/net/index.ts +1 -1
- package/src/preset/execute/scheduler/switch.ts +8 -8
- package/src/preset/index.ts +2 -2
- package/src/preset/interaction/dataset/compile.ts +27 -0
- package/src/preset/interaction/dataset/index.ts +1 -0
- package/src/preset/interaction/graphics/invoke.ts +27 -0
- package/src/preset/interaction/index.ts +3 -0
- package/src/preset/interaction/scheduler/switch.ts +27 -0
- package/src/utils/AssetProvider.ts +7 -6
- package/src/utils/constants.ts +10 -0
- package/src/utils/index.ts +1 -0
- package/src/Scriptable.ts +0 -27
- package/src/descriptor/RoutineDescriptor.ts +0 -54
- package/src/interpreter/RoutineInterpreter.ts +0 -88
- package/src/preset/routine/graphics/invoke.ts +0 -27
- package/src/preset/routine/index.ts +0 -2
- package/src/preset/routine/scheduler/switch.ts +0 -27
- /package/src/preset/{routine → interaction}/graphics/index.ts +0 -0
- /package/src/preset/{routine → interaction}/scheduler/index.ts +0 -0
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Asset } from "../asset";
|
|
2
|
-
import { Scriptable } from "../Scriptable";
|
|
3
|
-
import { RoutineDescriptor, RoutineNode, UpdateArgs, InteractionInputCollection } from "../descriptor";
|
|
4
|
-
import { Interpreter } from "./Interpreter";
|
|
5
|
-
|
|
6
|
-
type ExecuteResult = { [k: string]: any } | null
|
|
7
|
-
|
|
8
|
-
class RoutineInterpreter extends Interpreter {
|
|
9
|
-
static type = RoutineDescriptor.type
|
|
10
|
-
readonly collection = new Map<string, RoutineNode>()
|
|
11
|
-
readonly linkCollection = new Map<string, string[]>()
|
|
12
|
-
|
|
13
|
-
update(descriptor: RoutineDescriptor, args: UpdateArgs) {
|
|
14
|
-
super.update(descriptor, args)
|
|
15
|
-
|
|
16
|
-
this.collection.clear()
|
|
17
|
-
this.linkCollection.clear()
|
|
18
|
-
|
|
19
|
-
for (const node of descriptor.nodes) {
|
|
20
|
-
this.collection.set(node.id, node)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
for (const mapper of descriptor.mappers) {
|
|
24
|
-
let link = this.linkCollection.get(mapper.source)
|
|
25
|
-
if (link === undefined) {
|
|
26
|
-
link = []
|
|
27
|
-
this.linkCollection.set(mapper.source, link)
|
|
28
|
-
}
|
|
29
|
-
link.push(mapper.target)
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async doBranch(branch: string, previous: string, customInputs: InteractionInputCollection, descriptor: RoutineDescriptor, args: UpdateArgs, result: Map<string, ExecuteResult>) {
|
|
34
|
-
this.doExecute(branch, previous, customInputs, descriptor, args, result)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async doCondition(condition: string, previous: string, customInputs: InteractionInputCollection, descriptor: RoutineDescriptor, args: UpdateArgs, result: Map<string, ExecuteResult>) {
|
|
38
|
-
const preResult = result.get(previous)
|
|
39
|
-
const conditionResult = result.get(condition)
|
|
40
|
-
if (preResult !== conditionResult?.condition.value) return
|
|
41
|
-
|
|
42
|
-
this.doExecute(condition, previous, customInputs, descriptor, args, result)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
async doExecute(execute: string, previous: string, customInputs: InteractionInputCollection, descriptor: RoutineDescriptor, args: UpdateArgs, result: Map<string, ExecuteResult>) {
|
|
46
|
-
const nexts = this.linkCollection.get(execute)
|
|
47
|
-
if (nexts === undefined) return
|
|
48
|
-
|
|
49
|
-
for (const next of nexts) {
|
|
50
|
-
await this.doNext(next, execute, customInputs, descriptor, args, result)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
async doNext(current: string, previous: string, customInputs: InteractionInputCollection, descriptor: RoutineDescriptor, args: UpdateArgs, result: Map<string, ExecuteResult>) {
|
|
55
|
-
const active = this.collection.get(current)
|
|
56
|
-
if (active === undefined) return
|
|
57
|
-
|
|
58
|
-
const currentInput = customInputs[current] ?? {}
|
|
59
|
-
const script = Asset.get<Scriptable>(active.url)
|
|
60
|
-
if (script) {
|
|
61
|
-
const event = { ...args, input: { previous, default: active.input, user: currentInput }, result }
|
|
62
|
-
const executeResult = await script.execute(descriptor, this.graphics, event)
|
|
63
|
-
result.set(current, executeResult)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (active.routine === 'Branch') {
|
|
67
|
-
this.doBranch(current, previous, customInputs, descriptor, args, result)
|
|
68
|
-
} else if (active.routine === 'Condition') {
|
|
69
|
-
if (result.has(current) === false) result.set(current, active.input)
|
|
70
|
-
this.doCondition(current, previous, customInputs, descriptor, args, result)
|
|
71
|
-
} else {
|
|
72
|
-
this.doExecute(current, previous, customInputs, descriptor, args, result)
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
do(customInputs: InteractionInputCollection, descriptor: RoutineDescriptor, args: UpdateArgs) {
|
|
77
|
-
for (const root of descriptor.roots) {
|
|
78
|
-
const resultCollection = new Map()
|
|
79
|
-
this.doNext(root, '', customInputs, descriptor, args, resultCollection)
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
Interpreter.register(RoutineInterpreter)
|
|
85
|
-
|
|
86
|
-
export {
|
|
87
|
-
RoutineInterpreter
|
|
88
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Asset } from "../../../asset";
|
|
2
|
-
import { RoutineDescriptor } from "../../../descriptor";
|
|
3
|
-
import { graphics } from "../../execute"
|
|
4
|
-
|
|
5
|
-
const url = Asset.createVirtualUrl('preset/graphics/invoke.routine.json')
|
|
6
|
-
const nodes = {
|
|
7
|
-
invoke: 'invoke'
|
|
8
|
-
}
|
|
9
|
-
let _currentRoutine: RoutineDescriptor | null = null
|
|
10
|
-
const routineProvider = async () => {
|
|
11
|
-
if (_currentRoutine === null) {
|
|
12
|
-
_currentRoutine = new RoutineDescriptor()
|
|
13
|
-
const invokeNode = graphics.invoke.createExecuteNode({ id: nodes.invoke })
|
|
14
|
-
_currentRoutine.nodes.push(invokeNode)
|
|
15
|
-
_currentRoutine.roots.push(invokeNode.id)
|
|
16
|
-
}
|
|
17
|
-
return _currentRoutine
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
Asset.provider(url, routineProvider)
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
url,
|
|
24
|
-
nodes,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Asset } from "../../../asset";
|
|
2
|
-
import { RoutineDescriptor } from "../../../descriptor";
|
|
3
|
-
import { scheduler } from "../../execute"
|
|
4
|
-
|
|
5
|
-
const url = Asset.createVirtualUrl('preset/scheduler/switch.routine.json')
|
|
6
|
-
const nodes = {
|
|
7
|
-
switch: 'switch',
|
|
8
|
-
}
|
|
9
|
-
let _currentRoutine: RoutineDescriptor | null = null
|
|
10
|
-
const routineProvider = async () => {
|
|
11
|
-
if (_currentRoutine === null) {
|
|
12
|
-
_currentRoutine = new RoutineDescriptor()
|
|
13
|
-
const switchNode = scheduler.switch.createExecuteNode({ id: nodes.switch })
|
|
14
|
-
_currentRoutine.nodes.push(switchNode)
|
|
15
|
-
_currentRoutine.roots.push(switchNode.id)
|
|
16
|
-
}
|
|
17
|
-
return _currentRoutine
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
Asset.provider(url, routineProvider)
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
url,
|
|
24
|
-
nodes,
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
File without changes
|
|
File without changes
|