@adep/cli 0.5.1 → 0.5.3
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 +65 -15
- package/dist/index.js +1892 -696
- package/dist/vite.js +355 -29
- package/dist/worker-entry.js +69 -7
- package/package.json +17 -5
package/dist/worker-entry.js
CHANGED
|
@@ -441,6 +441,14 @@ function resolveModulePath(fromDir, request, files) {
|
|
|
441
441
|
}
|
|
442
442
|
return null;
|
|
443
443
|
}
|
|
444
|
+
function escapesFunctionRoot(fromDir, request) {
|
|
445
|
+
const depth = fromDir.split("/").filter((part) => part.length > 0).length;
|
|
446
|
+
let ups = 0;
|
|
447
|
+
for (const part of request.split("/")) {
|
|
448
|
+
if (part === "..") ups += 1;
|
|
449
|
+
}
|
|
450
|
+
return ups > depth;
|
|
451
|
+
}
|
|
444
452
|
function joinPosix(dir, request) {
|
|
445
453
|
const parts = [...dir.split("/"), ...request.split("/")];
|
|
446
454
|
const stack = [];
|
|
@@ -469,7 +477,7 @@ function syntaxErrorWithLocation(error, path) {
|
|
|
469
477
|
if (typeof code === "string") wrapped.code = code;
|
|
470
478
|
return wrapped;
|
|
471
479
|
}
|
|
472
|
-
function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache) {
|
|
480
|
+
function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache, strictPaths = false) {
|
|
473
481
|
const cached = cache.get(path);
|
|
474
482
|
if (cached !== void 0) return cached;
|
|
475
483
|
const source = files[path];
|
|
@@ -481,9 +489,16 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache)
|
|
|
481
489
|
const dir = path.includes("/") ? path.slice(0, path.lastIndexOf("/")) : "";
|
|
482
490
|
const module = { exports, default: void 0 };
|
|
483
491
|
const require2 = (request) => {
|
|
492
|
+
if (strictPaths && request.startsWith("../") && escapesFunctionRoot(dir, request)) {
|
|
493
|
+
const error2 = new Error(
|
|
494
|
+
`\u6C99\u7BB1\u62D2\u7EDD\u8D8A\u6839\u5F15\u7528\uFF1A"${request}"\uFF08\u51FD\u6570\u76EE\u5F55\u4E4B\u5916\u4E0D\u53EF\u5F15\u7528\uFF1B\u5E73\u53F0\u6C99\u7BB1\u540C\u6B64\u7EA6\u675F\uFF0CFN_SANDBOX_ESCAPE_BLOCKED\uFF09`
|
|
495
|
+
);
|
|
496
|
+
error2.code = "FN_SANDBOX_ESCAPE_BLOCKED";
|
|
497
|
+
throw error2;
|
|
498
|
+
}
|
|
484
499
|
const resolved = resolveModulePath(dir, request, files);
|
|
485
500
|
if (resolved !== null) {
|
|
486
|
-
return loadModule(resolved, files, sandboxGlobals, cache, resolveBare, bareCache);
|
|
501
|
+
return loadModule(resolved, files, sandboxGlobals, cache, resolveBare, bareCache, strictPaths);
|
|
487
502
|
}
|
|
488
503
|
if (resolveBare !== void 0 && !request.startsWith("./") && !request.startsWith("../")) {
|
|
489
504
|
const cachedModule = bareCache?.get(request);
|
|
@@ -522,10 +537,18 @@ function loadModule(path, files, sandboxGlobals, cache, resolveBare, bareCache)
|
|
|
522
537
|
}
|
|
523
538
|
return exports;
|
|
524
539
|
}
|
|
525
|
-
function loadFunctionModule(files, entry, sandboxGlobals, resolveBare) {
|
|
540
|
+
function loadFunctionModule(files, entry, sandboxGlobals, resolveBare, strictPaths = false) {
|
|
526
541
|
const cache = /* @__PURE__ */ new Map();
|
|
527
542
|
const bareCache = /* @__PURE__ */ new Map();
|
|
528
|
-
const entryExports = loadModule(
|
|
543
|
+
const entryExports = loadModule(
|
|
544
|
+
entry,
|
|
545
|
+
files,
|
|
546
|
+
sandboxGlobals,
|
|
547
|
+
cache,
|
|
548
|
+
resolveBare,
|
|
549
|
+
bareCache,
|
|
550
|
+
strictPaths
|
|
551
|
+
);
|
|
529
552
|
const handler = entryExports["default"];
|
|
530
553
|
if (typeof handler !== "function") {
|
|
531
554
|
throw new Error(`\u5165\u53E3\u6587\u4EF6 ${entry} \u7F3A\u5C11 default \u5BFC\u51FA\u7684\u51FD\u6570`);
|
|
@@ -1023,6 +1046,37 @@ function splitBareSpecifier(request) {
|
|
|
1023
1046
|
}
|
|
1024
1047
|
|
|
1025
1048
|
// packages/runtime/src/functions/runtime/worker-entry.ts
|
|
1049
|
+
var SANDBOX_GLOBAL_KEYS = [
|
|
1050
|
+
"console",
|
|
1051
|
+
// CF-015:Cloudflare Workers 代码重度依赖 Web 标准 API(URL / Request / Response /
|
|
1052
|
+
// Headers / 流 / 编码 / crypto 等)。Node 18+ 全局内置,直接注入 vm 上下文;
|
|
1053
|
+
// 与 @adep/cf-compat 的 Workers 适配(ctxToRequest / responseToEnvelopeBody)配套。
|
|
1054
|
+
"URL",
|
|
1055
|
+
"URLSearchParams",
|
|
1056
|
+
"Request",
|
|
1057
|
+
"Response",
|
|
1058
|
+
"Headers",
|
|
1059
|
+
"TextEncoder",
|
|
1060
|
+
"TextDecoder",
|
|
1061
|
+
"AbortController",
|
|
1062
|
+
"AbortSignal",
|
|
1063
|
+
"ReadableStream",
|
|
1064
|
+
"WritableStream",
|
|
1065
|
+
"TransformStream",
|
|
1066
|
+
"Blob",
|
|
1067
|
+
"FormData",
|
|
1068
|
+
"crypto",
|
|
1069
|
+
"performance",
|
|
1070
|
+
"atob",
|
|
1071
|
+
"btoa",
|
|
1072
|
+
"structuredClone",
|
|
1073
|
+
// CORE-154:定时器家族——esign 重试退避用 setTimeout 直接 ReferenceError(比原错误更难排查),
|
|
1074
|
+
// 被迫借 AbortSignal.timeout 的 abort 事件定时。本地定时无出网面,注入后与容器形态同形。
|
|
1075
|
+
"setTimeout",
|
|
1076
|
+
"clearTimeout",
|
|
1077
|
+
"setInterval",
|
|
1078
|
+
"clearInterval"
|
|
1079
|
+
];
|
|
1026
1080
|
function errorMessageOf2(error) {
|
|
1027
1081
|
if (error instanceof Error) return error.message;
|
|
1028
1082
|
if (typeof error === "object" && error !== null && "message" in error) {
|
|
@@ -1151,9 +1205,14 @@ function runWorker(input, port) {
|
|
|
1151
1205
|
performance,
|
|
1152
1206
|
atob,
|
|
1153
1207
|
btoa,
|
|
1154
|
-
structuredClone
|
|
1208
|
+
structuredClone,
|
|
1209
|
+
// CORE-154:定时器家族(纯本地定时,无出网/句柄面;清单见 SANDBOX_GLOBAL_KEYS 钉测面)。
|
|
1210
|
+
setTimeout,
|
|
1211
|
+
clearTimeout,
|
|
1212
|
+
setInterval,
|
|
1213
|
+
clearInterval
|
|
1155
1214
|
};
|
|
1156
|
-
if (input.env !== void 0) {
|
|
1215
|
+
if (input.env !== void 0 && input.parity !== true) {
|
|
1157
1216
|
sandboxGlobals["process"] = realmValue({ env: input.env });
|
|
1158
1217
|
}
|
|
1159
1218
|
if (input.fetch !== void 0) {
|
|
@@ -1181,7 +1240,9 @@ function runWorker(input, port) {
|
|
|
1181
1240
|
input.files,
|
|
1182
1241
|
input.entry,
|
|
1183
1242
|
sandboxGlobals,
|
|
1184
|
-
input.deps === void 0 ? void 0 : createBareResolver(input.deps)
|
|
1243
|
+
input.deps === void 0 ? void 0 : createBareResolver(input.deps),
|
|
1244
|
+
// CORE-154:--parity 严格模式连带 `../` 越根引用报错(与容器形态真实 fs 同形)。
|
|
1245
|
+
input.parity === true
|
|
1185
1246
|
);
|
|
1186
1247
|
const result = Promise.resolve(handler(ctx));
|
|
1187
1248
|
void result.then(
|
|
@@ -1233,6 +1294,7 @@ if (workerPort !== null && workerData !== void 0) {
|
|
|
1233
1294
|
runWorker(workerData, port);
|
|
1234
1295
|
}
|
|
1235
1296
|
export {
|
|
1297
|
+
SANDBOX_GLOBAL_KEYS,
|
|
1236
1298
|
createBareResolver,
|
|
1237
1299
|
runWorker
|
|
1238
1300
|
};
|
package/package.json
CHANGED
|
@@ -7,7 +7,19 @@
|
|
|
7
7
|
},
|
|
8
8
|
"homepage": "https://adep.top",
|
|
9
9
|
"bugs": "https://gitcode.com/yunqiang_wu/ai-yunke/issues",
|
|
10
|
-
"version": "0.5.
|
|
10
|
+
"version": "0.5.3",
|
|
11
|
+
"adep": {
|
|
12
|
+
"releaseTasks": [
|
|
13
|
+
"DB-024",
|
|
14
|
+
"FE-169",
|
|
15
|
+
"CLI-051",
|
|
16
|
+
"CLI-052",
|
|
17
|
+
"CLI-053",
|
|
18
|
+
"CLI-054",
|
|
19
|
+
"CLI-055",
|
|
20
|
+
"CLI-056"
|
|
21
|
+
]
|
|
22
|
+
},
|
|
11
23
|
"type": "module",
|
|
12
24
|
"description": "`adep` 命令行工具包位:登录 / 初始化 / 本地调试 / 部署 / 数据库维护 / 云存储 / 静态托管 / 微前端组件(widget),实现见任务单 CLI-001 ~ CLI-003 与 FE-002;子路径 `@adep/cli/vite` 提供云函数 vite 插件(CLI-014)",
|
|
13
25
|
"bin": {
|
|
@@ -30,14 +42,14 @@
|
|
|
30
42
|
"esbuild": "0.25.12",
|
|
31
43
|
"yaml": "2.9.1",
|
|
32
44
|
"zod": "^4.6.6",
|
|
45
|
+
"@adep/vite-plugin": "0.1.12",
|
|
33
46
|
"@adep/app-runtime": "0.1.1",
|
|
34
|
-
"@adep/cf-compat": "0.1.4",
|
|
35
47
|
"@adep/crypto": "0.1.1",
|
|
36
|
-
"@adep/
|
|
37
|
-
"@adep/runtime": "0.3.
|
|
48
|
+
"@adep/cf-compat": "0.1.4",
|
|
49
|
+
"@adep/runtime": "0.3.9"
|
|
38
50
|
},
|
|
39
51
|
"devDependencies": {
|
|
40
|
-
"@adep/types": "0.4.
|
|
52
|
+
"@adep/types": "0.4.2"
|
|
41
53
|
},
|
|
42
54
|
"scripts": {
|
|
43
55
|
"test": "vitest run",
|