@kodycodes/cli 3.39.0 → 3.41.0
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/dist/bin.js +3 -3
- package/dist/chunk-3IYBIEX6.js +225 -0
- package/dist/chunk-3IYBIEX6.js.map +6 -0
- package/dist/{chunk-OFTFT75V.js → chunk-42C77QLO.js} +93 -11
- package/dist/chunk-42C77QLO.js.map +6 -0
- package/dist/{chunk-TJ4YVG6B.js → chunk-CSXFRVBI.js} +8 -3
- package/dist/{chunk-TJ4YVG6B.js.map → chunk-CSXFRVBI.js.map} +1 -1
- package/dist/{chunk-5ZPZVTTT.js → chunk-MILGY6PM.js} +2 -2
- package/dist/{chunk-WWW5PWGZ.js → chunk-RUPUC727.js} +20 -19
- package/dist/{chunk-WWW5PWGZ.js.map → chunk-RUPUC727.js.map} +1 -1
- package/dist/cli.js +3 -3
- package/dist/{commands-5UYB25R5.js → commands-OF7JI46V.js} +21 -13
- package/dist/commands-OF7JI46V.js.map +6 -0
- package/dist/dev/dev-app-origin.d.ts +20 -0
- package/dist/dev/dev-host.d.ts +6 -3
- package/dist/dev/dev-port.d.ts +10 -1
- package/dist/dev/local-kody.d.ts +5 -2
- package/dist/{dev-command-ILYM5NXU.js → dev-command-2HKWG2GT.js} +147 -88
- package/dist/dev-command-2HKWG2GT.js.map +6 -0
- package/dist/dev-command.d.ts +4 -2
- package/dist/{dev-host-2KU7SLFK.js → dev-host-XDOJBJC5.js} +2 -2
- package/dist/execution-context/fs-access.d.ts +15 -1
- package/dist/execution-context/machine-capabilities.d.ts +8 -2
- package/dist/{local-execute-GES63R7D.js → local-execute-BCGZKZXG.js} +39 -3
- package/dist/local-execute-BCGZKZXG.js.map +6 -0
- package/dist/local-execute.d.ts +1 -1
- package/dist/{local-kody-NDNDB5MV.js → local-kody-RYKBNHAP.js} +52 -10
- package/dist/local-kody-RYKBNHAP.js.map +6 -0
- package/dist/package-app-dev.d.ts +13 -6
- package/dist/publish-builder.js +311 -30
- package/dist/{run-executor-2W5STQV3.js → run-executor-INDLQONB.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-IEGR76KD.js +0 -116
- package/dist/chunk-IEGR76KD.js.map +0 -6
- package/dist/chunk-OFTFT75V.js.map +0 -6
- package/dist/commands-5UYB25R5.js.map +0 -6
- package/dist/dev-command-ILYM5NXU.js.map +0 -6
- package/dist/local-execute-GES63R7D.js.map +0 -6
- package/dist/local-kody-NDNDB5MV.js.map +0 -6
- /package/dist/{chunk-5ZPZVTTT.js.map → chunk-MILGY6PM.js.map} +0 -0
- /package/dist/{dev-host-2KU7SLFK.js.map → dev-host-XDOJBJC5.js.map} +0 -0
- /package/dist/{run-executor-2W5STQV3.js.map → run-executor-INDLQONB.js.map} +0 -0
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createRequire as __createRequire } from 'node:module'; const require = __createRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
buildPackageAppOpenPath,
|
|
4
|
+
collectPackageCheckFiles,
|
|
5
|
+
localUsernameFor,
|
|
6
|
+
packageAppHostEntryQueryParam
|
|
7
|
+
} from "./chunk-3IYBIEX6.js";
|
|
5
8
|
import {
|
|
6
9
|
npmInstallEnv,
|
|
7
10
|
resolveMockFetchGateway
|
|
@@ -25,7 +28,7 @@ import "./chunk-UW6AWLXX.js";
|
|
|
25
28
|
import { spawn } from "node:child_process";
|
|
26
29
|
import { createHash } from "node:crypto";
|
|
27
30
|
import { createWriteStream, existsSync } from "node:fs";
|
|
28
|
-
import { createServer } from "node:http";
|
|
31
|
+
import { createServer, request as httpRequest } from "node:http";
|
|
29
32
|
import { mkdir, mkdtemp, rename, rm, writeFile } from "node:fs/promises";
|
|
30
33
|
import { dirname, join, resolve } from "node:path";
|
|
31
34
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -141,10 +144,6 @@ async function npmInstall(stagingDir, version, env) {
|
|
|
141
144
|
});
|
|
142
145
|
});
|
|
143
146
|
}
|
|
144
|
-
function localUsernameFor(manifest) {
|
|
145
|
-
const scope = /^@([a-z0-9][a-z0-9-]*)\//i.exec(manifest.name)?.[1];
|
|
146
|
-
return (scope ?? "dev").toLowerCase();
|
|
147
|
-
}
|
|
148
147
|
async function startLocalKody(input) {
|
|
149
148
|
const entry = await ensureDevRuntime({
|
|
150
149
|
env: input.env,
|
|
@@ -174,6 +173,7 @@ async function startLocalKody(input) {
|
|
|
174
173
|
const kody = await runtime.startDevRuntime({
|
|
175
174
|
stateDir,
|
|
176
175
|
username: localUsernameFor(input.manifest),
|
|
176
|
+
packageAppPort: input.packageAppPort,
|
|
177
177
|
...input.simulation ? { simulation: input.simulation } : {},
|
|
178
178
|
...outbound ? { outboundUrl: outbound.url } : {},
|
|
179
179
|
onLog: (line) => log.write(`[${line.source}] ${line.line}
|
|
@@ -223,6 +223,22 @@ async function startOutboundGateway(gateway) {
|
|
|
223
223
|
})
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
+
function readSetCookies(input) {
|
|
227
|
+
return new Promise((resolve2, reject) => {
|
|
228
|
+
const request = httpRequest(
|
|
229
|
+
new URL(input.path, input.origin),
|
|
230
|
+
{ headers: { host: input.host } },
|
|
231
|
+
(response) => {
|
|
232
|
+
response.resume();
|
|
233
|
+
resolve2(
|
|
234
|
+
(response.headers["set-cookie"] ?? []).map((cookie) => cookie.split(";")[0].trim()).filter((pair) => !pair.endsWith("="))
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
request.on("error", reject);
|
|
239
|
+
request.end();
|
|
240
|
+
});
|
|
241
|
+
}
|
|
226
242
|
function createLocalKodyUpstream(input) {
|
|
227
243
|
const fetchFn = input.fetchFn ?? fetch;
|
|
228
244
|
let packageId = null;
|
|
@@ -265,8 +281,34 @@ function createLocalKodyUpstream(input) {
|
|
|
265
281
|
};
|
|
266
282
|
return {
|
|
267
283
|
origin: input.kody.origin,
|
|
268
|
-
|
|
269
|
-
|
|
284
|
+
username: input.kody.username,
|
|
285
|
+
appSessionCookie: async ({ rootMounted }) => {
|
|
286
|
+
const open = new URL(
|
|
287
|
+
buildPackageAppOpenPath({
|
|
288
|
+
username: input.kody.username,
|
|
289
|
+
kodyId: input.manifest.kodyId
|
|
290
|
+
}),
|
|
291
|
+
input.kody.origin
|
|
292
|
+
);
|
|
293
|
+
if (rootMounted) open.searchParams.set(packageAppHostEntryQueryParam, "1");
|
|
294
|
+
const handoff = await fetchFn(open, {
|
|
295
|
+
redirect: "manual",
|
|
296
|
+
headers: { cookie: input.kody.sessionCookie }
|
|
297
|
+
});
|
|
298
|
+
const location = handoff.headers.get("location");
|
|
299
|
+
const target = location ? new URL(location, open) : null;
|
|
300
|
+
const cookies = target ? await readSetCookies({
|
|
301
|
+
origin: input.kody.origin,
|
|
302
|
+
host: target.host,
|
|
303
|
+
path: `${target.pathname}${target.search}`
|
|
304
|
+
}) : [];
|
|
305
|
+
if (cookies.length === 0) {
|
|
306
|
+
throw new Error(
|
|
307
|
+
`Local Kody did not sign in to the app${target ? ` at ${target.origin}` : ""} (HTTP ${handoff.status}).`
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
return cookies.join("; ");
|
|
311
|
+
},
|
|
270
312
|
listOutbox: () => input.kody.listOutbox(),
|
|
271
313
|
packageId: () => packageId,
|
|
272
314
|
call,
|
|
@@ -341,4 +383,4 @@ export {
|
|
|
341
383
|
parseDevSimulation,
|
|
342
384
|
startLocalKody
|
|
343
385
|
};
|
|
344
|
-
//# sourceMappingURL=local-kody-
|
|
386
|
+
//# sourceMappingURL=local-kody-RYKBNHAP.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/dev/local-kody.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,SAAS,aAAa;AACtB,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB,kBA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,mBAAmB;AAAA,EAC3C;AACA,MAAI,MAAM,SAAS,KAAM,YAAW,eAAe;AACnD,MAAI,OAAO,MAAM,UAAU,YAAY,MAAM,MAAM,KAAK,MAAM,IAAI;AACjE,UAAM,MAAM,MAAM,MAAM,KAAK;AAC7B,UAAM,SAAS,aAAa,KAAK,GAAG,IACjC,OAAO,GAAG,IACV,KAAK,MAAM,GAAG,KAAK,MAAM,OAAO,KAAK,IAAI;AAC5C,QAAI,CAAC,OAAO,cAAc,MAAM,GAAG;AAClC,YAAM,IAAI,mBAAmB;AAAA,QAC5B,MAAM;AAAA,QACN,SAAS,uDAAuD,KAAK,UAAU,GAAG,CAAC;AAAA,QACnF,QAAQ;AAAA,MACT,CAAC;AAAA,IACF;AACA,QAAI,WAAW,EAAG,YAAW,gBAAgB;AAAA,EAC9C;AACA,SAAO,OAAO,KAAK,UAAU,EAAE,SAAS,IAAI,aAAa;AAC1D;",
|
|
5
|
+
"names": ["entry", "resolve"]
|
|
6
|
+
}
|
|
@@ -31,8 +31,9 @@ export type PackageAppDevOptions = {
|
|
|
31
31
|
*/
|
|
32
32
|
defaultPort?: number;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* the
|
|
34
|
+
* Old path shape: the app under this path on the owner's host instead of
|
|
35
|
+
* at the root of its own (default ''). With `localKody` the only such path
|
|
36
|
+
* is `/{kodyId}`; anything else is rejected.
|
|
36
37
|
*/
|
|
37
38
|
appBasePath?: string;
|
|
38
39
|
/** User-owned token org selection (`?org=`), same as execute --local. */
|
|
@@ -125,11 +126,17 @@ export type PackageAppDevServer = {
|
|
|
125
126
|
* app on its origin, instead of a per-build workerd with a stub runtime.
|
|
126
127
|
*/
|
|
127
128
|
export type LocalKodyUpstream = {
|
|
129
|
+
/** Where the local Kody workers listen. */
|
|
128
130
|
origin: string;
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
|
|
131
|
+
/** Handle of the local account that owns the saved copy. */
|
|
132
|
+
username: string;
|
|
133
|
+
/**
|
|
134
|
+
* `Cookie` header that signs the local account in to the app on its own
|
|
135
|
+
* host (`rootMounted`) or on the owner's host under `/{kodyId}`.
|
|
136
|
+
*/
|
|
137
|
+
appSessionCookie: (input: {
|
|
138
|
+
rootMounted: boolean;
|
|
139
|
+
}) => Promise<string>;
|
|
133
140
|
/** Save the working tree into the local Kody. */
|
|
134
141
|
sync: () => Promise<void>;
|
|
135
142
|
/** Email captured by the local email boundary instead of being sent. */
|
package/dist/publish-builder.js
CHANGED
|
@@ -26656,9 +26656,149 @@ var init_module_source = __esm({
|
|
|
26656
26656
|
});
|
|
26657
26657
|
|
|
26658
26658
|
// ../worker/src/package-runtime/module-scope-bindings.ts
|
|
26659
|
+
function nameOf(node2) {
|
|
26660
|
+
const typed = node2;
|
|
26661
|
+
return typed?.type === "Identifier" && typeof typed.name === "string" ? typed.name : null;
|
|
26662
|
+
}
|
|
26663
|
+
function patternIdentifiers(pattern, into) {
|
|
26664
|
+
const node2 = pattern;
|
|
26665
|
+
if (!node2) return;
|
|
26666
|
+
switch (node2.type) {
|
|
26667
|
+
case "Identifier":
|
|
26668
|
+
into.push(node2);
|
|
26669
|
+
return;
|
|
26670
|
+
case "AssignmentPattern":
|
|
26671
|
+
patternIdentifiers(node2.left, into);
|
|
26672
|
+
return;
|
|
26673
|
+
case "RestElement":
|
|
26674
|
+
patternIdentifiers(node2.argument, into);
|
|
26675
|
+
return;
|
|
26676
|
+
case "TSParameterProperty":
|
|
26677
|
+
patternIdentifiers(node2.parameter, into);
|
|
26678
|
+
return;
|
|
26679
|
+
case "ArrayPattern":
|
|
26680
|
+
for (const element of node2.elements) {
|
|
26681
|
+
patternIdentifiers(element, into);
|
|
26682
|
+
}
|
|
26683
|
+
return;
|
|
26684
|
+
case "ObjectPattern":
|
|
26685
|
+
for (const property of node2.properties) {
|
|
26686
|
+
patternIdentifiers(
|
|
26687
|
+
property.type === "RestElement" ? property : property.value,
|
|
26688
|
+
into
|
|
26689
|
+
);
|
|
26690
|
+
}
|
|
26691
|
+
return;
|
|
26692
|
+
default:
|
|
26693
|
+
return;
|
|
26694
|
+
}
|
|
26695
|
+
}
|
|
26696
|
+
function resolveModuleBindings(program) {
|
|
26697
|
+
const scopes = /* @__PURE__ */ new Map();
|
|
26698
|
+
const declare = (scope, pattern) => {
|
|
26699
|
+
const identifiers = [];
|
|
26700
|
+
patternIdentifiers(pattern, identifiers);
|
|
26701
|
+
for (const identifier of identifiers) {
|
|
26702
|
+
const name = nameOf(identifier);
|
|
26703
|
+
if (!scope.bindings.has(name)) scope.bindings.set(name, { name });
|
|
26704
|
+
}
|
|
26705
|
+
};
|
|
26706
|
+
const functionScopeOf = (scope) => {
|
|
26707
|
+
let current = scope;
|
|
26708
|
+
while (!current.isFunction && current.parent) current = current.parent;
|
|
26709
|
+
return current;
|
|
26710
|
+
};
|
|
26711
|
+
const newScope = (parent, isFunction) => ({
|
|
26712
|
+
bindings: /* @__PURE__ */ new Map(),
|
|
26713
|
+
parent,
|
|
26714
|
+
isFunction
|
|
26715
|
+
});
|
|
26716
|
+
const build2 = (input3, scope) => {
|
|
26717
|
+
if (!input3 || typeof input3 !== "object") return;
|
|
26718
|
+
if (Array.isArray(input3)) {
|
|
26719
|
+
for (const entry of input3) build2(entry, scope);
|
|
26720
|
+
return;
|
|
26721
|
+
}
|
|
26722
|
+
const node2 = input3;
|
|
26723
|
+
let inner = scope;
|
|
26724
|
+
if (typeof node2.type === "string") {
|
|
26725
|
+
if (functionTypes.has(node2.type)) {
|
|
26726
|
+
if (node2.type === "FunctionDeclaration") declare(scope, node2.id);
|
|
26727
|
+
inner = newScope(scope, true);
|
|
26728
|
+
if (node2.type === "FunctionExpression") declare(inner, node2.id);
|
|
26729
|
+
for (const parameter of node2.params ?? []) {
|
|
26730
|
+
declare(inner, parameter);
|
|
26731
|
+
}
|
|
26732
|
+
} else if (scopeTypes.has(node2.type)) {
|
|
26733
|
+
inner = newScope(scope, false);
|
|
26734
|
+
if (node2.type === "CatchClause") declare(inner, node2.param);
|
|
26735
|
+
} else if (node2.type === "ClassDeclaration") {
|
|
26736
|
+
declare(scope, node2.id);
|
|
26737
|
+
} else if (node2.type === "ClassExpression" && node2.id) {
|
|
26738
|
+
inner = newScope(scope, false);
|
|
26739
|
+
declare(inner, node2.id);
|
|
26740
|
+
} else if (node2.type === "VariableDeclaration") {
|
|
26741
|
+
const target = node2.kind === "var" ? functionScopeOf(scope) : scope;
|
|
26742
|
+
for (const declarator of node2.declarations) {
|
|
26743
|
+
declare(target, declarator.id);
|
|
26744
|
+
}
|
|
26745
|
+
} else if (node2.type === "ImportSpecifier" || node2.type === "ImportDefaultSpecifier" || node2.type === "ImportNamespaceSpecifier") {
|
|
26746
|
+
declare(scope, node2.local);
|
|
26747
|
+
}
|
|
26748
|
+
scopes.set(node2, inner);
|
|
26749
|
+
}
|
|
26750
|
+
for (const value of Object.values(node2)) build2(value, inner);
|
|
26751
|
+
};
|
|
26752
|
+
const root = { bindings: /* @__PURE__ */ new Map(), parent: null, isFunction: true };
|
|
26753
|
+
build2(program, root);
|
|
26754
|
+
const resolved = /* @__PURE__ */ new Map();
|
|
26755
|
+
const resolve = (input3, scope) => {
|
|
26756
|
+
if (!input3 || typeof input3 !== "object") return;
|
|
26757
|
+
if (Array.isArray(input3)) {
|
|
26758
|
+
for (const entry of input3) resolve(entry, scope);
|
|
26759
|
+
return;
|
|
26760
|
+
}
|
|
26761
|
+
const node2 = input3;
|
|
26762
|
+
const name = nameOf(node2);
|
|
26763
|
+
if (name) {
|
|
26764
|
+
for (let current = scope; current; current = current.parent) {
|
|
26765
|
+
const binding = current.bindings.get(name);
|
|
26766
|
+
if (!binding) continue;
|
|
26767
|
+
resolved.set(node2, binding);
|
|
26768
|
+
break;
|
|
26769
|
+
}
|
|
26770
|
+
}
|
|
26771
|
+
const inner = scopes.get(node2) ?? scope;
|
|
26772
|
+
for (const [key, value] of Object.entries(node2)) {
|
|
26773
|
+
const declaredName = key === "id" && (node2.type === "FunctionDeclaration" || node2.type === "ClassDeclaration");
|
|
26774
|
+
resolve(value, declaredName ? scope : inner);
|
|
26775
|
+
}
|
|
26776
|
+
};
|
|
26777
|
+
resolve(program, root);
|
|
26778
|
+
return resolved;
|
|
26779
|
+
}
|
|
26780
|
+
var functionTypes, scopeTypes;
|
|
26659
26781
|
var init_module_scope_bindings = __esm({
|
|
26660
26782
|
"../worker/src/package-runtime/module-scope-bindings.ts"() {
|
|
26661
26783
|
"use strict";
|
|
26784
|
+
functionTypes = /* @__PURE__ */ new Set([
|
|
26785
|
+
"FunctionDeclaration",
|
|
26786
|
+
"FunctionExpression",
|
|
26787
|
+
"ArrowFunctionExpression",
|
|
26788
|
+
"ObjectMethod",
|
|
26789
|
+
"ClassMethod",
|
|
26790
|
+
"ClassPrivateMethod"
|
|
26791
|
+
]);
|
|
26792
|
+
scopeTypes = /* @__PURE__ */ new Set([
|
|
26793
|
+
"BlockStatement",
|
|
26794
|
+
"ForStatement",
|
|
26795
|
+
"ForInStatement",
|
|
26796
|
+
"ForOfStatement",
|
|
26797
|
+
"SwitchStatement",
|
|
26798
|
+
"CatchClause",
|
|
26799
|
+
"StaticBlock",
|
|
26800
|
+
"ClassBody"
|
|
26801
|
+
]);
|
|
26662
26802
|
}
|
|
26663
26803
|
});
|
|
26664
26804
|
|
|
@@ -26715,6 +26855,80 @@ async function collectTopLevelFetchCollisionNames(source) {
|
|
|
26715
26855
|
return null;
|
|
26716
26856
|
}
|
|
26717
26857
|
}
|
|
26858
|
+
function sourceMayReadFetchThroughGlobalObject(source) {
|
|
26859
|
+
return /\b(?:globalThis|self)\b/.test(source) && source.includes("fetch");
|
|
26860
|
+
}
|
|
26861
|
+
async function rewriteGlobalObjectFetchReads(source, replacement) {
|
|
26862
|
+
const found = await collectGlobalObjectFetchReads(source);
|
|
26863
|
+
if (!found) return source;
|
|
26864
|
+
let next2 = source;
|
|
26865
|
+
for (const read of found.reads.sort((a2, b3) => b3.start - a2.start)) {
|
|
26866
|
+
next2 = `${next2.slice(0, read.start)}${replacement}${next2.slice(read.end)}`;
|
|
26867
|
+
}
|
|
26868
|
+
return next2;
|
|
26869
|
+
}
|
|
26870
|
+
async function sourceReadsFetchThroughGlobalObject(source) {
|
|
26871
|
+
return ((await collectGlobalObjectFetchReads(source))?.reads.length ?? 0) > 0;
|
|
26872
|
+
}
|
|
26873
|
+
async function collectGlobalObjectFetchReads(source) {
|
|
26874
|
+
if (!sourceMayReadFetchThroughGlobalObject(source)) return null;
|
|
26875
|
+
let parsed;
|
|
26876
|
+
try {
|
|
26877
|
+
parsed = await parseModuleSource(source);
|
|
26878
|
+
} catch {
|
|
26879
|
+
return null;
|
|
26880
|
+
}
|
|
26881
|
+
const bindings = resolveModuleBindings(parsed);
|
|
26882
|
+
const reads = [];
|
|
26883
|
+
walkAst(parsed, (node2, parent) => {
|
|
26884
|
+
if (node2.type !== "Identifier") return;
|
|
26885
|
+
const name = node2.name;
|
|
26886
|
+
if (typeof name !== "string" || !globalObjectNames.has(name)) return;
|
|
26887
|
+
if (bindings.has(node2)) return;
|
|
26888
|
+
const member = parent;
|
|
26889
|
+
const isMember = member?.type === "MemberExpression" || member?.type === "OptionalMemberExpression" || member?.type === "StaticMemberExpression" || member?.type === "ComputedMemberExpression";
|
|
26890
|
+
if (!isMember || member.object !== node2) return;
|
|
26891
|
+
const property = member.property;
|
|
26892
|
+
const propertyName = member.computed === true ? typeof property?.value === "string" ? property.value : null : typeof property?.name === "string" ? property.name : null;
|
|
26893
|
+
if (propertyName !== "fetch") return;
|
|
26894
|
+
if (typeof member.start !== "number" || typeof member.end !== "number") {
|
|
26895
|
+
return;
|
|
26896
|
+
}
|
|
26897
|
+
reads.push({ start: member.start, end: member.end });
|
|
26898
|
+
});
|
|
26899
|
+
const writes = collectMemberWriteStarts(parsed);
|
|
26900
|
+
return { reads: reads.filter((read) => !writes.has(read.start)) };
|
|
26901
|
+
}
|
|
26902
|
+
function collectMemberWriteStarts(parsed) {
|
|
26903
|
+
const starts = /* @__PURE__ */ new Set();
|
|
26904
|
+
const addTarget = (target) => {
|
|
26905
|
+
walkAst(target, (inner) => {
|
|
26906
|
+
if (typeof inner.start === "number") starts.add(inner.start);
|
|
26907
|
+
});
|
|
26908
|
+
};
|
|
26909
|
+
walkAst(parsed, (node2) => {
|
|
26910
|
+
if (node2.type === "AssignmentExpression") {
|
|
26911
|
+
addTarget(node2.left);
|
|
26912
|
+
} else if (node2.type === "UpdateExpression" || node2.type === "UnaryExpression" && node2.operator === "delete") {
|
|
26913
|
+
addTarget(node2.argument);
|
|
26914
|
+
} else if (node2.type === "ForInStatement" || node2.type === "ForOfStatement") {
|
|
26915
|
+
addTarget(node2.left);
|
|
26916
|
+
}
|
|
26917
|
+
});
|
|
26918
|
+
return starts;
|
|
26919
|
+
}
|
|
26920
|
+
function walkAst(node2, visit2, parent) {
|
|
26921
|
+
if (!node2 || typeof node2 !== "object") return;
|
|
26922
|
+
const typed = node2;
|
|
26923
|
+
if (typeof typed.type === "string") visit2(typed, parent);
|
|
26924
|
+
for (const value of Object.values(typed)) {
|
|
26925
|
+
if (Array.isArray(value)) {
|
|
26926
|
+
for (const entry of value) walkAst(entry, visit2, typed);
|
|
26927
|
+
continue;
|
|
26928
|
+
}
|
|
26929
|
+
walkAst(value, visit2, typed);
|
|
26930
|
+
}
|
|
26931
|
+
}
|
|
26718
26932
|
function getBindingIdentifierName(node2) {
|
|
26719
26933
|
if (!node2 || typeof node2 !== "object") return null;
|
|
26720
26934
|
const typed = node2;
|
|
@@ -26762,12 +26976,14 @@ function collectPatternBoundNames(node2, names) {
|
|
|
26762
26976
|
return;
|
|
26763
26977
|
}
|
|
26764
26978
|
}
|
|
26979
|
+
var globalObjectNames;
|
|
26765
26980
|
var init_rewrite_local_execute_secret_fetch = __esm({
|
|
26766
26981
|
"../worker/src/package-runtime/rewrite-local-execute-secret-fetch.ts"() {
|
|
26767
26982
|
"use strict";
|
|
26768
26983
|
init_module_source();
|
|
26769
26984
|
init_module_scope_bindings();
|
|
26770
26985
|
init_module_graph_path_basics();
|
|
26986
|
+
globalObjectNames = /* @__PURE__ */ new Set(["globalThis", "self"]);
|
|
26771
26987
|
}
|
|
26772
26988
|
});
|
|
26773
26989
|
|
|
@@ -30916,6 +31132,9 @@ var init_runtime_source_modules = __esm({
|
|
|
30916
31132
|
});
|
|
30917
31133
|
|
|
30918
31134
|
// ../worker/src/package-runtime/pre-binding-artifact-repair.ts
|
|
31135
|
+
function hasLexicalBindingMarker(artifact) {
|
|
31136
|
+
return (artifact.packageBindingRewrite ?? 0) >= lexicalBindingRewriteVersion;
|
|
31137
|
+
}
|
|
30919
31138
|
function warnUnrepairedModule(input3) {
|
|
30920
31139
|
console.warn(
|
|
30921
31140
|
JSON.stringify({
|
|
@@ -30979,9 +31198,7 @@ function isRepairableArtifactKind(kind) {
|
|
|
30979
31198
|
}
|
|
30980
31199
|
function isPreBindingPublishedArtifact(artifact) {
|
|
30981
31200
|
if (!isRepairableArtifactKind(artifact.kind)) return false;
|
|
30982
|
-
if (artifact
|
|
30983
|
-
return false;
|
|
30984
|
-
}
|
|
31201
|
+
if (hasLexicalBindingMarker(artifact)) return false;
|
|
30985
31202
|
let needsBinding = false;
|
|
30986
31203
|
for (const [modulePath, module] of Object.entries(artifact.modules)) {
|
|
30987
31204
|
if (isPlatformRuntimeModulePath(modulePath)) continue;
|
|
@@ -31057,6 +31274,61 @@ ${source}`
|
|
|
31057
31274
|
if (!modules) return artifact;
|
|
31058
31275
|
return { ...artifact, modules };
|
|
31059
31276
|
}
|
|
31277
|
+
async function artifactReadsFetchThroughGlobalObject(artifact) {
|
|
31278
|
+
for (const [modulePath, module] of Object.entries(artifact.modules)) {
|
|
31279
|
+
if (isPlatformRuntimeModulePath(modulePath)) continue;
|
|
31280
|
+
const source = moduleSource(module);
|
|
31281
|
+
if (source == null || !sourceMayReadFetchThroughGlobalObject(source)) {
|
|
31282
|
+
continue;
|
|
31283
|
+
}
|
|
31284
|
+
if (await sourceReadsFetchThroughGlobalObject(source)) return true;
|
|
31285
|
+
}
|
|
31286
|
+
return false;
|
|
31287
|
+
}
|
|
31288
|
+
async function repairGlobalObjectFetchReadsInArtifact(artifact) {
|
|
31289
|
+
if (!isRepairableArtifactKind(artifact.kind)) return artifact;
|
|
31290
|
+
if (artifact.packageBindingRewrite === packageBindingRewriteVersion) {
|
|
31291
|
+
return artifact;
|
|
31292
|
+
}
|
|
31293
|
+
const ownPackageId = artifact.packageContext?.packageId?.trim();
|
|
31294
|
+
if (!ownPackageId) return artifact;
|
|
31295
|
+
if (publishedArtifactInlinesOtherPackages(artifact)) return artifact;
|
|
31296
|
+
let modules = null;
|
|
31297
|
+
for (const [modulePath, module] of Object.entries(artifact.modules)) {
|
|
31298
|
+
if (isPlatformRuntimeModulePath(modulePath)) continue;
|
|
31299
|
+
const original = moduleSource(module);
|
|
31300
|
+
if (original == null || !sourceMayReadFetchThroughGlobalObject(original)) {
|
|
31301
|
+
continue;
|
|
31302
|
+
}
|
|
31303
|
+
const rewritten = await rewriteGlobalObjectFetchReads(
|
|
31304
|
+
original,
|
|
31305
|
+
repairGlobalReadFetchName
|
|
31306
|
+
);
|
|
31307
|
+
if (rewritten === original) continue;
|
|
31308
|
+
const collisions = await collectTopLevelFetchCollisionNames(original);
|
|
31309
|
+
if (!collisions || collisions.has(repairGlobalReadFetchName) || collisions.has(repairGlobalReadCreatorName)) {
|
|
31310
|
+
warnUnrepairedModule({
|
|
31311
|
+
artifact,
|
|
31312
|
+
modulePath,
|
|
31313
|
+
reason: collisions ? "creator-name-collision" : "parse-failed"
|
|
31314
|
+
});
|
|
31315
|
+
continue;
|
|
31316
|
+
}
|
|
31317
|
+
modules ??= { ...artifact.modules };
|
|
31318
|
+
modules[modulePath] = withModuleSource(
|
|
31319
|
+
module,
|
|
31320
|
+
[
|
|
31321
|
+
`import { __kodyCreatePackageBoundFetch as ${repairGlobalReadCreatorName} } from ${JSON.stringify(
|
|
31322
|
+
runtimeSpecifierFrom(modulePath)
|
|
31323
|
+
)};`,
|
|
31324
|
+
`const ${repairGlobalReadFetchName} = ${repairGlobalReadCreatorName}(${JSON.stringify(ownPackageId)});`,
|
|
31325
|
+
rewritten
|
|
31326
|
+
].join("\n")
|
|
31327
|
+
);
|
|
31328
|
+
}
|
|
31329
|
+
if (!modules) return artifact;
|
|
31330
|
+
return { ...artifact, modules };
|
|
31331
|
+
}
|
|
31060
31332
|
function artifactMentionsLexicalPackageBinding(artifact) {
|
|
31061
31333
|
for (const [modulePath, module] of Object.entries(artifact.modules)) {
|
|
31062
31334
|
if (isPlatformRuntimeModulePath(modulePath)) continue;
|
|
@@ -31068,20 +31340,22 @@ function artifactMentionsLexicalPackageBinding(artifact) {
|
|
|
31068
31340
|
}
|
|
31069
31341
|
return false;
|
|
31070
31342
|
}
|
|
31071
|
-
function isUnrepairablePreBindingArtifact(artifact) {
|
|
31343
|
+
async function isUnrepairablePreBindingArtifact(artifact) {
|
|
31072
31344
|
if (!artifact.packageContext?.packageId) return false;
|
|
31073
31345
|
if (!isRepairableArtifactKind(artifact.kind)) return false;
|
|
31074
31346
|
if (!publishedArtifactInlinesOtherPackages(artifact)) return false;
|
|
31075
31347
|
if (artifact.packageBindingRewrite === packageBindingRewriteVersion) {
|
|
31076
31348
|
return false;
|
|
31077
31349
|
}
|
|
31350
|
+
if (await artifactReadsFetchThroughGlobalObject(artifact)) return true;
|
|
31351
|
+
if (hasLexicalBindingMarker(artifact)) return false;
|
|
31078
31352
|
if (!isPreBindingPublishedArtifact(artifact) && artifactMentionsLexicalPackageBinding(artifact)) {
|
|
31079
31353
|
return false;
|
|
31080
31354
|
}
|
|
31081
31355
|
return true;
|
|
31082
31356
|
}
|
|
31083
|
-
function publishedArtifactNeedsPackageBindingRebuild(input3) {
|
|
31084
|
-
if (!isUnrepairablePreBindingArtifact(input3.artifact)) return false;
|
|
31357
|
+
async function publishedArtifactNeedsPackageBindingRebuild(input3) {
|
|
31358
|
+
if (!await isUnrepairablePreBindingArtifact(input3.artifact)) return false;
|
|
31085
31359
|
const missing = listMissingPublishedSourceInstalledDependencies(
|
|
31086
31360
|
input3.sourceFiles
|
|
31087
31361
|
);
|
|
@@ -31095,7 +31369,7 @@ function publishedArtifactNeedsPackageBindingRebuild(input3) {
|
|
|
31095
31369
|
);
|
|
31096
31370
|
return false;
|
|
31097
31371
|
}
|
|
31098
|
-
var packageBindingRewriteVersion, lexicalBindingNames, repairFetchCreatorName, repairKodyCreatorName, freeFetchPattern, sharedRuntimeImportPattern, browserArtifactKinds;
|
|
31372
|
+
var packageBindingRewriteVersion, lexicalBindingRewriteVersion, lexicalBindingNames, repairFetchCreatorName, repairKodyCreatorName, freeFetchPattern, sharedRuntimeImportPattern, browserArtifactKinds, repairGlobalReadFetchName, repairGlobalReadCreatorName;
|
|
31099
31373
|
var init_pre_binding_artifact_repair = __esm({
|
|
31100
31374
|
"../worker/src/package-runtime/pre-binding-artifact-repair.ts"() {
|
|
31101
31375
|
"use strict";
|
|
@@ -31103,7 +31377,8 @@ var init_pre_binding_artifact_repair = __esm({
|
|
|
31103
31377
|
init_published_source_dependencies();
|
|
31104
31378
|
init_rewrite_local_execute_secret_fetch();
|
|
31105
31379
|
init_runtime_source_modules();
|
|
31106
|
-
packageBindingRewriteVersion =
|
|
31380
|
+
packageBindingRewriteVersion = 2;
|
|
31381
|
+
lexicalBindingRewriteVersion = 1;
|
|
31107
31382
|
lexicalBindingNames = [
|
|
31108
31383
|
"__kodyCreatePackageBoundFetch",
|
|
31109
31384
|
"__kodyCreatePackageBoundKody",
|
|
@@ -31114,6 +31389,8 @@ var init_pre_binding_artifact_repair = __esm({
|
|
|
31114
31389
|
freeFetchPattern = /\bfetch\b/;
|
|
31115
31390
|
sharedRuntimeImportPattern = /^import\s*\{([^}]*)\}\s*from\s*("[^"\n]*\.__kody_virtual__\/runtime\.js");?[ \t]*$/gm;
|
|
31116
31391
|
browserArtifactKinds = /* @__PURE__ */ new Set(["app-client"]);
|
|
31392
|
+
repairGlobalReadFetchName = "__kodyPreBindingGlobalReadFetch";
|
|
31393
|
+
repairGlobalReadCreatorName = "__kodyPreBindingGlobalReadCreator";
|
|
31117
31394
|
}
|
|
31118
31395
|
});
|
|
31119
31396
|
|
|
@@ -31821,7 +32098,9 @@ async function parseStoredPublishedBundleArtifact(stored) {
|
|
|
31821
32098
|
};
|
|
31822
32099
|
if (!isRepairableArtifactKind(loaded.kind)) return loaded;
|
|
31823
32100
|
return repairInlinedFacadeBindingsInArtifact(
|
|
31824
|
-
await
|
|
32101
|
+
await repairGlobalObjectFetchReadsInArtifact(
|
|
32102
|
+
await repairPreBindingPublishedArtifact(loaded)
|
|
32103
|
+
)
|
|
31825
32104
|
);
|
|
31826
32105
|
}
|
|
31827
32106
|
var sourceSnapshotVersion, sourceManifestSnapshotVersion, bundleArtifactVersion, sourceSnapshotPrefix, sourceManifestSnapshotPrefix, bundleArtifactPrefix, packageAppTemplateVersion, packageAppTemplatePrefix, packageAppClientPointerPrefix;
|
|
@@ -201328,7 +201607,7 @@ async function maybeEnsurePublishedArtifactTarget(input3) {
|
|
|
201328
201607
|
if (!artifact?.artifact) {
|
|
201329
201608
|
return null;
|
|
201330
201609
|
}
|
|
201331
|
-
if (publishedArtifactNeedsPackageBindingRebuild({
|
|
201610
|
+
if (await publishedArtifactNeedsPackageBindingRebuild({
|
|
201332
201611
|
artifact: artifact.artifact,
|
|
201333
201612
|
sourceFiles: input3.loaded.files
|
|
201334
201613
|
})) {
|
|
@@ -201656,6 +201935,23 @@ async function rewriteKodyImports(input3) {
|
|
|
201656
201935
|
`;
|
|
201657
201936
|
}
|
|
201658
201937
|
}
|
|
201938
|
+
if (input3.sourcePackageId && !input3.source.includes(packageOwnFetchName)) {
|
|
201939
|
+
const rewritten2 = await rewriteGlobalObjectFetchReads(
|
|
201940
|
+
input3.source,
|
|
201941
|
+
packageOwnFetchName
|
|
201942
|
+
);
|
|
201943
|
+
if (rewritten2 !== input3.source) {
|
|
201944
|
+
const facadePath = ensurePackageRuntimeModule(
|
|
201945
|
+
input3.state,
|
|
201946
|
+
input3.sourcePackageId
|
|
201947
|
+
);
|
|
201948
|
+
boundFetchPrefix += `import { __kodyBoundFetch as ${packageOwnFetchName} } from ${JSON.stringify(
|
|
201949
|
+
createRelativeImportSpecifier(input3.modulePath, facadePath)
|
|
201950
|
+
)};
|
|
201951
|
+
`;
|
|
201952
|
+
input3 = { ...input3, source: rewritten2 };
|
|
201953
|
+
}
|
|
201954
|
+
}
|
|
201659
201955
|
const {
|
|
201660
201956
|
literalImports: importNodes,
|
|
201661
201957
|
dynamicImportExpressions: dynamicImportNodes
|
|
@@ -201891,7 +202187,7 @@ function mergePublishedArtifactDependencies(input3) {
|
|
|
201891
202187
|
(left, right) => left.kodyId.localeCompare(right.kodyId) || left.sourceId.localeCompare(right.sourceId)
|
|
201892
202188
|
);
|
|
201893
202189
|
}
|
|
201894
|
-
var bundlerScriptSourcePathPattern, bundlerConfigSourcePathPattern;
|
|
202190
|
+
var bundlerScriptSourcePathPattern, bundlerConfigSourcePathPattern, packageOwnFetchName;
|
|
201895
202191
|
var init_module_graph_import_rewriting = __esm({
|
|
201896
202192
|
"../worker/src/package-runtime/module-graph-import-rewriting.ts"() {
|
|
201897
202193
|
"use strict";
|
|
@@ -201913,6 +202209,7 @@ var init_module_graph_import_rewriting = __esm({
|
|
|
201913
202209
|
init_module_graph_workspace();
|
|
201914
202210
|
bundlerScriptSourcePathPattern = /\.(?:[cm]?[jt]sx?)$/i;
|
|
201915
202211
|
bundlerConfigSourcePathPattern = /\.(?:jsonc?|toml)$/i;
|
|
202212
|
+
packageOwnFetchName = "__kodyPackageOwnFetch";
|
|
201916
202213
|
}
|
|
201917
202214
|
});
|
|
201918
202215
|
|
|
@@ -202332,13 +202629,6 @@ function createAttachedModulesExternalsPlugin(attachedModulePaths) {
|
|
|
202332
202629
|
}
|
|
202333
202630
|
};
|
|
202334
202631
|
}
|
|
202335
|
-
function preparedGraphNeedsSourceBuild(prepared) {
|
|
202336
|
-
if (prepared.hasTypedPublishedArtifactModules) return true;
|
|
202337
|
-
for (const role of prepared.moduleRoles.values()) {
|
|
202338
|
-
if (role === "package-source" || role === "root-dependency") return true;
|
|
202339
|
-
}
|
|
202340
|
-
return false;
|
|
202341
|
-
}
|
|
202342
202632
|
function splitAttachedPublishedArtifactModules(files, moduleRoles) {
|
|
202343
202633
|
const bundlerFiles = {};
|
|
202344
202634
|
const attachedModules = {};
|
|
@@ -202426,10 +202716,7 @@ async function buildKodyModuleBundle(input3) {
|
|
|
202426
202716
|
prepareCache: input3.prepareCache,
|
|
202427
202717
|
linkKodyPackageImports: input3.linkKodyPackageImports
|
|
202428
202718
|
});
|
|
202429
|
-
|
|
202430
|
-
throw new PublishedImportsNeedSourceBuildError();
|
|
202431
|
-
}
|
|
202432
|
-
const { bundlerFiles: files, attachedModules } = input3.attachPublishedArtifacts ? splitAttachedPublishedArtifactModules(
|
|
202719
|
+
const { bundlerFiles: files, attachedModules } = input3.attachPublishedArtifacts && !prepared.hasTypedPublishedArtifactModules ? splitAttachedPublishedArtifactModules(
|
|
202433
202720
|
prepared.files,
|
|
202434
202721
|
prepared.moduleRoles
|
|
202435
202722
|
) : {
|
|
@@ -202644,7 +202931,7 @@ function createPublishedPackageAppBundleCacheKey(input3) {
|
|
|
202644
202931
|
entryPoint: input3.entryPoint
|
|
202645
202932
|
});
|
|
202646
202933
|
}
|
|
202647
|
-
var packageAppBundleCache, moduleBundleCache, kodyRuntimeExternalsPlugin, kodyLinkedPackageImportsPlugin
|
|
202934
|
+
var packageAppBundleCache, moduleBundleCache, kodyRuntimeExternalsPlugin, kodyLinkedPackageImportsPlugin;
|
|
202648
202935
|
var init_module_graph_bundle_builders = __esm({
|
|
202649
202936
|
"../worker/src/package-runtime/module-graph-bundle-builders.ts"() {
|
|
202650
202937
|
"use strict";
|
|
@@ -202679,12 +202966,6 @@ var init_module_graph_bundle_builders = __esm({
|
|
|
202679
202966
|
});
|
|
202680
202967
|
}
|
|
202681
202968
|
};
|
|
202682
|
-
PublishedImportsNeedSourceBuildError = class extends Error {
|
|
202683
|
-
constructor() {
|
|
202684
|
-
super("Bundle needs a package source build.");
|
|
202685
|
-
this.name = "PublishedImportsNeedSourceBuildError";
|
|
202686
|
-
}
|
|
202687
|
-
};
|
|
202688
202969
|
}
|
|
202689
202970
|
});
|
|
202690
202971
|
|
|
@@ -202961,7 +203242,7 @@ async function resolveCurrentDynamicPackageArtifact(input3) {
|
|
|
202961
203242
|
entryPoint,
|
|
202962
203243
|
commit: servingArtifactCommitForSource(loaded.source)
|
|
202963
203244
|
});
|
|
202964
|
-
if (loadedArtifact?.artifact && !publishedArtifactNeedsPackageBindingRebuild({
|
|
203245
|
+
if (loadedArtifact?.artifact && !await publishedArtifactNeedsPackageBindingRebuild({
|
|
202965
203246
|
artifact: loadedArtifact.artifact,
|
|
202966
203247
|
sourceFiles: loaded.files
|
|
202967
203248
|
})) {
|
|
@@ -38,7 +38,7 @@ async function runContextRun(input) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
const hostCommands = input.hostCommands;
|
|
41
|
-
const { runLocalExecute } = await import("./local-execute-
|
|
41
|
+
const { runLocalExecute } = await import("./local-execute-BCGZKZXG.js");
|
|
42
42
|
let timing;
|
|
43
43
|
const result = await runLocalExecute({
|
|
44
44
|
code: source.code,
|
|
@@ -89,4 +89,4 @@ async function runContextRun(input) {
|
|
|
89
89
|
export {
|
|
90
90
|
runContextRun
|
|
91
91
|
};
|
|
92
|
-
//# sourceMappingURL=run-executor-
|
|
92
|
+
//# sourceMappingURL=run-executor-INDLQONB.js.map
|