peachsim 0.1.1653 → 0.1.1655

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 (111) hide show
  1. package/cli/app-stubs.ts +97 -14
  2. package/cli/bridge-diagnostics.ts +10 -7
  3. package/cli/cloud-client.ts +11 -2
  4. package/cli/commands/doctor.ts +20 -10
  5. package/cli/commands/inspect/core.ts +2 -1
  6. package/cli/commands/inspect/shared.ts +2 -0
  7. package/cli/commands/inspect.ts +11 -2
  8. package/cli/output-redaction.ts +22 -6
  9. package/cli/pause-aware-timeout.ts +24 -10
  10. package/cli/ws-bridge.ts +17 -1
  11. package/dist-lib/agent-daemon-client.cjs +1 -1
  12. package/dist-lib/agent-events.cjs +1 -1
  13. package/dist-lib/attached-projects.cjs +1 -1
  14. package/dist-lib/auth/shared-session.cjs +1 -1
  15. package/dist-lib/backend-origin.cjs +1 -1
  16. package/dist-lib/beta.cjs +1 -1
  17. package/dist-lib/beta.mjs +1 -1
  18. package/dist-lib/bridge-constants.cjs +1 -1
  19. package/dist-lib/bridge-contract-input.cjs +1 -1
  20. package/dist-lib/bridge-contract-input.mjs +1 -1
  21. package/dist-lib/bridge-contract.cjs +1 -1
  22. package/dist-lib/bridge-contract.mjs +1 -1
  23. package/dist-lib/bundle-channel.cjs +277 -244
  24. package/dist-lib/capture-contract.cjs +1 -1
  25. package/dist-lib/capture-contract.mjs +1 -1
  26. package/dist-lib/cloud-contract.cjs +1 -1
  27. package/dist-lib/cloud-contract.mjs +1 -1
  28. package/dist-lib/cloud-test-args.cjs +1 -1
  29. package/dist-lib/cloud-test-args.mjs +1 -1
  30. package/dist-lib/cloud.cjs +1 -1
  31. package/dist-lib/cloud.mjs +1 -1
  32. package/dist-lib/config.cjs +1 -1
  33. package/dist-lib/config.mjs +1 -1
  34. package/dist-lib/detox/index.cjs +47 -12
  35. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  36. package/dist-lib/expo-swift-bundle.cjs +276 -243
  37. package/dist-lib/expo-swift-metadata.cjs +1 -1
  38. package/dist-lib/expo-swift-metadata.mjs +1 -1
  39. package/dist-lib/home-paths.cjs +1 -1
  40. package/dist-lib/host/bridge-host.cjs +320 -246
  41. package/dist-lib/host/fetch-proxy-handler.cjs +191 -31
  42. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  43. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  44. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  45. package/dist-lib/host/websocket-proxy.cjs +1 -1
  46. package/dist-lib/index.cjs +633 -373
  47. package/dist-lib/jump-to-source-babel.cjs +1 -1
  48. package/dist-lib/jump-to-source-native.cjs +1 -1
  49. package/dist-lib/kotlin-host.cjs +1 -1
  50. package/dist-lib/menu.cjs +1 -1
  51. package/dist-lib/menu.mjs +1 -1
  52. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  53. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  54. package/dist-lib/metro-production-bundle.cjs +1 -1
  55. package/dist-lib/metro-production-bundle.mjs +1 -1
  56. package/dist-lib/metro.cjs +62 -14
  57. package/dist-lib/native-app-identity-project.cjs +1 -1
  58. package/dist-lib/native-app-identity-project.mjs +1 -1
  59. package/dist-lib/native-app-identity.cjs +1 -1
  60. package/dist-lib/native-app-identity.mjs +1 -1
  61. package/dist-lib/native-firebase-metadata.cjs +1 -1
  62. package/dist-lib/native-firebase-metadata.mjs +1 -1
  63. package/dist-lib/plist.cjs +1 -1
  64. package/dist-lib/plist.mjs +1 -1
  65. package/dist-lib/profiles.cjs +1 -1
  66. package/dist-lib/public-brand.cjs +1 -1
  67. package/dist-lib/public-origins-lib-esm.json +23 -23
  68. package/dist-lib/public-origins-lib.json +62 -54
  69. package/dist-lib/react-native-host-modules.cjs +1 -1
  70. package/dist-lib/react-native-host-modules.mjs +1 -1
  71. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  72. package/dist-lib/sdk.cjs +2 -2
  73. package/dist-lib/sdk.mjs +2 -2
  74. package/dist-lib/skills.cjs +535 -380
  75. package/dist-lib/swift-compile.cjs +258 -197
  76. package/dist-lib/swift-compile.mjs +257 -197
  77. package/dist-lib/swift-package.cjs +1 -1
  78. package/dist-lib/swift-package.mjs +1 -1
  79. package/dist-lib/swift-submit.cjs +1 -1
  80. package/dist-lib/swift-submit.mjs +1 -1
  81. package/dist-lib/swift-toolchain.cjs +1 -1
  82. package/dist-lib/swift.cjs +1 -1
  83. package/dist-lib/vite-swift.cjs +276 -243
  84. package/dist-lib/vite.cjs +385 -200
  85. package/dist-lib/worklet-executable.cjs +1 -1
  86. package/dist-lib/worklet-executable.mjs +1 -1
  87. package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +1 -0
  88. package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +10 -7
  89. package/dist-types/packages/peach-engine/src/capture/browser-composite.d.ts +10 -0
  90. package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
  91. package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -1
  92. package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
  93. package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +23 -0
  94. package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -1
  95. package/dist-types/packages/peach-engine/src/engine/visible-frame.d.ts +1 -0
  96. package/dist-types/packages/peach-engine/src/observability/types.d.ts +1 -0
  97. package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +38 -0
  98. package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +9 -0
  99. package/package.json +5 -1
  100. package/runtime-companion.json +1 -1
  101. package/src/bridge-contract.ts +2 -0
  102. package/src/bundleGlobalFooter.ts +9 -0
  103. package/src/host/fetch-proxy-handler.ts +54 -0
  104. package/src/sfSymbolMetricsContract.ts +268 -0
  105. package/src/swift-compile.ts +302 -238
  106. package/src/swift-distribution.lock.json +20 -46
  107. package/src/swift-objc-metadata.ts +21 -7
  108. package/src/swift-objc-sdk.ts +13 -0
  109. package/src/swiftContract.ts +2 -0
  110. package/src/vite-plugin-one.ts +161 -16
  111. package/src/host/lease-owner.test.ts +0 -49
