peachsim 0.1.796 → 0.1.798
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/cloud-test-tunnel.ts +1 -1
- package/cli/outbound-endpoints.ts +6 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.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 +383 -346
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +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/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +356 -326
- 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 +679 -565
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +401 -178
- 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 +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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +85 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +976 -842
- package/dist-lib/swift-compile.cjs +30 -5
- package/dist-lib/swift-compile.mjs +29 -5
- 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 +415 -358
- package/dist-lib/vite.cjs +240 -15
- package/package.json +1 -1
- package/scripts/dev-server-scanner.ts +16 -5
- package/src/expo-swift-host.ts +8 -4
- package/src/one-widget-discovery.ts +17 -0
- package/src/one-widget-metadata.ts +208 -0
- package/src/one-widget-package.ts +11 -165
- package/src/oneWidgetContract.ts +122 -0
- package/src/swift-compile.ts +31 -5
- package/src/swift-host.ts +2 -48
- package/src/swift-source-file.ts +48 -0
- package/src/vite-plugin-one.ts +18 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.798 | (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;
|
|
@@ -3816,8 +3816,8 @@ function metroIosAssetDestRelatives(httpServerLocation, filename) {
|
|
|
3816
3816
|
}
|
|
3817
3817
|
const out = [];
|
|
3818
3818
|
for (const dir of dirs) {
|
|
3819
|
-
const
|
|
3820
|
-
if (!out.includes(
|
|
3819
|
+
const path25 = `${dir}/${filename}`;
|
|
3820
|
+
if (!out.includes(path25)) out.push(path25);
|
|
3821
3821
|
}
|
|
3822
3822
|
if (!out.includes(filename)) out.push(filename);
|
|
3823
3823
|
return out;
|
|
@@ -4771,13 +4771,13 @@ function readFactoryStringLiterals(factory) {
|
|
|
4771
4771
|
return literals;
|
|
4772
4772
|
}
|
|
4773
4773
|
function normalizeFingerprintLiteral(literal) {
|
|
4774
|
-
const
|
|
4774
|
+
const path25 = literal.replaceAll("\\\\", "/").replaceAll("\\/", "/");
|
|
4775
4775
|
const nodeModulesMarker = "/node_modules/";
|
|
4776
|
-
const nodeModulesIndex =
|
|
4776
|
+
const nodeModulesIndex = path25.lastIndexOf(nodeModulesMarker);
|
|
4777
4777
|
if (nodeModulesIndex >= 0) {
|
|
4778
|
-
return `node_modules/${
|
|
4778
|
+
return `node_modules/${path25.slice(nodeModulesIndex + nodeModulesMarker.length)}`;
|
|
4779
4779
|
}
|
|
4780
|
-
if ((
|
|
4780
|
+
if ((path25.startsWith("/") || /^[A-Za-z]:\//.test(path25) || path25.startsWith("file:/")) && /\.[cm]?[jt]sx?(?::\d+(?::\d+)?)?$/.test(path25)) {
|
|
4781
4781
|
return null;
|
|
4782
4782
|
}
|
|
4783
4783
|
return literal;
|
|
@@ -5015,10 +5015,10 @@ function templateAssignment(template, embeddings) {
|
|
|
5015
5015
|
if (existingNode !== void 0 && existingNode !== nodeIndex) return null;
|
|
5016
5016
|
nodesByModuleId.set(moduleId, nodeIndex);
|
|
5017
5017
|
const node = template.nodes[nodeIndex];
|
|
5018
|
-
const
|
|
5018
|
+
const path25 = node.landmarkPath ?? `node_modules/${template.packageName}/__rnx_inferred__/${moduleId}.js`;
|
|
5019
5019
|
const existingPath = pathsByModuleId.get(moduleId);
|
|
5020
|
-
if (existingPath !== void 0 && existingPath !==
|
|
5021
|
-
pathsByModuleId.set(moduleId,
|
|
5020
|
+
if (existingPath !== void 0 && existingPath !== path25) return null;
|
|
5021
|
+
pathsByModuleId.set(moduleId, path25);
|
|
5022
5022
|
}
|
|
5023
5023
|
}
|
|
5024
5024
|
return {
|
|
@@ -5180,14 +5180,14 @@ async function inferMetroModuleIdentity(args) {
|
|
|
5180
5180
|
const packageClaims = claimsByPackage.values().next().value;
|
|
5181
5181
|
if (!packageClaims) continue;
|
|
5182
5182
|
const exactClaims = packageClaims.filter((assignment2) => {
|
|
5183
|
-
const
|
|
5184
|
-
return
|
|
5183
|
+
const path25 = assignment2.pathsByModuleId.get(moduleId);
|
|
5184
|
+
return path25 !== void 0 && !path25.includes("/__rnx_inferred__/");
|
|
5185
5185
|
});
|
|
5186
5186
|
const preferredClaims = exactClaims.length > 0 ? exactClaims : packageClaims;
|
|
5187
5187
|
const routes = new Set(
|
|
5188
5188
|
preferredClaims.flatMap((assignment2) => {
|
|
5189
|
-
const
|
|
5190
|
-
return
|
|
5189
|
+
const path25 = assignment2.pathsByModuleId.get(moduleId);
|
|
5190
|
+
return path25 ? [metroFingerprintModuleClaimRoute(assignment2.packageName, path25)] : [];
|
|
5191
5191
|
})
|
|
5192
5192
|
);
|
|
5193
5193
|
if (routes.size !== 1) continue;
|
|
@@ -5430,17 +5430,17 @@ function visit(node, visitor) {
|
|
|
5430
5430
|
} else
|
|
5431
5431
|
visit_(null, node, visitor_, Object.freeze([]));
|
|
5432
5432
|
}
|
|
5433
|
-
function visit_(key2, node, visitor,
|
|
5434
|
-
const ctrl = callVisitor(key2, node, visitor,
|
|
5433
|
+
function visit_(key2, node, visitor, path25) {
|
|
5434
|
+
const ctrl = callVisitor(key2, node, visitor, path25);
|
|
5435
5435
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
5436
|
-
replaceNode(key2,
|
|
5437
|
-
return visit_(key2, ctrl, visitor,
|
|
5436
|
+
replaceNode(key2, path25, ctrl);
|
|
5437
|
+
return visit_(key2, ctrl, visitor, path25);
|
|
5438
5438
|
}
|
|
5439
5439
|
if (typeof ctrl !== "symbol") {
|
|
5440
5440
|
if (isCollection(node)) {
|
|
5441
|
-
|
|
5441
|
+
path25 = Object.freeze(path25.concat(node));
|
|
5442
5442
|
for (let i = 0; i < node.items.length; ++i) {
|
|
5443
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
5443
|
+
const ci = visit_(i, node.items[i], visitor, path25);
|
|
5444
5444
|
if (typeof ci === "number")
|
|
5445
5445
|
i = ci - 1;
|
|
5446
5446
|
else if (ci === BREAK)
|
|
@@ -5451,13 +5451,13 @@ function visit_(key2, node, visitor, path24) {
|
|
|
5451
5451
|
}
|
|
5452
5452
|
}
|
|
5453
5453
|
} else if (isPair(node)) {
|
|
5454
|
-
|
|
5455
|
-
const ck = visit_("key", node.key, visitor,
|
|
5454
|
+
path25 = Object.freeze(path25.concat(node));
|
|
5455
|
+
const ck = visit_("key", node.key, visitor, path25);
|
|
5456
5456
|
if (ck === BREAK)
|
|
5457
5457
|
return BREAK;
|
|
5458
5458
|
else if (ck === REMOVE)
|
|
5459
5459
|
node.key = null;
|
|
5460
|
-
const cv = visit_("value", node.value, visitor,
|
|
5460
|
+
const cv = visit_("value", node.value, visitor, path25);
|
|
5461
5461
|
if (cv === BREAK)
|
|
5462
5462
|
return BREAK;
|
|
5463
5463
|
else if (cv === REMOVE)
|
|
@@ -5475,17 +5475,17 @@ async function visitAsync(node, visitor) {
|
|
|
5475
5475
|
} else
|
|
5476
5476
|
await visitAsync_(null, node, visitor_, Object.freeze([]));
|
|
5477
5477
|
}
|
|
5478
|
-
async function visitAsync_(key2, node, visitor,
|
|
5479
|
-
const ctrl = await callVisitor(key2, node, visitor,
|
|
5478
|
+
async function visitAsync_(key2, node, visitor, path25) {
|
|
5479
|
+
const ctrl = await callVisitor(key2, node, visitor, path25);
|
|
5480
5480
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
5481
|
-
replaceNode(key2,
|
|
5482
|
-
return visitAsync_(key2, ctrl, visitor,
|
|
5481
|
+
replaceNode(key2, path25, ctrl);
|
|
5482
|
+
return visitAsync_(key2, ctrl, visitor, path25);
|
|
5483
5483
|
}
|
|
5484
5484
|
if (typeof ctrl !== "symbol") {
|
|
5485
5485
|
if (isCollection(node)) {
|
|
5486
|
-
|
|
5486
|
+
path25 = Object.freeze(path25.concat(node));
|
|
5487
5487
|
for (let i = 0; i < node.items.length; ++i) {
|
|
5488
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
5488
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path25);
|
|
5489
5489
|
if (typeof ci === "number")
|
|
5490
5490
|
i = ci - 1;
|
|
5491
5491
|
else if (ci === BREAK)
|
|
@@ -5496,13 +5496,13 @@ async function visitAsync_(key2, node, visitor, path24) {
|
|
|
5496
5496
|
}
|
|
5497
5497
|
}
|
|
5498
5498
|
} else if (isPair(node)) {
|
|
5499
|
-
|
|
5500
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
5499
|
+
path25 = Object.freeze(path25.concat(node));
|
|
5500
|
+
const ck = await visitAsync_("key", node.key, visitor, path25);
|
|
5501
5501
|
if (ck === BREAK)
|
|
5502
5502
|
return BREAK;
|
|
5503
5503
|
else if (ck === REMOVE)
|
|
5504
5504
|
node.key = null;
|
|
5505
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
5505
|
+
const cv = await visitAsync_("value", node.value, visitor, path25);
|
|
5506
5506
|
if (cv === BREAK)
|
|
5507
5507
|
return BREAK;
|
|
5508
5508
|
else if (cv === REMOVE)
|
|
@@ -5529,23 +5529,23 @@ function initVisitor(visitor) {
|
|
|
5529
5529
|
}
|
|
5530
5530
|
return visitor;
|
|
5531
5531
|
}
|
|
5532
|
-
function callVisitor(key2, node, visitor,
|
|
5532
|
+
function callVisitor(key2, node, visitor, path25) {
|
|
5533
5533
|
if (typeof visitor === "function")
|
|
5534
|
-
return visitor(key2, node,
|
|
5534
|
+
return visitor(key2, node, path25);
|
|
5535
5535
|
if (isMap(node))
|
|
5536
|
-
return visitor.Map?.(key2, node,
|
|
5536
|
+
return visitor.Map?.(key2, node, path25);
|
|
5537
5537
|
if (isSeq(node))
|
|
5538
|
-
return visitor.Seq?.(key2, node,
|
|
5538
|
+
return visitor.Seq?.(key2, node, path25);
|
|
5539
5539
|
if (isPair(node))
|
|
5540
|
-
return visitor.Pair?.(key2, node,
|
|
5540
|
+
return visitor.Pair?.(key2, node, path25);
|
|
5541
5541
|
if (isScalar(node))
|
|
5542
|
-
return visitor.Scalar?.(key2, node,
|
|
5542
|
+
return visitor.Scalar?.(key2, node, path25);
|
|
5543
5543
|
if (isAlias(node))
|
|
5544
|
-
return visitor.Alias?.(key2, node,
|
|
5544
|
+
return visitor.Alias?.(key2, node, path25);
|
|
5545
5545
|
return void 0;
|
|
5546
5546
|
}
|
|
5547
|
-
function replaceNode(key2,
|
|
5548
|
-
const parent =
|
|
5547
|
+
function replaceNode(key2, path25, node) {
|
|
5548
|
+
const parent = path25[path25.length - 1];
|
|
5549
5549
|
if (isCollection(parent)) {
|
|
5550
5550
|
parent.items[key2] = node;
|
|
5551
5551
|
} else if (isPair(parent)) {
|
|
@@ -6096,10 +6096,10 @@ var init_createNode = __esm({
|
|
|
6096
6096
|
});
|
|
6097
6097
|
|
|
6098
6098
|
// ../../node_modules/yaml/browser/dist/nodes/Collection.js
|
|
6099
|
-
function collectionFromPath(schema4,
|
|
6099
|
+
function collectionFromPath(schema4, path25, value) {
|
|
6100
6100
|
let v = value;
|
|
6101
|
-
for (let i =
|
|
6102
|
-
const k =
|
|
6101
|
+
for (let i = path25.length - 1; i >= 0; --i) {
|
|
6102
|
+
const k = path25[i];
|
|
6103
6103
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
6104
6104
|
const a = [];
|
|
6105
6105
|
a[k] = v;
|
|
@@ -6124,7 +6124,7 @@ var init_Collection = __esm({
|
|
|
6124
6124
|
init_createNode();
|
|
6125
6125
|
init_identity();
|
|
6126
6126
|
init_Node();
|
|
6127
|
-
isEmptyPath = (
|
|
6127
|
+
isEmptyPath = (path25) => path25 == null || typeof path25 === "object" && !!path25[Symbol.iterator]().next().done;
|
|
6128
6128
|
Collection = class extends NodeBase {
|
|
6129
6129
|
constructor(type, schema4) {
|
|
6130
6130
|
super(type);
|
|
@@ -6154,11 +6154,11 @@ var init_Collection = __esm({
|
|
|
6154
6154
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
6155
6155
|
* that already exists in the map.
|
|
6156
6156
|
*/
|
|
6157
|
-
addIn(
|
|
6158
|
-
if (isEmptyPath(
|
|
6157
|
+
addIn(path25, value) {
|
|
6158
|
+
if (isEmptyPath(path25))
|
|
6159
6159
|
this.add(value);
|
|
6160
6160
|
else {
|
|
6161
|
-
const [key2, ...rest] =
|
|
6161
|
+
const [key2, ...rest] = path25;
|
|
6162
6162
|
const node = this.get(key2, true);
|
|
6163
6163
|
if (isCollection(node))
|
|
6164
6164
|
node.addIn(rest, value);
|
|
@@ -6172,8 +6172,8 @@ var init_Collection = __esm({
|
|
|
6172
6172
|
* Removes a value from the collection.
|
|
6173
6173
|
* @returns `true` if the item was found and removed.
|
|
6174
6174
|
*/
|
|
6175
|
-
deleteIn(
|
|
6176
|
-
const [key2, ...rest] =
|
|
6175
|
+
deleteIn(path25) {
|
|
6176
|
+
const [key2, ...rest] = path25;
|
|
6177
6177
|
if (rest.length === 0)
|
|
6178
6178
|
return this.delete(key2);
|
|
6179
6179
|
const node = this.get(key2, true);
|
|
@@ -6187,8 +6187,8 @@ var init_Collection = __esm({
|
|
|
6187
6187
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
6188
6188
|
* `true` (collections are always returned intact).
|
|
6189
6189
|
*/
|
|
6190
|
-
getIn(
|
|
6191
|
-
const [key2, ...rest] =
|
|
6190
|
+
getIn(path25, keepScalar) {
|
|
6191
|
+
const [key2, ...rest] = path25;
|
|
6192
6192
|
const node = this.get(key2, true);
|
|
6193
6193
|
if (rest.length === 0)
|
|
6194
6194
|
return !keepScalar && isScalar(node) ? node.value : node;
|
|
@@ -6206,8 +6206,8 @@ var init_Collection = __esm({
|
|
|
6206
6206
|
/**
|
|
6207
6207
|
* Checks if the collection includes a value with the key `key`.
|
|
6208
6208
|
*/
|
|
6209
|
-
hasIn(
|
|
6210
|
-
const [key2, ...rest] =
|
|
6209
|
+
hasIn(path25) {
|
|
6210
|
+
const [key2, ...rest] = path25;
|
|
6211
6211
|
if (rest.length === 0)
|
|
6212
6212
|
return this.has(key2);
|
|
6213
6213
|
const node = this.get(key2, true);
|
|
@@ -6217,8 +6217,8 @@ var init_Collection = __esm({
|
|
|
6217
6217
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
6218
6218
|
* boolean to add/remove the item from the set.
|
|
6219
6219
|
*/
|
|
6220
|
-
setIn(
|
|
6221
|
-
const [key2, ...rest] =
|
|
6220
|
+
setIn(path25, value) {
|
|
6221
|
+
const [key2, ...rest] = path25;
|
|
6222
6222
|
if (rest.length === 0) {
|
|
6223
6223
|
this.set(key2, value);
|
|
6224
6224
|
} else {
|
|
@@ -8137,15 +8137,15 @@ function visit2(cst, visitor) {
|
|
|
8137
8137
|
cst = { start: cst.start, value: cst.value };
|
|
8138
8138
|
_visit(Object.freeze([]), cst, visitor);
|
|
8139
8139
|
}
|
|
8140
|
-
function _visit(
|
|
8141
|
-
let ctrl = visitor(item,
|
|
8140
|
+
function _visit(path25, item, visitor) {
|
|
8141
|
+
let ctrl = visitor(item, path25);
|
|
8142
8142
|
if (typeof ctrl === "symbol")
|
|
8143
8143
|
return ctrl;
|
|
8144
8144
|
for (const field of ["key", "value"]) {
|
|
8145
8145
|
const token = item[field];
|
|
8146
8146
|
if (token && "items" in token) {
|
|
8147
8147
|
for (let i = 0; i < token.items.length; ++i) {
|
|
8148
|
-
const ci = _visit(Object.freeze(
|
|
8148
|
+
const ci = _visit(Object.freeze(path25.concat([[field, i]])), token.items[i], visitor);
|
|
8149
8149
|
if (typeof ci === "number")
|
|
8150
8150
|
i = ci - 1;
|
|
8151
8151
|
else if (ci === BREAK2)
|
|
@@ -8156,10 +8156,10 @@ function _visit(path24, item, visitor) {
|
|
|
8156
8156
|
}
|
|
8157
8157
|
}
|
|
8158
8158
|
if (typeof ctrl === "function" && field === "key")
|
|
8159
|
-
ctrl = ctrl(item,
|
|
8159
|
+
ctrl = ctrl(item, path25);
|
|
8160
8160
|
}
|
|
8161
8161
|
}
|
|
8162
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
8162
|
+
return typeof ctrl === "function" ? ctrl(item, path25) : ctrl;
|
|
8163
8163
|
}
|
|
8164
8164
|
var BREAK2, SKIP2, REMOVE2;
|
|
8165
8165
|
var init_cst_visit = __esm({
|
|
@@ -8170,9 +8170,9 @@ var init_cst_visit = __esm({
|
|
|
8170
8170
|
visit2.BREAK = BREAK2;
|
|
8171
8171
|
visit2.SKIP = SKIP2;
|
|
8172
8172
|
visit2.REMOVE = REMOVE2;
|
|
8173
|
-
visit2.itemAtPath = (cst,
|
|
8173
|
+
visit2.itemAtPath = (cst, path25) => {
|
|
8174
8174
|
let item = cst;
|
|
8175
|
-
for (const [field, index] of
|
|
8175
|
+
for (const [field, index] of path25) {
|
|
8176
8176
|
const tok = item?.[field];
|
|
8177
8177
|
if (tok && "items" in tok) {
|
|
8178
8178
|
item = tok.items[index];
|
|
@@ -8181,9 +8181,9 @@ var init_cst_visit = __esm({
|
|
|
8181
8181
|
}
|
|
8182
8182
|
return item;
|
|
8183
8183
|
};
|
|
8184
|
-
visit2.parentCollection = (cst,
|
|
8185
|
-
const parent = visit2.itemAtPath(cst,
|
|
8186
|
-
const field =
|
|
8184
|
+
visit2.parentCollection = (cst, path25) => {
|
|
8185
|
+
const parent = visit2.itemAtPath(cst, path25.slice(0, -1));
|
|
8186
|
+
const field = path25[path25.length - 1][0];
|
|
8187
8187
|
const coll = parent?.[field];
|
|
8188
8188
|
if (coll && "items" in coll)
|
|
8189
8189
|
return coll;
|
|
@@ -8278,8 +8278,8 @@ function detectFramework(deps) {
|
|
|
8278
8278
|
return "unknown";
|
|
8279
8279
|
}
|
|
8280
8280
|
function detectProject(dir) {
|
|
8281
|
-
const pkgPath = (0,
|
|
8282
|
-
if (!(0,
|
|
8281
|
+
const pkgPath = (0, import_node_path29.join)(dir, "package.json");
|
|
8282
|
+
if (!(0, import_node_fs28.existsSync)(pkgPath)) return null;
|
|
8283
8283
|
const pkg = readProjectManifest(dir);
|
|
8284
8284
|
if (!pkg) return null;
|
|
8285
8285
|
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -8291,25 +8291,25 @@ function detectProject(dir) {
|
|
|
8291
8291
|
if (framework === "unknown") return null;
|
|
8292
8292
|
return {
|
|
8293
8293
|
dir,
|
|
8294
|
-
name: pkg.name || (0,
|
|
8294
|
+
name: pkg.name || (0, import_node_path29.basename)(dir),
|
|
8295
8295
|
framework,
|
|
8296
8296
|
// a config file is a config file whatever module system it declares. real
|
|
8297
8297
|
// apps write .cjs as often as .js, and missing one reads as "this project
|
|
8298
8298
|
// has no bundler config" and sends the user to create a second one.
|
|
8299
8299
|
hasViteConfig: CONFIG_EXTENSIONS.some(
|
|
8300
|
-
(ext) => (0,
|
|
8300
|
+
(ext) => (0, import_node_fs28.existsSync)((0, import_node_path29.join)(dir, `vite.config.${ext}`))
|
|
8301
8301
|
),
|
|
8302
8302
|
hasMetroConfig: CONFIG_EXTENSIONS.some(
|
|
8303
|
-
(ext) => (0,
|
|
8303
|
+
(ext) => (0, import_node_fs28.existsSync)((0, import_node_path29.join)(dir, `metro.config.${ext}`))
|
|
8304
8304
|
),
|
|
8305
8305
|
devCommand: typeof devCommand === "string" ? devCommand : null
|
|
8306
8306
|
};
|
|
8307
8307
|
}
|
|
8308
|
-
function readProjectMetadata(
|
|
8308
|
+
function readProjectMetadata(path25) {
|
|
8309
8309
|
try {
|
|
8310
|
-
const info = (0,
|
|
8310
|
+
const info = (0, import_node_fs28.lstatSync)(path25);
|
|
8311
8311
|
if (!info.isFile() || info.size > 4 * 1024 * 1024) return null;
|
|
8312
|
-
return (0,
|
|
8312
|
+
return (0, import_node_fs28.readFileSync)(path25, "utf8");
|
|
8313
8313
|
} catch {
|
|
8314
8314
|
return null;
|
|
8315
8315
|
}
|
|
@@ -8318,8 +8318,8 @@ function metadataValue(value, key2) {
|
|
|
8318
8318
|
if (!value || typeof value !== "object") return void 0;
|
|
8319
8319
|
return Object.getOwnPropertyDescriptor(value, key2)?.value;
|
|
8320
8320
|
}
|
|
8321
|
-
function readProjectJson(
|
|
8322
|
-
const text3 = readProjectMetadata(
|
|
8321
|
+
function readProjectJson(path25) {
|
|
8322
|
+
const text3 = readProjectMetadata(path25);
|
|
8323
8323
|
if (text3 === null) return null;
|
|
8324
8324
|
try {
|
|
8325
8325
|
const value = JSON.parse(text3);
|
|
@@ -8329,7 +8329,7 @@ function readProjectJson(path24) {
|
|
|
8329
8329
|
}
|
|
8330
8330
|
}
|
|
8331
8331
|
function readProjectManifest(dir) {
|
|
8332
|
-
const parsed = readProjectJson((0,
|
|
8332
|
+
const parsed = readProjectJson((0, import_node_path29.join)(dir, "package.json"));
|
|
8333
8333
|
if (!parsed || typeof parsed !== "object") return null;
|
|
8334
8334
|
const record2 = (value) => {
|
|
8335
8335
|
if (!value || typeof value !== "object") return {};
|
|
@@ -8346,12 +8346,12 @@ function readProjectManifest(dir) {
|
|
|
8346
8346
|
devDependencies: record2(metadataValue(parsed, "devDependencies"))
|
|
8347
8347
|
};
|
|
8348
8348
|
}
|
|
8349
|
-
var
|
|
8349
|
+
var import_node_fs28, import_node_path29, import_json52, CONFIG_EXTENSIONS;
|
|
8350
8350
|
var init_detect = __esm({
|
|
8351
8351
|
"cli/commands/detect.ts"() {
|
|
8352
8352
|
"use strict";
|
|
8353
|
-
|
|
8354
|
-
|
|
8353
|
+
import_node_fs28 = require("node:fs");
|
|
8354
|
+
import_node_path29 = require("node:path");
|
|
8355
8355
|
import_json52 = __toESM(require_lib(), 1);
|
|
8356
8356
|
init_browser();
|
|
8357
8357
|
CONFIG_EXTENSIONS = ["ts", "js", "cjs", "mjs", "mts", "cts"];
|
|
@@ -8388,21 +8388,21 @@ function resolveCloudOrigin(value) {
|
|
|
8388
8388
|
return normalizeCloudOrigin(source);
|
|
8389
8389
|
}
|
|
8390
8390
|
function readImmutableBundleSource(bundlePath) {
|
|
8391
|
-
const filepath = (0,
|
|
8392
|
-
if ((0,
|
|
8391
|
+
const filepath = (0, import_node_path30.resolve)(bundlePath);
|
|
8392
|
+
if ((0, import_node_path30.extname)(filepath) !== ".js") {
|
|
8393
8393
|
throw new Error(`${REMOTE_COMMAND} requires one local Metro .js bundle`);
|
|
8394
8394
|
}
|
|
8395
|
-
const descriptor = (0,
|
|
8395
|
+
const descriptor = (0, import_node_fs29.openSync)(filepath, "r");
|
|
8396
8396
|
try {
|
|
8397
|
-
const before = (0,
|
|
8397
|
+
const before = (0, import_node_fs29.fstatSync)(descriptor, { bigint: true });
|
|
8398
8398
|
if (!before.isFile()) {
|
|
8399
8399
|
throw new Error(`${REMOTE_COMMAND} bundle must be a regular local file`);
|
|
8400
8400
|
}
|
|
8401
8401
|
if (before.size <= 0n) {
|
|
8402
8402
|
throw new Error(`${REMOTE_COMMAND} bundle is empty`);
|
|
8403
8403
|
}
|
|
8404
|
-
const bytes = (0,
|
|
8405
|
-
const after = (0,
|
|
8404
|
+
const bytes = (0, import_node_fs29.readFileSync)(descriptor);
|
|
8405
|
+
const after = (0, import_node_fs29.fstatSync)(descriptor, { bigint: true });
|
|
8406
8406
|
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeNs !== after.mtimeNs || bytes.length !== Number(before.size)) {
|
|
8407
8407
|
throw new Error(`${REMOTE_COMMAND} bundle changed while it was being read`);
|
|
8408
8408
|
}
|
|
@@ -8417,7 +8417,7 @@ function readImmutableBundleSource(bundlePath) {
|
|
|
8417
8417
|
}
|
|
8418
8418
|
return source;
|
|
8419
8419
|
} finally {
|
|
8420
|
-
(0,
|
|
8420
|
+
(0, import_node_fs29.closeSync)(descriptor);
|
|
8421
8421
|
}
|
|
8422
8422
|
}
|
|
8423
8423
|
async function fetchBundleSource(bundleUrl) {
|
|
@@ -8464,15 +8464,15 @@ async function loadBundleSource(bundleInput) {
|
|
|
8464
8464
|
return readImmutableBundleSource(bundleInput);
|
|
8465
8465
|
}
|
|
8466
8466
|
function listMetroAssetDest(assetsPath) {
|
|
8467
|
-
const directory = (0,
|
|
8468
|
-
if (!(0,
|
|
8469
|
-
const skipNested = (0,
|
|
8467
|
+
const directory = (0, import_node_path30.resolve)(assetsPath);
|
|
8468
|
+
if (!(0, import_node_fs29.existsSync)(directory)) return { directory, files: [], truncated: false };
|
|
8469
|
+
const skipNested = (0, import_node_fs29.existsSync)((0, import_node_path30.join)(directory, "package.json"));
|
|
8470
8470
|
const files2 = [];
|
|
8471
8471
|
let truncated = false;
|
|
8472
8472
|
const walk2 = (dir, prefix) => {
|
|
8473
8473
|
let entries;
|
|
8474
8474
|
try {
|
|
8475
|
-
entries = (0,
|
|
8475
|
+
entries = (0, import_node_fs29.readdirSync)(dir, { withFileTypes: true });
|
|
8476
8476
|
} catch {
|
|
8477
8477
|
return;
|
|
8478
8478
|
}
|
|
@@ -8484,7 +8484,7 @@ function listMetroAssetDest(assetsPath) {
|
|
|
8484
8484
|
if (entry.isDirectory()) {
|
|
8485
8485
|
if (entry.name === ".git") continue;
|
|
8486
8486
|
if (skipNested && PROJECT_ONLY_DIRECTORIES.has(entry.name)) continue;
|
|
8487
|
-
walk2((0,
|
|
8487
|
+
walk2((0, import_node_path30.join)(dir, entry.name), prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
8488
8488
|
} else if (entry.isFile()) {
|
|
8489
8489
|
files2.push(prefix ? `${prefix}/${entry.name}` : entry.name);
|
|
8490
8490
|
}
|
|
@@ -8519,7 +8519,7 @@ function distinctByContent(directory, options) {
|
|
|
8519
8519
|
for (const relative2 of options) {
|
|
8520
8520
|
let bytes;
|
|
8521
8521
|
try {
|
|
8522
|
-
bytes = (0,
|
|
8522
|
+
bytes = (0, import_node_fs29.readFileSync)((0, import_node_path30.join)(directory, relative2));
|
|
8523
8523
|
} catch {
|
|
8524
8524
|
continue;
|
|
8525
8525
|
}
|
|
@@ -8551,7 +8551,7 @@ function placeMetroDescriptor(listing, descriptor) {
|
|
|
8551
8551
|
let bytes;
|
|
8552
8552
|
try {
|
|
8553
8553
|
bytes = combination.map(
|
|
8554
|
-
(relative2) => (0,
|
|
8554
|
+
(relative2) => (0, import_node_fs29.readFileSync)((0, import_node_path30.join)(listing.directory, relative2))
|
|
8555
8555
|
);
|
|
8556
8556
|
} catch {
|
|
8557
8557
|
continue;
|
|
@@ -8579,10 +8579,10 @@ function unverifiedContentKey(dest, fileDigests) {
|
|
|
8579
8579
|
return JSON.stringify(
|
|
8580
8580
|
dest.placements.map(
|
|
8581
8581
|
(placement) => placement.verified ? null : [...placement.files].map(([scale, relative2]) => {
|
|
8582
|
-
const file = (0,
|
|
8582
|
+
const file = (0, import_node_path30.join)(dest.directory, relative2);
|
|
8583
8583
|
let digest = fileDigests.get(file);
|
|
8584
8584
|
if (digest === void 0) {
|
|
8585
|
-
digest = (0, import_node_crypto14.createHash)("sha256").update((0,
|
|
8585
|
+
digest = (0, import_node_crypto14.createHash)("sha256").update((0, import_node_fs29.readFileSync)(file)).digest("hex");
|
|
8586
8586
|
fileDigests.set(file, digest);
|
|
8587
8587
|
}
|
|
8588
8588
|
return [scale, digest];
|
|
@@ -8591,22 +8591,22 @@ function unverifiedContentKey(dest, fileDigests) {
|
|
|
8591
8591
|
);
|
|
8592
8592
|
}
|
|
8593
8593
|
function searchMetroAssetDest(bundlePath, descriptors) {
|
|
8594
|
-
const bundleDirectory = (0,
|
|
8594
|
+
const bundleDirectory = (0, import_node_path30.dirname)((0, import_node_path30.resolve)(bundlePath));
|
|
8595
8595
|
const candidates = [
|
|
8596
|
-
(0,
|
|
8596
|
+
(0, import_node_path30.join)(bundleDirectory, "assets"),
|
|
8597
8597
|
bundleDirectory,
|
|
8598
|
-
(0,
|
|
8598
|
+
(0, import_node_path30.resolve)(bundleDirectory, "..", "assets")
|
|
8599
8599
|
];
|
|
8600
8600
|
const cwd = process.cwd();
|
|
8601
8601
|
let projectDirectory = null;
|
|
8602
8602
|
for (const start of [bundleDirectory, cwd]) {
|
|
8603
|
-
let directory = (0,
|
|
8603
|
+
let directory = (0, import_node_path30.resolve)(start);
|
|
8604
8604
|
while (true) {
|
|
8605
8605
|
if (detectProject(directory)?.hasMetroConfig) {
|
|
8606
8606
|
projectDirectory = directory;
|
|
8607
8607
|
break;
|
|
8608
8608
|
}
|
|
8609
|
-
const parent = (0,
|
|
8609
|
+
const parent = (0, import_node_path30.dirname)(directory);
|
|
8610
8610
|
if (parent === directory) break;
|
|
8611
8611
|
directory = parent;
|
|
8612
8612
|
}
|
|
@@ -8614,11 +8614,11 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
8614
8614
|
}
|
|
8615
8615
|
if (projectDirectory) {
|
|
8616
8616
|
candidates.push(
|
|
8617
|
-
(0,
|
|
8618
|
-
(0,
|
|
8619
|
-
(0,
|
|
8620
|
-
(0,
|
|
8621
|
-
(0,
|
|
8617
|
+
(0, import_node_path30.join)(projectDirectory, "assets"),
|
|
8618
|
+
(0, import_node_path30.join)(projectDirectory, "dist"),
|
|
8619
|
+
(0, import_node_path30.join)(projectDirectory, "dist", "assets"),
|
|
8620
|
+
(0, import_node_path30.join)(projectDirectory, "build"),
|
|
8621
|
+
(0, import_node_path30.join)(projectDirectory, "build", "assets")
|
|
8622
8622
|
);
|
|
8623
8623
|
}
|
|
8624
8624
|
const searched = [];
|
|
@@ -8626,7 +8626,7 @@ function searchMetroAssetDest(bundlePath, descriptors) {
|
|
|
8626
8626
|
const stale = [];
|
|
8627
8627
|
let truncated = false;
|
|
8628
8628
|
for (const candidate of candidates) {
|
|
8629
|
-
const directory = (0,
|
|
8629
|
+
const directory = (0, import_node_path30.resolve)(candidate);
|
|
8630
8630
|
if (searched.includes(directory)) continue;
|
|
8631
8631
|
searched.push(directory);
|
|
8632
8632
|
const listing = listMetroAssetDest(directory);
|
|
@@ -8735,7 +8735,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
8735
8735
|
);
|
|
8736
8736
|
}
|
|
8737
8737
|
const relative2 = placement?.files.get(variant.scale);
|
|
8738
|
-
if (relative2 && dest) return (0,
|
|
8738
|
+
if (relative2 && dest) return (0, import_node_fs29.readFileSync)((0, import_node_path30.join)(dest.directory, relative2));
|
|
8739
8739
|
if (placement && placement.files.size > 0) return null;
|
|
8740
8740
|
if (placement && placement.ambiguous.length > 0 && dest) {
|
|
8741
8741
|
throw new Error(
|
|
@@ -8764,7 +8764,7 @@ async function embedBundleAssets(bundlePath, command, assetPolicy) {
|
|
|
8764
8764
|
);
|
|
8765
8765
|
const classic = metroIosAssetDestRelatives(variant.descriptor.httpServerLocation, filename)[0] ?? filename;
|
|
8766
8766
|
throw new Error(
|
|
8767
|
-
`${command} could not read ${(0,
|
|
8767
|
+
`${command} could not read ${(0, import_node_path30.join)(dest?.directory ?? ".", classic)} for ${variant.descriptor.name}.${variant.descriptor.type} at scale ${variant.scale}, and has no stand-in for a .${variant.descriptor.type} asset. Rebuild with \`react-native bundle --assets-dest\`.`
|
|
8768
8768
|
);
|
|
8769
8769
|
});
|
|
8770
8770
|
return {
|
|
@@ -8910,13 +8910,13 @@ async function createCloudBox(options) {
|
|
|
8910
8910
|
warnings: artifact.warnings
|
|
8911
8911
|
};
|
|
8912
8912
|
}
|
|
8913
|
-
var import_node_crypto14,
|
|
8913
|
+
var import_node_crypto14, import_node_fs29, import_node_path30, DEFAULT_RNX_CLOUD_ORIGIN, MAX_RNX_CLOUD_BUNDLE_BYTES, REMOTE_COMMAND, MAX_ASSET_DEST_FILES, ACCOUNT_CHOICE_REFUSALS, PROJECT_ONLY_DIRECTORIES, MAX_PLACEMENT_COMBINATIONS;
|
|
8914
8914
|
var init_cloud_client = __esm({
|
|
8915
8915
|
"cli/cloud-client.ts"() {
|
|
8916
8916
|
"use strict";
|
|
8917
8917
|
import_node_crypto14 = require("node:crypto");
|
|
8918
|
-
|
|
8919
|
-
|
|
8918
|
+
import_node_fs29 = require("node:fs");
|
|
8919
|
+
import_node_path30 = require("node:path");
|
|
8920
8920
|
init_metroAssetArtifact();
|
|
8921
8921
|
init_metroCloudArtifact();
|
|
8922
8922
|
init_metro_fingerprint_registry_client();
|
|
@@ -9262,6 +9262,83 @@ function normalizeNativeDevBundleUrl(bundleUrl) {
|
|
|
9262
9262
|
}
|
|
9263
9263
|
}
|
|
9264
9264
|
|
|
9265
|
+
// src/oneWidgetContract.ts
|
|
9266
|
+
function configuredWidgetFromScan(value, bundleUrl) {
|
|
9267
|
+
if (!Array.isArray(value)) return null;
|
|
9268
|
+
const requested = new URL(bundleUrl);
|
|
9269
|
+
for (const entry of value) {
|
|
9270
|
+
if (!entry || typeof entry !== "object") continue;
|
|
9271
|
+
const widget = Reflect.get(entry, "widget");
|
|
9272
|
+
if (!widget || typeof widget !== "object") continue;
|
|
9273
|
+
const metadata = Reflect.get(widget, "metadata");
|
|
9274
|
+
const advertisedUrl = Reflect.get(widget, "bundleUrl");
|
|
9275
|
+
const packageUrl = Reflect.get(widget, "packageUrl");
|
|
9276
|
+
const projectRoot = Reflect.get(widget, "projectRoot");
|
|
9277
|
+
const appIdentity = Reflect.get(widget, "appIdentity");
|
|
9278
|
+
const urlSchemes = Reflect.get(widget, "urlSchemes");
|
|
9279
|
+
if (typeof advertisedUrl !== "string" || typeof packageUrl !== "string" || typeof projectRoot !== "string" || !projectRoot || typeof appIdentity !== "string" || !/^[a-f0-9]{64}$/.test(appIdentity) || !Array.isArray(urlSchemes) || !urlSchemes.every(
|
|
9280
|
+
(scheme) => typeof scheme === "string" && /^[A-Za-z][A-Za-z0-9+.-]*$/.test(scheme)
|
|
9281
|
+
) || !metadata || typeof metadata !== "object")
|
|
9282
|
+
continue;
|
|
9283
|
+
const advertised = new URL(alignLoopbackBundleUrlWithProbe(advertisedUrl, bundleUrl));
|
|
9284
|
+
if (advertised.protocol !== requested.protocol || advertised.port !== requested.port || advertised.hostname !== requested.hostname || advertised.pathname !== requested.pathname)
|
|
9285
|
+
continue;
|
|
9286
|
+
if (["rnxProjectId", "rnxReplacementToken"].some(
|
|
9287
|
+
(key2) => requested.searchParams.has(key2) && requested.searchParams.get(key2) !== advertised.searchParams.get(key2)
|
|
9288
|
+
))
|
|
9289
|
+
continue;
|
|
9290
|
+
if (new URL(packageUrl).origin !== new URL(advertisedUrl).origin || new URL(packageUrl).pathname !== "/__peach/swift-package/OneWidgets")
|
|
9291
|
+
continue;
|
|
9292
|
+
const appName = Reflect.get(metadata, "appName");
|
|
9293
|
+
const bundleId = Reflect.get(metadata, "bundleId");
|
|
9294
|
+
const kind = Reflect.get(metadata, "kind");
|
|
9295
|
+
const suite = Reflect.get(metadata, "suite");
|
|
9296
|
+
const displayName = Reflect.get(metadata, "displayName");
|
|
9297
|
+
const description = Reflect.get(metadata, "description");
|
|
9298
|
+
const sources = Reflect.get(metadata, "sources");
|
|
9299
|
+
if (typeof appName !== "string" || !/^[A-Za-z][A-Za-z0-9_]*$/.test(appName) || typeof bundleId !== "string" || !bundleId || typeof kind !== "string" || !kind || typeof suite !== "string" || !suite || typeof displayName !== "string" || !displayName || typeof description !== "string" || !description || !sources || typeof sources !== "object" || Array.isArray(sources))
|
|
9300
|
+
continue;
|
|
9301
|
+
const sourceHashes = {};
|
|
9302
|
+
for (const [file, hash] of Object.entries(sources)) {
|
|
9303
|
+
if (typeof hash !== "string" || !/^[a-f0-9]{64}$/.test(hash)) return null;
|
|
9304
|
+
sourceHashes[file] = hash;
|
|
9305
|
+
}
|
|
9306
|
+
if (Object.keys(sourceHashes).length !== 2 || !sourceHashes["ios/OneWidgets/OneWidget.swift"] || !sourceHashes[`ios/${appName}/OneWidgetContract.swift`])
|
|
9307
|
+
continue;
|
|
9308
|
+
return {
|
|
9309
|
+
metadata: {
|
|
9310
|
+
appName,
|
|
9311
|
+
bundleId,
|
|
9312
|
+
kind,
|
|
9313
|
+
suite,
|
|
9314
|
+
displayName,
|
|
9315
|
+
description,
|
|
9316
|
+
sources: sourceHashes
|
|
9317
|
+
},
|
|
9318
|
+
bundleUrl,
|
|
9319
|
+
packageUrl: new URL("/__peach/swift-package/OneWidgets", requested).href,
|
|
9320
|
+
projectRoot,
|
|
9321
|
+
appIdentity,
|
|
9322
|
+
urlSchemes
|
|
9323
|
+
};
|
|
9324
|
+
}
|
|
9325
|
+
return null;
|
|
9326
|
+
}
|
|
9327
|
+
|
|
9328
|
+
// src/one-widget-discovery.ts
|
|
9329
|
+
async function readConfiguredOneWidget(bundleUrl) {
|
|
9330
|
+
try {
|
|
9331
|
+
const response = await fetch(new URL("/__server-scan", bundleUrl).href, {
|
|
9332
|
+
signal: AbortSignal.timeout(3e4)
|
|
9333
|
+
});
|
|
9334
|
+
if (!response.ok || !response.headers.get("content-type")?.includes("json"))
|
|
9335
|
+
return null;
|
|
9336
|
+
return configuredWidgetFromScan(await response.json(), bundleUrl);
|
|
9337
|
+
} catch {
|
|
9338
|
+
return null;
|
|
9339
|
+
}
|
|
9340
|
+
}
|
|
9341
|
+
|
|
9265
9342
|
// src/settings-bundle.ts
|
|
9266
9343
|
var import_promises = require("node:fs/promises");
|
|
9267
9344
|
var import_node_path = require("node:path");
|
|
@@ -9354,9 +9431,9 @@ function safeChildPlistName(value) {
|
|
|
9354
9431
|
name: file.toLowerCase().endsWith(".plist") ? file : `${file}.plist`
|
|
9355
9432
|
};
|
|
9356
9433
|
}
|
|
9357
|
-
async function readableSettingsBundle(
|
|
9434
|
+
async function readableSettingsBundle(path25) {
|
|
9358
9435
|
try {
|
|
9359
|
-
const root = await (0, import_promises.stat)((0, import_node_path.join)(
|
|
9436
|
+
const root = await (0, import_promises.stat)((0, import_node_path.join)(path25, "Root.plist"));
|
|
9360
9437
|
return root.isFile() && root.size <= MAX_PLIST_BYTES;
|
|
9361
9438
|
} catch {
|
|
9362
9439
|
return false;
|
|
@@ -9401,11 +9478,11 @@ async function settingsBundleFingerprint(bundlePath) {
|
|
|
9401
9478
|
return null;
|
|
9402
9479
|
}
|
|
9403
9480
|
}
|
|
9404
|
-
async function parsePlistRecord(
|
|
9481
|
+
async function parsePlistRecord(path25) {
|
|
9405
9482
|
try {
|
|
9406
|
-
const metadata = await (0, import_promises.stat)(
|
|
9483
|
+
const metadata = await (0, import_promises.stat)(path25);
|
|
9407
9484
|
if (!metadata.isFile() || metadata.size > MAX_PLIST_BYTES) return null;
|
|
9408
|
-
const source = await (0, import_promises.readFile)(
|
|
9485
|
+
const source = await (0, import_promises.readFile)(path25, "utf8");
|
|
9409
9486
|
const parsed = parsePlistSource(source);
|
|
9410
9487
|
return isRecord2(parsed) ? parsed : null;
|
|
9411
9488
|
} catch {
|
|
@@ -9667,7 +9744,7 @@ async function tcpPing(port, timeout = TCP_GATE_MS) {
|
|
|
9667
9744
|
return null;
|
|
9668
9745
|
}
|
|
9669
9746
|
}
|
|
9670
|
-
function httpGet(hostname, port,
|
|
9747
|
+
function httpGet(hostname, port, path25, method = "GET", timeout = TIMEOUT_MS, headers = {}) {
|
|
9671
9748
|
return new Promise((resolve5) => {
|
|
9672
9749
|
let settled = false;
|
|
9673
9750
|
let killing = false;
|
|
@@ -9676,7 +9753,7 @@ function httpGet(hostname, port, path24, method = "GET", timeout = TIMEOUT_MS, h
|
|
|
9676
9753
|
settled = true;
|
|
9677
9754
|
resolve5(value);
|
|
9678
9755
|
};
|
|
9679
|
-
const req = import_http.default.request({ hostname, port, path:
|
|
9756
|
+
const req = import_http.default.request({ hostname, port, path: path25, method, headers }, (res) => {
|
|
9680
9757
|
let body = "";
|
|
9681
9758
|
res.on("data", (c) => body += c.toString());
|
|
9682
9759
|
const contentType = (() => {
|
|
@@ -10281,6 +10358,13 @@ async function scanDevServers(opts = {}) {
|
|
|
10281
10358
|
if (result) results.push(result);
|
|
10282
10359
|
});
|
|
10283
10360
|
}
|
|
10361
|
+
await Promise.all(
|
|
10362
|
+
results.map(async (result) => {
|
|
10363
|
+
result.widget = null;
|
|
10364
|
+
if (result.framework !== "one" && result.framework !== "vxrn") return;
|
|
10365
|
+
result.widget = await readConfiguredOneWidget(result.bundleUrl);
|
|
10366
|
+
})
|
|
10367
|
+
);
|
|
10284
10368
|
const pidByPort = /* @__PURE__ */ new Map();
|
|
10285
10369
|
for (const { port, pid } of processes) {
|
|
10286
10370
|
if (pid > 0) pidByPort.set(port, pid);
|
|
@@ -10357,10 +10441,10 @@ function getCliVersion() {
|
|
|
10357
10441
|
// src/expo-swift-host.ts
|
|
10358
10442
|
var import_node_child_process9 = require("node:child_process");
|
|
10359
10443
|
var import_node_crypto9 = require("node:crypto");
|
|
10360
|
-
var
|
|
10444
|
+
var import_node_fs20 = __toESM(require("node:fs"), 1);
|
|
10361
10445
|
var import_node_module = require("node:module");
|
|
10362
10446
|
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
10363
|
-
var
|
|
10447
|
+
var import_node_path21 = __toESM(require("node:path"), 1);
|
|
10364
10448
|
var import_node_util3 = require("node:util");
|
|
10365
10449
|
|
|
10366
10450
|
// cli/internal-child.ts
|
|
@@ -10968,9 +11052,18 @@ var SPRITEKIT_PRODUCT = '.product(name: "SpriteKit", package: "sootsim-swift")';
|
|
|
10968
11052
|
var importsSpriteKit = (files2) => Object.entries(files2).some(
|
|
10969
11053
|
([file, contents]) => file.endsWith(".swift") && swiftImportNames(contents).includes("SpriteKit")
|
|
10970
11054
|
);
|
|
10971
|
-
var
|
|
11055
|
+
var FOUNDATION_IMPLICIT_MODULES = [
|
|
11056
|
+
"PeachObjC",
|
|
11057
|
+
"Dispatch",
|
|
11058
|
+
"FoundationNetworking",
|
|
11059
|
+
"WASILibc",
|
|
11060
|
+
"wasi_pthread"
|
|
11061
|
+
];
|
|
11062
|
+
var FOUNDATION_IMPLICIT_FLAGS = FOUNDATION_IMPLICIT_MODULES.map(
|
|
11063
|
+
(module2) => `, "-Xfrontend", "-import-module", "-Xfrontend", "${module2}"`
|
|
11064
|
+
).join("");
|
|
10972
11065
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
10973
|
-
var MULTI_MANIFEST_VERSION =
|
|
11066
|
+
var MULTI_MANIFEST_VERSION = 12;
|
|
10974
11067
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
10975
11068
|
const hash = (0, import_node_crypto3.createHash)("sha256");
|
|
10976
11069
|
hash.update(`swift-compile/v18
|
|
@@ -11021,8 +11114,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
11021
11114
|
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
11022
11115
|
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
11023
11116
|
);
|
|
11117
|
+
if (spriteKit) {
|
|
11118
|
+
reachedFrameworks.add("SpriteKit");
|
|
11119
|
+
reachedFrameworks.add("PeachBox2D");
|
|
11120
|
+
}
|
|
11024
11121
|
const distributionObjects = distribution?.objects.filter(
|
|
11025
|
-
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
11122
|
+
(object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
|
|
11026
11123
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
11027
11124
|
)
|
|
11028
11125
|
);
|
|
@@ -12179,7 +12276,17 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
12179
12276
|
])
|
|
12180
12277
|
],
|
|
12181
12278
|
{
|
|
12182
|
-
env:
|
|
12279
|
+
env: {
|
|
12280
|
+
...BUILD_ENV,
|
|
12281
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
12282
|
+
...process.platform === "linux" ? {
|
|
12283
|
+
LD_LIBRARY_PATH: [
|
|
12284
|
+
import_node_path7.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
12285
|
+
import_node_path7.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
12286
|
+
process.env.LD_LIBRARY_PATH
|
|
12287
|
+
].filter(Boolean).join(":")
|
|
12288
|
+
} : {}
|
|
12289
|
+
},
|
|
12183
12290
|
maxBuffer: 64 * 1024 * 1024,
|
|
12184
12291
|
timeout: options.timeoutMs
|
|
12185
12292
|
}
|
|
@@ -12814,9 +12921,9 @@ function swiftModuleToolchain(root) {
|
|
|
12814
12921
|
|
|
12815
12922
|
// src/swift-host.ts
|
|
12816
12923
|
var import_node_crypto8 = require("node:crypto");
|
|
12817
|
-
var
|
|
12924
|
+
var import_node_fs19 = __toESM(require("node:fs"), 1);
|
|
12818
12925
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
12819
|
-
var
|
|
12926
|
+
var import_node_path20 = __toESM(require("node:path"), 1);
|
|
12820
12927
|
|
|
12821
12928
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
12822
12929
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -12850,8 +12957,8 @@ function pickImagesetFile(images) {
|
|
|
12850
12957
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
12851
12958
|
};
|
|
12852
12959
|
}
|
|
12853
|
-
function flatScale(
|
|
12854
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
12960
|
+
function flatScale(path25) {
|
|
12961
|
+
const match = /@([23])x\.[^./]+$/.exec(path25);
|
|
12855
12962
|
return match ? Number(match[1]) : 1;
|
|
12856
12963
|
}
|
|
12857
12964
|
function providesNamespace(text3) {
|
|
@@ -12878,13 +12985,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
12878
12985
|
}
|
|
12879
12986
|
return segments.join("/");
|
|
12880
12987
|
}
|
|
12881
|
-
function isFlatResourceImage(
|
|
12882
|
-
return
|
|
12988
|
+
function isFlatResourceImage(path25) {
|
|
12989
|
+
return path25.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path25));
|
|
12883
12990
|
}
|
|
12884
12991
|
function enumerateBundleImages(paths, readText) {
|
|
12885
12992
|
const table = [];
|
|
12886
12993
|
const seen = /* @__PURE__ */ new Set();
|
|
12887
|
-
const catalogs = paths.filter((
|
|
12994
|
+
const catalogs = paths.filter((path25) => baseOf(path25) === "Contents.json");
|
|
12888
12995
|
for (const contentsPath of catalogs) {
|
|
12889
12996
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
12890
12997
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -12905,12 +13012,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
12905
13012
|
seen.add(name2);
|
|
12906
13013
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
12907
13014
|
}
|
|
12908
|
-
for (const
|
|
12909
|
-
if (!isFlatResourceImage(
|
|
12910
|
-
const name2 = baseOf(
|
|
13015
|
+
for (const path25 of paths) {
|
|
13016
|
+
if (!isFlatResourceImage(path25)) continue;
|
|
13017
|
+
const name2 = baseOf(path25).slice(0, -extOf(path25).length);
|
|
12911
13018
|
if (name2 === "" || seen.has(name2)) continue;
|
|
12912
13019
|
seen.add(name2);
|
|
12913
|
-
table.push({ name: name2, file:
|
|
13020
|
+
table.push({ name: name2, file: path25, scale: flatScale(path25) });
|
|
12914
13021
|
}
|
|
12915
13022
|
return table;
|
|
12916
13023
|
}
|
|
@@ -12939,7 +13046,7 @@ function colorsetValue(color) {
|
|
|
12939
13046
|
}
|
|
12940
13047
|
function enumerateBundleColors(paths, readText) {
|
|
12941
13048
|
const table = {};
|
|
12942
|
-
for (const contentsPath of paths.filter((
|
|
13049
|
+
for (const contentsPath of paths.filter((path25) => baseOf(path25) === "Contents.json")) {
|
|
12943
13050
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
12944
13051
|
if (name2 === null || name2 in table) continue;
|
|
12945
13052
|
let colors;
|
|
@@ -13004,8 +13111,8 @@ function axisExtremes(points) {
|
|
|
13004
13111
|
function pathBounds(d) {
|
|
13005
13112
|
const xs = [];
|
|
13006
13113
|
const ys = [];
|
|
13007
|
-
for (const
|
|
13008
|
-
(0, import_svgpath.default)(
|
|
13114
|
+
for (const path25 of d)
|
|
13115
|
+
(0, import_svgpath.default)(path25).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
13009
13116
|
const [command, ...args] = segment;
|
|
13010
13117
|
if (command === "M" || command === "L") {
|
|
13011
13118
|
xs.push(Number(args[0]));
|
|
@@ -13032,7 +13139,7 @@ function guide(svg, id, axis) {
|
|
|
13032
13139
|
}
|
|
13033
13140
|
function enumerateBundleSymbols(paths, readText) {
|
|
13034
13141
|
const table = {};
|
|
13035
|
-
for (const contentsPath of paths.filter((
|
|
13142
|
+
for (const contentsPath of paths.filter((path25) => baseOf(path25) === "Contents.json")) {
|
|
13036
13143
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
13037
13144
|
if (name2 === null || name2 in table) continue;
|
|
13038
13145
|
let symbols;
|
|
@@ -13065,8 +13172,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
13065
13172
|
viewBox: "0 0 24 24",
|
|
13066
13173
|
advance,
|
|
13067
13174
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
13068
|
-
layers: d.map((
|
|
13069
|
-
d: (0, import_svgpath.default)(
|
|
13175
|
+
layers: d.map((path25) => ({
|
|
13176
|
+
d: (0, import_svgpath.default)(path25).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
13070
13177
|
}))
|
|
13071
13178
|
};
|
|
13072
13179
|
}
|
|
@@ -13076,7 +13183,7 @@ function enumerateBundleJson(paths) {
|
|
|
13076
13183
|
const found = [];
|
|
13077
13184
|
const seen = /* @__PURE__ */ new Set();
|
|
13078
13185
|
const ordered = [...paths].filter(
|
|
13079
|
-
(
|
|
13186
|
+
(path25) => path25.split("/").includes("Resources") && path25.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path25) === ".json" || extOf(path25) === ".xcstrings")
|
|
13080
13187
|
).sort((a, b) => {
|
|
13081
13188
|
const aDepth = a.split("/").length;
|
|
13082
13189
|
const bDepth = b.split("/").length;
|
|
@@ -13903,12 +14010,57 @@ function resolveSwiftPackages(options) {
|
|
|
13903
14010
|
return result;
|
|
13904
14011
|
}
|
|
13905
14012
|
|
|
14013
|
+
// src/swift-source-file.ts
|
|
14014
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
14015
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
14016
|
+
function readPackageFile(root, file, maxBytes) {
|
|
14017
|
+
const canonicalRoot = import_node_fs16.default.realpathSync(root);
|
|
14018
|
+
const relative2 = import_node_path16.default.relative(canonicalRoot, import_node_fs16.default.realpathSync(file));
|
|
14019
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path16.default.sep}`) || import_node_path16.default.isAbsolute(relative2)) {
|
|
14020
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
14021
|
+
}
|
|
14022
|
+
let ancestor = import_node_path16.default.resolve(file);
|
|
14023
|
+
while (ancestor !== canonicalRoot) {
|
|
14024
|
+
if (import_node_fs16.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
14025
|
+
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
14026
|
+
}
|
|
14027
|
+
const parent = import_node_path16.default.dirname(ancestor);
|
|
14028
|
+
if (parent === ancestor)
|
|
14029
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
14030
|
+
ancestor = parent;
|
|
14031
|
+
}
|
|
14032
|
+
const expected = import_node_fs16.default.statSync(file);
|
|
14033
|
+
const fd = import_node_fs16.default.openSync(file, import_node_fs16.default.constants.O_RDONLY | import_node_fs16.default.constants.O_NOFOLLOW);
|
|
14034
|
+
try {
|
|
14035
|
+
const stat2 = import_node_fs16.default.fstatSync(fd);
|
|
14036
|
+
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
14037
|
+
throw new Error(`swift input changed while opening: ${file}`);
|
|
14038
|
+
}
|
|
14039
|
+
if (!stat2.isFile() || stat2.size > maxBytes) {
|
|
14040
|
+
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
14041
|
+
}
|
|
14042
|
+
const bytes = Buffer.alloc(stat2.size + 1);
|
|
14043
|
+
let offset = 0;
|
|
14044
|
+
while (offset < bytes.length) {
|
|
14045
|
+
const count = import_node_fs16.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
14046
|
+
if (count === 0) break;
|
|
14047
|
+
offset += count;
|
|
14048
|
+
}
|
|
14049
|
+
if (offset !== stat2.size || import_node_fs16.default.fstatSync(fd).size !== stat2.size) {
|
|
14050
|
+
throw new Error(`swift input changed while reading: ${file}`);
|
|
14051
|
+
}
|
|
14052
|
+
return bytes.subarray(0, offset);
|
|
14053
|
+
} finally {
|
|
14054
|
+
import_node_fs16.default.closeSync(fd);
|
|
14055
|
+
}
|
|
14056
|
+
}
|
|
14057
|
+
|
|
13906
14058
|
// src/swift-standins.ts
|
|
13907
14059
|
var import_node_child_process8 = require("node:child_process");
|
|
13908
14060
|
var import_node_crypto7 = require("node:crypto");
|
|
13909
|
-
var
|
|
14061
|
+
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
13910
14062
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
13911
|
-
var
|
|
14063
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
13912
14064
|
|
|
13913
14065
|
// src/swift-standin-emit.ts
|
|
13914
14066
|
var STANDIN_EMIT_VERSION = "4";
|
|
@@ -13968,7 +14120,7 @@ var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.")
|
|
|
13968
14120
|
var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
13969
14121
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
13970
14122
|
var synthesizedEquality = (symbol, conforms) => conforms.includes("Hashable") ? ["==(_:_:)", "hash(into:)", "hashValue"].includes(leaf(symbol)) : conforms.includes("Equatable") && leaf(symbol) === "==(_:_:)";
|
|
13971
|
-
var trap = (
|
|
14123
|
+
var trap = (path25) => `fatalError("${path25} is a binary framework peach cannot run")`;
|
|
13972
14124
|
function emitSwiftStandin(graphs, options) {
|
|
13973
14125
|
const skipped = [];
|
|
13974
14126
|
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
@@ -14105,10 +14257,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14105
14257
|
owners.push(...physical.map(() => current));
|
|
14106
14258
|
};
|
|
14107
14259
|
const scoped = (body) => (symbol, ...rest) => {
|
|
14108
|
-
const
|
|
14109
|
-
if (omit.has(
|
|
14260
|
+
const path25 = pathOf(symbol);
|
|
14261
|
+
if (omit.has(path25)) return void skipped.push({ path: path25, reason: omit.get(path25) });
|
|
14110
14262
|
const previous = current;
|
|
14111
|
-
current =
|
|
14263
|
+
current = path25;
|
|
14112
14264
|
try {
|
|
14113
14265
|
body(symbol, ...rest);
|
|
14114
14266
|
} finally {
|
|
@@ -14128,14 +14280,14 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14128
14280
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
14129
14281
|
const emitMember = scoped(
|
|
14130
14282
|
(member, indent, context) => {
|
|
14131
|
-
const
|
|
14283
|
+
const path25 = pathOf(member);
|
|
14132
14284
|
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
14133
14285
|
emitType(member, indent);
|
|
14134
14286
|
return;
|
|
14135
14287
|
}
|
|
14136
14288
|
if (member.kind.identifier === "swift.enum.case") return;
|
|
14137
14289
|
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
14138
|
-
skipped.push({ path:
|
|
14290
|
+
skipped.push({ path: path25, reason: `unhandled ${member.kind.identifier}` });
|
|
14139
14291
|
return;
|
|
14140
14292
|
}
|
|
14141
14293
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
@@ -14149,12 +14301,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14149
14301
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
14150
14302
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
14151
14303
|
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
14152
|
-
const override = context.inClass && !options.plain?.has(
|
|
14304
|
+
const override = context.inClass && !options.plain?.has(path25) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path25) || isObjC(member) && path25.endsWith(".init()")) ? "override " : "";
|
|
14153
14305
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
14154
|
-
const measured = behavior.get(
|
|
14155
|
-
if (measured) used.add(
|
|
14306
|
+
const measured = behavior.get(path25);
|
|
14307
|
+
if (measured) used.add(path25);
|
|
14156
14308
|
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
14157
|
-
const body = overloadBody ?? measured?.body ?? trap(
|
|
14309
|
+
const body = overloadBody ?? measured?.body ?? trap(path25);
|
|
14158
14310
|
switch (member.kind.identifier) {
|
|
14159
14311
|
case "swift.property":
|
|
14160
14312
|
case "swift.type.property":
|
|
@@ -14175,7 +14327,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14175
14327
|
return;
|
|
14176
14328
|
}
|
|
14177
14329
|
emit(
|
|
14178
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(
|
|
14330
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path25)} }` : ""} }`
|
|
14179
14331
|
);
|
|
14180
14332
|
return;
|
|
14181
14333
|
}
|
|
@@ -14228,7 +14380,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14228
14380
|
};
|
|
14229
14381
|
const emitType = scoped(
|
|
14230
14382
|
(symbol, indent) => {
|
|
14231
|
-
const
|
|
14383
|
+
const path25 = pathOf(symbol);
|
|
14232
14384
|
const id = symbol.identifier.precise;
|
|
14233
14385
|
const inner = `${indent} `;
|
|
14234
14386
|
switch (symbol.kind.identifier) {
|
|
@@ -14240,10 +14392,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14240
14392
|
case "swift.class": {
|
|
14241
14393
|
const shape = header(symbol, "class", indent);
|
|
14242
14394
|
if (!shape)
|
|
14243
|
-
return void skipped.push({ path:
|
|
14244
|
-
const parent = options.superclasses?.get(
|
|
14395
|
+
return void skipped.push({ path: path25, reason: `unparsed class ${text(symbol)}` });
|
|
14396
|
+
const parent = options.superclasses?.get(path25) ?? superclass.get(id);
|
|
14245
14397
|
const blocked = classBlocked(id);
|
|
14246
|
-
if (blocked) return void skipped.push({ path:
|
|
14398
|
+
if (blocked) return void skipped.push({ path: path25, reason: blocked });
|
|
14247
14399
|
const ancestors = /* @__PURE__ */ new Set();
|
|
14248
14400
|
for (let at = superId.get(id); at; at = superId.get(at))
|
|
14249
14401
|
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
@@ -14259,9 +14411,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14259
14411
|
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
14260
14412
|
);
|
|
14261
14413
|
const members = membersOf(id);
|
|
14262
|
-
const extra = options.behavior?.get(
|
|
14414
|
+
const extra = options.behavior?.get(path25)?.members;
|
|
14263
14415
|
if (extra) {
|
|
14264
|
-
used.add(
|
|
14416
|
+
used.add(path25);
|
|
14265
14417
|
emit(`${inner}${extra}`);
|
|
14266
14418
|
}
|
|
14267
14419
|
for (const member of members)
|
|
@@ -14314,13 +14466,13 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14314
14466
|
continue;
|
|
14315
14467
|
have.add(witnessKey(member));
|
|
14316
14468
|
have.add(sideLeaf(member));
|
|
14317
|
-
emitWitness(member, inner,
|
|
14469
|
+
emitWitness(member, inner, path25);
|
|
14318
14470
|
}
|
|
14319
14471
|
}
|
|
14320
14472
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
14321
14473
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
14322
14474
|
emit(
|
|
14323
|
-
`${inner}public required init?(coder: NSCoder) { ${trap(`${
|
|
14475
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path25}.init(coder:)`)} }`
|
|
14324
14476
|
);
|
|
14325
14477
|
emit(`${indent}}`);
|
|
14326
14478
|
return;
|
|
@@ -14328,7 +14480,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14328
14480
|
case "swift.struct": {
|
|
14329
14481
|
const shape = header(symbol, "struct", indent);
|
|
14330
14482
|
if (!shape)
|
|
14331
|
-
return void skipped.push({ path:
|
|
14483
|
+
return void skipped.push({ path: path25, reason: `unparsed struct ${text(symbol)}` });
|
|
14332
14484
|
const members = membersOf(id);
|
|
14333
14485
|
const raw2 = rawType(members);
|
|
14334
14486
|
const list2 = inheritance(id);
|
|
@@ -14379,7 +14531,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14379
14531
|
case "swift.enum": {
|
|
14380
14532
|
const shape = header(symbol, "enum", indent);
|
|
14381
14533
|
if (!shape)
|
|
14382
|
-
return void skipped.push({ path:
|
|
14534
|
+
return void skipped.push({ path: path25, reason: `unparsed enum ${text(symbol)}` });
|
|
14383
14535
|
const members = membersOf(id);
|
|
14384
14536
|
const raw2 = rawType(members);
|
|
14385
14537
|
const cases = (children.get(id) ?? []).filter(
|
|
@@ -14388,7 +14540,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14388
14540
|
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
14389
14541
|
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
14390
14542
|
return void skipped.push({
|
|
14391
|
-
path:
|
|
14543
|
+
path: path25,
|
|
14392
14544
|
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
14393
14545
|
});
|
|
14394
14546
|
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
@@ -14429,7 +14581,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14429
14581
|
const shape = header(symbol, "protocol", indent);
|
|
14430
14582
|
if (!shape)
|
|
14431
14583
|
return void skipped.push({
|
|
14432
|
-
path:
|
|
14584
|
+
path: path25,
|
|
14433
14585
|
reason: `unparsed protocol ${text(symbol)}`
|
|
14434
14586
|
});
|
|
14435
14587
|
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
@@ -14454,7 +14606,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14454
14606
|
}
|
|
14455
14607
|
emit(`${indent}}`);
|
|
14456
14608
|
if (defaults.length > 0) {
|
|
14457
|
-
emit(`${indent}extension ${
|
|
14609
|
+
emit(`${indent}extension ${path25} {`);
|
|
14458
14610
|
for (const member of defaults) {
|
|
14459
14611
|
const decl = text(member);
|
|
14460
14612
|
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
@@ -14501,7 +14653,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14501
14653
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
14502
14654
|
};
|
|
14503
14655
|
const emitGlobal = scoped((symbol) => {
|
|
14504
|
-
const
|
|
14656
|
+
const path25 = pathOf(symbol);
|
|
14505
14657
|
const kind = symbol.kind.identifier;
|
|
14506
14658
|
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
14507
14659
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
@@ -14512,17 +14664,17 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14512
14664
|
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
14513
14665
|
spelled = `${fix} ${spelled}`;
|
|
14514
14666
|
}
|
|
14515
|
-
emit(`${attrs}public ${spelled} { ${trap(
|
|
14667
|
+
emit(`${attrs}public ${spelled} { ${trap(path25)} }`);
|
|
14516
14668
|
} else if (kind === "swift.var") {
|
|
14517
14669
|
const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
|
|
14518
|
-
const measured = behavior.get(
|
|
14519
|
-
if (measured) used.add(
|
|
14520
|
-
emit(`public ${parsed.decl} { ${measured?.body ?? trap(
|
|
14521
|
-
} else skipped.push({ path:
|
|
14670
|
+
const measured = behavior.get(path25);
|
|
14671
|
+
if (measured) used.add(path25);
|
|
14672
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path25)} }`);
|
|
14673
|
+
} else skipped.push({ path: path25, reason: `unhandled top-level ${kind}` });
|
|
14522
14674
|
});
|
|
14523
14675
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
14524
14676
|
for (const symbol of roots) {
|
|
14525
|
-
const
|
|
14677
|
+
const path25 = pathOf(symbol);
|
|
14526
14678
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
14527
14679
|
else emitGlobal(symbol);
|
|
14528
14680
|
}
|
|
@@ -14564,9 +14716,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
14564
14716
|
...imports.map((name2) => `import ${name2}`),
|
|
14565
14717
|
""
|
|
14566
14718
|
];
|
|
14567
|
-
for (const
|
|
14568
|
-
if (!used.has(
|
|
14569
|
-
skipped.push({ path:
|
|
14719
|
+
for (const path25 of behavior.keys())
|
|
14720
|
+
if (!used.has(path25))
|
|
14721
|
+
skipped.push({ path: path25, reason: "behavior names no emitted declaration" });
|
|
14570
14722
|
return {
|
|
14571
14723
|
source: `${[...banner, ...lines].join("\n")}
|
|
14572
14724
|
`,
|
|
@@ -14641,7 +14793,7 @@ function stripDefaults(decl) {
|
|
|
14641
14793
|
|
|
14642
14794
|
// src/swift-standins.ts
|
|
14643
14795
|
var TRIPLE = "wasm32-unknown-wasip1";
|
|
14644
|
-
var cacheDir4 =
|
|
14796
|
+
var cacheDir4 = import_node_path17.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
14645
14797
|
function exec(file, args, cwd) {
|
|
14646
14798
|
return (0, import_node_child_process8.execFileSync)(file, args, {
|
|
14647
14799
|
cwd,
|
|
@@ -14661,15 +14813,15 @@ var digests = /* @__PURE__ */ new Map();
|
|
|
14661
14813
|
function treeDigest(root) {
|
|
14662
14814
|
const names = [];
|
|
14663
14815
|
const walk2 = (dir) => {
|
|
14664
|
-
for (const entry of
|
|
14665
|
-
const full =
|
|
14816
|
+
for (const entry of import_node_fs17.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
14817
|
+
const full = import_node_path17.default.join(dir, entry.name);
|
|
14666
14818
|
if (entry.isDirectory()) walk2(full);
|
|
14667
|
-
else if (entry.isFile()) names.push(
|
|
14819
|
+
else if (entry.isFile()) names.push(import_node_path17.default.relative(root, full));
|
|
14668
14820
|
}
|
|
14669
14821
|
};
|
|
14670
14822
|
walk2(root);
|
|
14671
14823
|
const stamp = names.map((name2) => {
|
|
14672
|
-
const stat2 =
|
|
14824
|
+
const stat2 = import_node_fs17.default.statSync(import_node_path17.default.join(root, name2));
|
|
14673
14825
|
return `${name2}\0${stat2.size}:${stat2.mtimeMs}`;
|
|
14674
14826
|
}).join("\n");
|
|
14675
14827
|
const memo2 = digests.get(`tree\0${root}`);
|
|
@@ -14677,7 +14829,7 @@ function treeDigest(root) {
|
|
|
14677
14829
|
const hash = (0, import_node_crypto7.createHash)("sha256");
|
|
14678
14830
|
for (const name2 of names) {
|
|
14679
14831
|
hash.update(`${name2}\0`);
|
|
14680
|
-
hash.update(
|
|
14832
|
+
hash.update(import_node_fs17.default.readFileSync(import_node_path17.default.join(root, name2)));
|
|
14681
14833
|
hash.update("\0");
|
|
14682
14834
|
}
|
|
14683
14835
|
const digest = hash.digest("hex");
|
|
@@ -14686,9 +14838,9 @@ function treeDigest(root) {
|
|
|
14686
14838
|
}
|
|
14687
14839
|
function locateXcframework(tree) {
|
|
14688
14840
|
const find = (root, depth) => {
|
|
14689
|
-
for (const entry of
|
|
14841
|
+
for (const entry of import_node_fs17.default.readdirSync(root, { withFileTypes: true })) {
|
|
14690
14842
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
14691
|
-
const full =
|
|
14843
|
+
const full = import_node_path17.default.join(root, entry.name);
|
|
14692
14844
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
14693
14845
|
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
14694
14846
|
if (nested) return nested;
|
|
@@ -14703,67 +14855,67 @@ function xcframework(binary2) {
|
|
|
14703
14855
|
if (binary2.url && (!binary2.checksum || !/^[a-f0-9]{64}$/i.test(binary2.checksum)))
|
|
14704
14856
|
throw new Error("remote binary archive requires its Package.swift SHA-256 checksum");
|
|
14705
14857
|
const expected = binary2.checksum?.toLowerCase();
|
|
14706
|
-
const dir =
|
|
14707
|
-
const archive =
|
|
14708
|
-
const fingerprint =
|
|
14858
|
+
const dir = import_node_path17.default.join(cacheDir4, "archives", key(binary2.url ? expected : binary2.dir));
|
|
14859
|
+
const archive = import_node_path17.default.join(dir, "archive.zip");
|
|
14860
|
+
const fingerprint = import_node_path17.default.join(dir, ".fingerprint");
|
|
14709
14861
|
const stored = (() => {
|
|
14710
14862
|
try {
|
|
14711
|
-
const parsed = JSON.parse(
|
|
14863
|
+
const parsed = JSON.parse(import_node_fs17.default.readFileSync(fingerprint, "utf8"));
|
|
14712
14864
|
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
14713
14865
|
} catch {
|
|
14714
14866
|
return null;
|
|
14715
14867
|
}
|
|
14716
14868
|
})();
|
|
14717
14869
|
if (!binary2.url) {
|
|
14718
|
-
const stat2 =
|
|
14870
|
+
const stat2 = import_node_fs17.default.statSync(binary2.dir);
|
|
14719
14871
|
const stamp = `${stat2.size}:${stat2.mtimeMs}`;
|
|
14720
14872
|
if (stored?.stamp === stamp) {
|
|
14721
|
-
const found3 = locateXcframework(
|
|
14873
|
+
const found3 = locateXcframework(import_node_path17.default.join(dir, "tree"));
|
|
14722
14874
|
if (found3) return { dir: found3, digest: stored.sha };
|
|
14723
14875
|
}
|
|
14724
|
-
const sha2 = (0, import_node_crypto7.createHash)("sha256").update(
|
|
14725
|
-
if (sha2 !== stored?.sha || !locateXcframework(
|
|
14726
|
-
|
|
14727
|
-
|
|
14728
|
-
exec("unzip", ["-q", binary2.dir, "-d",
|
|
14876
|
+
const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.readFileSync(binary2.dir)).digest("hex");
|
|
14877
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path17.default.join(dir, "tree"))) {
|
|
14878
|
+
import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
|
|
14879
|
+
import_node_fs17.default.mkdirSync(import_node_path17.default.join(dir, "tree"), { recursive: true });
|
|
14880
|
+
exec("unzip", ["-q", binary2.dir, "-d", import_node_path17.default.join(dir, "tree")]);
|
|
14729
14881
|
}
|
|
14730
|
-
|
|
14731
|
-
const found2 = locateXcframework(
|
|
14882
|
+
import_node_fs17.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
14883
|
+
const found2 = locateXcframework(import_node_path17.default.join(dir, "tree"));
|
|
14732
14884
|
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
14733
14885
|
return { dir: found2, digest: sha2 };
|
|
14734
14886
|
}
|
|
14735
|
-
if (stored &&
|
|
14736
|
-
const sha2 = (0, import_node_crypto7.createHash)("sha256").update(
|
|
14887
|
+
if (stored && import_node_fs17.default.existsSync(archive)) {
|
|
14888
|
+
const sha2 = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.readFileSync(archive)).digest("hex");
|
|
14737
14889
|
if (sha2 !== expected)
|
|
14738
14890
|
throw new Error(`archive checksum ${sha2} is not the declared checksum ${expected}`);
|
|
14739
|
-
const found2 = locateXcframework(
|
|
14891
|
+
const found2 = locateXcframework(import_node_path17.default.join(dir, "tree"));
|
|
14740
14892
|
if (found2) return { dir: found2, digest: sha2 };
|
|
14741
14893
|
}
|
|
14742
|
-
|
|
14743
|
-
|
|
14894
|
+
import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
|
|
14895
|
+
import_node_fs17.default.mkdirSync(import_node_path17.default.join(dir, "tree"), { recursive: true });
|
|
14744
14896
|
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary2.url]);
|
|
14745
|
-
const sha = (0, import_node_crypto7.createHash)("sha256").update(
|
|
14897
|
+
const sha = (0, import_node_crypto7.createHash)("sha256").update(import_node_fs17.default.readFileSync(archive)).digest("hex");
|
|
14746
14898
|
if (sha !== expected) {
|
|
14747
|
-
|
|
14899
|
+
import_node_fs17.default.rmSync(dir, { recursive: true, force: true });
|
|
14748
14900
|
throw new Error(`archive checksum ${sha} is not the declared checksum ${expected}`);
|
|
14749
14901
|
}
|
|
14750
|
-
exec("unzip", ["-q", archive, "-d",
|
|
14751
|
-
|
|
14752
|
-
const found = locateXcframework(
|
|
14902
|
+
exec("unzip", ["-q", archive, "-d", import_node_path17.default.join(dir, "tree")]);
|
|
14903
|
+
import_node_fs17.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
14904
|
+
const found = locateXcframework(import_node_path17.default.join(dir, "tree"));
|
|
14753
14905
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
14754
14906
|
return { dir: found, digest: sha };
|
|
14755
14907
|
}
|
|
14756
|
-
var files = (dir, test) =>
|
|
14908
|
+
var files = (dir, test) => import_node_fs17.default.existsSync(dir) ? import_node_fs17.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path17.default.basename(file))).sort() : [];
|
|
14757
14909
|
function surfaces(xcframeworkDir) {
|
|
14758
|
-
const slice =
|
|
14910
|
+
const slice = import_node_fs17.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
14759
14911
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
14760
|
-
const root =
|
|
14912
|
+
const root = import_node_path17.default.join(xcframeworkDir, slice);
|
|
14761
14913
|
const found = [];
|
|
14762
|
-
for (const entry of
|
|
14914
|
+
for (const entry of import_node_fs17.default.readdirSync(root).sort()) {
|
|
14763
14915
|
if (!entry.endsWith(".framework")) continue;
|
|
14764
14916
|
const module2 = entry.slice(0, -".framework".length);
|
|
14765
|
-
const framework =
|
|
14766
|
-
const swiftmodule =
|
|
14917
|
+
const framework = import_node_path17.default.join(root, entry);
|
|
14918
|
+
const swiftmodule = import_node_path17.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
14767
14919
|
const interfaces = files(
|
|
14768
14920
|
swiftmodule,
|
|
14769
14921
|
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
@@ -14773,41 +14925,41 @@ function surfaces(xcframeworkDir) {
|
|
|
14773
14925
|
found.push({
|
|
14774
14926
|
kind: "swift",
|
|
14775
14927
|
module: module2,
|
|
14776
|
-
interface:
|
|
14928
|
+
interface: import_node_path17.default.join(swiftmodule, chosen)
|
|
14777
14929
|
});
|
|
14778
14930
|
continue;
|
|
14779
14931
|
}
|
|
14780
|
-
const modulemap =
|
|
14781
|
-
if (
|
|
14932
|
+
const modulemap = import_node_path17.default.join(framework, "Modules", "module.modulemap");
|
|
14933
|
+
if (import_node_fs17.default.existsSync(modulemap))
|
|
14782
14934
|
found.push({
|
|
14783
14935
|
kind: "c",
|
|
14784
14936
|
module: module2,
|
|
14785
14937
|
modulemap,
|
|
14786
|
-
headers:
|
|
14938
|
+
headers: import_node_path17.default.join(framework, "Headers")
|
|
14787
14939
|
});
|
|
14788
14940
|
}
|
|
14789
|
-
const headers =
|
|
14941
|
+
const headers = import_node_path17.default.join(root, "Headers");
|
|
14790
14942
|
for (const map2 of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
14791
|
-
const modulemap =
|
|
14792
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
14943
|
+
const modulemap = import_node_path17.default.join(headers, map2);
|
|
14944
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs17.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
14793
14945
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
14794
14946
|
}
|
|
14795
14947
|
return found;
|
|
14796
14948
|
}
|
|
14797
14949
|
function peachModuleDirs(toolchain, imports) {
|
|
14798
14950
|
const { moduleRoot, toolchainBin } = toolchain;
|
|
14799
|
-
if (swiftDistributionAt(moduleRoot)) return [
|
|
14951
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path17.default.join(moduleRoot, "modules")];
|
|
14800
14952
|
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
14801
14953
|
const plugins = swiftMacroPlugins(moduleRoot);
|
|
14802
14954
|
if (plugins.stale)
|
|
14803
14955
|
exec("sh", [
|
|
14804
|
-
|
|
14956
|
+
import_node_path17.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
14805
14957
|
toolchainBin,
|
|
14806
14958
|
plugins.libraries[0]
|
|
14807
14959
|
]);
|
|
14808
14960
|
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
14809
14961
|
exec(
|
|
14810
|
-
|
|
14962
|
+
import_node_path17.default.join(toolchainBin, "swift"),
|
|
14811
14963
|
[
|
|
14812
14964
|
"build",
|
|
14813
14965
|
"--swift-sdk",
|
|
@@ -14827,7 +14979,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
14827
14979
|
],
|
|
14828
14980
|
moduleRoot
|
|
14829
14981
|
);
|
|
14830
|
-
return [
|
|
14982
|
+
return [import_node_path17.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
14831
14983
|
}
|
|
14832
14984
|
function swiftInterfaceForWasm(text3) {
|
|
14833
14985
|
return text3.replace(
|
|
@@ -14839,11 +14991,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
14839
14991
|
);
|
|
14840
14992
|
}
|
|
14841
14993
|
function swiftStandin(surface, binary2, toolchain, work) {
|
|
14842
|
-
const text3 = swiftInterfaceForWasm(
|
|
14843
|
-
const search =
|
|
14844
|
-
const moduleDir =
|
|
14845
|
-
|
|
14846
|
-
|
|
14994
|
+
const text3 = swiftInterfaceForWasm(import_node_fs17.default.readFileSync(surface.interface, "utf8"));
|
|
14995
|
+
const search = import_node_path17.default.join(work, "interfaces");
|
|
14996
|
+
const moduleDir = import_node_path17.default.join(search, `${surface.module}.swiftmodule`);
|
|
14997
|
+
import_node_fs17.default.mkdirSync(moduleDir, { recursive: true });
|
|
14998
|
+
import_node_fs17.default.writeFileSync(import_node_path17.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
14847
14999
|
const imports = [
|
|
14848
15000
|
...text3.matchAll(
|
|
14849
15001
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -14855,9 +15007,9 @@ function swiftStandin(surface, binary2, toolchain, work) {
|
|
|
14855
15007
|
);
|
|
14856
15008
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
14857
15009
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
14858
|
-
const out =
|
|
14859
|
-
|
|
14860
|
-
exec(
|
|
15010
|
+
const out = import_node_path17.default.join(work, "graphs");
|
|
15011
|
+
import_node_fs17.default.mkdirSync(out, { recursive: true });
|
|
15012
|
+
exec(import_node_path17.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
14861
15013
|
"-module-name",
|
|
14862
15014
|
surface.module,
|
|
14863
15015
|
...target,
|
|
@@ -14871,10 +15023,10 @@ function swiftStandin(surface, binary2, toolchain, work) {
|
|
|
14871
15023
|
"-output-dir",
|
|
14872
15024
|
out
|
|
14873
15025
|
]);
|
|
14874
|
-
const graphs =
|
|
15026
|
+
const graphs = import_node_fs17.default.readdirSync(out).filter((name2) => name2.endsWith(".symbols.json")).sort().map((name2) => JSON.parse(import_node_fs17.default.readFileSync(import_node_path17.default.join(out, name2), "utf8")));
|
|
14875
15027
|
const omit = /* @__PURE__ */ new Map();
|
|
14876
15028
|
const plain = /* @__PURE__ */ new Set();
|
|
14877
|
-
const file =
|
|
15029
|
+
const file = import_node_path17.default.join(work, `${surface.module}.swift`);
|
|
14878
15030
|
for (; ; ) {
|
|
14879
15031
|
const { source, owners } = emitSwiftStandin(graphs, {
|
|
14880
15032
|
module: surface.module,
|
|
@@ -14882,9 +15034,9 @@ function swiftStandin(surface, binary2, toolchain, work) {
|
|
|
14882
15034
|
omit,
|
|
14883
15035
|
plain
|
|
14884
15036
|
});
|
|
14885
|
-
|
|
15037
|
+
import_node_fs17.default.writeFileSync(file, source);
|
|
14886
15038
|
const check = (0, import_node_child_process8.spawnSync)(
|
|
14887
|
-
|
|
15039
|
+
import_node_path17.default.join(toolchain.toolchainBin, "swiftc"),
|
|
14888
15040
|
[
|
|
14889
15041
|
"-typecheck",
|
|
14890
15042
|
"-parse-as-library",
|
|
@@ -15034,21 +15186,21 @@ function splitDeclarators(statement, names) {
|
|
|
15034
15186
|
}
|
|
15035
15187
|
function cStandin(surface, binary2, toolchain, work) {
|
|
15036
15188
|
const named = [
|
|
15037
|
-
...
|
|
15189
|
+
...import_node_fs17.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
15038
15190
|
].map((match) => match[1]);
|
|
15039
15191
|
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
15040
15192
|
const texts = new Map(
|
|
15041
15193
|
headers.map((file) => [
|
|
15042
15194
|
file,
|
|
15043
|
-
|
|
15195
|
+
import_node_fs17.default.readFileSync(import_node_path17.default.join(surface.headers, file), "utf8")
|
|
15044
15196
|
])
|
|
15045
15197
|
);
|
|
15046
15198
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
15047
15199
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
15048
|
-
const include =
|
|
15200
|
+
const include = import_node_path17.default.join(work, "include");
|
|
15049
15201
|
for (const [file, text3] of texts) {
|
|
15050
|
-
|
|
15051
|
-
|
|
15202
|
+
import_node_fs17.default.mkdirSync(import_node_path17.default.dirname(import_node_path17.default.join(include, file)), { recursive: true });
|
|
15203
|
+
import_node_fs17.default.writeFileSync(import_node_path17.default.join(include, file), text3);
|
|
15052
15204
|
}
|
|
15053
15205
|
const roots = named.length > 0 ? named : headers;
|
|
15054
15206
|
const modulemap = `module ${surface.module} {
|
|
@@ -15056,12 +15208,12 @@ ${roots.map((file) => ` header "${file}"
|
|
|
15056
15208
|
`).join("")} export *
|
|
15057
15209
|
}
|
|
15058
15210
|
`;
|
|
15059
|
-
const probe =
|
|
15060
|
-
|
|
15211
|
+
const probe = import_node_path17.default.join(work, "declarations.c");
|
|
15212
|
+
import_node_fs17.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
15061
15213
|
`).join(""));
|
|
15062
15214
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
15063
15215
|
const ast = JSON.parse(
|
|
15064
|
-
exec(
|
|
15216
|
+
exec(import_node_path17.default.join(toolchain.toolchainBin, "clang"), [
|
|
15065
15217
|
"-target",
|
|
15066
15218
|
TRIPLE,
|
|
15067
15219
|
"--sysroot",
|
|
@@ -15074,7 +15226,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
15074
15226
|
probe
|
|
15075
15227
|
])
|
|
15076
15228
|
);
|
|
15077
|
-
const byPath = new Map(headers.map((file) => [
|
|
15229
|
+
const byPath = new Map(headers.map((file) => [import_node_path17.default.join(include, file), file]));
|
|
15078
15230
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
15079
15231
|
const groups = /* @__PURE__ */ new Map();
|
|
15080
15232
|
for (const declaration of declarations) {
|
|
@@ -15121,10 +15273,10 @@ ${roots.map((file) => ` header "${file}"
|
|
|
15121
15273
|
"",
|
|
15122
15274
|
...definitions
|
|
15123
15275
|
].join("\n");
|
|
15124
|
-
const out =
|
|
15125
|
-
|
|
15276
|
+
const out = import_node_path17.default.join(work, `${surface.module}.c`);
|
|
15277
|
+
import_node_fs17.default.writeFileSync(out, source);
|
|
15126
15278
|
try {
|
|
15127
|
-
exec(
|
|
15279
|
+
exec(import_node_path17.default.join(toolchain.toolchainBin, "clang"), [
|
|
15128
15280
|
"-target",
|
|
15129
15281
|
TRIPLE,
|
|
15130
15282
|
"--sysroot",
|
|
@@ -15206,25 +15358,25 @@ function binaryStandins(binary2, toolchain, provided) {
|
|
|
15206
15358
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
15207
15359
|
surface.modulemap,
|
|
15208
15360
|
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
15209
|
-
(file2) =>
|
|
15361
|
+
(file2) => import_node_path17.default.join(surface.headers, file2)
|
|
15210
15362
|
)
|
|
15211
15363
|
])
|
|
15212
|
-
hash.update(
|
|
15364
|
+
hash.update(import_node_fs17.default.readFileSync(file));
|
|
15213
15365
|
}
|
|
15214
15366
|
const id = hash.digest("hex").slice(0, 32);
|
|
15215
15367
|
const memo2 = built.get(id);
|
|
15216
15368
|
if (memo2) return memo2;
|
|
15217
|
-
const cached3 =
|
|
15218
|
-
if (
|
|
15219
|
-
const value = JSON.parse(
|
|
15369
|
+
const cached3 = import_node_path17.default.join(cacheDir4, "standins", `${id}.json`);
|
|
15370
|
+
if (import_node_fs17.default.existsSync(cached3)) {
|
|
15371
|
+
const value = JSON.parse(import_node_fs17.default.readFileSync(cached3, "utf8"));
|
|
15220
15372
|
built.set(id, value);
|
|
15221
15373
|
return value;
|
|
15222
15374
|
}
|
|
15223
|
-
const work =
|
|
15375
|
+
const work = import_node_fs17.default.mkdtempSync(import_node_path17.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
15224
15376
|
let result;
|
|
15225
15377
|
try {
|
|
15226
15378
|
result = found.map((surface) => {
|
|
15227
|
-
const dir =
|
|
15379
|
+
const dir = import_node_path17.default.join(work, surface.module);
|
|
15228
15380
|
try {
|
|
15229
15381
|
return surface.kind === "swift" ? swiftStandin(surface, binary2, toolchain, dir) : cStandin(surface, binary2, toolchain, dir);
|
|
15230
15382
|
} catch (error) {
|
|
@@ -15233,13 +15385,13 @@ function binaryStandins(binary2, toolchain, provided) {
|
|
|
15233
15385
|
);
|
|
15234
15386
|
}
|
|
15235
15387
|
});
|
|
15236
|
-
|
|
15237
|
-
|
|
15388
|
+
import_node_fs17.default.mkdirSync(import_node_path17.default.dirname(cached3), { recursive: true });
|
|
15389
|
+
import_node_fs17.default.writeFileSync(cached3, JSON.stringify(result));
|
|
15238
15390
|
built.set(id, result);
|
|
15239
15391
|
} catch (error) {
|
|
15240
15392
|
result = error instanceof Error ? error.message : String(error);
|
|
15241
15393
|
} finally {
|
|
15242
|
-
|
|
15394
|
+
import_node_fs17.default.rmSync(work, { recursive: true, force: true });
|
|
15243
15395
|
}
|
|
15244
15396
|
return result;
|
|
15245
15397
|
}
|
|
@@ -15381,12 +15533,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
15381
15533
|
}
|
|
15382
15534
|
|
|
15383
15535
|
// src/xcode-project.ts
|
|
15384
|
-
var
|
|
15385
|
-
var
|
|
15536
|
+
var import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
15537
|
+
var import_node_path19 = __toESM(require("node:path"), 1);
|
|
15386
15538
|
var import_plist3 = __toESM(require_plist(), 1);
|
|
15387
15539
|
|
|
15388
15540
|
// src/xcode-json-project.ts
|
|
15389
|
-
var
|
|
15541
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
15390
15542
|
var import_json5 = __toESM(require_lib(), 1);
|
|
15391
15543
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15392
15544
|
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -15402,7 +15554,7 @@ var PHASE_ISA = {
|
|
|
15402
15554
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
15403
15555
|
const json = import_json5.default.parse(source);
|
|
15404
15556
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
15405
|
-
const projectDir =
|
|
15557
|
+
const projectDir = import_node_path18.default.dirname(xcodeproj);
|
|
15406
15558
|
const objects = {};
|
|
15407
15559
|
let next = 0;
|
|
15408
15560
|
const add = (entry, id) => {
|
|
@@ -15415,7 +15567,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
15415
15567
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
15416
15568
|
if (base) {
|
|
15417
15569
|
if (base[1] === "PROJECT")
|
|
15418
|
-
return { sourceTree: "<absolute>", path:
|
|
15570
|
+
return { sourceTree: "<absolute>", path: import_node_path18.default.join(projectDir, base[2]) };
|
|
15419
15571
|
if (base[1] === "PRODUCTS")
|
|
15420
15572
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
15421
15573
|
return null;
|
|
@@ -15423,7 +15575,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
15423
15575
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
15424
15576
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
15425
15577
|
if (unescaped.startsWith("~")) return null;
|
|
15426
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
15578
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path18.default.join(groupDir, unescaped) };
|
|
15427
15579
|
};
|
|
15428
15580
|
const memberships = [];
|
|
15429
15581
|
const folders = [];
|
|
@@ -15434,7 +15586,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
15434
15586
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
15435
15587
|
const raw2 = text2(entry.path) ?? "";
|
|
15436
15588
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
15437
|
-
const name2 = text2(entry.name) ??
|
|
15589
|
+
const name2 = text2(entry.name) ?? import_node_path18.default.basename(raw2);
|
|
15438
15590
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
15439
15591
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
15440
15592
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -15549,7 +15701,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
15549
15701
|
if (!isObject(entry)) continue;
|
|
15550
15702
|
const repository = text2(entry.repository);
|
|
15551
15703
|
const local = text2(entry.path);
|
|
15552
|
-
const name2 = local !== void 0 ?
|
|
15704
|
+
const name2 = local !== void 0 ? import_node_path18.default.basename(import_node_path18.default.resolve(import_node_path18.default.dirname(xcodeproj), local)) : import_node_path18.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
15553
15705
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
15554
15706
|
packageIds.set(name2.toLowerCase(), id);
|
|
15555
15707
|
}
|
|
@@ -15826,28 +15978,28 @@ var CONDITIONS = {
|
|
|
15826
15978
|
variant: "normal"
|
|
15827
15979
|
};
|
|
15828
15980
|
function walkFiles(dir) {
|
|
15829
|
-
if (!
|
|
15981
|
+
if (!import_node_fs18.default.existsSync(dir)) return [];
|
|
15830
15982
|
const out = [];
|
|
15831
|
-
for (const entry of
|
|
15983
|
+
for (const entry of import_node_fs18.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
15832
15984
|
if (entry.name.startsWith(".")) continue;
|
|
15833
|
-
const full =
|
|
15985
|
+
const full = import_node_path19.default.join(dir, entry.name);
|
|
15834
15986
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
15835
15987
|
else if (entry.isFile()) out.push(full);
|
|
15836
15988
|
}
|
|
15837
15989
|
return out;
|
|
15838
15990
|
}
|
|
15839
|
-
var isDirectory = (dir) =>
|
|
15991
|
+
var isDirectory = (dir) => import_node_fs18.default.existsSync(dir) && import_node_fs18.default.statSync(dir).isDirectory();
|
|
15840
15992
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
15841
|
-
if (seen.has(file) || !
|
|
15993
|
+
if (seen.has(file) || !import_node_fs18.default.existsSync(file)) return {};
|
|
15842
15994
|
seen.add(file);
|
|
15843
15995
|
const settings = {};
|
|
15844
|
-
for (const raw2 of
|
|
15996
|
+
for (const raw2 of import_node_fs18.default.readFileSync(file, "utf8").split("\n")) {
|
|
15845
15997
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
15846
15998
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
15847
15999
|
if (include) {
|
|
15848
16000
|
Object.assign(
|
|
15849
16001
|
settings,
|
|
15850
|
-
readXcconfig(
|
|
16002
|
+
readXcconfig(import_node_path19.default.resolve(import_node_path19.default.dirname(file), include[1]), seen)
|
|
15851
16003
|
);
|
|
15852
16004
|
continue;
|
|
15853
16005
|
}
|
|
@@ -15897,22 +16049,22 @@ function decodeXml(text3) {
|
|
|
15897
16049
|
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
15898
16050
|
}
|
|
15899
16051
|
function workspaceReferences(workspace) {
|
|
15900
|
-
const data =
|
|
15901
|
-
if (!
|
|
16052
|
+
const data = import_node_path19.default.join(workspace, "contents.xcworkspacedata");
|
|
16053
|
+
if (!import_node_fs18.default.existsSync(data))
|
|
15902
16054
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
15903
|
-
const container =
|
|
16055
|
+
const container = import_node_path19.default.dirname(workspace);
|
|
15904
16056
|
const locate = (location2, base) => {
|
|
15905
16057
|
const colon = location2.indexOf(":");
|
|
15906
16058
|
const kind = location2.slice(0, colon);
|
|
15907
16059
|
const rest = location2.slice(colon + 1);
|
|
15908
|
-
if (kind === "group") return
|
|
15909
|
-
if (kind === "container" || kind === "self") return
|
|
15910
|
-
if (kind === "absolute") return
|
|
15911
|
-
throw new Error(`${
|
|
16060
|
+
if (kind === "group") return import_node_path19.default.resolve(base, rest);
|
|
16061
|
+
if (kind === "container" || kind === "self") return import_node_path19.default.resolve(container, rest);
|
|
16062
|
+
if (kind === "absolute") return import_node_path19.default.resolve(rest);
|
|
16063
|
+
throw new Error(`${import_node_path19.default.basename(workspace)} has an unsupported location ${location2}`);
|
|
15912
16064
|
};
|
|
15913
16065
|
const groups = [container];
|
|
15914
16066
|
const references = [];
|
|
15915
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
16067
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs18.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
15916
16068
|
if (closing) {
|
|
15917
16069
|
if (tag === "Group") groups.pop();
|
|
15918
16070
|
continue;
|
|
@@ -15928,8 +16080,8 @@ function workspaceReferences(workspace) {
|
|
|
15928
16080
|
var loaded = /* @__PURE__ */ new Map();
|
|
15929
16081
|
function xcodeProjectFile(xcodeproj) {
|
|
15930
16082
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
15931
|
-
const file =
|
|
15932
|
-
if (
|
|
16083
|
+
const file = import_node_path19.default.join(xcodeproj, name2);
|
|
16084
|
+
if (import_node_fs18.default.existsSync(file)) return file;
|
|
15933
16085
|
}
|
|
15934
16086
|
return null;
|
|
15935
16087
|
}
|
|
@@ -15937,10 +16089,10 @@ function loadProject(xcodeproj) {
|
|
|
15937
16089
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
15938
16090
|
if (!projectFile)
|
|
15939
16091
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
15940
|
-
const mtimeMs =
|
|
16092
|
+
const mtimeMs = import_node_fs18.default.statSync(projectFile).mtimeMs;
|
|
15941
16093
|
const cached3 = loaded.get(projectFile);
|
|
15942
16094
|
if (cached3?.mtimeMs === mtimeMs) return cached3.project;
|
|
15943
|
-
const source =
|
|
16095
|
+
const source = import_node_fs18.default.readFileSync(projectFile, "utf8");
|
|
15944
16096
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
15945
16097
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
15946
16098
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -15954,8 +16106,8 @@ function loadProject(xcodeproj) {
|
|
|
15954
16106
|
if (!project || project.isa !== "PBXProject") {
|
|
15955
16107
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
15956
16108
|
}
|
|
15957
|
-
const projectDir =
|
|
15958
|
-
|
|
16109
|
+
const projectDir = import_node_fs18.default.realpathSync(
|
|
16110
|
+
import_node_path19.default.resolve(import_node_path19.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
15959
16111
|
);
|
|
15960
16112
|
const parent = /* @__PURE__ */ new Map();
|
|
15961
16113
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -15973,11 +16125,11 @@ function loadProject(xcodeproj) {
|
|
|
15973
16125
|
const own = str(entry.path) ?? "";
|
|
15974
16126
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
15975
16127
|
if (tree === "<absolute>") result2 = own;
|
|
15976
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
16128
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path19.default.join(projectDir, own);
|
|
15977
16129
|
else if (tree === "<group>") {
|
|
15978
16130
|
const up = parent.get(id);
|
|
15979
16131
|
const base = up ? resolvePath(up) : projectDir;
|
|
15980
|
-
result2 = base === null ? null :
|
|
16132
|
+
result2 = base === null ? null : import_node_path19.default.join(base, own);
|
|
15981
16133
|
}
|
|
15982
16134
|
}
|
|
15983
16135
|
resolvedPaths.set(id, result2);
|
|
@@ -16077,7 +16229,7 @@ function targetMembers(ref) {
|
|
|
16077
16229
|
const addResource = (file) => {
|
|
16078
16230
|
if (isDirectory(file)) {
|
|
16079
16231
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
16080
|
-
} else if (
|
|
16232
|
+
} else if (import_node_fs18.default.existsSync(file)) resources.add(file);
|
|
16081
16233
|
};
|
|
16082
16234
|
const fileRefPaths = (refId) => {
|
|
16083
16235
|
const entry = project.object(refId);
|
|
@@ -16098,7 +16250,7 @@ function targetMembers(ref) {
|
|
|
16098
16250
|
for (const buildFileId of list(phase.files)) {
|
|
16099
16251
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
16100
16252
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
16101
|
-
if (!
|
|
16253
|
+
if (!import_node_fs18.default.existsSync(file)) continue;
|
|
16102
16254
|
allSources.add(file);
|
|
16103
16255
|
if (file.endsWith(".swift")) sources.add(file);
|
|
16104
16256
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -16106,7 +16258,7 @@ function targetMembers(ref) {
|
|
|
16106
16258
|
}
|
|
16107
16259
|
}
|
|
16108
16260
|
const addSynchronized = (folder, relative2) => {
|
|
16109
|
-
const file =
|
|
16261
|
+
const file = import_node_path19.default.join(folder, relative2);
|
|
16110
16262
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
16111
16263
|
if (file.endsWith(".swift")) {
|
|
16112
16264
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -16131,7 +16283,7 @@ function targetMembers(ref) {
|
|
|
16131
16283
|
}
|
|
16132
16284
|
if (owned.has(groupId)) {
|
|
16133
16285
|
for (const file of walkFiles(folder)) {
|
|
16134
|
-
const relative2 =
|
|
16286
|
+
const relative2 = import_node_path19.default.relative(folder, file).split(import_node_path19.default.sep).join("/");
|
|
16135
16287
|
if ([...exceptions].some(
|
|
16136
16288
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
16137
16289
|
))
|
|
@@ -16140,14 +16292,14 @@ function targetMembers(ref) {
|
|
|
16140
16292
|
}
|
|
16141
16293
|
} else {
|
|
16142
16294
|
for (const relative2 of exceptions) {
|
|
16143
|
-
const file =
|
|
16295
|
+
const file = import_node_path19.default.join(folder, relative2);
|
|
16144
16296
|
if (isDirectory(file)) {
|
|
16145
16297
|
for (const inner of walkFiles(file))
|
|
16146
16298
|
addSynchronized(
|
|
16147
16299
|
folder,
|
|
16148
|
-
|
|
16300
|
+
import_node_path19.default.relative(folder, inner).split(import_node_path19.default.sep).join("/")
|
|
16149
16301
|
);
|
|
16150
|
-
} else if (
|
|
16302
|
+
} else if (import_node_fs18.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
16151
16303
|
}
|
|
16152
16304
|
}
|
|
16153
16305
|
}
|
|
@@ -16160,8 +16312,8 @@ function targetMembers(ref) {
|
|
|
16160
16312
|
function commonAncestor(dirs) {
|
|
16161
16313
|
let common = dirs[0];
|
|
16162
16314
|
for (const dir of dirs) {
|
|
16163
|
-
while (common !==
|
|
16164
|
-
common =
|
|
16315
|
+
while (common !== import_node_path19.default.dirname(common) && import_node_path19.default.relative(common, dir).startsWith(".."))
|
|
16316
|
+
common = import_node_path19.default.dirname(common);
|
|
16165
16317
|
}
|
|
16166
16318
|
return common;
|
|
16167
16319
|
}
|
|
@@ -16170,8 +16322,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
16170
16322
|
const projects2 = [];
|
|
16171
16323
|
const projectAt = /* @__PURE__ */ new Map();
|
|
16172
16324
|
const addProject = (xcodeproj) => {
|
|
16173
|
-
const key2 =
|
|
16174
|
-
if (projectAt.has(key2) || key2.split(
|
|
16325
|
+
const key2 = import_node_path19.default.resolve(xcodeproj);
|
|
16326
|
+
if (projectAt.has(key2) || key2.split(import_node_path19.default.sep).includes("Pods")) return;
|
|
16175
16327
|
if (!xcodeProjectFile(key2)) return;
|
|
16176
16328
|
const project = loadProject(key2);
|
|
16177
16329
|
projectAt.set(key2, project);
|
|
@@ -16188,7 +16340,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
16188
16340
|
for (const reference of listed)
|
|
16189
16341
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
16190
16342
|
if (projects2.length === 0) {
|
|
16191
|
-
throw new Error(`${
|
|
16343
|
+
throw new Error(`${import_node_path19.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
16192
16344
|
}
|
|
16193
16345
|
return { listed, projects: projects2, projectAt };
|
|
16194
16346
|
}
|
|
@@ -16210,7 +16362,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16210
16362
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
16211
16363
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
16212
16364
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
16213
|
-
const container =
|
|
16365
|
+
const container = import_node_path19.default.basename(xcodeprojOrWorkspace);
|
|
16214
16366
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
16215
16367
|
if (named.length !== 1) {
|
|
16216
16368
|
throw new Error(
|
|
@@ -16222,14 +16374,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16222
16374
|
for (const ref of allTargets) {
|
|
16223
16375
|
const product = ref.project.object(str(ref.target.productReference));
|
|
16224
16376
|
const file = str(product?.path);
|
|
16225
|
-
if (file && !byProduct.has(
|
|
16226
|
-
byProduct.set(
|
|
16377
|
+
if (file && !byProduct.has(import_node_path19.default.basename(file)))
|
|
16378
|
+
byProduct.set(import_node_path19.default.basename(file), ref);
|
|
16227
16379
|
}
|
|
16228
16380
|
const proxied = (project, proxyId) => {
|
|
16229
16381
|
const proxy = project.object(proxyId);
|
|
16230
16382
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
16231
16383
|
const portal = str(proxy.containerPortal);
|
|
16232
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
16384
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path19.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
16233
16385
|
const remote = str(proxy.remoteGlobalIDString);
|
|
16234
16386
|
if (!owner || !remote) return void 0;
|
|
16235
16387
|
return nativeTargets(owner).find(
|
|
@@ -16250,7 +16402,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16250
16402
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
16251
16403
|
for (const buildFileId of list(phase.files)) {
|
|
16252
16404
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
16253
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
16405
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path19.default.basename(str(file.path) ?? "")) : void 0;
|
|
16254
16406
|
if (resolved) found.push(resolved);
|
|
16255
16407
|
}
|
|
16256
16408
|
}
|
|
@@ -16271,7 +16423,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16271
16423
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
16272
16424
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
16273
16425
|
TARGET_NAME: name2,
|
|
16274
|
-
PROJECT_NAME:
|
|
16426
|
+
PROJECT_NAME: import_node_path19.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
16275
16427
|
SRCROOT: ref.project.projectDir,
|
|
16276
16428
|
SOURCE_ROOT: ref.project.projectDir,
|
|
16277
16429
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -16302,8 +16454,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16302
16454
|
}
|
|
16303
16455
|
return value;
|
|
16304
16456
|
};
|
|
16305
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
16306
|
-
const sourceInfo = infoPlistFile ? import_plist3.default.parse(
|
|
16457
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path19.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
16458
|
+
const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs18.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
16307
16459
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
16308
16460
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
16309
16461
|
}
|
|
@@ -16321,12 +16473,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16321
16473
|
};
|
|
16322
16474
|
}
|
|
16323
16475
|
const localPackageDirs = [
|
|
16324
|
-
...listed.filter((reference) =>
|
|
16476
|
+
...listed.filter((reference) => import_node_fs18.default.existsSync(import_node_path19.default.join(reference, "Package.swift"))),
|
|
16325
16477
|
...projects2.flatMap(
|
|
16326
16478
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
16327
16479
|
if (!isDict(entry)) return [];
|
|
16328
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
16329
|
-
return candidate &&
|
|
16480
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path19.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
16481
|
+
return candidate && import_node_fs18.default.existsSync(import_node_path19.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
16330
16482
|
})
|
|
16331
16483
|
)
|
|
16332
16484
|
];
|
|
@@ -16350,7 +16502,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16350
16502
|
product,
|
|
16351
16503
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
16352
16504
|
kind: "local",
|
|
16353
|
-
dir:
|
|
16505
|
+
dir: import_node_path19.default.resolve(
|
|
16354
16506
|
project.projectDir,
|
|
16355
16507
|
str(reference.relativePath) ?? ""
|
|
16356
16508
|
)
|
|
@@ -16372,8 +16524,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16372
16524
|
}
|
|
16373
16525
|
}
|
|
16374
16526
|
}
|
|
16375
|
-
const resolvedFile =
|
|
16376
|
-
workspace ??
|
|
16527
|
+
const resolvedFile = import_node_path19.default.join(
|
|
16528
|
+
workspace ?? import_node_path19.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
16377
16529
|
"xcshareddata",
|
|
16378
16530
|
"swiftpm",
|
|
16379
16531
|
"Package.resolved"
|
|
@@ -16383,13 +16535,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16383
16535
|
...module2,
|
|
16384
16536
|
rootDir: commonAncestor(
|
|
16385
16537
|
[
|
|
16386
|
-
workspace ?
|
|
16538
|
+
workspace ? import_node_path19.default.dirname(workspace) : app.project.projectDir,
|
|
16387
16539
|
...used.map((project) => project.projectDir),
|
|
16388
16540
|
...localPackageDirs,
|
|
16389
16541
|
...linkedProducts.flatMap(
|
|
16390
|
-
({ source }) => source.kind === "local" &&
|
|
16542
|
+
({ source }) => source.kind === "local" && import_node_fs18.default.existsSync(source.dir) ? [source.dir] : []
|
|
16391
16543
|
)
|
|
16392
|
-
].map((dir) =>
|
|
16544
|
+
].map((dir) => import_node_fs18.default.realpathSync(dir))
|
|
16393
16545
|
),
|
|
16394
16546
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
16395
16547
|
infoPlist: import_plist3.default.build(info),
|
|
@@ -16397,10 +16549,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
16397
16549
|
frameworks,
|
|
16398
16550
|
linkedProducts,
|
|
16399
16551
|
localPackageDirs: [
|
|
16400
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
16552
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs18.default.realpathSync(dir)))
|
|
16401
16553
|
].sort(),
|
|
16402
16554
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
16403
|
-
packageResolved:
|
|
16555
|
+
packageResolved: import_node_fs18.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
16404
16556
|
appTargets: appTargetNames
|
|
16405
16557
|
};
|
|
16406
16558
|
}
|
|
@@ -16420,17 +16572,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
16420
16572
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
16421
16573
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
16422
16574
|
function swiftPackageId(packagePath) {
|
|
16423
|
-
return
|
|
16575
|
+
return import_node_path20.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
16424
16576
|
}
|
|
16425
16577
|
function nativeSourceDescriptor(packagePath) {
|
|
16426
|
-
packagePath =
|
|
16427
|
-
const file =
|
|
16428
|
-
if (!
|
|
16578
|
+
packagePath = import_node_fs19.default.realpathSync(packagePath);
|
|
16579
|
+
const file = import_node_path20.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
16580
|
+
if (!import_node_fs19.default.existsSync(file)) return null;
|
|
16429
16581
|
const value = JSON.parse(
|
|
16430
16582
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
16431
16583
|
);
|
|
16432
16584
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
16433
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
16585
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs19.default.existsSync(import_node_path20.default.join(packagePath, NATIVE_GLUE))) {
|
|
16434
16586
|
throw invalid();
|
|
16435
16587
|
}
|
|
16436
16588
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -16442,7 +16594,7 @@ var SwiftMissingModulesError = class extends Error {
|
|
|
16442
16594
|
};
|
|
16443
16595
|
var projects = /* @__PURE__ */ new Map();
|
|
16444
16596
|
function projectFor(packagePath, hosted) {
|
|
16445
|
-
packagePath =
|
|
16597
|
+
packagePath = import_node_fs19.default.realpathSync(packagePath);
|
|
16446
16598
|
const existing = projects.get(packagePath);
|
|
16447
16599
|
if (existing) {
|
|
16448
16600
|
if (hosted && !existing.hosted) {
|
|
@@ -16464,14 +16616,14 @@ function projectFor(packagePath, hosted) {
|
|
|
16464
16616
|
}
|
|
16465
16617
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
16466
16618
|
function swiftPackages(entry, app) {
|
|
16467
|
-
const stamp = (file) => file &&
|
|
16619
|
+
const stamp = (file) => file && import_node_fs19.default.existsSync(file) ? import_node_fs19.default.statSync(file).mtimeMs : 0;
|
|
16468
16620
|
const key2 = JSON.stringify([
|
|
16469
16621
|
app.linkedProducts,
|
|
16470
16622
|
app.packageResolved,
|
|
16471
16623
|
stamp(app.packageResolved),
|
|
16472
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
16624
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path20.default.join(dir, "Package.swift"))),
|
|
16473
16625
|
app.linkedProducts.map(
|
|
16474
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
16626
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path20.default.join(source.dir, "Package.swift")) : 0
|
|
16475
16627
|
)
|
|
16476
16628
|
]);
|
|
16477
16629
|
let cached3 = entry.packages;
|
|
@@ -16522,11 +16674,11 @@ var XCODE_APP_DIR = "__app__";
|
|
|
16522
16674
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
16523
16675
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
16524
16676
|
var XCODE_STANDINS_DIR = "__standins__";
|
|
16525
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
16677
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)}/`;
|
|
16526
16678
|
function xcodeInputKey(layout, file, relative2) {
|
|
16527
16679
|
const owner = layout.targetDirs.get(file);
|
|
16528
|
-
if (owner) return
|
|
16529
|
-
return relative2.startsWith(CHECKOUTS_PREFIX) ?
|
|
16680
|
+
if (owner) return import_node_path20.default.posix.join(owner, relative2);
|
|
16681
|
+
return relative2.startsWith(CHECKOUTS_PREFIX) ? import_node_path20.default.posix.join(XCODE_PACKAGES_DIR, relative2.slice(CHECKOUTS_PREFIX.length)) : relative2;
|
|
16530
16682
|
}
|
|
16531
16683
|
function xcodeLayout(root) {
|
|
16532
16684
|
const registered = xcodeProjects.get(root);
|
|
@@ -16537,7 +16689,7 @@ function xcodeLayout(root) {
|
|
|
16537
16689
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
16538
16690
|
const targets = [];
|
|
16539
16691
|
for (const framework of app.frameworks) {
|
|
16540
|
-
const dir =
|
|
16692
|
+
const dir = import_node_path20.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
16541
16693
|
for (const file of framework.sources) {
|
|
16542
16694
|
if (targetDirs.has(file)) continue;
|
|
16543
16695
|
targetDirs.set(file, dir);
|
|
@@ -16557,7 +16709,7 @@ function xcodeLayout(root) {
|
|
|
16557
16709
|
for (const standin of standins)
|
|
16558
16710
|
targets.push({
|
|
16559
16711
|
name: standin.module,
|
|
16560
|
-
path:
|
|
16712
|
+
path: import_node_path20.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
16561
16713
|
executable: false,
|
|
16562
16714
|
resources: false,
|
|
16563
16715
|
exclude: [],
|
|
@@ -16565,19 +16717,19 @@ function xcodeLayout(root) {
|
|
|
16565
16717
|
mainActorIsolation: false
|
|
16566
16718
|
});
|
|
16567
16719
|
for (const target of packages.targets) {
|
|
16568
|
-
const relative2 =
|
|
16569
|
-
target.remote ?
|
|
16720
|
+
const relative2 = import_node_path20.default.relative(
|
|
16721
|
+
target.remote ? import_node_path20.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
16570
16722
|
target.dir
|
|
16571
16723
|
);
|
|
16572
|
-
if (relative2 === ".." || relative2.startsWith(`..${
|
|
16724
|
+
if (relative2 === ".." || relative2.startsWith(`..${import_node_path20.default.sep}`) || import_node_path20.default.isAbsolute(relative2))
|
|
16573
16725
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
16574
|
-
const posix2 = relative2.split(
|
|
16726
|
+
const posix2 = relative2.split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep);
|
|
16575
16727
|
targets.push({
|
|
16576
16728
|
...target,
|
|
16577
|
-
path: target.remote ?
|
|
16729
|
+
path: target.remote ? import_node_path20.default.posix.join(XCODE_PACKAGES_DIR, posix2) : posix2,
|
|
16578
16730
|
exclude: []
|
|
16579
16731
|
});
|
|
16580
|
-
if (!target.remote) files2.add(
|
|
16732
|
+
if (!target.remote) files2.add(import_node_path20.default.join(target.packageDir, "Package.swift"));
|
|
16581
16733
|
for (const file of target.files) files2.add(file);
|
|
16582
16734
|
}
|
|
16583
16735
|
for (const target of targets) {
|
|
@@ -16607,25 +16759,25 @@ function xcodeManifest(layout) {
|
|
|
16607
16759
|
].join("\n");
|
|
16608
16760
|
}
|
|
16609
16761
|
function packageFiles(root) {
|
|
16610
|
-
const canonicalRoot =
|
|
16762
|
+
const canonicalRoot = import_node_fs19.default.realpathSync(root);
|
|
16611
16763
|
const xcode = xcodeLayout(canonicalRoot);
|
|
16612
16764
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
16613
16765
|
}
|
|
16614
16766
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
16615
16767
|
const found = [];
|
|
16616
16768
|
const walk2 = (dir2) => {
|
|
16617
|
-
for (const entry of
|
|
16769
|
+
for (const entry of import_node_fs19.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
16618
16770
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
16619
16771
|
continue;
|
|
16620
|
-
const full =
|
|
16772
|
+
const full = import_node_path20.default.join(dir2, entry.name);
|
|
16621
16773
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
16622
|
-
const real =
|
|
16623
|
-
const relative2 =
|
|
16624
|
-
if (relative2.startsWith(`..${
|
|
16774
|
+
const real = import_node_fs19.default.realpathSync(full);
|
|
16775
|
+
const relative2 = import_node_path20.default.relative(canonicalRoot, real);
|
|
16776
|
+
if (relative2.startsWith(`..${import_node_path20.default.sep}`) || relative2 === ".." || import_node_path20.default.isAbsolute(relative2)) {
|
|
16625
16777
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
16626
16778
|
}
|
|
16627
16779
|
if (entry.isDirectory()) {
|
|
16628
|
-
if (
|
|
16780
|
+
if (import_node_fs19.default.existsSync(import_node_path20.default.join(full, "Package.swift"))) continue;
|
|
16629
16781
|
walk2(full);
|
|
16630
16782
|
} else if (entry.isFile()) {
|
|
16631
16783
|
found.push(full);
|
|
@@ -16633,56 +16785,15 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
16633
16785
|
}
|
|
16634
16786
|
}
|
|
16635
16787
|
};
|
|
16636
|
-
if (
|
|
16788
|
+
if (import_node_fs19.default.existsSync(dir)) walk2(import_node_fs19.default.realpathSync(dir));
|
|
16637
16789
|
return found;
|
|
16638
16790
|
}
|
|
16639
|
-
function readPackageFile(root, file, maxBytes) {
|
|
16640
|
-
const canonicalRoot = import_node_fs18.default.realpathSync(root);
|
|
16641
|
-
const relative2 = import_node_path19.default.relative(canonicalRoot, import_node_fs18.default.realpathSync(file));
|
|
16642
|
-
if (relative2 === ".." || relative2.startsWith(`..${import_node_path19.default.sep}`) || import_node_path19.default.isAbsolute(relative2)) {
|
|
16643
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
16644
|
-
}
|
|
16645
|
-
let ancestor = import_node_path19.default.resolve(file);
|
|
16646
|
-
while (ancestor !== canonicalRoot) {
|
|
16647
|
-
if (import_node_fs18.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
16648
|
-
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
16649
|
-
}
|
|
16650
|
-
const parent = import_node_path19.default.dirname(ancestor);
|
|
16651
|
-
if (parent === ancestor)
|
|
16652
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
16653
|
-
ancestor = parent;
|
|
16654
|
-
}
|
|
16655
|
-
const expected = import_node_fs18.default.statSync(file);
|
|
16656
|
-
const fd = import_node_fs18.default.openSync(file, import_node_fs18.default.constants.O_RDONLY | import_node_fs18.default.constants.O_NOFOLLOW);
|
|
16657
|
-
try {
|
|
16658
|
-
const stat2 = import_node_fs18.default.fstatSync(fd);
|
|
16659
|
-
if (stat2.dev !== expected.dev || stat2.ino !== expected.ino) {
|
|
16660
|
-
throw new Error(`swift input changed while opening: ${file}`);
|
|
16661
|
-
}
|
|
16662
|
-
if (!stat2.isFile() || stat2.size > maxBytes) {
|
|
16663
|
-
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
16664
|
-
}
|
|
16665
|
-
const bytes = Buffer.alloc(stat2.size + 1);
|
|
16666
|
-
let offset = 0;
|
|
16667
|
-
while (offset < bytes.length) {
|
|
16668
|
-
const count = import_node_fs18.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
16669
|
-
if (count === 0) break;
|
|
16670
|
-
offset += count;
|
|
16671
|
-
}
|
|
16672
|
-
if (offset !== stat2.size || import_node_fs18.default.fstatSync(fd).size !== stat2.size) {
|
|
16673
|
-
throw new Error(`swift input changed while reading: ${file}`);
|
|
16674
|
-
}
|
|
16675
|
-
return bytes.subarray(0, offset);
|
|
16676
|
-
} finally {
|
|
16677
|
-
import_node_fs18.default.closeSync(fd);
|
|
16678
|
-
}
|
|
16679
|
-
}
|
|
16680
16791
|
function sourceFiles(root) {
|
|
16681
16792
|
return packageFiles(root).filter((file) => file.endsWith(".swift"));
|
|
16682
16793
|
}
|
|
16683
16794
|
function resourceCandidateFiles(root) {
|
|
16684
16795
|
return packageFiles(root).filter(
|
|
16685
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
16796
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path20.default.basename(file))
|
|
16686
16797
|
);
|
|
16687
16798
|
}
|
|
16688
16799
|
var HOSTED_LIMITS = {
|
|
@@ -16716,7 +16827,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
16716
16827
|
const limits = inputLimits(Boolean(project.hosted));
|
|
16717
16828
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
16718
16829
|
const relative2 = absolute.map(
|
|
16719
|
-
(file) =>
|
|
16830
|
+
(file) => import_node_path20.default.relative(project.packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)
|
|
16720
16831
|
);
|
|
16721
16832
|
const byRelative = new Map(absolute.map((file, index) => [relative2[index], file]));
|
|
16722
16833
|
const readContents = (candidate) => {
|
|
@@ -16738,16 +16849,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
16738
16849
|
for (const { name: name2, file, scale } of found) {
|
|
16739
16850
|
const disk = byRelative.get(file);
|
|
16740
16851
|
if (!disk) continue;
|
|
16741
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
16852
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs19.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
16742
16853
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
16743
16854
|
}
|
|
16744
16855
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
16745
16856
|
imageBytes += bytes.length;
|
|
16746
16857
|
const hash = (0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
16747
|
-
const ext =
|
|
16858
|
+
const ext = import_node_path20.default.posix.extname(file).toLowerCase();
|
|
16748
16859
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
16749
16860
|
images[name2] = {
|
|
16750
|
-
file:
|
|
16861
|
+
file: import_node_path20.default.posix.basename(file),
|
|
16751
16862
|
data: bytes.toString("base64")
|
|
16752
16863
|
};
|
|
16753
16864
|
watched.push(file);
|
|
@@ -16771,10 +16882,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
16771
16882
|
return { table, images, colors, symbols, watched };
|
|
16772
16883
|
}
|
|
16773
16884
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
16774
|
-
packagePath =
|
|
16885
|
+
packagePath = import_node_fs19.default.realpathSync(packagePath);
|
|
16775
16886
|
const limits = inputLimits(hosted);
|
|
16776
16887
|
const relative2 = resourceCandidateFiles(packagePath).map(
|
|
16777
|
-
(file) =>
|
|
16888
|
+
(file) => import_node_path20.default.relative(packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)
|
|
16778
16889
|
);
|
|
16779
16890
|
const files2 = {};
|
|
16780
16891
|
const watched = [];
|
|
@@ -16788,13 +16899,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
16788
16899
|
total += bytes.length;
|
|
16789
16900
|
if (xcode.app.infoPlistFile)
|
|
16790
16901
|
watched.push(
|
|
16791
|
-
|
|
16902
|
+
import_node_path20.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path20.default.sep).join("/")
|
|
16792
16903
|
);
|
|
16793
16904
|
}
|
|
16794
16905
|
for (const { base, file } of enumerateBundleJson(relative2)) {
|
|
16795
16906
|
watched.push(file);
|
|
16796
|
-
const disk =
|
|
16797
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
16907
|
+
const disk = import_node_path20.default.join(packagePath, ...file.split("/"));
|
|
16908
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs19.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
16798
16909
|
throw new Error(
|
|
16799
16910
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
16800
16911
|
);
|
|
@@ -16809,12 +16920,12 @@ function serveSwiftResource(project, key2) {
|
|
|
16809
16920
|
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
16810
16921
|
}
|
|
16811
16922
|
function linkedModuleRoots(packagePath) {
|
|
16812
|
-
packagePath =
|
|
16923
|
+
packagePath = import_node_fs19.default.realpathSync(packagePath);
|
|
16813
16924
|
let manifest;
|
|
16814
16925
|
try {
|
|
16815
16926
|
manifest = readPackageFile(
|
|
16816
16927
|
packagePath,
|
|
16817
|
-
|
|
16928
|
+
import_node_path20.default.join(packagePath, "Package.swift"),
|
|
16818
16929
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
16819
16930
|
).toString("utf8");
|
|
16820
16931
|
} catch {
|
|
@@ -16823,8 +16934,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
16823
16934
|
const roots = /* @__PURE__ */ new Set();
|
|
16824
16935
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
16825
16936
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
16826
|
-
const root =
|
|
16827
|
-
if (
|
|
16937
|
+
const root = import_node_path20.default.resolve(packagePath, match[1]);
|
|
16938
|
+
if (import_node_fs19.default.existsSync(import_node_path20.default.join(root, "Package.swift"))) roots.add(root);
|
|
16828
16939
|
}
|
|
16829
16940
|
return [...roots].sort();
|
|
16830
16941
|
}
|
|
@@ -16833,18 +16944,18 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
16833
16944
|
hash.update(packagePath);
|
|
16834
16945
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
16835
16946
|
for (const file of [...projectInputs].sort()) {
|
|
16836
|
-
hash.update(
|
|
16837
|
-
const stat2 =
|
|
16947
|
+
hash.update(import_node_path20.default.relative(packagePath, file));
|
|
16948
|
+
const stat2 = import_node_fs19.default.statSync(file);
|
|
16838
16949
|
hash.update(`${stat2.mtimeMs}/${stat2.ctimeMs}/${stat2.size}`);
|
|
16839
16950
|
}
|
|
16840
16951
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
16841
|
-
(root) =>
|
|
16952
|
+
(root) => import_node_fs19.default.existsSync(import_node_path20.default.join(root, "toolchain.json"))
|
|
16842
16953
|
);
|
|
16843
16954
|
if (moduleRoot) {
|
|
16844
16955
|
hash.update(moduleRoot);
|
|
16845
16956
|
for (const relative2 of swiftModuleInputFiles(moduleRoot)) {
|
|
16846
16957
|
hash.update(relative2);
|
|
16847
|
-
hash.update(String(
|
|
16958
|
+
hash.update(String(import_node_fs19.default.statSync(import_node_path20.default.join(moduleRoot, relative2)).mtimeMs));
|
|
16848
16959
|
}
|
|
16849
16960
|
}
|
|
16850
16961
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -16856,8 +16967,8 @@ function packageSources(packagePath) {
|
|
|
16856
16967
|
const xcode = xcodeLayout(packagePath);
|
|
16857
16968
|
const files2 = {};
|
|
16858
16969
|
for (const file of sourceFiles(packagePath)) {
|
|
16859
|
-
const relative2 =
|
|
16860
|
-
if (xcode &&
|
|
16970
|
+
const relative2 = import_node_path20.default.relative(packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep);
|
|
16971
|
+
if (xcode && import_node_path20.default.basename(file) === "Package.swift") continue;
|
|
16861
16972
|
files2[xcode ? xcodeInputKey(xcode, file, relative2) : relative2] = readPackageFile(
|
|
16862
16973
|
packagePath,
|
|
16863
16974
|
file,
|
|
@@ -16868,7 +16979,7 @@ function packageSources(packagePath) {
|
|
|
16868
16979
|
files2["Package.swift"] = xcodeManifest(xcode);
|
|
16869
16980
|
for (const standin of xcode.standins)
|
|
16870
16981
|
for (const [file, text3] of Object.entries(standin.files))
|
|
16871
|
-
files2[
|
|
16982
|
+
files2[import_node_path20.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
16872
16983
|
}
|
|
16873
16984
|
return files2;
|
|
16874
16985
|
}
|
|
@@ -16879,7 +16990,7 @@ function packageSnapshot(project) {
|
|
|
16879
16990
|
files: files2,
|
|
16880
16991
|
resourcePaths: swiftImplicitResourcePaths(
|
|
16881
16992
|
resourceCandidateFiles(project.packagePath).map(
|
|
16882
|
-
(file) =>
|
|
16993
|
+
(file) => import_node_path20.default.relative(project.packagePath, file).split(import_node_path20.default.sep).join(import_node_path20.default.posix.sep)
|
|
16883
16994
|
)
|
|
16884
16995
|
),
|
|
16885
16996
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -16888,7 +16999,7 @@ function packageSnapshot(project) {
|
|
|
16888
16999
|
...native ? {
|
|
16889
17000
|
glue: readPackageFile(
|
|
16890
17001
|
project.packagePath,
|
|
16891
|
-
|
|
17002
|
+
import_node_path20.default.join(project.packagePath, NATIVE_GLUE),
|
|
16892
17003
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
16893
17004
|
).toString("utf8")
|
|
16894
17005
|
} : {}
|
|
@@ -16924,7 +17035,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
16924
17035
|
package: content
|
|
16925
17036
|
};
|
|
16926
17037
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
16927
|
-
(root) =>
|
|
17038
|
+
(root) => import_node_fs19.default.existsSync(import_node_path20.default.join(root, "toolchain.json"))
|
|
16928
17039
|
) ?? await swiftDistributionRoot();
|
|
16929
17040
|
if (!moduleRoot)
|
|
16930
17041
|
return {
|
|
@@ -16951,10 +17062,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
16951
17062
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
16952
17063
|
// each app and module checkout gets its own root, which keeps the same
|
|
16953
17064
|
// app's incremental build across restarts.
|
|
16954
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
17065
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path20.default.join(
|
|
16955
17066
|
import_node_os8.default.tmpdir(),
|
|
16956
17067
|
"contrast-swift-build",
|
|
16957
|
-
(0, import_node_crypto8.createHash)("sha256").update(`${moduleRoot}\0${
|
|
17068
|
+
(0, import_node_crypto8.createHash)("sha256").update(`${moduleRoot}\0${import_node_path20.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
16958
17069
|
),
|
|
16959
17070
|
moduleRoot,
|
|
16960
17071
|
...toolchain
|
|
@@ -17066,7 +17177,7 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
17066
17177
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
17067
17178
|
...[...missing].map(([name2, files2]) => {
|
|
17068
17179
|
const gap = gaps.get(name2);
|
|
17069
|
-
return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${
|
|
17180
|
+
return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path20.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
17070
17181
|
})
|
|
17071
17182
|
].join("\n");
|
|
17072
17183
|
}
|
|
@@ -17074,7 +17185,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
17074
17185
|
const auth = hosted ? null : resolveCliAuth();
|
|
17075
17186
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
17076
17187
|
throw new Error(
|
|
17077
|
-
`compiling ${
|
|
17188
|
+
`compiling ${import_node_path20.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
17078
17189
|
);
|
|
17079
17190
|
}
|
|
17080
17191
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -17093,7 +17204,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
17093
17204
|
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
17094
17205
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
17095
17206
|
throw new Error(
|
|
17096
|
-
`${
|
|
17207
|
+
`${import_node_path20.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
|
|
17097
17208
|
);
|
|
17098
17209
|
}
|
|
17099
17210
|
const descriptor = snapshot.native;
|
|
@@ -17112,7 +17223,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
17112
17223
|
);
|
|
17113
17224
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
17114
17225
|
throw new Error(
|
|
17115
|
-
`${
|
|
17226
|
+
`${import_node_path20.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
|
|
17116
17227
|
);
|
|
17117
17228
|
}
|
|
17118
17229
|
const response = await fetch(address.url, { signal });
|
|
@@ -17236,8 +17347,8 @@ var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
|
17236
17347
|
var EXPO_SWIFT_ROUTE = "/__peach/expo-swift";
|
|
17237
17348
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
17238
17349
|
async function collectExpoSwiftSources(appRoot) {
|
|
17239
|
-
appRoot =
|
|
17240
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
17350
|
+
appRoot = import_node_fs20.default.realpathSync(appRoot);
|
|
17351
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path21.default.join(appRoot, "package.json"));
|
|
17241
17352
|
let autolinker;
|
|
17242
17353
|
try {
|
|
17243
17354
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -17251,7 +17362,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
17251
17362
|
(command) => run3(
|
|
17252
17363
|
process.execPath,
|
|
17253
17364
|
[
|
|
17254
|
-
|
|
17365
|
+
import_node_path21.default.join(import_node_path21.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
17255
17366
|
command,
|
|
17256
17367
|
"--platform",
|
|
17257
17368
|
"apple",
|
|
@@ -17282,8 +17393,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
17282
17393
|
const sourceRoot = Reflect.get(entry, "path");
|
|
17283
17394
|
if (typeof sourceRoot !== "string")
|
|
17284
17395
|
throw new Error("Expo autolinking entry has no path");
|
|
17285
|
-
const canonical =
|
|
17286
|
-
if (canonical.split(
|
|
17396
|
+
const canonical = import_node_fs20.default.realpathSync(sourceRoot);
|
|
17397
|
+
if (canonical.split(import_node_path21.default.sep).includes("node_modules")) continue;
|
|
17287
17398
|
const resolution = resolutions.find(
|
|
17288
17399
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
17289
17400
|
);
|
|
@@ -17310,12 +17421,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
17310
17421
|
registration: `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
17311
17422
|
});
|
|
17312
17423
|
}
|
|
17313
|
-
const ios =
|
|
17314
|
-
if (
|
|
17424
|
+
const ios = import_node_path21.default.join(canonical, "ios");
|
|
17425
|
+
if (import_node_fs20.default.lstatSync(ios).isSymbolicLink())
|
|
17315
17426
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
17316
17427
|
const walk2 = (dir) => {
|
|
17317
|
-
for (const child of
|
|
17318
|
-
const file =
|
|
17428
|
+
for (const child of import_node_fs20.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
17429
|
+
const file = import_node_path21.default.join(dir, child.name);
|
|
17319
17430
|
if (child.isSymbolicLink())
|
|
17320
17431
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
17321
17432
|
if (child.isDirectory()) {
|
|
@@ -17323,13 +17434,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
17323
17434
|
continue;
|
|
17324
17435
|
}
|
|
17325
17436
|
if (!child.name.endsWith(".swift")) continue;
|
|
17326
|
-
const size =
|
|
17437
|
+
const size = import_node_fs20.default.statSync(file).size;
|
|
17327
17438
|
bytes += size;
|
|
17328
17439
|
fileCount++;
|
|
17329
17440
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
17330
17441
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
17331
|
-
files2[`Sources/${namespace}/${
|
|
17332
|
-
${
|
|
17442
|
+
files2[`Sources/${namespace}/${import_node_path21.default.relative(ios, file).split(import_node_path21.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
17443
|
+
${import_node_fs20.default.readFileSync(file, "utf8")}`;
|
|
17333
17444
|
}
|
|
17334
17445
|
};
|
|
17335
17446
|
walk2(ios);
|
|
@@ -17415,7 +17526,7 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
17415
17526
|
modules: [],
|
|
17416
17527
|
failures: []
|
|
17417
17528
|
};
|
|
17418
|
-
const key2 = (0, import_node_crypto9.createHash)("sha256").update(
|
|
17529
|
+
const key2 = (0, import_node_crypto9.createHash)("sha256").update(import_node_fs20.default.realpathSync(root)).digest("hex");
|
|
17419
17530
|
const linked = [];
|
|
17420
17531
|
for (const unit of units) {
|
|
17421
17532
|
if (!module2) {
|
|
@@ -17425,14 +17536,14 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
17425
17536
|
});
|
|
17426
17537
|
continue;
|
|
17427
17538
|
}
|
|
17428
|
-
const packagePath =
|
|
17539
|
+
const packagePath = import_node_path21.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, unit.moduleId);
|
|
17429
17540
|
let stamp;
|
|
17430
17541
|
try {
|
|
17431
17542
|
syncSwiftTree(
|
|
17432
17543
|
packagePath,
|
|
17433
17544
|
new Map(
|
|
17434
17545
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
17435
|
-
|
|
17546
|
+
import_node_path21.default.join(packagePath, name2),
|
|
17436
17547
|
source
|
|
17437
17548
|
])
|
|
17438
17549
|
)
|
|
@@ -17457,10 +17568,13 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
17457
17568
|
const file = JSON.parse(match[1]);
|
|
17458
17569
|
return typeof file === "string" ? [file] : [];
|
|
17459
17570
|
});
|
|
17460
|
-
const
|
|
17461
|
-
|
|
17571
|
+
const errors = diagnostic.match(/^.+:\d+(?::\d+)?: error:.*$/gm) ?? [];
|
|
17572
|
+
const sourceErrors = errors.filter(
|
|
17573
|
+
(line) => appPaths.some((file) => line.startsWith(`${file}:`)) && !/external macro implementation type|failed to load library plugin/.test(line)
|
|
17574
|
+
);
|
|
17575
|
+
if (publishArtifact && (sourceErrors.length === 0 || sourceErrors.length !== errors.length) && !(error instanceof SwiftMissingModulesError))
|
|
17462
17576
|
throw error;
|
|
17463
|
-
if (sourceErrors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
|
|
17577
|
+
if (sourceErrors.length && sourceErrors.length === errors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
|
|
17464
17578
|
failedCompilations.set(packagePath, {
|
|
17465
17579
|
stamp,
|
|
17466
17580
|
diagnostic: sourceErrors.join("\n")
|
|
@@ -17490,12 +17604,12 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
17490
17604
|
import PackageDescription
|
|
17491
17605
|
let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.target(name: ${JSON.stringify(name2)}, path: ${JSON.stringify(`Sources/${name2}`)})`).join(", ")}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])
|
|
17492
17606
|
`;
|
|
17493
|
-
const packagePath =
|
|
17607
|
+
const packagePath = import_node_path21.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, "linked-app");
|
|
17494
17608
|
syncSwiftTree(
|
|
17495
17609
|
packagePath,
|
|
17496
17610
|
new Map(
|
|
17497
17611
|
Object.entries(files2).map(([name2, source]) => [
|
|
17498
|
-
|
|
17612
|
+
import_node_path21.default.join(packagePath, name2),
|
|
17499
17613
|
source
|
|
17500
17614
|
])
|
|
17501
17615
|
)
|
|
@@ -17538,7 +17652,7 @@ async function handleExpoSwiftRequest(req, res) {
|
|
|
17538
17652
|
return true;
|
|
17539
17653
|
}
|
|
17540
17654
|
const root = url.searchParams.get("root");
|
|
17541
|
-
if (!root || !
|
|
17655
|
+
if (!root || !import_node_path21.default.isAbsolute(root)) {
|
|
17542
17656
|
res.writeHead(400);
|
|
17543
17657
|
res.end("missing absolute app root");
|
|
17544
17658
|
return true;
|
|
@@ -17705,19 +17819,19 @@ var rnxRuntime = createRuntimeDelivery(RNX_RUNTIME_PRODUCT);
|
|
|
17705
17819
|
|
|
17706
17820
|
// src/host/agent-host.ts
|
|
17707
17821
|
var import_node_crypto12 = require("node:crypto");
|
|
17708
|
-
var
|
|
17709
|
-
var
|
|
17822
|
+
var import_node_fs24 = __toESM(require("node:fs"), 1);
|
|
17823
|
+
var import_node_path25 = __toESM(require("node:path"), 1);
|
|
17710
17824
|
|
|
17711
17825
|
// src/agent-sessions.ts
|
|
17712
17826
|
var import_node_child_process10 = require("node:child_process");
|
|
17713
17827
|
var import_node_crypto11 = require("node:crypto");
|
|
17714
|
-
var
|
|
17715
|
-
var
|
|
17828
|
+
var import_node_fs23 = __toESM(require("node:fs"), 1);
|
|
17829
|
+
var import_node_path24 = __toESM(require("node:path"), 1);
|
|
17716
17830
|
var import_node_readline = __toESM(require("node:readline"), 1);
|
|
17717
17831
|
|
|
17718
17832
|
// cli/self-invocation.ts
|
|
17719
|
-
var
|
|
17720
|
-
var
|
|
17833
|
+
var import_node_fs21 = require("node:fs");
|
|
17834
|
+
var import_node_path22 = require("node:path");
|
|
17721
17835
|
var import_node_url3 = require("node:url");
|
|
17722
17836
|
init_public_brand();
|
|
17723
17837
|
|
|
@@ -17727,14 +17841,14 @@ var IS_STANDALONE = typeof __SOOTSIM_STANDALONE__ !== "undefined" && __SOOTSIM_S
|
|
|
17727
17841
|
// cli/self-invocation.ts
|
|
17728
17842
|
function sourceEntryPath() {
|
|
17729
17843
|
try {
|
|
17730
|
-
const candidate = (0,
|
|
17731
|
-
return (0,
|
|
17844
|
+
const candidate = (0, import_node_path22.join)((0, import_node_path22.dirname)((0, import_node_url3.fileURLToPath)(__sootsim_import_meta_url)), "bin.ts");
|
|
17845
|
+
return (0, import_node_fs21.existsSync)(candidate) ? candidate : null;
|
|
17732
17846
|
} catch {
|
|
17733
17847
|
return null;
|
|
17734
17848
|
}
|
|
17735
17849
|
}
|
|
17736
|
-
function isCliEntry(
|
|
17737
|
-
const name2 = (0,
|
|
17850
|
+
function isCliEntry(path25) {
|
|
17851
|
+
const name2 = (0, import_node_path22.basename)(path25);
|
|
17738
17852
|
return name2 === "bin.ts" || name2 === "bin.js";
|
|
17739
17853
|
}
|
|
17740
17854
|
function rnxSelfInvocation() {
|
|
@@ -17794,8 +17908,8 @@ function encodeAgentPromptEnvelope(input) {
|
|
|
17794
17908
|
|
|
17795
17909
|
// src/attached-projects.ts
|
|
17796
17910
|
var import_node_crypto10 = require("node:crypto");
|
|
17797
|
-
var
|
|
17798
|
-
var
|
|
17911
|
+
var import_node_fs22 = __toESM(require("node:fs"), 1);
|
|
17912
|
+
var import_node_path23 = __toESM(require("node:path"), 1);
|
|
17799
17913
|
init_home_paths();
|
|
17800
17914
|
var overrideDir = null;
|
|
17801
17915
|
function userDataDir() {
|
|
@@ -17808,7 +17922,7 @@ function getUserDataDir() {
|
|
|
17808
17922
|
return userDataDir();
|
|
17809
17923
|
}
|
|
17810
17924
|
function storeFile() {
|
|
17811
|
-
return
|
|
17925
|
+
return import_node_path23.default.join(userDataDir(), "attached-projects.json");
|
|
17812
17926
|
}
|
|
17813
17927
|
function cloneEmpty() {
|
|
17814
17928
|
return {
|
|
@@ -17822,7 +17936,7 @@ function loadStore() {
|
|
|
17822
17936
|
const file = storeFile();
|
|
17823
17937
|
let raw2;
|
|
17824
17938
|
try {
|
|
17825
|
-
raw2 =
|
|
17939
|
+
raw2 = import_node_fs22.default.readFileSync(file, "utf8");
|
|
17826
17940
|
} catch (err) {
|
|
17827
17941
|
if (err.code === "ENOENT") return cloneEmpty();
|
|
17828
17942
|
throw err;
|
|
@@ -17839,7 +17953,7 @@ function loadStore() {
|
|
|
17839
17953
|
} catch (err) {
|
|
17840
17954
|
const quarantine = `${file}.corrupt-${Date.now()}`;
|
|
17841
17955
|
try {
|
|
17842
|
-
|
|
17956
|
+
import_node_fs22.default.renameSync(file, quarantine);
|
|
17843
17957
|
console.warn(
|
|
17844
17958
|
`[sootsim] attached-projects.json was unparseable; quarantined to ${quarantine}. original error: ${err.message}`
|
|
17845
17959
|
);
|
|
@@ -17850,16 +17964,16 @@ function loadStore() {
|
|
|
17850
17964
|
}
|
|
17851
17965
|
function writeStore(store) {
|
|
17852
17966
|
const file = storeFile();
|
|
17853
|
-
|
|
17967
|
+
import_node_fs22.default.mkdirSync(import_node_path23.default.dirname(file), { recursive: true });
|
|
17854
17968
|
const tmp = `${file}.tmp-${process.pid}-${Date.now()}`;
|
|
17855
|
-
const fd =
|
|
17969
|
+
const fd = import_node_fs22.default.openSync(tmp, "w", 384);
|
|
17856
17970
|
try {
|
|
17857
|
-
|
|
17858
|
-
|
|
17971
|
+
import_node_fs22.default.writeFileSync(fd, JSON.stringify(store, null, 2));
|
|
17972
|
+
import_node_fs22.default.fsyncSync(fd);
|
|
17859
17973
|
} finally {
|
|
17860
|
-
|
|
17974
|
+
import_node_fs22.default.closeSync(fd);
|
|
17861
17975
|
}
|
|
17862
|
-
|
|
17976
|
+
import_node_fs22.default.renameSync(tmp, file);
|
|
17863
17977
|
}
|
|
17864
17978
|
function mutateStore(fn) {
|
|
17865
17979
|
const store = loadStore();
|
|
@@ -17868,13 +17982,13 @@ function mutateStore(fn) {
|
|
|
17868
17982
|
return store;
|
|
17869
17983
|
}
|
|
17870
17984
|
function projectIdForCwd(cwd) {
|
|
17871
|
-
return (0, import_node_crypto10.createHash)("sha256").update(
|
|
17985
|
+
return (0, import_node_crypto10.createHash)("sha256").update(import_node_path23.default.resolve(cwd)).digest("hex").slice(0, 16);
|
|
17872
17986
|
}
|
|
17873
17987
|
function newSessionId() {
|
|
17874
17988
|
return `s_${(0, import_node_crypto10.randomBytes)(10).toString("hex")}`;
|
|
17875
17989
|
}
|
|
17876
17990
|
function upsertProject(input) {
|
|
17877
|
-
const cwd =
|
|
17991
|
+
const cwd = import_node_path23.default.resolve(input.cwd);
|
|
17878
17992
|
const id = projectIdForCwd(cwd);
|
|
17879
17993
|
let result;
|
|
17880
17994
|
mutateStore((store) => {
|
|
@@ -17900,7 +18014,7 @@ function upsertProject(input) {
|
|
|
17900
18014
|
const now = Date.now();
|
|
17901
18015
|
const created = {
|
|
17902
18016
|
id,
|
|
17903
|
-
name: input.name ??
|
|
18017
|
+
name: input.name ?? import_node_path23.default.basename(cwd),
|
|
17904
18018
|
cwd,
|
|
17905
18019
|
repoRoot: input.repoRoot,
|
|
17906
18020
|
sourceRoots: input.sourceRoots ?? [cwd],
|
|
@@ -18046,8 +18160,8 @@ async function seedFromDemoAppRegistry() {
|
|
|
18046
18160
|
if (apps.length === 0) return;
|
|
18047
18161
|
mutateStore((store) => {
|
|
18048
18162
|
for (const app of apps) {
|
|
18049
|
-
if (!
|
|
18050
|
-
const cwd =
|
|
18163
|
+
if (!import_node_fs22.default.existsSync(app.dir)) continue;
|
|
18164
|
+
const cwd = import_node_path23.default.resolve(app.dir);
|
|
18051
18165
|
const id = projectIdForCwd(cwd);
|
|
18052
18166
|
if (store.attachedProjects.some((p) => p.id === id)) continue;
|
|
18053
18167
|
const now = Date.now();
|
|
@@ -18072,16 +18186,16 @@ async function seedFromDemoAppRegistry() {
|
|
|
18072
18186
|
// src/agent-sessions.ts
|
|
18073
18187
|
init_public_brand();
|
|
18074
18188
|
function sessionDir(sessionId) {
|
|
18075
|
-
return
|
|
18189
|
+
return import_node_path24.default.join(getUserDataDir(), "sessions", sessionId);
|
|
18076
18190
|
}
|
|
18077
18191
|
function promptFifoPath(sessionId) {
|
|
18078
|
-
return
|
|
18192
|
+
return import_node_path24.default.join(sessionDir(sessionId), "prompt.in");
|
|
18079
18193
|
}
|
|
18080
18194
|
function eventsFifoPath(sessionId) {
|
|
18081
|
-
return
|
|
18195
|
+
return import_node_path24.default.join(sessionDir(sessionId), "events.out");
|
|
18082
18196
|
}
|
|
18083
18197
|
function transcriptPath(sessionId) {
|
|
18084
|
-
return
|
|
18198
|
+
return import_node_path24.default.join(getUserDataDir(), "transcripts", `${sessionId}.log`);
|
|
18085
18199
|
}
|
|
18086
18200
|
function pidIsAlive(pid, sessionId) {
|
|
18087
18201
|
if (!pid) return false;
|
|
@@ -18091,7 +18205,7 @@ function pidIsAlive(pid, sessionId) {
|
|
|
18091
18205
|
return false;
|
|
18092
18206
|
}
|
|
18093
18207
|
if (sessionId) {
|
|
18094
|
-
if (!
|
|
18208
|
+
if (!import_node_fs23.default.existsSync(sessionDir(sessionId))) return false;
|
|
18095
18209
|
}
|
|
18096
18210
|
return true;
|
|
18097
18211
|
}
|
|
@@ -18104,11 +18218,11 @@ function resolveSootsimInvocation() {
|
|
|
18104
18218
|
const resourcesPath = process.resourcesPath;
|
|
18105
18219
|
if (resourcesPath) {
|
|
18106
18220
|
const candidates = [
|
|
18107
|
-
|
|
18108
|
-
|
|
18221
|
+
import_node_path24.default.join(resourcesPath, "bin", "sootsim"),
|
|
18222
|
+
import_node_path24.default.join(resourcesPath, "bin", `sootsim-${process.platform}-${process.arch}`)
|
|
18109
18223
|
];
|
|
18110
18224
|
for (const c of candidates) {
|
|
18111
|
-
if (
|
|
18225
|
+
if (import_node_fs23.default.existsSync(c)) return { executable: c, prefixArgs: [] };
|
|
18112
18226
|
}
|
|
18113
18227
|
}
|
|
18114
18228
|
}
|
|
@@ -18127,15 +18241,15 @@ function tryWorkspaceSootsim() {
|
|
|
18127
18241
|
const sootsimDir = resolveSootsimPackageDir();
|
|
18128
18242
|
if (!sootsimDir) return null;
|
|
18129
18243
|
const binaryName = `peach-${process.platform === "win32" ? "windows" : process.platform}-${process.arch}${process.platform === "win32" ? ".exe" : ""}`;
|
|
18130
|
-
const distBinary =
|
|
18131
|
-
if (
|
|
18132
|
-
const distBin =
|
|
18133
|
-
if (
|
|
18244
|
+
const distBinary = import_node_path24.default.join(sootsimDir, "dist-bin", binaryName);
|
|
18245
|
+
if (import_node_fs23.default.existsSync(distBinary)) return { executable: distBinary, prefixArgs: [] };
|
|
18246
|
+
const distBin = import_node_path24.default.join(sootsimDir, "dist-cli", "bin.js");
|
|
18247
|
+
if (import_node_fs23.default.existsSync(distBin)) {
|
|
18134
18248
|
try {
|
|
18135
|
-
const src =
|
|
18136
|
-
if (
|
|
18137
|
-
const srcMtime =
|
|
18138
|
-
const buildMtime =
|
|
18249
|
+
const src = import_node_path24.default.join(sootsimDir, "cli", "commands", "agent-wrapper.ts");
|
|
18250
|
+
if (import_node_fs23.default.existsSync(src)) {
|
|
18251
|
+
const srcMtime = import_node_fs23.default.statSync(src).mtimeMs;
|
|
18252
|
+
const buildMtime = import_node_fs23.default.statSync(distBin).mtimeMs;
|
|
18139
18253
|
if (buildMtime < srcMtime) {
|
|
18140
18254
|
console.warn(
|
|
18141
18255
|
`[peach] dist-cli/bin.js is older than agent-wrapper.ts \u2014 rebuild with \`bun run --cwd packages/peachsim build:cli\`.`
|
|
@@ -18154,22 +18268,22 @@ function tryWorkspaceSootsim() {
|
|
|
18154
18268
|
function resolveSootsimPackageDir() {
|
|
18155
18269
|
try {
|
|
18156
18270
|
const resolved = require.resolve(`${rnxPublicBrand.packageName}/package.json`);
|
|
18157
|
-
return
|
|
18271
|
+
return import_node_path24.default.dirname(resolved);
|
|
18158
18272
|
} catch {
|
|
18159
18273
|
}
|
|
18160
18274
|
const here = fileFromImportMeta();
|
|
18161
18275
|
if (!here) return null;
|
|
18162
|
-
let cur =
|
|
18276
|
+
let cur = import_node_path24.default.dirname(here);
|
|
18163
18277
|
for (let i = 0; i < 8; i++) {
|
|
18164
|
-
const pkg =
|
|
18278
|
+
const pkg = import_node_path24.default.join(cur, "package.json");
|
|
18165
18279
|
try {
|
|
18166
|
-
if (
|
|
18167
|
-
const parsed = JSON.parse(
|
|
18280
|
+
if (import_node_fs23.default.existsSync(pkg)) {
|
|
18281
|
+
const parsed = JSON.parse(import_node_fs23.default.readFileSync(pkg, "utf8"));
|
|
18168
18282
|
if (parsed.name === rnxPublicBrand.packageName) return cur;
|
|
18169
18283
|
}
|
|
18170
18284
|
} catch {
|
|
18171
18285
|
}
|
|
18172
|
-
const parent =
|
|
18286
|
+
const parent = import_node_path24.default.dirname(cur);
|
|
18173
18287
|
if (parent === cur) break;
|
|
18174
18288
|
cur = parent;
|
|
18175
18289
|
}
|
|
@@ -18185,28 +18299,28 @@ function fileFromImportMeta() {
|
|
|
18185
18299
|
}
|
|
18186
18300
|
}
|
|
18187
18301
|
async function withStartLock(projectId, provider, fn) {
|
|
18188
|
-
const lockDir =
|
|
18189
|
-
|
|
18302
|
+
const lockDir = import_node_path24.default.join(getUserDataDir(), "locks");
|
|
18303
|
+
import_node_fs23.default.mkdirSync(lockDir, { recursive: true });
|
|
18190
18304
|
try {
|
|
18191
|
-
|
|
18305
|
+
import_node_fs23.default.chmodSync(lockDir, 448);
|
|
18192
18306
|
} catch {
|
|
18193
18307
|
}
|
|
18194
|
-
const lockPath =
|
|
18308
|
+
const lockPath = import_node_path24.default.join(lockDir, `start-${projectId}-${provider}.lock`);
|
|
18195
18309
|
const deadline = Date.now() + 4e3;
|
|
18196
18310
|
let fd = null;
|
|
18197
18311
|
while (fd === null) {
|
|
18198
18312
|
try {
|
|
18199
|
-
fd =
|
|
18313
|
+
fd = import_node_fs23.default.openSync(
|
|
18200
18314
|
lockPath,
|
|
18201
|
-
|
|
18315
|
+
import_node_fs23.constants.O_WRONLY | import_node_fs23.constants.O_CREAT | import_node_fs23.constants.O_EXCL,
|
|
18202
18316
|
384
|
|
18203
18317
|
);
|
|
18204
18318
|
} catch (err) {
|
|
18205
18319
|
if (err.code !== "EEXIST") throw err;
|
|
18206
18320
|
try {
|
|
18207
|
-
const stale = Number(
|
|
18321
|
+
const stale = Number(import_node_fs23.default.readFileSync(lockPath, "utf8").trim());
|
|
18208
18322
|
if (stale && !isProcessAlive(stale)) {
|
|
18209
|
-
|
|
18323
|
+
import_node_fs23.default.unlinkSync(lockPath);
|
|
18210
18324
|
continue;
|
|
18211
18325
|
}
|
|
18212
18326
|
} catch {
|
|
@@ -18220,15 +18334,15 @@ async function withStartLock(projectId, provider, fn) {
|
|
|
18220
18334
|
}
|
|
18221
18335
|
}
|
|
18222
18336
|
try {
|
|
18223
|
-
|
|
18337
|
+
import_node_fs23.default.writeFileSync(fd, String(process.pid));
|
|
18224
18338
|
return await fn();
|
|
18225
18339
|
} finally {
|
|
18226
18340
|
try {
|
|
18227
|
-
|
|
18341
|
+
import_node_fs23.default.closeSync(fd);
|
|
18228
18342
|
} catch {
|
|
18229
18343
|
}
|
|
18230
18344
|
try {
|
|
18231
|
-
|
|
18345
|
+
import_node_fs23.default.unlinkSync(lockPath);
|
|
18232
18346
|
} catch {
|
|
18233
18347
|
}
|
|
18234
18348
|
}
|
|
@@ -18242,25 +18356,25 @@ function isProcessAlive(pid) {
|
|
|
18242
18356
|
}
|
|
18243
18357
|
}
|
|
18244
18358
|
function mkfifoSync(p) {
|
|
18245
|
-
const parent =
|
|
18246
|
-
|
|
18359
|
+
const parent = import_node_path24.default.dirname(p);
|
|
18360
|
+
import_node_fs23.default.mkdirSync(parent, { recursive: true });
|
|
18247
18361
|
try {
|
|
18248
|
-
|
|
18362
|
+
import_node_fs23.default.chmodSync(parent, 448);
|
|
18249
18363
|
} catch {
|
|
18250
18364
|
}
|
|
18251
|
-
if (
|
|
18365
|
+
if (import_node_fs23.default.existsSync(p)) {
|
|
18252
18366
|
try {
|
|
18253
|
-
const stat2 =
|
|
18367
|
+
const stat2 = import_node_fs23.default.statSync(p);
|
|
18254
18368
|
if (stat2.isFIFO()) {
|
|
18255
18369
|
try {
|
|
18256
|
-
|
|
18370
|
+
import_node_fs23.default.chmodSync(p, 384);
|
|
18257
18371
|
} catch {
|
|
18258
18372
|
}
|
|
18259
18373
|
return;
|
|
18260
18374
|
}
|
|
18261
|
-
|
|
18375
|
+
import_node_fs23.default.unlinkSync(p);
|
|
18262
18376
|
} catch {
|
|
18263
|
-
|
|
18377
|
+
import_node_fs23.default.unlinkSync(p);
|
|
18264
18378
|
}
|
|
18265
18379
|
}
|
|
18266
18380
|
const result = (0, import_node_child_process10.spawnSync)("mkfifo", ["-m", "600", p]);
|
|
@@ -18307,10 +18421,10 @@ async function startSession(opts) {
|
|
|
18307
18421
|
const transcript = transcriptPath(session.id);
|
|
18308
18422
|
mkfifoSync(promptIn);
|
|
18309
18423
|
mkfifoSync(eventsOut);
|
|
18310
|
-
const transcriptDir =
|
|
18311
|
-
|
|
18424
|
+
const transcriptDir = import_node_path24.default.dirname(transcript);
|
|
18425
|
+
import_node_fs23.default.mkdirSync(transcriptDir, { recursive: true });
|
|
18312
18426
|
try {
|
|
18313
|
-
|
|
18427
|
+
import_node_fs23.default.chmodSync(transcriptDir, 448);
|
|
18314
18428
|
} catch {
|
|
18315
18429
|
}
|
|
18316
18430
|
const { executable, prefixArgs } = resolveSootsimInvocation();
|
|
@@ -18361,7 +18475,7 @@ async function startSession(opts) {
|
|
|
18361
18475
|
}
|
|
18362
18476
|
}
|
|
18363
18477
|
try {
|
|
18364
|
-
|
|
18478
|
+
import_node_fs23.default.rmSync(sessionDir(session.id), { recursive: true, force: true });
|
|
18365
18479
|
} catch {
|
|
18366
18480
|
}
|
|
18367
18481
|
updateSessionStatus(session.id, { status: "ended" });
|
|
@@ -18389,18 +18503,18 @@ async function sendPrompt(sessionId, prompt) {
|
|
|
18389
18503
|
);
|
|
18390
18504
|
}
|
|
18391
18505
|
const fifo = promptFifoPath(sessionId);
|
|
18392
|
-
if (!
|
|
18506
|
+
if (!import_node_fs23.default.existsSync(fifo)) {
|
|
18393
18507
|
throw new AgentSessionError("NO_FIFO", `prompt FIFO missing: ${fifo}`);
|
|
18394
18508
|
}
|
|
18395
|
-
const fd =
|
|
18509
|
+
const fd = import_node_fs23.default.openSync(fifo, import_node_fs23.constants.O_WRONLY);
|
|
18396
18510
|
try {
|
|
18397
18511
|
const wireText = encodeAgentPromptEnvelope(prompt);
|
|
18398
18512
|
if (!wireText) {
|
|
18399
18513
|
throw new AgentSessionError("EMPTY_PROMPT", "prompt text is empty");
|
|
18400
18514
|
}
|
|
18401
|
-
|
|
18515
|
+
import_node_fs23.default.writeSync(fd, wireText + "\n");
|
|
18402
18516
|
} finally {
|
|
18403
|
-
|
|
18517
|
+
import_node_fs23.default.closeSync(fd);
|
|
18404
18518
|
}
|
|
18405
18519
|
updateSessionStatus(sessionId, {
|
|
18406
18520
|
lastPrompt: prompt.displayText ?? prompt.text,
|
|
@@ -18422,7 +18536,7 @@ async function endSession(sessionId) {
|
|
|
18422
18536
|
const base = getUserDataDir();
|
|
18423
18537
|
if (dir.startsWith(base)) {
|
|
18424
18538
|
try {
|
|
18425
|
-
|
|
18539
|
+
import_node_fs23.default.rmSync(dir, { recursive: true, force: true });
|
|
18426
18540
|
} catch {
|
|
18427
18541
|
}
|
|
18428
18542
|
}
|
|
@@ -18430,11 +18544,11 @@ async function endSession(sessionId) {
|
|
|
18430
18544
|
}
|
|
18431
18545
|
function subscribeEvents(sessionId, onEvent) {
|
|
18432
18546
|
const fifo = eventsFifoPath(sessionId);
|
|
18433
|
-
if (!
|
|
18547
|
+
if (!import_node_fs23.default.existsSync(fifo)) {
|
|
18434
18548
|
throw new AgentSessionError("NO_FIFO", `events FIFO missing: ${fifo}`);
|
|
18435
18549
|
}
|
|
18436
|
-
const fd =
|
|
18437
|
-
const stream =
|
|
18550
|
+
const fd = import_node_fs23.default.openSync(fifo, import_node_fs23.constants.O_RDWR);
|
|
18551
|
+
const stream = import_node_fs23.default.createReadStream("", { fd, autoClose: true });
|
|
18438
18552
|
const rl = import_node_readline.default.createInterface({ input: stream, crlfDelay: Infinity });
|
|
18439
18553
|
rl.on("line", (line) => {
|
|
18440
18554
|
const event = parseAgentEventLine(line);
|
|
@@ -18445,7 +18559,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
18445
18559
|
if (closed) return;
|
|
18446
18560
|
closed = true;
|
|
18447
18561
|
try {
|
|
18448
|
-
|
|
18562
|
+
import_node_fs23.default.writeSync(fd, "\n");
|
|
18449
18563
|
} catch {
|
|
18450
18564
|
}
|
|
18451
18565
|
try {
|
|
@@ -18459,7 +18573,7 @@ function subscribeEvents(sessionId, onEvent) {
|
|
|
18459
18573
|
};
|
|
18460
18574
|
}
|
|
18461
18575
|
async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
18462
|
-
const fd =
|
|
18576
|
+
const fd = import_node_fs23.default.openSync(fifo, import_node_fs23.constants.O_RDWR | import_node_fs23.constants.O_NONBLOCK);
|
|
18463
18577
|
const buf = Buffer.alloc(8192);
|
|
18464
18578
|
let leftover = "";
|
|
18465
18579
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -18467,7 +18581,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
18467
18581
|
while (Date.now() < deadline) {
|
|
18468
18582
|
let n = 0;
|
|
18469
18583
|
try {
|
|
18470
|
-
n =
|
|
18584
|
+
n = import_node_fs23.default.readSync(fd, buf, 0, buf.length, null);
|
|
18471
18585
|
} catch (err) {
|
|
18472
18586
|
if (err.code !== "EAGAIN") throw err;
|
|
18473
18587
|
n = 0;
|
|
@@ -18487,7 +18601,7 @@ async function waitForFirstEvent(fifo, predicate, timeoutMs) {
|
|
|
18487
18601
|
}
|
|
18488
18602
|
return null;
|
|
18489
18603
|
} finally {
|
|
18490
|
-
|
|
18604
|
+
import_node_fs23.default.closeSync(fd);
|
|
18491
18605
|
}
|
|
18492
18606
|
}
|
|
18493
18607
|
|
|
@@ -18741,7 +18855,7 @@ var AgentHost = class {
|
|
|
18741
18855
|
);
|
|
18742
18856
|
const project = upsertProject({
|
|
18743
18857
|
cwd: match.cwd,
|
|
18744
|
-
name: match.projectName ??
|
|
18858
|
+
name: match.projectName ?? import_node_path25.default.basename(match.cwd),
|
|
18745
18859
|
preferredProvider: input.provider ?? existing?.preferredProvider,
|
|
18746
18860
|
sourceRoots: existing?.sourceRoots ?? [match.cwd],
|
|
18747
18861
|
knownBundleUrls,
|
|
@@ -18752,18 +18866,18 @@ var AgentHost = class {
|
|
|
18752
18866
|
}
|
|
18753
18867
|
getTranscript(sessionId) {
|
|
18754
18868
|
const p = transcriptPath(sessionId);
|
|
18755
|
-
if (!
|
|
18869
|
+
if (!import_node_fs24.default.existsSync(p)) {
|
|
18756
18870
|
return { error: "transcript not found", code: "NO_TRANSCRIPT" };
|
|
18757
18871
|
}
|
|
18758
|
-
return
|
|
18872
|
+
return import_node_fs24.default.readFileSync(p, "utf8");
|
|
18759
18873
|
}
|
|
18760
18874
|
getPaths() {
|
|
18761
18875
|
const dir = getUserDataDir();
|
|
18762
18876
|
return {
|
|
18763
18877
|
userDataDir: dir,
|
|
18764
|
-
storeFile:
|
|
18765
|
-
sessionsDir:
|
|
18766
|
-
transcriptsDir:
|
|
18878
|
+
storeFile: import_node_path25.default.join(dir, "attached-projects.json"),
|
|
18879
|
+
sessionsDir: import_node_path25.default.join(dir, "sessions"),
|
|
18880
|
+
transcriptsDir: import_node_path25.default.join(dir, "transcripts")
|
|
18767
18881
|
};
|
|
18768
18882
|
}
|
|
18769
18883
|
// --- subscription management ---
|
|
@@ -19635,8 +19749,8 @@ async function openUrl(url, options = {}) {
|
|
|
19635
19749
|
}
|
|
19636
19750
|
|
|
19637
19751
|
// src/host/plane-host.ts
|
|
19638
|
-
var
|
|
19639
|
-
var
|
|
19752
|
+
var import_node_fs26 = __toESM(require("node:fs"), 1);
|
|
19753
|
+
var import_node_path27 = __toESM(require("node:path"), 1);
|
|
19640
19754
|
|
|
19641
19755
|
// ../peach-box/src/planeProtocol.ts
|
|
19642
19756
|
var PLANE_FLAG_READ_ONLY = 1;
|
|
@@ -19716,8 +19830,8 @@ async function dispatchPlaneCommand(plane, type, msg, mutationOptions) {
|
|
|
19716
19830
|
|
|
19717
19831
|
// cli/commands/box/checkout-plane.ts
|
|
19718
19832
|
var import_node_child_process11 = require("node:child_process");
|
|
19719
|
-
var
|
|
19720
|
-
var
|
|
19833
|
+
var import_node_fs25 = __toESM(require("node:fs"), 1);
|
|
19834
|
+
var import_node_path26 = __toESM(require("node:path"), 1);
|
|
19721
19835
|
var CheckoutRequiresGitError = class extends Error {
|
|
19722
19836
|
};
|
|
19723
19837
|
var BINARY_SNIFF_BYTES = 8192;
|
|
@@ -19728,14 +19842,14 @@ function looksBinary(filePath, size) {
|
|
|
19728
19842
|
if (size === 0) return false;
|
|
19729
19843
|
let fd;
|
|
19730
19844
|
try {
|
|
19731
|
-
fd =
|
|
19845
|
+
fd = import_node_fs25.default.openSync(filePath, "r");
|
|
19732
19846
|
const buffer = Buffer.alloc(Math.min(BINARY_SNIFF_BYTES, size));
|
|
19733
|
-
const read =
|
|
19847
|
+
const read = import_node_fs25.default.readSync(fd, buffer, 0, buffer.length, 0);
|
|
19734
19848
|
return buffer.subarray(0, read).includes(0);
|
|
19735
19849
|
} catch {
|
|
19736
19850
|
return false;
|
|
19737
19851
|
} finally {
|
|
19738
|
-
if (fd !== void 0)
|
|
19852
|
+
if (fd !== void 0) import_node_fs25.default.closeSync(fd);
|
|
19739
19853
|
}
|
|
19740
19854
|
}
|
|
19741
19855
|
var CheckoutFilePlane = class {
|
|
@@ -19748,7 +19862,7 @@ var CheckoutFilePlane = class {
|
|
|
19748
19862
|
listTimeoutMs;
|
|
19749
19863
|
trackedOnly;
|
|
19750
19864
|
constructor(root, options = {}) {
|
|
19751
|
-
this.root =
|
|
19865
|
+
this.root = import_node_path26.default.resolve(root);
|
|
19752
19866
|
this.listTimeoutMs = options.listTimeoutMs ?? LIST_FILES_TIMEOUT_MS;
|
|
19753
19867
|
this.trackedOnly = options.trackedOnly ?? false;
|
|
19754
19868
|
}
|
|
@@ -19810,13 +19924,13 @@ var CheckoutFilePlane = class {
|
|
|
19810
19924
|
if (!relative2) continue;
|
|
19811
19925
|
let stat2;
|
|
19812
19926
|
try {
|
|
19813
|
-
stat2 =
|
|
19927
|
+
stat2 = import_node_fs25.default.statSync(import_node_path26.default.join(this.root, relative2));
|
|
19814
19928
|
} catch {
|
|
19815
19929
|
continue;
|
|
19816
19930
|
}
|
|
19817
19931
|
if (!stat2.isFile()) continue;
|
|
19818
19932
|
const seen = this.sniffed.get(relative2);
|
|
19819
|
-
const binary2 = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(
|
|
19933
|
+
const binary2 = seen && seen.size === stat2.size && seen.mtimeMs === stat2.mtimeMs ? seen.binary : looksBinary(import_node_path26.default.join(this.root, relative2), stat2.size);
|
|
19820
19934
|
nextSniffed.set(relative2, { size: stat2.size, mtimeMs: stat2.mtimeMs, binary: binary2 });
|
|
19821
19935
|
next.set(relative2, {
|
|
19822
19936
|
size: stat2.size,
|
|
@@ -19830,22 +19944,22 @@ var CheckoutFilePlane = class {
|
|
|
19830
19944
|
this.sniffed = nextSniffed;
|
|
19831
19945
|
}
|
|
19832
19946
|
absolute(planePath) {
|
|
19833
|
-
const resolved =
|
|
19834
|
-
if (resolved !== this.root && !resolved.startsWith(`${this.root}${
|
|
19947
|
+
const resolved = import_node_path26.default.resolve(this.root, planePath);
|
|
19948
|
+
if (resolved !== this.root && !resolved.startsWith(`${this.root}${import_node_path26.default.sep}`)) {
|
|
19835
19949
|
throw new Error(`path escapes the project: ${planePath}`);
|
|
19836
19950
|
}
|
|
19837
19951
|
return resolved;
|
|
19838
19952
|
}
|
|
19839
19953
|
async read(planePath) {
|
|
19840
|
-
return
|
|
19954
|
+
return import_node_fs25.default.promises.readFile(this.absolute(planePath), "utf8");
|
|
19841
19955
|
}
|
|
19842
19956
|
async readBytes(planePath) {
|
|
19843
|
-
return
|
|
19957
|
+
return import_node_fs25.default.promises.readFile(this.absolute(planePath));
|
|
19844
19958
|
}
|
|
19845
19959
|
async write(planePath, content) {
|
|
19846
19960
|
const absolute = this.absolute(planePath);
|
|
19847
|
-
await
|
|
19848
|
-
await
|
|
19961
|
+
await import_node_fs25.default.promises.mkdir(import_node_path26.default.dirname(absolute), { recursive: true });
|
|
19962
|
+
await import_node_fs25.default.promises.writeFile(absolute, content);
|
|
19849
19963
|
this.entries.set(planePath, {
|
|
19850
19964
|
size: content.byteLength,
|
|
19851
19965
|
readOnly: false,
|
|
@@ -19854,7 +19968,7 @@ var CheckoutFilePlane = class {
|
|
|
19854
19968
|
});
|
|
19855
19969
|
}
|
|
19856
19970
|
async delete(planePath) {
|
|
19857
|
-
await
|
|
19971
|
+
await import_node_fs25.default.promises.rm(this.absolute(planePath), { force: true });
|
|
19858
19972
|
this.entries.delete(planePath);
|
|
19859
19973
|
}
|
|
19860
19974
|
};
|
|
@@ -19980,14 +20094,14 @@ var PlaneHost = class {
|
|
|
19980
20094
|
// root and an opened one cannot disagree about the same directory.
|
|
19981
20095
|
realRoot(root) {
|
|
19982
20096
|
if (!root) throw new Error("root is required");
|
|
19983
|
-
const resolved =
|
|
20097
|
+
const resolved = import_node_path27.default.resolve(root);
|
|
19984
20098
|
let real;
|
|
19985
20099
|
try {
|
|
19986
|
-
real =
|
|
20100
|
+
real = import_node_fs26.default.realpathSync(resolved);
|
|
19987
20101
|
} catch {
|
|
19988
20102
|
throw new Error(`no such directory: ${resolved}`);
|
|
19989
20103
|
}
|
|
19990
|
-
if (!
|
|
20104
|
+
if (!import_node_fs26.default.statSync(real).isDirectory()) throw new Error(`not a directory: ${real}`);
|
|
19991
20105
|
return real;
|
|
19992
20106
|
}
|
|
19993
20107
|
respond(ws, id, result) {
|
|
@@ -20007,9 +20121,9 @@ var PlaneHost = class {
|
|
|
20007
20121
|
};
|
|
20008
20122
|
|
|
20009
20123
|
// src/host/replacement-module-handler.ts
|
|
20010
|
-
var
|
|
20124
|
+
var import_node_fs27 = require("node:fs");
|
|
20011
20125
|
var import_promises5 = __toESM(require("node:fs/promises"), 1);
|
|
20012
|
-
var
|
|
20126
|
+
var import_node_path28 = __toESM(require("node:path"), 1);
|
|
20013
20127
|
|
|
20014
20128
|
// ../contrast-bundler/src/replacementModule.ts
|
|
20015
20129
|
var import_dist = require("sucrase/dist/index.js");
|
|
@@ -20337,16 +20451,16 @@ function sendJavaScript(req, res, source) {
|
|
|
20337
20451
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
20338
20452
|
}
|
|
20339
20453
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
20340
|
-
const base =
|
|
20454
|
+
const base = import_node_path28.default.resolve(import_node_path28.default.dirname(fromFile), specifier);
|
|
20341
20455
|
const candidates = [
|
|
20342
20456
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
20343
|
-
(ext) => ext ===
|
|
20457
|
+
(ext) => ext === import_node_path28.default.extname(base).toLowerCase()
|
|
20344
20458
|
) ? [base] : [],
|
|
20345
20459
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
20346
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
20460
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path28.default.join(base, `index${ext}`))
|
|
20347
20461
|
];
|
|
20348
20462
|
const found = candidates.find(
|
|
20349
|
-
(candidate) => (0,
|
|
20463
|
+
(candidate) => (0, import_node_fs27.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
20350
20464
|
);
|
|
20351
20465
|
if (!found) {
|
|
20352
20466
|
throw new Error(
|
|
@@ -20401,13 +20515,13 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
20401
20515
|
res.end("missing path param");
|
|
20402
20516
|
return true;
|
|
20403
20517
|
}
|
|
20404
|
-
const extension =
|
|
20518
|
+
const extension = import_node_path28.default.extname(targetPath).toLowerCase();
|
|
20405
20519
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
20406
20520
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
20407
20521
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
20408
20522
|
return true;
|
|
20409
20523
|
}
|
|
20410
|
-
if (!
|
|
20524
|
+
if (!import_node_path28.default.isAbsolute(targetPath)) {
|
|
20411
20525
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
20412
20526
|
res.end("replacement file path must be absolute");
|
|
20413
20527
|
return true;
|
|
@@ -20415,10 +20529,10 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
20415
20529
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
20416
20530
|
let resolvedProjectRoot;
|
|
20417
20531
|
if (options.projectRoot) {
|
|
20418
|
-
const lexicalProjectRoot =
|
|
20532
|
+
const lexicalProjectRoot = import_node_path28.default.resolve(options.projectRoot);
|
|
20419
20533
|
resolvedProjectRoot = await import_promises5.default.realpath(options.projectRoot);
|
|
20420
|
-
const lexicalTarget =
|
|
20421
|
-
if (lexicalTarget.startsWith("..") ||
|
|
20534
|
+
const lexicalTarget = import_node_path28.default.relative(lexicalProjectRoot, targetPath);
|
|
20535
|
+
if (lexicalTarget.startsWith("..") || import_node_path28.default.isAbsolute(lexicalTarget)) {
|
|
20422
20536
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
20423
20537
|
res.end("replacement file must be inside the project root");
|
|
20424
20538
|
return true;
|
|
@@ -20434,8 +20548,8 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
20434
20548
|
return true;
|
|
20435
20549
|
}
|
|
20436
20550
|
if (resolvedProjectRoot) {
|
|
20437
|
-
const relativeTarget =
|
|
20438
|
-
if (relativeTarget.startsWith("..") ||
|
|
20551
|
+
const relativeTarget = import_node_path28.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
20552
|
+
if (relativeTarget.startsWith("..") || import_node_path28.default.isAbsolute(relativeTarget)) {
|
|
20439
20553
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
20440
20554
|
res.end("replacement file must be inside the project root");
|
|
20441
20555
|
return true;
|