peachsim 0.1.800 → 0.1.809

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 (82) hide show
  1. package/cli/drivers/playwright-sim-host.ts +2 -0
  2. package/cli/outbound-endpoints.ts +0 -4
  3. package/dist-lib/agent-daemon-client.cjs +1 -1
  4. package/dist-lib/agent-events.cjs +1 -1
  5. package/dist-lib/agent-identity.cjs +1 -1
  6. package/dist-lib/agent-sessions.cjs +1 -1
  7. package/dist-lib/attached-projects.cjs +1 -1
  8. package/dist-lib/auth/shared-session.cjs +1 -1
  9. package/dist-lib/backend-origin.cjs +1 -1
  10. package/dist-lib/beta.cjs +1 -1
  11. package/dist-lib/beta.mjs +1 -1
  12. package/dist-lib/bridge-constants.cjs +1 -1
  13. package/dist-lib/bridge-contract-input.cjs +1 -1
  14. package/dist-lib/bridge-contract-input.mjs +1 -1
  15. package/dist-lib/bridge-contract.cjs +1 -1
  16. package/dist-lib/bridge-contract.mjs +1 -1
  17. package/dist-lib/bundle-channel.cjs +132 -10
  18. package/dist-lib/capture-contract.cjs +1 -1
  19. package/dist-lib/capture-contract.mjs +1 -1
  20. package/dist-lib/cli-constants.cjs +1 -1
  21. package/dist-lib/cloud-contract.cjs +1 -1
  22. package/dist-lib/cloud-contract.mjs +1 -1
  23. package/dist-lib/cloud-test-args.cjs +1 -1
  24. package/dist-lib/cloud-test-args.mjs +1 -1
  25. package/dist-lib/cloud.cjs +1 -1
  26. package/dist-lib/cloud.mjs +1 -1
  27. package/dist-lib/config.cjs +1 -1
  28. package/dist-lib/detox/index.cjs +46 -7
  29. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  30. package/dist-lib/expo-swift-bundle.cjs +132 -10
  31. package/dist-lib/expo-swift-metadata.cjs +1 -1
  32. package/dist-lib/expo-swift-metadata.mjs +1 -1
  33. package/dist-lib/home-paths.cjs +1 -1
  34. package/dist-lib/host/bridge-host.cjs +252 -108
  35. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  36. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  37. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  38. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  39. package/dist-lib/host/websocket-proxy.cjs +1 -1
  40. package/dist-lib/index.cjs +1 -1
  41. package/dist-lib/jump-to-source-babel.cjs +1 -1
  42. package/dist-lib/jump-to-source-native.cjs +1 -1
  43. package/dist-lib/kotlin-host.cjs +1 -1
  44. package/dist-lib/menu.cjs +1 -1
  45. package/dist-lib/menu.mjs +1 -1
  46. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  47. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  48. package/dist-lib/metro-production-bundle.cjs +1 -1
  49. package/dist-lib/metro-production-bundle.mjs +1 -1
  50. package/dist-lib/metro.cjs +1 -1
  51. package/dist-lib/native-app-identity.cjs +1 -1
  52. package/dist-lib/native-app-identity.mjs +1 -1
  53. package/dist-lib/native-firebase-metadata.cjs +1 -1
  54. package/dist-lib/native-firebase-metadata.mjs +1 -1
  55. package/dist-lib/plist.cjs +1 -1
  56. package/dist-lib/plist.mjs +1 -1
  57. package/dist-lib/profiles.cjs +1 -1
  58. package/dist-lib/public-brand.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.cjs +1 -1
  60. package/dist-lib/react-native-host-modules.mjs +1 -1
  61. package/dist-lib/render-mode.cjs +1 -1
  62. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  63. package/dist-lib/sdk.cjs +1 -1
  64. package/dist-lib/sdk.mjs +1 -1
  65. package/dist-lib/skills.cjs +252 -108
  66. package/dist-lib/swift-compile.cjs +141 -11
  67. package/dist-lib/swift-compile.mjs +140 -11
  68. package/dist-lib/swift-package.cjs +1 -1
  69. package/dist-lib/swift-package.mjs +1 -1
  70. package/dist-lib/swift-submit.cjs +1 -1
  71. package/dist-lib/swift-submit.mjs +1 -1
  72. package/dist-lib/swift-toolchain.cjs +1 -1
  73. package/dist-lib/swift.cjs +1 -1
  74. package/dist-lib/vite-swift.cjs +132 -10
  75. package/dist-lib/vite.cjs +1 -1
  76. package/dist-lib/worklet-executable.cjs +119 -0
  77. package/dist-lib/worklet-executable.mjs +93 -0
  78. package/package.json +9 -1
  79. package/src/swift-compile.ts +160 -11
  80. package/src/vite-plugin.ts +5 -2
  81. package/src/worklet-executable.ts +125 -0
  82. package/src/worklets-babel.ts +47 -6
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.800 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.809 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -2042,7 +2042,7 @@ var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"'
2042
2042
  var MULTI_MANIFEST_VERSION = 12;