@@ -1,10 +1,10 @@
1
1
  {
2
- "id": "e3bdd3d8fa4f9993",
2
+ "id": "ca4dfda0ca14bc49",
3
3
  "release": "swift-6.4.0-RELEASE-custom-0d775d32d7c74eae",
4
4
  "wasmSdkId": "swift-6.4.0-RELEASE_wasm-peach-f02bd198",
5
5
  "wasmSdkUrl": "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-f02bd198.artifactbundle.tar.gz",
6
6
  "wasmSdkChecksum": "1e19ea768fd4e821aae34b8966c4ddcee45615c4b3cf018979b061aee2fb5504",
7
- "source": "5791eeff9ca9c054514aeb4a6599e1de8e1e4711",
7
+ "source": "33e8641403dd73a7ce0ca902007e3a36407e1f0b",
8
8
  "targets": [
9
9
  "ImagePlayground",
10
10
  "QuickLookThumbnailing",
@@ -49,6 +49,7 @@
49
49
  "PeachObjCRuntime",
50
50
  "PeachObjC",
51
51
  "UIUtilities",
52
+ "UIKitEnums",
52
53
  "UIKitCore",
53
54
  "PeachICU",
54
55
  "PeachCMark",
@@ -164,33 +165,14 @@
164
165
  "PeachBox2D"
165
166
  ],
166
167
  "systemEnvironment": {
167
- "scenePhase": [
168
- "string:active",
169
- "string:inactive",
170
- "string:background"
171
- ],
172
- "deviceModel": [
173
- "string"
174
- ],
175
- "systemName": [
176
- "string"
177
- ],
178
- "systemVersion": [
179
- "string"
180
- ],
181
- "colorScheme": [
182
- "string:light",
183
- "string:dark"
184
- ],
185
- "semanticColors": [
186
- "object"
187
- ],
188
- "imageAssets": [
189
- "object"
190
- ],
191
- "locale": [
192
- "string"
193
- ],
168
+ "scenePhase": ["string:active", "string:inactive", "string:background"],
169
+ "deviceModel": ["string"],
170
+ "systemName": ["string"],
171
+ "systemVersion": ["string"],
172
+ "colorScheme": ["string:light", "string:dark"],
173
+ "semanticColors": ["object"],
174
+ "imageAssets": ["object"],
175
+ "locale": ["string"],
194
176
  "dynamicTypeSize": [
195
177
  "string:xSmall",
196
178
  "string:small",
@@ -205,30 +187,22 @@
205
187
  "string:accessibility4",
206
188
  "string:accessibility5"
207
189
  ],
208
- "horizontalSizeClass": [
209
- "string:compact",
210
- "string:regular"
211
- ],
212
- "verticalSizeClass": [
213
- "string:compact",
214
- "string:regular"
215
- ],
216
- "accessibilityReduceMotion": [
217
- "bool"
218
- ]
190
+ "horizontalSizeClass": ["string:compact", "string:regular"],
191
+ "verticalSizeClass": ["string:compact", "string:regular"],
192
+ "accessibilityReduceMotion": ["bool"]
219
193
  },
220
194
  "hosts": {
221
195
  "darwin-arm64": {
222
- "sha256": "278cf5301795dd1e9f0f044bdb4e079b45ab4eb72a6e72331b06916115e34902",
223
- "size": 71532233
196
+ "sha256": "8679052c4c2b21ad748a8db40cdbc0c91ab14a29fc06bbed777efb57030c01fa",
197
+ "size": 70963039
224
198
  },
225
199
  "linux-x64": {
226
- "sha256": "920c6fe08ba45930880fee133a3cb85b310d713a4d60404f29d03555d3df879c",
227
- "size": 71538725
200
+ "sha256": "a1719d844e2f45e8c9a2ccb9dbe7857978918639a3933c225a328d84cae235cf",
201
+ "size": 70968746
228
202
  },
229
203
  "linux-arm64": {
230
- "sha256": "d3a3421e0c80cc698869bc39dd538d42b0e053db02526d3f5f22acf8e7c6dca9",
231
- "size": 71536749
204
+ "sha256": "3da8f2c920e65c633b5310c778b4a5c54b0f5f8278d58fd109f3db4310794c04",
205
+ "size": 70967077
232
206
  }
233
207
  }
234
208
  }
