embedded-react 0.15.0 → 0.17.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/aot/compile.mjs +173 -8272
- package/aot/compiler/animations.mjs +1001 -0
- package/aot/compiler/assemble.mjs +922 -0
- package/aot/compiler/boot.mjs +441 -0
- package/aot/compiler/branch-merge.mjs +319 -0
- package/aot/compiler/c/animations.mjs +362 -0
- package/aot/compiler/c/boot.mjs +127 -0
- package/aot/compiler/c/expressions.mjs +270 -0
- package/aot/compiler/c/functions.mjs +268 -0
- package/aot/compiler/c/keyboard.mjs +96 -0
- package/aot/compiler/c/nodes.mjs +294 -0
- package/aot/compiler/c/pan-responder.mjs +136 -0
- package/aot/compiler/c/statements.mjs +271 -0
- package/aot/compiler/c/text.mjs +83 -0
- package/aot/compiler/c/vectors.mjs +381 -0
- package/aot/compiler/c-syntax.mjs +127 -0
- package/aot/compiler/check.mjs +165 -0
- package/aot/compiler/collect.mjs +785 -0
- package/aot/compiler/control-flow.mjs +696 -0
- package/aot/compiler/diagnostics.mjs +137 -0
- package/aot/compiler/elements/activity-indicator.mjs +160 -0
- package/aot/compiler/elements/dial.mjs +346 -0
- package/aot/compiler/elements/flat-list.mjs +139 -0
- package/aot/compiler/elements/image.mjs +151 -0
- package/aot/compiler/elements/modal.mjs +158 -0
- package/aot/compiler/elements/props.mjs +474 -0
- package/aot/compiler/elements/switch.mjs +183 -0
- package/aot/compiler/elements/text-input.mjs +171 -0
- package/aot/compiler/expressions.mjs +1579 -0
- package/aot/compiler/handlers.mjs +1072 -0
- package/aot/compiler/ir/animations.mjs +16 -0
- package/aot/compiler/ir/app.mjs +16 -0
- package/aot/compiler/ir/boot.mjs +16 -0
- package/aot/compiler/ir/expressions.mjs +16 -0
- package/aot/compiler/ir/functions.mjs +16 -0
- package/aot/compiler/ir/keyboard.mjs +16 -0
- package/aot/compiler/ir/nodes.mjs +107 -0
- package/aot/compiler/ir/pan-responder.mjs +16 -0
- package/aot/compiler/ir/reads.mjs +351 -0
- package/aot/compiler/ir/source.mjs +16 -0
- package/aot/compiler/ir/statements.mjs +16 -0
- package/aot/compiler/ir/text.mjs +16 -0
- package/aot/compiler/ir/types.mjs +185 -0
- package/aot/compiler/ir/vectors.mjs +16 -0
- package/aot/compiler/keyboard.mjs +152 -0
- package/aot/compiler/lower.mjs +311 -0
- package/aot/compiler/nodes.mjs +688 -0
- package/aot/compiler/options.mjs +55 -0
- package/aot/compiler/out.mjs +94 -0
- package/aot/compiler/pan-responder.mjs +354 -0
- package/aot/compiler/parse.mjs +300 -0
- package/aot/compiler/static-eval.mjs +454 -0
- package/aot/compiler/style-text.mjs +807 -0
- package/aot/compiler/svg.mjs +1167 -0
- package/aot/compiler/types.mjs +16 -0
- package/aot/screenshot-smoke.mjs +95 -55
- package/aot/style-map.mjs +366 -304
- package/cli.mjs +5 -8
- package/package.json +14 -6
- package/sim/embedded-react.wasm +0 -0
- package/src/embedded-react/FlatList.js +4 -4
- package/src/props.js +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/*----------------------------------------------------------------------------------------------------------------------
|
|
17
|
+
- Imports
|
|
18
|
+
---------------------------------------------------------------------------------------------------------------------*/
|
|
19
|
+
import { isBootOnlyNode, isBootOnlyVector } from './reads.mjs';
|
|
20
|
+
/*----------------------------------------------------------------------------------------------------------------------
|
|
21
|
+
- Implementation
|
|
22
|
+
---------------------------------------------------------------------------------------------------------------------*/
|
|
23
|
+
/**
|
|
24
|
+
* Whether any of a node's props, text, or image is a runtime value rather than a constant.
|
|
25
|
+
*
|
|
26
|
+
* @param node The node.
|
|
27
|
+
*
|
|
28
|
+
* @returns True when one is.
|
|
29
|
+
*/
|
|
30
|
+
export const hasRuntimeProps = (node) => (node.text?.parts.some(part => part.kind !== 'literal') ?? false) ||
|
|
31
|
+
node.stateProps.length > 0 ||
|
|
32
|
+
node.image?.kind === 'value';
|
|
33
|
+
/**
|
|
34
|
+
* Whether state drives any of a node's props, text or image, so it keeps a handle and app_update() sets its
|
|
35
|
+
* props again. Props that read-only values worked out at boot are set once, by er_app_build().
|
|
36
|
+
*
|
|
37
|
+
* @param node The node.
|
|
38
|
+
*
|
|
39
|
+
* @returns True when state drives it.
|
|
40
|
+
*/
|
|
41
|
+
export const isStateDriven = (node) => hasRuntimeProps(node) && !isBootOnlyNode(node);
|
|
42
|
+
/**
|
|
43
|
+
* The drawing state drives on a node if it has one: a drawing that reads only values worked out at boot is
|
|
44
|
+
* built once, by er_app_build().
|
|
45
|
+
*
|
|
46
|
+
* @param node The node.
|
|
47
|
+
*
|
|
48
|
+
* @returns The drawing, or null.
|
|
49
|
+
*/
|
|
50
|
+
export function updatedVectorOf(node) {
|
|
51
|
+
const vector = stateDrivenVectorOf(node);
|
|
52
|
+
return vector && !isBootOnlyVector(vector) ? vector : null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The drawing state drives on a node, if it has one.
|
|
56
|
+
*
|
|
57
|
+
* @param node The node.
|
|
58
|
+
*
|
|
59
|
+
* @returns The drawing, or null.
|
|
60
|
+
*/
|
|
61
|
+
export function stateDrivenVectorOf(node) {
|
|
62
|
+
for (const wire of node.wiring) {
|
|
63
|
+
if (wire.kind === 'stateDrivenVector') {
|
|
64
|
+
return wire.vector;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Every node under an element, each before its children, in the order er_app_build() creates them.
|
|
71
|
+
*
|
|
72
|
+
* @param element The element.
|
|
73
|
+
*
|
|
74
|
+
* @returns The nodes.
|
|
75
|
+
*/
|
|
76
|
+
export function nodesOf(element) {
|
|
77
|
+
if (element.kind === 'component') {
|
|
78
|
+
return nodesOf(element.root);
|
|
79
|
+
}
|
|
80
|
+
const nodes = [element.node];
|
|
81
|
+
for (const child of element.node.children) {
|
|
82
|
+
if (child.kind === 'element') {
|
|
83
|
+
nodes.push(...nodesOf(child.element));
|
|
84
|
+
}
|
|
85
|
+
else if (child.kind === 'conditional') {
|
|
86
|
+
nodes.push(...branchElements(child).flatMap(nodesOf));
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
nodes.push(...child.rows.flatMap(nodesOf));
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return nodes;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The elements a conditional builds, in source order: every branch, nested conditionals included.
|
|
96
|
+
*
|
|
97
|
+
* @param conditional The conditional.
|
|
98
|
+
*
|
|
99
|
+
* @returns The elements.
|
|
100
|
+
*/
|
|
101
|
+
export function branchElements(conditional) {
|
|
102
|
+
return [conditional.whenTrue, conditional.whenFalse].flatMap(branch => branch == null
|
|
103
|
+
? []
|
|
104
|
+
: branch.kind === 'conditional'
|
|
105
|
+
? branchElements(branch)
|
|
106
|
+
: [branch]);
|
|
107
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
/*----------------------------------------------------------------------------------------------------------------------
|
|
17
|
+
- Implementation
|
|
18
|
+
---------------------------------------------------------------------------------------------------------------------*/
|
|
19
|
+
/**
|
|
20
|
+
* Records what a local reads: a list row's item reads its list, and any other local reads what it was set from.
|
|
21
|
+
* A local with neither is untracked.
|
|
22
|
+
*
|
|
23
|
+
* @param local The local.
|
|
24
|
+
* @param found What the walk has found.
|
|
25
|
+
*/
|
|
26
|
+
function readLocal(local, found) {
|
|
27
|
+
if (local.list) {
|
|
28
|
+
found.states.add(local.list);
|
|
29
|
+
}
|
|
30
|
+
else if (local.source) {
|
|
31
|
+
readSource(local.source, found);
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
found.untracked = true;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Records what an expression, before typing, reads.
|
|
39
|
+
*
|
|
40
|
+
* @param source The expression.
|
|
41
|
+
* @param found What the walk has found.
|
|
42
|
+
*/
|
|
43
|
+
function readSource(source, found) {
|
|
44
|
+
switch (source.kind) {
|
|
45
|
+
case 'number':
|
|
46
|
+
case 'string':
|
|
47
|
+
case 'boolean':
|
|
48
|
+
return;
|
|
49
|
+
case 'state':
|
|
50
|
+
found.states.add(source.state);
|
|
51
|
+
return;
|
|
52
|
+
case 'local':
|
|
53
|
+
readLocal(source.local, found);
|
|
54
|
+
return;
|
|
55
|
+
case 'ref':
|
|
56
|
+
found.untracked = true;
|
|
57
|
+
return;
|
|
58
|
+
case 'fixed':
|
|
59
|
+
readExpr(source.expr, found);
|
|
60
|
+
return;
|
|
61
|
+
case 'unary':
|
|
62
|
+
readSource(source.operand, found);
|
|
63
|
+
return;
|
|
64
|
+
case 'binary':
|
|
65
|
+
case 'logical':
|
|
66
|
+
readSource(source.left, found);
|
|
67
|
+
readSource(source.right, found);
|
|
68
|
+
return;
|
|
69
|
+
case 'conditional':
|
|
70
|
+
readSource(source.test, found);
|
|
71
|
+
readSource(source.consequent, found);
|
|
72
|
+
readSource(source.alternate, found);
|
|
73
|
+
return;
|
|
74
|
+
case 'math':
|
|
75
|
+
source.args.forEach(arg => readSource(arg, found));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Records what an expression reads.
|
|
81
|
+
*
|
|
82
|
+
* @param expr The expression.
|
|
83
|
+
* @param found What the walk has found.
|
|
84
|
+
*/
|
|
85
|
+
function readExpr(expr, found) {
|
|
86
|
+
switch (expr.kind) {
|
|
87
|
+
case 'number':
|
|
88
|
+
case 'string':
|
|
89
|
+
case 'boolean':
|
|
90
|
+
case 'pi':
|
|
91
|
+
return;
|
|
92
|
+
case 'state':
|
|
93
|
+
found.states.add(expr.state);
|
|
94
|
+
return;
|
|
95
|
+
case 'boot':
|
|
96
|
+
found.boot = true;
|
|
97
|
+
return;
|
|
98
|
+
case 'local':
|
|
99
|
+
readLocal(expr.local, found);
|
|
100
|
+
return;
|
|
101
|
+
case 'listLength':
|
|
102
|
+
found.states.add(expr.list);
|
|
103
|
+
return;
|
|
104
|
+
case 'itemField':
|
|
105
|
+
readLocal(expr.item, found);
|
|
106
|
+
return;
|
|
107
|
+
case 'ref':
|
|
108
|
+
case 'clock':
|
|
109
|
+
case 'event':
|
|
110
|
+
case 'layout':
|
|
111
|
+
case 'gesture':
|
|
112
|
+
found.untracked = true;
|
|
113
|
+
return;
|
|
114
|
+
case 'toFloat':
|
|
115
|
+
case 'unary':
|
|
116
|
+
case 'wholeRound':
|
|
117
|
+
case 'trunc':
|
|
118
|
+
case 'toInt':
|
|
119
|
+
readExpr(expr.operand, found);
|
|
120
|
+
return;
|
|
121
|
+
case 'helper':
|
|
122
|
+
case 'floatMath':
|
|
123
|
+
expr.args.forEach(arg => readExpr(arg, found));
|
|
124
|
+
return;
|
|
125
|
+
case 'arithmetic':
|
|
126
|
+
case 'floatDivide':
|
|
127
|
+
case 'narrowRemainder':
|
|
128
|
+
case 'compare':
|
|
129
|
+
case 'stringEquals':
|
|
130
|
+
case 'logical':
|
|
131
|
+
case 'pick':
|
|
132
|
+
readExpr(expr.left, found);
|
|
133
|
+
readExpr(expr.right, found);
|
|
134
|
+
return;
|
|
135
|
+
case 'conditional':
|
|
136
|
+
readExpr(expr.test, found);
|
|
137
|
+
readExpr(expr.consequent, found);
|
|
138
|
+
readExpr(expr.alternate, found);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Records what a conditional's show condition reads, the conditions it sits within included.
|
|
144
|
+
*
|
|
145
|
+
* @param show The condition.
|
|
146
|
+
* @param found What the walk has found.
|
|
147
|
+
*/
|
|
148
|
+
function readShow(show, found) {
|
|
149
|
+
if (show.kind === 'rowInUse') {
|
|
150
|
+
found.states.add(show.list);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
readExpr(show.test, found);
|
|
154
|
+
if (show.within) {
|
|
155
|
+
readShow(show.within, found);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Records what a state-driven prop value reads.
|
|
160
|
+
*
|
|
161
|
+
* @param value The value.
|
|
162
|
+
* @param found What the walk has found.
|
|
163
|
+
*/
|
|
164
|
+
function readPropValue(value, found) {
|
|
165
|
+
switch (value.kind) {
|
|
166
|
+
case 'constant':
|
|
167
|
+
return;
|
|
168
|
+
case 'select':
|
|
169
|
+
readExpr(value.test, found);
|
|
170
|
+
readPropValue(value.whenTrue, found);
|
|
171
|
+
readPropValue(value.whenFalse, found);
|
|
172
|
+
return;
|
|
173
|
+
case 'opacity':
|
|
174
|
+
case 'dimension':
|
|
175
|
+
case 'visible':
|
|
176
|
+
case 'float':
|
|
177
|
+
readExpr(value.value, found);
|
|
178
|
+
return;
|
|
179
|
+
case 'shown':
|
|
180
|
+
readShow(value.show, found);
|
|
181
|
+
return;
|
|
182
|
+
case 'whileShown':
|
|
183
|
+
readShow(value.show, found);
|
|
184
|
+
readPropValue(value.value, found);
|
|
185
|
+
return;
|
|
186
|
+
case 'flag':
|
|
187
|
+
readExpr(value.test, found);
|
|
188
|
+
return;
|
|
189
|
+
case 'byte':
|
|
190
|
+
readPropValue(value.value, found);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Records what a text reads.
|
|
196
|
+
*
|
|
197
|
+
* @param text The text.
|
|
198
|
+
* @param found What the walk has found.
|
|
199
|
+
*/
|
|
200
|
+
function readText(text, found) {
|
|
201
|
+
for (const part of text.parts) {
|
|
202
|
+
if (part.kind !== 'literal') {
|
|
203
|
+
readExpr(part.value, found);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Records what one slot of a drawing's op-tape reads.
|
|
209
|
+
*
|
|
210
|
+
* @param value The slot.
|
|
211
|
+
* @param found What the walk has found.
|
|
212
|
+
*/
|
|
213
|
+
function readTapeValue(value, found) {
|
|
214
|
+
switch (value.kind) {
|
|
215
|
+
case 'op':
|
|
216
|
+
case 'number':
|
|
217
|
+
case 'local':
|
|
218
|
+
case 'fullTurn':
|
|
219
|
+
return;
|
|
220
|
+
case 'float':
|
|
221
|
+
readExpr(value.value, found);
|
|
222
|
+
return;
|
|
223
|
+
case 'chain':
|
|
224
|
+
readTapeValue(value.first, found);
|
|
225
|
+
value.rest.forEach(step => readTapeValue(step.value, found));
|
|
226
|
+
return;
|
|
227
|
+
case 'radians':
|
|
228
|
+
readTapeValue(value.degrees, found);
|
|
229
|
+
return;
|
|
230
|
+
case 'clampRadius':
|
|
231
|
+
readTapeValue(value.radius, found);
|
|
232
|
+
readTapeValue(value.side, found);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Records what a paint color reads.
|
|
238
|
+
*
|
|
239
|
+
* @param color The color.
|
|
240
|
+
* @param found What the walk has found.
|
|
241
|
+
*/
|
|
242
|
+
function readPaintColor(color, found) {
|
|
243
|
+
if (color.kind === 'state') {
|
|
244
|
+
readPropValue(color.value, found);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* What a walk found, as reads.
|
|
249
|
+
*
|
|
250
|
+
* @param found What the walk found.
|
|
251
|
+
*
|
|
252
|
+
* @returns The state read, or null when something untracked is read too.
|
|
253
|
+
*/
|
|
254
|
+
const readsOf = (found) => found.untracked ? null : found.states;
|
|
255
|
+
/**
|
|
256
|
+
* The state a node's props, text and image read. app_update() sets them all again together, so this is
|
|
257
|
+
* everything any of them reads.
|
|
258
|
+
*
|
|
259
|
+
* @param node The node.
|
|
260
|
+
*
|
|
261
|
+
* @returns Its reads.
|
|
262
|
+
*/
|
|
263
|
+
export const nodeReads = (node) => readsOf(nodeFound(node));
|
|
264
|
+
/**
|
|
265
|
+
* Whether a node's runtime props read only values worked out at boot, so er_app_build() sets them once.
|
|
266
|
+
*
|
|
267
|
+
* @param node The node.
|
|
268
|
+
*
|
|
269
|
+
* @returns True when they do.
|
|
270
|
+
*/
|
|
271
|
+
export const isBootOnlyNode = (node) => isBootOnly(nodeFound(node));
|
|
272
|
+
/**
|
|
273
|
+
* Whether a drawing reads only values worked out at boot, so er_app_build() builds it once.
|
|
274
|
+
*
|
|
275
|
+
* @param vector The drawing.
|
|
276
|
+
*
|
|
277
|
+
* @returns True when it does.
|
|
278
|
+
*/
|
|
279
|
+
export const isBootOnlyVector = (vector) => isBootOnly(vectorFound(vector));
|
|
280
|
+
/**
|
|
281
|
+
* Whether a walk found boot values and nothing that changes.
|
|
282
|
+
*
|
|
283
|
+
* @param found What the walk found.
|
|
284
|
+
*
|
|
285
|
+
* @returns True when it did.
|
|
286
|
+
*/
|
|
287
|
+
const isBootOnly = (found) => !!found.boot && !found.untracked && found.states.size === 0;
|
|
288
|
+
/**
|
|
289
|
+
* Walks everything a node's props, text and image read.
|
|
290
|
+
*
|
|
291
|
+
* @param node The node.
|
|
292
|
+
*
|
|
293
|
+
* @returns What the walk found.
|
|
294
|
+
*/
|
|
295
|
+
function nodeFound(node) {
|
|
296
|
+
const found = { states: new Set(), untracked: false };
|
|
297
|
+
node.stateProps.forEach(prop => readPropValue(prop.value, found));
|
|
298
|
+
if (node.text) {
|
|
299
|
+
readText(node.text, found);
|
|
300
|
+
}
|
|
301
|
+
if (node.image?.kind === 'value') {
|
|
302
|
+
readExpr(node.image.value, found);
|
|
303
|
+
}
|
|
304
|
+
return found;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* The state a drawing reads: its locals and tape, and its paints and gradients.
|
|
308
|
+
*
|
|
309
|
+
* @param vector The drawing.
|
|
310
|
+
*
|
|
311
|
+
* @returns Its reads.
|
|
312
|
+
*/
|
|
313
|
+
export const vectorReads = (vector) => readsOf(vectorFound(vector));
|
|
314
|
+
/**
|
|
315
|
+
* Walks everything a drawing reads.
|
|
316
|
+
*
|
|
317
|
+
* @param vector The drawing.
|
|
318
|
+
*
|
|
319
|
+
* @returns What the walk found.
|
|
320
|
+
*/
|
|
321
|
+
function vectorFound(vector) {
|
|
322
|
+
const found = { states: new Set(), untracked: false };
|
|
323
|
+
vector.locals.forEach(local => readTapeValue(local.value, found));
|
|
324
|
+
vector.tape.forEach(value => readTapeValue(value, found));
|
|
325
|
+
for (const paint of vector.paints) {
|
|
326
|
+
readPaintColor(paint.fill, found);
|
|
327
|
+
readPaintColor(paint.stroke, found);
|
|
328
|
+
readTapeValue(paint.strokeWidth, found);
|
|
329
|
+
for (const gradient of [paint.fillGradient, paint.strokeGradient]) {
|
|
330
|
+
if (gradient.when) {
|
|
331
|
+
readExpr(gradient.when.test, found);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
for (const gradient of vector.gradients) {
|
|
336
|
+
for (const stop of gradient.stops) {
|
|
337
|
+
readPaintColor(stop.color, found);
|
|
338
|
+
readTapeValue(stop.offset, found);
|
|
339
|
+
}
|
|
340
|
+
for (const value of [
|
|
341
|
+
gradient.ax,
|
|
342
|
+
gradient.ay,
|
|
343
|
+
gradient.bx,
|
|
344
|
+
gradient.by,
|
|
345
|
+
gradient.r,
|
|
346
|
+
]) {
|
|
347
|
+
readTapeValue(value, found);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return found;
|
|
351
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 Cory Lamming
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
export {};
|