rnxsim 0.1.506 → 0.1.508
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/commands/control.ts +3 -3
- package/cli/commands/flow.ts +8 -12
- package/cli/commands/platform.ts +2 -1
- package/cli/ws-bridge.ts +28 -15
- package/detox/index.ts +24 -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 +24 -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 +1 -1
- 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 +36 -20
- 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 +26 -21
- package/dist-lib/swift.cjs +507 -0
- package/dist-lib/vite.cjs +185 -5
- package/package.json +6 -1
- package/src/swift.ts +6 -0
- package/src/vite-plugin-one.ts +8 -0
- package/src/vite-plugin-swift.ts +254 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.508 | (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 __defProp = Object.defineProperty;
|
package/dist-lib/render-mode.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.508 | (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 __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.508 | (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;
|
package/dist-lib/sdk.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.508 | (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 __defProp = Object.defineProperty;
|
package/dist-lib/sdk.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.508 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
package/dist-lib/skills.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.508 | (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;
|
|
@@ -5889,12 +5889,12 @@ var init_registry = __esm({
|
|
|
5889
5889
|
usage: 1,
|
|
5890
5890
|
importance: 1,
|
|
5891
5891
|
estimate: 1,
|
|
5892
|
-
rationale: "Tabs.Host and Tabs.Screen, FullWindowOverlay, transition progress, and opt-in React freeze behavior remain available. The inspected tab, overlay, and freeze path has no app-facing behavior gap."
|
|
5892
|
+
rationale: "Tabs.Host and Tabs.Screen support system Search, bottom accessories, measured scroll minimization, active-tab restoration, compact main-tab persistence while Search is selected, and tab selection. FullWindowOverlay, transition progress, and opt-in React freeze behavior remain available. The inspected tab, overlay, and freeze path has no app-facing behavior gap."
|
|
5893
5893
|
}
|
|
5894
5894
|
],
|
|
5895
5895
|
capabilityCoverage: CAPABILITY_INVENTORY_PACKAGE_COVERAGE["react-native-screens"],
|
|
5896
|
-
note: "screen container, stack, header
|
|
5897
|
-
working: "Screen, ScreenContainer, ScreenStack, enableFreeze/freezeEnabled with delayed React freeze, Android modal/pageSheet push fallback, Android statusBarHidden/statusBarStyle/navigationBarHidden traits, push/pop slide, replaceAnimation push/pop direction, zoom/fade/fade_from_bottom transitions, edge swipe-back, parallax behind-screen, large title collapse, header (back button, inline/large title, custom left/center/right/search bar subviews, native header bar buttons/menus/badges, crossfade), formSheet custom initial detents/corner radius/grabber/undimmed range, numeric-detent dragging and settling, eligible content scrolling, detent callbacks, guarded dismissal and stacked sheets, useHeaderHeight, useTransitionProgress, FullWindowOverlay, SearchBar with stacked and iOS 26 automatic/inline/integrated/integratedCentered/integratedButton toolbar placement, Tabs.Host/Screen, lifecycle callbacks (onAppear/onDisappear/onWillAppear/onWillDisappear), onDismissed",
|
|
5896
|
+
note: "screen container, stack, header and search chrome, native tabs, navigation props",
|
|
5897
|
+
working: "Screen, ScreenContainer, ScreenStack, enableFreeze/freezeEnabled with delayed React freeze, Android modal/pageSheet push fallback, Android statusBarHidden/statusBarStyle/navigationBarHidden traits, push/pop slide, replaceAnimation push/pop direction, zoom/fade/fade_from_bottom transitions, edge swipe-back, parallax behind-screen, large title collapse, header (back button, inline/large title, custom left/center/right/search bar subviews, native header bar buttons/menus/badges, crossfade), formSheet custom initial detents/corner radius/grabber/undimmed range, numeric-detent dragging and settling, eligible content scrolling, detent callbacks, guarded dismissal and stacked sheets, useHeaderHeight, useTransitionProgress, FullWindowOverlay, SearchBar with stacked and iOS 26 automatic/inline/integrated/integratedCentered/integratedButton toolbar placement, Tabs.Host/Screen with detached system Search, regular/inline bottomAccessory, tabBarMinimizeBehavior none/automatic/onScrollDown/onScrollUp, active-tab restoration and prior-main-tab persistence while Search is compact, lifecycle callbacks (onAppear/onDisappear/onWillAppear/onWillDisappear), onDismissed",
|
|
5898
5898
|
missing: "native velocity and spring fidelity, pointer cancellation, fit-to-content and non-numeric detents, numeric 1.0 native geometry, and expandsWhenScrolledToEdge remain incomplete or unverified"
|
|
5899
5899
|
}
|
|
5900
5900
|
]
|
|
@@ -9439,9 +9439,9 @@ var init_registry = __esm({
|
|
|
9439
9439
|
{
|
|
9440
9440
|
range: ">=1.21.0",
|
|
9441
9441
|
coverage: 0.72,
|
|
9442
|
-
note: "native-seam
|
|
9443
|
-
working: "ToolbarHost, ToolbarItem with SF Symbols/image sources, badges, fixed/fluid spacers, view children, nested MenuAction trees, disabled/selected/destructive actions,
|
|
9444
|
-
missing: "Color
|
|
9442
|
+
note: "native-seam for toolbar/menu and zoom-transition host views. The real @vxrn/native React code runs from the bundle and converts its public props into native host props.",
|
|
9443
|
+
working: "ToolbarHost, ToolbarItem with SF Symbols/image sources, badges, fixed/fluid spacers, view children, nested MenuAction trees, disabled/selected/destructive actions, visible action callbacks, ZoomTransitionSource source-window registration, and ZoomTransitionEnabler destination alignment",
|
|
9444
|
+
missing: "Color native host, SplitView gamma host, bottom SearchBarSlot integration with a configured native search controller, exact UIKit shared-background grouping"
|
|
9445
9445
|
}
|
|
9446
9446
|
]
|
|
9447
9447
|
},
|
|
@@ -31238,19 +31238,21 @@ function createBridge(wsPort, opts = {}) {
|
|
|
31238
31238
|
});
|
|
31239
31239
|
let warnedAboutContention = false;
|
|
31240
31240
|
let noticedTarget = false;
|
|
31241
|
-
const
|
|
31241
|
+
const lineageBySimId = /* @__PURE__ */ new Map();
|
|
31242
31242
|
const lineageLookupBySimId = /* @__PURE__ */ new Map();
|
|
31243
31243
|
function pickReloadedTarget(sims, retiredSimId) {
|
|
31244
|
-
const
|
|
31245
|
-
if (
|
|
31244
|
+
const lineage = lineageBySimId.get(retiredSimId);
|
|
31245
|
+
if (!lineage) return null;
|
|
31246
31246
|
const matches = (Array.isArray(sims) ? sims : []).filter(
|
|
31247
|
-
(sim) => sim.readyState === "open" && sim.meta?.sootsimHostPid ===
|
|
31247
|
+
(sim) => sim.readyState === "open" && sim.meta?.sootsimHostPid === lineage.hostPid && sim.connectedAt > lineage.connectedAt
|
|
31248
31248
|
);
|
|
31249
|
-
const
|
|
31250
|
-
if (
|
|
31251
|
-
|
|
31252
|
-
|
|
31253
|
-
|
|
31249
|
+
const successor = matches.find((sim) => sim.id === retiredSimId) ?? (matches.length === 1 ? matches[0] : null);
|
|
31250
|
+
if (!successor) return null;
|
|
31251
|
+
lineageBySimId.set(successor.id, {
|
|
31252
|
+
hostPid: lineage.hostPid,
|
|
31253
|
+
connectedAt: successor.connectedAt
|
|
31254
|
+
});
|
|
31255
|
+
return successor.id;
|
|
31254
31256
|
}
|
|
31255
31257
|
function maybeNoticeTarget(cmdType, simId) {
|
|
31256
31258
|
if (noticedTarget) return;
|
|
@@ -31340,7 +31342,7 @@ function createBridge(wsPort, opts = {}) {
|
|
|
31340
31342
|
const sentSimId = opts.simIdSource === "flag" ? opts.simId : readCurrentSimId() ?? opts.simId;
|
|
31341
31343
|
const targetedSimId = typeof cmd.simId === "string" && cmd.simId ? cmd.simId : sentSimId;
|
|
31342
31344
|
try {
|
|
31343
|
-
if (targetedSimId && cmd.type !== "bridge:list-sims" && !
|
|
31345
|
+
if (targetedSimId && cmd.type !== "bridge:list-sims" && !lineageBySimId.has(targetedSimId)) {
|
|
31344
31346
|
let lookup = lineageLookupBySimId.get(targetedSimId);
|
|
31345
31347
|
if (!lookup) {
|
|
31346
31348
|
lookup = (async () => {
|
|
@@ -31351,8 +31353,11 @@ function createBridge(wsPort, opts = {}) {
|
|
|
31351
31353
|
(sim) => sim.id === targetedSimId
|
|
31352
31354
|
);
|
|
31353
31355
|
const hostPid = targeted?.meta?.sootsimHostPid;
|
|
31354
|
-
if (typeof hostPid === "number") {
|
|
31355
|
-
|
|
31356
|
+
if (targeted && typeof hostPid === "number") {
|
|
31357
|
+
lineageBySimId.set(targetedSimId, {
|
|
31358
|
+
hostPid,
|
|
31359
|
+
connectedAt: targeted.connectedAt
|
|
31360
|
+
});
|
|
31356
31361
|
}
|
|
31357
31362
|
} catch {
|
|
31358
31363
|
} finally {
|
|
@@ -35142,7 +35147,7 @@ async function runOpenCommand(args, opts = {}) {
|
|
|
35142
35147
|
quiet
|
|
35143
35148
|
);
|
|
35144
35149
|
await maybeDescribeAfterOpen(parsed.wsPort, targetSim.id, args);
|
|
35145
|
-
return
|
|
35150
|
+
return { simId: targetSim.id, launched: false };
|
|
35146
35151
|
}
|
|
35147
35152
|
} finally {
|
|
35148
35153
|
bridge.close();
|
|
@@ -35216,7 +35221,7 @@ async function runOpenCommand(args, opts = {}) {
|
|
|
35216
35221
|
signalDriverLaunchConnected(result);
|
|
35217
35222
|
printOpenedSim(openUrl2, match, `${driver.name} driver`, quiet);
|
|
35218
35223
|
await maybeDescribeAfterOpen(parsed.wsPort, match.id, args);
|
|
35219
|
-
return
|
|
35224
|
+
return { simId: match.id, launched: true };
|
|
35220
35225
|
}
|
|
35221
35226
|
async function runUseLikeCommand(args, opts = {}) {
|
|
35222
35227
|
const parsed = parseBridgeCliArgs(args, {
|
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
/*! rnx v0.1.508 | (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.ts
|
|
23
|
+
var swift_exports = {};
|
|
24
|
+
__export(swift_exports, {
|
|
25
|
+
createSwiftModule: () => createSwiftModule
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(swift_exports);
|
|
28
|
+
|
|
29
|
+
// ../sootsim-swift/src/mount.tsx
|
|
30
|
+
var import_swift_ui = require("@expo/ui/swift-ui");
|
|
31
|
+
var import_react = require("react");
|
|
32
|
+
var import_react_native = require("react-native");
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
function isRecord(value) {
|
|
35
|
+
return typeof value === "object" && value !== null;
|
|
36
|
+
}
|
|
37
|
+
function readModifier(value) {
|
|
38
|
+
if (!isRecord(value) || typeof value.$type !== "string") {
|
|
39
|
+
throw new Error("swift modifier is not a { $type } object");
|
|
40
|
+
}
|
|
41
|
+
return { ...value, $type: value.$type };
|
|
42
|
+
}
|
|
43
|
+
function readNode(value) {
|
|
44
|
+
if (!isRecord(value)) throw new Error("swift node is not an object");
|
|
45
|
+
const { t, id, p, m, c, h } = value;
|
|
46
|
+
if (typeof t !== "string" || typeof id !== "string") {
|
|
47
|
+
throw new Error("swift node has no type or identity");
|
|
48
|
+
}
|
|
49
|
+
const node = { t, id };
|
|
50
|
+
if (p !== void 0) {
|
|
51
|
+
if (!isRecord(p)) throw new Error(`swift node ${id} has a non-object props`);
|
|
52
|
+
node.p = p;
|
|
53
|
+
}
|
|
54
|
+
if (m !== void 0) {
|
|
55
|
+
if (!Array.isArray(m)) throw new Error(`swift node ${id} has a non-array modifiers`);
|
|
56
|
+
node.m = m.map(readModifier);
|
|
57
|
+
}
|
|
58
|
+
if (c !== void 0) {
|
|
59
|
+
if (!Array.isArray(c)) throw new Error(`swift node ${id} has non-array children`);
|
|
60
|
+
node.c = c.map(readNode);
|
|
61
|
+
}
|
|
62
|
+
if (h !== void 0) {
|
|
63
|
+
if (!isRecord(h)) throw new Error(`swift node ${id} has non-object handlers`);
|
|
64
|
+
const handlers = {};
|
|
65
|
+
for (const [name, handlerId2] of Object.entries(h)) {
|
|
66
|
+
if (typeof handlerId2 !== "number") {
|
|
67
|
+
throw new Error(`swift node ${id} handler ${name} is not a number`);
|
|
68
|
+
}
|
|
69
|
+
handlers[name] = handlerId2;
|
|
70
|
+
}
|
|
71
|
+
node.h = handlers;
|
|
72
|
+
}
|
|
73
|
+
return node;
|
|
74
|
+
}
|
|
75
|
+
function readTree(text) {
|
|
76
|
+
const value = JSON.parse(text);
|
|
77
|
+
if (!Array.isArray(value)) throw new Error("swift tree is not an array");
|
|
78
|
+
return value.map(readNode);
|
|
79
|
+
}
|
|
80
|
+
var WASI_BADF = 8;
|
|
81
|
+
function wasiImports(host) {
|
|
82
|
+
return {
|
|
83
|
+
args_get: () => 0,
|
|
84
|
+
args_sizes_get: (argcPtr, argvSizePtr) => {
|
|
85
|
+
host.writeU32(argcPtr, 0);
|
|
86
|
+
host.writeU32(argvSizePtr, 0);
|
|
87
|
+
return 0;
|
|
88
|
+
},
|
|
89
|
+
environ_get: () => 0,
|
|
90
|
+
environ_sizes_get: (countPtr, sizePtr) => {
|
|
91
|
+
host.writeU32(countPtr, 0);
|
|
92
|
+
host.writeU32(sizePtr, 0);
|
|
93
|
+
return 0;
|
|
94
|
+
},
|
|
95
|
+
fd_close: () => WASI_BADF,
|
|
96
|
+
fd_fdstat_get: () => WASI_BADF,
|
|
97
|
+
fd_prestat_get: () => WASI_BADF,
|
|
98
|
+
fd_prestat_dir_name: () => WASI_BADF,
|
|
99
|
+
fd_read: () => WASI_BADF,
|
|
100
|
+
fd_seek: () => WASI_BADF,
|
|
101
|
+
fd_write: (_fd, iovsPtr, iovsLen, writtenPtr) => {
|
|
102
|
+
const view = new DataView(host.bytes().buffer);
|
|
103
|
+
let written = 0;
|
|
104
|
+
for (let index = 0; index < iovsLen; index += 1) {
|
|
105
|
+
written += view.getUint32(iovsPtr + index * 8 + 4, true);
|
|
106
|
+
}
|
|
107
|
+
host.writeU32(writtenPtr, written);
|
|
108
|
+
return 0;
|
|
109
|
+
},
|
|
110
|
+
path_open: () => WASI_BADF,
|
|
111
|
+
proc_exit: (code) => {
|
|
112
|
+
throw new Error(`swift app exited with code ${code}`);
|
|
113
|
+
},
|
|
114
|
+
random_get: (bufferPtr, length) => {
|
|
115
|
+
crypto.getRandomValues(host.bytes().subarray(bufferPtr, bufferPtr + length));
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function rawExport(exports2, name) {
|
|
121
|
+
const value = exports2[name];
|
|
122
|
+
if (typeof value !== "function") {
|
|
123
|
+
throw new Error(`swift artifact has no exported function ${name}`);
|
|
124
|
+
}
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
function pointerExport(exports2, name) {
|
|
128
|
+
const fn = rawExport(exports2, name);
|
|
129
|
+
return (...args) => {
|
|
130
|
+
const result = Reflect.apply(fn, void 0, args);
|
|
131
|
+
if (typeof result !== "number") {
|
|
132
|
+
throw new Error(`swift export ${name} returned ${typeof result}`);
|
|
133
|
+
}
|
|
134
|
+
return result;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function voidExport(exports2, name) {
|
|
138
|
+
const fn = rawExport(exports2, name);
|
|
139
|
+
return (...args) => {
|
|
140
|
+
Reflect.apply(fn, void 0, args);
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function instantiate(module2) {
|
|
144
|
+
let memory;
|
|
145
|
+
const requireMemory = () => {
|
|
146
|
+
if (!memory) throw new Error("swift artifact memory is not live");
|
|
147
|
+
return memory;
|
|
148
|
+
};
|
|
149
|
+
const host = {
|
|
150
|
+
writeU32(ptr, value) {
|
|
151
|
+
new DataView(requireMemory().buffer).setUint32(ptr, value, true);
|
|
152
|
+
},
|
|
153
|
+
bytes: () => new Uint8Array(requireMemory().buffer)
|
|
154
|
+
};
|
|
155
|
+
const instance = new WebAssembly.Instance(module2, {
|
|
156
|
+
wasi_snapshot_preview1: wasiImports(host)
|
|
157
|
+
});
|
|
158
|
+
const exportedMemory = instance.exports.memory;
|
|
159
|
+
if (!(exportedMemory instanceof WebAssembly.Memory)) {
|
|
160
|
+
throw new Error("swift artifact does not export its memory");
|
|
161
|
+
}
|
|
162
|
+
memory = exportedMemory;
|
|
163
|
+
const initialize = voidExport(instance.exports, "_initialize");
|
|
164
|
+
const mainArgv = voidExport(instance.exports, "__main_argc_argv");
|
|
165
|
+
const mount = pointerExport(instance.exports, "rnx_mount");
|
|
166
|
+
const event = pointerExport(instance.exports, "rnx_event");
|
|
167
|
+
const stateExport = pointerExport(instance.exports, "rnx_state_export");
|
|
168
|
+
const stateImport = voidExport(instance.exports, "rnx_state_import");
|
|
169
|
+
const alloc = pointerExport(instance.exports, "rnx_alloc");
|
|
170
|
+
const free = voidExport(instance.exports, "rnx_free");
|
|
171
|
+
const readBuffer = (ptr) => {
|
|
172
|
+
const view = new DataView(requireMemory().buffer);
|
|
173
|
+
const length = view.getUint32(ptr, true);
|
|
174
|
+
return new TextDecoder().decode(
|
|
175
|
+
new Uint8Array(requireMemory().buffer, ptr + 4, length)
|
|
176
|
+
);
|
|
177
|
+
};
|
|
178
|
+
const withPayload = (value, run) => {
|
|
179
|
+
const encoded = new TextEncoder().encode(JSON.stringify(value));
|
|
180
|
+
const ptr = alloc(encoded.length);
|
|
181
|
+
new Uint8Array(requireMemory().buffer).set(encoded, ptr);
|
|
182
|
+
const result = run(ptr, encoded.length);
|
|
183
|
+
free(ptr);
|
|
184
|
+
return result;
|
|
185
|
+
};
|
|
186
|
+
initialize();
|
|
187
|
+
mainArgv(0, 0);
|
|
188
|
+
return {
|
|
189
|
+
mount: () => readTree(readBuffer(mount())),
|
|
190
|
+
deliver: (handlerId2, payload) => readTree(
|
|
191
|
+
readBuffer(
|
|
192
|
+
withPayload(
|
|
193
|
+
payload,
|
|
194
|
+
(ptr, length) => (
|
|
195
|
+
// handler ids are opaque to the tenant: they come from the tree
|
|
196
|
+
// this instance just returned and they are only meaningful to it
|
|
197
|
+
event(handlerId2, ptr, length)
|
|
198
|
+
)
|
|
199
|
+
)
|
|
200
|
+
)
|
|
201
|
+
),
|
|
202
|
+
exportState: () => readBuffer(stateExport()),
|
|
203
|
+
importState: (state) => {
|
|
204
|
+
withPayload(JSON.parse(state), (ptr, length) => {
|
|
205
|
+
stateImport(ptr, length);
|
|
206
|
+
return 0;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
var compiledModules = /* @__PURE__ */ new Map();
|
|
212
|
+
function compile(url) {
|
|
213
|
+
const cached = compiledModules.get(url);
|
|
214
|
+
if (cached) return cached;
|
|
215
|
+
const pending = fetch(url).then((response) => {
|
|
216
|
+
if (!response.ok) {
|
|
217
|
+
throw new Error(`swift artifact ${url} answered ${response.status}`);
|
|
218
|
+
}
|
|
219
|
+
return response.arrayBuffer();
|
|
220
|
+
}).then((bytes) => WebAssembly.compile(bytes));
|
|
221
|
+
compiledModules.set(url, pending);
|
|
222
|
+
return pending;
|
|
223
|
+
}
|
|
224
|
+
var HIERARCHICAL = /* @__PURE__ */ new Map([
|
|
225
|
+
["label", "primary"],
|
|
226
|
+
["secondaryLabel", "secondary"]
|
|
227
|
+
]);
|
|
228
|
+
function withAlpha(color, alpha) {
|
|
229
|
+
const hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color);
|
|
230
|
+
if (hex) {
|
|
231
|
+
const digits = hex[1];
|
|
232
|
+
const full = digits.length === 3 ? digits.split("").map((digit) => digit + digit).join("") : digits;
|
|
233
|
+
const value = Number.parseInt(full, 16);
|
|
234
|
+
return `rgba(${value >> 16 & 255},${value >> 8 & 255},${value & 255},${alpha})`;
|
|
235
|
+
}
|
|
236
|
+
const rgba = /^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/.exec(color);
|
|
237
|
+
if (rgba) {
|
|
238
|
+
return `rgba(${rgba[1]},${rgba[2]},${rgba[3]},${Number(rgba[4]) * alpha})`;
|
|
239
|
+
}
|
|
240
|
+
throw new Error(`swift color ${color} cannot take opacity ${alpha}`);
|
|
241
|
+
}
|
|
242
|
+
function splitColor(value) {
|
|
243
|
+
const at = value.lastIndexOf("@");
|
|
244
|
+
return at === -1 ? { name: value, alpha: 1 } : { name: value.slice(0, at), alpha: Number(value.slice(at + 1)) };
|
|
245
|
+
}
|
|
246
|
+
function resolveColor(value) {
|
|
247
|
+
const { name, alpha } = splitColor(value);
|
|
248
|
+
const resolved = (0, import_react_native.PlatformColor)(name);
|
|
249
|
+
if (alpha === 1) return resolved;
|
|
250
|
+
if (typeof resolved === "string") return withAlpha(resolved, alpha);
|
|
251
|
+
if (isRecord(resolved) && isRecord(resolved.dynamic)) {
|
|
252
|
+
const variants = {};
|
|
253
|
+
for (const [scheme, variant] of Object.entries(resolved.dynamic)) {
|
|
254
|
+
if (typeof variant !== "string") {
|
|
255
|
+
throw new Error(`swift color ${name} has a non-string ${scheme} variant`);
|
|
256
|
+
}
|
|
257
|
+
variants[scheme] = withAlpha(variant, alpha);
|
|
258
|
+
}
|
|
259
|
+
return { dynamic: variants };
|
|
260
|
+
}
|
|
261
|
+
throw new Error(`swift color ${name} cannot take opacity ${alpha}`);
|
|
262
|
+
}
|
|
263
|
+
function resolveModifier(modifier) {
|
|
264
|
+
const color = modifier.color;
|
|
265
|
+
if (typeof color !== "string") {
|
|
266
|
+
const glass = modifier.glass;
|
|
267
|
+
if (modifier.$type === "glassEffect" && isRecord(glass) && typeof glass.tint === "string") {
|
|
268
|
+
return { ...modifier, glass: { ...glass, tint: resolveColor(glass.tint) } };
|
|
269
|
+
}
|
|
270
|
+
return modifier;
|
|
271
|
+
}
|
|
272
|
+
const { name, alpha } = splitColor(color);
|
|
273
|
+
const level = modifier.$type === "foregroundStyle" ? HIERARCHICAL.get(name) : void 0;
|
|
274
|
+
if (level !== void 0 && alpha === 1) {
|
|
275
|
+
return {
|
|
276
|
+
$type: "foregroundStyle",
|
|
277
|
+
styleType: "hierarchical",
|
|
278
|
+
hierarchicalStyle: level
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
return { ...modifier, color: resolveColor(color) };
|
|
282
|
+
}
|
|
283
|
+
var NODE_COMPONENTS = {
|
|
284
|
+
Button: import_swift_ui.Button,
|
|
285
|
+
Capsule: import_swift_ui.Capsule,
|
|
286
|
+
Circle: import_swift_ui.Circle,
|
|
287
|
+
Divider: import_swift_ui.Divider,
|
|
288
|
+
Form: import_swift_ui.Form,
|
|
289
|
+
Group: import_swift_ui.Group,
|
|
290
|
+
HStack: import_swift_ui.HStack,
|
|
291
|
+
Image: import_swift_ui.Image,
|
|
292
|
+
List: import_swift_ui.List,
|
|
293
|
+
Rectangle: import_swift_ui.Rectangle,
|
|
294
|
+
RoundedRectangle: import_swift_ui.RoundedRectangle,
|
|
295
|
+
ScrollView: import_swift_ui.ScrollView,
|
|
296
|
+
Section: import_swift_ui.Section,
|
|
297
|
+
Slider: import_swift_ui.Slider,
|
|
298
|
+
Spacer: import_swift_ui.Spacer,
|
|
299
|
+
Text: import_swift_ui.Text,
|
|
300
|
+
TextField: import_swift_ui.TextField,
|
|
301
|
+
Toggle: import_swift_ui.Toggle,
|
|
302
|
+
VStack: import_swift_ui.VStack,
|
|
303
|
+
ZStack: import_swift_ui.ZStack
|
|
304
|
+
};
|
|
305
|
+
var TEXT_STYLE_SIZES = /* @__PURE__ */ new Map([
|
|
306
|
+
["largeTitle", 34],
|
|
307
|
+
["title", 28],
|
|
308
|
+
["title2", 22],
|
|
309
|
+
["title3", 20],
|
|
310
|
+
["headline", 17],
|
|
311
|
+
["subheadline", 15],
|
|
312
|
+
["body", 17],
|
|
313
|
+
["callout", 16],
|
|
314
|
+
["footnote", 13],
|
|
315
|
+
["caption", 12],
|
|
316
|
+
["caption2", 11]
|
|
317
|
+
]);
|
|
318
|
+
var FONT_WEIGHTS = /* @__PURE__ */ new Map([
|
|
319
|
+
["ultraLight", "100"],
|
|
320
|
+
["thin", "200"],
|
|
321
|
+
["light", "300"],
|
|
322
|
+
["regular", "400"],
|
|
323
|
+
["medium", "500"],
|
|
324
|
+
["semibold", "600"],
|
|
325
|
+
["bold", "700"],
|
|
326
|
+
["heavy", "800"],
|
|
327
|
+
["black", "900"]
|
|
328
|
+
]);
|
|
329
|
+
function fontModifier(modifiers) {
|
|
330
|
+
return modifiers?.find((modifier) => modifier.$type === "font");
|
|
331
|
+
}
|
|
332
|
+
function fontStyle(font) {
|
|
333
|
+
if (!font) return void 0;
|
|
334
|
+
const style = {};
|
|
335
|
+
if (typeof font.size === "number") style.fontSize = font.size;
|
|
336
|
+
else if (typeof font.style === "string") {
|
|
337
|
+
const size = TEXT_STYLE_SIZES.get(font.style);
|
|
338
|
+
if (size === void 0) throw new Error(`swift font style ${font.style} has no size`);
|
|
339
|
+
style.fontSize = size;
|
|
340
|
+
}
|
|
341
|
+
if (typeof font.weight === "string") {
|
|
342
|
+
const weight = FONT_WEIGHTS.get(font.weight);
|
|
343
|
+
if (weight === void 0)
|
|
344
|
+
throw new Error(`swift font weight ${font.weight} has no value`);
|
|
345
|
+
style.fontWeight = weight;
|
|
346
|
+
}
|
|
347
|
+
return style;
|
|
348
|
+
}
|
|
349
|
+
function handlerId(node, name) {
|
|
350
|
+
return node.h?.[name];
|
|
351
|
+
}
|
|
352
|
+
function nodeProps(node, deliver) {
|
|
353
|
+
const props = node.p ?? {};
|
|
354
|
+
switch (node.t) {
|
|
355
|
+
case "Text": {
|
|
356
|
+
const style = fontStyle(fontModifier(node.m));
|
|
357
|
+
return {
|
|
358
|
+
children: typeof props.children === "string" ? props.children : "",
|
|
359
|
+
...style ? { style } : {}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
case "Image": {
|
|
363
|
+
const font = fontModifier(node.m);
|
|
364
|
+
const size = typeof font?.size === "number" ? font.size : void 0;
|
|
365
|
+
return {
|
|
366
|
+
...typeof props.systemName === "string" ? { systemName: props.systemName } : {},
|
|
367
|
+
...size === void 0 ? {} : { size }
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
case "Toggle": {
|
|
371
|
+
const onValueChange = handlerId(node, "onValueChange");
|
|
372
|
+
return {
|
|
373
|
+
isOn: props.value === true,
|
|
374
|
+
...onValueChange === void 0 ? {} : { onIsOnChange: (value) => deliver(onValueChange, value) }
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
case "TextField": {
|
|
378
|
+
const onChangeText = handlerId(node, "onChangeText");
|
|
379
|
+
return {
|
|
380
|
+
...typeof props.placeholder === "string" ? { placeholder: props.placeholder } : {},
|
|
381
|
+
...typeof props.defaultValue === "string" ? { defaultValue: props.defaultValue } : {},
|
|
382
|
+
...onChangeText === void 0 ? {} : { onChangeText: (value) => deliver(onChangeText, value) }
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
case "Slider": {
|
|
386
|
+
const onValueChange = handlerId(node, "onValueChange");
|
|
387
|
+
return {
|
|
388
|
+
value: typeof props.value === "number" ? props.value : 0,
|
|
389
|
+
min: typeof props.min === "number" ? props.min : 0,
|
|
390
|
+
max: typeof props.max === "number" ? props.max : 1,
|
|
391
|
+
...onValueChange === void 0 ? {} : { onValueChange: (value) => deliver(onValueChange, value) }
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
case "Button": {
|
|
395
|
+
const onPress = handlerId(node, "onPress");
|
|
396
|
+
return onPress === void 0 ? {} : { onPress: () => deliver(onPress, null) };
|
|
397
|
+
}
|
|
398
|
+
default:
|
|
399
|
+
return props;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
function buttonModifier(modifier) {
|
|
403
|
+
if (modifier.$type === "glassEffect") {
|
|
404
|
+
const glass = modifier.glass;
|
|
405
|
+
const variant = isRecord(glass) && typeof glass.variant === "string" ? glass.variant : "regular";
|
|
406
|
+
return variant === "identity" ? modifier : { $type: "buttonStyle", style: "glass" };
|
|
407
|
+
}
|
|
408
|
+
if (modifier.$type === "foregroundStyle" && modifier.color !== void 0) {
|
|
409
|
+
return { $type: "tint", color: modifier.color };
|
|
410
|
+
}
|
|
411
|
+
return modifier;
|
|
412
|
+
}
|
|
413
|
+
function nodeModifiers(node) {
|
|
414
|
+
const resolved = node.m?.map(resolveModifier);
|
|
415
|
+
if (node.t !== "Button") return resolved;
|
|
416
|
+
return resolved?.map(buttonModifier);
|
|
417
|
+
}
|
|
418
|
+
function renderNode(node, deliver) {
|
|
419
|
+
const component = NODE_COMPONENTS[node.t];
|
|
420
|
+
if (!component) throw new Error(`swift view ${node.t} has no rnx kit component`);
|
|
421
|
+
const modifiers = nodeModifiers(node);
|
|
422
|
+
const children = node.c?.map((child) => renderNode(child, deliver));
|
|
423
|
+
return (0, import_react.createElement)(
|
|
424
|
+
component,
|
|
425
|
+
{
|
|
426
|
+
key: node.id,
|
|
427
|
+
...modifiers === void 0 ? {} : { modifiers },
|
|
428
|
+
...nodeProps(node, deliver)
|
|
429
|
+
},
|
|
430
|
+
...children ?? []
|
|
431
|
+
);
|
|
432
|
+
}
|
|
433
|
+
var ROOT_KEY = "__rnx_swift_roots__";
|
|
434
|
+
function rootRegistry() {
|
|
435
|
+
const existing = Reflect.get(globalThis, ROOT_KEY);
|
|
436
|
+
if (existing instanceof Map) return existing;
|
|
437
|
+
const created = /* @__PURE__ */ new Map();
|
|
438
|
+
Reflect.set(globalThis, ROOT_KEY, created);
|
|
439
|
+
return created;
|
|
440
|
+
}
|
|
441
|
+
function createRoot() {
|
|
442
|
+
let instance = null;
|
|
443
|
+
let source = null;
|
|
444
|
+
let state = { tree: null, error: null };
|
|
445
|
+
let swap = Promise.resolve();
|
|
446
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
447
|
+
const publish = (next) => {
|
|
448
|
+
state = next;
|
|
449
|
+
for (const listener of listeners) listener();
|
|
450
|
+
};
|
|
451
|
+
const apply = async (options) => {
|
|
452
|
+
const carried = instance?.exportState() ?? null;
|
|
453
|
+
const created = instantiate(await compile(options.url));
|
|
454
|
+
if (carried !== null) created.importState(carried);
|
|
455
|
+
if (source !== options) return;
|
|
456
|
+
instance = created;
|
|
457
|
+
publish({ tree: created.mount(), error: null });
|
|
458
|
+
};
|
|
459
|
+
const component = function SwiftRoot() {
|
|
460
|
+
const rendered = (0, import_react.useSyncExternalStore)(
|
|
461
|
+
(listener) => {
|
|
462
|
+
listeners.add(listener);
|
|
463
|
+
return () => listeners.delete(listener);
|
|
464
|
+
},
|
|
465
|
+
() => state
|
|
466
|
+
);
|
|
467
|
+
if (rendered.error) throw rendered.error;
|
|
468
|
+
if (!rendered.tree) return null;
|
|
469
|
+
const deliver = (handlerId2, payload) => {
|
|
470
|
+
if (!instance) throw new Error("swift app received an event before it mounted");
|
|
471
|
+
publish({ tree: instance.deliver(handlerId2, payload), error: null });
|
|
472
|
+
};
|
|
473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_swift_ui.Host, { style: { flex: 1 }, children: rendered.tree.map((node) => renderNode(node, deliver)) });
|
|
474
|
+
};
|
|
475
|
+
return {
|
|
476
|
+
component,
|
|
477
|
+
use(options) {
|
|
478
|
+
const changed = source === null || source.hash !== options.hash || source.url !== options.url;
|
|
479
|
+
if (changed) {
|
|
480
|
+
source = options;
|
|
481
|
+
swap = swap.then(
|
|
482
|
+
() => apply(options),
|
|
483
|
+
() => apply(options)
|
|
484
|
+
);
|
|
485
|
+
swap.catch((error) => {
|
|
486
|
+
publish({
|
|
487
|
+
tree: null,
|
|
488
|
+
error: error instanceof Error ? error : new Error(String(error))
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
return component;
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
function createSwiftModule(options) {
|
|
497
|
+
const rootId = options.rootId ?? "root";
|
|
498
|
+
const registry = rootRegistry();
|
|
499
|
+
const existing = registry.get(rootId);
|
|
500
|
+
const root = existing ?? createRoot();
|
|
501
|
+
if (!existing) registry.set(rootId, root);
|
|
502
|
+
return root.use(options);
|
|
503
|
+
}
|
|
504
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
505
|
+
0 && (module.exports = {
|
|
506
|
+
createSwiftModule
|
|
507
|
+
});
|