@@ -160,6 +160,8 @@ export function validateObjcPeerClasses(
160
160
  for (const peer of classes) {
161
161
  if (!/^[A-Za-z_]\w*$/.test(peer.name) || names.has(peer.name))
162
162
  throw new Error(`invalid or duplicate Objective-C metadata class: ${peer.name}`)
163
+ if (peer.name === 'NSSimpleCString' || peer.name === 'NSConstantString')
164
+ throw new Error(`${peer.name} metadata is emitted with NSString, not as its own peer`)
163
165
  names.add(peer.name)
164
166
  const header = /^(\w+)\/([\w./-]+\.h)$/.exec(peer.header)
165
167
  if (
@@ -307,6 +309,10 @@ export function compileObjcPeerMetadata(args: {
307
309
  descriptor?: number
308
310
  }): { object: string; registration: string; files: string[] } {
309
311
  const names = validateObjcPeerClasses(args.classes)
312
+ // clang's gnustep-2 string literals are NSConstantString instances, so any
313
+ // NSString peer also needs the literal class chain the SDK declares.
314
+ const literals = names.has('NSString') ? ['NSSimpleCString', 'NSConstantString'] : []
315
+ const emittedNames = new Set([...names, ...literals])
310
316
  const headers = materializeObjcSdk(args.headerCache)
311
317
  // an importer that cannot run may succeed later; a refusal is the answer.
312
318
  let views: Map<string, ObjcView>
@@ -338,6 +344,9 @@ export function compileObjcPeerMetadata(args: {
338
344
  registration,
339
345
  [
340
346
  'import PeachObjC',
347
+ ...(args.classes.some((peer) => peer.header.startsWith('Foundation/'))
348
+ ? ['import PeachFoundation']
349
+ : []),
341
350
  ...[...new Set(args.classes.map((peer) => peer.header.split('/')[0]!))].map(
342
351
  (module) => `import ${module}`,
343
352
  ),
@@ -347,10 +356,13 @@ export function compileObjcPeerMetadata(args: {
347
356
  (left, right) =>
348
357
  Number(right.name === 'NSObject') - Number(left.name === 'NSObject'),
349
358
  )
350
- .map(
351
- (peer) =>
352
- ` _objcRegisterPeerClass(\`${types.get(peer.name)!.swift}\`.self, nativeName: "${peer.name}")`,
353
- ),
359
+ .flatMap((peer) => [
360
+ ` _objcRegisterPeerClass(\`${types.get(peer.name)!.swift}\`.self, nativeName: "${peer.name}")`,
361
+ // foundation's adapters join the type it just registered.
362
+ ...(peer.header.startsWith('Foundation/')
363
+ ? [` _objcInstallFoundationPeerMethods(\`${types.get(peer.name)!.swift}\`.self)`]
364
+ : []),
365
+ ]),
354
366
  '}()',
355
367
  '@_cdecl("_peach_objc_register_peers")',
356
368
  'public func _peachRegisterObjcPeers() { _ = __peachPeerRegistration }',
@@ -363,7 +375,9 @@ export function compileObjcPeerMetadata(args: {
363
375
  ...[...new Set(args.classes.map((peer) => peer.header))].map(
364
376
  (header) => `#import <${header}>`,
365
377
  ),
366
- ...args.classes.map((peer) => `@implementation ${peer.name}\n@end`),
378
+ ...[...args.classes.map((peer) => peer.name), ...literals].map(
379
+ (name) => `@implementation ${name}\n@end`,
380
+ ),
367
381
  '',
368
382
  ].join('\n'),
369
383
  )
@@ -465,8 +479,8 @@ export function compileObjcPeerMetadata(args: {
465
479
  (match) => match[1]!,
466
480
  )
467
481
  if (
468
- emitted.length !== names.size ||
469
- !emitted.every((name) => names.has(name)) ||
482
+ emitted.length !== emittedNames.size ||
483
+ !emitted.every((name) => emittedNames.has(name)) ||
470
484
  /^\._OBJC_CLASS_\w+ U(?: |$)/m.test(symbols.stdout) ||
471
485
  /^_[ic]_\w+/m.test(symbols.stdout)
472
486
  )
@@ -13874,6 +13874,19 @@ __attribute__((swift_bridge("Swift.String")))
13874
13874
  - (void)appendFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
13875
13875
  + (NSMutableString *)stringWithCapacity:(NSUInteger)capacity;
13876
13876
  @end
13877
+ NS_SWIFT_UNAVAILABLE("Use String or NSString instead.")
13878
+ @interface NSSimpleCString : NSString {
13879
+ @package
13880
+ char *bytes;
13881
+ int numBytes;
13882
+ #if __LP64__
13883
+ int _unused;
13884
+ #endif
13885
+ }
13886
+ @end
13887
+ NS_SWIFT_UNAVAILABLE("Use String or NSString instead.")
13888
+ @interface NSConstantString : NSSimpleCString
13889
+ @end
13877
13890
  @interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>
13878
13891
  @property (readonly, copy) NSString *string;
13879
13892
  @end
@@ -49,6 +49,8 @@ export interface SwiftObjCImplementationPlan {
49
49
 
50
50
  export interface SwiftProjectPreparation {
51
51
  headerProducers: string[]
52
+ /** targets that could not be prepared; the rest still build. */
53
+ targetFailures: string[]
52
54
  objcImplementations?: SwiftObjCImplementationPlan
53
55
  }
54
56
 
@@ -12,6 +12,8 @@ import { fileURLToPath } from 'node:url'
12
12
  import path from 'path'
13
13
  import { WebSocket, WebSocketServer } from 'ws'
14
14
  import { DEFAULT_SOOTSIM_BRIDGE_PORT } from './bridge-constants'
15
+ import { ROLLDOWN_INVENTORY_HEADER } from './bundleGlobalFooter'
16
+ import { getCliRuntime } from './cli-runtime'
15
17
  import {
16
18
  launchRnxDesktop,
17
19
  resolveRnxDesktopAppName,
@@ -69,12 +71,16 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
69
71
  vxrnNative({ root, dev }: { root: string; dev: boolean }): Plugin {
70
72
  return {
71
73
  name: 'peach:package-versions',
72
- generateBundle(_options, bundle) {
74
+ async generateBundle(_options, bundle) {
73
75
  if (options.enabled === false || dev) return
74
76
  const versions = readInstalledNativePackageVersions(root)
77
+ const { attachRolldownBundleInventory } =
78
+ getCliRuntime().rolldown_bundle_inventory
75
79
  for (const output of Object.values(bundle)) {
76
80
  if (output.type !== 'chunk') continue
77
- output.code = insertPackageVersionsFooter(output.code, versions)
81
+ output.code = await attachRolldownBundleInventory(
82
+ insertPackageVersionsFooter(output.code, versions),
83
+ )
78
84
  }
79
85
  },
80
86
  }
@@ -95,6 +101,159 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
95
101
 
96
102
  async configureServer(server) {
97
103
  if (options.enabled === false) return
104
+ // place at the front of server.middlewares.stack so this wrapper runs
105
+ // ahead of One's .bundle handler even when one() precedes peachPlugin().
106
+ server.middlewares.use((req, res, next) => {
107
+ if (!(req.url ?? '').split('?')[0].endsWith('.bundle')) {
108
+ next()
109
+ return
110
+ }
111
+ res.setHeader(
112
+ PACKAGE_VERSIONS_HEADER,
113
+ JSON.stringify(readInstalledNativePackageVersions(server.config.root)),
114
+ )
115
+ exposeHeader(res, PACKAGE_VERSIONS_HEADER)
116
+ res.setHeader(ROLLDOWN_INVENTORY_HEADER, '1')
117
+ exposeHeader(res, ROLLDOWN_INVENTORY_HEADER)
118
+ const origWriteHead = res.writeHead.bind(res)
119
+ const origWrite = res.write.bind(res)
120
+ const origEnd = res.end.bind(res)
121
+ let pendingStatus: number | undefined
122
+ let pendingMessage: string | undefined
123
+ const flushHead = () => {
124
+ if (pendingStatus !== undefined && !res.headersSent) {
125
+ const code = pendingStatus
126
+ const msg = pendingMessage
127
+ pendingStatus = undefined
128
+ pendingMessage = undefined
129
+ if (typeof msg === 'string') origWriteHead(code, msg)
130
+ else origWriteHead(code)
131
+ }
132
+ }
133
+ Reflect.set(
134
+ res,
135
+ 'writeHead',
136
+ function (statusCode: number, statusMessage?: unknown, headers?: unknown) {
137
+ pendingStatus = statusCode
138
+ res.statusCode = statusCode
139
+ if (typeof statusMessage === 'string') pendingMessage = statusMessage
140
+ const hdrs =
141
+ typeof statusMessage === 'object' && statusMessage !== null
142
+ ? statusMessage
143
+ : headers
144
+ if (hdrs && typeof hdrs === 'object' && !Array.isArray(hdrs)) {
145
+ for (const [key, value] of Object.entries(hdrs)) {
146
+ if (key.toLowerCase() === 'content-length') continue
147
+ if (
148
+ typeof value === 'string' ||
149
+ typeof value === 'number' ||
150
+ Array.isArray(value)
151
+ ) {
152
+ res.setHeader(key, value)
153
+ }
154
+ }
155
+ }
156
+ res.removeHeader('content-length')
157
+ if (statusCode !== 200) res.removeHeader(ROLLDOWN_INVENTORY_HEADER)
158
+ return res
159
+ },
160
+ )
161
+ const chunks: Buffer[] = []
162
+ let buffering = false
163
+ const isBufferEncoding = (value: unknown): value is BufferEncoding =>
164
+ typeof value === 'string' && Buffer.isEncoding(value)
165
+ const toBuffer = (chunk: unknown, encoding?: unknown): Buffer | null => {
166
+ if (chunk === undefined || chunk === null || typeof chunk === 'function')
167
+ return null
168
+ if (Buffer.isBuffer(chunk)) return chunk
169
+ if (chunk instanceof Uint8Array) return Buffer.from(chunk)
170
+ if (typeof chunk === 'string')
171
+ return Buffer.from(chunk, isBufferEncoding(encoding) ? encoding : 'utf8')
172
+ return null
173
+ }
174
+ Reflect.set(res, 'write', function (chunk: unknown, arg1?: unknown) {
175
+ const buf = toBuffer(chunk, arg1)
176
+ if (!buf) {
177
+ flushHead()
178
+ return origWrite('')
179
+ }
180
+ if (!buffering) {
181
+ const lower = buf.toString('utf8').toLowerCase()
182
+ const contentType = String(res.getHeader('content-type') ?? '').toLowerCase()
183
+ if (
184
+ !contentType.includes('multipart/mixed') ||
185
+ lower.includes('content-type: text/javascript') ||
186
+ lower.includes('content-type: application/javascript')
187
+ ) {
188
+ buffering = true
189
+ }
190
+ }
191
+ if (buffering) {
192
+ chunks.push(buf)
193
+ return true
194
+ }
195
+ flushHead()
196
+ return origWrite(buf)
197
+ })
198
+ Reflect.set(
199
+ res,
200
+ 'end',
201
+ function (chunk?: unknown, arg1?: unknown, arg2?: unknown) {
202
+ const callback =
203
+ typeof chunk === 'function'
204
+ ? chunk
205
+ : typeof arg1 === 'function'
206
+ ? arg1
207
+ : typeof arg2 === 'function'
208
+ ? arg2
209
+ : undefined
210
+ const finish = () => {
211
+ flushHead()
212
+ if (typeof callback === 'function') {
213
+ return origEnd(() => {
214
+ Reflect.apply(callback, res, [])
215
+ })
216
+ }
217
+ return origEnd()
218
+ }
219
+ const buf = toBuffer(chunk, arg1)
220
+ if (buf) chunks.push(buf)
221
+ if (chunks.length === 0 || (res.statusCode && res.statusCode !== 200)) {
222
+ if (!res.headersSent) res.removeHeader(ROLLDOWN_INVENTORY_HEADER)
223
+ flushHead()
224
+ for (const queued of chunks) origWrite(queued)
225
+ return finish()
226
+ }
227
+ const payload = Buffer.concat(chunks).toString('utf8')
228
+ const contentType = String(res.getHeader('content-type') ?? '')
229
+ void getCliRuntime()
230
+ .rolldown_bundle_inventory.attachRolldownBundleHttpPayload(
231
+ payload,
232
+ contentType,
233
+ )
234
+ .then((annotated) => {
235
+ if (!res.headersSent) res.removeHeader('content-length')
236
+ flushHead()
237
+ origWrite(Buffer.from(annotated, 'utf8'))
238
+ finish()
239
+ })
240
+ .catch((error: unknown) => {
241
+ console.error('[peach] failed to attach rolldown bundle inventory', error)
242
+ if (!res.headersSent) {
243
+ res.removeHeader('content-length')
244
+ res.removeHeader(ROLLDOWN_INVENTORY_HEADER)
245
+ }
246
+ flushHead()
247
+ origWrite(Buffer.from(payload, 'utf8'))
248
+ finish()
249
+ })
250
+ return res
251
+ },
252
+ )
253
+ next()
254
+ })
255
+ const bundleLayer = server.middlewares.stack.pop()
256
+ if (bundleLayer) server.middlewares.stack.unshift(bundleLayer)
98
257
  const { swiftPackageDirectories } = await import('vxrn')
99
258
  let swiftPackages: Map<string, string> | undefined
100
259
  // the workspace SwiftUI module beside peachsim compiles locally; an
@@ -380,20 +539,6 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
380
539
  next()
381
540
  })
382
541
 
383
- // a native bundle carries the install it was built from, as hosted
384
- // bundles do: any shell that launches it, including one that found this
385
- // server by scanning, learns the installed native package versions.
386
- server.middlewares.use((req, res, next) => {
387
- if ((req.url ?? '').split('?')[0].endsWith('.bundle')) {
388
- res.setHeader(
389
- PACKAGE_VERSIONS_HEADER,
390
- JSON.stringify(readInstalledNativePackageVersions(server.config.root)),
391
- )
392
- exposeHeader(res, PACKAGE_VERSIONS_HEADER)
393
- }
394
- next()
395
- })
396
-
397
542
  // serve a minimal /__server-scan describing THIS vite dev server, so a
398
543
  // sootsim shell loaded from <port>/__peachsim can resolve this app's native
399
544
  // bundle. dev-bundle-resolution's resolvePortViaServerScan fetches
@@ -1,49 +0,0 @@
1
- import { describe, expect, test } from 'bun:test'
2
- import { isCliLeaseOwnerGone } from './lease-owner'
3
-
4
- const alive = () => true
5
- const gone = () => false
6
-
7
- describe('isCliLeaseOwnerGone', () => {
8
- test('a gppid owner that exited frees the lease while its group lives on', () => {
9
- const lease = {
10
- kind: 'cli' as const,
11
- cliIdentityKey: 'gppid-8513',
12
- ownerPgid: 8513,
13
- ownerPid: 8513,
14
- }
15
- expect(isCliLeaseOwnerGone(lease, alive, gone)).toBe(true)
16
- expect(isCliLeaseOwnerGone(lease, alive, alive)).toBe(false)
17
- })
18
-
19
- test('an empty owner group frees the lease whatever the identity', () => {
20
- const lease = {
21
- kind: 'cli' as const,
22
- cliIdentityKey: 'CODEX_THREAD_ID:abc',
23
- ownerPgid: 42,
24
- }
25
- expect(isCliLeaseOwnerGone(lease, gone, alive)).toBe(true)
26
- expect(isCliLeaseOwnerGone(lease, alive, gone)).toBe(false)
27
- })
28
-
29
- test('a named one-shot owner exiting frees its lease while its group survives', () => {
30
- const lease = {
31
- kind: 'cli' as const,
32
- cliIdentityKey: 'TM_SESSION:one-shot',
33
- ownerPgid: 42,
34
- ownerPid: 43,
35
- }
36
- expect(isCliLeaseOwnerGone(lease, alive, gone)).toBe(true)
37
- expect(isCliLeaseOwnerGone(lease, alive, alive)).toBe(false)
38
- })
39
-
40
- test('a user-active lease keeps ttl-only expiry', () => {
41
- const lease = {
42
- kind: 'user-active' as const,
43
- cliIdentityKey: 'gppid-1',
44
- ownerPgid: 2,
45
- ownerPid: 3,
46
- }
47
- expect(isCliLeaseOwnerGone(lease, gone, gone)).toBe(false)
48
- })
49
- })