@adep/cli 0.1.8 → 0.1.9
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 +7 -1
- package/dist/index.js +340 -262
- package/dist/vite.js +138 -88
- package/dist/worker-entry.js +19 -12
- package/package.json +4 -4
package/dist/vite.js
CHANGED
|
@@ -4,8 +4,8 @@ import { adepPlugin } from "@adep/vite-plugin";
|
|
|
4
4
|
// packages/cli/src/dev.ts
|
|
5
5
|
import { createServer } from "node:http";
|
|
6
6
|
import { watch } from "node:fs";
|
|
7
|
-
import { mkdir as mkdir3,
|
|
8
|
-
import { basename, join as
|
|
7
|
+
import { mkdir as mkdir3, readFile as readFile6, writeFile as writeFile3 } from "node:fs/promises";
|
|
8
|
+
import { basename, join as join9, resolve as resolve2 } from "node:path";
|
|
9
9
|
|
|
10
10
|
// packages/runtime/src/shared/capability-keys.ts
|
|
11
11
|
var RPC_CAPABILITY_KEY = "__adepRpc";
|
|
@@ -1106,7 +1106,7 @@ function createDbCapability(driver, options = {}) {
|
|
|
1106
1106
|
};
|
|
1107
1107
|
}
|
|
1108
1108
|
|
|
1109
|
-
// packages/
|
|
1109
|
+
// packages/runtime/src/sim/sql-engine.ts
|
|
1110
1110
|
var SimDbError = class extends Error {
|
|
1111
1111
|
constructor(code, message) {
|
|
1112
1112
|
super(message);
|
|
@@ -1146,7 +1146,7 @@ function parseCreateTable(ddl) {
|
|
|
1146
1146
|
);
|
|
1147
1147
|
if (m === null) return null;
|
|
1148
1148
|
const name = ident(m[1]);
|
|
1149
|
-
const body = m[
|
|
1149
|
+
const body = m[3];
|
|
1150
1150
|
const columns = [];
|
|
1151
1151
|
for (const part of body.split(",")) {
|
|
1152
1152
|
const tokens = part.trim().split(/\s+/);
|
|
@@ -1236,9 +1236,9 @@ function matchValue(value, clause) {
|
|
|
1236
1236
|
const right = clause.value;
|
|
1237
1237
|
switch (op) {
|
|
1238
1238
|
case "=":
|
|
1239
|
-
return left === right;
|
|
1239
|
+
return left !== null && right !== null && left === right;
|
|
1240
1240
|
case "!=":
|
|
1241
|
-
return left !== right;
|
|
1241
|
+
return left !== null && right !== null && left !== right;
|
|
1242
1242
|
case ">":
|
|
1243
1243
|
return left !== null && right !== null && left > right;
|
|
1244
1244
|
case ">=":
|
|
@@ -1698,6 +1698,19 @@ function assertSafeStoragePath(path) {
|
|
|
1698
1698
|
}
|
|
1699
1699
|
return path;
|
|
1700
1700
|
}
|
|
1701
|
+
function assertStoragePrefix(prefix) {
|
|
1702
|
+
if (prefix !== void 0 && prefix !== "") {
|
|
1703
|
+
const segments = prefix.split("/");
|
|
1704
|
+
if (prefix.startsWith("/") || /[\\]/.test(prefix) || segments.some((segment) => segment === "..")) {
|
|
1705
|
+
throw new StorageError(
|
|
1706
|
+
400,
|
|
1707
|
+
STORAGE_CODES.invalidPath,
|
|
1708
|
+
`\u975E\u6CD5\u524D\u7F00 "${prefix}"\uFF08\u7981\u6B62 / \u5F00\u5934\u3001\u53CD\u659C\u6760\u6216 .. \u7A7F\u8D8A\uFF09`
|
|
1709
|
+
);
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
return prefix ?? "";
|
|
1713
|
+
}
|
|
1701
1714
|
|
|
1702
1715
|
// packages/runtime/src/storage/hmac-sha256.ts
|
|
1703
1716
|
var K = new Uint32Array([
|
|
@@ -2081,16 +2094,7 @@ function createLocalStorageDriver(options) {
|
|
|
2081
2094
|
await unlink(metaPath(projectId, path)).catch(() => void 0);
|
|
2082
2095
|
},
|
|
2083
2096
|
async list(projectId, prefix) {
|
|
2084
|
-
|
|
2085
|
-
const segments = prefix.split("/");
|
|
2086
|
-
if (prefix.startsWith("/") || /[\\]/.test(prefix) || segments.some((segment) => segment === "..")) {
|
|
2087
|
-
throw new StorageError(
|
|
2088
|
-
400,
|
|
2089
|
-
STORAGE_CODES.invalidPath,
|
|
2090
|
-
`\u975E\u6CD5\u524D\u7F00 "${prefix}"\uFF08\u7981\u6B62 / \u5F00\u5934\u3001\u53CD\u659C\u6760\u6216 .. \u7A7F\u8D8A\uFF09`
|
|
2091
|
-
);
|
|
2092
|
-
}
|
|
2093
|
-
}
|
|
2097
|
+
assertStoragePrefix(prefix);
|
|
2094
2098
|
const root = bucketDir(projectId);
|
|
2095
2099
|
const metas = [];
|
|
2096
2100
|
const walk = async (dir, relative) => {
|
|
@@ -2156,7 +2160,7 @@ function createSimStorageCapability(options) {
|
|
|
2156
2160
|
return { bundle, driver };
|
|
2157
2161
|
}
|
|
2158
2162
|
|
|
2159
|
-
// packages/
|
|
2163
|
+
// packages/runtime/src/sim/realtime.ts
|
|
2160
2164
|
var SimRealtime = class {
|
|
2161
2165
|
seq = 0;
|
|
2162
2166
|
subscribers = /* @__PURE__ */ new Map();
|
|
@@ -2278,10 +2282,7 @@ function createSimRealtimeCapability() {
|
|
|
2278
2282
|
};
|
|
2279
2283
|
}
|
|
2280
2284
|
|
|
2281
|
-
// packages/
|
|
2282
|
-
function simDir(cwd) {
|
|
2283
|
-
return join4(cwd, ".adep", "sim");
|
|
2284
|
-
}
|
|
2285
|
+
// packages/runtime/src/sim/merge.ts
|
|
2285
2286
|
function mergeBundles(bundles) {
|
|
2286
2287
|
const capabilities = [];
|
|
2287
2288
|
const byName = /* @__PURE__ */ new Map();
|
|
@@ -2301,6 +2302,11 @@ function mergeBundles(bundles) {
|
|
|
2301
2302
|
}
|
|
2302
2303
|
return { capabilities, rpcHandlers };
|
|
2303
2304
|
}
|
|
2305
|
+
|
|
2306
|
+
// packages/cli/src/sim/runtime.ts
|
|
2307
|
+
function simDir(cwd) {
|
|
2308
|
+
return join4(cwd, ".adep", "sim");
|
|
2309
|
+
}
|
|
2304
2310
|
function jsonStorage(cwd) {
|
|
2305
2311
|
const file = join4(simDir(cwd), "db.json");
|
|
2306
2312
|
return {
|
|
@@ -2416,12 +2422,21 @@ function createSimInvokeHandler(options) {
|
|
|
2416
2422
|
};
|
|
2417
2423
|
}
|
|
2418
2424
|
|
|
2419
|
-
//
|
|
2420
|
-
var
|
|
2421
|
-
var
|
|
2422
|
-
|
|
2423
|
-
|
|
2425
|
+
// shared/builtin-deps.ts
|
|
2426
|
+
var CF_COMPAT_SPECIFIER = "@adep/cf-compat";
|
|
2427
|
+
var STATE_OBJECTS_SPECIFIER = "@adep/runtime/state-objects";
|
|
2428
|
+
var BUILTIN_DEPS = [
|
|
2429
|
+
CF_COMPAT_SPECIFIER,
|
|
2430
|
+
STATE_OBJECTS_SPECIFIER,
|
|
2431
|
+
"axios",
|
|
2432
|
+
"lodash",
|
|
2433
|
+
"dayjs",
|
|
2434
|
+
"zod"
|
|
2424
2435
|
];
|
|
2436
|
+
var BUILTIN_DEPS_CSV = BUILTIN_DEPS.join(",");
|
|
2437
|
+
|
|
2438
|
+
// packages/cli/src/builtin-deps.ts
|
|
2439
|
+
var LOCAL_BUILTIN_DEPS = [CF_COMPAT_SPECIFIER, STATE_OBJECTS_SPECIFIER];
|
|
2425
2440
|
|
|
2426
2441
|
// packages/cli/src/sim/boundary.ts
|
|
2427
2442
|
var SIM_BOUNDARIES = [
|
|
@@ -3057,9 +3072,9 @@ function loadFunctionModule(files, entry, sandboxGlobals, resolveBare) {
|
|
|
3057
3072
|
|
|
3058
3073
|
// packages/runtime/src/state-objects/loader.ts
|
|
3059
3074
|
var STATE_OBJECTS_ENTRY = "state-objects.ts";
|
|
3060
|
-
var
|
|
3075
|
+
var STATE_OBJECTS_SPECIFIER2 = "@adep/runtime/state-objects";
|
|
3061
3076
|
function resolveStateObjectSpecifier(request) {
|
|
3062
|
-
if (request ===
|
|
3077
|
+
if (request === STATE_OBJECTS_SPECIFIER2) return { StateObject };
|
|
3063
3078
|
return void 0;
|
|
3064
3079
|
}
|
|
3065
3080
|
function defaultStateSandboxGlobals() {
|
|
@@ -3381,6 +3396,19 @@ function createSandboxFetch(options) {
|
|
|
3381
3396
|
};
|
|
3382
3397
|
}
|
|
3383
3398
|
|
|
3399
|
+
// packages/runtime/src/functions/runtime/rpc-wire.ts
|
|
3400
|
+
function wireRpcResponses(port, pending) {
|
|
3401
|
+
port.on?.((message) => {
|
|
3402
|
+
const reply = message;
|
|
3403
|
+
if (reply?.type !== "rpc-response" || typeof reply.id !== "number") return;
|
|
3404
|
+
const entry = pending.get(reply.id);
|
|
3405
|
+
if (entry === void 0) return;
|
|
3406
|
+
pending.delete(reply.id);
|
|
3407
|
+
if (reply.ok === true) entry.resolve(reply.result);
|
|
3408
|
+
else entry.reject(new Error(reply.error ?? "RPC \u80FD\u529B\u8C03\u7528\u5931\u8D25"));
|
|
3409
|
+
});
|
|
3410
|
+
}
|
|
3411
|
+
|
|
3384
3412
|
// packages/runtime/src/functions/runtime/chain.ts
|
|
3385
3413
|
function isChainCapability(value) {
|
|
3386
3414
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -3452,6 +3480,11 @@ function createChainClient(capability, port, pending, nextId, spec) {
|
|
|
3452
3480
|
return makeRoot(void 0);
|
|
3453
3481
|
}
|
|
3454
3482
|
|
|
3483
|
+
// packages/runtime/src/shared/regexp.ts
|
|
3484
|
+
function escapeRegExp(text) {
|
|
3485
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3486
|
+
}
|
|
3487
|
+
|
|
3455
3488
|
// packages/runtime/src/functions/runtime/worker-entry.ts
|
|
3456
3489
|
function isRpcCapability(value) {
|
|
3457
3490
|
return typeof value === "object" && value !== null && value[RPC_CAPABILITY_KEY] === true;
|
|
@@ -3481,9 +3514,6 @@ function errorMessageOf2(error) {
|
|
|
3481
3514
|
}
|
|
3482
3515
|
return String(error);
|
|
3483
3516
|
}
|
|
3484
|
-
function escapeRegExp(text) {
|
|
3485
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
3486
|
-
}
|
|
3487
3517
|
function firstUserFrame(stack, files) {
|
|
3488
3518
|
for (const key of Object.keys(files)) {
|
|
3489
3519
|
const match = new RegExp(
|
|
@@ -3542,15 +3572,7 @@ function runWorker(input, port) {
|
|
|
3542
3572
|
const container = createCloudContainer();
|
|
3543
3573
|
const pending = /* @__PURE__ */ new Map();
|
|
3544
3574
|
let rpcId = 0;
|
|
3545
|
-
port
|
|
3546
|
-
const reply = message;
|
|
3547
|
-
if (reply?.type !== "rpc-response" || typeof reply.id !== "number") return;
|
|
3548
|
-
const entry = pending.get(reply.id);
|
|
3549
|
-
if (entry === void 0) return;
|
|
3550
|
-
pending.delete(reply.id);
|
|
3551
|
-
if (reply.ok === true) entry.resolve(reply.result);
|
|
3552
|
-
else entry.reject(new Error(reply.error ?? "RPC \u80FD\u529B\u8C03\u7528\u5931\u8D25"));
|
|
3553
|
-
});
|
|
3575
|
+
wireRpcResponses(port, pending);
|
|
3554
3576
|
for (const capability of input.capabilities ?? []) {
|
|
3555
3577
|
container.register(
|
|
3556
3578
|
capability.name,
|
|
@@ -3656,30 +3678,36 @@ if (workerPort !== null && workerData !== void 0) {
|
|
|
3656
3678
|
runWorker(workerData, port);
|
|
3657
3679
|
}
|
|
3658
3680
|
|
|
3659
|
-
// packages/cli/src/dev.ts
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3681
|
+
// packages/cli/src/dev-shared.ts
|
|
3682
|
+
import { readdir as readdir2, readFile as readFile5 } from "node:fs/promises";
|
|
3683
|
+
import { join as join8 } from "node:path";
|
|
3684
|
+
var BEARER_TOKEN_RE = /^Bearer\s+(.+)$/i;
|
|
3685
|
+
function bearerUserResolverFromEnv() {
|
|
3686
|
+
const raw = process.env.ADEP_AUTH_ISSUER;
|
|
3687
|
+
if (raw === void 0 || raw.trim() === "") return void 0;
|
|
3688
|
+
return createBearerUserResolver(raw.trim());
|
|
3689
|
+
}
|
|
3690
|
+
function createBearerUserResolver(issuer) {
|
|
3691
|
+
const userinfoUrl = `${issuer.replace(/\/+$/, "")}/oauth/userinfo`;
|
|
3692
|
+
return async (headers) => {
|
|
3693
|
+
const match = BEARER_TOKEN_RE.exec((headers["authorization"] ?? "").trim());
|
|
3694
|
+
const token = match?.[1]?.trim();
|
|
3695
|
+
if (token === void 0 || token === "") return null;
|
|
3696
|
+
try {
|
|
3697
|
+
const res = await fetch(userinfoUrl, { headers: { authorization: `Bearer ${token}` } });
|
|
3698
|
+
if (!res.ok) return null;
|
|
3699
|
+
const claims = await res.json();
|
|
3700
|
+
if (typeof claims.sub !== "string" || claims.sub.length === 0) return null;
|
|
3701
|
+
return {
|
|
3702
|
+
id: claims.sub,
|
|
3703
|
+
...typeof claims.name === "string" ? { name: claims.name } : {},
|
|
3704
|
+
...typeof claims.email === "string" ? { email: claims.email } : {}
|
|
3705
|
+
};
|
|
3706
|
+
} catch {
|
|
3707
|
+
return null;
|
|
3708
|
+
}
|
|
3668
3709
|
};
|
|
3669
3710
|
}
|
|
3670
|
-
function parseEnvFile(content) {
|
|
3671
|
-
const env = {};
|
|
3672
|
-
for (const raw of content.split(/\r?\n/)) {
|
|
3673
|
-
const line = raw.trim();
|
|
3674
|
-
if (line.length === 0 || line.startsWith("#")) continue;
|
|
3675
|
-
const eq = line.indexOf("=");
|
|
3676
|
-
if (eq === -1) continue;
|
|
3677
|
-
const key = line.slice(0, eq).trim();
|
|
3678
|
-
if (key.length === 0) continue;
|
|
3679
|
-
env[key] = line.slice(eq + 1).trim();
|
|
3680
|
-
}
|
|
3681
|
-
return env;
|
|
3682
|
-
}
|
|
3683
3711
|
async function collectFunctions(dir) {
|
|
3684
3712
|
const files = {};
|
|
3685
3713
|
const walk = async (sub, prefix) => {
|
|
@@ -3721,6 +3749,42 @@ function bodyOf(req) {
|
|
|
3721
3749
|
req.on("error", rejectBody);
|
|
3722
3750
|
});
|
|
3723
3751
|
}
|
|
3752
|
+
function writeJson(res, status, payload) {
|
|
3753
|
+
res.writeHead(status, { "content-type": "application/json" });
|
|
3754
|
+
res.end(JSON.stringify(payload));
|
|
3755
|
+
}
|
|
3756
|
+
async function requestInput(url, req, readBody) {
|
|
3757
|
+
const query = {};
|
|
3758
|
+
for (const key of new Set(url.searchParams.keys())) {
|
|
3759
|
+
const values = url.searchParams.getAll(key);
|
|
3760
|
+
query[key] = values.length > 1 ? values.join(",") : values[0] ?? "";
|
|
3761
|
+
}
|
|
3762
|
+
const headers = {};
|
|
3763
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
3764
|
+
if (typeof value === "string") headers[key] = value;
|
|
3765
|
+
}
|
|
3766
|
+
const body = req.method === "GET" || req.method === "HEAD" ? void 0 : await readBody(req);
|
|
3767
|
+
return {
|
|
3768
|
+
method: req.method ?? "GET",
|
|
3769
|
+
path: url.pathname,
|
|
3770
|
+
query,
|
|
3771
|
+
headers,
|
|
3772
|
+
...body === void 0 ? {} : { body }
|
|
3773
|
+
};
|
|
3774
|
+
}
|
|
3775
|
+
|
|
3776
|
+
// packages/cli/src/dev.ts
|
|
3777
|
+
async function loadConfig(cwd) {
|
|
3778
|
+
const name = basename(resolve2(cwd));
|
|
3779
|
+
const config = await loadAdepConfigModule(cwd);
|
|
3780
|
+
return {
|
|
3781
|
+
name: config?.name ?? name,
|
|
3782
|
+
functionsDir: config?.functionsDir ?? "functions",
|
|
3783
|
+
functionsPrefix: config?.functions_prefix ?? "",
|
|
3784
|
+
...config?.environment === void 0 ? {} : { environment: config.environment }
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
var parseEnvFile = parseEnv;
|
|
3724
3788
|
function resolveRouteFnName(pathname, prefix) {
|
|
3725
3789
|
const segments = pathname.split("/").filter((segment) => segment.length > 0);
|
|
3726
3790
|
const normalizedPrefix = prefix.replace(/^\/+|\/+$/g, "");
|
|
@@ -3747,10 +3811,6 @@ function resolveRouteFnName(pathname, prefix) {
|
|
|
3747
3811
|
}
|
|
3748
3812
|
return { fnName: second };
|
|
3749
3813
|
}
|
|
3750
|
-
function writeJson(res, status, payload) {
|
|
3751
|
-
res.writeHead(status, { "content-type": "application/json" });
|
|
3752
|
-
res.end(JSON.stringify(payload));
|
|
3753
|
-
}
|
|
3754
3814
|
function printBoundaries(log) {
|
|
3755
3815
|
log("[adep] \u80FD\u529B\u8FB9\u754C\uFF08\u6A21\u62DF\u8FD0\u884C\u65F6\u53EA\u66FF\u6362\u4F20\u8F93/\u6301\u4E45\u5316\uFF0C\u4E0D\u6539\u5199\u8BED\u4E49\uFF09\uFF1A");
|
|
3756
3816
|
for (const b of SIM_BOUNDARIES) {
|
|
@@ -3758,8 +3818,8 @@ function printBoundaries(log) {
|
|
|
3758
3818
|
}
|
|
3759
3819
|
}
|
|
3760
3820
|
async function ensureGitignore(cwd) {
|
|
3761
|
-
const gitignorePath =
|
|
3762
|
-
const existing = await
|
|
3821
|
+
const gitignorePath = join9(cwd, ".gitignore");
|
|
3822
|
+
const existing = await readFile6(gitignorePath, "utf8").catch(() => "");
|
|
3763
3823
|
if (existing.split(/\r?\n/).includes(".adep/")) return;
|
|
3764
3824
|
await writeFile3(gitignorePath, `${existing.replace(/\n+$/, "")}
|
|
3765
3825
|
.adep/
|
|
@@ -3773,8 +3833,9 @@ async function startDevServer(options) {
|
|
|
3773
3833
|
if (options.prefix !== void 0) {
|
|
3774
3834
|
config.functionsPrefix = options.prefix.replace(/^\/+|\/+$/g, "");
|
|
3775
3835
|
}
|
|
3776
|
-
const functionsDir =
|
|
3836
|
+
const functionsDir = join9(cwd, config.functionsDir);
|
|
3777
3837
|
const coldStartAt = Date.now();
|
|
3838
|
+
const bearerUser = bearerUserResolverFromEnv();
|
|
3778
3839
|
const executor = new WorkerFunctionExecutor({
|
|
3779
3840
|
deps: { rootDir: cwd, builtin: LOCAL_BUILTIN_DEPS }
|
|
3780
3841
|
});
|
|
@@ -3865,12 +3926,12 @@ async function startDevServer(options) {
|
|
|
3865
3926
|
const reload = async () => {
|
|
3866
3927
|
const [nextFiles, envText2] = await Promise.all([
|
|
3867
3928
|
collectFunctions(functionsDir),
|
|
3868
|
-
|
|
3929
|
+
readFile6(join9(cwd, ".env.local"), "utf8").catch(() => "")
|
|
3869
3930
|
]);
|
|
3870
3931
|
files = nextFiles;
|
|
3871
3932
|
env = { ...config.environment, ...parseEnvFile(envText2) };
|
|
3872
3933
|
};
|
|
3873
|
-
const envText = await
|
|
3934
|
+
const envText = await readFile6(join9(cwd, ".env.local"), "utf8").catch(() => "");
|
|
3874
3935
|
env = { ...config.environment, ...parseEnvFile(envText) };
|
|
3875
3936
|
let debounceTimer;
|
|
3876
3937
|
let watcher;
|
|
@@ -3885,29 +3946,15 @@ async function startDevServer(options) {
|
|
|
3885
3946
|
watcher = void 0;
|
|
3886
3947
|
}
|
|
3887
3948
|
const buildInput = async (fnName, entry, url, req) => {
|
|
3888
|
-
const query = {};
|
|
3889
|
-
for (const key of new Set(url.searchParams.keys())) {
|
|
3890
|
-
const values = url.searchParams.getAll(key);
|
|
3891
|
-
query[key] = values.length > 1 ? values.join(",") : values[0] ?? "";
|
|
3892
|
-
}
|
|
3893
|
-
const headers = {};
|
|
3894
|
-
for (const [key, value] of Object.entries(req.headers)) {
|
|
3895
|
-
if (typeof value === "string") headers[key] = value;
|
|
3896
|
-
}
|
|
3897
|
-
const body = req.method === "GET" || req.method === "HEAD" ? void 0 : await bodyOf(req);
|
|
3898
3949
|
const hasEnv = Object.keys(env).length > 0;
|
|
3950
|
+
const request = await requestInput(url, req, bodyOf);
|
|
3951
|
+
if (bearerUser !== void 0) request.user = await bearerUser(request.headers);
|
|
3899
3952
|
return {
|
|
3900
3953
|
project: { id: "local", slug: config.name },
|
|
3901
3954
|
fn: { id: fnName, name: fnName },
|
|
3902
3955
|
files,
|
|
3903
3956
|
entry,
|
|
3904
|
-
request
|
|
3905
|
-
method: req.method ?? "GET",
|
|
3906
|
-
path: url.pathname,
|
|
3907
|
-
query,
|
|
3908
|
-
headers,
|
|
3909
|
-
...body === void 0 ? {} : { body }
|
|
3910
|
-
},
|
|
3957
|
+
request,
|
|
3911
3958
|
// 模拟运行时能力:db / storage / realtime 各自只读复用线上装配,语义一致。
|
|
3912
3959
|
capabilities: dbBundle.capabilities,
|
|
3913
3960
|
rpcHandlers: {
|
|
@@ -4044,6 +4091,9 @@ async function startDevServer(options) {
|
|
|
4044
4091
|
log(`[adep] dev server listening on ${baseUrl}\uFF08\u6A21\u62DF\u8FD0\u884C\u65F6\uFF0C\u51B7\u542F\u52A8 ${coldStartMs}ms\uFF09`);
|
|
4045
4092
|
log(`[adep] curl \u793A\u4F8B\uFF1Acurl ${baseUrl}${curlPath}`);
|
|
4046
4093
|
printBoundaries(log);
|
|
4094
|
+
if (bearerUser !== void 0) {
|
|
4095
|
+
log(`[adep] \u767B\u5F55\u5373\u670D\u52A1\uFF1AADEP_AUTH_ISSUER \u5DF2\u914D\u7F6E\uFF0CBearer token \u5C06\u89E3\u6790\u4E3A\u7528\u6237\u8EAB\u4EFD\uFF08userinfo \u7AEF\u70B9\uFF09`);
|
|
4096
|
+
}
|
|
4047
4097
|
log(`[adep] \u6A21\u62DF\u6570\u636E\u76EE\u5F55\uFF1A${simDir(cwd)}`);
|
|
4048
4098
|
startStateAlarmScheduler();
|
|
4049
4099
|
return {
|
package/dist/worker-entry.js
CHANGED
|
@@ -434,6 +434,19 @@ var DB_RPC = {
|
|
|
434
434
|
chain: "chain"
|
|
435
435
|
};
|
|
436
436
|
|
|
437
|
+
// packages/runtime/src/functions/runtime/rpc-wire.ts
|
|
438
|
+
function wireRpcResponses(port, pending) {
|
|
439
|
+
port.on?.((message) => {
|
|
440
|
+
const reply = message;
|
|
441
|
+
if (reply?.type !== "rpc-response" || typeof reply.id !== "number") return;
|
|
442
|
+
const entry = pending.get(reply.id);
|
|
443
|
+
if (entry === void 0) return;
|
|
444
|
+
pending.delete(reply.id);
|
|
445
|
+
if (reply.ok === true) entry.resolve(reply.result);
|
|
446
|
+
else entry.reject(new Error(reply.error ?? "RPC \u80FD\u529B\u8C03\u7528\u5931\u8D25"));
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
437
450
|
// packages/runtime/src/functions/runtime/chain.ts
|
|
438
451
|
function isChainCapability(value) {
|
|
439
452
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -514,6 +527,11 @@ function splitBareSpecifier(request) {
|
|
|
514
527
|
return request.split("/")[0];
|
|
515
528
|
}
|
|
516
529
|
|
|
530
|
+
// packages/runtime/src/shared/regexp.ts
|
|
531
|
+
function escapeRegExp(text) {
|
|
532
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
533
|
+
}
|
|
534
|
+
|
|
517
535
|
// packages/runtime/src/functions/runtime/worker-entry.ts
|
|
518
536
|
function isRpcCapability(value) {
|
|
519
537
|
return typeof value === "object" && value !== null && value[RPC_CAPABILITY_KEY] === true;
|
|
@@ -543,9 +561,6 @@ function errorMessageOf2(error) {
|
|
|
543
561
|
}
|
|
544
562
|
return String(error);
|
|
545
563
|
}
|
|
546
|
-
function escapeRegExp(text) {
|
|
547
|
-
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
548
|
-
}
|
|
549
564
|
function firstUserFrame(stack, files) {
|
|
550
565
|
for (const key of Object.keys(files)) {
|
|
551
566
|
const match = new RegExp(
|
|
@@ -604,15 +619,7 @@ function runWorker(input, port) {
|
|
|
604
619
|
const container = createCloudContainer();
|
|
605
620
|
const pending = /* @__PURE__ */ new Map();
|
|
606
621
|
let rpcId = 0;
|
|
607
|
-
port
|
|
608
|
-
const reply = message;
|
|
609
|
-
if (reply?.type !== "rpc-response" || typeof reply.id !== "number") return;
|
|
610
|
-
const entry = pending.get(reply.id);
|
|
611
|
-
if (entry === void 0) return;
|
|
612
|
-
pending.delete(reply.id);
|
|
613
|
-
if (reply.ok === true) entry.resolve(reply.result);
|
|
614
|
-
else entry.reject(new Error(reply.error ?? "RPC \u80FD\u529B\u8C03\u7528\u5931\u8D25"));
|
|
615
|
-
});
|
|
622
|
+
wireRpcResponses(port, pending);
|
|
616
623
|
for (const capability of input.capabilities ?? []) {
|
|
617
624
|
container.register(
|
|
618
625
|
capability.name,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adep/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "`adep` 命令行工具包位:登录 / 初始化 / 本地调试 / 部署 / 数据库维护 / 云存储 / 静态托管 / 微前端组件(widget),实现见任务单 CLI-001 ~ CLI-003 与 FE-002;子路径 `@adep/cli/vite` 提供云函数 vite 插件(CLI-014)",
|
|
6
6
|
"bin": {
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"commander": "14.0.2",
|
|
22
22
|
"esbuild": "0.25.12",
|
|
23
23
|
"@adep/cf-compat": "0.1.1",
|
|
24
|
-
"@adep/vite-plugin": "0.1.
|
|
24
|
+
"@adep/vite-plugin": "0.1.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@adep/runtime": "0.2.
|
|
28
|
-
"@adep/types": "0.2.
|
|
27
|
+
"@adep/runtime": "0.2.3",
|
|
28
|
+
"@adep/types": "0.2.3"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"test": "vitest run",
|