2043
2043
  function swiftArtifactHash(input, release, moduleRoot) {
2044
2044
  const hash = (0, import_node_crypto2.createHash)("sha256");
2045
- hash.update(`swift-compile/v18
2045
+ hash.update(`swift-compile/v20
2046
2046
  ${release}
2047
2047
  `);
2048
2048
  if (input.oneModule) hash.update("one-module\n");
@@ -2640,6 +2640,125 @@ function lowerNotificationDelegate(source) {
2640
2640
  result = result.slice(0, at) + text3 + result.slice(at + count);
2641
2641
  return result;
2642
2642
  }
2643
+ function tableProtocolConformances(sources) {
2644
+ const parents = /* @__PURE__ */ new Map();
2645
+ for (const source of sources) {
2646
+ const code = swiftCodeMask(source);
2647
+ for (const owner of code.matchAll(
2648
+ /\b(?:class|extension)\s+([A-Za-z_]\w*)\s*:\s*([^{}]+)\{/g
2649
+ )) {
2650
+ const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
2651
+ for (const type of owner[2].matchAll(/\b[A-Za-z_]\w*\b/g)) inherited.add(type[0]);
2652
+ parents.set(owner[1], inherited);
2653
+ }
2654
+ }
2655
+ const result = /* @__PURE__ */ new Map();
2656
+ const protocols = ["UITableViewDataSource", "UITableViewDelegate"];
2657
+ for (const type of parents.keys()) {
2658
+ const pending = [type];
2659
+ const seen = /* @__PURE__ */ new Set();
2660
+ const conformances = /* @__PURE__ */ new Set();
2661
+ while (pending.length) {
2662
+ const next = pending.pop();
2663
+ if (seen.has(next)) continue;
2664
+ seen.add(next);
2665
+ if (protocols.includes(next)) conformances.add(next);
2666
+ for (const parent of parents.get(next) ?? []) pending.push(parent);
2667
+ }
2668
+ if (conformances.size) result.set(type, conformances);
2669
+ }
2670
+ return result;
2671
+ }
2672
+ function lowerTableProtocolMethods(source, conformances) {
2673
+ const code = swiftCodeMask(source);
2674
+ const dataSource = {
2675
+ numberOfRowsInSection: "tableView:numberOfRowsInSection:",
2676
+ cellForRowAt: "tableView:cellForRowAtIndexPath:",
2677
+ titleForHeaderInSection: "tableView:titleForHeaderInSection:",
2678
+ titleForFooterInSection: "tableView:titleForFooterInSection:",
2679
+ canEditRowAt: "tableView:canEditRowAtIndexPath:",
2680
+ commit: "tableView:commitEditingStyle:forRowAtIndexPath:"
2681
+ };
2682
+ const delegate = {
2683
+ willDisplay: "tableView:willDisplayCell:forRowAtIndexPath:",
2684
+ didEndDisplaying: "tableView:didEndDisplayingCell:forRowAtIndexPath:",
2685
+ heightForRowAt: "tableView:heightForRowAtIndexPath:",
2686
+ estimatedHeightForRowAt: "tableView:estimatedHeightForRowAtIndexPath:",
2687
+ heightForHeaderInSection: "tableView:heightForHeaderInSection:",
2688
+ heightForFooterInSection: "tableView:heightForFooterInSection:",
2689
+ estimatedHeightForHeaderInSection: "tableView:estimatedHeightForHeaderInSection:",
2690
+ estimatedHeightForFooterInSection: "tableView:estimatedHeightForFooterInSection:",
2691
+ viewForHeaderInSection: "tableView:viewForHeaderInSection:",
2692
+ viewForFooterInSection: "tableView:viewForFooterInSection:",
2693
+ willDisplayHeaderView: "tableView:willDisplayHeaderView:forSection:",
2694
+ willDisplayFooterView: "tableView:willDisplayFooterView:forSection:",
2695
+ didEndDisplayingHeaderView: "tableView:didEndDisplayingHeaderView:forSection:",
2696
+ didEndDisplayingFooterView: "tableView:didEndDisplayingFooterView:forSection:",
2697
+ shouldHighlightRowAt: "tableView:shouldHighlightRowAtIndexPath:",
2698
+ didHighlightRowAt: "tableView:didHighlightRowAtIndexPath:",
2699
+ didUnhighlightRowAt: "tableView:didUnhighlightRowAtIndexPath:",
2700
+ willSelectRowAt: "tableView:willSelectRowAtIndexPath:",
2701
+ willDeselectRowAt: "tableView:willDeselectRowAtIndexPath:",
2702
+ didSelectRowAt: "tableView:didSelectRowAtIndexPath:",
2703
+ didDeselectRowAt: "tableView:didDeselectRowAtIndexPath:",
2704
+ accessoryButtonTappedForRowWith: "tableView:accessoryButtonTappedForRowWithIndexPath:",
2705
+ editingStyleForRowAt: "tableView:editingStyleForRowAtIndexPath:",
2706
+ leadingSwipeActionsConfigurationForRowAt: "tableView:leadingSwipeActionsConfigurationForRowAtIndexPath:",
2707
+ trailingSwipeActionsConfigurationForRowAt: "tableView:trailingSwipeActionsConfigurationForRowAtIndexPath:",
2708
+ willBeginEditingRowAt: "tableView:willBeginEditingRowAtIndexPath:",
2709
+ didEndEditingRowAt: "tableView:didEndEditingRowAtIndexPath:"
2710
+ };
2711
+ const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
2712
+ const edits = [];
2713
+ for (const owner of code.matchAll(/\b(?:class|extension)\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
2714
+ const conforms = conformances.get(owner[1]);
2715
+ if (!conforms) continue;
2716
+ const selectors = {
2717
+ ...conforms.has("UITableViewDataSource") ? dataSource : {},
2718
+ ...conforms.has("UITableViewDelegate") ? delegate : {}
2719
+ };
2720
+ const open = owner.index + owner[0].length - 1;
2721
+ const close = closingBrace(code, braces, open);
2722
+ let depth = 1;
2723
+ let previous = open + 1;
2724
+ for (const token of swiftCodeScan(code.slice(open + 1, close - 1)).tokens) {
2725
+ const at = open + 1 + token;
2726
+ if (code[at] === "{") depth++;
2727
+ else if (code[at] === "}") {
2728
+ depth--;
2729
+ if (depth === 1) previous = at + 1;
2730
+ } else if (depth === 1 && /^func\b/.test(code.slice(at))) {
2731
+ const signature2 = code.slice(at, code.indexOf("{", at));
2732
+ const prefix = code.slice(previous, at);
2733
+ const attributes = /(?:@\w+(?:\([^{}]*\))?\s*|(?:public|open|private|fileprivate|internal|final|override|static|class|nonisolated|dynamic)\s+)*$/.exec(
2734
+ prefix
2735
+ )?.[0] ?? "";
2736
+ if (/\b(?:override|static|class)\b|@(?:objc|ObjC|IBAction)\b/.test(attributes))
2737
+ continue;
2738
+ let selector;
2739
+ if (conforms.has("UITableViewDataSource") && /^func\s+numberOfSections\s*\(\s*in\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*\)/.test(
2740
+ signature2
2741
+ ))
2742
+ selector = "numberOfSectionsInTableView:";
2743
+ else {
2744
+ const match = /^func\s+tableView\s*\(\s*_\s+\w+\s*:\s*(?:UIKit\.)?UITableView\s*,\s*(\w+)\b/.exec(
2745
+ signature2
2746
+ );
2747
+ if (match) selector = selectors[match[1]];
2748
+ }
2749
+ if (selector)
2750
+ edits.push([
2751
+ at,
2752
+ `${/\bnonisolated\b/.test(attributes) ? "" : "@MainActor "}@ObjC(${JSON.stringify(selector)}) `
2753
+ ]);
2754
+ }
2755
+ }
2756
+ }
2757
+ let result = source;
2758
+ for (const [at, text3] of edits.sort((a, b) => b[0] - a[0]))
2759
+ result = result.slice(0, at) + text3 + result.slice(at);
2760
+ return result;
2761
+ }
2643
2762
  function swiftCodeMask(source) {
2644
2763
  const chars = source.split("");
2645
2764
  const blank = (from, to) => {
@@ -2743,9 +2862,9 @@ function swiftCodeMask(source) {
2743
2862
  scanCode(0, false);
2744
2863
  return chars.join("");
2745
2864
  }
2746
- function swiftSourceAsIOS(original, extraObjCExtensions) {
2865
+ function swiftSourceAsIOS(original, extraObjCExtensions, tableConformances = tableProtocolConformances([original])) {
2747
2866
  const source = liftExtensionOverrides(
2748
- lowerNotificationDelegate(original),
2867
+ lowerTableProtocolMethods(lowerNotificationDelegate(original), tableConformances),
2749
2868
  extraObjCExtensions
2750
2869
  );
2751
2870
  const { lineStarts, tokens } = swiftCodeScan(source);
@@ -2957,7 +3076,7 @@ function swiftCodeScan(source) {
2957
3076
  }
2958
3077
  return { lineStarts: starts, tokens };
2959
3078
  }
2960
- var compiledSource = (file, contents, extraObjCExtensions) => file.endsWith(".swift") ? swiftSourceAsIOS(contents, extraObjCExtensions) : contents;
3079
+ var compiledSource = (file, contents, extraObjCExtensions, tableConformances) => file.endsWith(".swift") ? swiftSourceAsIOS(contents, extraObjCExtensions, tableConformances) : contents;
2961
3080
  function writeSwiftProject(layout, input, moduleRoot) {
2962
3081
  const resourceTargets = swiftManifestTargets(
2963
3082
  input.files["Package.swift"] ?? "",
@@ -2990,15 +3109,15 @@ function writeSwiftProject(layout, input, moduleRoot) {
2990
3109
  // sootsim-swift files ${modulePlan.digest("hex").slice(0, 16)}
2991
3110
  // resource accessors ${resourcePlan}
2992
3111
  `;
2993
- const objcExtensions = objcExtensionMemberIndex(
2994
- Object.entries(input.files).filter(([file]) => file.endsWith(".swift")).map(([, contents]) => contents)
2995
- );
3112
+ const swiftSources = Object.entries(input.files).filter(([file]) => file.endsWith(".swift")).map(([, contents]) => contents);
3113
+ const objcExtensions = objcExtensionMemberIndex(swiftSources);
3114
+ const tableConformances = tableProtocolConformances(swiftSources);
2996
3115
  if (targets.length === 0) {
2997
3116
  for (const [file, contents] of Object.entries(input.files)) {
2998
3117
  if (file === "Package.swift") continue;
2999
3118
  files2.set(
3000
3119
  import_node_path2.default.join(layout.sources, file),
3001
- compiledSource(file, contents, objcExtensions)
3120
+ compiledSource(file, contents, objcExtensions, tableConformances)
3002
3121
  );
3003
3122
  }
3004
3123
  let manifest = (0, import_node_fs2.readFileSync)(
@@ -3045,7 +3164,10 @@ function writeSwiftProject(layout, input, moduleRoot) {
3045
3164
  const base = layout.multi ? layout.root : layout.sources;
3046
3165
  for (const [file, contents] of Object.entries(input.files)) {
3047
3166
  if (file === "Package.swift") continue;
3048
- files2.set(import_node_path2.default.join(base, file), compiledSource(file, contents, objcExtensions));
3167
+ files2.set(
3168
+ import_node_path2.default.join(base, file),
3169
+ compiledSource(file, contents, objcExtensions, tableConformances)
3170
+ );
3049
3171
  }
3050
3172
  files2.set(
3051
3173
  import_node_path2.default.join(layout.root, "Package.swift"),
package/dist-lib/vite.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! rnx v0.1.800 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
1
+ /*! rnx v0.1.809 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
3
  "use strict";
4
4
  var __create = Object.create;
@@ -0,0 +1,119 @@
1
+ /*! rnx v0.1.809 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
3
+ "use strict";
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
+
22
+ // src/worklet-executable.ts
23
+ var worklet_executable_exports = {};
24
+ __export(worklet_executable_exports, {
25
+ compileWorkletExecutables: () => compileWorkletExecutables,
26
+ workletExecutableBodies: () => workletExecutableBodies
27
+ });
28
+ module.exports = __toCommonJS(worklet_executable_exports);
29
+ var import_acorn = require("acorn");
30
+ function isNode(value) {
31
+ return value !== null && typeof value === "object" && typeof Reflect.get(value, "type") === "string";
32
+ }
33
+ function walk(node, visit) {
34
+ visit(node);
35
+ for (const value of Object.values(node)) {
36
+ if (isNode(value)) walk(value, visit);
37
+ else if (Array.isArray(value)) {
38
+ for (const child of value) if (isNode(child)) walk(child, visit);
39
+ }
40
+ }
41
+ }
42
+ function propertyName(node) {
43
+ if (!isNode(node)) return void 0;
44
+ const name = Reflect.get(node, node.type === "Identifier" ? "name" : "value");
45
+ return typeof name === "string" ? name : void 0;
46
+ }
47
+ function workletExecutableBodies(syntax) {
48
+ if (!isNode(syntax)) throw new Error("peach: expected worklet syntax");
49
+ const tree = syntax;
50
+ const initNames = /* @__PURE__ */ new Set();
51
+ const objects = /* @__PURE__ */ new Set();
52
+ walk(tree, (node) => {
53
+ if (node.type !== "AssignmentExpression") return;
54
+ const left = Reflect.get(node, "left");
55
+ if (!isNode(left) || left.type !== "MemberExpression" || propertyName(Reflect.get(left, "property")) !== "__initData")
56
+ return;
57
+ const right = Reflect.get(node, "right");
58
+ if (!isNode(right)) return;
59
+ if (right.type === "ObjectExpression") objects.add(right);
60
+ else if (right.type === "Identifier") {
61
+ const name = propertyName(right);
62
+ if (name) initNames.add(name);
63
+ }
64
+ });
65
+ walk(tree, (node) => {
66
+ if (node.type !== "VariableDeclarator") return;
67
+ const name = propertyName(Reflect.get(node, "id"));
68
+ const init = Reflect.get(node, "init");
69
+ if (name && initNames.has(name) && isNode(init) && init.type === "ObjectExpression") {
70
+ objects.add(init);
71
+ }
72
+ });
73
+ const bodies = [];
74
+ for (const object of objects) {
75
+ const properties = Reflect.get(object, "properties");
76
+ if (!Array.isArray(properties)) continue;
77
+ if (properties.some(
78
+ (property2) => isNode(property2) && propertyName(Reflect.get(property2, "key")) === "__peachExecutable"
79
+ ))
80
+ continue;
81
+ const property = properties.find(
82
+ (property2) => isNode(property2) && ["Property", "ObjectProperty"].includes(property2.type) && propertyName(Reflect.get(property2, "key")) === "code"
83
+ );
84
+ if (!isNode(property)) continue;
85
+ const literal = Reflect.get(property, "value");
86
+ const code = isNode(literal) && Reflect.get(literal, "value");
87
+ if (typeof code !== "string") {
88
+ throw new Error("peach: worklet init data requires literal code at build time");
89
+ }
90
+ bodies.push({ initData: object, codeProperty: property, code });
91
+ }
92
+ return bodies;
93
+ }
94
+ function compileWorkletExecutables(source, onInsert) {
95
+ if (!source.includes("__initData")) return source;
96
+ const tree = (0, import_acorn.parse)(source, { ecmaVersion: "latest", sourceType: "module" });
97
+ const edits = workletExecutableBodies(tree).map(({ codeProperty, code }) => {
98
+ const body = compileWorkletExecutables(code);
99
+ const expression = (0, import_acorn.parse)(`(${body})`, { ecmaVersion: "latest" }).body[0];
100
+ const fn = expression && Reflect.get(expression, "expression");
101
+ if (!isNode(fn) || !["FunctionExpression", "ArrowFunctionExpression"].includes(fn.type)) {
102
+ throw new Error("peach: worklet code did not compile to a function");
103
+ }
104
+ const offset = Reflect.get(codeProperty, "end");
105
+ if (typeof offset !== "number") throw new Error("peach: worklet code has no offset");
106
+ return { offset, text: `, __peachExecutable: (${body})` };
107
+ });
108
+ let compiled = source;
109
+ for (const edit of edits.sort((a, b) => b.offset - a.offset)) {
110
+ onInsert?.(edit.offset, edit.text);
111
+ compiled = compiled.slice(0, edit.offset) + edit.text + compiled.slice(edit.offset);
112
+ }
113
+ return compiled;
114
+ }
115
+ // Annotate the CommonJS export names for ESM import in node:
116
+ 0 && (module.exports = {
117
+ compileWorkletExecutables,
118
+ workletExecutableBodies
119
+ });
@@ -0,0 +1,93 @@
1
+ /*! rnx v0.1.809 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+
3
+ // src/worklet-executable.ts
4
+ import { parse } from "acorn";
5
+ function isNode(value) {
6
+ return value !== null && typeof value === "object" && typeof Reflect.get(value, "type") === "string";
7
+ }
8
+ function walk(node, visit) {
9
+ visit(node);
10
+ for (const value of Object.values(node)) {
11
+ if (isNode(value)) walk(value, visit);
12
+ else if (Array.isArray(value)) {
13
+ for (const child of value) if (isNode(child)) walk(child, visit);
14
+ }
15
+ }
16
+ }
17
+ function propertyName(node) {
18
+ if (!isNode(node)) return void 0;
19
+ const name = Reflect.get(node, node.type === "Identifier" ? "name" : "value");
20
+ return typeof name === "string" ? name : void 0;
21
+ }
22
+ function workletExecutableBodies(syntax) {
23
+ if (!isNode(syntax)) throw new Error("peach: expected worklet syntax");
24
+ const tree = syntax;
25
+ const initNames = /* @__PURE__ */ new Set();
26
+ const objects = /* @__PURE__ */ new Set();
27
+ walk(tree, (node) => {
28
+ if (node.type !== "AssignmentExpression") return;
29
+ const left = Reflect.get(node, "left");
30
+ if (!isNode(left) || left.type !== "MemberExpression" || propertyName(Reflect.get(left, "property")) !== "__initData")
31
+ return;
32
+ const right = Reflect.get(node, "right");
33
+ if (!isNode(right)) return;
34
+ if (right.type === "ObjectExpression") objects.add(right);
35
+ else if (right.type === "Identifier") {
36
+ const name = propertyName(right);
37
+ if (name) initNames.add(name);
38
+ }
39
+ });
40
+ walk(tree, (node) => {
41
+ if (node.type !== "VariableDeclarator") return;
42
+ const name = propertyName(Reflect.get(node, "id"));
43
+ const init = Reflect.get(node, "init");
44
+ if (name && initNames.has(name) && isNode(init) && init.type === "ObjectExpression") {
45
+ objects.add(init);
46
+ }
47
+ });
48
+ const bodies = [];
49
+ for (const object of objects) {
50
+ const properties = Reflect.get(object, "properties");
51
+ if (!Array.isArray(properties)) continue;
52
+ if (properties.some(
53
+ (property2) => isNode(property2) && propertyName(Reflect.get(property2, "key")) === "__peachExecutable"
54
+ ))
55
+ continue;
56
+ const property = properties.find(
57
+ (property2) => isNode(property2) && ["Property", "ObjectProperty"].includes(property2.type) && propertyName(Reflect.get(property2, "key")) === "code"
58
+ );
59
+ if (!isNode(property)) continue;
60
+ const literal = Reflect.get(property, "value");
61
+ const code = isNode(literal) && Reflect.get(literal, "value");
62
+ if (typeof code !== "string") {
63
+ throw new Error("peach: worklet init data requires literal code at build time");
64
+ }
65
+ bodies.push({ initData: object, codeProperty: property, code });
66
+ }
67
+ return bodies;
68
+ }
69
+ function compileWorkletExecutables(source, onInsert) {
70
+ if (!source.includes("__initData")) return source;
71
+ const tree = parse(source, { ecmaVersion: "latest", sourceType: "module" });
72
+ const edits = workletExecutableBodies(tree).map(({ codeProperty, code }) => {
73
+ const body = compileWorkletExecutables(code);
74
+ const expression = parse(`(${body})`, { ecmaVersion: "latest" }).body[0];
75
+ const fn = expression && Reflect.get(expression, "expression");
76
+ if (!isNode(fn) || !["FunctionExpression", "ArrowFunctionExpression"].includes(fn.type)) {
77
+ throw new Error("peach: worklet code did not compile to a function");
78
+ }
79
+ const offset = Reflect.get(codeProperty, "end");
80
+ if (typeof offset !== "number") throw new Error("peach: worklet code has no offset");
81
+ return { offset, text: `, __peachExecutable: (${body})` };
82
+ });
83
+ let compiled = source;
84
+ for (const edit of edits.sort((a, b) => b.offset - a.offset)) {
85
+ onInsert?.(edit.offset, edit.text);
86
+ compiled = compiled.slice(0, edit.offset) + edit.text + compiled.slice(edit.offset);
87
+ }
88
+ return compiled;
89
+ }
90
+ export {
91
+ compileWorkletExecutables,
92
+ workletExecutableBodies
93
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.800",
3
+ "version": "0.1.809",
4
4
  "description": "Vite and Metro plugins, testing drivers, and SDK exports for peach.",
5
5
  "author": "Tamagui LLC",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -102,6 +102,13 @@
102
102
  "import": "./dist-lib/metro-production-bundle.mjs",
103
103
  "default": "./dist-lib/metro-production-bundle.cjs"
104
104
  },
105
+ "./worklet-executable": {
106
+ "types": "./src/worklet-executable.ts",
107
+ "source": "./src/worklet-executable.ts",
108
+ "bun": "./src/worklet-executable.ts",
109
+ "import": "./dist-lib/worklet-executable.mjs",
110
+ "default": "./dist-lib/worklet-executable.cjs"
111
+ },
105
112
  "./plist": {
106
113
  "types": "./src/plist.ts",
107
114
  "source": "./src/plist.ts",
@@ -337,6 +344,7 @@
337
344
  },
338
345
  "dependencies": {
339
346
  "@peculiar/x509": "1.14.3",
347
+ "acorn": "^8.16.0",
340
348
  "@sucrase/jest-plugin": "3.0.0",
341
349
  "jiti": "2.7.0",
342
350
  "magic-string": "^0.30.21",