peachsim 0.1.2278 → 0.1.2296

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 (114) hide show
  1. package/cli/commands/platform.ts +28 -8
  2. package/cli/commands/shell-url.ts +13 -4
  3. package/cli/outbound-endpoints.ts +2 -0
  4. package/dist-lib/agent-daemon-client.cjs +1 -1
  5. package/dist-lib/agent-events.cjs +1 -1
  6. package/dist-lib/attached-projects.cjs +1 -1
  7. package/dist-lib/auth/shared-session.cjs +1 -1
  8. package/dist-lib/backend-origin.cjs +1 -1
  9. package/dist-lib/beta.cjs +1 -1
  10. package/dist-lib/beta.mjs +1 -1
  11. package/dist-lib/bridge-constants.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.mjs +1 -1
  14. package/dist-lib/bridge-contract.cjs +1 -1
  15. package/dist-lib/bridge-contract.mjs +1 -1
  16. package/dist-lib/bundle-channel.cjs +2552 -2481
  17. package/dist-lib/capture-contract.cjs +1 -1
  18. package/dist-lib/capture-contract.mjs +1 -1
  19. package/dist-lib/cloud-contract.cjs +1 -1
  20. package/dist-lib/cloud-contract.mjs +1 -1
  21. package/dist-lib/cloud-test-args.cjs +1 -1
  22. package/dist-lib/cloud-test-args.mjs +1 -1
  23. package/dist-lib/cloud.cjs +1 -1
  24. package/dist-lib/cloud.mjs +1 -1
  25. package/dist-lib/config.cjs +1 -1
  26. package/dist-lib/config.mjs +1 -1
  27. package/dist-lib/detox/index.cjs +2 -2
  28. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  29. package/dist-lib/expo-swift-bundle.cjs +1953 -1881
  30. package/dist-lib/expo-swift-metadata.cjs +1 -1
  31. package/dist-lib/expo-swift-metadata.mjs +1 -1
  32. package/dist-lib/home-paths.cjs +1 -1
  33. package/dist-lib/host/bridge-host.cjs +2765 -2694
  34. package/dist-lib/host/fetch-proxy-handler.cjs +16 -6
  35. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  37. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  38. package/dist-lib/host/websocket-proxy.cjs +1 -1
  39. package/dist-lib/index.cjs +9865 -7701
  40. package/dist-lib/jump-to-source-babel.cjs +1 -1
  41. package/dist-lib/jump-to-source-native.cjs +1 -1
  42. package/dist-lib/kotlin-host.cjs +1 -1
  43. package/dist-lib/menu.cjs +1 -1
  44. package/dist-lib/menu.mjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  47. package/dist-lib/metro-production-bundle.cjs +1 -1
  48. package/dist-lib/metro-production-bundle.mjs +1 -1
  49. package/dist-lib/metro.cjs +6699 -4534
  50. package/dist-lib/native-app-identity-project.cjs +12 -4
  51. package/dist-lib/native-app-identity-project.mjs +12 -4
  52. package/dist-lib/native-app-identity.cjs +11 -3
  53. package/dist-lib/native-app-identity.mjs +11 -3
  54. package/dist-lib/native-firebase-metadata.cjs +1 -1
  55. package/dist-lib/native-firebase-metadata.mjs +1 -1
  56. package/dist-lib/pdfium-raster.cjs +1 -1
  57. package/dist-lib/pdfium-raster.mjs +1 -1
  58. package/dist-lib/plist.cjs +1 -1
  59. package/dist-lib/plist.mjs +1 -1
  60. package/dist-lib/profiles.cjs +1 -1
  61. package/dist-lib/public-brand.cjs +1 -1
  62. package/dist-lib/public-origins-lib-esm.json +26 -25
  63. package/dist-lib/public-origins-lib.json +92 -78
  64. package/dist-lib/react-native-host-modules.cjs +1 -1
  65. package/dist-lib/react-native-host-modules.mjs +1 -1
  66. package/dist-lib/reap-browser.cjs +1 -1
  67. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  68. package/dist-lib/sdk.cjs +1 -1
  69. package/dist-lib/sdk.mjs +1 -1
  70. package/dist-lib/skills.cjs +3468 -3364
  71. package/dist-lib/swift-compile.cjs +1 -1
  72. package/dist-lib/swift-compile.mjs +1 -1
  73. package/dist-lib/swift-package.cjs +1 -1
  74. package/dist-lib/swift-package.mjs +1 -1
  75. package/dist-lib/swift-submit.cjs +1 -1
  76. package/dist-lib/swift-submit.mjs +1 -1
  77. package/dist-lib/swift-toolchain.cjs +1 -1
  78. package/dist-lib/swift.cjs +1 -1
  79. package/dist-lib/vite-swift.cjs +465 -446
  80. package/dist-lib/vite.cjs +16 -6
  81. package/dist-lib/worklet-executable.cjs +421 -118
  82. package/dist-lib/worklet-executable.mjs +427 -113
  83. package/dist-types/packages/peach-engine/src/engine/animation-graph.d.ts +3 -1
  84. package/dist-types/packages/peach-engine/src/engine/node.d.ts +4 -3
  85. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +3 -1
  86. package/dist-types/packages/peach-engine/src/engine/scroll-momentum-math.d.ts +14 -15
  87. package/dist-types/packages/peach-engine/src/engine/scroll-platform.d.ts +17 -21
  88. package/dist-types/packages/peach-engine/src/engine/scroll-velocity.d.ts +0 -1
  89. package/dist-types/packages/peach-engine/src/kernel/kernel.d.ts +69 -0
  90. package/dist-types/packages/peach-engine/src/kernel/worklet-kernel.d.ts +28 -0
  91. package/dist-types/packages/peach-engine/src/platform/personality.d.ts +1 -1
  92. package/dist-types/packages/peach-engine/src/render-worker/app-load.d.ts +4 -0
  93. package/dist-types/packages/peach-engine/src/render-worker/graph-linked-value.d.ts +3 -3
  94. package/dist-types/packages/peach-engine/src/render-worker/worker-input-runtime.d.ts +1 -2
  95. package/dist-types/packages/peach-engine/src/render-worker/worklet-serialize.d.ts +5 -0
  96. package/dist-types/packages/peach-engine/src/render-worker/worklet-wire.d.ts +2 -0
  97. package/kotlin/sdk.tar.gz +0 -0
  98. package/package.json +1 -1
  99. package/runtime-companion.json +1 -1
  100. package/src/expo-native-prebuilt.ts +24 -0
  101. package/src/expo-native-workspace.ts +51 -5
  102. package/src/metro-plugin.ts +4 -1
  103. package/src/nitro-adapter.lock.json +265 -265
  104. package/src/nitro-superset.lock.json +4 -4
  105. package/src/swift-compiler-digest.ts +8 -1
  106. package/src/swift-distribution.lock.json +8 -8
  107. package/src/swift-helper.ts +38 -0
  108. package/src/swift-pdf-raster.ts +7 -33
  109. package/src/turbo-compile.ts +12 -1
  110. package/src/turbo-runtime.lock.json +19 -19
  111. package/src/worklet-executable.ts +4 -1
  112. package/src/worklet-kernel.ts +370 -0
  113. package/src/worklets-babel.ts +10 -0
  114. package/src/xcode-target-members.ts +17 -7
