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,4 +1,4 @@
1
- /*! peach v0.1.1653 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
1
+ /*! peach v0.1.1655 | (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;
@@ -45019,6 +45019,19 @@ __attribute__((swift_bridge("Swift.String")))
45019
45019
  - (void)appendFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);
45020
45020
  + (NSMutableString *)stringWithCapacity:(NSUInteger)capacity;
45021
45021
  @end
45022
+ NS_SWIFT_UNAVAILABLE("Use String or NSString instead.")
45023
+ @interface NSSimpleCString : NSString {
45024
+ @package
45025
+ char *bytes;
45026
+ int numBytes;
45027
+ #if __LP64__
45028
+ int _unused;
45029
+ #endif
45030
+ }
45031
+ @end
45032
+ NS_SWIFT_UNAVAILABLE("Use String or NSString instead.")
45033
+ @interface NSConstantString : NSSimpleCString
45034
+ @end
45022
45035
  @interface NSAttributedString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>
45023
45036
  @property (readonly, copy) NSString *string;
45024
45037
  @end
@@ -48034,6 +48047,9 @@ async function runCompiler(command, args, options, stream = false, quiet) {
48034
48047
  await stopping;
48035
48048
  }
48036
48049
  }
48050
+ function swiftBuilderHopTimeoutMs(compileTimeoutMs) {
48051
+ return (compileTimeoutMs ?? SWIFT_BUILDER_DEFAULT_COMPILE_MS) + SWIFT_BUILDER_TRANSPORT_MARGIN_MS;
48052
+ }
48037
48053
  function swiftDistributionAt(root) {
48038
48054
  const file = import_node_path11.default.join(root, SWIFT_DISTRIBUTION_MANIFEST);
48039
48055
  if (!(0, import_node_fs13.existsSync)(file)) return null;
@@ -50330,6 +50346,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
50330
50346
  ] : compileTargets(input);
50331
50347
  const files2 = /* @__PURE__ */ new Map();
50332
50348
  const native = /* @__PURE__ */ new Map();
50349
+ const targetFailures = [];
50333
50350
  const bySourcePath = [...targets].sort(
50334
50351
  (left, right) => right.path.length - left.path.length
50335
50352
  );
