sootsim 0.1.36 → 0.1.37
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/README.md +20 -5
- package/dist-cli/bin.js +15 -20
- package/dist-cli/chunks/{agent-YZB6D3DR.js → agent-EQRQGSBL.js} +2 -2
- package/dist-cli/chunks/{agent-wrapper-VHCVS22I.js → agent-wrapper-AWKZ67GN.js} +10 -10
- package/dist-cli/chunks/{assert-AIVCKKLG.js → assert-ZVGELUZB.js} +2 -2
- package/dist-cli/chunks/auto-bootstrap-UEOLNAWJ.js +2 -0
- package/dist-cli/chunks/beta-4MD7WSI4.js +2 -0
- package/dist-cli/chunks/chunk-2ZPJHSIJ.js +11 -0
- package/dist-cli/chunks/{chunk-A5BRCXYE.js → chunk-4IO3D5XG.js} +1 -1
- package/dist-cli/chunks/chunk-4OHVCGMF.js +2 -0
- package/dist-cli/chunks/chunk-56BIMCDH.js +2 -0
- package/dist-cli/chunks/chunk-5FLDI6CV.js +66 -0
- package/dist-cli/chunks/{chunk-LHDWH7VS.js → chunk-B3RAGRK6.js} +1 -1
- package/dist-cli/chunks/{chunk-27P763IZ.js → chunk-BGAPLYMS.js} +2 -2
- package/dist-cli/chunks/chunk-CX3ZIPD3.js +3 -0
- package/dist-cli/chunks/{chunk-HWCKZXNJ.js → chunk-DSTV2VJT.js} +2 -2
- package/dist-cli/chunks/chunk-EDBFYOQB.js +2 -0
- package/dist-cli/chunks/chunk-ERLA3F77.js +1 -0
- package/dist-cli/chunks/chunk-FCQLQ7NA.js +117 -0
- package/dist-cli/chunks/chunk-H2HSOHXN.js +7 -0
- package/dist-cli/chunks/chunk-HYYMBXIX.js +2 -0
- package/dist-cli/chunks/chunk-JMGDVXAV.js +3 -0
- package/dist-cli/chunks/chunk-JMU5IGIU.js +1 -0
- package/dist-cli/chunks/chunk-KA5JJCWL.js +1 -0
- package/dist-cli/chunks/chunk-L4F4JRKJ.js +348 -0
- package/dist-cli/chunks/{chunk-G7XQD4KC.js → chunk-LDWXH43L.js} +2 -2
- package/dist-cli/chunks/chunk-PERKPZ7T.js +4 -0
- package/dist-cli/chunks/chunk-PN6FWLD4.js +5 -0
- package/dist-cli/chunks/chunk-QD7YIVPS.js +64 -0
- package/dist-cli/chunks/chunk-QWKO62QM.js +2 -0
- package/dist-cli/chunks/{chunk-VFDRZNPN.js → chunk-QXMZNJV5.js} +1 -1
- package/dist-cli/chunks/chunk-R77F5J3X.js +4 -0
- package/dist-cli/chunks/chunk-RLNIKWFO.js +27 -0
- package/dist-cli/chunks/chunk-RX6RHGSI.js +2 -0
- package/dist-cli/chunks/{chunk-IJMYFYDZ.js → chunk-S74RCIVB.js} +2 -2
- package/dist-cli/chunks/chunk-SK4SOISL.js +1 -0
- package/dist-cli/chunks/{chunk-YIO6S3R5.js → chunk-T5L73GJB.js} +1 -1
- package/dist-cli/chunks/{chunk-KAXZHEKM.js → chunk-UIQ3536J.js} +1 -1
- package/dist-cli/chunks/chunk-URSEYCC5.js +16 -0
- package/dist-cli/chunks/chunk-WFXYY3DU.js +3 -0
- package/dist-cli/chunks/{chunk-EWSQSALM.js → chunk-WHLHA5R5.js} +4 -4
- package/dist-cli/chunks/chunk-WLIVBPPY.js +3 -0
- package/dist-cli/chunks/{chunk-CYCXOAVZ.js → chunk-X6BP5JFC.js} +4 -4
- package/dist-cli/chunks/chunk-YFXTO4QX.js +5 -0
- package/dist-cli/chunks/{chunk-RMW5BO3S.js → chunk-Z5SVSAZO.js} +2 -2
- package/dist-cli/chunks/{chunk-OXN2PEB7.js → chunk-Z5X3PITK.js} +3 -3
- package/dist-cli/chunks/chunk-ZBOIGEGO.js +5 -0
- package/dist-cli/chunks/chunk-ZERYEI3L.js +17 -0
- package/dist-cli/chunks/{compat-Y2O2U7FL.js → compat-QQ3OJDBI.js} +2 -2
- package/dist-cli/chunks/{config-SRBOFUCI.js → config-LT27SC25.js} +2 -2
- package/dist-cli/chunks/control-3BO54QMO.js +2 -0
- package/dist-cli/chunks/cpu-profile-XEO3JCVB.js +22 -0
- package/dist-cli/chunks/daemon-3J2SAVQZ.js +83 -0
- package/dist-cli/chunks/{debug-BIDMW2PE.js → debug-OGQLIH4U.js} +4 -4
- package/dist-cli/chunks/demo-app-registry-5RZCXLWB.js +2 -0
- package/dist-cli/chunks/detox-Z2OSCIQU.js +49 -0
- package/dist-cli/chunks/device-RPTVD25S.js +16 -0
- package/dist-cli/chunks/diagnose-LAEXBNOQ.js +41 -0
- package/dist-cli/chunks/drivers-PSQUUAYC.js +2 -0
- package/dist-cli/chunks/electron-S2463O3P.js +18 -0
- package/dist-cli/chunks/flow-34YCVQDB.js +2 -0
- package/dist-cli/chunks/hints-E5PXPWFT.js +2 -0
- package/dist-cli/chunks/home-paths-F5SGBTRZ.js +2 -0
- package/dist-cli/chunks/inspect-EVGMEZ3G.js +1101 -0
- package/dist-cli/chunks/install-AM5PTJT3.js +2 -0
- package/dist-cli/chunks/{install-desktop-2MYEI4FM.js → install-desktop-ZNWYKTWQ.js} +3 -3
- package/dist-cli/chunks/{keys-7PNASIQR.js → keys-5ETF6DYO.js} +2 -2
- package/dist-cli/chunks/{launch-JNS47LAQ.js → launch-DHUCNFX6.js} +3 -3
- package/dist-cli/chunks/{login-YWZWUHBS.js → login-KDR34JIP.js} +4 -4
- package/dist-cli/chunks/{logout-O6SXMSBP.js → logout-R6WIJYCW.js} +2 -2
- package/dist-cli/chunks/maestro-ZOOJ2YVH.js +80 -0
- package/dist-cli/chunks/{preview-WGKJO5FS.js → preview-YFADHNBD.js} +2 -2
- package/dist-cli/chunks/profile-CQSC32HB.js +22 -0
- package/dist-cli/chunks/react-QSQD6CJE.js +30 -0
- package/dist-cli/chunks/{record-QPWLYH5R.js → record-IWLEYATN.js} +5 -5
- package/dist-cli/chunks/{runtime-KEMO2MSB.js → runtime-WKMNKYTN.js} +3 -3
- package/dist-cli/chunks/screenshot-VJXHV57I.js +28 -0
- package/dist-cli/chunks/screenshot-mode-FA4VQ76K.js +17 -0
- package/dist-cli/chunks/screenshots-U4FQXHVK.js +70 -0
- package/dist-cli/chunks/server-7WZLM5NQ.js +35 -0
- package/dist-cli/chunks/setup-repo-3BXLAX5E.js +2 -0
- package/dist-cli/chunks/{skills-MO7BFNVM.js → skills-KO7RCY24.js} +2 -2
- package/dist-cli/chunks/start-EBD7T2GW.js +23 -0
- package/dist-cli/chunks/store-ONX3EBS4.js +2 -0
- package/dist-cli/chunks/telemetry-MFR7TUW7.js +2 -0
- package/dist-cli/chunks/{test-XUI3KNNQ.js → test-OSVUG54G.js} +3 -3
- package/dist-cli/chunks/three-mode-MDBXZQG4.js +39 -0
- package/dist-cli/chunks/timeline-UJOKZKQR.js +22 -0
- package/dist-cli/chunks/upload-H2SMWP6T.js +2 -0
- package/dist-cli/chunks/what-happened-LFWH74FR.js +15 -0
- package/dist-cli/chunks/whoami-CUF56TLP.js +2 -0
- package/dist-lib/agent-daemon-client.cjs +4 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +41 -39
- package/dist-lib/attached-projects.cjs +30 -28
- package/dist-lib/auth/shared-session.cjs +35 -27
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/config.cjs +6 -2
- package/dist-lib/dev-bundle-resolution.cjs +5 -21
- package/dist-lib/home-paths.cjs +94 -38
- package/dist-lib/host/bridge-host.cjs +2131 -1333
- package/dist-lib/host/fetch-proxy-handler.cjs +248 -0
- package/dist-lib/index.cjs +21 -21
- package/dist-lib/metro.cjs +21 -21
- package/dist-lib/profiles.cjs +246 -0
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/vite-base.cjs +3402 -1640
- package/dist-lib/vite.cjs +1 -1
- package/package.json +7 -1
- package/dist-cli/chunks/auto-bootstrap-MLNTX23H.js +0 -2
- package/dist-cli/chunks/chunk-3UIWOHC2.js +0 -62
- package/dist-cli/chunks/chunk-5KGFHWVR.js +0 -1
- package/dist-cli/chunks/chunk-5QIUJNT3.js +0 -5
- package/dist-cli/chunks/chunk-6GGMKFWJ.js +0 -4
- package/dist-cli/chunks/chunk-6Z275LCY.js +0 -2
- package/dist-cli/chunks/chunk-75LBYBKW.js +0 -11
- package/dist-cli/chunks/chunk-DFN3GGH7.js +0 -5
- package/dist-cli/chunks/chunk-EBEHZJRG.js +0 -117
- package/dist-cli/chunks/chunk-EJLNUMMP.js +0 -3
- package/dist-cli/chunks/chunk-FE7UI3MT.js +0 -4
- package/dist-cli/chunks/chunk-G663654J.js +0 -1
- package/dist-cli/chunks/chunk-GW7XY5KC.js +0 -2
- package/dist-cli/chunks/chunk-H2QO4TDV.js +0 -22
- package/dist-cli/chunks/chunk-HWFHBMAQ.js +0 -27
- package/dist-cli/chunks/chunk-J7CTD37P.js +0 -1
- package/dist-cli/chunks/chunk-N32NCVL2.js +0 -3
- package/dist-cli/chunks/chunk-NIZBR7EK.js +0 -2
- package/dist-cli/chunks/chunk-NYY36OKU.js +0 -308
- package/dist-cli/chunks/chunk-PJL25JQV.js +0 -5
- package/dist-cli/chunks/chunk-SHO54NET.js +0 -2
- package/dist-cli/chunks/chunk-SMVJOWSV.js +0 -16
- package/dist-cli/chunks/chunk-TC6V7YFC.js +0 -3
- package/dist-cli/chunks/chunk-YLIIVTTQ.js +0 -3
- package/dist-cli/chunks/chunk-YR7BGGYE.js +0 -2
- package/dist-cli/chunks/chunk-ZEW3RF5Q.js +0 -1
- package/dist-cli/chunks/control-PL2V2O6S.js +0 -2
- package/dist-cli/chunks/daemon-IZC32PZW.js +0 -50
- package/dist-cli/chunks/demo-app-registry-5JFOUU3D.js +0 -2
- package/dist-cli/chunks/detox-B3FDOIS3.js +0 -49
- package/dist-cli/chunks/device-ZZSI363W.js +0 -16
- package/dist-cli/chunks/drivers-S4NGK4DB.js +0 -2
- package/dist-cli/chunks/electron-5YFHXEOI.js +0 -15
- package/dist-cli/chunks/flow-JJBO6TFY.js +0 -2
- package/dist-cli/chunks/hints-G5HBBV2O.js +0 -2
- package/dist-cli/chunks/home-paths-VWC3FWA3.js +0 -2
- package/dist-cli/chunks/inspect-POOPWUQI.js +0 -1034
- package/dist-cli/chunks/install-MP6FHXNZ.js +0 -2
- package/dist-cli/chunks/install-dev-desktop-SKH3KEHY.js +0 -100
- package/dist-cli/chunks/maestro-CW6XVUKV.js +0 -75
- package/dist-cli/chunks/profile-SUOBRPIC.js +0 -22
- package/dist-cli/chunks/screenshot-JTY46V7G.js +0 -26
- package/dist-cli/chunks/screenshot-mode-7OYBBX6D.js +0 -17
- package/dist-cli/chunks/screenshots-QISKC4GD.js +0 -70
- package/dist-cli/chunks/server-YSFJAKAV.js +0 -34
- package/dist-cli/chunks/setup-repo-LFB3HBEO.js +0 -2
- package/dist-cli/chunks/store-6MFL53I4.js +0 -2
- package/dist-cli/chunks/telemetry-CN42GMVC.js +0 -2
- package/dist-cli/chunks/upload-6FUT7AX5.js +0 -2
- package/dist-cli/chunks/whoami-TQFHY42N.js +0 -2
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
/*! sootsim v0.1.37 | (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/host/fetch-proxy-handler.ts
|
|
33
|
+
var fetch_proxy_handler_exports = {};
|
|
34
|
+
__export(fetch_proxy_handler_exports, {
|
|
35
|
+
buildFetchProxyHeaders: () => buildFetchProxyHeaders,
|
|
36
|
+
handleAppApiRequest: () => handleAppApiRequest,
|
|
37
|
+
handleFetchProxyRequest: () => handleFetchProxyRequest,
|
|
38
|
+
isAppApiRequestUrl: () => isAppApiRequestUrl,
|
|
39
|
+
isFetchProxyRequestUrl: () => isFetchProxyRequestUrl
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(fetch_proxy_handler_exports);
|
|
42
|
+
var import_http = __toESM(require("http"), 1);
|
|
43
|
+
var import_https = __toESM(require("https"), 1);
|
|
44
|
+
var FETCH_PROXY_USER_AGENT = "sootsim";
|
|
45
|
+
var STRIP_FETCH_PROXY_HEADERS = /* @__PURE__ */ new Set([
|
|
46
|
+
"host",
|
|
47
|
+
"origin",
|
|
48
|
+
"referer",
|
|
49
|
+
"user-agent",
|
|
50
|
+
"cookie",
|
|
51
|
+
"connection",
|
|
52
|
+
"keep-alive",
|
|
53
|
+
"transfer-encoding",
|
|
54
|
+
"upgrade",
|
|
55
|
+
"content-length",
|
|
56
|
+
"sec-fetch-site",
|
|
57
|
+
"sec-fetch-mode",
|
|
58
|
+
"sec-fetch-dest",
|
|
59
|
+
"sec-ch-ua",
|
|
60
|
+
"sec-ch-ua-mobile",
|
|
61
|
+
"sec-ch-ua-platform"
|
|
62
|
+
]);
|
|
63
|
+
var FETCH_PROXY_CORS_HEADERS = {
|
|
64
|
+
"access-control-allow-origin": "*",
|
|
65
|
+
"access-control-allow-methods": "GET,POST,PUT,DELETE,PATCH,OPTIONS",
|
|
66
|
+
"access-control-allow-headers": "*",
|
|
67
|
+
"access-control-expose-headers": "*",
|
|
68
|
+
"access-control-max-age": "3600"
|
|
69
|
+
};
|
|
70
|
+
function applyFetchProxyCors(res) {
|
|
71
|
+
for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
|
|
72
|
+
res.setHeader(key, value);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function formatFetchProxyError(targetUrl, err) {
|
|
76
|
+
const details = [];
|
|
77
|
+
const error = err;
|
|
78
|
+
if (error?.code) details.push(error.code);
|
|
79
|
+
if (error?.message) details.push(error.message);
|
|
80
|
+
if (error?.cause?.code) details.push(error.cause.code);
|
|
81
|
+
if (error?.cause?.message) details.push(error.cause.message);
|
|
82
|
+
const uniqueDetails = [...new Set(details.filter(Boolean))];
|
|
83
|
+
const message = uniqueDetails.join(" | ") || String(err);
|
|
84
|
+
if (targetUrl.includes("stored-in-.env.local")) {
|
|
85
|
+
return `${message} | upstream url still contains placeholder env values`;
|
|
86
|
+
}
|
|
87
|
+
return message;
|
|
88
|
+
}
|
|
89
|
+
function buildFetchProxyHeaders(reqHeaders) {
|
|
90
|
+
const headers = {};
|
|
91
|
+
for (const [key, value] of Object.entries(reqHeaders)) {
|
|
92
|
+
if (!value) continue;
|
|
93
|
+
if (STRIP_FETCH_PROXY_HEADERS.has(key.toLowerCase())) continue;
|
|
94
|
+
headers[key] = Array.isArray(value) ? value.join(", ") : value;
|
|
95
|
+
}
|
|
96
|
+
headers["user-agent"] = FETCH_PROXY_USER_AGENT;
|
|
97
|
+
return headers;
|
|
98
|
+
}
|
|
99
|
+
function isFetchProxyRequestUrl(rawUrl) {
|
|
100
|
+
return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
|
|
101
|
+
}
|
|
102
|
+
function isAppApiRequestUrl(rawUrl) {
|
|
103
|
+
if (!rawUrl) return false;
|
|
104
|
+
if (rawUrl.startsWith("/__app-api?")) return true;
|
|
105
|
+
if (rawUrl.startsWith("/__app-api/")) return true;
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
async function handleFetchProxyRequest(req, res) {
|
|
109
|
+
if (req.method === "OPTIONS") {
|
|
110
|
+
applyFetchProxyCors(res);
|
|
111
|
+
res.writeHead(204);
|
|
112
|
+
res.end();
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const params = new URLSearchParams((req.url || "").split("?")[1] || "");
|
|
116
|
+
const targetUrl = params.get("url");
|
|
117
|
+
if (!targetUrl) {
|
|
118
|
+
applyFetchProxyCors(res);
|
|
119
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
120
|
+
res.end("missing url param");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
let upstreamUrl;
|
|
124
|
+
try {
|
|
125
|
+
upstreamUrl = new URL(targetUrl);
|
|
126
|
+
} catch {
|
|
127
|
+
applyFetchProxyCors(res);
|
|
128
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
129
|
+
res.end("invalid url param");
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const headers = buildFetchProxyHeaders(req.headers);
|
|
133
|
+
let body;
|
|
134
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
135
|
+
const chunks = [];
|
|
136
|
+
for await (const chunk of req) {
|
|
137
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
138
|
+
}
|
|
139
|
+
if (chunks.length > 0) body = Buffer.concat(chunks);
|
|
140
|
+
}
|
|
141
|
+
let upstream;
|
|
142
|
+
try {
|
|
143
|
+
upstream = await fetch(upstreamUrl.href, {
|
|
144
|
+
method: req.method,
|
|
145
|
+
headers,
|
|
146
|
+
body,
|
|
147
|
+
redirect: "follow"
|
|
148
|
+
});
|
|
149
|
+
} catch (err) {
|
|
150
|
+
applyFetchProxyCors(res);
|
|
151
|
+
res.writeHead(502, { "Content-Type": "text/plain" });
|
|
152
|
+
res.end(`fetch proxy error: ${formatFetchProxyError(upstreamUrl.href, err)}`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
upstream.headers.forEach((value, key) => {
|
|
156
|
+
const lowerKey = key.toLowerCase();
|
|
157
|
+
if (lowerKey === "content-encoding" || lowerKey === "transfer-encoding" || lowerKey === "content-length" || lowerKey === "set-cookie" || lowerKey.startsWith("access-control-")) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
res.setHeader(key, value);
|
|
161
|
+
});
|
|
162
|
+
applyFetchProxyCors(res);
|
|
163
|
+
const setCookie = upstream.headers.getSetCookie?.() ?? [];
|
|
164
|
+
if (setCookie.length > 0) {
|
|
165
|
+
res.setHeader("x-sootsim-set-cookie", setCookie.join(", "));
|
|
166
|
+
}
|
|
167
|
+
res.statusCode = upstream.status;
|
|
168
|
+
const buf = Buffer.from(await upstream.arrayBuffer());
|
|
169
|
+
res.end(buf);
|
|
170
|
+
}
|
|
171
|
+
function handleAppApiRequest(req, res) {
|
|
172
|
+
const reqUrl = req.url || "";
|
|
173
|
+
let targetPath = "";
|
|
174
|
+
let targetOrigin = "";
|
|
175
|
+
if (reqUrl.startsWith("/__app-api?")) {
|
|
176
|
+
const parsed = new URL(reqUrl, "http://sootsim.local");
|
|
177
|
+
targetPath = parsed.searchParams.get("path") || "";
|
|
178
|
+
targetOrigin = parsed.searchParams.get("origin")?.trim() || "";
|
|
179
|
+
} else if (reqUrl.startsWith("/__app-api/")) {
|
|
180
|
+
targetPath = reqUrl.slice("/__app-api".length);
|
|
181
|
+
} else {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
if (!targetOrigin) {
|
|
185
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
186
|
+
res.end("app-api: missing origin query param");
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
if (req.method === "OPTIONS") {
|
|
190
|
+
res.writeHead(204, {
|
|
191
|
+
"Access-Control-Allow-Origin": req.headers.origin || "*",
|
|
192
|
+
"Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS",
|
|
193
|
+
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || "*",
|
|
194
|
+
"Access-Control-Allow-Credentials": "true",
|
|
195
|
+
"Access-Control-Max-Age": "86400"
|
|
196
|
+
});
|
|
197
|
+
res.end();
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
let targetUrl;
|
|
201
|
+
try {
|
|
202
|
+
targetUrl = new URL(targetPath, targetOrigin);
|
|
203
|
+
} catch {
|
|
204
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
205
|
+
res.end("app-api: invalid origin or path");
|
|
206
|
+
return true;
|
|
207
|
+
}
|
|
208
|
+
const transport = targetUrl.protocol === "https:" ? import_https.default : import_http.default;
|
|
209
|
+
const fwdHeaders = { ...req.headers };
|
|
210
|
+
delete fwdHeaders.host;
|
|
211
|
+
fwdHeaders.host = targetUrl.host;
|
|
212
|
+
const proxyReq = transport.request(
|
|
213
|
+
{
|
|
214
|
+
hostname: targetUrl.hostname,
|
|
215
|
+
port: targetUrl.port || (targetUrl.protocol === "https:" ? 443 : 80),
|
|
216
|
+
path: targetUrl.pathname + targetUrl.search,
|
|
217
|
+
method: req.method,
|
|
218
|
+
headers: fwdHeaders
|
|
219
|
+
},
|
|
220
|
+
(proxyRes) => {
|
|
221
|
+
const exposedHeaders = Object.keys(proxyRes.headers).filter((name) => {
|
|
222
|
+
const lower = name.toLowerCase();
|
|
223
|
+
return !lower.startsWith("access-control-") && lower !== "set-cookie";
|
|
224
|
+
}).join(", ");
|
|
225
|
+
res.writeHead(proxyRes.statusCode ?? 502, {
|
|
226
|
+
...proxyRes.headers,
|
|
227
|
+
"access-control-allow-origin": req.headers.origin || "*",
|
|
228
|
+
"access-control-allow-credentials": "true",
|
|
229
|
+
"access-control-expose-headers": exposedHeaders
|
|
230
|
+
});
|
|
231
|
+
proxyRes.pipe(res);
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
proxyReq.on("error", (err) => {
|
|
235
|
+
res.statusCode = 502;
|
|
236
|
+
res.end(`app proxy error: ${err.message}`);
|
|
237
|
+
});
|
|
238
|
+
req.pipe(proxyReq);
|
|
239
|
+
return true;
|
|
240
|
+
}
|
|
241
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
242
|
+
0 && (module.exports = {
|
|
243
|
+
buildFetchProxyHeaders,
|
|
244
|
+
handleAppApiRequest,
|
|
245
|
+
handleFetchProxyRequest,
|
|
246
|
+
isAppApiRequestUrl,
|
|
247
|
+
isFetchProxyRequestUrl
|
|
248
|
+
});
|
package/dist-lib/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.37 | (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;
|
|
@@ -177,32 +177,32 @@ async function openElectronApp(sootsimUrl) {
|
|
|
177
177
|
}
|
|
178
178
|
|
|
179
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
180
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
185
|
-
var import_os = require("os");
|
|
186
181
|
var import_path2 = __toESM(require("path"), 1);
|
|
182
|
+
|
|
183
|
+
// src/home-paths.ts
|
|
184
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
185
|
+
var import_node_os = require("node:os");
|
|
186
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
187
187
|
var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
|
|
188
188
|
var ACTIVE_RUNTIME_FILE = "active";
|
|
189
189
|
function sootsimHomeDir() {
|
|
190
190
|
const override = process.env[SOOTSIM_HOME_ENV];
|
|
191
|
-
if (override && override.length > 0) return
|
|
192
|
-
return
|
|
191
|
+
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
192
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".sootsim");
|
|
193
193
|
}
|
|
194
194
|
function runtimesDir() {
|
|
195
|
-
return
|
|
195
|
+
return import_node_path.default.join(sootsimHomeDir(), "runtimes");
|
|
196
196
|
}
|
|
197
197
|
function runtimeDir(version) {
|
|
198
|
-
return
|
|
198
|
+
return import_node_path.default.join(runtimesDir(), version);
|
|
199
199
|
}
|
|
200
200
|
function activeRuntimeFile() {
|
|
201
|
-
return
|
|
201
|
+
return import_node_path.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
202
202
|
}
|
|
203
203
|
function readActiveRuntime() {
|
|
204
204
|
try {
|
|
205
|
-
const value =
|
|
205
|
+
const value = import_node_fs.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
206
206
|
return value.length > 0 ? value : null;
|
|
207
207
|
} catch {
|
|
208
208
|
return null;
|
|
@@ -216,7 +216,7 @@ function resolveRuntimeRoot() {
|
|
|
216
216
|
const active = readActiveRuntime();
|
|
217
217
|
if (!active) return null;
|
|
218
218
|
const dir = runtimeDir(active);
|
|
219
|
-
if (!
|
|
219
|
+
if (!import_fs2.default.existsSync(import_path2.default.join(dir, "index.html"))) return null;
|
|
220
220
|
return dir;
|
|
221
221
|
}
|
|
222
222
|
var RUNTIME_MISSING_MESSAGE = "[sootsim] no engine runtime installed \u2014 run `sootsim setup-repo` in your project, or `sootsim runtime install`";
|
|
@@ -260,10 +260,10 @@ function resolveRuntimeFilePath(runtimeRoot, pathname) {
|
|
|
260
260
|
for (const segment of pathname.split("/")) {
|
|
261
261
|
if (segment === "..") return null;
|
|
262
262
|
}
|
|
263
|
-
const fullPath =
|
|
264
|
-
const rootWithSep = runtimeRoot.endsWith(
|
|
263
|
+
const fullPath = import_path2.default.resolve(runtimeRoot, pathname.replace(/^\/+/, ""));
|
|
264
|
+
const rootWithSep = runtimeRoot.endsWith(import_path2.default.sep) ? runtimeRoot : runtimeRoot + import_path2.default.sep;
|
|
265
265
|
if (!fullPath.startsWith(rootWithSep) && fullPath !== runtimeRoot) return null;
|
|
266
|
-
if (!
|
|
266
|
+
if (!import_fs2.default.existsSync(fullPath) || !import_fs2.default.statSync(fullPath).isFile()) return null;
|
|
267
267
|
return fullPath;
|
|
268
268
|
}
|
|
269
269
|
function withSootsim(config, options = {}) {
|
|
@@ -317,10 +317,10 @@ function withSootsim(config, options = {}) {
|
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
319
|
if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
|
|
320
|
-
const ext =
|
|
320
|
+
const ext = import_path2.default.extname(pathname);
|
|
321
321
|
if (!ext) {
|
|
322
|
-
const htmlPath =
|
|
323
|
-
let html =
|
|
322
|
+
const htmlPath = import_path2.default.join(runtimeRoot, "index.html");
|
|
323
|
+
let html = import_fs2.default.readFileSync(htmlPath, "utf8");
|
|
324
324
|
html = html.replace(
|
|
325
325
|
"</head>",
|
|
326
326
|
`<script>history.replaceState(null,'','${prefix}/?bundle=${encodeURIComponent(bundleUrl)}')</script></head>`
|
|
@@ -341,10 +341,10 @@ function withSootsim(config, options = {}) {
|
|
|
341
341
|
}
|
|
342
342
|
var metro_plugin_default = withSootsim;
|
|
343
343
|
function serveRuntimeFile(res, fullPath) {
|
|
344
|
-
const ext =
|
|
344
|
+
const ext = import_path2.default.extname(fullPath);
|
|
345
345
|
res.setHeader("content-type", MIME_TYPES2[ext] || "application/octet-stream");
|
|
346
346
|
res.setHeader("cache-control", "max-age=31536000,immutable");
|
|
347
|
-
|
|
347
|
+
import_fs2.default.createReadStream(fullPath).pipe(res);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
// src/bridge-constants.ts
|
package/dist-lib/metro.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! sootsim v0.1.
|
|
1
|
+
/*! sootsim v0.1.37 | (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;
|
|
@@ -38,32 +38,32 @@ __export(metro_plugin_exports, {
|
|
|
38
38
|
withSootsim: () => withSootsim
|
|
39
39
|
});
|
|
40
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
41
|
var import_fs = __toESM(require("fs"), 1);
|
|
46
|
-
var import_os = require("os");
|
|
47
42
|
var import_path = __toESM(require("path"), 1);
|
|
43
|
+
|
|
44
|
+
// src/home-paths.ts
|
|
45
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
46
|
+
var import_node_os = require("node:os");
|
|
47
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
48
48
|
var SOOTSIM_HOME_ENV = "SOOTSIM_HOME";
|
|
49
49
|
var ACTIVE_RUNTIME_FILE = "active";
|
|
50
50
|
function sootsimHomeDir() {
|
|
51
51
|
const override = process.env[SOOTSIM_HOME_ENV];
|
|
52
|
-
if (override && override.length > 0) return
|
|
53
|
-
return
|
|
52
|
+
if (override && override.length > 0) return import_node_path.default.resolve(override);
|
|
53
|
+
return import_node_path.default.join((0, import_node_os.homedir)(), ".sootsim");
|
|
54
54
|
}
|
|
55
55
|
function runtimesDir() {
|
|
56
|
-
return
|
|
56
|
+
return import_node_path.default.join(sootsimHomeDir(), "runtimes");
|
|
57
57
|
}
|
|
58
58
|
function runtimeDir(version) {
|
|
59
|
-
return
|
|
59
|
+
return import_node_path.default.join(runtimesDir(), version);
|
|
60
60
|
}
|
|
61
61
|
function activeRuntimeFile() {
|
|
62
|
-
return
|
|
62
|
+
return import_node_path.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
63
63
|
}
|
|
64
64
|
function readActiveRuntime() {
|
|
65
65
|
try {
|
|
66
|
-
const value =
|
|
66
|
+
const value = import_node_fs.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
67
67
|
return value.length > 0 ? value : null;
|
|
68
68
|
} catch {
|
|
69
69
|
return null;
|
|
@@ -77,7 +77,7 @@ function resolveRuntimeRoot() {
|
|
|
77
77
|
const active = readActiveRuntime();
|
|
78
78
|
if (!active) return null;
|
|
79
79
|
const dir = runtimeDir(active);
|
|
80
|
-
if (!
|
|
80
|
+
if (!import_fs.default.existsSync(import_path.default.join(dir, "index.html"))) return null;
|
|
81
81
|
return dir;
|
|
82
82
|
}
|
|
83
83
|
var RUNTIME_MISSING_MESSAGE = "[sootsim] no engine runtime installed \u2014 run `sootsim setup-repo` in your project, or `sootsim runtime install`";
|
|
@@ -121,10 +121,10 @@ function resolveRuntimeFilePath(runtimeRoot, pathname) {
|
|
|
121
121
|
for (const segment of pathname.split("/")) {
|
|
122
122
|
if (segment === "..") return null;
|
|
123
123
|
}
|
|
124
|
-
const fullPath =
|
|
125
|
-
const rootWithSep = runtimeRoot.endsWith(
|
|
124
|
+
const fullPath = import_path.default.resolve(runtimeRoot, pathname.replace(/^\/+/, ""));
|
|
125
|
+
const rootWithSep = runtimeRoot.endsWith(import_path.default.sep) ? runtimeRoot : runtimeRoot + import_path.default.sep;
|
|
126
126
|
if (!fullPath.startsWith(rootWithSep) && fullPath !== runtimeRoot) return null;
|
|
127
|
-
if (!
|
|
127
|
+
if (!import_fs.default.existsSync(fullPath) || !import_fs.default.statSync(fullPath).isFile()) return null;
|
|
128
128
|
return fullPath;
|
|
129
129
|
}
|
|
130
130
|
function withSootsim(config, options = {}) {
|
|
@@ -178,10 +178,10 @@ function withSootsim(config, options = {}) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
|
|
181
|
-
const ext =
|
|
181
|
+
const ext = import_path.default.extname(pathname);
|
|
182
182
|
if (!ext) {
|
|
183
|
-
const htmlPath =
|
|
184
|
-
let html =
|
|
183
|
+
const htmlPath = import_path.default.join(runtimeRoot, "index.html");
|
|
184
|
+
let html = import_fs.default.readFileSync(htmlPath, "utf8");
|
|
185
185
|
html = html.replace(
|
|
186
186
|
"</head>",
|
|
187
187
|
`<script>history.replaceState(null,'','${prefix}/?bundle=${encodeURIComponent(bundleUrl)}')</script></head>`
|
|
@@ -202,10 +202,10 @@ function withSootsim(config, options = {}) {
|
|
|
202
202
|
}
|
|
203
203
|
var metro_plugin_default = withSootsim;
|
|
204
204
|
function serveRuntimeFile(res, fullPath) {
|
|
205
|
-
const ext =
|
|
205
|
+
const ext = import_path.default.extname(fullPath);
|
|
206
206
|
res.setHeader("content-type", MIME_TYPES[ext] || "application/octet-stream");
|
|
207
207
|
res.setHeader("cache-control", "max-age=31536000,immutable");
|
|
208
|
-
|
|
208
|
+
import_fs.default.createReadStream(fullPath).pipe(res);
|
|
209
209
|
}
|
|
210
210
|
// Annotate the CommonJS export names for ESM import in node:
|
|
211
211
|
0 && (module.exports = {
|