peachsim 0.1.2278 → 0.1.2298

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 (157) 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 +3691 -3537
  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 +1995 -1900
  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 +2875 -2721
  34. package/dist-lib/host/fetch-proxy-handler.cjs +19 -7
  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 +55 -21
  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 +14 -2
  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 +55 -21
  50. package/dist-lib/native-app-identity-project.cjs +13 -5
  51. package/dist-lib/native-app-identity-project.mjs +13 -5
  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 +68 -58
  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 +3579 -3392
  71. package/dist-lib/swift-compile.cjs +2 -2
  72. package/dist-lib/swift-compile.mjs +2 -2
  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 +467 -447
  80. package/dist-lib/vite.cjs +19 -7
  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 +13 -9
  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 -22
  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 +3 -3
  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/dist-types/packages/peach-engine/src/settings/device-spec-bus.d.ts +5 -0
  98. package/kotlin/README.md +1 -1
  99. package/kotlin/sdk.tar.gz +0 -0
  100. package/kotlin/toolchain.json +5 -1
  101. package/package.json +1 -1
  102. package/runtime-companion.json +1 -1
  103. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXAction.h +34 -0
  104. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXAnswerCallAction.h +20 -0
  105. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXBase.h +20 -0
  106. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCall.h +28 -0
  107. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallAction.h +23 -0
  108. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallController.h +53 -0
  109. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallDirectory.h +16 -0
  110. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallDirectoryExtensionContext.h +86 -0
  111. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallDirectoryManager.h +29 -0
  112. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallDirectoryProvider.h +21 -0
  113. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallObserver.h +34 -0
  114. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXCallUpdate.h +43 -0
  115. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXEndCallAction.h +20 -0
  116. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXError.h +66 -0
  117. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXHandle.h +31 -0
  118. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXPlayDTMFCallAction.h +33 -0
  119. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXProvider.h +127 -0
  120. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXProviderConfiguration.h +42 -0
  121. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXSetGroupCallAction.h +27 -0
  122. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXSetHeldCallAction.h +23 -0
  123. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXSetMutedCallAction.h +23 -0
  124. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXSetTranslatingCallAction.h +40 -0
  125. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXStartCallAction.h +33 -0
  126. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CXTransaction.h +34 -0
  127. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CallKit.apinotes +36 -0
  128. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Headers/CallKit.h +35 -0
  129. package/sdk/ios/System/Library/Frameworks/CallKit.framework/Modules/module.modulemap +6 -0
  130. package/sdk/ios/System/Library/Frameworks/React.framework/Headers/React.h +14 -0
  131. package/src/expo-autolinking.ts +1 -1
  132. package/src/expo-native-prebuilt.ts +24 -0
  133. package/src/expo-native-workspace.ts +51 -5
  134. package/src/expo-swift-host.ts +5 -5
  135. package/src/kotlin-toolchain.ts +16 -1
  136. package/src/kotlinSdkContract.ts +2 -1
  137. package/src/nitro-adapter.lock.json +284 -284
  138. package/src/nitro-compile.ts +69 -4
  139. package/src/nitro-superset.lock.json +4 -4
  140. package/src/one-sdk/source.ts +2 -1
  141. package/src/prepared-native-inventory.ts +8 -2
  142. package/src/react-native-autolinking.ts +28 -9
  143. package/src/swift-compiler-digest.ts +8 -1
  144. package/src/swift-coverage/xcode-packages.ts +2 -1
  145. package/src/swift-distribution.lock.json +11 -11
  146. package/src/swift-helper.ts +38 -0
  147. package/src/swift-host.ts +3 -1
  148. package/src/swift-pdf-raster.ts +7 -33
  149. package/src/turbo-bundle.ts +14 -6
  150. package/src/turbo-codegen-intake.ts +3 -2
  151. package/src/turbo-compile.ts +12 -1
  152. package/src/turbo-runtime.lock.json +22 -22
  153. package/src/turbo-source.ts +2 -4
  154. package/src/worklet-executable.ts +4 -1
  155. package/src/worklet-kernel.ts +370 -0
  156. package/src/worklets-babel.ts +10 -0
  157. package/src/xcode-target-members.ts +17 -7
