sootsim 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +12 -0
  2. package/dist-cli/bin.js +16 -10
  3. package/dist-cli/chunks/agent-3T4BJEZM.js +61 -0
  4. package/dist-cli/chunks/agent-wrapper-WCYNLWHZ.js +15 -0
  5. package/dist-cli/chunks/assert-FPFJEFF3.js +47 -0
  6. package/dist-cli/chunks/auto-bootstrap-HDW6N77H.js +2 -0
  7. package/dist-cli/chunks/chunk-3HBBSRLE.js +2 -0
  8. package/dist-cli/chunks/chunk-4372UQHZ.js +308 -0
  9. package/dist-cli/chunks/chunk-4GWEO5CL.js +1 -0
  10. package/dist-cli/chunks/{chunk-G5MR66EB.js → chunk-5C5I5OFM.js} +2 -2
  11. package/dist-cli/chunks/chunk-6IPY24VM.js +11 -0
  12. package/dist-cli/chunks/chunk-AS4V7TZU.js +2 -0
  13. package/dist-cli/chunks/chunk-B5R4K2DG.js +5 -0
  14. package/dist-cli/chunks/chunk-CXTA5VGA.js +4 -0
  15. package/dist-cli/chunks/chunk-CZZB4DWG.js +3 -0
  16. package/dist-cli/chunks/chunk-DW54UPRZ.js +119 -0
  17. package/dist-cli/chunks/chunk-EIZCWDRE.js +1 -0
  18. package/dist-cli/chunks/{chunk-KSACMDXK.js → chunk-ET3NNZAR.js} +2 -2
  19. package/dist-cli/chunks/chunk-EWEKADK4.js +5 -0
  20. package/dist-cli/chunks/{chunk-JSF5LPNT.js → chunk-EWMYTXM2.js} +5 -5
  21. package/dist-cli/chunks/chunk-FUQ4XA6I.js +16 -0
  22. package/dist-cli/chunks/chunk-GQUOQNTP.js +27 -0
  23. package/dist-cli/chunks/chunk-HBNVKYSC.js +2 -0
  24. package/dist-cli/chunks/{chunk-64TOMNZX.js → chunk-HORCHQT7.js} +2 -2
  25. package/dist-cli/chunks/{chunk-YCETS3B3.js → chunk-ISAMAM3I.js} +2 -2
  26. package/dist-cli/chunks/{chunk-GPVPHE2B.js → chunk-K6YUSCAC.js} +2 -2
  27. package/dist-cli/chunks/{chunk-E522F5JW.js → chunk-K7LDP7JL.js} +1 -1
  28. package/dist-cli/chunks/chunk-KZ2LIDW6.js +2 -0
  29. package/dist-cli/chunks/{chunk-J2S3OCWA.js → chunk-LOV766MI.js} +1 -1
  30. package/dist-cli/chunks/{chunk-OROM7DZI.js → chunk-LXCFGKL2.js} +1 -1
  31. package/dist-cli/chunks/{chunk-PWXPA745.js → chunk-NE62JSI6.js} +1 -1
  32. package/dist-cli/chunks/chunk-NHA3G6A3.js +22 -0
  33. package/dist-cli/chunks/chunk-NXWCDGWS.js +2 -0
  34. package/dist-cli/chunks/{chunk-QOBRRY5X.js → chunk-RJUBGX5M.js} +1 -1
  35. package/dist-cli/chunks/chunk-SLCVEGTW.js +4 -0
  36. package/dist-cli/chunks/chunk-TGDP3D3V.js +34 -0
  37. package/dist-cli/chunks/chunk-TSZBQS6W.js +62 -0
  38. package/dist-cli/chunks/chunk-XKDQEYTE.js +1 -0
  39. package/dist-cli/chunks/chunk-XXUAOYYT.js +4 -0
  40. package/dist-cli/chunks/{chunk-7X6OPSRD.js → chunk-YVSZHVLU.js} +2 -2
  41. package/dist-cli/chunks/{compat-MRN2ORY5.js → compat-3HMKLGXL.js} +4 -4
  42. package/dist-cli/chunks/{config-CO5IYWUY.js → config-IJQ3KANN.js} +5 -5
  43. package/dist-cli/chunks/control-3RAFI4AW.js +2 -0
  44. package/dist-cli/chunks/{daemon-G4XVRFHM.js → daemon-BBEQJLRY.js} +2 -2
  45. package/dist-cli/chunks/{debug-ZNSZTWT6.js → debug-SGZ5ZFQI.js} +4 -4
  46. package/dist-cli/chunks/demo-app-registry-NCYP3WA6.js +2 -0
  47. package/dist-cli/chunks/{detox-JEGYNTYV.js → detox-PK74V2Y7.js} +2 -2
  48. package/dist-cli/chunks/{device-BS34FAFM.js → device-MWNFX54L.js} +2 -2
  49. package/dist-cli/chunks/drivers-EXUREU4B.js +2 -0
  50. package/dist-cli/chunks/electron-3NIHSU2K.js +15 -0
  51. package/dist-cli/chunks/flow-6Y3E6E5P.js +2 -0
  52. package/dist-cli/chunks/{hints-7Z656W4H.js → hints-XZJLBIXW.js} +2 -2
  53. package/dist-cli/chunks/home-paths-BNRMUBJA.js +2 -0
  54. package/dist-cli/chunks/{inspect-NAHXP2M5.js → inspect-FGTUAK4C.js} +153 -165
  55. package/dist-cli/chunks/install-LCXALH26.js +65 -0
  56. package/dist-cli/chunks/{install-desktop-PYIZIH67.js → install-desktop-U3RQ6XUX.js} +8 -4
  57. package/dist-cli/chunks/install-dev-desktop-BLKRFI42.js +100 -0
  58. package/dist-cli/chunks/keys-N5LBDSD5.js +19 -0
  59. package/dist-cli/chunks/launch-NIMSJH5I.js +16 -0
  60. package/dist-cli/chunks/{login-Z5Z54HUJ.js → login-CQV2XBRM.js} +5 -5
  61. package/dist-cli/chunks/{logout-T2QDYGCB.js → logout-R56NWAWQ.js} +2 -2
  62. package/dist-cli/chunks/{maestro-4AXTS7OE.js → maestro-ZYUVTM7H.js} +2 -2
  63. package/dist-cli/chunks/{preview-NMGWHWMX.js → preview-AOAWAYEQ.js} +2 -2
  64. package/dist-cli/chunks/{profile-6RGJA4FR.js → profile-DDADDPRW.js} +3 -3
  65. package/dist-cli/chunks/record-3OIOTHP6.js +37 -0
  66. package/dist-cli/chunks/runtime-JTLZYEXK.js +25 -0
  67. package/dist-cli/chunks/{screenshot-R3GCCSCI.js → screenshot-Q6N2V5LL.js} +3 -3
  68. package/dist-cli/chunks/screenshot-mode-WWLWJWQD.js +17 -0
  69. package/dist-cli/chunks/{screenshots-4UQJE4NC.js → screenshots-2JEPJGZO.js} +2 -2
  70. package/dist-cli/chunks/server-VH34RVAX.js +29 -0
  71. package/dist-cli/chunks/{skills-2PPKPL4B.js → skills-PU4627FY.js} +2 -2
  72. package/dist-cli/chunks/store-U2VDD2S4.js +2 -0
  73. package/dist-cli/chunks/{test-5LFKOQ4M.js → test-AECE56E7.js} +3 -3
  74. package/dist-cli/chunks/upload-KPP7KG6E.js +2 -0
  75. package/dist-cli/chunks/{whoami-H6FW34JS.js → whoami-NCGRRR7X.js} +2 -2
  76. package/dist-lib/agent-daemon-client.cjs +414 -0
  77. package/dist-lib/agent-events.cjs +48 -0
  78. package/dist-lib/agent-sessions.cjs +692 -0
  79. package/dist-lib/attached-projects.cjs +448 -0
  80. package/dist-lib/auth/shared-session.cjs +174 -0
  81. package/dist-lib/backend-origin.cjs +70 -0
  82. package/dist-lib/bridge-constants.cjs +32 -0
  83. package/dist-lib/cli-constants.cjs +32 -0
  84. package/dist-lib/config.cjs +88 -0
  85. package/dist-lib/dev-bundle-resolution.cjs +236 -0
  86. package/dist-lib/home-paths.cjs +234 -0
  87. package/dist-lib/host/bridge-host.cjs +3458 -0
  88. package/dist-lib/index.cjs +361 -0
  89. package/dist-lib/metro.cjs +215 -0
  90. package/dist-lib/render-mode.cjs +54 -0
  91. package/dist-lib/vite-base.cjs +4217 -0
  92. package/dist-lib/vite.cjs +178 -0
  93. package/package.json +80 -13
  94. package/scripts/postinstall.cjs +70 -0
  95. package/dist-cli/chunks/bridge-host-2EY7Z4AO.js +0 -2
  96. package/dist-cli/chunks/chunk-3C3ZH7PP.js +0 -4
  97. package/dist-cli/chunks/chunk-3R4ZZESY.js +0 -119
  98. package/dist-cli/chunks/chunk-74XPLOV4.js +0 -2
  99. package/dist-cli/chunks/chunk-7LMDCMSI.js +0 -8
  100. package/dist-cli/chunks/chunk-A2CZQIWO.js +0 -1
  101. package/dist-cli/chunks/chunk-CKZ376AY.js +0 -322
  102. package/dist-cli/chunks/chunk-E5UBZEYR.js +0 -2
  103. package/dist-cli/chunks/chunk-HOIHCO7S.js +0 -3
  104. package/dist-cli/chunks/chunk-KQWZZ56P.js +0 -2
  105. package/dist-cli/chunks/chunk-KSB6MSZ4.js +0 -34
  106. package/dist-cli/chunks/chunk-KXYKAYYB.js +0 -51
  107. package/dist-cli/chunks/chunk-MBFP2LVH.js +0 -3
  108. package/dist-cli/chunks/chunk-MPSZ5EWF.js +0 -16
  109. package/dist-cli/chunks/chunk-X2U72K7X.js +0 -1
  110. package/dist-cli/chunks/control-Y7TKKB6D.js +0 -2
  111. package/dist-cli/chunks/dev-ZUKCZQEX.js +0 -25
  112. package/dist-cli/chunks/dev-checkout-IEZVVTCN.js +0 -2
  113. package/dist-cli/chunks/drivers-46PFFIDF.js +0 -2
  114. package/dist-cli/chunks/electron-P2KOPX2S.js +0 -15
  115. package/dist-cli/chunks/flow-VVOF6UNC.js +0 -2
  116. package/dist-cli/chunks/install-EPUJX4AT.js +0 -67
  117. package/dist-cli/chunks/record-IE27Z2GA.js +0 -37
  118. package/dist-cli/chunks/screenshot-mode-SZQDNGYE.js +0 -17
  119. package/dist-cli/chunks/server-AN2G5KO4.js +0 -21
  120. package/dist-cli/chunks/store-PU5ES4YQ.js +0 -2
  121. package/dist-cli/chunks/upload-BYNPC54C.js +0 -2
  122. package/dist-cli/chunks/vite-plugin-5AEUUBKP.js +0 -9
