peachsim 0.1.1653 → 0.1.1654
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.
- package/cli/app-stubs.ts +97 -14
- package/cli/bridge-diagnostics.ts +10 -7
- package/cli/cloud-client.ts +11 -2
- package/cli/commands/doctor.ts +20 -10
- package/cli/commands/inspect/core.ts +2 -1
- package/cli/commands/inspect/shared.ts +2 -0
- package/cli/commands/inspect.ts +11 -2
- package/cli/output-redaction.ts +22 -6
- package/cli/pause-aware-timeout.ts +24 -10
- package/cli/ws-bridge.ts +17 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +42 -50
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +47 -12
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +41 -49
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +70 -52
- package/dist-lib/host/fetch-proxy-handler.cjs +176 -31
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +633 -373
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +62 -14
- package/dist-lib/native-app-identity-project.cjs +1 -1
- package/dist-lib/native-app-identity-project.mjs +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +23 -23
- package/dist-lib/public-origins-lib.json +62 -54
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +2 -2
- package/dist-lib/sdk.mjs +2 -2
- package/dist-lib/skills.cjs +284 -185
- package/dist-lib/swift-compile.cjs +23 -3
- package/dist-lib/swift-compile.mjs +22 -3
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +41 -49
- package/dist-lib/vite.cjs +385 -200
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-gesture-handler.d.ts +1 -0
- package/dist-types/packages/peach-compat/src/stubs/screen-transition-math.d.ts +10 -7
- package/dist-types/packages/peach-engine/src/capture/browser-composite.d.ts +10 -0
- package/dist-types/packages/peach-engine/src/cli-companion.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -1
- package/dist-types/packages/peach-engine/src/engine/scene-table.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +23 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/visible-frame.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/observability/types.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +38 -0
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +5 -0
- package/package.json +5 -1
- package/runtime-companion.json +1 -1
- package/src/bridge-contract.ts +2 -0
- package/src/bundleGlobalFooter.ts +9 -0
- package/src/host/fetch-proxy-handler.ts +37 -0
- package/src/sfSymbolMetricsContract.ts +268 -0
- package/src/swift-compile.ts +16 -1
- package/src/swift-distribution.lock.json +20 -46
- package/src/swift-objc-metadata.ts +21 -7
- package/src/swift-objc-sdk.ts +13 -0
- package/src/vite-plugin-one.ts +161 -16
- package/src/host/lease-owner.test.ts +0 -49
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1654 | (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;
|
|
@@ -32,27 +32,70 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
32
|
));
|
|
33
33
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
34
|
|
|
35
|
+
// runtime-companion.json
|
|
36
|
+
var runtime_companion_default;
|
|
37
|
+
var init_runtime_companion = __esm({
|
|
38
|
+
"runtime-companion.json"() {
|
|
39
|
+
runtime_companion_default = { abi: 1, sha256: "a1b49c57129dd06888a9cdfbb05051be3626e8233980236705a3efd52b651623", file: "node/cli-a1b49c57129dd06888a9cdfbb05051be3626e8233980236705a3efd52b651623.cjs" };
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/process-group.ts
|
|
44
|
+
var init_process_group = __esm({
|
|
45
|
+
"src/process-group.ts"() {
|
|
46
|
+
"use strict";
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// ../contrast-runtime-delivery/src/version.ts
|
|
51
|
+
function isValidRuntimeVersion(value) {
|
|
52
|
+
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
53
|
+
}
|
|
54
|
+
var init_version = __esm({
|
|
55
|
+
"../contrast-runtime-delivery/src/version.ts"() {
|
|
56
|
+
"use strict";
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// ../contrast-runtime-delivery/src/product.ts
|
|
61
|
+
var init_product = __esm({
|
|
62
|
+
"../contrast-runtime-delivery/src/product.ts"() {
|
|
63
|
+
"use strict";
|
|
64
|
+
init_version();
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ../contrast-runtime-delivery/src/index.ts
|
|
69
|
+
var init_src = __esm({
|
|
70
|
+
"../contrast-runtime-delivery/src/index.ts"() {
|
|
71
|
+
"use strict";
|
|
72
|
+
init_process_group();
|
|
73
|
+
init_product();
|
|
74
|
+
init_product();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
|
|
35
78
|
// src/home-paths.ts
|
|
36
79
|
function rnxHomeDir() {
|
|
37
80
|
const override = process.env[PEACH_HOME_ENV];
|
|
38
|
-
if (override && override.length > 0) return
|
|
39
|
-
return
|
|
81
|
+
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
82
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".peach");
|
|
40
83
|
}
|
|
41
84
|
function runtimesDir() {
|
|
42
|
-
return
|
|
85
|
+
return import_node_path.default.join(rnxHomeDir(), "runtimes");
|
|
43
86
|
}
|
|
44
87
|
function runtimeDir(version) {
|
|
45
|
-
return
|
|
88
|
+
return import_node_path.default.join(runtimesDir(), version);
|
|
46
89
|
}
|
|
47
90
|
function activeRuntimeFile() {
|
|
48
|
-
return
|
|
91
|
+
return import_node_path.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
49
92
|
}
|
|
50
93
|
function daemonLockfilePath() {
|
|
51
|
-
return
|
|
94
|
+
return import_node_path.default.join(rnxHomeDir(), DAEMON_LOCKFILE);
|
|
52
95
|
}
|
|
53
96
|
function readActiveRuntime() {
|
|
54
97
|
try {
|
|
55
|
-
const value =
|
|
98
|
+
const value = import_node_fs.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
56
99
|
return value.length > 0 ? value : null;
|
|
57
100
|
} catch {
|
|
58
101
|
return null;
|
|
@@ -60,10 +103,10 @@ function readActiveRuntime() {
|
|
|
60
103
|
}
|
|
61
104
|
function readDaemonLockfile() {
|
|
62
105
|
try {
|
|
63
|
-
const fd =
|
|
106
|
+
const fd = import_node_fs.default.openSync(daemonLockfilePath(), "r");
|
|
64
107
|
try {
|
|
65
108
|
const buf = Buffer.alloc(DAEMON_LOCKFILE_MAX_BYTES);
|
|
66
|
-
const bytesRead =
|
|
109
|
+
const bytesRead = import_node_fs.default.readSync(fd, buf, 0, DAEMON_LOCKFILE_MAX_BYTES, 0);
|
|
67
110
|
const raw = buf.subarray(0, bytesRead).toString("utf8");
|
|
68
111
|
const parsed = JSON.parse(raw);
|
|
69
112
|
if (parsed && parsed.schema === 1 && typeof parsed.pid === "number" && typeof parsed.bridgePort === "number" && typeof parsed.runtimePort === "number" && typeof parsed.startedAt === "number" && typeof parsed.heartbeatAt === "number" && (parsed.servedRuntimes === void 0 || Array.isArray(parsed.servedRuntimes) && parsed.servedRuntimes.every((version) => typeof version === "string"))) {
|
|
@@ -71,7 +114,7 @@ function readDaemonLockfile() {
|
|
|
71
114
|
}
|
|
72
115
|
return null;
|
|
73
116
|
} finally {
|
|
74
|
-
|
|
117
|
+
import_node_fs.default.closeSync(fd);
|
|
75
118
|
}
|
|
76
119
|
} catch {
|
|
77
120
|
return null;
|
|
@@ -87,13 +130,13 @@ function isDaemonLockfileFresh(lock, now = Date.now()) {
|
|
|
87
130
|
return false;
|
|
88
131
|
}
|
|
89
132
|
}
|
|
90
|
-
var
|
|
133
|
+
var import_node_fs, import_node_os, import_node_path, PEACH_HOME_ENV, ACTIVE_RUNTIME_FILE, DAEMON_LOCKFILE, DAEMON_HEARTBEAT_STALE_MS, DAEMON_LOCKFILE_MAX_BYTES;
|
|
91
134
|
var init_home_paths = __esm({
|
|
92
135
|
"src/home-paths.ts"() {
|
|
93
136
|
"use strict";
|
|
94
|
-
|
|
137
|
+
import_node_fs = __toESM(require("node:fs"), 1);
|
|
95
138
|
import_node_os = require("node:os");
|
|
96
|
-
|
|
139
|
+
import_node_path = __toESM(require("node:path"), 1);
|
|
97
140
|
PEACH_HOME_ENV = "PEACH_HOME";
|
|
98
141
|
ACTIVE_RUNTIME_FILE = "active";
|
|
99
142
|
DAEMON_LOCKFILE = "daemon.json";
|
|
@@ -102,51 +145,16 @@ var init_home_paths = __esm({
|
|
|
102
145
|
}
|
|
103
146
|
});
|
|
104
147
|
|
|
105
|
-
// src/process-group.ts
|
|
106
|
-
var init_process_group = __esm({
|
|
107
|
-
"src/process-group.ts"() {
|
|
108
|
-
"use strict";
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// ../contrast-runtime-delivery/src/version.ts
|
|
113
|
-
function isValidRuntimeVersion(value) {
|
|
114
|
-
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
115
|
-
}
|
|
116
|
-
var init_version = __esm({
|
|
117
|
-
"../contrast-runtime-delivery/src/version.ts"() {
|
|
118
|
-
"use strict";
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
// ../contrast-runtime-delivery/src/product.ts
|
|
123
|
-
var init_product = __esm({
|
|
124
|
-
"../contrast-runtime-delivery/src/product.ts"() {
|
|
125
|
-
"use strict";
|
|
126
|
-
init_version();
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
// ../contrast-runtime-delivery/src/index.ts
|
|
131
|
-
var init_src = __esm({
|
|
132
|
-
"../contrast-runtime-delivery/src/index.ts"() {
|
|
133
|
-
"use strict";
|
|
134
|
-
init_process_group();
|
|
135
|
-
init_product();
|
|
136
|
-
init_product();
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
|
|
140
148
|
// src/runtime-assets.ts
|
|
141
149
|
function findMonorepoRoot() {
|
|
142
150
|
if (_monorepoRootCache !== void 0) return _monorepoRootCache;
|
|
143
|
-
let dir =
|
|
144
|
-
for (let i = 0; i < 12 && dir !==
|
|
145
|
-
if (
|
|
151
|
+
let dir = import_path.default.dirname((0, import_url.fileURLToPath)(__sootsim_import_meta_url));
|
|
152
|
+
for (let i = 0; i < 12 && dir !== import_path.default.dirname(dir); i++) {
|
|
153
|
+
if (import_fs.default.existsSync(import_path.default.join(dir, "packages/peach-engine/package.json")) && import_fs.default.existsSync(import_path.default.join(dir, "public/sootsim"))) {
|
|
146
154
|
_monorepoRootCache = dir;
|
|
147
155
|
return dir;
|
|
148
156
|
}
|
|
149
|
-
dir =
|
|
157
|
+
dir = import_path.default.dirname(dir);
|
|
150
158
|
}
|
|
151
159
|
_monorepoRootCache = null;
|
|
152
160
|
return null;
|
|
@@ -155,12 +163,12 @@ function resolveDevCheckoutRuntimeAssetRoot() {
|
|
|
155
163
|
if (process.env.PEACH_HOME && readActiveRuntime()) return null;
|
|
156
164
|
const root = findMonorepoRoot();
|
|
157
165
|
if (!root) return null;
|
|
158
|
-
return
|
|
166
|
+
return import_path.default.join(root, "public/sootsim");
|
|
159
167
|
}
|
|
160
168
|
function resolveDevCheckoutRuntimeRoot() {
|
|
161
169
|
const devBuild = resolveDevCheckoutRuntimeAssetRoot();
|
|
162
170
|
if (!devBuild) return null;
|
|
163
|
-
if (
|
|
171
|
+
if (import_fs.default.existsSync(import_path.default.join(devBuild, "index.html")) && import_fs.default.existsSync(import_path.default.join(devBuild, "engine/index.html")) && import_fs.default.existsSync(import_path.default.join(devBuild, "engine-tenant/worker.js")) && import_fs.default.existsSync(import_path.default.join(devBuild, "engine-tenant/worker.prod.js"))) {
|
|
164
172
|
return devBuild;
|
|
165
173
|
}
|
|
166
174
|
return null;
|
|
@@ -171,7 +179,7 @@ function resolveActiveRuntimeRoot() {
|
|
|
171
179
|
const active = readActiveRuntime();
|
|
172
180
|
if (!active) return null;
|
|
173
181
|
const dir = runtimeDir(active);
|
|
174
|
-
if (!
|
|
182
|
+
if (!import_fs.default.existsSync(import_path.default.join(dir, "index.html"))) return null;
|
|
175
183
|
return dir;
|
|
176
184
|
}
|
|
177
185
|
function isRuntimeVersionHostname(hostname) {
|
|
@@ -194,7 +202,7 @@ function runtimeVersionFromHostname(hostname) {
|
|
|
194
202
|
}
|
|
195
203
|
function resolveInstalledRuntimeRoot(version) {
|
|
196
204
|
const dir = runtimeDir(version);
|
|
197
|
-
if (!
|
|
205
|
+
if (!import_fs.default.existsSync(import_path.default.join(dir, "index.html"))) return null;
|
|
198
206
|
return dir;
|
|
199
207
|
}
|
|
200
208
|
function resolveRuntimeRootForHostname(hostname) {
|
|
@@ -220,20 +228,20 @@ function resolveRuntimeFilePath(runtimeRoot, pathname) {
|
|
|
220
228
|
if (segment === "..") return null;
|
|
221
229
|
}
|
|
222
230
|
const normalized = pathname.startsWith("/sootsim/") ? pathname.slice("/sootsim".length) : pathname;
|
|
223
|
-
const fullPath =
|
|
224
|
-
const rootWithSep = runtimeRoot.endsWith(
|
|
231
|
+
const fullPath = import_path.default.resolve(runtimeRoot, normalized.replace(/^\/+/, ""));
|
|
232
|
+
const rootWithSep = runtimeRoot.endsWith(import_path.default.sep) ? runtimeRoot : runtimeRoot + import_path.default.sep;
|
|
225
233
|
if (!fullPath.startsWith(rootWithSep) && fullPath !== runtimeRoot) return null;
|
|
226
|
-
if (!
|
|
234
|
+
if (!import_fs.default.existsSync(fullPath) || !import_fs.default.statSync(fullPath).isFile()) return null;
|
|
227
235
|
return fullPath;
|
|
228
236
|
}
|
|
229
237
|
function serveRuntimeFile(req, res, fullPath) {
|
|
230
|
-
const ext =
|
|
231
|
-
const stat =
|
|
238
|
+
const ext = import_path.default.extname(fullPath);
|
|
239
|
+
const stat = import_fs.default.statSync(fullPath);
|
|
232
240
|
const lastModified = stat.mtime.toUTCString();
|
|
233
241
|
res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
|
|
234
|
-
if (/^canvaskit-graphite-pipelines-[0-9a-f]{8}\.bin$/.test(
|
|
242
|
+
if (/^canvaskit-graphite-pipelines-[0-9a-f]{8}\.bin$/.test(import_path.default.basename(fullPath))) {
|
|
235
243
|
res.setHeader("cache-control", "public, max-age=31536000, immutable");
|
|
236
|
-
|
|
244
|
+
import_fs.default.createReadStream(fullPath).pipe(res);
|
|
237
245
|
return;
|
|
238
246
|
}
|
|
239
247
|
res.setHeader("cache-control", "no-cache");
|
|
@@ -265,7 +273,7 @@ function sendFileWithRanges(req, res, filePath, total, headers) {
|
|
|
265
273
|
"Content-Length": String(end - start + 1)
|
|
266
274
|
});
|
|
267
275
|
if (head) res.end();
|
|
268
|
-
else streamFile(res,
|
|
276
|
+
else streamFile(res, import_fs.default.createReadStream(filePath, { start, end }));
|
|
269
277
|
return;
|
|
270
278
|
}
|
|
271
279
|
res.writeHead(200, {
|
|
@@ -274,18 +282,18 @@ function sendFileWithRanges(req, res, filePath, total, headers) {
|
|
|
274
282
|
"Content-Length": String(total)
|
|
275
283
|
});
|
|
276
284
|
if (head || total === 0) res.end();
|
|
277
|
-
else streamFile(res,
|
|
285
|
+
else streamFile(res, import_fs.default.createReadStream(filePath, { start: 0, end: total - 1 }));
|
|
278
286
|
}
|
|
279
287
|
function streamFile(res, stream) {
|
|
280
288
|
stream.on("error", (error) => res.destroy(error));
|
|
281
289
|
stream.pipe(res);
|
|
282
290
|
}
|
|
283
|
-
var
|
|
291
|
+
var import_fs, import_path, import_url, SOOTSIM_RUNTIME_MISSING_MESSAGE, _monorepoRootCache, MIME_TYPES, ROOT_RUNTIME_PATHS, RUNTIME_VERSION_HOSTNAME_SUFFIX;
|
|
284
292
|
var init_runtime_assets = __esm({
|
|
285
293
|
"src/runtime-assets.ts"() {
|
|
286
294
|
"use strict";
|
|
287
|
-
|
|
288
|
-
|
|
295
|
+
import_fs = __toESM(require("fs"), 1);
|
|
296
|
+
import_path = __toESM(require("path"), 1);
|
|
289
297
|
import_url = require("url");
|
|
290
298
|
init_src();
|
|
291
299
|
init_home_paths();
|
|
@@ -335,6 +343,57 @@ var init_runtime_assets = __esm({
|
|
|
335
343
|
}
|
|
336
344
|
});
|
|
337
345
|
|
|
346
|
+
// src/cli-runtime.ts
|
|
347
|
+
function cliCompanionPath() {
|
|
348
|
+
return `node/cli-${runtime_companion_default.sha256}.cjs`;
|
|
349
|
+
}
|
|
350
|
+
function verifyCliCompanion(root) {
|
|
351
|
+
const file = (0, import_node_path2.join)(root, cliCompanionPath());
|
|
352
|
+
let bytes;
|
|
353
|
+
try {
|
|
354
|
+
bytes = (0, import_node_fs2.readFileSync)(file);
|
|
355
|
+
} catch (cause) {
|
|
356
|
+
throw new Error(
|
|
357
|
+
"Peach runtime is missing the companion required by this CLI; run `peach runtime install`",
|
|
358
|
+
{ cause }
|
|
359
|
+
);
|
|
360
|
+
}
|
|
361
|
+
const hash = (0, import_node_crypto.createHash)("sha256").update(bytes).digest("hex");
|
|
362
|
+
if (hash !== runtime_companion_default.sha256) {
|
|
363
|
+
throw new Error(
|
|
364
|
+
"Peach runtime companion does not match this CLI; run `peach runtime install`"
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
function getCliRuntime() {
|
|
369
|
+
if (loaded) return loaded.runtime;
|
|
370
|
+
const root = resolveDevCheckoutRuntimeAssetRoot() ?? resolveActiveRuntimeRoot();
|
|
371
|
+
if (!root) throw new Error("No Peach runtime installed; run `peach runtime install`");
|
|
372
|
+
verifyCliCompanion(root);
|
|
373
|
+
const require2 = (0, import_node_module.createRequire)(__sootsim_import_meta_url);
|
|
374
|
+
const runtime = require2((0, import_node_path2.join)(root, cliCompanionPath()));
|
|
375
|
+
if (runtime.cliCompanionAbi !== CLI_COMPANION_ABI) {
|
|
376
|
+
throw new Error(
|
|
377
|
+
"Incompatible Peach runtime companion ABI; run `peach runtime install`"
|
|
378
|
+
);
|
|
379
|
+
}
|
|
380
|
+
loaded = { root, runtime };
|
|
381
|
+
return runtime;
|
|
382
|
+
}
|
|
383
|
+
var import_node_crypto, import_node_fs2, import_node_module, import_node_path2, CLI_COMPANION_ABI, loaded;
|
|
384
|
+
var init_cli_runtime = __esm({
|
|
385
|
+
"src/cli-runtime.ts"() {
|
|
386
|
+
"use strict";
|
|
387
|
+
import_node_crypto = require("node:crypto");
|
|
388
|
+
import_node_fs2 = require("node:fs");
|
|
389
|
+
import_node_module = require("node:module");
|
|
390
|
+
import_node_path2 = require("node:path");
|
|
391
|
+
init_runtime_companion();
|
|
392
|
+
init_runtime_assets();
|
|
393
|
+
CLI_COMPANION_ABI = 1;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
|
|
338
397
|
// src/vite-plugin-one.ts
|
|
339
398
|
var vite_plugin_one_exports = {};
|
|
340
399
|
__export(vite_plugin_one_exports, {
|
|
@@ -343,7 +402,7 @@ __export(vite_plugin_one_exports, {
|
|
|
343
402
|
});
|
|
344
403
|
module.exports = __toCommonJS(vite_plugin_one_exports);
|
|
345
404
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
346
|
-
var
|
|
405
|
+
var import_node_crypto4 = require("node:crypto");
|
|
347
406
|
var import_node_url = require("node:url");
|
|
348
407
|
var import_path3 = __toESM(require("path"), 1);
|
|
349
408
|
var import_ws = require("ws");
|
|
@@ -360,11 +419,62 @@ var DEFAULT_SOOTSIM_BRIDGE_URL = `http://localhost:${DEFAULT_SOOTSIM_BRIDGE_PORT
|
|
|
360
419
|
var HOSTED_SHELL_PATH = new RegExp(`^(?:${PEACH_SIMULATOR_PATH}|/sootsim)(?:/|$)`);
|
|
361
420
|
var AUTOMATION_SIM_IDLE_REAP_TTL_MS = 5 * 6e4;
|
|
362
421
|
|
|
422
|
+
// src/bundleGlobalFooter.ts
|
|
423
|
+
function findBundleFooter(source, prefix) {
|
|
424
|
+
let end = source.length;
|
|
425
|
+
while (end > 0) {
|
|
426
|
+
const newline = source.lastIndexOf("\n", end - 1);
|
|
427
|
+
if (newline < 0) return -1;
|
|
428
|
+
const line = newline + 1;
|
|
429
|
+
if (source.startsWith(prefix, line)) return newline;
|
|
430
|
+
if (!isFooterBlockLine(source, line, end)) return -1;
|
|
431
|
+
end = newline;
|
|
432
|
+
}
|
|
433
|
+
return -1;
|
|
434
|
+
}
|
|
435
|
+
function isFooterBlockLine(source, line, end) {
|
|
436
|
+
return line === end || source.startsWith("globalThis.", line) || source.startsWith("//", line);
|
|
437
|
+
}
|
|
438
|
+
function readFooter(source, prefix, suffix, name) {
|
|
439
|
+
const start = findBundleFooter(source, prefix);
|
|
440
|
+
if (start < 0) return null;
|
|
441
|
+
const end = source.indexOf("\n", start + 1);
|
|
442
|
+
const line = source.slice(start + 1, end < 0 ? void 0 : end);
|
|
443
|
+
if (!line.endsWith(suffix)) throw new Error(`${name} footer is truncated`);
|
|
444
|
+
const value = JSON.parse(
|
|
445
|
+
line.slice(prefix.length, suffix ? -suffix.length : void 0)
|
|
446
|
+
);
|
|
447
|
+
if (value === null) throw new Error(`${name} footer has no metadata`);
|
|
448
|
+
return value;
|
|
449
|
+
}
|
|
450
|
+
var ROLLDOWN_INVENTORY_HEADER = "X-Peach-Rolldown-Inventory";
|
|
451
|
+
function detachFooter(source, prefix, suffix, name) {
|
|
452
|
+
const start = findBundleFooter(source, prefix);
|
|
453
|
+
if (start < 0) return { source, value: null };
|
|
454
|
+
const value = readFooter(source, prefix, suffix, name);
|
|
455
|
+
const end = source.indexOf("\n", start + 1);
|
|
456
|
+
return { source: source.slice(0, start) + (end < 0 ? "" : source.slice(end)), value };
|
|
457
|
+
}
|
|
458
|
+
function insertBundleGlobalFooter(source, name, value) {
|
|
459
|
+
return insertFooter(source, `globalThis.${name}=`, ";", name, value);
|
|
460
|
+
}
|
|
461
|
+
function insertFooter(source, prefix, suffix, name, value) {
|
|
462
|
+
source = detachFooter(source, prefix, suffix, name).source;
|
|
463
|
+
const json = JSON.stringify(value).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
|
|
464
|
+
const footer = `
|
|
465
|
+
${prefix}${json}${suffix}`;
|
|
466
|
+
const identity = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
|
|
467
|
+
return identity < 0 ? source + footer : source.slice(0, identity) + footer + source.slice(identity);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// src/vite-plugin-one.ts
|
|
471
|
+
init_cli_runtime();
|
|
472
|
+
|
|
363
473
|
// src/dev-server-open.ts
|
|
364
474
|
var import_node_child_process = require("node:child_process");
|
|
365
|
-
var
|
|
366
|
-
var
|
|
367
|
-
var
|
|
475
|
+
var import_node_crypto2 = require("node:crypto");
|
|
476
|
+
var import_node_fs3 = __toESM(require("node:fs"), 1);
|
|
477
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
368
478
|
function resolveRnxDesktopAppName(open, projectRoot) {
|
|
369
479
|
if (!open) return null;
|
|
370
480
|
if (typeof open === "object") {
|
|
@@ -372,8 +482,8 @@ function resolveRnxDesktopAppName(open, projectRoot) {
|
|
|
372
482
|
if (!appName) throw new Error("peach: open.appName must not be empty");
|
|
373
483
|
return appName;
|
|
374
484
|
}
|
|
375
|
-
const packageJsonPath =
|
|
376
|
-
const packageJson = JSON.parse(
|
|
485
|
+
const packageJsonPath = import_node_path3.default.join(projectRoot, "package.json");
|
|
486
|
+
const packageJson = JSON.parse(import_node_fs3.default.readFileSync(packageJsonPath, "utf8"));
|
|
377
487
|
const packageName = packageJson && typeof packageJson === "object" ? Reflect.get(packageJson, "name") : void 0;
|
|
378
488
|
if (typeof packageName !== "string" || !packageName.trim()) {
|
|
379
489
|
throw new Error(`peach: ${packageJsonPath} must declare a package name`);
|
|
@@ -387,7 +497,7 @@ function tagRnxBundleForPlugin(bundleUrl, replacementOrigin, replacementToken, p
|
|
|
387
497
|
url.searchParams.set("rnxAppName", appName);
|
|
388
498
|
url.searchParams.set(
|
|
389
499
|
"rnxProjectId",
|
|
390
|
-
(0,
|
|
500
|
+
(0, import_node_crypto2.createHash)("sha256").update(import_node_fs3.default.realpathSync(projectRoot)).digest("hex").slice(0, 32)
|
|
391
501
|
);
|
|
392
502
|
}
|
|
393
503
|
url.searchParams.set("rnxReplacementOrigin", replacementOrigin);
|
|
@@ -434,9 +544,9 @@ function launchRnxDesktop(bundleUrl, appName) {
|
|
|
434
544
|
init_home_paths();
|
|
435
545
|
|
|
436
546
|
// src/host/replacement-module-handler.ts
|
|
437
|
-
var
|
|
547
|
+
var import_node_fs4 = require("node:fs");
|
|
438
548
|
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
439
|
-
var
|
|
549
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
440
550
|
|
|
441
551
|
// ../contrast-bundler/src/replacementModule.ts
|
|
442
552
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -475,7 +585,7 @@ function normalize(p) {
|
|
|
475
585
|
if (trailingSlash) joined += "/";
|
|
476
586
|
return absolute ? "/" + joined : joined;
|
|
477
587
|
}
|
|
478
|
-
function
|
|
588
|
+
function join2(...parts) {
|
|
479
589
|
const present = parts.filter((part) => part.length > 0);
|
|
480
590
|
if (present.length === 0) return ".";
|
|
481
591
|
return normalize(present.join("/"));
|
|
@@ -532,7 +642,7 @@ var posix = {
|
|
|
532
642
|
delimiter,
|
|
533
643
|
isAbsolute,
|
|
534
644
|
normalize,
|
|
535
|
-
join,
|
|
645
|
+
join: join2,
|
|
536
646
|
resolve,
|
|
537
647
|
dirname,
|
|
538
648
|
basename,
|
|
@@ -772,16 +882,16 @@ function sendJavaScript(req, res, source) {
|
|
|
772
882
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
773
883
|
}
|
|
774
884
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
775
|
-
const base =
|
|
885
|
+
const base = import_node_path4.default.resolve(import_node_path4.default.dirname(fromFile), specifier);
|
|
776
886
|
const candidates = [
|
|
777
887
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
778
|
-
(ext) => ext ===
|
|
888
|
+
(ext) => ext === import_node_path4.default.extname(base).toLowerCase()
|
|
779
889
|
) ? [base] : [],
|
|
780
890
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
781
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
891
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path4.default.join(base, `index${ext}`))
|
|
782
892
|
];
|
|
783
893
|
const found = candidates.find(
|
|
784
|
-
(candidate) => (0,
|
|
894
|
+
(candidate) => (0, import_node_fs4.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
785
895
|
);
|
|
786
896
|
if (!found) {
|
|
787
897
|
throw new Error(
|
|
@@ -792,8 +902,8 @@ function resolveReplacementModuleFile(fromFile, specifier) {
|
|
|
792
902
|
}
|
|
793
903
|
function isInsideAny(roots, file) {
|
|
794
904
|
return roots.some((root) => {
|
|
795
|
-
const relative2 =
|
|
796
|
-
return !relative2.startsWith("..") && !
|
|
905
|
+
const relative2 = import_node_path4.default.relative(root, file);
|
|
906
|
+
return !relative2.startsWith("..") && !import_node_path4.default.isAbsolute(relative2);
|
|
797
907
|
});
|
|
798
908
|
}
|
|
799
909
|
async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
@@ -833,19 +943,19 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
833
943
|
res.end("missing path param");
|
|
834
944
|
return true;
|
|
835
945
|
}
|
|
836
|
-
const extension =
|
|
946
|
+
const extension = import_node_path4.default.extname(targetPath).toLowerCase();
|
|
837
947
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
838
948
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
839
949
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
840
950
|
return true;
|
|
841
951
|
}
|
|
842
|
-
if (!
|
|
952
|
+
if (!import_node_path4.default.isAbsolute(targetPath)) {
|
|
843
953
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
844
954
|
res.end("replacement file path must be absolute");
|
|
845
955
|
return true;
|
|
846
956
|
}
|
|
847
957
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
848
|
-
const servedRoots = options.servedRoots?.map((root) =>
|
|
958
|
+
const servedRoots = options.servedRoots?.map((root) => import_node_path4.default.resolve(root));
|
|
849
959
|
if (servedRoots && !isInsideAny(servedRoots, targetPath)) {
|
|
850
960
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
851
961
|
res.end("replacement file must be inside a folder the bundler serves");
|
|
@@ -899,8 +1009,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
899
1009
|
}
|
|
900
1010
|
|
|
901
1011
|
// src/installed-package-versions.ts
|
|
902
|
-
var
|
|
903
|
-
var
|
|
1012
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
1013
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
904
1014
|
|
|
905
1015
|
// ../peach-compat/src/lazy-stub-patterns.ts
|
|
906
1016
|
var LAZY_STUB_PATTERNS = [
|
|
@@ -3787,10 +3897,10 @@ function isMissing(error) {
|
|
|
3787
3897
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
3788
3898
|
}
|
|
3789
3899
|
function answerSync(step) {
|
|
3790
|
-
if (step.op === "exists") return
|
|
3791
|
-
if (step.op === "realpath") return
|
|
3900
|
+
if (step.op === "exists") return import_fs2.default.existsSync(step.path);
|
|
3901
|
+
if (step.op === "realpath") return import_fs2.default.realpathSync(step.path);
|
|
3792
3902
|
try {
|
|
3793
|
-
return parseManifest(
|
|
3903
|
+
return parseManifest(import_fs2.default.readFileSync(step.path, "utf8"));
|
|
3794
3904
|
} catch (error) {
|
|
3795
3905
|
if (isMissing(error)) return null;
|
|
3796
3906
|
throw error;
|
|
@@ -3807,25 +3917,25 @@ function createInstalledPackageReader() {
|
|
|
3807
3917
|
const manifests = /* @__PURE__ */ new Map();
|
|
3808
3918
|
return function* readInstalledPackage(fromDir, name) {
|
|
3809
3919
|
for (let dir = fromDir; ; ) {
|
|
3810
|
-
if (
|
|
3811
|
-
const modules =
|
|
3920
|
+
if (import_path2.default.basename(dir) !== "node_modules") {
|
|
3921
|
+
const modules = import_path2.default.join(dir, "node_modules");
|
|
3812
3922
|
let present = hasModules.get(dir);
|
|
3813
3923
|
if (present === void 0) {
|
|
3814
3924
|
present = yield* exists(modules);
|
|
3815
3925
|
hasModules.set(dir, present);
|
|
3816
3926
|
}
|
|
3817
3927
|
if (present) {
|
|
3818
|
-
const root =
|
|
3928
|
+
const root = import_path2.default.join(modules, name);
|
|
3819
3929
|
let installed = manifests.get(root);
|
|
3820
3930
|
if (installed === void 0) {
|
|
3821
|
-
const manifest = yield* readManifest(
|
|
3931
|
+
const manifest = yield* readManifest(import_path2.default.join(root, "package.json"));
|
|
3822
3932
|
installed = manifest ? { root, manifest } : null;
|
|
3823
3933
|
manifests.set(root, installed);
|
|
3824
3934
|
}
|
|
3825
3935
|
if (installed) return installed;
|
|
3826
3936
|
}
|
|
3827
3937
|
}
|
|
3828
|
-
const parent =
|
|
3938
|
+
const parent = import_path2.default.dirname(dir);
|
|
3829
3939
|
if (parent === dir) return null;
|
|
3830
3940
|
dir = parent;
|
|
3831
3941
|
}
|
|
@@ -3853,7 +3963,7 @@ function* nativePackageVersionsWalk(projectRoot) {
|
|
|
3853
3963
|
const name = extractPackageFromPath(`node_modules/${specifier}`);
|
|
3854
3964
|
if (name) nativeNames.add(name);
|
|
3855
3965
|
}
|
|
3856
|
-
const manifest = yield* readManifest(
|
|
3966
|
+
const manifest = yield* readManifest(import_path2.default.join(appRoot, "package.json"));
|
|
3857
3967
|
if (!manifest) throw new Error("app package.json must contain an object");
|
|
3858
3968
|
const readInstalledPackage = createInstalledPackageReader();
|
|
3859
3969
|
const pending = [{ root: appRoot, manifest }];
|
|
@@ -3890,10 +4000,10 @@ function readInstalledNativePackageVersions(projectRoot) {
|
|
|
3890
4000
|
|
|
3891
4001
|
// src/one-widget-metadata.ts
|
|
3892
4002
|
var import_node_child_process2 = require("node:child_process");
|
|
3893
|
-
var
|
|
3894
|
-
var
|
|
3895
|
-
var
|
|
3896
|
-
var
|
|
4003
|
+
var import_node_crypto3 = require("node:crypto");
|
|
4004
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
4005
|
+
var import_node_module2 = require("node:module");
|
|
4006
|
+
var import_node_path6 = __toESM(require("node:path"), 1);
|
|
3897
4007
|
var import_node_util = require("node:util");
|
|
3898
4008
|
|
|
3899
4009
|
// cli/internal-child.ts
|
|
@@ -3916,28 +4026,28 @@ function isHomeWidgetFamily(value) {
|
|
|
3916
4026
|
}
|
|
3917
4027
|
|
|
3918
4028
|
// src/swift-source-file.ts
|
|
3919
|
-
var
|
|
3920
|
-
var
|
|
4029
|
+
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
4030
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
3921
4031
|
function readPackageFile(root, file, maxBytes) {
|
|
3922
|
-
const canonicalRoot =
|
|
3923
|
-
const relative2 =
|
|
3924
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
4032
|
+
const canonicalRoot = import_node_fs5.default.realpathSync(root);
|
|
4033
|
+
const relative2 = import_node_path5.default.relative(canonicalRoot, import_node_fs5.default.realpathSync(file));
|
|
4034
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path5.default.sep}`) || import_node_path5.default.isAbsolute(relative2)) {
|
|
3925
4035
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
3926
4036
|
}
|
|
3927
|
-
let ancestor =
|
|
4037
|
+
let ancestor = import_node_path5.default.resolve(file);
|
|
3928
4038
|
while (ancestor !== canonicalRoot) {
|
|
3929
|
-
if (
|
|
4039
|
+
if (import_node_fs5.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
3930
4040
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
3931
4041
|
}
|
|
3932
|
-
const parent =
|
|
4042
|
+
const parent = import_node_path5.default.dirname(ancestor);
|
|
3933
4043
|
if (parent === ancestor)
|
|
3934
4044
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
3935
4045
|
ancestor = parent;
|
|
3936
4046
|
}
|
|
3937
|
-
const expected =
|
|
3938
|
-
const fd =
|
|
4047
|
+
const expected = import_node_fs5.default.statSync(file);
|
|
4048
|
+
const fd = import_node_fs5.default.openSync(file, import_node_fs5.default.constants.O_RDONLY | import_node_fs5.default.constants.O_NOFOLLOW);
|
|
3939
4049
|
try {
|
|
3940
|
-
const stat =
|
|
4050
|
+
const stat = import_node_fs5.default.fstatSync(fd);
|
|
3941
4051
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
3942
4052
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
3943
4053
|
}
|
|
@@ -3947,16 +4057,16 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
3947
4057
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
3948
4058
|
let offset = 0;
|
|
3949
4059
|
while (offset < bytes.length) {
|
|
3950
|
-
const count =
|
|
4060
|
+
const count = import_node_fs5.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
3951
4061
|
if (count === 0) break;
|
|
3952
4062
|
offset += count;
|
|
3953
4063
|
}
|
|
3954
|
-
if (offset !== stat.size ||
|
|
4064
|
+
if (offset !== stat.size || import_node_fs5.default.fstatSync(fd).size !== stat.size) {
|
|
3955
4065
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
3956
4066
|
}
|
|
3957
4067
|
return bytes.subarray(0, offset);
|
|
3958
4068
|
} finally {
|
|
3959
|
-
|
|
4069
|
+
import_node_fs5.default.closeSync(fd);
|
|
3960
4070
|
}
|
|
3961
4071
|
}
|
|
3962
4072
|
|
|
@@ -3994,8 +4104,8 @@ fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
|
3994
4104
|
function configStamp(files) {
|
|
3995
4105
|
return JSON.stringify(
|
|
3996
4106
|
files.map((file) => {
|
|
3997
|
-
if (!
|
|
3998
|
-
const stat =
|
|
4107
|
+
if (!import_node_fs6.default.existsSync(file)) return [file, null];
|
|
4108
|
+
const stat = import_node_fs6.default.statSync(file);
|
|
3999
4109
|
return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
|
|
4000
4110
|
})
|
|
4001
4111
|
);
|
|
@@ -4006,13 +4116,13 @@ async function readConfig(root) {
|
|
|
4006
4116
|
const reading = reads.get(root);
|
|
4007
4117
|
if (reading) return reading;
|
|
4008
4118
|
const promise = (async () => {
|
|
4009
|
-
(0,
|
|
4010
|
-
const cache =
|
|
4011
|
-
|
|
4012
|
-
const directory =
|
|
4013
|
-
const script =
|
|
4014
|
-
const result =
|
|
4015
|
-
|
|
4119
|
+
(0, import_node_module2.createRequire)(import_node_path6.default.join(root, "package.json")).resolve("one/vite");
|
|
4120
|
+
const cache = import_node_path6.default.join(root, "node_modules/.cache/peach-widget-config");
|
|
4121
|
+
import_node_fs6.default.mkdirSync(cache, { recursive: true });
|
|
4122
|
+
const directory = import_node_fs6.default.mkdtempSync(import_node_path6.default.join(cache, "read-"));
|
|
4123
|
+
const script = import_node_path6.default.join(directory, "read.mjs");
|
|
4124
|
+
const result = import_node_path6.default.join(directory, "result.json");
|
|
4125
|
+
import_node_fs6.default.writeFileSync(script, CONFIG_CHILD);
|
|
4016
4126
|
try {
|
|
4017
4127
|
await run(process.execPath, [script, result], {
|
|
4018
4128
|
cwd: root,
|
|
@@ -4020,7 +4130,7 @@ async function readConfig(root) {
|
|
|
4020
4130
|
timeout: 3e4,
|
|
4021
4131
|
maxBuffer: 1024 * 1024
|
|
4022
4132
|
});
|
|
4023
|
-
const value = JSON.parse(
|
|
4133
|
+
const value = JSON.parse(import_node_fs6.default.readFileSync(result, "utf8"));
|
|
4024
4134
|
if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
|
|
4025
4135
|
throw new Error("One config loader returned invalid dependencies");
|
|
4026
4136
|
if (!Array.isArray(value.urlSchemes) || !value.urlSchemes.every(
|
|
@@ -4043,20 +4153,20 @@ async function readConfig(root) {
|
|
|
4043
4153
|
}
|
|
4044
4154
|
const watched = [
|
|
4045
4155
|
.../* @__PURE__ */ new Set([
|
|
4046
|
-
|
|
4047
|
-
...value.watched.map((file) =>
|
|
4156
|
+
import_node_path6.default.join(root, "package.json"),
|
|
4157
|
+
...value.watched.map((file) => import_node_path6.default.resolve(root, file))
|
|
4048
4158
|
])
|
|
4049
4159
|
];
|
|
4050
|
-
const
|
|
4160
|
+
const loaded2 = {
|
|
4051
4161
|
widget,
|
|
4052
4162
|
urlSchemes: value.urlSchemes,
|
|
4053
4163
|
watched,
|
|
4054
4164
|
stamp: configStamp(watched)
|
|
4055
4165
|
};
|
|
4056
|
-
configs.set(root,
|
|
4057
|
-
return
|
|
4166
|
+
configs.set(root, loaded2);
|
|
4167
|
+
return loaded2;
|
|
4058
4168
|
} finally {
|
|
4059
|
-
|
|
4169
|
+
import_node_fs6.default.rmSync(directory, { recursive: true, force: true });
|
|
4060
4170
|
}
|
|
4061
4171
|
})();
|
|
4062
4172
|
reads.set(root, promise);
|
|
@@ -4077,13 +4187,13 @@ function declaredFamilies(source) {
|
|
|
4077
4187
|
return home;
|
|
4078
4188
|
}
|
|
4079
4189
|
async function readOneWidgetSources(appRoot) {
|
|
4080
|
-
const root =
|
|
4190
|
+
const root = import_node_fs6.default.realpathSync(appRoot);
|
|
4081
4191
|
const config = await readConfig(root);
|
|
4082
4192
|
if (!config.widget) return null;
|
|
4083
4193
|
const widget = config.widget;
|
|
4084
4194
|
const sourceFiles = {
|
|
4085
|
-
"OneWidget.swift":
|
|
4086
|
-
"OneWidgetContract.swift":
|
|
4195
|
+
"OneWidget.swift": import_node_path6.default.join(root, "ios/OneWidgets/OneWidget.swift"),
|
|
4196
|
+
"OneWidgetContract.swift": import_node_path6.default.join(
|
|
4087
4197
|
root,
|
|
4088
4198
|
"ios",
|
|
4089
4199
|
widget.appName,
|
|
@@ -4093,14 +4203,14 @@ async function readOneWidgetSources(appRoot) {
|
|
|
4093
4203
|
const files = /* @__PURE__ */ new Map();
|
|
4094
4204
|
const sources = {};
|
|
4095
4205
|
for (const [name, file] of Object.entries(sourceFiles)) {
|
|
4096
|
-
if (!
|
|
4206
|
+
if (!import_node_fs6.default.existsSync(file))
|
|
4097
4207
|
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
|
|
4098
4208
|
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
|
|
4099
4209
|
const text = bytes.toString("utf8");
|
|
4100
4210
|
if (!Buffer.from(text).equals(bytes))
|
|
4101
4211
|
throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
|
|
4102
4212
|
files.set(name, text);
|
|
4103
|
-
sources[
|
|
4213
|
+
sources[import_node_path6.default.relative(root, file).split(import_node_path6.default.sep).join("/")] = (0, import_node_crypto3.createHash)("sha256").update(bytes).digest("hex");
|
|
4104
4214
|
}
|
|
4105
4215
|
const contract = files.get("OneWidgetContract.swift") ?? "";
|
|
4106
4216
|
const source = files.get("OneWidget.swift") ?? "";
|
|
@@ -4124,60 +4234,13 @@ async function configuredOneWidget(appRoot, bundleUrl) {
|
|
|
4124
4234
|
return {
|
|
4125
4235
|
metadata: source.widget,
|
|
4126
4236
|
projectRoot: source.root,
|
|
4127
|
-
appIdentity: (0,
|
|
4237
|
+
appIdentity: (0, import_node_crypto3.createHash)("sha256").update(JSON.stringify([source.root, source.widget.bundleId])).digest("hex"),
|
|
4128
4238
|
bundleUrl,
|
|
4129
4239
|
packageUrl: new URL(`${SWIFT_PACKAGE_PATH}OneWidgets`, bundleUrl).href,
|
|
4130
4240
|
urlSchemes: source.urlSchemes
|
|
4131
4241
|
};
|
|
4132
4242
|
}
|
|
4133
4243
|
|
|
4134
|
-
// src/bundleGlobalFooter.ts
|
|
4135
|
-
function findBundleFooter(source, prefix) {
|
|
4136
|
-
let end = source.length;
|
|
4137
|
-
while (end > 0) {
|
|
4138
|
-
const newline = source.lastIndexOf("\n", end - 1);
|
|
4139
|
-
if (newline < 0) return -1;
|
|
4140
|
-
const line = newline + 1;
|
|
4141
|
-
if (source.startsWith(prefix, line)) return newline;
|
|
4142
|
-
if (!isFooterBlockLine(source, line, end)) return -1;
|
|
4143
|
-
end = newline;
|
|
4144
|
-
}
|
|
4145
|
-
return -1;
|
|
4146
|
-
}
|
|
4147
|
-
function isFooterBlockLine(source, line, end) {
|
|
4148
|
-
return line === end || source.startsWith("globalThis.", line) || source.startsWith("//", line);
|
|
4149
|
-
}
|
|
4150
|
-
function readFooter(source, prefix, suffix, name) {
|
|
4151
|
-
const start = findBundleFooter(source, prefix);
|
|
4152
|
-
if (start < 0) return null;
|
|
4153
|
-
const end = source.indexOf("\n", start + 1);
|
|
4154
|
-
const line = source.slice(start + 1, end < 0 ? void 0 : end);
|
|
4155
|
-
if (!line.endsWith(suffix)) throw new Error(`${name} footer is truncated`);
|
|
4156
|
-
const value = JSON.parse(
|
|
4157
|
-
line.slice(prefix.length, suffix ? -suffix.length : void 0)
|
|
4158
|
-
);
|
|
4159
|
-
if (value === null) throw new Error(`${name} footer has no metadata`);
|
|
4160
|
-
return value;
|
|
4161
|
-
}
|
|
4162
|
-
function detachFooter(source, prefix, suffix, name) {
|
|
4163
|
-
const start = findBundleFooter(source, prefix);
|
|
4164
|
-
if (start < 0) return { source, value: null };
|
|
4165
|
-
const value = readFooter(source, prefix, suffix, name);
|
|
4166
|
-
const end = source.indexOf("\n", start + 1);
|
|
4167
|
-
return { source: source.slice(0, start) + (end < 0 ? "" : source.slice(end)), value };
|
|
4168
|
-
}
|
|
4169
|
-
function insertBundleGlobalFooter(source, name, value) {
|
|
4170
|
-
return insertFooter(source, `globalThis.${name}=`, ";", name, value);
|
|
4171
|
-
}
|
|
4172
|
-
function insertFooter(source, prefix, suffix, name, value) {
|
|
4173
|
-
source = detachFooter(source, prefix, suffix, name).source;
|
|
4174
|
-
const json = JSON.stringify(value).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
|
|
4175
|
-
const footer = `
|
|
4176
|
-
${prefix}${json}${suffix}`;
|
|
4177
|
-
const identity = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
|
|
4178
|
-
return identity < 0 ? source + footer : source.slice(0, identity) + footer + source.slice(identity);
|
|
4179
|
-
}
|
|
4180
|
-
|
|
4181
4244
|
// src/packageVersionsContract.ts
|
|
4182
4245
|
var PACKAGE_VERSIONS_HEADER = "X-Peach-Package-Versions";
|
|
4183
4246
|
var FOOTER = "__peachPackageVersions";
|
|
@@ -4220,12 +4283,15 @@ function peachPlugin(options = {}) {
|
|
|
4220
4283
|
vxrnNative({ root, dev }) {
|
|
4221
4284
|
return {
|
|
4222
4285
|
name: "peach:package-versions",
|
|
4223
|
-
generateBundle(_options, bundle) {
|
|
4286
|
+
async generateBundle(_options, bundle) {
|
|
4224
4287
|
if (options.enabled === false || dev) return;
|
|
4225
4288
|
const versions = readInstalledNativePackageVersions(root);
|
|
4289
|
+
const { attachRolldownBundleInventory } = getCliRuntime().rolldown_bundle_inventory;
|
|
4226
4290
|
for (const output of Object.values(bundle)) {
|
|
4227
4291
|
if (output.type !== "chunk") continue;
|
|
4228
|
-
output.code =
|
|
4292
|
+
output.code = await attachRolldownBundleInventory(
|
|
4293
|
+
insertPackageVersionsFooter(output.code, versions)
|
|
4294
|
+
);
|
|
4229
4295
|
}
|
|
4230
4296
|
}
|
|
4231
4297
|
};
|
|
@@ -4244,6 +4310,135 @@ function peachPlugin(options = {}) {
|
|
|
4244
4310
|
},
|
|
4245
4311
|
async configureServer(server) {
|
|
4246
4312
|
if (options.enabled === false) return;
|
|
4313
|
+
server.middlewares.use((req, res, next) => {
|
|
4314
|
+
if (!(req.url ?? "").split("?")[0].endsWith(".bundle")) {
|
|
4315
|
+
next();
|
|
4316
|
+
return;
|
|
4317
|
+
}
|
|
4318
|
+
res.setHeader(
|
|
4319
|
+
PACKAGE_VERSIONS_HEADER,
|
|
4320
|
+
JSON.stringify(readInstalledNativePackageVersions(server.config.root))
|
|
4321
|
+
);
|
|
4322
|
+
exposeHeader(res, PACKAGE_VERSIONS_HEADER);
|
|
4323
|
+
res.setHeader(ROLLDOWN_INVENTORY_HEADER, "1");
|
|
4324
|
+
exposeHeader(res, ROLLDOWN_INVENTORY_HEADER);
|
|
4325
|
+
const origWriteHead = res.writeHead.bind(res);
|
|
4326
|
+
const origWrite = res.write.bind(res);
|
|
4327
|
+
const origEnd = res.end.bind(res);
|
|
4328
|
+
let pendingStatus;
|
|
4329
|
+
let pendingMessage;
|
|
4330
|
+
const flushHead = () => {
|
|
4331
|
+
if (pendingStatus !== void 0 && !res.headersSent) {
|
|
4332
|
+
const code = pendingStatus;
|
|
4333
|
+
const msg = pendingMessage;
|
|
4334
|
+
pendingStatus = void 0;
|
|
4335
|
+
pendingMessage = void 0;
|
|
4336
|
+
if (typeof msg === "string") origWriteHead(code, msg);
|
|
4337
|
+
else origWriteHead(code);
|
|
4338
|
+
}
|
|
4339
|
+
};
|
|
4340
|
+
Reflect.set(
|
|
4341
|
+
res,
|
|
4342
|
+
"writeHead",
|
|
4343
|
+
function(statusCode, statusMessage, headers) {
|
|
4344
|
+
pendingStatus = statusCode;
|
|
4345
|
+
res.statusCode = statusCode;
|
|
4346
|
+
if (typeof statusMessage === "string") pendingMessage = statusMessage;
|
|
4347
|
+
const hdrs = typeof statusMessage === "object" && statusMessage !== null ? statusMessage : headers;
|
|
4348
|
+
if (hdrs && typeof hdrs === "object" && !Array.isArray(hdrs)) {
|
|
4349
|
+
for (const [key, value] of Object.entries(hdrs)) {
|
|
4350
|
+
if (key.toLowerCase() === "content-length") continue;
|
|
4351
|
+
if (typeof value === "string" || typeof value === "number" || Array.isArray(value)) {
|
|
4352
|
+
res.setHeader(key, value);
|
|
4353
|
+
}
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
res.removeHeader("content-length");
|
|
4357
|
+
if (statusCode !== 200) res.removeHeader(ROLLDOWN_INVENTORY_HEADER);
|
|
4358
|
+
return res;
|
|
4359
|
+
}
|
|
4360
|
+
);
|
|
4361
|
+
const chunks = [];
|
|
4362
|
+
let buffering = false;
|
|
4363
|
+
const isBufferEncoding = (value) => typeof value === "string" && Buffer.isEncoding(value);
|
|
4364
|
+
const toBuffer = (chunk, encoding) => {
|
|
4365
|
+
if (chunk === void 0 || chunk === null || typeof chunk === "function")
|
|
4366
|
+
return null;
|
|
4367
|
+
if (Buffer.isBuffer(chunk)) return chunk;
|
|
4368
|
+
if (chunk instanceof Uint8Array) return Buffer.from(chunk);
|
|
4369
|
+
if (typeof chunk === "string")
|
|
4370
|
+
return Buffer.from(chunk, isBufferEncoding(encoding) ? encoding : "utf8");
|
|
4371
|
+
return null;
|
|
4372
|
+
};
|
|
4373
|
+
Reflect.set(res, "write", function(chunk, arg1) {
|
|
4374
|
+
const buf = toBuffer(chunk, arg1);
|
|
4375
|
+
if (!buf) {
|
|
4376
|
+
flushHead();
|
|
4377
|
+
return origWrite("");
|
|
4378
|
+
}
|
|
4379
|
+
if (!buffering) {
|
|
4380
|
+
const lower = buf.toString("utf8").toLowerCase();
|
|
4381
|
+
const contentType = String(res.getHeader("content-type") ?? "").toLowerCase();
|
|
4382
|
+
if (!contentType.includes("multipart/mixed") || lower.includes("content-type: text/javascript") || lower.includes("content-type: application/javascript")) {
|
|
4383
|
+
buffering = true;
|
|
4384
|
+
}
|
|
4385
|
+
}
|
|
4386
|
+
if (buffering) {
|
|
4387
|
+
chunks.push(buf);
|
|
4388
|
+
return true;
|
|
4389
|
+
}
|
|
4390
|
+
flushHead();
|
|
4391
|
+
return origWrite(buf);
|
|
4392
|
+
});
|
|
4393
|
+
Reflect.set(
|
|
4394
|
+
res,
|
|
4395
|
+
"end",
|
|
4396
|
+
function(chunk, arg1, arg2) {
|
|
4397
|
+
const callback = typeof chunk === "function" ? chunk : typeof arg1 === "function" ? arg1 : typeof arg2 === "function" ? arg2 : void 0;
|
|
4398
|
+
const finish = () => {
|
|
4399
|
+
flushHead();
|
|
4400
|
+
if (typeof callback === "function") {
|
|
4401
|
+
return origEnd(() => {
|
|
4402
|
+
Reflect.apply(callback, res, []);
|
|
4403
|
+
});
|
|
4404
|
+
}
|
|
4405
|
+
return origEnd();
|
|
4406
|
+
};
|
|
4407
|
+
const buf = toBuffer(chunk, arg1);
|
|
4408
|
+
if (buf) chunks.push(buf);
|
|
4409
|
+
if (chunks.length === 0 || res.statusCode && res.statusCode !== 200) {
|
|
4410
|
+
if (!res.headersSent) res.removeHeader(ROLLDOWN_INVENTORY_HEADER);
|
|
4411
|
+
flushHead();
|
|
4412
|
+
for (const queued of chunks) origWrite(queued);
|
|
4413
|
+
return finish();
|
|
4414
|
+
}
|
|
4415
|
+
const payload = Buffer.concat(chunks).toString("utf8");
|
|
4416
|
+
const contentType = String(res.getHeader("content-type") ?? "");
|
|
4417
|
+
void getCliRuntime().rolldown_bundle_inventory.attachRolldownBundleHttpPayload(
|
|
4418
|
+
payload,
|
|
4419
|
+
contentType
|
|
4420
|
+
).then((annotated) => {
|
|
4421
|
+
if (!res.headersSent) res.removeHeader("content-length");
|
|
4422
|
+
flushHead();
|
|
4423
|
+
origWrite(Buffer.from(annotated, "utf8"));
|
|
4424
|
+
finish();
|
|
4425
|
+
}).catch((error) => {
|
|
4426
|
+
console.error("[peach] failed to attach rolldown bundle inventory", error);
|
|
4427
|
+
if (!res.headersSent) {
|
|
4428
|
+
res.removeHeader("content-length");
|
|
4429
|
+
res.removeHeader(ROLLDOWN_INVENTORY_HEADER);
|
|
4430
|
+
}
|
|
4431
|
+
flushHead();
|
|
4432
|
+
origWrite(Buffer.from(payload, "utf8"));
|
|
4433
|
+
finish();
|
|
4434
|
+
});
|
|
4435
|
+
return res;
|
|
4436
|
+
}
|
|
4437
|
+
);
|
|
4438
|
+
next();
|
|
4439
|
+
});
|
|
4440
|
+
const bundleLayer = server.middlewares.stack.pop();
|
|
4441
|
+
if (bundleLayer) server.middlewares.stack.unshift(bundleLayer);
|
|
4247
4442
|
const { swiftPackageDirectories } = await import("vxrn");
|
|
4248
4443
|
let swiftPackages;
|
|
4249
4444
|
let swiftModuleRoot;
|
|
@@ -4431,7 +4626,7 @@ function peachPlugin(options = {}) {
|
|
|
4431
4626
|
});
|
|
4432
4627
|
const bundleUrl = options.bundleUrl || "/node_modules/one/metro-entry.bundle?platform=ios&dev=true&minify=false";
|
|
4433
4628
|
const appName = resolveRnxDesktopAppName(options.open, server.config.root);
|
|
4434
|
-
const replacementToken = (0,
|
|
4629
|
+
const replacementToken = (0, import_node_crypto4.randomUUID)();
|
|
4435
4630
|
const bundleForOrigin = (origin) => {
|
|
4436
4631
|
const fullBundleUrl = new URL(bundleUrl, `${origin}/`).toString();
|
|
4437
4632
|
return tagRnxBundleForPlugin(
|
|
@@ -4465,16 +4660,6 @@ function peachPlugin(options = {}) {
|
|
|
4465
4660
|
};
|
|
4466
4661
|
next();
|
|
4467
4662
|
});
|
|
4468
|
-
server.middlewares.use((req, res, next) => {
|
|
4469
|
-
if ((req.url ?? "").split("?")[0].endsWith(".bundle")) {
|
|
4470
|
-
res.setHeader(
|
|
4471
|
-
PACKAGE_VERSIONS_HEADER,
|
|
4472
|
-
JSON.stringify(readInstalledNativePackageVersions(server.config.root))
|
|
4473
|
-
);
|
|
4474
|
-
exposeHeader(res, PACKAGE_VERSIONS_HEADER);
|
|
4475
|
-
}
|
|
4476
|
-
next();
|
|
4477
|
-
});
|
|
4478
4663
|
server.middlewares.use(async (req, res, next) => {
|
|
4479
4664
|
if ((req.url || "").split("?")[0] !== "/__server-scan") return next();
|
|
4480
4665
|
const scanPort = listeningPort();
|