peachsim 0.1.2560 → 0.1.2562

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 (131) hide show
  1. package/dist-lib/agent-daemon-client.cjs +1 -1
  2. package/dist-lib/agent-events.cjs +1 -1
  3. package/dist-lib/attached-projects.cjs +1 -1
  4. package/dist-lib/auth/shared-session.cjs +1 -1
  5. package/dist-lib/backend-origin.cjs +1 -1
  6. package/dist-lib/beta.cjs +1 -1
  7. package/dist-lib/beta.mjs +2 -2
  8. package/dist-lib/bridge-constants.cjs +1 -1
  9. package/dist-lib/bridge-contract-input.cjs +1 -1
  10. package/dist-lib/bridge-contract-input.mjs +5 -5
  11. package/dist-lib/bridge-contract.cjs +1 -1
  12. package/dist-lib/bridge-contract.mjs +3 -3
  13. package/dist-lib/bundle-channel.cjs +52 -12
  14. package/dist-lib/capture-contract.cjs +1 -1
  15. package/dist-lib/capture-contract.mjs +3 -3
  16. package/dist-lib/cloud-contract.cjs +1 -1
  17. package/dist-lib/cloud-contract.mjs +3 -3
  18. package/dist-lib/cloud-test-args.cjs +1 -1
  19. package/dist-lib/cloud-test-args.mjs +2 -2
  20. package/dist-lib/cloud.cjs +1 -1
  21. package/dist-lib/cloud.mjs +7 -7
  22. package/dist-lib/config.cjs +1 -1
  23. package/dist-lib/config.mjs +5 -5
  24. package/dist-lib/detox/index.cjs +2 -2
  25. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  26. package/dist-lib/esm-chunks/{acorn-CO5WASBN.mjs → acorn-Q22M6WOR.mjs} +3 -3
  27. package/dist-lib/esm-chunks/{chunk-3BESMJQO.mjs → chunk-2SO2C5FV.mjs} +1 -1
  28. package/dist-lib/esm-chunks/{chunk-RL2FZIJ4.mjs → chunk-36FHDERF.mjs} +5 -5
  29. package/dist-lib/esm-chunks/{chunk-XOEBZM45.mjs → chunk-A4JEVAJE.mjs} +1 -1
  30. package/dist-lib/esm-chunks/{chunk-D2E3LXDA.mjs → chunk-AM4K5S4B.mjs} +1 -1
  31. package/dist-lib/esm-chunks/{chunk-JGCU4O43.mjs → chunk-BHYC2MNS.mjs} +3 -3
  32. package/dist-lib/esm-chunks/{chunk-3BCOQ4H2.mjs → chunk-CNAMYVUQ.mjs} +1 -1
  33. package/dist-lib/esm-chunks/{chunk-KVRVF6Q6.mjs → chunk-GKMAR3UN.mjs} +1 -1
  34. package/dist-lib/esm-chunks/{chunk-B5EXH3LW.mjs → chunk-GZISBWKM.mjs} +1 -1
  35. package/dist-lib/esm-chunks/{chunk-27TSGHLA.mjs → chunk-HJZRIROU.mjs} +4 -4
  36. package/dist-lib/esm-chunks/{chunk-2HHFMQBN.mjs → chunk-JKZVLPH3.mjs} +1 -1
  37. package/dist-lib/esm-chunks/{chunk-TBSCDD2J.mjs → chunk-MNFZO6P7.mjs} +1 -1
  38. package/dist-lib/esm-chunks/{chunk-GKOJM3J2.mjs → chunk-ONETXZWG.mjs} +1 -1
  39. package/dist-lib/esm-chunks/{chunk-5PEKPAXB.mjs → chunk-PDHKRXLR.mjs} +1 -1
  40. package/dist-lib/esm-chunks/{chunk-2UZ7WW4Y.mjs → chunk-PLJGPUCK.mjs} +1 -1
  41. package/dist-lib/esm-chunks/{chunk-SSY2MDJY.mjs → chunk-QAR3QLGG.mjs} +1 -1
  42. package/dist-lib/esm-chunks/{chunk-HLKBS5IR.mjs → chunk-QN6HZZRJ.mjs} +1 -1
  43. package/dist-lib/esm-chunks/{chunk-2GEELRIL.mjs → chunk-SCRYU7HQ.mjs} +1 -1
  44. package/dist-lib/esm-chunks/{chunk-P6EKH2IL.mjs → chunk-UESWZZED.mjs} +2 -2
  45. package/dist-lib/esm-chunks/{chunk-R7VDCV2V.mjs → chunk-VOOX3EIF.mjs} +59 -19
  46. package/dist-lib/esm-chunks/{chunk-LAHNJ2GO.mjs → chunk-XGXCADRS.mjs} +1 -1
  47. package/dist-lib/esm-chunks/{chunk-YCGMZYJG.mjs → chunk-YHV5ITC4.mjs} +5 -5
  48. package/dist-lib/esm-chunks/{metro-layout-parser-O2CVDM6R.mjs → metro-layout-parser-6NROM3NC.mjs} +3 -3
  49. package/dist-lib/esm-chunks/{swift-package-prebuilt-SY3FNEHX.mjs → swift-package-prebuilt-4SGKMCEQ.mjs} +10 -10
  50. package/dist-lib/esm-chunks/{swift-sdk-app-module-J3RFODQ7.mjs → swift-sdk-app-module-K2BBOWB3.mjs} +13 -13
  51. package/dist-lib/esm-chunks/{swift-sdk-image-4OZNBMXU.mjs → swift-sdk-image-2OORMZCP.mjs} +13 -13
  52. package/dist-lib/esm-chunks/{swift-sdk-image-producer-ZPXRBMCV.mjs → swift-sdk-image-producer-XQ3KW7BR.mjs} +4 -4
  53. package/dist-lib/expo-swift-bundle.cjs +50 -10
  54. package/dist-lib/expo-swift-metadata.cjs +1 -1
  55. package/dist-lib/expo-swift-metadata.mjs +7 -7
  56. package/dist-lib/home-paths.cjs +1 -1
  57. package/dist-lib/host/bridge-host.cjs +92 -41
  58. package/dist-lib/host/fetch-proxy-handler.cjs +5 -5
  59. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  60. package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
  61. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  62. package/dist-lib/host/websocket-proxy.cjs +1 -1
  63. package/dist-lib/index.cjs +1 -1
  64. package/dist-lib/kotlin-host.cjs +1 -1
  65. package/dist-lib/menu.cjs +1 -1
  66. package/dist-lib/menu.mjs +3 -3
  67. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  68. package/dist-lib/metro-fingerprint-registry.mjs +3 -3
  69. package/dist-lib/metro-production-bundle.cjs +1 -1
  70. package/dist-lib/metro-production-bundle.mjs +4 -4
  71. package/dist-lib/native-app-identity-project.cjs +2 -2
  72. package/dist-lib/native-app-identity-project.mjs +15 -15
  73. package/dist-lib/native-app-identity.cjs +1 -1
  74. package/dist-lib/native-app-identity.mjs +6 -6
  75. package/dist-lib/native-firebase-metadata.cjs +1 -1
  76. package/dist-lib/native-firebase-metadata.mjs +3 -3
  77. package/dist-lib/pdfium-raster.cjs +1 -1
  78. package/dist-lib/pdfium-raster.mjs +2 -2
  79. package/dist-lib/plist.cjs +1 -1
  80. package/dist-lib/plist.mjs +3 -3
  81. package/dist-lib/profiles.cjs +1 -1
  82. package/dist-lib/public-brand.cjs +1 -1
  83. package/dist-lib/public-origins-lib-esm.json +79 -79
  84. package/dist-lib/public-origins-lib.json +69 -69
  85. package/dist-lib/react-native-host-modules.cjs +1 -1
  86. package/dist-lib/react-native-host-modules.mjs +2 -2
  87. package/dist-lib/reap-browser.cjs +1 -1
  88. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  89. package/dist-lib/sdk.cjs +1 -1
  90. package/dist-lib/sdk.mjs +7 -7
  91. package/dist-lib/skills.cjs +98 -47
  92. package/dist-lib/swift-compile.cjs +48 -8
  93. package/dist-lib/swift-compile.mjs +10 -10
  94. package/dist-lib/swift-package.cjs +1 -1
  95. package/dist-lib/swift-package.mjs +3 -3
  96. package/dist-lib/swift-submit.cjs +1 -1
  97. package/dist-lib/swift-submit.mjs +5 -5
  98. package/dist-lib/swift-svg-raster.cjs +1 -1
  99. package/dist-lib/swift-svg-raster.mjs +2 -2
  100. package/dist-lib/swift-toolchain.cjs +1 -1
  101. package/dist-lib/swift.cjs +1 -1
  102. package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
  103. package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
  104. package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
  105. package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
  106. package/dist-lib/vendor/acorn.cjs +1 -1
  107. package/dist-lib/vendor/bplist-parser.cjs +1 -1
  108. package/dist-lib/vendor/ignore.cjs +1 -1
  109. package/dist-lib/vendor/magic-string.cjs +1 -1
  110. package/dist-lib/vendor/plist.cjs +1 -1
  111. package/dist-lib/vendor/smol-toml.cjs +1 -1
  112. package/dist-lib/vendor/stream-json.cjs +1 -1
  113. package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
  114. package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
  115. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
  116. package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
  117. package/dist-lib/vendor/sucrase.cjs +1 -1
  118. package/dist-lib/vendor/terser.cjs +1 -1
  119. package/dist-lib/vendor/valibot.cjs +1 -1
  120. package/dist-lib/vendor/ws.cjs +1 -1
  121. package/dist-lib/vendor/zod.cjs +1 -1
  122. package/dist-lib/worklet-executable.cjs +1 -1
  123. package/dist-lib/worklet-executable.mjs +3 -3
  124. package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +1 -0
  125. package/dist-types/packages/peach-globals/src/browser-object-url.d.ts +1 -8
  126. package/dist-types/packages/peach-globals/src/browser-url.d.ts +8 -0
  127. package/package.json +1 -1
  128. package/runtime-companion.json +1 -1
  129. package/src/runtime-assets.ts +49 -43
  130. package/src/swift-compile.ts +54 -8
  131. package/src/swiftContract.ts +2 -0
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
 
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __commonJS = (cb, mod) => function __require() {
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
 
4
4
  // ../../node_modules/valibot/dist/index.cjs
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -1,4 +1,4 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
3
3
  "use strict";
4
4
  var __defProp = Object.defineProperty;
@@ -1,12 +1,12 @@
1
- /*! peach v0.1.2560 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.2562 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
2
2
  import {
3
3
  parse
4
- } from "./esm-chunks/chunk-XOEBZM45.mjs";
4
+ } from "./esm-chunks/chunk-A4JEVAJE.mjs";
5
5
  import {
6
6
  __privateAdd,
7
7
  __privateGet,
8
8
  __publicField
9
- } from "./esm-chunks/chunk-2HHFMQBN.mjs";
9
+ } from "./esm-chunks/chunk-JKZVLPH3.mjs";
10
10
 
11
11
  // src/worklet-kernel.ts
12
12
  var Unsupported = class extends Error {
@@ -50,6 +50,7 @@ export type PreviewUploadInitRequest = {
50
50
  contentHash: string;
51
51
  hasBundle?: boolean;
52
52
  bundleSizeBytes?: number;
53
+ bundleUploadSizeBytes?: number;
53
54
  bundleContentType?: string;
54
55
  bundleNativeAppIdentityHeader?: string | null;
55
56
  bundleEncoding?: 'gzip' | 'br';
@@ -1,10 +1,3 @@
1
- export declare const BrowserURL: {
2
- new (url: string | URL, base?: string | URL): URL;
3
- prototype: URL;
4
- canParse(url: string | URL, base?: string | URL): boolean;
5
- createObjectURL(obj: Blob | MediaSource): string;
6
- parse(url: string | URL, base?: string | URL): URL | null;
7
- revokeObjectURL(url: string): void;
8
- };
1
+ export { BrowserURL } from './browser-url.d.ts';
9
2
  export declare const createBrowserObjectURL: (obj: Blob | MediaSource) => string;
10
3
  export declare const revokeBrowserObjectURL: (url: string) => void;
@@ -0,0 +1,8 @@
1
+ export declare const BrowserURL: {
2
+ new (url: string | URL, base?: string | URL): URL;
3
+ prototype: URL;
4
+ canParse(url: string | URL, base?: string | URL): boolean;
5
+ createObjectURL(obj: Blob | MediaSource): string;
6
+ parse(url: string | URL, base?: string | URL): URL | null;
7
+ revokeObjectURL(url: string): void;
8
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peachsim",
3
- "version": "0.1.2560",
3
+ "version": "0.1.2562",
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",
@@ -1 +1 @@
1
- {"abi":1,"sha256":"dddabd2a2fec3f216287693f22e4f002de18de6b3c4829b2dee913cb1cad49d6","file":"node/cli-dddabd2a2fec3f216287693f22e4f002de18de6b3c4829b2dee913cb1cad49d6.cjs"}
1
+ {"abi":1,"sha256":"e4f8c9667fee8ed0bd41316d684267b2b7fd65309e3430a850786931e5589010","file":"node/cli-e4f8c9667fee8ed0bd41316d684267b2b7fd65309e3430a850786931e5589010.cjs"}
@@ -228,10 +228,16 @@ export function resolveRuntimeFilePath(
228
228
  // isolated surface: Swift timed waits block with Atomics.wait on a
229
229
  // SharedArrayBuffer, which exists only when the document and its workers are
230
230
  // isolated. require-corp because Safari does not isolate under credentialless.
231
+ export const runtimeIsolationHeaders = {
232
+ 'cross-origin-opener-policy': 'same-origin',
233
+ 'cross-origin-embedder-policy': 'require-corp',
234
+ 'cross-origin-resource-policy': 'cross-origin',
235
+ }
236
+
231
237
  export function setRuntimeIsolationHeaders(res: ServerResponse) {
232
- res.setHeader('cross-origin-opener-policy', 'same-origin')
233
- res.setHeader('cross-origin-embedder-policy', 'require-corp')
234
- res.setHeader('cross-origin-resource-policy', 'cross-origin')
238
+ for (const [name, value] of Object.entries(runtimeIsolationHeaders)) {
239
+ res.setHeader(name, value)
240
+ }
235
241
  }
236
242
 
237
243
  export function sendShellHtml(res: ServerResponse, html: string) {
@@ -240,37 +246,32 @@ export function sendShellHtml(res: ServerResponse, html: string) {
240
246
  res.end(html)
241
247
  }
242
248
 
249
+ // content-hashed artifacts (`name?sha256=<full hash>`, the one url scheme
250
+ // from src/site/cacheControl) are immutable: the url changes when the bytes
251
+ // do, so a warm document reuses its cache and a new artifact can never
252
+ // serve stale. (this file keeps its own 3-line predicate instead of
253
+ // importing the shared helper: the packaged CLI serves standalone.)
254
+ export function runtimeFileHeaders(filePath: string, url: string, lastModified: string) {
255
+ const immutable =
256
+ /^canvaskit-graphite-pipelines-[0-9a-f]{8}\.bin$/.test(path.basename(filePath)) ||
257
+ /[?&]sha256=[a-f0-9]{64}(?:&|$)/.test(url)
258
+ return {
259
+ ...runtimeIsolationHeaders,
260
+ 'content-type': MIME_TYPES[path.extname(filePath)] || 'application/octet-stream',
261
+ 'cache-control': immutable ? 'public, max-age=31536000, immutable' : 'no-cache',
262
+ ...(!immutable && { 'last-modified': lastModified }),
263
+ }
264
+ }
265
+
243
266
  export function serveRuntimeFile(req: any, res: any, fullPath: string) {
244
- setRuntimeIsolationHeaders(res)
245
- const ext = path.extname(fullPath)
246
267
  const stat = fs.statSync(fullPath)
247
- const lastModified = stat.mtime.toUTCString()
248
- res.setHeader('content-type', MIME_TYPES[ext] || 'application/octet-stream')
249
- if (/^canvaskit-graphite-pipelines-[0-9a-f]{8}\.bin$/.test(path.basename(fullPath))) {
250
- res.setHeader('cache-control', 'public, max-age=31536000, immutable')
268
+ const headers = runtimeFileHeaders(fullPath, req?.url ?? '', stat.mtime.toUTCString())
269
+ for (const [name, value] of Object.entries(headers)) res.setHeader(name, value)
270
+ if (!headers['last-modified']) {
251
271
  fs.createReadStream(fullPath).pipe(res)
252
272
  return
253
273
  }
254
- // content-hashed artifacts (`name?sha256=<full hash>`, the one url scheme
255
- // from src/site/cacheControl) are immutable: the url changes when the bytes
256
- // do, so a warm document reuses its cache and a new artifact can never
257
- // serve stale. (this file keeps its own 3-line predicate instead of
258
- // importing the shared helper: the packaged CLI serves standalone.)
259
- if (/[?&]sha256=[a-f0-9]{64}(?:&|$)/.test(req?.url ?? '')) {
260
- res.setHeader('cache-control', 'public, max-age=31536000, immutable')
261
- fs.createReadStream(fullPath).pipe(res)
262
- return
263
- }
264
- // these urls are STABLE across dev rebuilds and runtime version switches
265
- // (both worker entries, canvaskit-graphite.wasm, and the html shells are
266
- // unhashed), so the
267
- // browser must revalidate every load — the old year-long immutable here made every
268
- // new tab run a stale cached tenant entry against a fresh engine,
269
- // which also broke `do reload` ("bridge never reconnected"). no-cache +
270
- // last-modified keeps repeat loads cheap 304s on localhost.
271
- res.setHeader('cache-control', 'no-cache')
272
- res.setHeader('last-modified', lastModified)
273
- if (req?.headers?.['if-modified-since'] === lastModified) {
274
+ if (req?.headers?.['if-modified-since'] === headers['last-modified']) {
274
275
  res.statusCode = 304
275
276
  res.end()
276
277
  return
@@ -278,6 +279,17 @@ export function serveRuntimeFile(req: any, res: any, fullPath: string) {
278
279
  sendFileWithRanges(req, res, fullPath, stat.size, {})
279
280
  }
280
281
 
282
+ export function runtimeFileRange(header: string | null | undefined, total: number) {
283
+ const parts = /^bytes=(\d*)-(\d*)$/.exec(header ?? '')
284
+ if (!parts) return
285
+ const [, startRaw, endRaw] = parts
286
+ if ((!startRaw && !endRaw) || (startRaw && endRaw && Number(endRaw) < Number(startRaw)))
287
+ return
288
+ const start = startRaw ? Number(startRaw) : Math.max(0, total - Number(endRaw))
289
+ const end = startRaw && endRaw ? Math.min(Number(endRaw), total - 1) : total - 1
290
+ return start > end || start >= total ? null : { start, end }
291
+ }
292
+
281
293
  // a file body that honours a single `bytes=` range. a media element can only
282
294
  // seek a resource whose server answers ranges, so any file a <video> or
283
295
  // <audio> might load goes through here.
@@ -289,20 +301,14 @@ export function sendFileWithRanges(
289
301
  headers: Record<string, string>,
290
302
  ) {
291
303
  const head = (req?.method || 'GET').toUpperCase() === 'HEAD'
292
- const range = /^bytes=(\d*)-(\d*)$/.exec(req?.headers?.range || '')
293
- // a last byte before the first makes the header invalid, which a server
294
- // ignores (RFC 9110 14.1.1)
295
- const invalid = range && range[1] && range[2] && Number(range[2]) < Number(range[1])
296
- if (range && (range[1] || range[2]) && !invalid) {
297
- const [, startRaw, endRaw] = range
298
- // a suffix range (bytes=-N) is the last N bytes
299
- const start = startRaw ? Number(startRaw) : Math.max(0, total - Number(endRaw))
300
- const end = startRaw && endRaw ? Math.min(Number(endRaw), total - 1) : total - 1
301
- if (start > end || start >= total) {
302
- res.writeHead(416, { ...headers, 'Content-Range': `bytes */${total}` })
303
- res.end()
304
- return
305
- }
304
+ const range = runtimeFileRange(req?.headers?.range, total)
305
+ if (range === null) {
306
+ res.writeHead(416, { ...headers, 'Content-Range': `bytes */${total}` })
307
+ res.end()
308
+ return
309
+ }
310
+ if (range) {
311
+ const { start, end } = range
306
312
  res.writeHead(206, {
307
313
  ...headers,
308
314
  'Content-Range': `bytes ${start}-${end}/${total}`,
@@ -6894,18 +6894,60 @@ export function writeSwiftProject(
6894
6894
  target: buildProduct(`${SWIFT_HEADER_PRODUCTS_TARGET}${level}`, producers),
6895
6895
  producers,
6896
6896
  }))
6897
- const nativeBuildTargets = [
6897
+ const earlyNativeTargets = [
6898
6898
  ...new Set([
6899
6899
  ...(input.staticClangTargets ?? []),
6900
- ...[...native].flatMap(([name, plan]) => [
6901
- ...(!plan.mixed && plan.sources.length > 0 ? [name] : []),
6902
- ...(plan.groups?.map((group) => group.name) ??
6903
- (plan.late ? [plan.late.name] : [])),
6904
- ]),
6900
+ ...[...native].flatMap(([name, plan]) =>
6901
+ !plan.mixed && plan.sources.length > 0 ? [name] : [],
6902
+ ),
6905
6903
  ]),
6906
6904
  ]
6907
- const nativeProductTarget = nativeBuildTargets.length
6908
- ? buildProduct('PeachNativeProducts', nativeBuildTargets)
6905
+ const nativeBuildTargets = [
6906
+ ...new Set([
6907
+ ...earlyNativeTargets,
6908
+ ...[...native].flatMap(
6909
+ ([, plan]) =>
6910
+ plan.groups?.map((group) => group.name) ?? (plan.late ? [plan.late.name] : []),
6911
+ ),
6912
+ ]),
6913
+ ]
6914
+ let nativePrerequisiteTargets: string[] = []
6915
+ if (headerCompiler && earlyNativeTargets.length > 0) {
6916
+ const reachableFromProducers = new Set<string>()
6917
+ const visitReachable = (name: string): void => {
6918
+ if (reachableFromProducers.has(name)) return
6919
+ reachableFromProducers.add(name)
6920
+ for (const dependency of dependencies.get(name) ?? []) visitReachable(dependency)
6921
+ }
6922
+ for (const producer of orderedProducers) visitReachable(producer)
6923
+ const swiftDependent = new Map<string, boolean>()
6924
+ const reachesSwift = (name: string, seen = new Set<string>()): boolean => {
6925
+ const cached = swiftDependent.get(name)
6926
+ if (cached !== undefined) return cached
6927
+ if (seen.has(name)) return false
6928
+ seen.add(name)
6929
+ const result =
6930
+ swiftTargets.has(name) ||
6931
+ (dependencies.get(name) ?? []).some((dependency) =>
6932
+ reachesSwift(dependency, seen),
6933
+ )
6934
+ seen.delete(name)
6935
+ if (seen.size === 0) swiftDependent.set(name, result)
6936
+ return result
6937
+ }
6938
+ nativePrerequisiteTargets = earlyNativeTargets.filter(
6939
+ (name) => reachableFromProducers.has(name) && !reachesSwift(name),
6940
+ )
6941
+ }
6942
+ const nativePrerequisiteSet = new Set(nativePrerequisiteTargets)
6943
+ const remainingNativeBuildTargets = nativeBuildTargets.filter(
6944
+ (name) => !nativePrerequisiteSet.has(name),
6945
+ )
6946
+ const nativePrerequisiteTarget = nativePrerequisiteTargets.length
6947
+ ? buildProduct('PeachHeaderNativePrereqs', nativePrerequisiteTargets)
6948
+ : undefined
6949
+ const nativeProductTarget = remainingNativeBuildTargets.length
6950
+ ? buildProduct('PeachNativeProducts', remainingNativeBuildTargets)
6909
6951
  : undefined
6910
6952
  files.set(manifestPath, manifest)
6911
6953
  syncSwiftTree(layout.root, files)
@@ -6918,6 +6960,7 @@ export function writeSwiftProject(
6918
6960
  if (files.has(clangWrapper) && (statSync(clangWrapper).mode & 0o7777) !== 0o755)
6919
6961
  chmodSync(clangWrapper, 0o755)
6920
6962
  return {
6963
+ nativePrerequisiteTarget,
6921
6964
  headerBuilds,
6922
6965
  nativeHeaderDeclarations,
6923
6966
  nativeProductTarget,
@@ -8700,6 +8743,9 @@ async function compileSwiftProjectOnce(
8700
8743
  // swiftpm's transitive swift module maps are not C declarations:
8701
8744
  // importing them would shadow SDK modules such as ObjectiveC.
8702
8745
  const stages = [
8746
+ ...(preparation.nativePrerequisiteTarget
8747
+ ? [{ target: preparation.nativePrerequisiteTarget, producers: [] }]
8748
+ : []),
8703
8749
  ...preparation.headerBuilds,
8704
8750
  ...(preparation.nativeProductTarget
8705
8751
  ? [{ target: preparation.nativeProductTarget, producers: [] }]
@@ -216,6 +216,8 @@ export function isSwiftHeaderAliases(value: unknown): value is SwiftHeaderAliase
216
216
  }
217
217
 
218
218
  export interface SwiftProjectPreparation {
219
+ /** pure-clang prerequisites of header producers commit their objects before Swift builds. */
220
+ nativePrerequisiteTarget?: string
219
221
  /** dependency-ordered stages; independent producers share one SwiftPM build. */
220
222
  headerBuilds: { target: string; producers: string[] }[]
221
223
  /** completed native products commit their object records before the app build. */