@@ -0,0 +1,370 @@
1
+ import { parse } from 'acorn'
2
+ import type {
3
+ WorkletKernelSide,
4
+ WorkletKernelStep,
5
+ WorkletKernelOp,
6
+ WorkletKernel,
7
+ } from '../../peach-engine/src/kernel/worklet-kernel'
8
+
9
+ interface Node {
10
+ type: string
11
+ [key: string]: unknown
12
+ }
13
+
14
+ class Unsupported extends Error {}
15
+
16
+ function isNode(value: unknown): value is Node {
17
+ return (
18
+ value !== null &&
19
+ typeof value === 'object' &&
20
+ typeof Reflect.get(value, 'type') === 'string'
21
+ )
22
+ }
23
+
24
+ function node(value: unknown): Node {
25
+ if (!isNode(value)) throw new Unsupported()
26
+ return value
27
+ }
28
+
29
+ function nodes(value: unknown): Node[] {
30
+ if (!Array.isArray(value)) throw new Unsupported()
31
+ return value.map(node)
32
+ }
33
+
34
+ function name(value: unknown): string {
35
+ const n = node(value)
36
+ if (n.type !== 'Identifier' || typeof n.name !== 'string') throw new Unsupported()
37
+ return n.name
38
+ }
39
+
40
+ // the static key a non-computed member or property names
41
+ function key(owner: Node, value: unknown): string {
42
+ if (owner.computed === true) throw new Unsupported()
43
+ const n = node(value)
44
+ if (n.type === 'Identifier' && typeof n.name === 'string') return n.name
45
+ if (n.type === 'Literal' && typeof n.value === 'string') return n.value
46
+ throw new Unsupported()
47
+ }
48
+
49
+ const MATH: Record<string, { op: WorkletKernelOp; arity: number | 'any' }> = {
50
+ min: { op: 'min', arity: 'any' },
51
+ max: { op: 'max', arity: 'any' },
52
+ abs: { op: 'abs', arity: 1 },
53
+ sqrt: { op: 'sqrt', arity: 1 },
54
+ exp: { op: 'exp', arity: 1 },
55
+ sin: { op: 'sin', arity: 1 },
56
+ cos: { op: 'cos', arity: 1 },
57
+ pow: { op: 'pow', arity: 2 },
58
+ }
59
+
60
+ const BINARY: Record<string, WorkletKernelOp> = {
61
+ '+': 'add',
62
+ '-': 'sub',
63
+ '*': 'mul',
64
+ '/': 'quotient',
65
+ '**': 'pow',
66
+ }
67
+
68
+ class Recipe {
69
+ readonly steps: WorkletKernelStep[] = []
70
+ readonly #interned = new Map<string, number>()
71
+ readonly locals = new Map<string, number>()
72
+
73
+ constructor(
74
+ readonly closure: Map<string, number>,
75
+ readonly event: string | undefined,
76
+ ) {}
77
+
78
+ step(step: WorkletKernelStep): number {
79
+ const id = JSON.stringify(step)
80
+ const held = this.#interned.get(id)
81
+ if (held !== undefined) return held
82
+ this.steps.push(step)
83
+ this.#interned.set(id, this.steps.length - 1)
84
+ return this.steps.length - 1
85
+ }
86
+
87
+ slot(identifier: unknown): number {
88
+ const slot = this.closure.get(name(identifier))
89
+ if (slot === undefined) throw new Unsupported()
90
+ return slot
91
+ }
92
+
93
+ // a comparison as a kernel 1 or 0, for a conditional's test
94
+ test(expression: Node): number {
95
+ if (expression.type !== 'BinaryExpression') throw new Unsupported()
96
+ const left = this.value(node(expression.left))
97
+ const right = this.value(node(expression.right))
98
+ switch (expression.operator) {
99
+ case '>':
100
+ return this.step(['op', 'gt', left, right])
101
+ case '>=':
102
+ return this.step(['op', 'gte', left, right])
103
+ case '<':
104
+ return this.step(['op', 'gt', right, left])
105
+ case '<=':
106
+ return this.step(['op', 'gte', right, left])
107
+ }
108
+ throw new Unsupported()
109
+ }
110
+
111
+ side(expression: Node): WorkletKernelSide {
112
+ if (expression.type === 'Literal' && typeof expression.value === 'string')
113
+ return expression.value
114
+ if (expression.type === 'MemberExpression')
115
+ return [
116
+ 'member',
117
+ this.slot(expression.object),
118
+ key(expression, expression.property),
119
+ ]
120
+ throw new Unsupported()
121
+ }
122
+
123
+ extrapolation(argument: unknown): readonly [WorkletKernelSide, WorkletKernelSide] {
124
+ if (argument === undefined) return [null, null]
125
+ const expression = node(argument)
126
+ if (expression.type !== 'ObjectExpression') {
127
+ const side = this.side(expression)
128
+ return [side, side]
129
+ }
130
+ let left: WorkletKernelSide = null
131
+ let right: WorkletKernelSide = null
132
+ for (const property of nodes(expression.properties)) {
133
+ if (
134
+ property.type !== 'Property' ||
135
+ property.kind !== 'init' ||
136
+ property.method === true
137
+ )
138
+ throw new Unsupported()
139
+ const which = key(property, property.key)
140
+ if (which === 'extrapolateLeft') left = this.side(node(property.value))
141
+ else if (which === 'extrapolateRight') right = this.side(node(property.value))
142
+ else throw new Unsupported()
143
+ }
144
+ return [left, right]
145
+ }
146
+
147
+ list(argument: unknown): number[] {
148
+ const array = node(argument)
149
+ if (array.type !== 'ArrayExpression') throw new Unsupported()
150
+ return nodes(array.elements).map((element) => this.value(element))
151
+ }
152
+
153
+ value(expression: Node): number {
154
+ switch (expression.type) {
155
+ case 'Literal':
156
+ if (typeof expression.value !== 'number') throw new Unsupported()
157
+ return this.step(['number', expression.value])
158
+ case 'Identifier': {
159
+ const local = this.locals.get(name(expression))
160
+ if (local !== undefined) return local
161
+ return this.step(['closure', this.slot(expression)])
162
+ }
163
+ case 'MemberExpression': {
164
+ const object = node(expression.object)
165
+ const field = key(expression, expression.property)
166
+ if (field === 'value' && object.type === 'Identifier')
167
+ return this.step(['shared', this.slot(object)])
168
+ if (
169
+ this.event !== undefined &&
170
+ object.type === 'MemberExpression' &&
171
+ node(object.object).type === 'Identifier' &&
172
+ name(object.object) === this.event &&
173
+ key(object, object.property) === 'contentOffset' &&
174
+ (field === 'x' || field === 'y')
175
+ )
176
+ return this.step(['event', `contentOffset.${field}`])
177
+ throw new Unsupported()
178
+ }
179
+ case 'UnaryExpression':
180
+ if (expression.operator !== '-') throw new Unsupported()
181
+ return this.step(['op', 'neg', this.value(node(expression.argument))])
182
+ case 'BinaryExpression': {
183
+ const op = BINARY[String(expression.operator)]
184
+ if (!op) throw new Unsupported()
185
+ return this.step([
186
+ 'op',
187
+ op,
188
+ this.value(node(expression.left)),
189
+ this.value(node(expression.right)),
190
+ ])
191
+ }
192
+ case 'ConditionalExpression':
193
+ return this.step([
194
+ 'op',
195
+ 'select',
196
+ this.test(node(expression.test)),
197
+ this.value(node(expression.consequent)),
198
+ this.value(node(expression.alternate)),
199
+ ])
200
+ case 'CallExpression':
201
+ return this.call(expression)
202
+ }
203
+ throw new Unsupported()
204
+ }
205
+
206
+ call(expression: Node): number {
207
+ if (expression.optional === true) throw new Unsupported()
208
+ const callee = node(expression.callee)
209
+ const args = nodes(expression.arguments)
210
+ if (args.some((argument) => argument.type === 'SpreadElement'))
211
+ throw new Unsupported()
212
+ if (
213
+ callee.type === 'MemberExpression' &&
214
+ node(callee.object).type === 'Identifier' &&
215
+ name(callee.object) === 'Math' &&
216
+ !this.closure.has('Math')
217
+ ) {
218
+ const math = MATH[key(callee, callee.property)]
219
+ if (!math || args.length === 0) throw new Unsupported()
220
+ if (math.arity !== 'any' && args.length !== math.arity) throw new Unsupported()
221
+ const values = args.map((argument) => this.value(argument))
222
+ if (math.arity === 1) return this.step(['op', math.op, values[0]!])
223
+ return values
224
+ .slice(1)
225
+ .reduce((a, b) => this.step(['op', math.op, a, b]), values[0]!)
226
+ }
227
+ if (callee.type !== 'Identifier') throw new Unsupported()
228
+ const slot = this.slot(callee)
229
+ if (args.length === 3 && args[1]!.type !== 'ArrayExpression')
230
+ return this.step([
231
+ 'clamp',
232
+ slot,
233
+ this.value(args[0]!),
234
+ this.value(args[1]!),
235
+ this.value(args[2]!),
236
+ ])
237
+ if (args.length === 3 || args.length === 4) {
238
+ const inputs = this.list(args[1])
239
+ const outputs = this.list(args[2])
240
+ if (inputs.length < 2 || inputs.length !== outputs.length) throw new Unsupported()
241
+ return this.step([
242
+ 'interpolate',
243
+ slot,
244
+ this.value(args[0]!),
245
+ inputs,
246
+ outputs,
247
+ this.extrapolation(args[3]),
248
+ ])
249
+ }
250
+ throw new Unsupported()
251
+ }
252
+ }
253
+
254
+ // `const [a, b] = this.__closure` names each closure slot
255
+ function closureSlots(statement: Node): Map<string, number> | undefined {
256
+ if (statement.type !== 'VariableDeclaration') return undefined
257
+ const [declarator] = nodes(statement.declarations)
258
+ if (nodes(statement.declarations).length !== 1 || !declarator) return undefined
259
+ const init = declarator.init === null ? undefined : node(declarator.init)
260
+ if (
261
+ !init ||
262
+ init.type !== 'MemberExpression' ||
263
+ node(init.object).type !== 'ThisExpression' ||
264
+ key(init, init.property) !== '__closure'
265
+ )
266
+ return undefined
267
+ const pattern = node(declarator.id)
268
+ if (pattern.type !== 'ArrayPattern') throw new Unsupported()
269
+ const slots = new Map<string, number>()
270
+ nodes(pattern.elements).forEach((element, index) => slots.set(name(element), index))
271
+ return slots
272
+ }
273
+
274
+ function styleOutputs(
275
+ recipe: Recipe,
276
+ expression: Node,
277
+ path: string,
278
+ outputs: [string, number][],
279
+ ): void {
280
+ if (expression.type === 'ObjectExpression') {
281
+ for (const property of nodes(expression.properties)) {
282
+ if (
283
+ property.type !== 'Property' ||
284
+ property.kind !== 'init' ||
285
+ property.method === true
286
+ )
287
+ throw new Unsupported()
288
+ const field = key(property, property.key)
289
+ styleOutputs(
290
+ recipe,
291
+ node(property.value),
292
+ path ? `${path}.${field}` : field,
293
+ outputs,
294
+ )
295
+ }
296
+ return
297
+ }
298
+ if (expression.type === 'ArrayExpression') {
299
+ nodes(expression.elements).forEach((element, index) =>
300
+ styleOutputs(recipe, element, `${path}.${index}`, outputs),
301
+ )
302
+ return
303
+ }
304
+ outputs.push([path, recipe.value(expression)])
305
+ }
306
+
307
+ // the recipe of one worklet's code, as upstream's babel plugin emits it, or undefined when the
308
+ // worklet does anything a kernel cannot carry exactly
309
+ export function compileWorkletKernel(code: string): WorkletKernel | undefined {
310
+ try {
311
+ // the code is a function declaration or expression, named or not, as the executable pass reads it
312
+ const program = parse(`(${code})`, { ecmaVersion: 'latest' })
313
+ const [statement] = nodes(program.body)
314
+ if (!statement || statement.type !== 'ExpressionStatement') return undefined
315
+ const fn = node(statement.expression)
316
+ if (fn.type !== 'FunctionExpression' || fn.async === true || fn.generator === true)
317
+ return undefined
318
+ const params = nodes(fn.params)
319
+ const body = nodes(node(fn.body).body)
320
+ const slots = body[0] ? closureSlots(body[0]) : undefined
321
+ const statements = slots ? body.slice(1) : body
322
+ if (params.length === 0) {
323
+ const recipe = new Recipe(slots ?? new Map(), undefined)
324
+ for (const [index, item] of statements.entries()) {
325
+ if (item.type === 'ReturnStatement' && index === statements.length - 1) {
326
+ const outputs: [string, number][] = []
327
+ const returned = node(item.argument)
328
+ if (returned.type !== 'ObjectExpression') return undefined
329
+ styleOutputs(recipe, returned, '', outputs)
330
+ if (outputs.length === 0) return undefined
331
+ return { kind: 'style', steps: recipe.steps, outputs }
332
+ }
333
+ declareLocals(recipe, item)
334
+ }
335
+ return undefined
336
+ }
337
+ if (params.length > 2) return undefined
338
+ const recipe = new Recipe(slots ?? new Map(), name(params[0]))
339
+ const writes: [number, number][] = []
340
+ for (const item of statements) {
341
+ if (item.type === 'VariableDeclaration') {
342
+ declareLocals(recipe, item)
343
+ continue
344
+ }
345
+ if (item.type !== 'ExpressionStatement') return undefined
346
+ const assignment = node(item.expression)
347
+ if (assignment.type !== 'AssignmentExpression' || assignment.operator !== '=')
348
+ return undefined
349
+ const target = node(assignment.left)
350
+ if (target.type !== 'MemberExpression' || key(target, target.property) !== 'value')
351
+ return undefined
352
+ writes.push([recipe.slot(target.object), recipe.value(node(assignment.right))])
353
+ }
354
+ if (writes.length === 0) return undefined
355
+ return { kind: 'handler', steps: recipe.steps, writes }
356
+ } catch (error) {
357
+ if (error instanceof Unsupported) return undefined
358
+ throw error
359
+ }
360
+ }
361
+
362
+ function declareLocals(recipe: Recipe, item: Node): void {
363
+ if (item.type !== 'VariableDeclaration' || item.kind !== 'const')
364
+ throw new Unsupported()
365
+ for (const declarator of nodes(item.declarations)) {
366
+ const local = name(declarator.id)
367
+ if (recipe.closure.has(local) || recipe.locals.has(local)) throw new Unsupported()
368
+ recipe.locals.set(local, recipe.value(node(declarator.init)))
369
+ }
370
+ }
@@ -10,6 +10,7 @@ import {
10
10
  compileWorkletExecutables,
11
11
  workletExecutableBodies,
12
12
  } from './worklet-executable.ts'