@@ -50380,188 +50397,212 @@ function writeSwiftProject(layout, input, moduleRoot) {
50380
50397
  if (units.length === 0) continue;
50381
50398
  const settings = input.nativeTargets?.find((value) => value.name === target.name);
50382
50399
  if (entries.some(([file]) => file.endsWith(".swift")) || settings && units.some(([file]) => /\.mm?$/.test(file))) {
50383
- if (!settings)
50384
- throw new Error(
50385
- `mixed target ${target.name} requires its original native target settings; SwiftPM does not compile mixed source targets`
50400
+ const swift = entries.some(([file]) => file.endsWith(".swift"));
50401
+ try {
50402
+ if (!settings)
50403
+ throw new Error(
50404
+ `mixed target ${target.name} requires its original native target settings; SwiftPM does not compile mixed source targets`
50405
+ );
50406
+ const headers = settings.headers;
50407
+ const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : settings.publicHeaders;
50408
+ for (const file of headers) {
50409
+ const destination = import_node_path11.default.join(layout.root, file);
50410
+ (0, import_node_fs13.mkdirSync)(import_node_path11.default.dirname(destination), { recursive: true });
50411
+ (0, import_node_fs13.writeFileSync)(destination, input.files[file]);
50412
+ }
50413
+ const search = [
50414
+ .../* @__PURE__ */ new Set([
50415
+ ...settings?.headerSearchPaths ?? [],
50416
+ ...headers.map((file) => import_node_path11.default.posix.dirname(file))
50417
+ ])
50418
+ ].flatMap((dir) => ["-I", import_node_path11.default.join(layout.root, dir)]);
50419
+ const pin = distribution ?? JSON.parse((0, import_node_fs13.readFileSync)(import_node_path11.default.join(moduleRoot, "toolchain.json"), "utf8"));
50420
+ const release = pin.release;
50421
+ const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot));
50422
+ const sdkHeaders = materializeObjcSdk(
50423
+ import_node_path11.default.join(layout.root, ".build", "peach-objc-sdk")
50386
50424
  );
50387
- const headers = settings.headers;
50388
- const roots2 = settings.bridgingHeader ? [settings.bridgingHeader] : settings.publicHeaders;
50389
- if (!roots2.length)
50390
- throw new Error(`mixed target ${target.name} has no original declaration headers`);
50391
- for (const file of headers) {
50392
- const destination = import_node_path11.default.join(layout.root, file);
50393
- (0, import_node_fs13.mkdirSync)(import_node_path11.default.dirname(destination), { recursive: true });
50394
- (0, import_node_fs13.writeFileSync)(destination, input.files[file]);
50395
- }
50396
- const search = [
50397
- .../* @__PURE__ */ new Set([
50398
- ...settings?.headerSearchPaths ?? [],
50399
- ...headers.map((file) => import_node_path11.default.posix.dirname(file))
50400
- ])
50401
- ].flatMap((dir) => ["-I", import_node_path11.default.join(layout.root, dir)]);
50402
- const pin = distribution ?? JSON.parse((0, import_node_fs13.readFileSync)(import_node_path11.default.join(moduleRoot, "toolchain.json"), "utf8"));
50403
- const release = pin.release;
50404
- const toolchainBin = swiftToolchain(release, swiftModuleSdk(moduleRoot));
50405
- const sdkHeaders = materializeObjcSdk(
50406
- import_node_path11.default.join(layout.root, ".build", "peach-objc-sdk")
50407
- );
50408
- const stageFlags = (flags2, sdkInclude) => flags2.map(
50409
- (flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude)
50410
- );
50411
- const originalFlags = [
50412
- ...settings?.flags ?? [],
50413
- ...search,
50414
- ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
50415
- "-F",
50416
- import_node_path11.default.join(layout.root, dir)
50417
- ]),
50418
- "-I",
50419
- headerDirectory
50420
- ];
50421
- const flags = stageFlags(
50422
- originalFlags,
50423
- import_node_path11.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "include")
50424
- );
50425
- const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path11.default.join(layout.root, settings.prefixHeader)] : [];
50426
- const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
50427
- target: target.name,
50428
- path: target.path,
50429
- resources: resourceTargets.find((candidate) => candidate.name === target.name)?.resources ?? false,
50430
- usesBundleMacro: entries.some(
50431
- ([file, contents]) => /\.(?:c|cc|cpp|cxx|m|mm|h|hpp|hh|hxx)$/.test(file) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents)
50432
- ),
50433
- bundles: input.resourceBundles
50434
- });
50435
- const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
50436
- const accessorHeader = import_node_path11.default.join(
50437
- layout.root,
50438
- target.path,
50439
- OBJC_RESOURCE_ACCESSOR_HEADER
50440
- );
50441
- const accessorUnit = `${prefix}${OBJC_RESOURCE_ACCESSOR_BODY}`;
50442
- if (accessor && (input.files[accessorUnit] !== void 0 || input.files[`${prefix}${OBJC_RESOURCE_ACCESSOR_HEADER}`] !== void 0))
50443
- throw new Error(`target ${target.name} already contains its resource accessor`);
50444
- const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
50445
- const accessorFlags = accessor ? ["-include", accessorHeader] : [];
50446
- if (accessor) {
50447
- files2.set(accessorHeader, accessor.header);
50448
- files2.set(import_node_path11.default.join(layout.root, accessorUnit), accessor.body);
50449
- }
50450
- const sourceHeaders = import_node_path11.default.join(
50451
- layout.root,
50452
- ".build",
50453
- "peach-objc-originals",
50454
- target.name
50455
- );
50456
- (0, import_node_fs13.mkdirSync)(sourceHeaders, { recursive: true });
50457
- const modulemap = import_node_path11.default.join(sourceHeaders, "module.modulemap");
50458
- (0, import_node_fs13.writeFileSync)(
50459
- modulemap,
50460
- `module ${swiftTargetModuleName(target.name)} {
50425
+ const stageFlags = (flags2, sdkInclude) => flags2.map(
50426
+ (flag) => flag.replaceAll(SWIFT_NATIVE_INPUT_ROOT, layout.root).replaceAll(SWIFT_NATIVE_SDK_INCLUDE, sdkInclude)
50427
+ );
50428
+ const originalFlags = [
50429
+ ...settings?.flags ?? [],
50430
+ ...search,
50431
+ ...(settings?.frameworkSearchPaths ?? []).flatMap((dir) => [
50432
+ "-F",
50433
+ import_node_path11.default.join(layout.root, dir)
50434
+ ]),
50435
+ "-I",
50436
+ headerDirectory
50437
+ ];
50438
+ const flags = stageFlags(
50439
+ originalFlags,
50440
+ import_node_path11.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "include")
50441
+ );
50442
+ const prefixHeader = settings?.prefixHeader ? ["-include", import_node_path11.default.join(layout.root, settings.prefixHeader)] : [];
50443
+ const bundleName = entries.some(([file]) => file.endsWith(".swift")) ? void 0 : swiftObjCResourceBundleName({
50444
+ target: target.name,
50445
+ path: target.path,
50446
+ resources: resourceTargets.find((candidate) => candidate.name === target.name)?.resources ?? false,
50447
+ usesBundleMacro: entries.some(
50448
+ ([file, contents]) => /\.(?:c|cc|cpp|cxx|m|mm|h|hpp|hh|hxx)$/.test(file) && /\bSWIFTPM_MODULE_BUNDLE\b/.test(contents)
50449
+ ),
50450
+ bundles: input.resourceBundles
50451
+ });
50452
+ const accessor = bundleName === void 0 ? void 0 : swiftObjCResourceAccessor(bundleName);
50453
+ const accessorHeader = import_node_path11.default.join(
50454
+ layout.root,
50455
+ target.path,
50456
+ OBJC_RESOURCE_ACCESSOR_HEADER
50457
+ );
50458
+ const accessorUnit = `${prefix}${OBJC_RESOURCE_ACCESSOR_BODY}`;
50459
+ if (accessor && (input.files[accessorUnit] !== void 0 || input.files[`${prefix}${OBJC_RESOURCE_ACCESSOR_HEADER}`] !== void 0))
50460
+ throw new Error(`target ${target.name} already contains its resource accessor`);
50461
+ const nativeUnits = accessor ? [...units, [accessorUnit, accessor.body]] : units;
50462
+ const accessorFlags = accessor ? ["-include", accessorHeader] : [];
50463
+ if (accessor) {
50464
+ files2.set(accessorHeader, accessor.header);
50465
+ files2.set(import_node_path11.default.join(layout.root, accessorUnit), accessor.body);
50466
+ }
50467
+ if (roots2.length) {
50468
+ const sourceHeaders = import_node_path11.default.join(
50469
+ layout.root,
50470
+ ".build",
50471
+ "peach-objc-originals",
50472
+ target.name
50473
+ );
50474
+ (0, import_node_fs13.mkdirSync)(sourceHeaders, { recursive: true });
50475
+ const modulemap = import_node_path11.default.join(sourceHeaders, "module.modulemap");
50476
+ (0, import_node_fs13.writeFileSync)(
50477
+ modulemap,
50478
+ `module ${swiftTargetModuleName(target.name)} {
50461
50479
  ${roots2.map((file) => `header ${JSON.stringify(import_node_path11.default.join(layout.root, file))}`).join("\n")}
50462
50480
  export *
50463
50481
  }
50464
50482
  `
50465
- );
50466
- const view = objcView(
50467
- { module: swiftTargetModuleName(target.name), headers: sourceHeaders, modulemap },
50468
- toolchainBin,
50469
- import_node_path11.default.join(moduleRoot, "ios-simulator-stdlib"),
50470
- import_node_path11.default.join(layout.root, ".build", "peach-objc-sdk"),
50471
- import_node_path11.default.join(layout.root, ".build", "peach-objc-imports", target.name),
50472
- {
50473
- flags: stageFlags(originalFlags, import_node_path11.default.join(sdkHeaders, "usr/include")),
50474
- target: `arm64-apple-ios${settings?.deploymentTarget ?? "16.0"}-simulator`
50483
+ );
50484
+ const view = objcView(
50485
+ {
50486
+ module: swiftTargetModuleName(target.name),
50487
+ headers: sourceHeaders,
50488
+ modulemap
50489
+ },
50490
+ toolchainBin,
50491
+ import_node_path11.default.join(moduleRoot, "ios-simulator-stdlib"),
50492
+ import_node_path11.default.join(layout.root, ".build", "peach-objc-sdk"),
50493
+ import_node_path11.default.join(layout.root, ".build", "peach-objc-imports", target.name),
50494
+ {
50495
+ flags: stageFlags(originalFlags, import_node_path11.default.join(sdkHeaders, "usr/include")),
50496
+ target: `arm64-apple-ios${settings?.deploymentTarget ?? "16.0"}-simulator`
50497
+ }
50498
+ );
50499
+ const defined = /* @__PURE__ */ new Set();
50500
+ const declarations = (node) => {
50501
+ if (!node || typeof node !== "object") return;
50502
+ const name3 = Reflect.get(node, "name");
50503
+ if (Reflect.get(node, "kind") === "ObjCInterfaceDecl" && Reflect.get(node, "super") && typeof name3 === "string")
50504
+ defined.add(name3);
50505
+ const children = Reflect.get(node, "inner");
50506
+ if (Array.isArray(children)) for (const child of children) declarations(child);
50507
+ };
50508
+ declarations(view.clangAST);
50509
+ const foreignTypes = /* @__PURE__ */ new Map();
50510
+ for (const graph of view.graphs)
50511
+ for (const symbol of graph.symbols) {
50512
+ const nativeName = /^c:objc\(cs\)(\w+)$/.exec(
50513
+ symbol.identifier.precise
50514
+ )?.[1];
50515
+ if (nativeName && defined.has(nativeName))
50516
+ foreignTypes.set(symbol.pathComponents[0], nativeName);
50517
+ }
50518
+ imports.set(target.name, {
50519
+ view,
50520
+ classes: [...foreignTypes.values()],
50521
+ headers: roots2.map((file) => import_node_path11.default.join(layout.root, file)),
50522
+ foreignTypes
50523
+ });
50475
50524
  }
50476
- );
50477
- const defined = /* @__PURE__ */ new Set();
50478
- const declarations = (node) => {
50479
- if (!node || typeof node !== "object") return;
50480
- const name3 = Reflect.get(node, "name");
50481
- if (Reflect.get(node, "kind") === "ObjCInterfaceDecl" && Reflect.get(node, "super") && typeof name3 === "string")
50482
- defined.add(name3);
50483
- const children = Reflect.get(node, "inner");
50484
- if (Array.isArray(children)) for (const child of children) declarations(child);
50485
- };
50486
- declarations(view.clangAST);
50487
- const foreignTypes = /* @__PURE__ */ new Map();
50488
- for (const graph of view.graphs)
50489
- for (const symbol of graph.symbols) {
50490
- const nativeName = /^c:objc\(cs\)(\w+)$/.exec(symbol.identifier.precise)?.[1];
50491
- if (nativeName && defined.has(nativeName))
50492
- foreignTypes.set(symbol.pathComponents[0], nativeName);
50493
- }
50494
- imports.set(target.name, {
50495
- view,
50496
- classes: [...foreignTypes.values()],
50497
- headers: roots2.map((file) => import_node_path11.default.join(layout.root, file)),
50498
- foreignTypes
50499
- });
50500
- const thunk = "PeachObjCImports.generated.m";
50501
- const groups = /* @__PURE__ */ new Map();
50502
- for (const [file] of nativeUnits) {
50503
- const origin = settings?.sourceDirectories[file];
50504
- if (origin) (0, import_node_fs13.mkdirSync)(import_node_path11.default.join(layout.root, origin), { recursive: true });
50505
- const perFile = [
50506
- ...origin ? ["-iquote", import_node_path11.default.join(layout.root, origin)] : [],
50507
- ...stageFlags(
50508
- settings?.fileFlags[file] ?? [],
50509
- import_node_path11.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "include")
50510
- )
50511
- ];
50512
- const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
50513
- const identity = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify([cxx, perFile])).digest("hex").slice(0, 12);
50514
- const group = groups.get(identity) ?? {
50515
- name: `${target.name}SwiftImplementation_${identity}`,
50516
- sources: [],
50517
- flags: [...flags, ...prefixHeader, ...accessorFlags, ...perFile],
50518
- cxxFlags: [
50519
- ...flags,
50520
- ...prefixHeader,
50521
- ...accessorFlags,
50525
+ const thunks = roots2.length ? ["PeachObjCImports.generated.m"] : [];
50526
+ const groups = /* @__PURE__ */ new Map();
50527
+ for (const [file] of nativeUnits) {
50528
+ const origin = settings?.sourceDirectories[file];
50529
+ if (origin) (0, import_node_fs13.mkdirSync)(import_node_path11.default.join(layout.root, origin), { recursive: true });
50530
+ const perFile = [
50531
+ ...origin ? ["-iquote", import_node_path11.default.join(layout.root, origin)] : [],
50522
50532
  ...stageFlags(
50523
- cxx ? settings.cxxFlags : [],
50533
+ settings?.fileFlags[file] ?? [],
50524
50534
  import_node_path11.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "include")
50525
- ),
50526
- ...perFile
50527
- ]
50528
- };
50529
- group.sources.push(file.slice(prefix.length));
50530
- groups.set(identity, group);
50531
- }
50532
- groups.set("imports", {
50533
- name: `${target.name}ObjCImports`,
50534
- sources: [thunk],
50535
- flags: [...flags, "-fobjc-arc"],
50536
- cxxFlags: [...flags, "-fobjc-arc"]
50537
- });
50538
- const include2 = import_node_path11.default.join(layout.root, target.path, "include");
50539
- files2.set(
50540
- import_node_path11.default.join(include2, "module.modulemap"),
50541
- `module ${target.name}ImplementationDeclarations { export * }
50535
+ )
50536
+ ];
50537
+ const cxx = /\.(?:cc|cpp|cxx|mm)$/.test(file);
50538
+ const identity = (0, import_node_crypto11.createHash)("sha256").update(JSON.stringify([cxx, perFile])).digest("hex").slice(0, 12);
50539
+ const group = groups.get(identity) ?? {
50540
+ name: `${target.name}SwiftImplementation_${identity}`,
50541
+ sources: [],
50542
+ flags: [...flags, ...prefixHeader, ...accessorFlags, ...perFile],
50543
+ cxxFlags: [
50544
+ ...flags,
50545
+ ...prefixHeader,
50546
+ ...accessorFlags,
50547
+ ...stageFlags(
50548
+ cxx ? settings.cxxFlags : [],
50549
+ import_node_path11.default.join(swiftSdkPaths(moduleRoot, toolchainBin).sysroot, "include")
50550
+ ),
50551
+ ...perFile
50552
+ ]
50553
+ };
50554
+ group.sources.push(file.slice(prefix.length));
50555
+ groups.set(identity, group);
50556
+ }
50557
+ if (thunks.length)
50558
+ groups.set("imports", {
50559
+ name: `${target.name}ObjCImports`,
50560
+ sources: thunks,
50561
+ flags: [...flags, "-fobjc-arc"],
50562
+ cxxFlags: [...flags, "-fobjc-arc"]
50563
+ });
50564
+ const include2 = import_node_path11.default.join(layout.root, target.path, "include");
50565
+ files2.set(
50566
+ import_node_path11.default.join(include2, "module.modulemap"),
50567
+ `module ${target.name}ImplementationDeclarations { export * }
50542
50568
  `
50543
- );
50544
- native.set(target.name, {
50545
- mixed: true,
50546
- path: target.path,
50547
- includeDirectory: include2,
50548
- sources: nativeUnits.map(([file]) => file.slice(prefix.length)),
50549
- lateSources: [...nativeUnits.map(([file]) => file.slice(prefix.length)), thunk],
50550
- exclude: [
50551
- ...entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length)),
50552
- ...accessor ? [OBJC_RESOURCE_ACCESSOR_HEADER, OBJC_RESOURCE_ACCESSOR_BODY] : [],
50553
- thunk,
50554
- "include"
50555
- ],
50556
- groups: [...groups.values()],
50557
- late: {
50558
- name: `${target.name}SwiftImplementation`,
50559
- producers: [
50560
- target.name,
50561
- ...(target.dependencies ?? []).filter((dependency) => swiftTargets.has(dependency.name)).map((dependency) => dependency.name)
50562
- ]
50563
- }
50564
- });
50569
+ );
50570
+ native.set(target.name, {
50571
+ mixed: true,
50572
+ path: target.path,
50573
+ includeDirectory: include2,
50574
+ sources: nativeUnits.map(([file]) => file.slice(prefix.length)),
50575
+ lateSources: [
50576
+ ...nativeUnits.map(([file]) => file.slice(prefix.length)),
50577
+ ...thunks
50578
+ ],
50579
+ exclude: [
50580
+ ...entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length)),
50581
+ ...accessor ? [OBJC_RESOURCE_ACCESSOR_HEADER, OBJC_RESOURCE_ACCESSOR_BODY] : [],
50582
+ ...thunks,
50583
+ "include"
50584
+ ],
50585
+ groups: [...groups.values()],
50586
+ late: {
50587
+ name: `${target.name}SwiftImplementation`,
50588
+ producers: [
50589
+ target.name,
50590
+ ...(target.dependencies ?? []).filter((dependency) => swiftTargets.has(dependency.name)).map((dependency) => dependency.name)
50591
+ ]
50592
+ }
50593
+ });
50594
+ } catch (error) {
50595
+ if (!swift || !(error instanceof Error)) throw error;
50596
+ targetFailures.push(`${target.name}: ${error.message}`);
50597
+ native.set(target.name, {
50598
+ mixed: true,
50599
+ path: target.path,
50600
+ includeDirectory: import_node_path11.default.join(layout.root, target.path, "include"),
50601
+ sources: [],
50602
+ lateSources: [],
50603
+ exclude: entries.filter(([file]) => !file.endsWith(".swift") && !file.endsWith(".metal")).map(([file]) => file.slice(prefix.length))
50604
+ });
50605
+ }
50565
50606
  continue;
