rnxsim 0.1.524 → 0.1.526
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/outbound-endpoints.ts +15 -0
- 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/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.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/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +33 -4
- 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 +3 -1
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.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/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 +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +37 -8
- package/dist-lib/swift-submit.cjs +92 -0
- package/dist-lib/swift-submit.mjs +65 -0
- package/dist-lib/swift.cjs +316 -23
- package/dist-lib/vite.cjs +280 -11
- package/package.json +8 -1
- package/src/rolldown-plugin-swift.ts +240 -0
- package/src/swift-submit.ts +185 -0
- package/src/vite-plugin-one.ts +10 -3
- package/src/vite-plugin-swift.ts +86 -2
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/*! rnx v0.1.526 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
|
+
"use strict";
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/swift-submit.ts
|
|
23
|
+
var swift_submit_exports = {};
|
|
24
|
+
__export(swift_submit_exports, {
|
|
25
|
+
SWIFT_COMPILE_PATH: () => SWIFT_COMPILE_PATH,
|
|
26
|
+
compileSwiftProject: () => compileSwiftProject,
|
|
27
|
+
httpSwiftCompileSubmit: () => httpSwiftCompileSubmit
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(swift_submit_exports);
|
|
30
|
+
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
31
|
+
var POLL_INTERVAL_MS = 1500;
|
|
32
|
+
function httpSwiftCompileSubmit(context) {
|
|
33
|
+
const { assetReadToken, endpoint } = context;
|
|
34
|
+
if (!assetReadToken) return void 0;
|
|
35
|
+
const url = endpoint ? `${endpoint.replace(/\/+$/, "")}${SWIFT_COMPILE_PATH}` : SWIFT_COMPILE_PATH;
|
|
36
|
+
return async (work) => {
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
response = await fetch(url, {
|
|
40
|
+
method: "POST",
|
|
41
|
+
headers: { "content-type": "application/json" },
|
|
42
|
+
body: JSON.stringify({ ...work, token: assetReadToken })
|
|
43
|
+
});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
`contrast-bundler: fetch failed for ${url} while compiling ${work.entry}: ${error instanceof Error ? error.message : String(error)}`,
|
|
47
|
+
{ cause: error }
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
const detail = (await response.text()).trim();
|
|
52
|
+
throw new Error(
|
|
53
|
+
`contrast-bundler: the swift compile for ${work.entry} answered ${response.status}${detail ? `: ${detail}` : ""}`
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
return await response.json();
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function resolveImageUrls(urls, origin) {
|
|
60
|
+
const resolved = {};
|
|
61
|
+
for (const [name, url] of Object.entries(urls)) {
|
|
62
|
+
resolved[name] = new URL(url, origin).href;
|
|
63
|
+
}
|
|
64
|
+
return resolved;
|
|
65
|
+
}
|
|
66
|
+
async function compileSwiftProject(submit, work, origin) {
|
|
67
|
+
while (true) {
|
|
68
|
+
const outcome = await submit(work);
|
|
69
|
+
switch (outcome.status) {
|
|
70
|
+
case "published":
|
|
71
|
+
return {
|
|
72
|
+
url: new URL(outcome.artifactUrl, origin).href,
|
|
73
|
+
hash: outcome.hash,
|
|
74
|
+
...outcome.imageUrls === void 0 ? {} : { imageUrls: resolveImageUrls(outcome.imageUrls, origin) }
|
|
75
|
+
};
|
|
76
|
+
case "compiling":
|
|
77
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
78
|
+
continue;
|
|
79
|
+
case "refused":
|
|
80
|
+
case "failed":
|
|
81
|
+
throw new Error(
|
|
82
|
+
`contrast-bundler: the swift sources for ${work.entry} cannot be compiled: ${outcome.detail}`
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
SWIFT_COMPILE_PATH,
|
|
90
|
+
compileSwiftProject,
|
|
91
|
+
httpSwiftCompileSubmit
|
|
92
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*! rnx v0.1.526 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
|
+
|
|
3
|
+
// src/swift-submit.ts
|
|
4
|
+
var SWIFT_COMPILE_PATH = "/api/swift-compile";
|
|
5
|
+
var POLL_INTERVAL_MS = 1500;
|
|
6
|
+
function httpSwiftCompileSubmit(context) {
|
|
7
|
+
const { assetReadToken, endpoint } = context;
|
|
8
|
+
if (!assetReadToken) return void 0;
|
|
9
|
+
const url = endpoint ? `${endpoint.replace(/\/+$/, "")}${SWIFT_COMPILE_PATH}` : SWIFT_COMPILE_PATH;
|
|
10
|
+
return async (work) => {
|
|
11
|
+
let response;
|
|
12
|
+
try {
|
|
13
|
+
response = await fetch(url, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: { "content-type": "application/json" },
|
|
16
|
+
body: JSON.stringify({ ...work, token: assetReadToken })
|
|
17
|
+
});
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`contrast-bundler: fetch failed for ${url} while compiling ${work.entry}: ${error instanceof Error ? error.message : String(error)}`,
|
|
21
|
+
{ cause: error }
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
const detail = (await response.text()).trim();
|
|
26
|
+
throw new Error(
|
|
27
|
+
`contrast-bundler: the swift compile for ${work.entry} answered ${response.status}${detail ? `: ${detail}` : ""}`
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
return await response.json();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function resolveImageUrls(urls, origin) {
|
|
34
|
+
const resolved = {};
|
|
35
|
+
for (const [name, url] of Object.entries(urls)) {
|
|
36
|
+
resolved[name] = new URL(url, origin).href;
|
|
37
|
+
}
|
|
38
|
+
return resolved;
|
|
39
|
+
}
|
|
40
|
+
async function compileSwiftProject(submit, work, origin) {
|
|
41
|
+
while (true) {
|
|
42
|
+
const outcome = await submit(work);
|
|
43
|
+
switch (outcome.status) {
|
|
44
|
+
case "published":
|
|
45
|
+
return {
|
|
46
|
+
url: new URL(outcome.artifactUrl, origin).href,
|
|
47
|
+
hash: outcome.hash,
|
|
48
|
+
...outcome.imageUrls === void 0 ? {} : { imageUrls: resolveImageUrls(outcome.imageUrls, origin) }
|
|
49
|
+
};
|
|
50
|
+
case "compiling":
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
52
|
+
continue;
|
|
53
|
+
case "refused":
|
|
54
|
+
case "failed":
|
|
55
|
+
throw new Error(
|
|
56
|
+
`contrast-bundler: the swift sources for ${work.entry} cannot be compiled: ${outcome.detail}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export {
|
|
62
|
+
SWIFT_COMPILE_PATH,
|
|
63
|
+
compileSwiftProject,
|
|
64
|
+
httpSwiftCompileSubmit
|
|
65
|
+
};
|
package/dist-lib/swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.526 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -54,6 +54,244 @@ function resolveImageSource(source, table, onMiss) {
|
|
|
54
54
|
return source;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
// ../sootsim-swift/src/resfs.ts
|
|
58
|
+
var RES_BADF = 8;
|
|
59
|
+
var RES_INVAL = 28;
|
|
60
|
+
var RES_NOENT = 44;
|
|
61
|
+
var RES_NOTDIR = 54;
|
|
62
|
+
var RES_NOTCAPABLE = 76;
|
|
63
|
+
var RES_DIRTYPE = 3;
|
|
64
|
+
var RES_FILETYPE = 4;
|
|
65
|
+
var O_CREAT = 1;
|
|
66
|
+
var O_DIRECTORY = 2;
|
|
67
|
+
var O_EXCL = 4;
|
|
68
|
+
var O_TRUNC = 8;
|
|
69
|
+
var RES_PREOPEN = 3;
|
|
70
|
+
var RES_DIR_NAME = "/res";
|
|
71
|
+
var B64_DIGITS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
72
|
+
function decodeBase64(text) {
|
|
73
|
+
const clean = text.replace(/\s/g, "");
|
|
74
|
+
if (clean.length % 4 !== 0) {
|
|
75
|
+
throw new Error(`swift bundle file is not base64 (length ${clean.length})`);
|
|
76
|
+
}
|
|
77
|
+
const values = new Uint8Array(clean.length);
|
|
78
|
+
let length = clean.length;
|
|
79
|
+
let pad = 0;
|
|
80
|
+
if (clean.endsWith("==")) pad = 2;
|
|
81
|
+
else if (clean.endsWith("=")) pad = 1;
|
|
82
|
+
length -= pad;
|
|
83
|
+
for (let index = 0; index < clean.length - pad; index += 1) {
|
|
84
|
+
const digit = B64_DIGITS.indexOf(clean[index]);
|
|
85
|
+
if (digit < 0) {
|
|
86
|
+
throw new Error(`swift bundle file is not base64 (char '${clean[index]}')`);
|
|
87
|
+
}
|
|
88
|
+
values[index] = digit;
|
|
89
|
+
}
|
|
90
|
+
const out = new Uint8Array((clean.length / 4 | 0) * 3 - pad);
|
|
91
|
+
let at = 0;
|
|
92
|
+
for (let index = 0; index < clean.length; index += 4) {
|
|
93
|
+
const group = values[index] << 18 | values[index + 1] << 12 | values[index + 2] << 6 | values[index + 3];
|
|
94
|
+
out[at] = group >> 16 & 255;
|
|
95
|
+
if (at + 1 < out.length) out[at + 1] = group >> 8 & 255;
|
|
96
|
+
if (at + 2 < out.length) out[at + 2] = group & 255;
|
|
97
|
+
at += 3;
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
|
101
|
+
function resIno(name) {
|
|
102
|
+
let hash = 0xcbf29ce484222325n;
|
|
103
|
+
const bytes = new TextEncoder().encode(name);
|
|
104
|
+
for (const byte of bytes) {
|
|
105
|
+
hash ^= BigInt(byte);
|
|
106
|
+
hash = hash * 0x100000001b3n & 0xffffffffffffffffn;
|
|
107
|
+
}
|
|
108
|
+
return hash === 0n ? 1n : hash;
|
|
109
|
+
}
|
|
110
|
+
function resArgv0(moduleUrl) {
|
|
111
|
+
const base = moduleUrl.split("/").pop()?.split("?")[0] ?? "app.wasm";
|
|
112
|
+
return `${RES_DIR_NAME}/${base === "" ? "app.wasm" : base}`;
|
|
113
|
+
}
|
|
114
|
+
function resolveName(files, rel) {
|
|
115
|
+
let rest = rel;
|
|
116
|
+
if (rest === RES_DIR_NAME || rest === `${RES_DIR_NAME}/`) return null;
|
|
117
|
+
if (rest.startsWith(`${RES_DIR_NAME}/`)) rest = rest.slice(RES_DIR_NAME.length + 1);
|
|
118
|
+
if (rest.startsWith("/")) rest = rest.slice(1);
|
|
119
|
+
while (rest.startsWith("./")) rest = rest.slice(2);
|
|
120
|
+
if (rest === "" || rest === ".") return null;
|
|
121
|
+
if (rest.includes("/")) return null;
|
|
122
|
+
return Object.prototype.hasOwnProperty.call(files, rest) ? rest : null;
|
|
123
|
+
}
|
|
124
|
+
function writeStat(mem, ptr, filetype, size, ino) {
|
|
125
|
+
mem.bytes().fill(0, ptr, ptr + 64);
|
|
126
|
+
mem.bytes()[ptr + 16] = filetype;
|
|
127
|
+
mem.writeU64(ptr + 8, ino);
|
|
128
|
+
mem.writeU64(ptr + 32, BigInt(size));
|
|
129
|
+
}
|
|
130
|
+
function createResFs(files) {
|
|
131
|
+
const names = Object.keys(files).sort();
|
|
132
|
+
const fds = /* @__PURE__ */ new Map();
|
|
133
|
+
let nextFd = RES_PREOPEN + 1;
|
|
134
|
+
const freeFds = [];
|
|
135
|
+
let preopenOpen = true;
|
|
136
|
+
const allocFd = () => {
|
|
137
|
+
if (freeFds.length > 0) return freeFds.shift();
|
|
138
|
+
nextFd += 1;
|
|
139
|
+
return nextFd - 1;
|
|
140
|
+
};
|
|
141
|
+
const dirFdOk = (fd) => {
|
|
142
|
+
if (fd === RES_PREOPEN) return preopenOpen;
|
|
143
|
+
const found = fds.get(fd);
|
|
144
|
+
return found !== void 0 && found.kind === "dir";
|
|
145
|
+
};
|
|
146
|
+
const inoOf = (name) => resIno(name);
|
|
147
|
+
return {
|
|
148
|
+
imports(mem) {
|
|
149
|
+
return {
|
|
150
|
+
path_open: (dirfd, _dirflags, pathPtr, pathLen, oflags, _r1, _r2, _r3, fdPtr) => {
|
|
151
|
+
if (!dirFdOk(dirfd)) return RES_BADF;
|
|
152
|
+
if ((oflags & (O_CREAT | O_EXCL | O_TRUNC)) !== 0) return RES_INVAL;
|
|
153
|
+
const rel = mem.readString(pathPtr, pathLen);
|
|
154
|
+
if (rel === "." || rel === "./" || rel === RES_DIR_NAME || rel === `${RES_DIR_NAME}/`) {
|
|
155
|
+
const fd2 = allocFd();
|
|
156
|
+
fds.set(fd2, { kind: "dir" });
|
|
157
|
+
mem.writeU32(fdPtr, fd2);
|
|
158
|
+
return 0;
|
|
159
|
+
}
|
|
160
|
+
const hit = resolveName(files, rel);
|
|
161
|
+
if (hit === null) return RES_NOENT;
|
|
162
|
+
if ((oflags & O_DIRECTORY) !== 0) return RES_NOTDIR;
|
|
163
|
+
const fd = allocFd();
|
|
164
|
+
fds.set(fd, { kind: "file", name: hit, bytes: files[hit], offset: 0 });
|
|
165
|
+
mem.writeU32(fdPtr, fd);
|
|
166
|
+
return 0;
|
|
167
|
+
},
|
|
168
|
+
path_filestat_get: (dirfd, _flags, pathPtr, pathLen, statPtr) => {
|
|
169
|
+
if (!dirFdOk(dirfd)) return RES_BADF;
|
|
170
|
+
const rel = mem.readString(pathPtr, pathLen);
|
|
171
|
+
if (rel === "." || rel === "./" || rel === RES_DIR_NAME || rel === `${RES_DIR_NAME}/`) {
|
|
172
|
+
writeStat(mem, statPtr, RES_DIRTYPE, 0, inoOf(RES_DIR_NAME));
|
|
173
|
+
return 0;
|
|
174
|
+
}
|
|
175
|
+
const hit = resolveName(files, rel);
|
|
176
|
+
if (hit === null) return RES_NOENT;
|
|
177
|
+
writeStat(mem, statPtr, RES_FILETYPE, files[hit].length, inoOf(hit));
|
|
178
|
+
return 0;
|
|
179
|
+
},
|
|
180
|
+
fd_fdstat_get: (fd, statPtr) => {
|
|
181
|
+
if (fd === RES_PREOPEN) {
|
|
182
|
+
if (!preopenOpen) return RES_BADF;
|
|
183
|
+
mem.bytes().fill(0, statPtr, statPtr + 24);
|
|
184
|
+
mem.bytes()[statPtr] = RES_DIRTYPE;
|
|
185
|
+
return 0;
|
|
186
|
+
}
|
|
187
|
+
const found = fds.get(fd);
|
|
188
|
+
if (!found) return RES_BADF;
|
|
189
|
+
mem.bytes().fill(0, statPtr, statPtr + 24);
|
|
190
|
+
mem.bytes()[statPtr] = found.kind === "dir" ? RES_DIRTYPE : RES_FILETYPE;
|
|
191
|
+
return 0;
|
|
192
|
+
},
|
|
193
|
+
fd_filestat_get: (fd, statPtr) => {
|
|
194
|
+
const found = fds.get(fd);
|
|
195
|
+
if (!found) return RES_BADF;
|
|
196
|
+
if (found.kind === "dir") {
|
|
197
|
+
writeStat(mem, statPtr, RES_DIRTYPE, 0, inoOf(RES_DIR_NAME));
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
writeStat(mem, statPtr, RES_FILETYPE, found.bytes.length, inoOf(found.name));
|
|
201
|
+
return 0;
|
|
202
|
+
},
|
|
203
|
+
fd_prestat_get: (fd, prestatPtr) => {
|
|
204
|
+
if (fd === RES_PREOPEN && preopenOpen) {
|
|
205
|
+
mem.bytes().fill(0, prestatPtr, prestatPtr + 8);
|
|
206
|
+
mem.bytes()[prestatPtr] = 0;
|
|
207
|
+
mem.writeU32(prestatPtr + 4, RES_DIR_NAME.length);
|
|
208
|
+
return 0;
|
|
209
|
+
}
|
|
210
|
+
return RES_BADF;
|
|
211
|
+
},
|
|
212
|
+
fd_prestat_dir_name: (fd, pathPtr, pathLen) => {
|
|
213
|
+
if (fd !== RES_PREOPEN || !preopenOpen) return RES_BADF;
|
|
214
|
+
if (pathLen < RES_DIR_NAME.length) return RES_INVAL;
|
|
215
|
+
mem.bytes().set(new TextEncoder().encode(RES_DIR_NAME), pathPtr);
|
|
216
|
+
return 0;
|
|
217
|
+
},
|
|
218
|
+
fd_readdir: (fd, bufPtr, bufLen, cookie, usedPtr) => {
|
|
219
|
+
const isPreopen = fd === RES_PREOPEN && preopenOpen;
|
|
220
|
+
const found = fds.get(fd);
|
|
221
|
+
if (!isPreopen && !found) return RES_BADF;
|
|
222
|
+
if (!isPreopen && found?.kind !== "dir") return RES_NOTCAPABLE;
|
|
223
|
+
let used = 0;
|
|
224
|
+
names.forEach((name, index) => {
|
|
225
|
+
const next = index + 1;
|
|
226
|
+
if (next <= cookie) return;
|
|
227
|
+
const encoded = new TextEncoder().encode(name);
|
|
228
|
+
if (used + 24 + encoded.length > bufLen) return;
|
|
229
|
+
const at = bufPtr + used;
|
|
230
|
+
mem.writeU64(at, BigInt(next));
|
|
231
|
+
mem.writeU64(at + 8, inoOf(name));
|
|
232
|
+
mem.writeU32(at + 16, encoded.length);
|
|
233
|
+
mem.bytes()[at + 20] = RES_FILETYPE;
|
|
234
|
+
mem.bytes().fill(0, at + 21, at + 24);
|
|
235
|
+
mem.bytes().set(encoded, at + 24);
|
|
236
|
+
used += 24 + encoded.length;
|
|
237
|
+
});
|
|
238
|
+
mem.writeU32(usedPtr, used);
|
|
239
|
+
return 0;
|
|
240
|
+
},
|
|
241
|
+
fd_read: (fd, iovsPtr, iovsLen, donePtr) => {
|
|
242
|
+
const found = fds.get(fd);
|
|
243
|
+
if (!found) return RES_BADF;
|
|
244
|
+
if (found.kind !== "file") return RES_NOTCAPABLE;
|
|
245
|
+
let done = 0;
|
|
246
|
+
for (let index = 0; index < iovsLen; index += 1) {
|
|
247
|
+
const ptr = mem.readU32(iovsPtr + index * 8);
|
|
248
|
+
const want = mem.readU32(iovsPtr + index * 8 + 4);
|
|
249
|
+
const chunk = found.bytes.subarray(found.offset, found.offset + want);
|
|
250
|
+
mem.bytes().set(chunk, ptr);
|
|
251
|
+
found.offset += chunk.length;
|
|
252
|
+
done += chunk.length;
|
|
253
|
+
if (chunk.length < want) break;
|
|
254
|
+
}
|
|
255
|
+
mem.writeU32(donePtr, done);
|
|
256
|
+
return 0;
|
|
257
|
+
},
|
|
258
|
+
// the tree is read-only: any write to it is not-capable, and an
|
|
259
|
+
// unknown fd is a bad descriptor. stdio never reaches here; the
|
|
260
|
+
// mount answers fds 0-2 itself before delegating.
|
|
261
|
+
fd_write: (fd, _iovsPtr, _iovsLen, _donePtr) => {
|
|
262
|
+
if (fd === RES_PREOPEN || fds.has(fd)) return RES_NOTCAPABLE;
|
|
263
|
+
return RES_BADF;
|
|
264
|
+
},
|
|
265
|
+
fd_pread: (fd, _iovsPtr, _iovsLen, _offset, _donePtr) => {
|
|
266
|
+
if (fd === RES_PREOPEN || fds.has(fd)) return RES_NOTCAPABLE;
|
|
267
|
+
return RES_BADF;
|
|
268
|
+
},
|
|
269
|
+
fd_seek: (fd, _offLo, _offHi, _whence, _posPtr) => {
|
|
270
|
+
if (fd === RES_PREOPEN || fds.has(fd)) return RES_NOTCAPABLE;
|
|
271
|
+
return RES_BADF;
|
|
272
|
+
},
|
|
273
|
+
fd_tell: (fd, _posPtr) => {
|
|
274
|
+
if (fd === RES_PREOPEN || fds.has(fd)) return RES_NOTCAPABLE;
|
|
275
|
+
return RES_BADF;
|
|
276
|
+
},
|
|
277
|
+
fd_close: (fd) => {
|
|
278
|
+
if (fd === RES_PREOPEN) {
|
|
279
|
+
if (!preopenOpen) return RES_BADF;
|
|
280
|
+
preopenOpen = false;
|
|
281
|
+
return 0;
|
|
282
|
+
}
|
|
283
|
+
if (!fds.has(fd)) return RES_BADF;
|
|
284
|
+
fds.delete(fd);
|
|
285
|
+
const at = freeFds.findIndex((other) => other > fd);
|
|
286
|
+
if (at < 0) freeFds.push(fd);
|
|
287
|
+
else freeFds.splice(at, 0, fd);
|
|
288
|
+
return 0;
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
57
295
|
// ../sootsim-swift/src/mount.tsx
|
|
58
296
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
59
297
|
function isRecord(value) {
|
|
@@ -104,12 +342,28 @@ function readTree(text) {
|
|
|
104
342
|
}
|
|
105
343
|
var WASI_BADF = 8;
|
|
106
344
|
var WASI_INVAL = 28;
|
|
107
|
-
function wasiImports(host) {
|
|
345
|
+
function wasiImports(host, argv, resFiles) {
|
|
346
|
+
const argvBytes = argv.map((arg) => new TextEncoder().encode(`${arg}\0`));
|
|
347
|
+
const resImports = createResFs(resFiles).imports(host);
|
|
108
348
|
return {
|
|
109
|
-
args_get: () =>
|
|
349
|
+
args_get: (argvPtr, bufPtr) => {
|
|
350
|
+
let argp = argvPtr;
|
|
351
|
+
let bufp = bufPtr;
|
|
352
|
+
for (const bytes of argvBytes) {
|
|
353
|
+
host.writeU32(argp, bufp);
|
|
354
|
+
host.bytes().set(bytes, bufp);
|
|
355
|
+
argp += 4;
|
|
356
|
+
bufp += bytes.length;
|
|
357
|
+
}
|
|
358
|
+
host.writeU32(argp, 0);
|
|
359
|
+
return 0;
|
|
360
|
+
},
|
|
110
361
|
args_sizes_get: (argcPtr, argvSizePtr) => {
|
|
111
|
-
host.writeU32(argcPtr,
|
|
112
|
-
host.writeU32(
|
|
362
|
+
host.writeU32(argcPtr, argvBytes.length);
|
|
363
|
+
host.writeU32(
|
|
364
|
+
argvSizePtr,
|
|
365
|
+
argvBytes.reduce((total, bytes) => total + bytes.length, 0)
|
|
366
|
+
);
|
|
113
367
|
return 0;
|
|
114
368
|
},
|
|
115
369
|
environ_get: () => 0,
|
|
@@ -118,21 +372,23 @@ function wasiImports(host) {
|
|
|
118
372
|
host.writeU32(sizePtr, 0);
|
|
119
373
|
return 0;
|
|
120
374
|
},
|
|
121
|
-
fd_close: () =>
|
|
122
|
-
fd_fdstat_get: () =>
|
|
375
|
+
fd_close: (...args) => resImports.fd_close(...args),
|
|
376
|
+
fd_fdstat_get: (...args) => resImports.fd_fdstat_get(...args),
|
|
123
377
|
fd_fdstat_set_flags: () => WASI_BADF,
|
|
124
|
-
fd_filestat_get: () =>
|
|
378
|
+
fd_filestat_get: (...args) => resImports.fd_filestat_get(...args),
|
|
125
379
|
fd_filestat_set_size: () => WASI_BADF,
|
|
126
380
|
fd_filestat_set_times: () => WASI_BADF,
|
|
127
|
-
fd_pread: () =>
|
|
128
|
-
fd_prestat_get: () =>
|
|
129
|
-
fd_prestat_dir_name: () =>
|
|
130
|
-
fd_read: () =>
|
|
131
|
-
fd_readdir: () =>
|
|
132
|
-
fd_seek: () =>
|
|
381
|
+
fd_pread: (...args) => resImports.fd_pread(...args),
|
|
382
|
+
fd_prestat_get: (...args) => resImports.fd_prestat_get(...args),
|
|
383
|
+
fd_prestat_dir_name: (...args) => resImports.fd_prestat_dir_name(...args),
|
|
384
|
+
fd_read: (...args) => resImports.fd_read(...args),
|
|
385
|
+
fd_readdir: (...args) => resImports.fd_readdir(...args),
|
|
386
|
+
fd_seek: (...args) => resImports.fd_seek(...args),
|
|
133
387
|
fd_sync: () => WASI_BADF,
|
|
134
|
-
fd_tell: () =>
|
|
135
|
-
fd_write: (
|
|
388
|
+
fd_tell: (...args) => resImports.fd_tell(...args),
|
|
389
|
+
fd_write: (fd, iovsPtr, iovsLen, writtenPtr) => {
|
|
390
|
+
if (fd !== 1 && fd !== 2)
|
|
391
|
+
return resImports.fd_write(fd, iovsPtr, iovsLen, writtenPtr);
|
|
136
392
|
const view = new DataView(host.bytes().buffer);
|
|
137
393
|
let written = 0;
|
|
138
394
|
for (let index = 0; index < iovsLen; index += 1) {
|
|
@@ -142,10 +398,10 @@ function wasiImports(host) {
|
|
|
142
398
|
return 0;
|
|
143
399
|
},
|
|
144
400
|
path_create_directory: () => WASI_BADF,
|
|
145
|
-
path_filestat_get: () =>
|
|
401
|
+
path_filestat_get: (...args) => resImports.path_filestat_get(...args),
|
|
146
402
|
path_filestat_set_times: () => WASI_BADF,
|
|
147
403
|
path_link: () => WASI_BADF,
|
|
148
|
-
path_open: () =>
|
|
404
|
+
path_open: (...args) => resImports.path_open(...args),
|
|
149
405
|
path_readlink: () => WASI_BADF,
|
|
150
406
|
path_remove_directory: () => WASI_BADF,
|
|
151
407
|
path_rename: () => WASI_BADF,
|
|
@@ -206,7 +462,7 @@ function voidExport(exports2, name) {
|
|
|
206
462
|
Reflect.apply(fn, void 0, args);
|
|
207
463
|
};
|
|
208
464
|
}
|
|
209
|
-
function instantiate(module2) {
|
|
465
|
+
function instantiate(module2, bundle) {
|
|
210
466
|
let memory;
|
|
211
467
|
const requireMemory = () => {
|
|
212
468
|
if (!memory) throw new Error("swift artifact memory is not live");
|
|
@@ -219,10 +475,19 @@ function instantiate(module2) {
|
|
|
219
475
|
writeU64(ptr, value) {
|
|
220
476
|
new DataView(requireMemory().buffer).setBigUint64(ptr, value, true);
|
|
221
477
|
},
|
|
478
|
+
readU32(ptr) {
|
|
479
|
+
return new DataView(requireMemory().buffer).getUint32(ptr, true);
|
|
480
|
+
},
|
|
481
|
+
readString(ptr, len) {
|
|
482
|
+
return new TextDecoder().decode(
|
|
483
|
+
new Uint8Array(requireMemory().buffer).subarray(ptr, ptr + len)
|
|
484
|
+
);
|
|
485
|
+
},
|
|
222
486
|
bytes: () => new Uint8Array(requireMemory().buffer)
|
|
223
487
|
};
|
|
488
|
+
const argv = bundle === null ? [] : [bundle.argv0];
|
|
224
489
|
const instance = new WebAssembly.Instance(module2, {
|
|
225
|
-
wasi_snapshot_preview1: wasiImports(host)
|
|
490
|
+
wasi_snapshot_preview1: wasiImports(host, argv, bundle?.files ?? {})
|
|
226
491
|
});
|
|
227
492
|
const exportedMemory = instance.exports.memory;
|
|
228
493
|
if (!(exportedMemory instanceof WebAssembly.Memory)) {
|
|
@@ -277,7 +542,15 @@ function instantiate(module2) {
|
|
|
277
542
|
return result;
|
|
278
543
|
};
|
|
279
544
|
initialize();
|
|
280
|
-
|
|
545
|
+
if (bundle === null) {
|
|
546
|
+
mainArgv(0, 0);
|
|
547
|
+
} else {
|
|
548
|
+
const encoded = new TextEncoder().encode(`${bundle.argv0}\0`);
|
|
549
|
+
const ptr = alloc(encoded.length + 4);
|
|
550
|
+
new Uint8Array(requireMemory().buffer).set(encoded, ptr + 4);
|
|
551
|
+
new DataView(requireMemory().buffer).setUint32(ptr, ptr + 4, true);
|
|
552
|
+
mainArgv(1, ptr);
|
|
553
|
+
}
|
|
281
554
|
return {
|
|
282
555
|
mount: () => {
|
|
283
556
|
if (hasViewExport() === 1) {
|
|
@@ -328,6 +601,21 @@ function instantiate(module2) {
|
|
|
328
601
|
};
|
|
329
602
|
}
|
|
330
603
|
var compiledModules = /* @__PURE__ */ new Map();
|
|
604
|
+
function decodeBundle(moduleUrl, packed) {
|
|
605
|
+
if (packed === void 0) return null;
|
|
606
|
+
const files = {};
|
|
607
|
+
for (const [name, base64] of Object.entries(packed)) {
|
|
608
|
+
try {
|
|
609
|
+
files[name] = decodeBase64(base64);
|
|
610
|
+
} catch (error) {
|
|
611
|
+
throw new Error(
|
|
612
|
+
`swift bundle file '${name}' is not decodable: ${error instanceof Error ? error.message : String(error)}`
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
if (Object.keys(files).length === 0) return null;
|
|
617
|
+
return { files, argv0: resArgv0(moduleUrl) };
|
|
618
|
+
}
|
|
331
619
|
function compile(url) {
|
|
332
620
|
const cached = compiledModules.get(url);
|
|
333
621
|
if (cached) return cached;
|
|
@@ -691,6 +979,8 @@ function nodeProps(node, deliver) {
|
|
|
691
979
|
}
|
|
692
980
|
case "Button":
|
|
693
981
|
return pressProps(node, deliver);
|
|
982
|
+
case "EditButton":
|
|
983
|
+
return pressProps(node, deliver);
|
|
694
984
|
case "TabView": {
|
|
695
985
|
const onSelect = handlerId(node, "onSelect");
|
|
696
986
|
const tabs = (node.c ?? []).map((tab, index) => {
|
|
@@ -1255,7 +1545,10 @@ function createRoot(mountTree) {
|
|
|
1255
1545
|
};
|
|
1256
1546
|
const apply = async (options, props) => {
|
|
1257
1547
|
const carried = instance?.exportState() ?? null;
|
|
1258
|
-
const created = instantiate(
|
|
1548
|
+
const created = instantiate(
|
|
1549
|
+
await compile(options.url),
|
|
1550
|
+
decodeBundle(options.url, options.bundleFiles)
|
|
1551
|
+
);
|
|
1259
1552
|
if (carried !== null) created.importState(carried);
|
|
1260
1553
|
if (source !== options) return;
|
|
1261
1554
|
instance = created;
|
|
@@ -1296,7 +1589,7 @@ function createRoot(mountTree) {
|
|
|
1296
1589
|
return {
|
|
1297
1590
|
component,
|
|
1298
1591
|
use(options, refreshKey, props) {
|
|
1299
|
-
const changed = source === null || source.hash !== options.hash || source.url !== options.url || JSON.stringify(source.resources ?? null) !== JSON.stringify(options.resources ?? null) || refreshKey !== void 0 && refreshKey !== refresh;
|
|
1592
|
+
const changed = source === null || source.hash !== options.hash || source.url !== options.url || JSON.stringify(source.resources ?? null) !== JSON.stringify(options.resources ?? null) || JSON.stringify(source.bundleFiles ?? null) !== JSON.stringify(options.bundleFiles ?? null) || refreshKey !== void 0 && refreshKey !== refresh;
|
|
1300
1593
|
if (changed) {
|
|
1301
1594
|
source = options;
|
|
1302
1595
|
refresh = refreshKey;
|