13
+ import { compileWorkletKernel } from './worklet-kernel.ts'
13
14
  import type { PluginObj, TransformOptions } from '@babel/core'
14
15
  import type { TransformResult } from 'vite'
15
16
 
@@ -141,6 +142,7 @@ const CACHE_ROOT = path.join(homedir(), '.cache', 'peach-worklets')
141
142
  const CACHE_SCHEMA = createHash('sha256')
142
143
  .update(fs.readFileSync(path.join(sootsimRoot, 'src/worklets-babel.ts')))
143
144
  .update(fs.readFileSync(path.join(sootsimRoot, 'src/worklet-executable.ts')))
145
+ .update(fs.readFileSync(path.join(sootsimRoot, 'src/worklet-kernel.ts')))
144
146
  .digest('hex')
145
147
 
146
148
  // null once resolved on a tree we cannot write to (a read-only install), which
@@ -275,6 +277,14 @@ function executableWorkletsPlugin(
275
277
  api.template.expression.ast(`(${compileWorkletExecutables(code)})`),
276
278
  ),
277
279
  )
280
+ const kernel = compileWorkletKernel(code)
281
+ if (kernel)
282
+ properties.push(
283
+ api.types.objectProperty(
284
+ api.types.identifier('__peachKernel'),
285
+ api.types.valueToNode(kernel),
286
+ ),
287
+ )
278
288
  }