50566
50607
  }
50567
50608
  const includes = `${prefix}include/`;
@@ -50724,20 +50765,27 @@ export *
50724
50765
  for (const name3 of objcProducers) {
50725
50766
  const target = targets.find((value) => value.name === name3);
50726
50767
  const prefix = target.path === "." ? "" : `${target.path}/`;
50727
- const exported = swiftObjCExports({
50728
- module: swiftTargetModuleName(name3),
50729
- sources: Object.entries(input.files).filter(
50730
- ([file]) => file.startsWith(prefix) && file.endsWith(".swift") && !targets.some(
50731
- (candidate) => candidate.name !== name3 && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
50732
- ) && !target.exclude?.some(
50733
- (excluded) => file.slice(prefix.length) === excluded || file.slice(prefix.length).startsWith(`${excluded}/`)
50734
- )
50735
- ),
50736
- mask: swiftCodeMask,
50737
- declarationStart,
50738
- selector: objcSelectorName,
50739
- foreignTypes: imports.get(name3)?.foreignTypes
50740
- });
50768
+ let exported;
50769
+ try {
50770
+ exported = swiftObjCExports({
50771
+ module: swiftTargetModuleName(name3),
50772
+ sources: Object.entries(input.files).filter(
50773
+ ([file]) => file.startsWith(prefix) && file.endsWith(".swift") && !targets.some(
50774
+ (candidate) => candidate.name !== name3 && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
50775
+ ) && !target.exclude?.some(
50776
+ (excluded) => file.slice(prefix.length) === excluded || file.slice(prefix.length).startsWith(`${excluded}/`)
50777
+ )
50778
+ ),
50779
+ mask: swiftCodeMask,
50780
+ declarationStart,
50781
+ selector: objcSelectorName,
50782
+ foreignTypes: imports.get(name3)?.foreignTypes
50783
+ });
50784
+ } catch (error) {
50785
+ if (!(error instanceof Error)) throw error;
50786
+ targetFailures.push(`${name3}: ${error.message}`);
50787
+ continue;
50788
+ }
50741
50789
  const original = imports.get(name3);
50742
50790
  if (!exported && !original) continue;
50743
50791
  objcModules.add(name3);
@@ -51009,6 +51057,7 @@ public func __peachObjcExportRoot() { _objcRegisterPeerClass(NSObject.self, nati
51009
51057
  for (const dependency of dependencies.get(producer) ?? []) include(dependency);
51010
51058
  return {
51011
51059
  headerProducers: producers.filter((name3) => !included.has(name3)),
51060
+ targetFailures,
51012
51061
  ...rootOwner && objcExports ? {
51013
51062
  objcImplementations: {
51014
51063
  owner: import_node_path11.default.join(layout.root, rootOwner),
@@ -51195,7 +51244,7 @@ function compileSwiftProjectUnit(input, options) {
51195
51244
  ],
51196
51245
  {
51197
51246
  cwd: repo,
51198
- timeout: options.timeoutMs,
51247
+ timeout: options.timeoutMs === void 0 ? void 0 : swiftBuilderHopTimeoutMs(options.timeoutMs),
51199
51248
  maxBuffer: 64 * 1024 * 1024,
51200
51249
  signal: options.signal
51201
51250
  },
@@ -51227,6 +51276,9 @@ function compileSwiftProjectUnit(input, options) {
51227
51276
  return retain(root, built2);
51228
51277
  }
51229
51278
  const preparation = writeSwiftProject(layout, input, moduleRoot);
51279
+ const unprepared = preparation.targetFailures.map(
51280
+ (failure3) => `error: target ${failure3}`
51281
+ );
51230
51282
  const swift = import_node_path11.default.join(options.toolchainBin, "swift");
51231
51283
  if (!(0, import_node_fs13.existsSync)(swift)) {
51232
51284
  throw new Error(
@@ -51376,18 +51428,23 @@ function compileSwiftProjectUnit(input, options) {
51376
51428
  );
51377
51429
  } catch (retryError) {
51378
51430
  throw new Error(
51379
- projectDiagnostic(outputOf(retryError), layout, input.files),
51380
- {
51381
- cause: retryError
51382
- }
51431
+ [
51432
+ ...unprepared,
51433
+ projectDiagnostic(outputOf(retryError), layout, input.files)
51434
+ ].join("\n"),
51435
+ { cause: retryError }
51383
51436
  );
51384
51437
  }
51385
51438
  } else {
51386
- throw new Error(projectDiagnostic(output, layout, input.files), {
51387
- cause: error
51388
- });
51439
+ throw new Error(
51440
+ [...unprepared, projectDiagnostic(output, layout, input.files)].join(
51441
+ "\n"
51442
+ ),
51443
+ { cause: error }
51444
+ );
51389
51445
  }
51390
51446
  }
51447
+ if (unprepared.length) throw new Error(unprepared.join("\n"));
51391
51448
  const artifact = {
51392
51449
  hash: hash2,
51393
51450
  bytes: (0, import_node_fs13.readFileSync)(builtArtifact(layout)),
@@ -51404,7 +51461,7 @@ function compileSwiftProjectUnit(input, options) {
51404
51461
  options.signal
51405
51462
  );
51406
51463
  }
51407
- var import_node_child_process11, import_node_crypto11, import_node_fs13, import_node_os6, import_node_path11, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, BUILD_JOBS, linkedModuleDigests, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, sdkPaths, availableModules, ONE_PRODUCT, SPRITEKIT_PRODUCT, importsSpriteKit, FOUNDATION_IMPLICIT_MODULES, FOUNDATION_IMPLICIT_FLAGS, ONE_IMPLICIT_FLAGS, EXECUTABLE_LINK_FLAGS, REACTOR_FLAG, MULTI_MANIFEST_VERSION, compilerSourceDigest, DIRECTIVE, OS_IOS, OBJC_ATTRIBUTE, SELECTOR, PROTOCOL_NAME, KEY_PATH, TYPE_AFTER_ATTRIBUTE, DELEGATE_CLASS, REUSABLE_INIT, REUSABLE_VIEW_BASES, CLASS_BASE, FRAME_INIT, APPLE_CLASS, EXTENSION_DECL, CLASS_DECL, MODIFIERS, OVERRIDE_FUNC, OVERRIDE_VAR, APPLE_PROTOCOL, OBJC_PROTOCOL, OBJC_PREPOSITIONS, DECLARATION_MODIFIERS, optionalResult, SDK_OBJC_OPTIONAL, IMP_CONVENTION, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, ROOT_LOCKS, host, rootLocks, retainedArtifacts;
51464
+ var import_node_child_process11, import_node_crypto11, import_node_fs13, import_node_os6, import_node_path11, WASM_TRIPLE, SWIFTPM_PROGRESS, SWIFTPM_NOISE, BUILD_JOBS, SWIFT_BUILDER_TRANSPORT_MARGIN_MS, SWIFT_BUILDER_DEFAULT_COMPILE_MS, linkedModuleDigests, OPTIONAL_FRAMEWORK_DEPENDENCIES, OPTIONAL_FRAMEWORKS, SWIFT_IMPORT, sdkPaths, availableModules, ONE_PRODUCT, SPRITEKIT_PRODUCT, importsSpriteKit, FOUNDATION_IMPLICIT_MODULES, FOUNDATION_IMPLICIT_FLAGS, ONE_IMPLICIT_FLAGS, EXECUTABLE_LINK_FLAGS, REACTOR_FLAG, MULTI_MANIFEST_VERSION, compilerSourceDigest, DIRECTIVE, OS_IOS, OBJC_ATTRIBUTE, SELECTOR, PROTOCOL_NAME, KEY_PATH, TYPE_AFTER_ATTRIBUTE, DELEGATE_CLASS, REUSABLE_INIT, REUSABLE_VIEW_BASES, CLASS_BASE, FRAME_INIT, APPLE_CLASS, EXTENSION_DECL, CLASS_DECL, MODIFIERS, OVERRIDE_FUNC, OVERRIDE_VAR, APPLE_PROTOCOL, OBJC_PROTOCOL, OBJC_PREPOSITIONS, DECLARATION_MODIFIERS, optionalResult, SDK_OBJC_OPTIONAL, IMP_CONVENTION, FOUNDATION_NETWORKING_TYPES, FOUNDATION_OVERLAY_TYPES, FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_OVERLAY_GLOBALS, CORE_FOUNDATION_GEOMETRY_TYPES, CORE_FOUNDATION_GRAPHICS_TYPES, CORE_FOUNDATION_HANDLE_IMPORTS, ROOT_LOCKS, host, rootLocks, retainedArtifacts;
51408
51465
  var init_swift_compile = __esm({
51409
51466
  "src/swift-compile.ts"() {
51410
51467
  "use strict";
@@ -51436,6 +51493,8 @@ var init_swift_compile = __esm({
51436
51493
  BUILD_JOBS = String(
51437
51494
  Math.min(4, Math.max(1, Math.floor(import_node_os6.default.availableParallelism() / 2)))
51438
51495
  );
51496
+ SWIFT_BUILDER_TRANSPORT_MARGIN_MS = 3e5;
51497
+ SWIFT_BUILDER_DEFAULT_COMPILE_MS = 18e5;
51439
51498
  linkedModuleDigests = /* @__PURE__ */ new Map();
51440
51499
  OPTIONAL_FRAMEWORK_DEPENDENCIES = {
51441
51500
  GameplayKit: [],
@@ -51508,7 +51567,7 @@ var init_swift_compile = __esm({
51508
51567
  `;
51509
51568
  REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
51510
51569
  MULTI_MANIFEST_VERSION = 39;
51511
- compilerSourceDigest = true ? "f4eb526a3d0d01972f3bb179b60c2b10df37c90e90ad1717a3b4946374cdb248" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
51570
+ compilerSourceDigest = true ? "042e57f70d169ec5fd94262a87fc4d50da0c31cc6a6c329e56f12d4b7c5484a1" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
51512
51571
  DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
51513
51572
  OS_IOS = /\b(?:os\(\s*iOS\s*\)|targetEnvironment\(\s*simulator\s*\))/g;
51514
51573
  OBJC_ATTRIBUTE = /^@(?:objcMembers\b|objc\b(?:(\s*)\(([^()]*)\))?|IBAction\b)/;
@@ -56769,12 +56828,12 @@ var swift_distribution_lock_default;
56769
56828
  var init_swift_distribution_lock = __esm({
56770
56829
  "src/swift-distribution.lock.json"() {
56771
56830
  swift_distribution_lock_default = {
56772
- id: "e3bdd3d8fa4f9993",
56831
+ id: "ca4dfda0ca14bc49",
56773
56832
  release: "swift-6.4.0-RELEASE-custom-0d775d32d7c74eae",
56774
56833
  wasmSdkId: "swift-6.4.0-RELEASE_wasm-peach-f02bd198",
56775
56834
  wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.4.0-RELEASE_wasm-peach-f02bd198.artifactbundle.tar.gz",
56776
56835
  wasmSdkChecksum: "1e19ea768fd4e821aae34b8966c4ddcee45615c4b3cf018979b061aee2fb5504",
56777
- source: "5791eeff9ca9c054514aeb4a6599e1de8e1e4711",
56836
+ source: "33e8641403dd73a7ce0ca902007e3a36407e1f0b",
56778
56837
  targets: [
56779
56838
  "ImagePlayground",
56780
56839
  "QuickLookThumbnailing",
@@ -56819,6 +56878,7 @@ var init_swift_distribution_lock = __esm({
56819
56878
  "PeachObjCRuntime",
56820
56879
  "PeachObjC",
56821
56880
  "UIUtilities",
56881
+ "UIKitEnums",
56822
56882
  "UIKitCore",
56823
56883
  "PeachICU",
56824
56884
  "PeachCMark",
@@ -56934,33 +56994,14 @@ var init_swift_distribution_lock = __esm({
56934
56994
  "PeachBox2D"
56935
56995
  ],
56936
56996
  systemEnvironment: {
56937
- scenePhase: [
56938
- "string:active",
56939
- "string:inactive",
56940
- "string:background"
56941
- ],
56942
- deviceModel: [
56943
- "string"
56944
- ],
56945
- systemName: [
56946
- "string"
56947
- ],
56948
- systemVersion: [
56949
- "string"
56950
- ],
56951
- colorScheme: [
56952
- "string:light",
56953
- "string:dark"
56954
- ],
56955
- semanticColors: [
56956
- "object"
56957
- ],
56958
- imageAssets: [
56959
- "object"
56960
- ],
56961
- locale: [
56962
- "string"
56963
- ],
56997
+ scenePhase: ["string:active", "string:inactive", "string:background"],
56998
+ deviceModel: ["string"],
56999
+ systemName: ["string"],
57000
+ systemVersion: ["string"],
57001
+ colorScheme: ["string:light", "string:dark"],
57002
+ semanticColors: ["object"],
57003
+ imageAssets: ["object"],
57004
+ locale: ["string"],
56964
57005
  dynamicTypeSize: [
56965
57006
  "string:xSmall",
56966
57007
  "string:small",
@@ -56975,30 +57016,22 @@ var init_swift_distribution_lock = __esm({
56975
57016
  "string:accessibility4",
56976
57017
  "string:accessibility5"
56977
57018
  ],
56978
- horizontalSizeClass: [
56979
- "string:compact",
56980
- "string:regular"
56981
- ],
56982
- verticalSizeClass: [
56983
- "string:compact",
56984
- "string:regular"
56985
- ],
56986
- accessibilityReduceMotion: [
56987
- "bool"
56988
- ]
57019
+ horizontalSizeClass: ["string:compact", "string:regular"],
57020
+ verticalSizeClass: ["string:compact", "string:regular"],
57021
+ accessibilityReduceMotion: ["bool"]
56989
57022
  },
56990
57023
  hosts: {
56991
57024
  "darwin-arm64": {
56992
- sha256: "278cf5301795dd1e9f0f044bdb4e079b45ab4eb72a6e72331b06916115e34902",
56993
- size: 71532233
57025
+ sha256: "8679052c4c2b21ad748a8db40cdbc0c91ab14a29fc06bbed777efb57030c01fa",
57026
+ size: 70963039
56994
57027
  },
56995
57028
  "linux-x64": {
56996
- sha256: "920c6fe08ba45930880fee133a3cb85b310d713a4d60404f29d03555d3df879c",
56997
- size: 71538725
57029
+ sha256: "a1719d844e2f45e8c9a2ccb9dbe7857978918639a3933c225a328d84cae235cf",
57030
+ size: 70968746
56998
57031
  },
56999
57032
  "linux-arm64": {
57000
- sha256: "d3a3421e0c80cc698869bc39dd538d42b0e053db02526d3f5f22acf8e7c6dca9",
57001
- size: 71536749
57033
+ sha256: "3da8f2c920e65c633b5310c778b4a5c54b0f5f8278d58fd109f3db4310794c04",
57034
+ size: 70967077
57002
57035
  }
57003
57036
  }
57004
57037
  };
@@ -58469,9 +58502,11 @@ ${prefix}${json}${suffix}`;
58469
58502
  const identity = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
58470
58503
  return identity < 0 ? source + footer : source.slice(0, identity) + footer + source.slice(identity);
58471
58504
  }
58505
+ var ROLLDOWN_INVENTORY_HEADER;
58472
58506
  var init_bundleGlobalFooter = __esm({
58473
58507
  "src/bundleGlobalFooter.ts"() {
58474
58508
  "use strict";
58509
+ ROLLDOWN_INVENTORY_HEADER = "X-Peach-Rolldown-Inventory";
58475
58510
  }
58476
58511
  });
58477
58512
 
@@ -64640,7 +64675,7 @@ var init_runtime_assets = __esm({
64640
64675
  var runtime_companion_default;
64641
64676
  var init_runtime_companion = __esm({
64642
64677
  "runtime-companion.json"() {
64643
- runtime_companion_default = { abi: 1, sha256: "d58f0fedc3c0065faaafcf578781567b6cdac88e5c062a8354111d37fdf3c465", file: "node/cli-d58f0fedc3c0065faaafcf578781567b6cdac88e5c062a8354111d37fdf3c465.cjs" };
64678
+ runtime_companion_default = { abi: 1, sha256: "6f6a55398d832d1703346a258bf9f81bf78fded8cf5d83cdf51e5e15ccd7a1ce", file: "node/cli-6f6a55398d832d1703346a258bf9f81bf78fded8cf5d83cdf51e5e15ccd7a1ce.cjs" };
64644
64679
  }
64645
64680
  });
64646
64681
 
@@ -70950,6 +70985,10 @@ async function handleFetchProxyRequest(req, res) {
70950
70985
  if (packageVersions)
70951
70986
  res.setHeader(PACKAGE_VERSIONS_HEADER, JSON.stringify(packageVersions));
70952
70987
  }
70988
+ if (isBundleProxyRequestUrl(req.url) && req.method === "GET" && upstream.statusCode === 200 && upstreamUrl.pathname.endsWith(".bundle") && upstream.headers["x-peach-rolldown-inventory"] !== "1") {
70989
+ res.setHeader(ROLLDOWN_INVENTORY_HEADER, "1");
70990
+ res.removeHeader("content-length");
70991
+ }
70953
70992
  applyFetchProxyCors(req, res);
70954
70993
  if (setCookies.length > 0)
70955
70994
  res.setHeader("x-sootsim-set-cookie", setCookies.join(", "));
@@ -71113,6 +71152,35 @@ async function proxyUpstream(req, res, upstreamUrl, reportFailure, route) {
71113
71152
  if (redirects > 0) res.setHeader(FETCH_PROXY_RESPONSE_URL_HEADER, targetUrl.href);
71114
71153
  await route.respond(proxyRes, hopCookies);
71115
71154
  res.statusCode = status;
71155
+ if (isBundleProxyRequestUrl(req.url) && method === "GET" && status === 200 && targetUrl.pathname.endsWith(".bundle") && proxyRes.headers["x-peach-rolldown-inventory"] !== "1") {
71156
+ const contentType2 = typeof proxyRes.headers["content-type"] === "string" ? proxyRes.headers["content-type"] : "";
71157
+ const inventory = getCliRuntime().rolldown_bundle_inventory;
71158
+ res.removeHeader("content-length");
71159
+ const annotate = async function* () {
71160
+ const decoder = new TextDecoder();
71161
+ let payload = "";
71162
+ let sent = 0;
71163
+ let bundleStarted = false;
71164
+ for await (const chunk of proxyRes) {
71165
+ payload += decoder.decode(chunk, { stream: true });
71166
+ if (bundleStarted) continue;
71167
+ const releasable = inventory.releasableMultipartPrefix(payload, contentType2);
71168
+ bundleStarted = releasable.bundleStarted;
71169
+ if (releasable.length > sent) {
71170
+ yield Buffer.from(payload.slice(sent, releasable.length), "utf8");
71171
+ sent = releasable.length;
71172
+ }
71173
+ }
71174
+ payload += decoder.decode();
71175
+ const annotated = await inventory.attachRolldownBundleHttpPayload(
71176
+ payload,
71177
+ contentType2
71178
+ );
71179
+ yield Buffer.from(annotated.slice(sent), "utf8");
71180
+ };
71181
+ await (0, import_promises5.pipeline)(import_stream.Readable.from(annotate(), { objectMode: false }), res);
71182
+ return;
71183
+ }
71116
71184
  await (0, import_promises5.pipeline)(proxyRes, res);
71117
71185
  };
71118
71186
  let body;
@@ -71157,15 +71225,18 @@ async function proxyUpstream(req, res, upstreamUrl, reportFailure, route) {
71157
71225
  else req.socket.destroy();
71158
71226
  }
71159
71227
  }
71160
- var import_http2, import_https, import_node_http2, import_promises5, fetchProxyHttpAgent, fetchProxyHttpsAgent, FETCH_PROXY_CORS_HEADERS, APP_API_HEADER_REWRITES;
71228
+ var import_http2, import_https, import_node_http2, import_stream, import_promises5, fetchProxyHttpAgent, fetchProxyHttpsAgent, FETCH_PROXY_CORS_HEADERS, APP_API_HEADER_REWRITES;
71161
71229
  var init_fetch_proxy_handler = __esm({
71162
71230
  "src/host/fetch-proxy-handler.ts"() {
71163
71231
  "use strict";
71164
71232
  import_http2 = __toESM(require("http"), 1);
71165
71233
  import_https = __toESM(require("https"), 1);
71166
71234
  import_node_http2 = require("node:http2");
71235
+ import_stream = require("stream");
71167
71236
  import_promises5 = require("stream/promises");
71168
71237
  init_backend_origin();
71238
+ init_bundleGlobalFooter();
71239
+ init_cli_runtime();
71169
71240
  init_packageVersionsContract();
71170
71241
  init_dev_server_package_versions();
71171
71242
  init_fetch_proxy_overrides();
@@ -76632,9 +76703,12 @@ async function buildRnxCloudArtifact(bundle, options = {}) {
76632
76703
  if (getCliRuntime().preview_bundle_layout.isRolldownBundle(bundle)) {
76633
76704
  if (mode !== "production")
76634
76705
  throw new Error("peach Cloud One artifacts require a production bundle");
76706
+ const { attachRolldownBundleInventory, stripRolldownBundleInventoryFooter } = getCliRuntime().rolldown_bundle_inventory;
76635
76707
  const { readRolldownProductionInput } = getCliRuntime().rolldown_production_fingerprint;
76636
- code = (0, import_metro_production_bundle.detachRNXMetroSourceMapUrl)(bundle).source;
76637
- modules = (await readRolldownProductionInput(code)).modules.length;
76708
+ const raw2 = (0, import_metro_production_bundle.detachRNXMetroSourceMapUrl)(bundle).source;
76709
+ const annotated = await attachRolldownBundleInventory(raw2);
76710
+ modules = (await readRolldownProductionInput(annotated)).modules.length;
76711
+ code = stripRolldownBundleInventoryFooter(annotated);
76638
76712
  } else {
76639
76713
  const hostVersionEvidence = readHostVersionEvidence(bundle);
76640
76714
  const autolinked = detachAndroidAutolinkingFooter(bundle);
@@ -80640,6 +80714,7 @@ function heldRoots(paused, roots) {
80640
80714
  return held;
80641
80715
  }
80642
80716
  function tick2() {
80717
+ poll = void 0;
80643
80718
  const now = Date.now();
80644
80719
  const paused = pausedPids();
80645
80720
  const held = paused.length ? heldRoots(paused, new Set([...timers].map((timer) => timer.hostPid))) : /* @__PURE__ */ new Set();
@@ -80651,10 +80726,23 @@ function tick2() {
80651
80726
  timer.fire();
80652
80727
  }
80653
80728
  }
80654
- if (timers.size === 0 && poll) {
80655
- clearInterval(poll);
80729
+ schedule();
80730
+ }
80731
+ function schedule() {
80732
+ if (timers.size === 0) {
80733
+ if (poll) clearTimeout(poll);
80656
80734
  poll = void 0;
80735
+ return;
80657
80736
  }
80737
+ const now = Date.now();
80738
+ const soonest = Math.min(
80739
+ ...[...timers].map((timer) => timer.remaining - (now - timer.accountedAt))
80740
+ );
80741
+ const due = now + Math.max(0, Math.min(TICK_MS2, soonest));
80742
+ if (poll && pollDueAt <= due) return;
80743
+ if (poll) clearTimeout(poll);
80744
+ pollDueAt = due;
80745
+ poll = setTimeout(tick2, due - now);
80658
80746
  }
80659
80747
  function setPauseAwareTimeout(fn, budgetMs, hostPid) {
80660
80748
  if (hostPid === void 0) {
@@ -80663,18 +80751,13 @@ function setPauseAwareTimeout(fn, budgetMs, hostPid) {
80663
80751
  }
80664
80752
  const timer = { hostPid, remaining: budgetMs, accountedAt: Date.now(), fire: fn };
80665
80753
  timers.add(timer);
80666
- if (!poll) {
80667
- poll = setInterval(tick2, TICK_MS2);
80668
- }
80754
+ schedule();
80669
80755
  return () => {
80670
80756
  timers.delete(timer);
80671
- if (timers.size === 0 && poll) {
80672
- clearInterval(poll);
80673
- poll = void 0;
80674
- }
80757
+ schedule();
80675
80758
  };
80676
80759
  }
80677
- var import_node_child_process21, import_node_fs49, import_node_os10, import_node_path46, LEDGER_PATH2, TICK_MS2, timers, poll;
80760
+ var import_node_child_process21, import_node_fs49, import_node_os10, import_node_path46, LEDGER_PATH2, TICK_MS2, timers, poll, pollDueAt;
80678
80761
  var init_pause_aware_timeout = __esm({
80679
80762
  "cli/pause-aware-timeout.ts"() {
80680
80763
  "use strict";
@@ -80688,6 +80771,7 @@ var init_pause_aware_timeout = __esm({
80688
80771
  );
80689
80772
  TICK_MS2 = 500;
80690
80773
  timers = /* @__PURE__ */ new Set();
80774
+ pollDueAt = 0;
80691
80775
  }
80692
80776
  });
80693
80777
 
@@ -80881,6 +80965,17 @@ function describeSimIdSource(source) {
80881
80965
  function disconnectedSavedSimMessage(simId, detail = "") {
80882
80966
  return `saved sim ${simId} is not connected${detail}; commands resume when it reconnects, or run \`peach list\` and \`peach use <sim>\`, or open a fresh sim`;
80883
80967
  }
80968
+ function parseTimeoutMs(value) {
80969
+ const match = /^(\d+(?:\.\d+)?)(ms|s|m)?$/.exec(value.trim());
80970
+ const ms = match ? Number(match[1]) * TIMEOUT_UNIT_MS[match[2] ?? "ms"] : NaN;
80971
+ if (!(ms > 0)) {
80972
+ console.error(
80973
+ `--timeout takes a positive duration in milliseconds (or with an ms, s or m suffix), got "${value}"`
80974
+ );
80975
+ peachExit(2);
80976
+ }
80977
+ return ms;
80978
+ }
80884
80979
  function parseBridgeCliArgs(args, opts = {}) {
80885
80980
  const flagIndices = /* @__PURE__ */ new Set();
80886
80981
  const state = {
@@ -81391,7 +81486,7 @@ async function callInBridge(bridge, path56, ...args) {
81391
81486
  async function callInBridgeWrite(bridge, path56, ...args) {
81392
81487
  return bridge.send({ type: "call", path: path56, args, acquireLock: true });
81393
81488
  }
81394
- var import_node_fs50, import_node_path47, import_ws3, PEACH_PLACEMENT_ENV, resolvedWorld, BridgeSimLockedError, DisconnectedSimError, BRIDGE_VALUE_FLAGS_TABLE, BRIDGE_VALUE_FLAGS;
81489
+ var import_node_fs50, import_node_path47, import_ws3, PEACH_PLACEMENT_ENV, resolvedWorld, BridgeSimLockedError, DisconnectedSimError, TIMEOUT_UNIT_MS, BRIDGE_VALUE_FLAGS_TABLE, BRIDGE_VALUE_FLAGS;
81395
81490
  var init_ws_bridge = __esm({
81396
81491
  "cli/ws-bridge.ts"() {
81397
81492
  "use strict";
@@ -81405,6 +81500,7 @@ var init_ws_bridge = __esm({
81405
81500
  init_cloud_client();
81406
81501
  init_current_sim();
81407
81502
  init_pause_aware_timeout();
81503
+ init_run_rnx();
81408
81504
  PEACH_PLACEMENT_ENV = "PEACH_PLACEMENT";
81409
81505
  resolvedWorld = null;
81410
81506
  BridgeSimLockedError = class extends Error {
@@ -81417,6 +81513,7 @@ var init_ws_bridge = __esm({
81417
81513
  };
81418
81514
  DisconnectedSimError = class extends Error {
81419
81515
  };
81516
+ TIMEOUT_UNIT_MS = { ms: 1, s: 1e3, m: 6e4 };
81420
81517
  BRIDGE_VALUE_FLAGS_TABLE = [
81421
81518
  {
81422
81519
  names: ["--port", "-p"],
@@ -81431,7 +81528,7 @@ var init_ws_bridge = __esm({
81431
81528
  names: ["--timeout"],
81432
81529
  apply: (state, value) => {
81433
81530
  if (value !== void 0) {
81434
- state.commandTimeoutMs = Number(value);
81531
+ state.commandTimeoutMs = parseTimeoutMs(value);
81435
81532
  state.explicitTimeout = true;
81436
81533
  }
81437
81534
  }
@@ -82634,6 +82731,12 @@ function installedPackageDir(appDir, name3) {
82634
82731
  current = parent;
82635
82732
  }
82636
82733
  }
82734
+ function isAndroidCheck(node) {
82735
+ if (node.type !== "BinaryExpression" || !["===", "=="].includes(node.operator))
82736
+ return false;
82737
+ const side = (value, literal3) => value.type === "MemberExpression" && !value.computed && nativeLookupName(value.object) === "Platform" && nativeLookupName(value) === "OS" && literal3.type === "Literal" && literal3.value === "android";
82738
+ return side(node.left, node.right) || side(node.right, node.left);
82739
+ }
82637
82740
  function nativeLookupName(node) {
82638
82741
  if (node.type === "Identifier") return node.name;
82639
82742
  if (node.type === "MemberExpression" && !node.computed && node.property.type === "Identifier")
@@ -82642,6 +82745,7 @@ function nativeLookupName(node) {
82642
82745
  }
82643
82746
  function sourceNativeRequests(file, text5, includeLegacy = false) {
82644
82747
  if (!NATIVE_LOOKUP.test(text5)) return [];
82748
+ const androidFile = /\.android\.[cm]?[jt]sx?$/.test(file);
82645
82749
  let code;
82646
82750
  try {
82647
82751
  code = (0, import_sucrase2.transform)(text5, {
@@ -82654,36 +82758,63 @@ function sourceNativeRequests(file, text5, includeLegacy = false) {
82654
82758
  const { program, errors } = (0, import_oxc_parser2.parseSync)(file, code, { lang: "jsx" });
82655
82759
  if (errors.length) return [];
82656
82760
  const found = [];
82657
- const add = (kind, name3, at) => {
82658
- found.push({ kind, name: name3, line: code.slice(0, at).split("\n").length });
82761
+ const androidRanges = [];
82762
+ const guard = (test, branch) => {
82763
+ if (isAndroidCheck(test)) androidRanges.push([branch.start, branch.end]);
82764
+ };
82765
+ const add = (kind, name3, at, optional) => {
82766
+ found.push({
82767
+ kind,
82768
+ name: name3,
82769
+ optional,
82770
+ androidOnly: androidFile || androidRanges.some(([start, end]) => at >= start && at < end),
82771
+ line: code.slice(0, at).split("\n").length
82772
+ });
82659
82773
  };
82660
82774
  visitParsedProgram(program, {
82775
+ IfStatement(node) {
82776
+ guard(node.test, node.consequent);
82777
+ },
82778
+ ConditionalExpression(node) {
82779
+ guard(node.test, node.consequent);
82780
+ },
82781
+ LogicalExpression(node) {
82782
+ if (node.operator === "&&") guard(node.left, node.right);
82783
+ },
82661
82784
  CallExpression(node) {
82662
82785
  const first = node.arguments[0];
82663
82786
  if (first?.type !== "Literal" || typeof first.value !== "string") return;
82664
82787
  const callee = node.callee;
82665
82788
  const lookup = nativeLookupName(callee);
82666
82789
  if (callee.type === "MemberExpression" && !callee.computed && nativeLookupName(callee.object) === "TurboModuleRegistry" && (lookup === "get" || lookup === "getEnforcing")) {
82667
- add("module", first.value, node.start);
82790
+ add("module", first.value, node.start, false);
82668
82791
  } else if (lookup) {
82669
82792
  if (["requireNativeModule", "requireOptionalNativeModule"].includes(lookup))
82670
- add("module", first.value, node.start);
82793
+ add("module", first.value, node.start, lookup === "requireOptionalNativeModule");
82671
82794
  else if (["requireNativeComponent", "codegenNativeComponent"].includes(lookup))
82672
- add("view", first.value, node.start);
82795
+ add("view", first.value, node.start, false);
82673
82796
  else if (["requireNativeView", "requireNativeViewManager"].includes(lookup)) {
82674
82797
  const second = node.arguments[1];
82675
82798
  const name3 = second?.type === "Literal" && typeof second.value === "string" ? `${first.value}_${second.value}` : first.value;
82676
- add("view", name3, node.start);
82799
+ add("view", name3, node.start, false);
82677
82800
  }
82678
82801
  }
82679
82802
  },
82680
82803
  MemberExpression(node) {
82681
82804
  if (includeLegacy && !node.computed && nativeLookupName(node.object) === "NativeModules" && node.property.type === "Identifier")
82682
- add("module", node.property.name, node.start);
82805
+ add("module", node.property.name, node.start, false);
82683
82806
  }
82684
82807
  });
82685
82808
  return found;
82686
82809
  }
82810
+ function mergeRequests(previous, next) {
82811
+ if (!previous) return next;
82812
+ return {
82813
+ ...next,
82814
+ optional: previous.optional && next.optional,
82815
+ androidOnly: previous.androidOnly && next.androidOnly
82816
+ };
82817
+ }
82687
82818
  function packageNativeRequests(dir) {
82688
82819
  const found = /* @__PURE__ */ new Map();
82689
82820
  const directories = scanRepository(dir).directories.filter((sub) => {
@@ -82698,8 +82829,11 @@ function packageNativeRequests(dir) {
82698
82829
  const file = (0, import_node_path53.join)(sub, name3);
82699
82830
  const text5 = readSmallFile(file);
82700
82831
  if (!text5) continue;
82701
- for (const { kind, name: name4 } of sourceNativeRequests(file, text5, true))
82702
- found.set(`${kind}:${name4}`, { kind, name: name4 });
82832
+ for (const { line: _line, ...request } of sourceNativeRequests(file, text5, true))
82833
+ found.set(
82834
+ `${request.kind}:${request.name}`,
82835
+ mergeRequests(found.get(`${request.kind}:${request.name}`), request)
82836
+ );
82703
82837
  }
82704
82838
  }
82705
82839
  return [...found.values()].sort(
@@ -82878,9 +83012,13 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
82878
83012
  return result;
82879
83013
  };
82880
83014
  const found = /* @__PURE__ */ new Map();
82881
- const add = (kind, name3, file, line) => {
83015
+ const add = (kind, name3, file, line, optional = false) => {
82882
83016
  const key2 = `${kind}:${name3}`;
82883
- if (found.has(key2)) return;
83017
+ const known = found.get(key2);
83018
+ if (known) {
83019
+ known.optional &&= optional;
83020
+ return;
83021
+ }
82884
83022
  providers ??= dependencyNativeOwners(appDir, pkg);
82885
83023
  const packageName = providers.get(key2) ?? owner((0, import_node_path53.dirname)(file));
82886
83024
  if (knownPackages.has(packageName)) return;
@@ -82891,6 +83029,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
82891
83029
  package: packageName,
82892
83030
  path: `${(0, import_node_path53.relative)(appDir, file)}:${line}`,
82893
83031
  expoModule: moduleDir ? (0, import_node_path53.relative)(appDir, moduleDir) || "." : null,
83032
+ optional,
82894
83033
  swift: moduleDir ? (nativeFilesByModule.get(moduleDir) ?? []).some(
82895
83034
  (path56) => path56.endsWith(".swift") && [...(readSmallFile(path56) ?? "").matchAll(/\bName\(\s*"(\w+)"\s*\)/g)].some(
82896
83035
  (match) => match[1] === name3
@@ -82902,8 +83041,14 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
82902
83041
  for (const file of sourceFiles2) {
82903
83042
  const text5 = readSmallFile(file);
82904
83043
  if (!text5) continue;
82905
- for (const { kind, name: name3, line } of sourceNativeRequests(file, text5, includeLegacy))
82906
- add(kind, name3, file, line);
83044
+ for (const { kind, name: name3, line, optional, androidOnly } of sourceNativeRequests(
83045
+ file,
83046
+ text5,
83047
+ includeLegacy
83048
+ )) {
83049
+ if (androidOnly && platform === "ios") continue;
83050
+ add(kind, name3, file, line, optional);
83051
+ }
82907
83052
  }
82908
83053
  for (const [, files2] of nativeFilesByModule) {
82909
83054
  const swiftFirst = [...files2].sort(
@@ -84013,7 +84158,7 @@ function waitReadyReason(status) {
84013
84158
  return `sim unreachable: ${status.bridgeError} \u2014 the target tab is closed or no sim is connected (check \`peach list\`, reopen with \`peach open\`)`;
84014
84159
  }
84015
84160
  const waitingOnGuestFetch = status.externalReady === false && /https?:\/\//.test(status.externalStatus);
84016
- const base = status.externalError ? `guest app errored: ${status.externalError}` : waitingOnGuestFetch ? `waiting on a guest fetch: ${status.externalStatus}` : status.loadingText ? `still showing "${status.loadingText}"` : status.externalReady === false ? "guest app is still loading" : status.flag !== true && status.targets > 0 ? "native content is rendered but the ready signal has not settled" : status.flag !== true ? "guest app has not emitted sootsim:externalAppReady" : status.targets <= 0 ? "ready flag emitted but no visible app content is inspectable yet" : "node tree is still changing";
84161
+ const base = status.externalError ? `guest app errored: ${status.externalError}` : waitingOnGuestFetch ? `waiting on a guest fetch: ${status.externalStatus}` : status.loadingText ? `still showing "${status.loadingText}"` : status.externalReady === false ? "guest app is still loading" : status.flag !== true && status.targets > 0 ? "native content is rendered but the ready signal has not settled" : status.flag !== true ? "guest app has not emitted sootsim:externalAppReady" : status.targets <= 0 && !status.paintedAppContent ? "ready flag emitted but no visible app content is inspectable yet" : "node tree is still changing";
84017
84162
  return !status.externalError && status.suppressedEntryError ? `${base} (suppressed entry error: ${status.suppressedEntryError})` : base;
84018
84163
  }
84019
84164
  async function inspectWaitReady(bridge, timeoutMs = 2e4, options = {}) {
@@ -84308,16 +84453,121 @@ var init_shared = __esm({
84308
84453
  }
84309
84454
  });
84310
84455
 
84456
+ // cli/output-redaction.ts
84457
+ function mask(value) {
84458
+ if (MASKED.test(value)) return value;
84459
+ return `<redacted:${(0, import_node_crypto31.createHash)("sha256").update(value).digest("hex").slice(0, 4)}>`;
84460
+ }
84461
+ function maskQuoted(quoted) {
84462
+ return `${quoted[0]}${mask(quoted.slice(1, -1))}${quoted[0]}`;
84463
+ }
84464
+ function redactString(quoted, configurationOnly) {
84465
+ if (quoted.startsWith("'")) {
84466
+ const inner = quoted.slice(1, -1);
84467
+ const redacted2 = redactText(inner, configurationOnly);
84468
+ return redacted2 === inner ? quoted : `'${redacted2}'`;
84469
+ }
84470
+ let decoded;
84471
+ try {
84472
+ decoded = JSON.parse(quoted);
84473
+ } catch {
84474
+ decoded = quoted.slice(1, -1).replace(/\\(["\\/])/g, "$1");
84475
+ }
84476
+ const redacted = redactText(decoded, configurationOnly);
84477
+ return redacted === decoded ? quoted : JSON.stringify(redacted);
84478
+ }
84479
+ function decodeStrict(value) {
84480
+ try {
84481
+ return decodeURIComponent(value);
84482
+ } catch {
84483
+ return void 0;
84484
+ }
84485
+ }
84486
+ function redactPair(pair, prefix, quotedName, bareName, value, configurationOnly) {
84487
+ const name3 = quotedName ?? bareName;
84488
+ if (name3 === PEACH_CONFIG_QUERY_PARAM) return `${prefix}"[redacted]"`;
84489
+ if (configurationOnly || !SECRET_NAME.test(name3)) {
84490
+ if (!/^["'[]/.test(value)) return pair;
84491
+ const inner = value.startsWith("[") ? value.replace(STRING_TOKEN, (quoted) => redactString(quoted, configurationOnly)) : redactString(value, configurationOnly);
84492
+ return inner === value ? pair : `${prefix}${inner}`;
84493
+ }
84494
+ if (value.startsWith("[")) return `${prefix}${value.replace(STRING_TOKEN, maskQuoted)}`;
84495
+ return `${prefix}${/^["']/.test(value) ? maskQuoted(value) : `"${mask(value)}"`}`;
84496
+ }
84497
+ function redactConfigurationForDiagnostics(text5) {
84498
+ return redactText(text5, true);
84499
+ }
84500
+ function redactForSharing(text5) {
84501
+ return redactText(text5, false);
84502
+ }
84503
+ function redactEncoded(value, configurationOnly) {
84504
+ const decoded = decodeStrict(value);
84505
+ if (decoded === void 0) return mask(value);
84506
+ if (decoded === value) return value;
84507
+ const redacted = /%[0-9a-f]{2}/i.test(decoded) && !/["{}&=]/.test(decoded) ? redactEncoded(decoded, configurationOnly) : redactText(decoded, configurationOnly);
84508
+ return redacted === decoded ? value : encodeURIComponent(redacted);
84509
+ }
84510
+ function redactText(text5, configurationOnly) {
84511
+ if (!configurationOnly) {
84512
+ text5 = text5.replace(JWT, mask).replace(GOOGLE_API_KEY, mask).replace(BEARER, (match, scheme) => `${scheme} ${mask(match)}`);
84513
+ }
84514
+ const redacted = text5.replace(
84515
+ PAIR2,
84516
+ (pair, prefix, quotedName, bareName, value) => redactPair(pair, prefix, quotedName, bareName, value, configurationOnly)
84517
+ ).replace(QUERY_PAIR, (pair, prefix, name3, value) => {
84518
+ const decodedName = decodeStrict(name3);
84519
+ if (decodedName === void 0) return `${prefix}${mask(value)}`;
84520
+ if (decodedName === PEACH_CONFIG_QUERY_PARAM) return `${prefix}%5Bredacted%5D`;
84521
+ if (!configurationOnly && SECRET_NAME.test(decodedName))
84522
+ return `${prefix}${mask(value)}`;
84523
+ if (!/%[0-9a-f]{2}/i.test(value)) return pair;
84524
+ const redacted2 = redactEncoded(value, configurationOnly);
84525
+ return redacted2 === value ? pair : `${prefix}${redacted2}`;
84526
+ });
84527
+ if (configurationOnly) return redacted;
84528
+ return redacted.replace(
84529
+ HEADER_LINE,
84530
+ (line, prefix, name3, value) => SECRET_NAME.test(name3) ? `${prefix}${mask(value)}` : line
84531
+ ).replace(EMAIL, mask).replace(OPAQUE_ID, mask);
84532
+ }
84533
+ var import_node_crypto31, SECRET_NAME, JWT, GOOGLE_API_KEY, BEARER, EMAIL, OPAQUE_ID, STRING, NUMBER, PAIR2, STRING_TOKEN, QUERY_PAIR, HEADER_LINE, MASKED, utf8;
84534
+ var init_output_redaction = __esm({
84535
+ "cli/output-redaction.ts"() {
84536
+ "use strict";
84537
+ import_node_crypto31 = require("node:crypto");
84538
+ init_config();
84539
+ SECRET_NAME = /^(?:[\w-]*(?:api[-_]?key|token|secret|password|passwd|authorization|cookie|signature|credential)s?|auth|sig|email|uid|[\w-]*(?:user|account|local|device|installation|client|app|project|sender|measurement|tenant)[-_]?id)$/i;
84540
+ JWT = /\beyJ[\w-]{6,}\.[\w-]{6,}\.[\w-]{6,}/g;
84541
+ GOOGLE_API_KEY = /\bAIza[\w-]{30,}/g;
84542
+ BEARER = /\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi;
84543
+ EMAIL = /\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/g;
84544
+ OPAQUE_ID = /\b(?=[A-Za-z0-9]*[A-Z])(?=[A-Za-z0-9]*[a-z])(?=[A-Za-z0-9]*\d)[A-Za-z0-9]{20,}\b/g;
84545
+ STRING = String.raw`(?:"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*')`;
84546
+ NUMBER = String.raw`-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?`;
84547
+ PAIR2 = new RegExp(
84548
+ String.raw`((?:"([\w-]+)"|\b([\w-]+))\s*:\s*)(${STRING}|${NUMBER}\b|\[\s*${STRING}(?:\s*,\s*${STRING})*\s*\])`,
84549
+ "g"
84550
+ );
84551
+ STRING_TOKEN = new RegExp(STRING, "g");
84552
+ QUERY_PAIR = /([?&;]([\w.%-]+)=)([^&#\s"'\\]+)/g;
84553
+ HEADER_LINE = /^(\s*([\w-]+)\s*:\s+)(\S.*)$/gm;
84554
+ MASKED = /^<redacted:[0-9a-f]{4}>$/;
84555
+ utf8 = new TextDecoder("utf-8", { fatal: true });
84556
+ }
84557
+ });
84558
+
84311
84559
  // cli/bridge-diagnostics.ts
84312
84560
  function formatRequestMessage(entry) {
84313
84561
  const target = entry.displayUrl || entry.url;
84314
84562
  if (entry.status != null) {
84315
- return `${entry.method} ${target} -> ${entry.status}${entry.statusText ? ` ${entry.statusText}` : ""}`;
84563
+ return redactConfigurationForDiagnostics(
84564
+ `${entry.method} ${target} -> ${entry.status}${entry.statusText ? ` ${entry.statusText}` : ""}`
84565
+ );
84316
84566
  }
84317
84567
  if (entry.error) {
84318
- return `${entry.method} ${target} -> ${entry.error}`;
84568
+ return redactConfigurationForDiagnostics(`${entry.method} ${target} -> ${entry.error}`);
84319
84569
  }
84320
- return `${entry.method} ${target}`;
84570
+ return redactConfigurationForDiagnostics(`${entry.method} ${target}`);
84321
84571
  }
84322
84572
  async function callTestBridge(bridge, method, ...args) {
84323
84573
  return bridge.send({
@@ -84355,7 +84605,7 @@ async function printBridgeConsoleSummary(bridge, opts = {}) {
84355
84605
  const msg = Array.isArray(entry.args) ? entry.args.map(
84356
84606
  (value) => typeof value === "object" ? JSON.stringify(value) : String(value)
84357
84607
  ).join(" ") : String(entry);
84358
- console.log(` [${time}] ${msg}`);
84608
+ console.log(` [${time}] ${redactConfigurationForDiagnostics(msg)}`);
84359
84609
  }
84360
84610
  }
84361
84611
  async function printBridgeRequestSummary(bridge, opts = {}) {
@@ -84381,9 +84631,9 @@ async function printBridgeRequestSummary(bridge, opts = {}) {
84381
84631
  const time = formatLogTimestamp(entry.timestamp);
84382
84632
  console.log(` [${time}] ${formatRequestMessage(entry)}`);
84383
84633
  if (entry.responseBody) {
84384
- console.log(` ${entry.responseBody}`);
84634
+ console.log(` ${redactConfigurationForDiagnostics(entry.responseBody)}`);
84385
84635
  } else if (entry.error) {
84386
- console.log(` ${entry.error}`);
84636
+ console.log(` ${redactConfigurationForDiagnostics(entry.error)}`);
84387
84637
  }
84388
84638
  }
84389
84639
  }
@@ -84420,7 +84670,7 @@ async function printBridgeStateSummary(bridge) {
84420
84670
  if (!state || typeof state !== "object") return;
84421
84671
  console.log("\n state:");
84422
84672
  if (state.simId) console.log(` sim: ${state.simId}`);
84423
- if (state.url) console.log(` url: ${state.url}`);
84673
+ if (state.url) console.log(` url: ${redactConfigurationForDiagnostics(state.url)}`);
84424
84674
  if (state.mode) console.log(` mode: ${state.mode}`);
84425
84675
  const nodeCount = Number(state.nodeCount) || 0;
84426
84676
  console.log(` nodes: ${nodeCount}${nodeCount > 10 ? " (ready)" : " (not ready)"}`);
@@ -84467,6 +84717,7 @@ var init_bridge_diagnostics = __esm({
84467
84717
  "use strict";
84468
84718
  init_core();
84469
84719
  init_shared();
84720
+ init_output_redaction();
84470
84721
  }
84471
84722
  });
84472
84723
 
@@ -84680,7 +84931,7 @@ function macDesktopLaunchHome(bridgePort) {
84680
84931
  const dev = readDevBridgeLockfiles().find(
84681
84932
  (lock) => lock.bridgePort === bridgePort && isDevBridgeLockfileFresh(lock)
84682
84933
  );
84683
- const homeKey = (0, import_node_crypto31.createHash)("sha256").update(home).digest("hex");
84934
+ const homeKey = (0, import_node_crypto32.createHash)("sha256").update(home).digest("hex");
84684
84935
  const dir = (0, import_path7.join)((0, import_os3.tmpdir)(), "peach-desktop-launch", homeKey, String(bridgePort));
84685
84936
  (0, import_fs8.mkdirSync)(dir, { recursive: true });
84686
84937
  if ((0, import_fs8.existsSync)(home)) {
@@ -84783,13 +85034,13 @@ function buildMacLaunchUrl(url, opts, nativeApp = false) {
84783
85034
  }
84784
85035
  return deepLink.toString();
84785
85036
  }
84786
- var import_child_process5, import_fs8, import_node_crypto31, import_os3, import_path7, import_url2, import_meta2, _sootsimRoot;
85037
+ var import_child_process5, import_fs8, import_node_crypto32, import_os3, import_path7, import_url2, import_meta2, _sootsimRoot;
84787
85038
  var init_desktop_companion = __esm({
84788
85039
  "cli/desktop-companion.ts"() {
84789
85040
  "use strict";
84790
85041
  import_child_process5 = require("child_process");
84791
85042
  import_fs8 = require("fs");
84792
- import_node_crypto31 = require("node:crypto");
85043
+ import_node_crypto32 = require("node:crypto");
84793
85044
  import_os3 = require("os");
84794
85045
  import_path7 = require("path");
84795
85046
  import_url2 = require("url");
@@ -86582,102 +86833,6 @@ var init_open_url2 = __esm({
86582
86833
  }
86583
86834
  });
86584
86835
 
86585
- // cli/output-redaction.ts
86586
- function mask(value) {
86587
- if (MASKED.test(value)) return value;
86588
- return `<redacted:${(0, import_node_crypto32.createHash)("sha256").update(value).digest("hex").slice(0, 4)}>`;
86589
- }
86590
- function maskQuoted(quoted) {
86591
- return `${quoted[0]}${mask(quoted.slice(1, -1))}${quoted[0]}`;
86592
- }
86593
- function redactString(quoted, configurationOnly) {
86594
- if (quoted.startsWith("'")) {
86595
- const inner = quoted.slice(1, -1);
86596
- const redacted2 = redactText(inner, configurationOnly);
86597
- return redacted2 === inner ? quoted : `'${redacted2}'`;
86598
- }
86599
- let decoded;
86600
- try {
86601
- decoded = JSON.parse(quoted);
86602
- } catch {
86603
- decoded = quoted.slice(1, -1).replace(/\\(["\\/])/g, "$1");
86604
- }
86605
- const redacted = redactText(decoded, configurationOnly);
86606
- return redacted === decoded ? quoted : JSON.stringify(redacted);
86607
- }
86608
- function decodeOrSelf(value) {
86609
- try {
86610
- return decodeURIComponent(value);
86611
- } catch {
86612
- return value;
86613
- }
86614
- }
86615
- function redactPair(pair, prefix, quotedName, bareName, value, configurationOnly) {
86616
- const name3 = quotedName ?? bareName;
86617
- if (name3 === PEACH_CONFIG_QUERY_PARAM) return `${prefix}"[redacted]"`;
86618
- if (configurationOnly || !SECRET_NAME.test(name3)) {
86619
- if (!/^["'[]/.test(value)) return pair;
86620
- const inner = value.startsWith("[") ? value.replace(STRING_TOKEN, (quoted) => redactString(quoted, configurationOnly)) : redactString(value, configurationOnly);
86621
- return inner === value ? pair : `${prefix}${inner}`;
86622
- }
86623
- if (value.startsWith("[")) return `${prefix}${value.replace(STRING_TOKEN, maskQuoted)}`;
86624
- return `${prefix}${/^["']/.test(value) ? maskQuoted(value) : `"${mask(value)}"`}`;
86625
- }
86626
- function redactConfigurationForDiagnostics(text5) {
86627
- return redactText(text5, true);
86628
- }
86629
- function redactForSharing(text5) {
86630
- return redactText(text5, false);
86631
- }
86632
- function redactText(text5, configurationOnly) {
86633
- if (!configurationOnly) {
86634
- text5 = text5.replace(JWT, mask).replace(GOOGLE_API_KEY, mask).replace(BEARER, (match, scheme) => `${scheme} ${mask(match)}`);
86635
- }
86636
- const redacted = text5.replace(
86637
- PAIR2,
86638
- (pair, prefix, quotedName, bareName, value) => redactPair(pair, prefix, quotedName, bareName, value, configurationOnly)
86639
- ).replace(QUERY_PAIR, (pair, prefix, name3, value) => {
86640
- const decodedName = decodeOrSelf(name3);
86641
- if (decodedName === PEACH_CONFIG_QUERY_PARAM) return `${prefix}%5Bredacted%5D`;
86642
- if (!configurationOnly && SECRET_NAME.test(decodedName))
86643
- return `${prefix}${mask(value)}`;
86644
- if (!/%[0-9a-f]{2}/i.test(value)) return pair;
86645
- const decoded = decodeOrSelf(value);
86646
- const redacted2 = redactText(decoded, configurationOnly);
86647
- return redacted2 === decoded ? pair : `${prefix}${encodeURIComponent(redacted2)}`;
86648
- });
86649
- if (configurationOnly) return redacted;
86650
- return redacted.replace(
86651
- HEADER_LINE,
86652
- (line, prefix, name3, value) => SECRET_NAME.test(name3) ? `${prefix}${mask(value)}` : line
86653
- ).replace(EMAIL, mask).replace(OPAQUE_ID, mask);
86654
- }
86655
- var import_node_crypto32, SECRET_NAME, JWT, GOOGLE_API_KEY, BEARER, EMAIL, OPAQUE_ID, STRING, NUMBER, PAIR2, STRING_TOKEN, QUERY_PAIR, HEADER_LINE, MASKED, utf8;
86656
- var init_output_redaction = __esm({
86657
- "cli/output-redaction.ts"() {
86658
- "use strict";
86659
- import_node_crypto32 = require("node:crypto");
86660
- init_config();
86661
- SECRET_NAME = /^(?:[\w-]*(?:api[-_]?key|token|secret|password|passwd|authorization|cookie|signature|credential)s?|auth|sig|email|uid|[\w-]*(?:user|account|local|device|installation|client|app|project|sender|measurement|tenant)[-_]?id)$/i;
86662
- JWT = /\beyJ[\w-]{6,}\.[\w-]{6,}\.[\w-]{6,}/g;
86663
- GOOGLE_API_KEY = /\bAIza[\w-]{30,}/g;
86664
- BEARER = /\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi;
86665
- EMAIL = /\b[\w.+-]+@[\w-]+(?:\.[\w-]+)+\b/g;
86666
- OPAQUE_ID = /\b(?=[A-Za-z0-9]*[A-Z])(?=[A-Za-z0-9]*[a-z])(?=[A-Za-z0-9]*\d)[A-Za-z0-9]{20,}\b/g;
86667
- STRING = String.raw`(?:"(?:[^"\\\n]|\\.)*"|'(?:[^'\\\n]|\\.)*')`;
86668
- NUMBER = String.raw`-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?`;
86669
- PAIR2 = new RegExp(
86670
- String.raw`((?:"([\w-]+)"|\b([\w-]+))\s*:\s*)(${STRING}|${NUMBER}\b|\[\s*${STRING}(?:\s*,\s*${STRING})*\s*\])`,
86671
- "g"
86672
- );
86673
- STRING_TOKEN = new RegExp(STRING, "g");
86674
- QUERY_PAIR = /([?&;]([\w.%-]+)=)([^&#\s"'\\]+)/g;
86675
- HEADER_LINE = /^(\s*([\w-]+)\s*:\s+)(\S.*)$/gm;
86676
- MASKED = /^<redacted:[0-9a-f]{4}>$/;
86677
- utf8 = new TextDecoder("utf-8", { fatal: true });
86678
- }
86679
- });
86680
-
86681
86836
  // cli/command-registry.ts
86682
86837
  var NODE_COMMAND_NAMES, BROWSER_FAMILIES, registrations, RNX_COMMAND_NAMES, RNX_NODE_COMMAND_NAMES;
86683
86838
  var init_command_registry = __esm({