@@ -1,58 +1,370 @@
1
- /*! peach v0.1.2278 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2296 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
+ var __defProp = Object.defineProperty;
3
+ var __typeError = (msg) => {
4
+ throw TypeError(msg);
5
+ };
6
+ var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
7
+ var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
8
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
9
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
10
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
2
11
 
3
12
  // src/worklet-executable.ts
13
+ import { parse as parse2 } from "acorn";
14
+
15
+ // src/worklet-kernel.ts
4
16
  import { parse } from "acorn";
17
+ var Unsupported = class extends Error {
18
+ };
5
19
  function isNode(value) {
6
20
  return value !== null && typeof value === "object" && typeof Reflect.get(value, "type") === "string";
7
21
  }
22
+ function node(value) {
23
+ if (!isNode(value)) throw new Unsupported();
24
+ return value;
25
+ }
26
+ function nodes(value) {
27
+ if (!Array.isArray(value)) throw new Unsupported();
28
+ return value.map(node);
29
+ }
30
+ function name(value) {
31
+ const n = node(value);
32
+ if (n.type !== "Identifier" || typeof n.name !== "string") throw new Unsupported();
33
+ return n.name;
34
+ }
35
+ function key(owner, value) {
36
+ if (owner.computed === true) throw new Unsupported();
37
+ const n = node(value);
38
+ if (n.type === "Identifier" && typeof n.name === "string") return n.name;
39
+ if (n.type === "Literal" && typeof n.value === "string") return n.value;
40
+ throw new Unsupported();
41
+ }
42
+ var MATH = {
43
+ min: { op: "min", arity: "any" },
44
+ max: { op: "max", arity: "any" },
45
+ abs: { op: "abs", arity: 1 },
46
+ sqrt: { op: "sqrt", arity: 1 },
47
+ exp: { op: "exp", arity: 1 },
48
+ sin: { op: "sin", arity: 1 },
49
+ cos: { op: "cos", arity: 1 },
50
+ pow: { op: "pow", arity: 2 }
51
+ };
52
+ var BINARY = {
53
+ "+": "add",
54
+ "-": "sub",
55
+ "*": "mul",
56
+ "/": "quotient",
57
+ "**": "pow"
58
+ };
59
+ var _interned;
60
+ var Recipe = class {
61
+ constructor(closure, event) {
62
+ this.closure = closure;
63
+ this.event = event;
64
+ __publicField(this, "steps", []);
65
+ __privateAdd(this, _interned, /* @__PURE__ */ new Map());
66
+ __publicField(this, "locals", /* @__PURE__ */ new Map());
67
+ }
68
+ step(step) {
69
+ const id = JSON.stringify(step);
70
+ const held = __privateGet(this, _interned).get(id);
71
+ if (held !== void 0) return held;
72
+ this.steps.push(step);
73
+ __privateGet(this, _interned).set(id, this.steps.length - 1);
74
+ return this.steps.length - 1;
75
+ }
76
+ slot(identifier) {
77
+ const slot = this.closure.get(name(identifier));
78
+ if (slot === void 0) throw new Unsupported();
79
+ return slot;
80
+ }
81
+ // a comparison as a kernel 1 or 0, for a conditional's test
82
+ test(expression) {
83
+ if (expression.type !== "BinaryExpression") throw new Unsupported();
84
+ const left = this.value(node(expression.left));
85
+ const right = this.value(node(expression.right));
86
+ switch (expression.operator) {
87
+ case ">":
88
+ return this.step(["op", "gt", left, right]);
89
+ case ">=":
90
+ return this.step(["op", "gte", left, right]);
91
+ case "<":
92
+ return this.step(["op", "gt", right, left]);
93
+ case "<=":
94
+ return this.step(["op", "gte", right, left]);
95
+ }
96
+ throw new Unsupported();
97
+ }
98
+ side(expression) {
99
+ if (expression.type === "Literal" && typeof expression.value === "string")
100
+ return expression.value;
101
+ if (expression.type === "MemberExpression")
102
+ return [
103
+ "member",
104
+ this.slot(expression.object),
105
+ key(expression, expression.property)
106
+ ];
107
+ throw new Unsupported();
108
+ }
109
+ extrapolation(argument) {
110
+ if (argument === void 0) return [null, null];
111
+ const expression = node(argument);
112
+ if (expression.type !== "ObjectExpression") {
113
+ const side = this.side(expression);
114
+ return [side, side];
115
+ }
116
+ let left = null;
117
+ let right = null;
118
+ for (const property of nodes(expression.properties)) {
119
+ if (property.type !== "Property" || property.kind !== "init" || property.method === true)
120
+ throw new Unsupported();
121
+ const which = key(property, property.key);
122
+ if (which === "extrapolateLeft") left = this.side(node(property.value));
123
+ else if (which === "extrapolateRight") right = this.side(node(property.value));
124
+ else throw new Unsupported();
125
+ }
126
+ return [left, right];
127
+ }
128
+ list(argument) {
129
+ const array = node(argument);
130
+ if (array.type !== "ArrayExpression") throw new Unsupported();
131
+ return nodes(array.elements).map((element) => this.value(element));
132
+ }
133
+ value(expression) {
134
+ switch (expression.type) {
135
+ case "Literal":
136
+ if (typeof expression.value !== "number") throw new Unsupported();
137
+ return this.step(["number", expression.value]);
138
+ case "Identifier": {
139
+ const local = this.locals.get(name(expression));
140
+ if (local !== void 0) return local;
141
+ return this.step(["closure", this.slot(expression)]);
142
+ }
143
+ case "MemberExpression": {
144
+ const object = node(expression.object);
145
+ const field = key(expression, expression.property);
146
+ if (field === "value" && object.type === "Identifier")
147
+ return this.step(["shared", this.slot(object)]);
148
+ if (this.event !== void 0 && object.type === "MemberExpression" && node(object.object).type === "Identifier" && name(object.object) === this.event && key(object, object.property) === "contentOffset" && (field === "x" || field === "y"))
149
+ return this.step(["event", `contentOffset.${field}`]);
150
+ throw new Unsupported();
151
+ }
152
+ case "UnaryExpression":
153
+ if (expression.operator !== "-") throw new Unsupported();
154
+ return this.step(["op", "neg", this.value(node(expression.argument))]);
155
+ case "BinaryExpression": {
156
+ const op = BINARY[String(expression.operator)];
157
+ if (!op) throw new Unsupported();
158
+ return this.step([
159
+ "op",
160
+ op,
161
+ this.value(node(expression.left)),
162
+ this.value(node(expression.right))
163
+ ]);
164
+ }
165
+ case "ConditionalExpression":
166
+ return this.step([
167
+ "op",
168
+ "select",
169
+ this.test(node(expression.test)),
170
+ this.value(node(expression.consequent)),
171
+ this.value(node(expression.alternate))
172
+ ]);
173
+ case "CallExpression":
174
+ return this.call(expression);
175
+ }
176
+ throw new Unsupported();
177
+ }
178
+ call(expression) {
179
+ if (expression.optional === true) throw new Unsupported();
180
+ const callee = node(expression.callee);
181
+ const args = nodes(expression.arguments);
182
+ if (args.some((argument) => argument.type === "SpreadElement"))
183
+ throw new Unsupported();
184
+ if (callee.type === "MemberExpression" && node(callee.object).type === "Identifier" && name(callee.object) === "Math" && !this.closure.has("Math")) {
185
+ const math = MATH[key(callee, callee.property)];
186
+ if (!math || args.length === 0) throw new Unsupported();
187
+ if (math.arity !== "any" && args.length !== math.arity) throw new Unsupported();
188
+ const values = args.map((argument) => this.value(argument));
189
+ if (math.arity === 1) return this.step(["op", math.op, values[0]]);
190
+ return values.slice(1).reduce((a, b) => this.step(["op", math.op, a, b]), values[0]);
191
+ }
192
+ if (callee.type !== "Identifier") throw new Unsupported();
193
+ const slot = this.slot(callee);
194
+ if (args.length === 3 && args[1].type !== "ArrayExpression")
195
+ return this.step([
196
+ "clamp",
197
+ slot,
198
+ this.value(args[0]),
199
+ this.value(args[1]),
200
+ this.value(args[2])
201
+ ]);
202
+ if (args.length === 3 || args.length === 4) {
203
+ const inputs = this.list(args[1]);
204
+ const outputs = this.list(args[2]);
205
+ if (inputs.length < 2 || inputs.length !== outputs.length) throw new Unsupported();
206
+ return this.step([
207
+ "interpolate",
208
+ slot,
209
+ this.value(args[0]),
210
+ inputs,
211
+ outputs,
212
+ this.extrapolation(args[3])
213
+ ]);
214
+ }
215
+ throw new Unsupported();
216
+ }
217
+ };
218
+ _interned = new WeakMap();
219
+ function closureSlots(statement) {
220
+ if (statement.type !== "VariableDeclaration") return void 0;
221
+ const [declarator] = nodes(statement.declarations);
222
+ if (nodes(statement.declarations).length !== 1 || !declarator) return void 0;
223
+ const init = declarator.init === null ? void 0 : node(declarator.init);
224
+ if (!init || init.type !== "MemberExpression" || node(init.object).type !== "ThisExpression" || key(init, init.property) !== "__closure")
225
+ return void 0;
226
+ const pattern = node(declarator.id);
227
+ if (pattern.type !== "ArrayPattern") throw new Unsupported();
228
+ const slots = /* @__PURE__ */ new Map();
229
+ nodes(pattern.elements).forEach((element, index) => slots.set(name(element), index));
230
+ return slots;
231
+ }
232
+ function styleOutputs(recipe, expression, path, outputs) {
233
+ if (expression.type === "ObjectExpression") {
234
+ for (const property of nodes(expression.properties)) {
235
+ if (property.type !== "Property" || property.kind !== "init" || property.method === true)
236
+ throw new Unsupported();
237
+ const field = key(property, property.key);
238
+ styleOutputs(
239
+ recipe,
240
+ node(property.value),
241
+ path ? `${path}.${field}` : field,
242
+ outputs
243
+ );
244
+ }
245
+ return;
246
+ }
247
+ if (expression.type === "ArrayExpression") {
248
+ nodes(expression.elements).forEach(
249
+ (element, index) => styleOutputs(recipe, element, `${path}.${index}`, outputs)
250
+ );
251
+ return;
252
+ }
253
+ outputs.push([path, recipe.value(expression)]);
254
+ }
255
+ function compileWorkletKernel(code) {
256
+ try {
257
+ const program = parse(`(${code})`, { ecmaVersion: "latest" });
258
+ const [statement] = nodes(program.body);
259
+ if (!statement || statement.type !== "ExpressionStatement") return void 0;
260
+ const fn = node(statement.expression);
261
+ if (fn.type !== "FunctionExpression" || fn.async === true || fn.generator === true)
262
+ return void 0;
263
+ const params = nodes(fn.params);
264
+ const body = nodes(node(fn.body).body);
265
+ const slots = body[0] ? closureSlots(body[0]) : void 0;
266
+ const statements = slots ? body.slice(1) : body;
267
+ if (params.length === 0) {
268
+ const recipe2 = new Recipe(slots ?? /* @__PURE__ */ new Map(), void 0);
269
+ for (const [index, item] of statements.entries()) {
270
+ if (item.type === "ReturnStatement" && index === statements.length - 1) {
271
+ const outputs = [];
272
+ const returned = node(item.argument);
273
+ if (returned.type !== "ObjectExpression") return void 0;
274
+ styleOutputs(recipe2, returned, "", outputs);
275
+ if (outputs.length === 0) return void 0;
276
+ return { kind: "style", steps: recipe2.steps, outputs };
277
+ }
278
+ declareLocals(recipe2, item);
279
+ }
280
+ return void 0;
281
+ }
282
+ if (params.length > 2) return void 0;
283
+ const recipe = new Recipe(slots ?? /* @__PURE__ */ new Map(), name(params[0]));
284
+ const writes = [];
285
+ for (const item of statements) {
286
+ if (item.type === "VariableDeclaration") {
287
+ declareLocals(recipe, item);
288
+ continue;
289
+ }
290
+ if (item.type !== "ExpressionStatement") return void 0;
291
+ const assignment = node(item.expression);
292
+ if (assignment.type !== "AssignmentExpression" || assignment.operator !== "=")
293
+ return void 0;
294
+ const target = node(assignment.left);
295
+ if (target.type !== "MemberExpression" || key(target, target.property) !== "value")
296
+ return void 0;
297
+ writes.push([recipe.slot(target.object), recipe.value(node(assignment.right))]);
298
+ }
299
+ if (writes.length === 0) return void 0;
300
+ return { kind: "handler", steps: recipe.steps, writes };
301
+ } catch (error) {
302
+ if (error instanceof Unsupported) return void 0;
303
+ throw error;
304
+ }
305
+ }
306
+ function declareLocals(recipe, item) {
307
+ if (item.type !== "VariableDeclaration" || item.kind !== "const")
308
+ throw new Unsupported();
309
+ for (const declarator of nodes(item.declarations)) {
310
+ const local = name(declarator.id);
311
+ if (recipe.closure.has(local) || recipe.locals.has(local)) throw new Unsupported();
312
+ recipe.locals.set(local, recipe.value(node(declarator.init)));
313
+ }
314
+ }
315
+
316
+ // src/worklet-executable.ts
317
+ function isNode2(value) {
318
+ return value !== null && typeof value === "object" && typeof Reflect.get(value, "type") === "string";
319
+ }
8
320
  function childNodes(value) {
9
- return Array.isArray(value) ? value.filter(isNode) : [];
10
- }
11
- function identifierName(node) {
12
- if (!isNode(node) || node.type !== "Identifier") return void 0;
13
- const name = Reflect.get(node, "name");
14
- return typeof name === "string" ? name : void 0;
15
- }
16
- function constantString(node) {
17
- if (!isNode(node)) return void 0;
18
- if (node.type === "TemplateLiteral") {
19
- const expressions = Reflect.get(node, "expressions");
20
- const quasis = Reflect.get(node, "quasis");
321
+ return Array.isArray(value) ? value.filter(isNode2) : [];
322
+ }
323
+ function identifierName(node2) {
324
+ if (!isNode2(node2) || node2.type !== "Identifier") return void 0;
325
+ const name2 = Reflect.get(node2, "name");
326
+ return typeof name2 === "string" ? name2 : void 0;
327
+ }
328
+ function constantString(node2) {
329
+ if (!isNode2(node2)) return void 0;
330
+ if (node2.type === "TemplateLiteral") {
331
+ const expressions = Reflect.get(node2, "expressions");
332
+ const quasis = Reflect.get(node2, "quasis");
21
333
  if (!Array.isArray(expressions) || expressions.length > 0) return void 0;
22
- if (!Array.isArray(quasis) || quasis.length !== 1 || !isNode(quasis[0]))
334
+ if (!Array.isArray(quasis) || quasis.length !== 1 || !isNode2(quasis[0]))
23
335
  return void 0;
24
336
  const value2 = Reflect.get(quasis[0], "value");
25
337
  const cooked = value2 && typeof value2 === "object" && Reflect.get(value2, "cooked");
26
338
  return typeof cooked === "string" ? cooked : void 0;
27
339
  }
28
- const value = Reflect.get(node, "value");
340
+ const value = Reflect.get(node2, "value");
29
341
  return typeof value === "string" ? value : void 0;
30
342
  }
31
- function propertyName(node) {
32
- if (!isNode(node)) return void 0;
33
- const name = Reflect.get(node, node.type === "Identifier" ? "name" : "value");
34
- return typeof name === "string" ? name : void 0;
343
+ function propertyName(node2) {
344
+ if (!isNode2(node2)) return void 0;
345
+ const name2 = Reflect.get(node2, node2.type === "Identifier" ? "name" : "value");
346
+ return typeof name2 === "string" ? name2 : void 0;
35
347
  }
36
- function keyName(owner, key) {
37
- if (Reflect.get(owner, "computed") === true && isNode(key) && key.type === "Identifier")
348
+ function keyName(owner, key2) {
349
+ if (Reflect.get(owner, "computed") === true && isNode2(key2) && key2.type === "Identifier")
38
350
  return void 0;
39
- return propertyName(key);
351
+ return propertyName(key2);
40
352
  }
41
- function patternNames(node) {
42
- if (!isNode(node)) return [];
43
- switch (node.type) {
353
+ function patternNames(node2) {
354
+ if (!isNode2(node2)) return [];
355
+ switch (node2.type) {
44
356
  case "Identifier": {
45
- const name = identifierName(node);
46
- return name === void 0 ? [] : [name];
357
+ const name2 = identifierName(node2);
358
+ return name2 === void 0 ? [] : [name2];
47
359
  }
48
360
  case "AssignmentPattern":
49
- return patternNames(Reflect.get(node, "left"));
361
+ return patternNames(Reflect.get(node2, "left"));
50
362
  case "RestElement":
51
- return patternNames(Reflect.get(node, "argument"));
363
+ return patternNames(Reflect.get(node2, "argument"));
52
364
  case "ArrayPattern":
53
- return childNodes(Reflect.get(node, "elements")).flatMap(patternNames);
365
+ return childNodes(Reflect.get(node2, "elements")).flatMap(patternNames);
54
366
  case "ObjectPattern":
55
- return childNodes(Reflect.get(node, "properties")).flatMap(
367
+ return childNodes(Reflect.get(node2, "properties")).flatMap(
56
368
  (property) => patternNames(
57
369
  property.type === "Property" || property.type === "ObjectProperty" ? Reflect.get(property, "value") : property
58
370
  )
@@ -75,46 +387,46 @@ function hoistScope(scope) {
75
387
  while (!current.hoist && current.parent) current = current.parent;
76
388
  return current;
77
389
  }
78
- function declare(scope, name, binding) {
79
- scope.names.set(name, scope.names.has(name) ? { kind: "opaque" } : binding);
390
+ function declare(scope, name2, binding) {
391
+ scope.names.set(name2, scope.names.has(name2) ? { kind: "opaque" } : binding);
80
392
  }
81
393
  function declareOpaque(scope, names) {
82
- for (const name of names) declare(scope, name, { kind: "opaque" });
394
+ for (const name2 of names) declare(scope, name2, { kind: "opaque" });
83
395
  }
84
- function lookup(scope, name) {
396
+ function lookup(scope, name2) {
85
397
  for (let current = scope; current; current = current.parent) {
86
- const binding = current.names.get(name);
398
+ const binding = current.names.get(name2);
87
399
  if (binding) return binding;
88
400
  }
89
401
  return void 0;
90
402
  }
91
403
  function declareParam(inner, fn, index, param) {
92
- const name = identifierName(param);
93
- if (name !== void 0) {
94
- declare(inner, name, { kind: "param", fn, index });
404
+ const name2 = identifierName(param);
405
+ if (name2 !== void 0) {
406
+ declare(inner, name2, { kind: "param", fn, index });
95
407
  return;
96
408
  }
97
- if (isNode(param) && param.type === "ArrayPattern") {
409
+ if (isNode2(param) && param.type === "ArrayPattern") {
98
410
  const elements = Reflect.get(param, "elements");
99
411
  if (!Array.isArray(elements)) return;
100
412
  elements.forEach((element, position) => {
101
- const name2 = identifierName(element);
102
- if (name2 !== void 0)
103
- declare(inner, name2, { kind: "param", fn, index, key: String(position) });
413
+ const name3 = identifierName(element);
414
+ if (name3 !== void 0)
415
+ declare(inner, name3, { kind: "param", fn, index, key: String(position) });
104
416
  else declareOpaque(inner, patternNames(element));
105
417
  });
106
418
  return;
107
419
  }
108
- if (!isNode(param) || param.type !== "ObjectPattern") {
420
+ if (!isNode2(param) || param.type !== "ObjectPattern") {
109
421
  declareOpaque(inner, patternNames(param));
110
422
  return;
111
423
  }
112
424
  for (const property of childNodes(Reflect.get(param, "properties"))) {
113
- const key = keyName(property, Reflect.get(property, "key"));
425
+ const key2 = keyName(property, Reflect.get(property, "key"));
114
426
  const value = Reflect.get(property, "value");
115
427
  const valueName = identifierName(value);
116
- if (key !== void 0 && valueName !== void 0 && ["Property", "ObjectProperty"].includes(property.type))
117
- declare(inner, valueName, { kind: "param", fn, index, key });
428
+ if (key2 !== void 0 && valueName !== void 0 && ["Property", "ObjectProperty"].includes(property.type))
429
+ declare(inner, valueName, { kind: "param", fn, index, key: key2 });
118
430
  else
119
431
  declareOpaque(
120
432
  inner,
@@ -122,19 +434,19 @@ function declareParam(inner, fn, index, param) {
122
434
  );
123
435
  }
124
436
  }
125
- function enter(node, scope) {
126
- switch (node.type) {
437
+ function enter(node2, scope) {
438
+ switch (node2.type) {
127
439
  case "FunctionDeclaration":
128
440
  case "FunctionExpression":
129
441
  case "ArrowFunctionExpression": {
130
442
  const inner = newScope(scope, true);
131
- const params = Reflect.get(node, "params");
443
+ const params = Reflect.get(node2, "params");
132
444
  if (Array.isArray(params)) {
133
- params.forEach((param, index) => declareParam(inner, node, index, param));
445
+ params.forEach((param, index) => declareParam(inner, node2, index, param));
134
446
  }
135
- const id = Reflect.get(node, "id");
136
- if (node.type === "FunctionExpression") declareOpaque(inner, patternNames(id));
137
- if (node.type === "FunctionDeclaration") {
447
+ const id = Reflect.get(node2, "id");
448
+ if (node2.type === "FunctionExpression") declareOpaque(inner, patternNames(id));
449
+ if (node2.type === "FunctionDeclaration") {
138
450
  declareOpaque(scope, patternNames(id));
139
451
  declareOpaque(hoistScope(scope), patternNames(id));
140
452
  }
@@ -149,79 +461,79 @@ function enter(node, scope) {
149
461
  return newScope(scope, false);
150
462
  case "CatchClause": {
151
463
  const inner = newScope(scope, false);
152
- declareOpaque(inner, patternNames(Reflect.get(node, "param")));
464
+ declareOpaque(inner, patternNames(Reflect.get(node2, "param")));
153
465
  return inner;
154
466
  }
155
467
  case "VariableDeclaration": {
156
- const target = Reflect.get(node, "kind") === "var" ? hoistScope(scope) : scope;
157
- for (const declarator of childNodes(Reflect.get(node, "declarations"))) {
468
+ const target = Reflect.get(node2, "kind") === "var" ? hoistScope(scope) : scope;
469
+ for (const declarator of childNodes(Reflect.get(node2, "declarations"))) {
158
470
  const id = Reflect.get(declarator, "id");
159
471
  const init = Reflect.get(declarator, "init");
160
- const name = identifierName(id);
161
- if (name !== void 0 && isNode(init))
162
- declare(target, name, { kind: "value", init, scope });
163
- else if (name !== void 0 && init === null)
164
- declare(target, name, { kind: "uninitialized" });
472
+ const name2 = identifierName(id);
473
+ if (name2 !== void 0 && isNode2(init))
474
+ declare(target, name2, { kind: "value", init, scope });
475
+ else if (name2 !== void 0 && init === null)
476
+ declare(target, name2, { kind: "uninitialized" });
165
477
  else declareOpaque(target, patternNames(id));
166
478
  }
167
479
  return scope;
168
480
  }
169
481
  case "ImportDeclaration":
170
- for (const specifier of childNodes(Reflect.get(node, "specifiers")))
482
+ for (const specifier of childNodes(Reflect.get(node2, "specifiers")))
171
483
  declareOpaque(scope, patternNames(Reflect.get(specifier, "local")));
172
484
  return scope;
173
485
  case "ClassDeclaration":
174
- declareOpaque(scope, patternNames(Reflect.get(node, "id")));
486
+ declareOpaque(scope, patternNames(Reflect.get(node2, "id")));
175
487
  return scope;
176
488
  default:
177
489
  return scope;
178
490
  }
179
491
  }
180
492
  function recordWrites(target, scope, collection, value) {
181
- const name = identifierName(target);
182
- if (name !== void 0 && value) {
183
- collection.writes.push({ name, scope, value });
493
+ const name2 = identifierName(target);
494
+ if (name2 !== void 0 && value) {
495
+ collection.writes.push({ name: name2, scope, value });
184
496
  return;
185
497
  }
186
- for (const name2 of patternNames(target)) collection.writes.push({ name: name2, scope });
498
+ for (const name3 of patternNames(target)) collection.writes.push({ name: name3, scope });
187
499
  }
188
- function record(node, scope, collection) {
189
- switch (node.type) {
500
+ function record(node2, scope, collection) {
501
+ switch (node2.type) {
190
502
  case "AssignmentExpression": {
191
- const left = Reflect.get(node, "left");
192
- const right = Reflect.get(node, "right");
193
- if (isNode(left) && left.type === "MemberExpression" && keyName(left, Reflect.get(left, "property")) === "__initData" && isNode(right))
503
+ const left = Reflect.get(node2, "left");
504
+ const right = Reflect.get(node2, "right");
505
+ if (isNode2(left) && left.type === "MemberExpression" && keyName(left, Reflect.get(left, "property")) === "__initData" && isNode2(right))
194
506
  collection.inits.push({ value: right, scope });
195
507
  recordWrites(
196
508
  left,
197
509
  scope,
198
510
  collection,
199
- Reflect.get(node, "operator") === "=" && isNode(right) ? right : void 0
511
+ Reflect.get(node2, "operator") === "=" && isNode2(right) ? right : void 0
200
512
  );
201
513
  return;
202
514
  }
203
515
  case "UpdateExpression":
204
- recordWrites(Reflect.get(node, "argument"), scope, collection);
516
+ recordWrites(Reflect.get(node2, "argument"), scope, collection);
205
517
  return;
206
518
  case "ForInStatement":
207
519
  case "ForOfStatement":
208
- recordWrites(Reflect.get(node, "left"), scope, collection);
520
+ recordWrites(Reflect.get(node2, "left"), scope, collection);
209
521
  return;
210
522
  case "CallExpression": {
211
- const callee = Reflect.get(node, "callee");
212
- if (isNode(callee) && FUNCTION_TYPES.has(callee.type))
213
- collection.immediate.set(callee, { call: node, scope });
523
+ const callee = Reflect.get(node2, "callee");
524
+ if (isNode2(callee) && FUNCTION_TYPES.has(callee.type))
525
+ collection.immediate.set(callee, { call: node2, scope });
214
526
  return;
215
527
  }
216
528
  default:
217
529
  return;
218
530
  }
219
531
  }
220
- function visit(node, scope, collection) {
221
- record(node, scope, collection);
222
- const inner = enter(node, scope);
223
- for (const value of Object.values(node)) {
224
- if (isNode(value)) visit(value, inner, collection);
532
+ function visit(node2, scope, collection) {
533
+ record(node2, scope, collection);
534
+ const inner = enter(node2, scope);
535
+ for (const value of Object.values(node2)) {
536
+ if (isNode2(value)) visit(value, inner, collection);
225
537
  else for (const child of childNodes(value)) visit(child, inner, collection);
226
538
  }
227
539
  }
@@ -235,8 +547,8 @@ function collectInitData(root) {
235
547
  free: /* @__PURE__ */ new Map()
236
548
  };
237
549
  visit(root, newScope(void 0, true), collection);
238
- for (const { name, scope, value } of collection.writes) {
239
- const binding = lookup(scope, name);
550
+ for (const { name: name2, scope, value } of collection.writes) {
551
+ const binding = lookup(scope, name2);
240
552
  if (binding?.kind === "uninitialized")
241
553
  collection.assigned.set(
242
554
  binding,
@@ -245,8 +557,8 @@ function collectInitData(root) {
245
557
  else if (binding) collection.reassigned.add(binding);
246
558
  else
247
559
  collection.free.set(
248
- name,
249
- collection.free.has(name) || !value ? null : { value, scope }
560
+ name2,
561
+ collection.free.has(name2) || !value ? null : { value, scope }
250
562
  );
251
563
  }
252
564
  return collection;
@@ -256,35 +568,35 @@ function immediateArgument(fn, index, collection) {
256
568
  const args = immediate && Reflect.get(immediate.call, "arguments");
257
569
  if (!immediate || !Array.isArray(args)) return void 0;
258
570
  const preceding = args.slice(0, index + 1);
259
- if (preceding.some((arg) => isNode(arg) && arg.type === "SpreadElement"))
571
+ if (preceding.some((arg) => isNode2(arg) && arg.type === "SpreadElement"))
260
572
  return void 0;
261
573
  return { argument: args[index], scope: immediate.scope };
262
574
  }
263
- function propertyValue(object, name) {
575
+ function propertyValue(object, name2) {
264
576
  if (object.type === "ArrayExpression") {
265
- const index = Number(name);
577
+ const index = Number(name2);
266
578
  const elements = Reflect.get(object, "elements");
267
- if (!Number.isSafeInteger(index) || index < 0 || String(index) !== name)
579
+ if (!Number.isSafeInteger(index) || index < 0 || String(index) !== name2)
268
580
  return void 0;
269
581
  if (!Array.isArray(elements)) return void 0;
270
- if (elements.slice(0, index + 1).some((element) => isNode(element) && element.type === "SpreadElement"))
582
+ if (elements.slice(0, index + 1).some((element) => isNode2(element) && element.type === "SpreadElement"))
271
583
  return void 0;
272
584
  const value2 = elements[index];
273
- return isNode(value2) ? value2 : void 0;
585
+ return isNode2(value2) ? value2 : void 0;
274
586
  }
275
587
  let value;
276
588
  for (const property of childNodes(Reflect.get(object, "properties"))) {
277
589
  if (property.type === "SpreadElement") return void 0;
278
590
  if (!["Property", "ObjectProperty"].includes(property.type)) continue;
279
- if (keyName(property, Reflect.get(property, "key")) !== name) continue;
591
+ if (keyName(property, Reflect.get(property, "key")) !== name2) continue;
280
592
  const next = Reflect.get(property, "value");
281
- value = isNode(next) ? next : void 0;
593
+ value = isNode2(next) ? next : void 0;
282
594
  }
283
595
  return value;
284
596
  }
285
- function resolveProperty(owner, name, collection, depth) {
597
+ function resolveProperty(owner, name2, collection, depth) {
286
598
  if (!owner) return void 0;
287
- const value = propertyValue(owner.object, name);
599
+ const value = propertyValue(owner.object, name2);
288
600
  return value && resolveObject(value, owner.scope, collection, depth + 1);
289
601
  }
290
602
  function resolveObject(expression, scope, collection, depth) {
@@ -296,10 +608,10 @@ function resolveObject(expression, scope, collection, depth) {
296
608
  return last && resolveObject(last, scope, collection, depth + 1);
297
609
  }
298
610
  if (expression.type === "Identifier") {
299
- const name = identifierName(expression);
300
- const binding = name === void 0 ? void 0 : lookup(scope, name);
611
+ const name2 = identifierName(expression);
612
+ const binding = name2 === void 0 ? void 0 : lookup(scope, name2);
301
613
  if (!binding) {
302
- const free = name === void 0 ? void 0 : collection.free.get(name);
614
+ const free = name2 === void 0 ? void 0 : collection.free.get(name2);
303
615
  return free ? resolveObject(free.value, free.scope, collection, depth + 1) : void 0;
304
616
  }
305
617
  if (collection.reassigned.has(binding)) return void 0;
@@ -311,23 +623,23 @@ function resolveObject(expression, scope, collection, depth) {
311
623
  return resolveObject(binding.init, binding.scope, collection, depth + 1);
312
624
  if (binding.kind === "param") {
313
625
  const passed = immediateArgument(binding.fn, binding.index, collection);
314
- if (!passed || !isNode(passed.argument)) return void 0;
626
+ if (!passed || !isNode2(passed.argument)) return void 0;
315
627
  const argument = resolveObject(passed.argument, passed.scope, collection, depth + 1);
316
628
  return binding.key === void 0 ? argument : resolveProperty(argument, binding.key, collection, depth);
317
629
  }
318
630
  return void 0;
319
631
  }
320
632
  if (expression.type === "MemberExpression") {
321
- const name = keyName(expression, Reflect.get(expression, "property"));
633
+ const name2 = keyName(expression, Reflect.get(expression, "property"));
322
634
  const object = Reflect.get(expression, "object");
323
- if (name === void 0 || !isNode(object)) return void 0;
635
+ if (name2 === void 0 || !isNode2(object)) return void 0;
324
636
  const owner = resolveObject(object, scope, collection, depth + 1);
325
- return resolveProperty(owner, name, collection, depth);
637
+ return resolveProperty(owner, name2, collection, depth);
326
638
  }
327
639
  return void 0;
328
640
  }
329
641
  function workletExecutableBodies(syntax, includeCompiled = false) {
330
- if (!isNode(syntax)) throw new Error("peach: expected worklet syntax");
642
+ if (!isNode2(syntax)) throw new Error("peach: expected worklet syntax");
331
643
  const collection = collectInitData(syntax);
332
644
  const objects = /* @__PURE__ */ new Set();
333
645
  for (const { value, scope } of collection.inits) {
@@ -339,13 +651,13 @@ function workletExecutableBodies(syntax, includeCompiled = false) {
339
651
  const properties = Reflect.get(object, "properties");
340
652
  if (!Array.isArray(properties)) continue;
341
653
  if (!includeCompiled && properties.some(
342
- (property2) => isNode(property2) && propertyName(Reflect.get(property2, "key")) === "__peachExecutable"
654
+ (property2) => isNode2(property2) && propertyName(Reflect.get(property2, "key")) === "__peachExecutable"
343
655
  ))
344
656
  continue;
345
657
  const property = properties.find(
346
- (property2) => isNode(property2) && ["Property", "ObjectProperty"].includes(property2.type) && propertyName(Reflect.get(property2, "key")) === "code"
658
+ (property2) => isNode2(property2) && ["Property", "ObjectProperty"].includes(property2.type) && propertyName(Reflect.get(property2, "key")) === "code"
347
659
  );
348
- if (!isNode(property)) continue;
660
+ if (!isNode2(property)) continue;
349
661
  const code = constantString(Reflect.get(property, "value"));
350
662
  if (code === void 0) {
351
663
  throw new Error("peach: worklet init data requires literal code at build time");
@@ -356,17 +668,19 @@ function workletExecutableBodies(syntax, includeCompiled = false) {
356
668
  }
357
669
  function compileWorkletExecutables(source, onInsert) {
358
670
  if (!source.includes("__initData")) return source;
359
- const tree = parse(source, { ecmaVersion: "latest", sourceType: "module" });
671
+ const tree = parse2(source, { ecmaVersion: "latest", sourceType: "module" });
360
672
  const edits = workletExecutableBodies(tree).map(({ codeProperty, code }) => {
361
673
  const body = compileWorkletExecutables(code);
362
- const expression = parse(`(${body})`, { ecmaVersion: "latest" }).body[0];
674
+ const expression = parse2(`(${body})`, { ecmaVersion: "latest" }).body[0];
363
675
  const fn = expression && Reflect.get(expression, "expression");
364
- if (!isNode(fn) || !["FunctionExpression", "ArrowFunctionExpression"].includes(fn.type)) {
676
+ if (!isNode2(fn) || !["FunctionExpression", "ArrowFunctionExpression"].includes(fn.type)) {
365
677
  throw new Error("peach: worklet code did not compile to a function");
366
678
  }
367
679
  const offset = Reflect.get(codeProperty, "end");
368
680
  if (typeof offset !== "number") throw new Error("peach: worklet code has no offset");
369
- return { offset, text: `, __peachExecutable: (${body})` };
681
+ const kernel = compileWorkletKernel(code);
682
+ const recipe = kernel ? `, __peachKernel: ${JSON.stringify(kernel)}` : "";
683
+ return { offset, text: `, __peachExecutable: (${body})${recipe}` };
370
684
  });
371
685
  const parts = [];
372
686
  let cursor = source.length;