peachsim 0.1.1469 → 0.1.1477

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/cli/drivers/playwright-sim-host.ts +7 -2
  2. package/cli/drivers/playwright.ts +6 -6
  3. package/dist-lib/agent-daemon-client.cjs +1 -1
  4. package/dist-lib/agent-events.cjs +1 -1
  5. package/dist-lib/attached-projects.cjs +1 -1
  6. package/dist-lib/auth/shared-session.cjs +1 -1
  7. package/dist-lib/backend-origin.cjs +1 -1
  8. package/dist-lib/beta.cjs +1 -1
  9. package/dist-lib/beta.mjs +1 -1
  10. package/dist-lib/bridge-constants.cjs +1 -1
  11. package/dist-lib/bridge-contract-input.cjs +1 -1
  12. package/dist-lib/bridge-contract-input.mjs +1 -1
  13. package/dist-lib/bridge-contract.cjs +1 -1
  14. package/dist-lib/bridge-contract.mjs +1 -1
  15. package/dist-lib/bundle-channel.cjs +13 -2
  16. package/dist-lib/capture-contract.cjs +1 -1
  17. package/dist-lib/capture-contract.mjs +1 -1
  18. package/dist-lib/cloud-contract.cjs +1 -1
  19. package/dist-lib/cloud-contract.mjs +1 -1
  20. package/dist-lib/cloud-test-args.cjs +1 -1
  21. package/dist-lib/cloud-test-args.mjs +1 -1
  22. package/dist-lib/cloud.cjs +1 -1
  23. package/dist-lib/cloud.mjs +1 -1
  24. package/dist-lib/config.cjs +1 -1
  25. package/dist-lib/config.mjs +1 -1
  26. package/dist-lib/detox/index.cjs +46 -40
  27. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  28. package/dist-lib/expo-swift-bundle.cjs +7 -2
  29. package/dist-lib/expo-swift-metadata.cjs +1 -1
  30. package/dist-lib/expo-swift-metadata.mjs +1 -1
  31. package/dist-lib/home-paths.cjs +1 -1
  32. package/dist-lib/host/bridge-host.cjs +134 -37
  33. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  34. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  35. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  36. package/dist-lib/host/replacement-module-handler.cjs +1 -1
  37. package/dist-lib/host/websocket-proxy.cjs +1 -1
  38. package/dist-lib/index.cjs +1 -1
  39. package/dist-lib/jump-to-source-babel.cjs +1 -1
  40. package/dist-lib/jump-to-source-native.cjs +1 -1
  41. package/dist-lib/kotlin-host.cjs +1 -1
  42. package/dist-lib/menu.cjs +1 -1
  43. package/dist-lib/menu.mjs +1 -1
  44. package/dist-lib/metro-fingerprint-registry.cjs +1 -1
  45. package/dist-lib/metro-fingerprint-registry.mjs +1 -1
  46. package/dist-lib/metro-production-bundle.cjs +1 -1
  47. package/dist-lib/metro-production-bundle.mjs +1 -1
  48. package/dist-lib/metro.cjs +1 -1
  49. package/dist-lib/native-app-identity-project.cjs +1 -1
  50. package/dist-lib/native-app-identity-project.mjs +1 -1
  51. package/dist-lib/native-app-identity.cjs +1 -1
  52. package/dist-lib/native-app-identity.mjs +1 -1
  53. package/dist-lib/native-firebase-metadata.cjs +1 -1
  54. package/dist-lib/native-firebase-metadata.mjs +1 -1
  55. package/dist-lib/plist.cjs +1 -1
  56. package/dist-lib/plist.mjs +1 -1
  57. package/dist-lib/profiles.cjs +1 -1
  58. package/dist-lib/public-brand.cjs +1 -1
  59. package/dist-lib/react-native-host-modules.cjs +1 -1
  60. package/dist-lib/react-native-host-modules.mjs +1 -1
  61. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  62. package/dist-lib/sdk.cjs +1 -1
  63. package/dist-lib/sdk.mjs +1 -1
  64. package/dist-lib/skills.cjs +141 -93
  65. package/dist-lib/swift-compile.cjs +7 -2
  66. package/dist-lib/swift-compile.mjs +7 -2
  67. package/dist-lib/swift-package.cjs +1 -1
  68. package/dist-lib/swift-package.mjs +1 -1
  69. package/dist-lib/swift-submit.cjs +1 -1
  70. package/dist-lib/swift-submit.mjs +1 -1
  71. package/dist-lib/swift-toolchain.cjs +1 -1
  72. package/dist-lib/swift.cjs +1 -1
  73. package/dist-lib/vite-swift.cjs +7 -2
  74. package/dist-lib/vite.cjs +1 -1
  75. package/dist-lib/worklet-executable.cjs +1 -1
  76. package/dist-lib/worklet-executable.mjs +1 -1
  77. package/package.json +1 -1
  78. package/src/admitted-mac-build.ts +12 -0
  79. package/src/bridge-constants.ts +5 -3
  80. package/src/host/bridge-host.ts +34 -6
  81. package/src/swift-compile.ts +5 -4
  82. package/src/worker-system-chunks.ts +10 -9