279
289
  },
280
290
  },
@@ -9,19 +9,29 @@ const FOLDER_REFERENCE = /^(?:folder|wrapper\.scnassets)$/
9
9
  const BUNDLE_DIR =
10
10
  /\.(xcassets|bundle|lproj|xcdatamodeld|scnassets|spriteatlas|rcproject|storyboardc|icon)$/
11
11
 
12
- export function xcodePathResolver(
13
- objects: PlistDict,
14
- projectDir: string,
15
- join: (base: string, own: string) => string,
16
- sourceTreeRoot?: (tree: string) => string,
17
- ): (id: string) => string | null {
18
- const parents = new Map<string, string>()
12
+ // a project's targets each build a resolver; the group parents are the same for all of them.
13
+ const groupParents = new WeakMap<PlistDict, Map<string, string>>()
14
+ function groupParentsOf(objects: PlistDict): Map<string, string> {
15
+ let parents = groupParents.get(objects)
16
+ if (parents) return parents
17
+ parents = new Map<string, string>()
19
18
  for (const [id, entry] of Object.entries(objects)) {
20
19
  if (!isDict(entry)) continue
21
20
  if (entry.isa === 'PBXGroup' || entry.isa === 'PBXVariantGroup') {
22
21
  for (const child of list(entry.children)) parents.set(child, id)
23
22
  }
24
23
  }
24
+ groupParents.set(objects, parents)
25
+ return parents
26
+ }
27
+
28
+ export function xcodePathResolver(
29
+ objects: PlistDict,
30
+ projectDir: string,
31
+ join: (base: string, own: string) => string,
32
+ sourceTreeRoot?: (tree: string) => string,
33
+ ): (id: string) => string | null {
34
+ const parents = groupParentsOf(objects)
25
35
  const paths = new Map<string, string | null>()
26
36
  const resolve = (id: string): string | null => {
27
37
  if (paths.has(id)) return paths.get(id)!