@@ -0,0 +1,361 @@
1
+ /*! sootsim v0.0.2 | (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 __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/index.ts
33
+ var src_exports = {};
34
+ __export(src_exports, {
35
+ DEFAULT_SOOTSIM_BRIDGE_PORT: () => DEFAULT_SOOTSIM_BRIDGE_PORT,
36
+ DEFAULT_SOOTSIM_SHELL_URL: () => DEFAULT_SOOTSIM_SHELL_URL,
37
+ metroPlugin: () => metro_plugin_default,
38
+ sootsimPlugin: () => sootsimPlugin
39
+ });
40
+ module.exports = __toCommonJS(src_exports);
41
+
42
+ // src/vite-plugin-one.ts
43
+ var import_fs = __toESM(require("fs"), 1);
44
+ var import_path = __toESM(require("path"), 1);
45
+ var sootsimRoot = import_path.default.resolve(import_path.default.dirname(new URL(__sootsim_import_meta_url).pathname), "..");
46
+ var distDir = import_path.default.join(sootsimRoot, "dist-plugin");
47
+ var publicDir = import_path.default.join(sootsimRoot, "public");
48
+ var MIME_TYPES = {
49
+ ".js": "application/javascript",
50
+ ".mjs": "application/javascript",
51
+ ".css": "text/css",
52
+ ".html": "text/html",
53
+ ".wasm": "application/wasm",
54
+ ".json": "application/json",
55
+ ".png": "image/png",
56
+ ".svg": "image/svg+xml",
57
+ ".ttf": "font/ttf",
58
+ ".otf": "font/otf",
59
+ ".woff": "font/woff",
60
+ ".woff2": "font/woff2",
61
+ ".mp3": "audio/mpeg",
62
+ ".wav": "audio/wav",
63
+ ".jpg": "image/jpeg",
64
+ ".webp": "image/webp"
65
+ };
66
+ function sootsimPlugin(options = {}) {
67
+ if (options.enabled === false) return [];
68
+ const prefix2 = options.prefix || "/__soot";
69
+ return [
70
+ {
71
+ name: "sootsim-one",
72
+ configureServer(server) {
73
+ const bundleUrl = options.bundleUrl || "/node_modules/one/metro-entry.bundle?platform=ios&dev=true&minify=false";
74
+ server.middlewares.use((req, res, next) => {
75
+ const origWriteHead = res.writeHead.bind(res);
76
+ res.writeHead = function(statusCode, ...args) {
77
+ const setCookie = res.getHeader("set-cookie");
78
+ if (setCookie) {
79
+ const value = Array.isArray(setCookie) ? setCookie.join(", ") : String(setCookie);
80
+ res.setHeader("x-sootsim-set-cookie", value);
81
+ res.setHeader("access-control-expose-headers", "x-sootsim-set-cookie");
82
+ }
83
+ return origWriteHead(
84
+ statusCode,
85
+ ...args
86
+ );
87
+ };
88
+ next();
89
+ });
90
+ server.middlewares.use((req, res, next) => {
91
+ const url = req.url || "";
92
+ if (url === prefix2 || url === prefix2 + "/" || url.startsWith(prefix2 + "/?")) {
93
+ const htmlPath = import_path.default.join(distDir, "index.html");
94
+ if (!import_fs.default.existsSync(htmlPath)) {
95
+ res.statusCode = 500;
96
+ res.end("[sootsim] dist-plugin not built. run: bun scripts/build-plugin.ts");
97
+ return;
98
+ }
99
+ let html = import_fs.default.readFileSync(htmlPath, "utf8");
100
+ html = html.replace(
101
+ "</head>",
102
+ `<script>history.replaceState(null,'','${prefix2}/?bundle=${encodeURIComponent(bundleUrl)}')</script></head>`
103
+ );
104
+ res.setHeader("content-type", "text/html");
105
+ res.end(html);
106
+ return;
107
+ }
108
+ if (url.startsWith(prefix2 + "/")) {
109
+ const filePath = url.slice(prefix2.length).split("?")[0];
110
+ const fullPath = import_path.default.join(distDir, filePath);
111
+ if (import_fs.default.existsSync(fullPath) && import_fs.default.statSync(fullPath).isFile()) {
112
+ const ext = import_path.default.extname(fullPath);
113
+ res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
114
+ res.setHeader("cache-control", "max-age=31536000,immutable");
115
+ import_fs.default.createReadStream(fullPath).pipe(res);
116
+ return;
117
+ }
118
+ const publicPath = import_path.default.join(publicDir, filePath);
119
+ if (import_fs.default.existsSync(publicPath) && import_fs.default.statSync(publicPath).isFile()) {
120
+ const ext = import_path.default.extname(publicPath);
121
+ res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
122
+ import_fs.default.createReadStream(publicPath).pipe(res);
123
+ return;
124
+ }
125
+ }
126
+ const staticRoots = ["/canvaskit.wasm", "/fonts/", "/icons/", "/sounds/"];
127
+ if (staticRoots.some((p) => url.startsWith(p))) {
128
+ const fullPath = import_path.default.join(publicDir, url.split("?")[0]);
129
+ if (import_fs.default.existsSync(fullPath) && import_fs.default.statSync(fullPath).isFile()) {
130
+ const ext = import_path.default.extname(fullPath);
131
+ res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
132
+ import_fs.default.createReadStream(fullPath).pipe(res);
133
+ return;
134
+ }
135
+ }
136
+ next();
137
+ });
138
+ const port = server.config.server.port || 8081;
139
+ const sootsimUrl = `http://localhost:${port}${prefix2}/`;
140
+ console.log(`[sootsim] serving at ${sootsimUrl}`);
141
+ openElectronApp(sootsimUrl);
142
+ }
143
+ }
144
+ ];
145
+ }
146
+ async function openElectronApp(sootsimUrl) {
147
+ if (process.platform !== "darwin") return;
148
+ const { execSync, exec } = await import("child_process");
149
+ const schemeUrl = `sootsim://dev?url=${encodeURIComponent(sootsimUrl)}`;
150
+ try {
151
+ exec(`open "${schemeUrl}"`);
152
+ return;
153
+ } catch {
154
+ }
155
+ const candidates = [
156
+ "/Applications/sootsim.app",
157
+ import_path.default.join(process.env.HOME || "", "Applications/sootsim.app"),
158
+ import_path.default.join(sootsimRoot, "release/mac-arm64/sootsim.app")
159
+ ];
160
+ let appPath = candidates.find((p) => import_fs.default.existsSync(p));
161
+ if (!appPath) {
162
+ try {
163
+ const found = execSync(
164
+ 'mdfind "kMDItemCFBundleIdentifier == dev.sootsim.simulator"',
165
+ { encoding: "utf8", timeout: 3e3 }
166
+ ).trim();
167
+ if (found) appPath = found.split("\n")[0];
168
+ } catch {
169
+ }
170
+ }
171
+ if (appPath) {
172
+ try {
173
+ exec(`open -a "${appPath}" "${sootsimUrl}"`);
174
+ } catch {
175
+ }
176
+ }
177
+ }
178
+
179
+ // src/metro-plugin.ts
180
+ var import_fs3 = __toESM(require("fs"), 1);
181
+ var import_path3 = __toESM(require("path"), 1);
182
+
183
+ // src/home-paths.ts
184
+ var import_fs2 = __toESM(require("fs"), 1);
185
+ var import_os = require("os");
186
+ var import_path2 = __toESM(require("path"), 1);
187
+ var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
188
+ var ACTIVE_RUNTIME_FILE = "active";
189
+ function sootsimHomeDir() {
190
+ const override = process.env[SOOTSIM_HOME_ENV];
191
+ if (override && override.length > 0) return import_path2.default.resolve(override);
192
+ return import_path2.default.join((0, import_os.homedir)(), ".sootsim");
193
+ }
194
+ function runtimesDir() {
195
+ return import_path2.default.join(sootsimHomeDir(), "runtimes");
196
+ }
197
+ function runtimeDir(version) {
198
+ return import_path2.default.join(runtimesDir(), version);
199
+ }
200
+ function activeRuntimeFile() {
201
+ return import_path2.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
202
+ }
203
+ function readActiveRuntime() {
204
+ try {
205
+ const value = import_fs2.default.readFileSync(activeRuntimeFile(), "utf8").trim();
206
+ return value.length > 0 ? value : null;
207
+ } catch {
208
+ return null;
209
+ }
210
+ }
211
+ var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
212
+
213
+ // src/metro-plugin.ts
214
+ var prefix = "/__soot";
215
+ function resolveRuntimeRoot() {
216
+ const active = readActiveRuntime();
217
+ if (!active) return null;
218
+ const dir = runtimeDir(active);
219
+ if (!import_fs3.default.existsSync(import_path3.default.join(dir, "index.html"))) return null;
220
+ return dir;
221
+ }
222
+ var RUNTIME_MISSING_MESSAGE = "[sootsim] no engine runtime installed \u2014 run `sootsim install` in your project, or `sootsim runtime install`";
223
+ var MIME_TYPES2 = {
224
+ ".js": "application/javascript",
225
+ ".css": "text/css",
226
+ ".html": "text/html",
227
+ ".wasm": "application/wasm",
228
+ ".json": "application/json",
229
+ ".jpg": "image/jpeg",
230
+ ".jpeg": "image/jpeg",
231
+ ".png": "image/png",
232
+ ".svg": "image/svg+xml",
233
+ ".webp": "image/webp",
234
+ ".glb": "model/gltf-binary",
235
+ ".ttf": "font/ttf",
236
+ ".otf": "font/otf",
237
+ ".mp3": "audio/mpeg",
238
+ ".wav": "audio/wav"
239
+ };
240
+ var ROOT_RUNTIME_PATHS = [
241
+ "/assets/",
242
+ "/engine/",
243
+ "/engine-tenant/",
244
+ "/photos/",
245
+ "/three-mode/",
246
+ "/canvaskit.wasm",
247
+ "/fonts/",
248
+ "/icons/",
249
+ "/sounds/",
250
+ "/spike/",
251
+ "/test-wallpaper.jpg",
252
+ "/preview-sw.js"
253
+ ];
254
+ function isRootRuntimeAssetPath(pathname) {
255
+ return ROOT_RUNTIME_PATHS.some((p) => pathname === p || pathname.startsWith(p));
256
+ }
257
+ function resolveRuntimeFilePath(runtimeRoot, pathname) {
258
+ if (!pathname.startsWith("/")) return null;
259
+ if (pathname.includes("\0") || pathname.includes("\\")) return null;
260
+ for (const segment of pathname.split("/")) {
261
+ if (segment === "..") return null;
262
+ }
263
+ const fullPath = import_path3.default.resolve(runtimeRoot, pathname.replace(/^\/+/, ""));
264
+ const rootWithSep = runtimeRoot.endsWith(import_path3.default.sep) ? runtimeRoot : runtimeRoot + import_path3.default.sep;
265
+ if (!fullPath.startsWith(rootWithSep) && fullPath !== runtimeRoot) return null;
266
+ if (!import_fs3.default.existsSync(fullPath) || !import_fs3.default.statSync(fullPath).isFile()) return null;
267
+ return fullPath;
268
+ }
269
+ function withSootsim(config, options = {}) {
270
+ if (options.enabled === false) return config;
271
+ const bundleUrl = options.bundleUrl || "/index.bundle?platform=ios&dev=true&hot=true&minify=false";
272
+ const cfgServer = config.server;
273
+ const existingEnhance = cfgServer?.enhanceMiddleware;
274
+ const serverConfig = {
275
+ ...cfgServer,
276
+ enhanceMiddleware: (metroMiddleware, metroServer) => {
277
+ let middleware = metroMiddleware;
278
+ if (existingEnhance) {
279
+ middleware = existingEnhance(metroMiddleware, metroServer);
280
+ }
281
+ let connect;
282
+ try {
283
+ connect = require("connect");
284
+ } catch {
285
+ console.warn("[sootsim] connect not available");
286
+ return middleware;
287
+ }
288
+ const server = connect();
289
+ server.use((req, res, next) => {
290
+ const url = req.url || "";
291
+ const pathname = url.split("?")[0];
292
+ const runtimeRoot = resolveRuntimeRoot();
293
+ if (!runtimeRoot) {
294
+ if (pathname === prefix || pathname === prefix + "/") {
295
+ res.statusCode = 500;
296
+ res.end(RUNTIME_MISSING_MESSAGE);
297
+ return;
298
+ }
299
+ next();
300
+ return;
301
+ }
302
+ if (isRootRuntimeAssetPath(pathname)) {
303
+ const fullPath = resolveRuntimeFilePath(runtimeRoot, pathname);
304
+ if (fullPath) {
305
+ serveRuntimeFile(res, fullPath);
306
+ return;
307
+ }
308
+ }
309
+ if (pathname.startsWith(prefix + "/")) {
310
+ const fullPath = resolveRuntimeFilePath(
311
+ runtimeRoot,
312
+ pathname.slice(prefix.length)
313
+ );
314
+ if (fullPath) {
315
+ serveRuntimeFile(res, fullPath);
316
+ return;
317
+ }
318
+ }
319
+ if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
320
+ const ext = import_path3.default.extname(pathname);
321
+ if (!ext) {
322
+ const htmlPath = import_path3.default.join(runtimeRoot, "index.html");
323
+ let html = import_fs3.default.readFileSync(htmlPath, "utf8");
324
+ html = html.replace(
325
+ "</head>",
326
+ `<script>history.replaceState(null,'','${prefix}/?bundle=${encodeURIComponent(bundleUrl)}')</script></head>`
327
+ );
328
+ res.setHeader("content-type", "text/html");
329
+ res.end(html);
330
+ return;
331
+ }
332
+ }
333
+ next();
334
+ });
335
+ server.use(middleware);
336
+ console.log(`[sootsim] serving at ${prefix}/`);
337
+ return server;
338
+ }
339
+ };
340
+ return { ...config, server: serverConfig };
341
+ }
342
+ var metro_plugin_default = withSootsim;
343
+ function serveRuntimeFile(res, fullPath) {
344
+ const ext = import_path3.default.extname(fullPath);
345
+ res.setHeader("content-type", MIME_TYPES2[ext] || "application/octet-stream");
346
+ res.setHeader("cache-control", "max-age=31536000,immutable");
347
+ import_fs3.default.createReadStream(fullPath).pipe(res);
348
+ }
349
+
350
+ // src/bridge-constants.ts
351
+ var DEFAULT_SOOTSIM_BRIDGE_PORT = 7668;
352
+
353
+ // src/cli-constants.ts
354
+ var DEFAULT_SOOTSIM_SHELL_URL = "http://localhost:5173/";
355
+ // Annotate the CommonJS export names for ESM import in node:
356
+ 0 && (module.exports = {
357
+ DEFAULT_SOOTSIM_BRIDGE_PORT,
358
+ DEFAULT_SOOTSIM_SHELL_URL,
359
+ metroPlugin,
360
+ sootsimPlugin
361
+ });
@@ -0,0 +1,215 @@
1
+ /*! sootsim v0.0.2 | (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 __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/metro-plugin.ts
33
+ var metro_plugin_exports = {};
34
+ __export(metro_plugin_exports, {
35
+ default: () => metro_plugin_default,
36
+ isRootRuntimeAssetPath: () => isRootRuntimeAssetPath,
37
+ resolveRuntimeFilePath: () => resolveRuntimeFilePath,
38
+ withSootsim: () => withSootsim
39
+ });
40
+ module.exports = __toCommonJS(metro_plugin_exports);
41
+ var import_fs2 = __toESM(require("fs"), 1);
42
+ var import_path2 = __toESM(require("path"), 1);
43
+
44
+ // src/home-paths.ts
45
+ var import_fs = __toESM(require("fs"), 1);
46
+ var import_os = require("os");
47
+ var import_path = __toESM(require("path"), 1);
48
+ var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
49
+ var ACTIVE_RUNTIME_FILE = "active";
50
+ function sootsimHomeDir() {
51
+ const override = process.env[SOOTSIM_HOME_ENV];
52
+ if (override && override.length > 0) return import_path.default.resolve(override);
53
+ return import_path.default.join((0, import_os.homedir)(), ".sootsim");
54
+ }
55
+ function runtimesDir() {
56
+ return import_path.default.join(sootsimHomeDir(), "runtimes");
57
+ }
58
+ function runtimeDir(version) {
59
+ return import_path.default.join(runtimesDir(), version);
60
+ }
61
+ function activeRuntimeFile() {
62
+ return import_path.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
63
+ }
64
+ function readActiveRuntime() {
65
+ try {
66
+ const value = import_fs.default.readFileSync(activeRuntimeFile(), "utf8").trim();
67
+ return value.length > 0 ? value : null;
68
+ } catch {
69
+ return null;
70
+ }
71
+ }
72
+ var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
73
+
74
+ // src/metro-plugin.ts
75
+ var prefix = "/__soot";
76
+ function resolveRuntimeRoot() {
77
+ const active = readActiveRuntime();
78
+ if (!active) return null;
79
+ const dir = runtimeDir(active);
80
+ if (!import_fs2.default.existsSync(import_path2.default.join(dir, "index.html"))) return null;
81
+ return dir;
82
+ }
83
+ var RUNTIME_MISSING_MESSAGE = "[sootsim] no engine runtime installed \u2014 run `sootsim install` in your project, or `sootsim runtime install`";
84
+ var MIME_TYPES = {
85
+ ".js": "application/javascript",
86
+ ".css": "text/css",
87
+ ".html": "text/html",
88
+ ".wasm": "application/wasm",
89
+ ".json": "application/json",
90
+ ".jpg": "image/jpeg",
91
+ ".jpeg": "image/jpeg",
92
+ ".png": "image/png",
93
+ ".svg": "image/svg+xml",
94
+ ".webp": "image/webp",
95
+ ".glb": "model/gltf-binary",
96
+ ".ttf": "font/ttf",
97
+ ".otf": "font/otf",
98
+ ".mp3": "audio/mpeg",
99
+ ".wav": "audio/wav"
100
+ };
101
+ var ROOT_RUNTIME_PATHS = [
102
+ "/assets/",
103
+ "/engine/",
104
+ "/engine-tenant/",
105
+ "/photos/",
106
+ "/three-mode/",
107
+ "/canvaskit.wasm",
108
+ "/fonts/",
109
+ "/icons/",
110
+ "/sounds/",
111
+ "/spike/",
112
+ "/test-wallpaper.jpg",
113
+ "/preview-sw.js"
114
+ ];
115
+ function isRootRuntimeAssetPath(pathname) {
116
+ return ROOT_RUNTIME_PATHS.some((p) => pathname === p || pathname.startsWith(p));
117
+ }
118
+ function resolveRuntimeFilePath(runtimeRoot, pathname) {
119
+ if (!pathname.startsWith("/")) return null;
120
+ if (pathname.includes("\0") || pathname.includes("\\")) return null;
121
+ for (const segment of pathname.split("/")) {
122
+ if (segment === "..") return null;
123
+ }
124
+ const fullPath = import_path2.default.resolve(runtimeRoot, pathname.replace(/^\/+/, ""));
125
+ const rootWithSep = runtimeRoot.endsWith(import_path2.default.sep) ? runtimeRoot : runtimeRoot + import_path2.default.sep;
126
+ if (!fullPath.startsWith(rootWithSep) && fullPath !== runtimeRoot) return null;
127
+ if (!import_fs2.default.existsSync(fullPath) || !import_fs2.default.statSync(fullPath).isFile()) return null;
128
+ return fullPath;
129
+ }
130
+ function withSootsim(config, options = {}) {
131
+ if (options.enabled === false) return config;
132
+ const bundleUrl = options.bundleUrl || "/index.bundle?platform=ios&dev=true&hot=true&minify=false";
133
+ const cfgServer = config.server;
134
+ const existingEnhance = cfgServer?.enhanceMiddleware;
135
+ const serverConfig = {
136
+ ...cfgServer,
137
+ enhanceMiddleware: (metroMiddleware, metroServer) => {
138
+ let middleware = metroMiddleware;
139
+ if (existingEnhance) {
140
+ middleware = existingEnhance(metroMiddleware, metroServer);
141
+ }
142
+ let connect;
143
+ try {
144
+ connect = require("connect");
145
+ } catch {
146
+ console.warn("[sootsim] connect not available");
147
+ return middleware;
148
+ }
149
+ const server = connect();
150
+ server.use((req, res, next) => {
151
+ const url = req.url || "";
152
+ const pathname = url.split("?")[0];
153
+ const runtimeRoot = resolveRuntimeRoot();
154
+ if (!runtimeRoot) {
155
+ if (pathname === prefix || pathname === prefix + "/") {
156
+ res.statusCode = 500;
157
+ res.end(RUNTIME_MISSING_MESSAGE);
158
+ return;
159
+ }
160
+ next();
161
+ return;
162
+ }
163
+ if (isRootRuntimeAssetPath(pathname)) {
164
+ const fullPath = resolveRuntimeFilePath(runtimeRoot, pathname);
165
+ if (fullPath) {
166
+ serveRuntimeFile(res, fullPath);
167
+ return;
168
+ }
169
+ }
170
+ if (pathname.startsWith(prefix + "/")) {
171
+ const fullPath = resolveRuntimeFilePath(
172
+ runtimeRoot,
173
+ pathname.slice(prefix.length)
174
+ );
175
+ if (fullPath) {
176
+ serveRuntimeFile(res, fullPath);
177
+ return;
178
+ }
179
+ }
180
+ if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
181
+ const ext = import_path2.default.extname(pathname);
182
+ if (!ext) {
183
+ const htmlPath = import_path2.default.join(runtimeRoot, "index.html");
184
+ let html = import_fs2.default.readFileSync(htmlPath, "utf8");
185
+ html = html.replace(
186
+ "</head>",
187
+ `<script>history.replaceState(null,'','${prefix}/?bundle=${encodeURIComponent(bundleUrl)}')</script></head>`
188
+ );
189
+ res.setHeader("content-type", "text/html");
190
+ res.end(html);
191
+ return;
192
+ }
193
+ }
194
+ next();
195
+ });
196
+ server.use(middleware);
197
+ console.log(`[sootsim] serving at ${prefix}/`);
198
+ return server;
199
+ }
200
+ };
201
+ return { ...config, server: serverConfig };
202
+ }
203
+ var metro_plugin_default = withSootsim;
204
+ function serveRuntimeFile(res, fullPath) {
205
+ const ext = import_path2.default.extname(fullPath);
206
+ res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
207
+ res.setHeader("cache-control", "max-age=31536000,immutable");
208
+ import_fs2.default.createReadStream(fullPath).pipe(res);
209
+ }
210
+ // Annotate the CommonJS export names for ESM import in node:
211
+ 0 && (module.exports = {
212
+ isRootRuntimeAssetPath,
213
+ resolveRuntimeFilePath,
214
+ withSootsim
215
+ });
@@ -0,0 +1,54 @@
1
+ /*! sootsim v0.0.2 | (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/render-mode.ts
23
+ var render_mode_exports = {};
24
+ __export(render_mode_exports, {
25
+ getRenderMode: () => getRenderMode,
26
+ hasRenderWorkerBootstrap: () => hasRenderWorkerBootstrap,
27
+ isRenderMainMode: () => isRenderMainMode,
28
+ isRenderWorkerMode: () => isRenderWorkerMode,
29
+ shouldEnableRenderWorker: () => shouldEnableRenderWorker
30
+ });
31
+ module.exports = __toCommonJS(render_mode_exports);
32
+ function getRenderMode(_searchParams) {
33
+ return "worker";
34
+ }
35
+ function isRenderWorkerMode(_searchParams) {
36
+ return true;
37
+ }
38
+ function isRenderMainMode(_searchParams) {
39
+ return false;
40
+ }
41
+ function hasRenderWorkerBootstrap(workerModuleBaseUrl) {
42
+ return typeof workerModuleBaseUrl === "string" && workerModuleBaseUrl.length > 0;
43
+ }
44
+ function shouldEnableRenderWorker(_searchParams, workerModuleBaseUrl) {
45
+ return hasRenderWorkerBootstrap(workerModuleBaseUrl);
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ getRenderMode,
50
+ hasRenderWorkerBootstrap,
51
+ isRenderMainMode,
52
+ isRenderWorkerMode,
53
+ shouldEnableRenderWorker
54
+ });