@@ -1,8 +1,10 @@
1
- import { spawn } from 'child_process'
1
+ import childProcess, { spawn } from 'child_process'
2
2
  import fs from 'fs'
3
3
  import { createServer, type IncomingMessage, type ServerResponse } from 'http'
4
+ import os from 'os'
4
5
  import path from 'path'
5
6
  import { WebSocket, WebSocketServer } from 'ws'
7
+ import { readChromiumQueue } from '../../../../scripts/lib/chromium-admission.ts'
6
8
  import {
7
9
  scanDevServers,
8
10
  type DiscoveredServer,
@@ -2038,6 +2040,7 @@ export class SootSimBridgeHost {
2038
2040
 
2039
2041
  private reapIdleSims(now = Date.now()) {
2040
2042
  const attachedSimIds = new Set(this.cliSimBySocket.values())
2043
+ let reclaimable: { ws: WebSocket; idleMs: number } | null = null
2041
2044
  for (const sim of this.sims.values()) {
2042
2045
  if (attachedSimIds.has(sim.id)) continue
2043
2046
  const automation = this.isAutomationSim(sim)
@@ -2053,13 +2056,38 @@ export class SootSimBridgeHost {
2053
2056
  // never-CLI-driven sims have lastActiveAt 0 — fall back to connectedAt
2054
2057
  // so a freshly opened, not-yet-primary tab isn't reaped on the spot.
2055
2058
  const idleMs = now - Math.max(sim.lastActiveAt, sim.connectedAt)
2056
- const ttl = automation
2057
- ? AUTOMATION_SIM_IDLE_REAP_TTL_MS
2058
- : SootSimBridgeHost.SIM_IDLE_REAP_TTL_MS
2059
+ if (automation) {
2060
+ if (
2061
+ idleMs >= AUTOMATION_SIM_IDLE_REAP_TTL_MS &&
2062
+ idleMs > (reclaimable?.idleMs ?? 0)
2063
+ )
2064
+ reclaimable = { ws: sim.ws, idleMs }
2065
+ continue
2066
+ }
2059
2067
  // terminal close → client closes the window, does not reconnect; the
2060
2068
  // 'close' handler runs rememberDisconnectedSim → this.sims.delete.
2061
- if (idleMs >= ttl) this.closeSimSocketFromHost(sim.ws)
2062
- }
2069
+ if (idleMs >= SootSimBridgeHost.SIM_IDLE_REAP_TTL_MS)
2070
+ this.closeSimSocketFromHost(sim.ws)
2071
+ }
2072
+ // an automation sim lives as long as the session that opened it, as a
2073
+ // simulator stays booted between commands; its host closes chrome when that
2074
+ // session exits. an idle one gives up its chromium slot only while another
2075
+ // launch on this machine waits for one, the longest idle first.
2076
+ if (reclaimable && this.chromiumLaunchWaiting())
2077
+ this.closeSimSocketFromHost(reclaimable.ws)
2078
+ }
2079
+
2080
+ private chromiumQueueVerified = new Map<string, boolean>()
2081
+
2082
+ private chromiumLaunchWaiting(): boolean {
2083
+ const queue = readChromiumQueue(
2084
+ { fs, os, path, childProcess },
2085
+ this.chromiumQueueVerified,
2086
+ )
2087
+ const live = new Set(queue.tickets)
2088
+ for (const entry of this.chromiumQueueVerified.keys())
2089
+ if (!live.has(entry)) this.chromiumQueueVerified.delete(entry)
2090
+ return queue.tickets.length > queue.limit
2063
2091
  }
2064
2092
 
2065
2093
  // ping every connected ws; if the previous round's ping went unanswered,
@@ -15,6 +15,7 @@ import {
15
15
  import os from 'node:os'
16
16
  import path from 'node:path'
17
17
  import { promisify } from 'node:util'
18
+ import { admittedMacBuilderSlot } from './admitted-mac-build'
18
19
  import {
19
20
  parseSwiftDistributionManifest,
20
21
  SWIFT_DISTRIBUTION_MANIFEST,
@@ -2690,13 +2691,13 @@ export function compileSwiftProjectUnit(
2690
2691
  }
2691
2692
  const hash = swiftArtifactHash(input, options.release, moduleRoot)
2692
2693
  return serialize(root, async () => {
2693
- // a remote builder slot (CONTRAST_REMOTE_BUILD) already admitted this work
2694
- // and every builder mac carries the pinned toolchain, so it compiles in
2695
- // place. offloading again from there adds a second workspace and install.
2694
+ // an admitted mac slot already holds the build lock and the pinned
2695
+ // toolchain, so it compiles here. a bare CONTRAST_REMOTE_BUILD value is
2696
+ // only an inherited marker and still dispatches through admission.
2696
2697
  if (
2697
2698
  process.platform === 'darwin' &&
2698
2699
  process.env.TM_SESSION &&
2699
- !process.env.CONTRAST_REMOTE_BUILD &&
2700
+ !admittedMacBuilderSlot() &&
2700
2701
  process.env.CI !== 'true' &&
2701
2702
  moduleRoot === path.resolve(import.meta.dirname, '../../sootsim-swift') &&
2702
2703
  !swiftDistributionAt(moduleRoot)
@@ -6,22 +6,23 @@ import { isRecord } from './is-record'
6
6
 
7
7
  const require = createRequire(import.meta.url)
8
8
  const systemRuntime = fs.readFileSync(require.resolve('systemjs/dist/s.min.js'), 'utf8')
9
- const minifierModule = require.resolve('terser')
9
+ const minifierModule = require.resolve('rolldown/utils')
10
10
  type MinifiedWorkerChunk = { code: string; map: string }
11
11
  const minifierWorker = `
12
12
  const { parentPort, workerData } = require('node:worker_threads');
13
- const { minify } = require(workerData.module);
13
+ const minifier = import(workerData.module);
14
14
  parentPort.on('message', async ({ code, map, keepNames, measurement }) => {
15
15
  try {
16
- const result = await minify(code, {
16
+ const { minifySync } = await minifier;
17
+ const result = minifySync('peach-worker-chunk.js', code, {
17
18
  module: true,
18
- compress: measurement ? false : { passes: 2 },
19
- mangle: !measurement,
20
- keep_fnames: keepNames,
21
- keep_classnames: keepNames,
22
- sourceMap: { content: map },
19
+ compress: measurement ? false : { keepNames: { function: keepNames, class: keepNames } },
20
+ mangle: measurement ? false : { keepNames },
21
+ sourcemap: true,
22
+ inputMap: JSON.parse(map),
23
23
  });
24
- parentPort.postMessage({ code: result.code, map: result.map });
24
+ if (result.errors.length) throw new Error(result.errors.map(error => error.message).join('; '));
25
+ parentPort.postMessage({ code: result.code, map: result.map && JSON.stringify(result.map) });
25
26
  } catch (error) {
26
27
  parentPort.postMessage({ error: error instanceof Error ? error.message : String(error) });
27
28
  }