@vite-hub/queue 0.3.1 → 0.5.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/README.md +22 -20
- package/dist/{client-Cj50hQYp.js → client-DYE_ZV8c.js} +11 -10
- package/dist/{cloudflare-client-DYsAjM8B.js → cloudflare-client-BasaJ68s.js} +22 -9
- package/dist/{cloudflare-resource-name-BJHYRCMQ.js → cloudflare-resource-name-BUNNqgkg.js} +1 -1
- package/dist/{config-BcTDeQIP.js → config-YEuaeQVq.js} +1 -3
- package/dist/definition-BL_3WHNu.js +27 -0
- package/dist/{errors-DL3pcNO4.js → duration-CshzgSSx.js} +48 -6
- package/dist/{error-diagnostics-DSkCJC_L.js → error-diagnostics-C0KyI408.js} +10 -2
- package/dist/{error-diagnostics-BRartC1z.js → error-diagnostics-DukggGP6.js} +14 -10
- package/dist/{handler-response-By0Fpspv.js → handler-response-ChtAjPNo.js} +8 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +4 -12
- package/dist/internal/runtime/cloudflare-client.d.ts +1 -1
- package/dist/internal/runtime/cloudflare-client.js +1 -1
- package/dist/internal/runtime/cloudflare-vite.d.ts +1 -1
- package/dist/internal/runtime/cloudflare-vite.js +10 -9
- package/dist/internal/runtime/local-client.d.ts +3 -3
- package/dist/internal/runtime/local-client.js +4 -4
- package/dist/internal/runtime/postgres-client.d.ts +5 -4
- package/dist/internal/runtime/postgres-client.js +34 -17
- package/dist/internal/runtime/state.d.ts +2 -2
- package/dist/internal/runtime/state.js +1 -1
- package/dist/internal/runtime/vercel-client.d.ts +1 -1
- package/dist/internal/runtime/vercel-client.js +23 -12
- package/dist/internal/runtime/worker-client.d.ts +2 -2
- package/dist/internal/runtime/worker-client.js +1 -1
- package/dist/{local-CGckW5nr.js → local-CnBd5jdm.js} +50 -31
- package/dist/{local-CVVRVWeR.d.ts → local-DAL5ZgDg.d.ts} +2 -1
- package/dist/{operation-definition-8gOe-ubD.d.ts → operation-definition-CI2PJGqu.d.ts} +13 -2
- package/dist/{operations-Crwjca91.js → operations-BL0b9pte.js} +10 -11
- package/dist/operations.d.ts +5 -4
- package/dist/operations.js +16 -48
- package/dist/runtime/hosted.d.ts +1 -1
- package/dist/runtime/hosted.js +4 -4
- package/dist/scan-module-BbqyaLl6.js +311 -0
- package/dist/{state-mVA2X_wa.js → state-ER1YdCBF.js} +1 -1
- package/dist/{types-DS_rqu9l.d.ts → types-D6hDNcMY.d.ts} +1 -2
- package/dist/{types-BD-8U9zS.d.ts → types-klaR79hV.d.ts} +50 -24
- package/dist/{vercel-region-D1CivgdA.js → vercel-region-DOciq2kx.js} +1 -1
- package/dist/vite.d.ts +10 -4
- package/dist/vite.js +123 -94
- package/package.json +4 -4
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as queueErrorDiagnostics } from "./error-diagnostics-
|
|
2
|
-
import {
|
|
3
|
-
import { i as getQueueRuntimeConfig, o as getQueueRuntimeJobStore, s as listQueueDefinitionNames } from "./state-
|
|
4
|
-
import { n as dynamicQueue } from "./client-
|
|
1
|
+
import { t as queueErrorDiagnostics } from "./error-diagnostics-DukggGP6.js";
|
|
2
|
+
import { a as normalizePublicQueueIdentifier, r as isQueueError } from "./duration-CshzgSSx.js";
|
|
3
|
+
import { i as getQueueRuntimeConfig, o as getQueueRuntimeJobStore, s as listQueueDefinitionNames } from "./state-ER1YdCBF.js";
|
|
4
|
+
import { n as dynamicQueue } from "./client-DYE_ZV8c.js";
|
|
5
5
|
import { t as redactInspectionText } from "./inspect-PeuckaC3.js";
|
|
6
|
+
import { runtimeErrorDiagnostics } from "@vite-hub/runtime/internal/error-diagnostics";
|
|
6
7
|
//#region src/runtime/operations.ts
|
|
7
|
-
/** The HTTP status that the CLI, the Console, and Agents report for each code of a failed operation. */
|
|
8
8
|
const statuses = {
|
|
9
9
|
QUEUE_DEFINITION_NAME_INVALID: 400,
|
|
10
10
|
QUEUE_DEFINITION_NOT_FOUND: 404,
|
|
@@ -17,8 +17,11 @@ const statuses = {
|
|
|
17
17
|
QUEUE_PROVIDER_INVALID_RESPONSE: 502,
|
|
18
18
|
QUEUE_UNSUPPORTED_OPTION: 400
|
|
19
19
|
};
|
|
20
|
-
/** Gives a Queue catalog error the status and the redacted message that the CLI and the Console report. */
|
|
21
20
|
function failure(error) {
|
|
21
|
+
if (runtimeErrorDiagnostics.RUNTIME_DURATION_INVALID.is(error)) return Object.assign(error, {
|
|
22
|
+
status: 400,
|
|
23
|
+
statusMessage: redactInspectionText(error.message)
|
|
24
|
+
});
|
|
22
25
|
if (!isQueueError(error)) return error;
|
|
23
26
|
return Object.assign(error, {
|
|
24
27
|
status: statuses[error.code] ?? 500,
|
|
@@ -62,7 +65,7 @@ async function sendToQueue(input) {
|
|
|
62
65
|
const queue = normalizePublicQueueIdentifier(input.queue);
|
|
63
66
|
if (!queue) throw failure(queueErrorDiagnostics.QUEUE_DEFINITION_NAME_INVALID());
|
|
64
67
|
const options = {
|
|
65
|
-
...input.
|
|
68
|
+
...input.delay === void 0 ? {} : { delay: input.delay },
|
|
66
69
|
...input.idempotencyKey === void 0 ? {} : { idempotencyKey: input.idempotencyKey }
|
|
67
70
|
};
|
|
68
71
|
let result;
|
|
@@ -81,10 +84,6 @@ async function sendToQueue(input) {
|
|
|
81
84
|
status: "queued"
|
|
82
85
|
};
|
|
83
86
|
}
|
|
84
|
-
/**
|
|
85
|
-
* The stored jobs of the local or postgres provider. Cloudflare and Vercel do not let a producer read their queue, so
|
|
86
|
-
* their jobs do not list.
|
|
87
|
-
*/
|
|
88
87
|
async function localJobs() {
|
|
89
88
|
const config = getQueueRuntimeConfig();
|
|
90
89
|
if (config === false) throw failure(queueErrorDiagnostics.QUEUE_DISABLED());
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./local-
|
|
3
|
-
import { t as AnyOperation } from "./operation-definition-
|
|
1
|
+
import { A as QueueJobStore, d as LocalQueueJob, f as LocalQueueJobDetail, h as LocalQueueStatus, p as LocalQueueRules, w as QueueDriver } from "./types-klaR79hV.js";
|
|
2
|
+
import "./local-DAL5ZgDg.js";
|
|
3
|
+
import { t as AnyOperation } from "./operation-definition-CI2PJGqu.js";
|
|
4
4
|
//#region src/runtime/operations.d.ts
|
|
5
5
|
interface QueueListResult {
|
|
6
6
|
/** `undefined` when the runtime has not installed a Queue configuration. */
|
|
@@ -52,7 +52,8 @@ interface QueueSendOperationResult {
|
|
|
52
52
|
status: "queued";
|
|
53
53
|
}
|
|
54
54
|
interface QueueSendOperationInput {
|
|
55
|
-
|
|
55
|
+
/** Time before delivery, such as `"1m"`. The send reads it, and a wrong one fails with `RUNTIME_DURATION_INVALID`. */
|
|
56
|
+
delay?: string;
|
|
56
57
|
idempotencyKey?: string;
|
|
57
58
|
payload: unknown;
|
|
58
59
|
queue: string;
|
package/dist/operations.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as internalErrorDiagnostics } from "./error-diagnostics-DSkCJC_L.js";
|
|
2
1
|
import { r as isRecordOrFunction } from "./object-D8pRdprI.js";
|
|
2
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-C0KyI408.js";
|
|
3
3
|
//#region ../internal/src/standard-schema.ts
|
|
4
4
|
function readOwn(value, key) {
|
|
5
5
|
if (value === null || Object(value) !== value) return;
|
|
@@ -934,20 +934,20 @@ function _standardSchema(schema) {
|
|
|
934
934
|
};
|
|
935
935
|
return schema;
|
|
936
936
|
}
|
|
937
|
+
/**
|
|
938
|
+
* Creates a description metadata action.
|
|
939
|
+
*
|
|
940
|
+
* @param description_ The description text.
|
|
941
|
+
*
|
|
942
|
+
* @returns A description action.
|
|
943
|
+
*/
|
|
937
944
|
/* @__NO_SIDE_EFFECTS__ */
|
|
938
|
-
function
|
|
945
|
+
function description(description_) {
|
|
939
946
|
return {
|
|
940
|
-
kind: "
|
|
941
|
-
type: "
|
|
942
|
-
reference:
|
|
943
|
-
|
|
944
|
-
expects: null,
|
|
945
|
-
requirement: Number.isInteger,
|
|
946
|
-
message: message$1,
|
|
947
|
-
"~run"(dataset, config$1) {
|
|
948
|
-
if (dataset.typed && !this.requirement(dataset.value)) _addIssue(this, "integer", dataset, config$1);
|
|
949
|
-
return dataset;
|
|
950
|
-
}
|
|
947
|
+
kind: "metadata",
|
|
948
|
+
type: "description",
|
|
949
|
+
reference: description,
|
|
950
|
+
description: description_
|
|
951
951
|
};
|
|
952
952
|
}
|
|
953
953
|
/* @__NO_SIDE_EFFECTS__ */
|
|
@@ -966,22 +966,6 @@ function minLength(requirement, message$1) {
|
|
|
966
966
|
}
|
|
967
967
|
};
|
|
968
968
|
}
|
|
969
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
970
|
-
function minValue(requirement, message$1) {
|
|
971
|
-
return {
|
|
972
|
-
kind: "validation",
|
|
973
|
-
type: "min_value",
|
|
974
|
-
reference: minValue,
|
|
975
|
-
async: false,
|
|
976
|
-
expects: `>=${requirement instanceof Date ? requirement.toJSON() : /* @__PURE__ */ _stringify(requirement)}`,
|
|
977
|
-
requirement,
|
|
978
|
-
message: message$1,
|
|
979
|
-
"~run"(dataset, config$1) {
|
|
980
|
-
if (dataset.typed && !(dataset.value >= this.requirement)) _addIssue(this, "value", dataset, config$1, { received: dataset.value instanceof Date ? dataset.value.toJSON() : /* @__PURE__ */ _stringify(dataset.value) });
|
|
981
|
-
return dataset;
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
}
|
|
985
969
|
/**
|
|
986
970
|
* Returns the fallback value of the schema.
|
|
987
971
|
*
|
|
@@ -1009,22 +993,6 @@ function getDefault(schema, dataset, config$1) {
|
|
|
1009
993
|
return typeof schema.default === "function" ? schema.default(dataset, config$1) : schema.default;
|
|
1010
994
|
}
|
|
1011
995
|
/* @__NO_SIDE_EFFECTS__ */
|
|
1012
|
-
function number(message$1) {
|
|
1013
|
-
return _standardSchema({
|
|
1014
|
-
kind: "schema",
|
|
1015
|
-
type: "number",
|
|
1016
|
-
reference: number,
|
|
1017
|
-
expects: "number",
|
|
1018
|
-
async: false,
|
|
1019
|
-
message: message$1,
|
|
1020
|
-
"~run"(dataset, config$1) {
|
|
1021
|
-
if (typeof dataset.value === "number" && !isNaN(dataset.value)) dataset.typed = true;
|
|
1022
|
-
else _addIssue(this, "type", dataset, config$1);
|
|
1023
|
-
return dataset;
|
|
1024
|
-
}
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
1028
996
|
function optional(wrapped, default_) {
|
|
1029
997
|
return _standardSchema({
|
|
1030
998
|
kind: "schema",
|
|
@@ -1195,7 +1163,7 @@ function pipe(...pipe$1) {
|
|
|
1195
1163
|
}
|
|
1196
1164
|
//#endregion
|
|
1197
1165
|
//#region src/operations.ts
|
|
1198
|
-
const runtime = () => import("./operations-
|
|
1166
|
+
const runtime = () => import("./operations-BL0b9pte.js");
|
|
1199
1167
|
function defineQueueOperation(definition) {
|
|
1200
1168
|
return defineOperation({
|
|
1201
1169
|
...definition,
|
|
@@ -1218,7 +1186,7 @@ const send = defineQueueOperation({
|
|
|
1218
1186
|
},
|
|
1219
1187
|
description: "Send one job to a Queue Definition. The payload is a JSON value.",
|
|
1220
1188
|
input: /* @__PURE__ */ strictObject({
|
|
1221
|
-
|
|
1189
|
+
delay: /* @__PURE__ */ optional(/* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1), /* @__PURE__ */ description("Time before delivery, such as 1m or 30s."))),
|
|
1222
1190
|
idempotencyKey: /* @__PURE__ */ optional(/* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1))),
|
|
1223
1191
|
payload: /* @__PURE__ */ unknown(),
|
|
1224
1192
|
queue: /* @__PURE__ */ pipe(/* @__PURE__ */ string(), /* @__PURE__ */ minLength(1))
|
|
@@ -1300,7 +1268,7 @@ const queueOperations = [
|
|
|
1300
1268
|
}),
|
|
1301
1269
|
defineQueueOperation({
|
|
1302
1270
|
cli: {
|
|
1303
|
-
command: "jobs
|
|
1271
|
+
command: "jobs get",
|
|
1304
1272
|
format: formatJob,
|
|
1305
1273
|
namespace: "queue",
|
|
1306
1274
|
positional: ["id"]
|
package/dist/runtime/hosted.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as QueueDefinition } from "../types-klaR79hV.js";
|
|
2
2
|
//#region src/runtime/hosted.d.ts
|
|
3
3
|
export declare const hostedVercelWaitUntil: (promise: Promise<unknown>) => void | undefined;
|
|
4
4
|
/** Handle one Vercel Queue delivery. The generated consumer route is a Fetchable module that passes its Request here. */
|
package/dist/runtime/hosted.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as queueErrorDiagnostics } from "../error-diagnostics-
|
|
2
|
-
import { n as dynamicQueue } from "../client-
|
|
3
|
-
import { i as reportQueueDeliveryError, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "../handler-response-
|
|
1
|
+
import { t as queueErrorDiagnostics } from "../error-diagnostics-DukggGP6.js";
|
|
2
|
+
import { n as dynamicQueue } from "../client-DYE_ZV8c.js";
|
|
3
|
+
import { i as reportQueueDeliveryError, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "../handler-response-ChtAjPNo.js";
|
|
4
4
|
import { runInRunScopes } from "@vite-hub/runtime/internal/run-scope";
|
|
5
5
|
import { waitUntil } from "@vercel/functions";
|
|
6
6
|
//#region src/runtime/hosted.ts
|
|
@@ -43,7 +43,7 @@ async function handleHostedVercelQueueCallback(request, name, definition) {
|
|
|
43
43
|
driver: queue.provider,
|
|
44
44
|
expected: "vercel"
|
|
45
45
|
});
|
|
46
|
-
const result = await queue.callback(createVercelJobHandler(definition), createVercelCallbackOptions(name, definition.
|
|
46
|
+
const result = await queue.callback(createVercelJobHandler(definition), createVercelCallbackOptions(name, definition.callbackOptions))(request);
|
|
47
47
|
if (result instanceof Response) return result;
|
|
48
48
|
return result === void 0 ? new Response(null, { status: 204 }) : Response.json(result);
|
|
49
49
|
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { parseSync } from "vite";
|
|
2
|
+
//#region ../internal/src/build/ast-walk.ts
|
|
3
|
+
/** The oxc parser grammar for a file, from its extension. Defaults to TypeScript. */
|
|
4
|
+
function moduleLanguage(file) {
|
|
5
|
+
if (/\.(?:c|m)?tsx$/i.test(file)) return "tsx";
|
|
6
|
+
if (/\.(?:c|m)?jsx$/i.test(file)) return "jsx";
|
|
7
|
+
if (/\.(?:c|m)?js$/i.test(file)) return "js";
|
|
8
|
+
return "ts";
|
|
9
|
+
}
|
|
10
|
+
function isNode(value) {
|
|
11
|
+
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string";
|
|
12
|
+
}
|
|
13
|
+
/** Visits `node` and its descendants. Return `false` from `visit` to skip the children of a node. */
|
|
14
|
+
function walk(node, visit, parent) {
|
|
15
|
+
if (visit(node, parent) === false) return;
|
|
16
|
+
const fields = node;
|
|
17
|
+
for (const key in fields) {
|
|
18
|
+
const child = fields[key];
|
|
19
|
+
if (typeof child !== "object" || child === null || key === "parent") continue;
|
|
20
|
+
if (Array.isArray(child)) {
|
|
21
|
+
for (const item of child) if (isNode(item)) walk(item, visit, node);
|
|
22
|
+
} else if (isNode(child)) walk(child, visit, node);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region ../internal/src/build/scan-module.ts
|
|
27
|
+
/**
|
|
28
|
+
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
29
|
+
* the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
|
|
30
|
+
* `dynamic`, so callers can report their own diagnostics.
|
|
31
|
+
*/
|
|
32
|
+
/** The value of an expression that the scanner cannot read without running the module. */
|
|
33
|
+
const dynamic = Symbol("dynamic");
|
|
34
|
+
/** Parses a module once. `file` selects the grammar from its extension and defaults to TypeScript. */
|
|
35
|
+
function scanModule(source, file = "module.ts") {
|
|
36
|
+
const result = parseSync(file, source, {
|
|
37
|
+
lang: moduleLanguage(file),
|
|
38
|
+
preserveParens: false,
|
|
39
|
+
sourceType: "module"
|
|
40
|
+
});
|
|
41
|
+
return {
|
|
42
|
+
comments: result.comments,
|
|
43
|
+
errors: result.errors,
|
|
44
|
+
file,
|
|
45
|
+
program: result.program,
|
|
46
|
+
source
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** Lists the names that a module exports. A default export reads as `default`. Type-only exports are left out. */
|
|
50
|
+
function exportNames(source, file = "module.ts") {
|
|
51
|
+
const { module } = parseSync(file, source, {
|
|
52
|
+
lang: moduleLanguage(file),
|
|
53
|
+
sourceType: "module"
|
|
54
|
+
});
|
|
55
|
+
return module.staticExports.flatMap((statement) => statement.entries).flatMap((entry) => {
|
|
56
|
+
if (entry.isType) return [];
|
|
57
|
+
if (entry.exportName.kind === "Default") return ["default"];
|
|
58
|
+
return entry.exportName.name === null ? [] : [entry.exportName.name];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/** The source text of a node. */
|
|
62
|
+
function nodeText(module, node) {
|
|
63
|
+
return module.source.slice(node.start, node.end);
|
|
64
|
+
}
|
|
65
|
+
/** Removes parentheses, `as`, `satisfies`, `!`, and `<T>` assertions around an expression. */
|
|
66
|
+
function unwrapExpression(node) {
|
|
67
|
+
while (node.type === "ParenthesizedExpression" || node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression" || node.type === "TSTypeAssertion") node = node.expression;
|
|
68
|
+
return node;
|
|
69
|
+
}
|
|
70
|
+
/** A call argument without assertions, or undefined for a spread or missing argument. */
|
|
71
|
+
function argumentExpression(argument) {
|
|
72
|
+
return argument === void 0 || argument.type === "SpreadElement" ? void 0 : unwrapExpression(argument);
|
|
73
|
+
}
|
|
74
|
+
/** Calls whose callee is a plain identifier in `names`, such as `defineCollection(...)`, in source order. */
|
|
75
|
+
function findCalls(module, names) {
|
|
76
|
+
const wanted = new Set(names);
|
|
77
|
+
const calls = [];
|
|
78
|
+
walk(module.program, (node) => {
|
|
79
|
+
if (node.type === "CallExpression" && node.callee.type === "Identifier" && wanted.has(node.callee.name)) calls.push(node);
|
|
80
|
+
});
|
|
81
|
+
return calls.sort((left, right) => left.start - right.start);
|
|
82
|
+
}
|
|
83
|
+
/** The expression of `export default <expression>`, without assertions. Declarations return undefined. */
|
|
84
|
+
function defaultExportExpression(module) {
|
|
85
|
+
for (const statement of module.program.body) {
|
|
86
|
+
if (statement.type !== "ExportDefaultDeclaration") continue;
|
|
87
|
+
const declaration = statement.declaration;
|
|
88
|
+
if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration" || declaration.type === "TSInterfaceDeclaration") return;
|
|
89
|
+
return unwrapExpression(declaration);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Finds `export default defineX({ ... })` for one of `names`. With `positionalOptionsIndex`, a call whose first
|
|
94
|
+
* argument is not an object and that has more than one argument reads its options from that argument. Returns
|
|
95
|
+
* undefined when the options are not an object literal.
|
|
96
|
+
*/
|
|
97
|
+
function findDefaultExportCall(module, names, options = {}) {
|
|
98
|
+
const call = defaultExportExpression(module);
|
|
99
|
+
if (call?.type !== "CallExpression" || call.callee.type !== "Identifier" || !names.includes(call.callee.name)) return;
|
|
100
|
+
const name = call.callee.name;
|
|
101
|
+
const first = argumentExpression(call.arguments[0]);
|
|
102
|
+
if (first?.type === "ObjectExpression") return {
|
|
103
|
+
call,
|
|
104
|
+
name,
|
|
105
|
+
options: first
|
|
106
|
+
};
|
|
107
|
+
if (options.positionalOptionsIndex === void 0 || first === void 0 || call.arguments.length < 2) return;
|
|
108
|
+
const positional = call.arguments[options.positionalOptionsIndex];
|
|
109
|
+
if (positional === void 0) return {
|
|
110
|
+
call,
|
|
111
|
+
name
|
|
112
|
+
};
|
|
113
|
+
const object = argumentExpression(positional);
|
|
114
|
+
return object?.type === "ObjectExpression" ? {
|
|
115
|
+
call,
|
|
116
|
+
name,
|
|
117
|
+
options: object
|
|
118
|
+
} : void 0;
|
|
119
|
+
}
|
|
120
|
+
function staticKey(property) {
|
|
121
|
+
const key = property.key;
|
|
122
|
+
if (key.type === "Identifier" && !property.computed) return key.name;
|
|
123
|
+
if (key.type === "PrivateIdentifier") return;
|
|
124
|
+
const value = staticValue(key);
|
|
125
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "bigint" ? String(value) : void 0;
|
|
126
|
+
}
|
|
127
|
+
/** The members of an object literal in source order. */
|
|
128
|
+
function objectProperties(object) {
|
|
129
|
+
return object.properties.map((node) => node.type === "SpreadElement" ? {
|
|
130
|
+
computed: false,
|
|
131
|
+
key: void 0,
|
|
132
|
+
node,
|
|
133
|
+
value: void 0
|
|
134
|
+
} : {
|
|
135
|
+
computed: node.computed,
|
|
136
|
+
key: staticKey(node),
|
|
137
|
+
node,
|
|
138
|
+
value: unwrapExpression(node.value)
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/** The last member named `name`, which is the one that the object keeps at runtime. */
|
|
142
|
+
function findProperty(object, name) {
|
|
143
|
+
return objectProperties(object).findLast((property) => property.key === name);
|
|
144
|
+
}
|
|
145
|
+
/** The value of a template literal without substitutions. */
|
|
146
|
+
function staticTemplate(node) {
|
|
147
|
+
if (node.expressions.length) return dynamic;
|
|
148
|
+
return node.quasis[0]?.value.cooked ?? dynamic;
|
|
149
|
+
}
|
|
150
|
+
const escapePattern = /\\(u\{[^}]*\}?|u[\s\S]{0,4}|x[\s\S]{0,2}|0\d|[\s\S])/g;
|
|
151
|
+
/**
|
|
152
|
+
* True when a string literal has an escape that strict mode code rejects. The parser recovers from some bad escapes
|
|
153
|
+
* and accepts legacy octal escapes, so the scanner checks them again.
|
|
154
|
+
*/
|
|
155
|
+
function hasInvalidEscape(raw) {
|
|
156
|
+
for (const [, escape = ""] of raw.matchAll(escapePattern)) if (escape.startsWith("u{")) {
|
|
157
|
+
const code = escape.slice(2, -1);
|
|
158
|
+
if (!escape.endsWith("}") || !/^[\da-fA-F]+$/.test(code) || Number.parseInt(code, 16) > 1114111) return true;
|
|
159
|
+
} else if (escape.startsWith("u")) {
|
|
160
|
+
if (!/^u[\da-fA-F]{4}$/.test(escape)) return true;
|
|
161
|
+
} else if (escape.startsWith("x")) {
|
|
162
|
+
if (!/^x[\da-fA-F]{2}$/.test(escape)) return true;
|
|
163
|
+
} else if (/^(?:[1-9]|0\d)$/.test(escape)) return true;
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Reads a literal value: strings, numbers, booleans, `null`, `undefined`, template literals without substitutions,
|
|
168
|
+
* and arrays and objects of these. Any other expression gives `dynamic`.
|
|
169
|
+
*/
|
|
170
|
+
function staticValue(node) {
|
|
171
|
+
node = unwrapExpression(node);
|
|
172
|
+
switch (node.type) {
|
|
173
|
+
case "Literal":
|
|
174
|
+
if ("regex" in node) return dynamic;
|
|
175
|
+
return typeof node.value === "string" && hasInvalidEscape(node.raw ?? "") ? dynamic : node.value;
|
|
176
|
+
case "TemplateLiteral": return staticTemplate(node);
|
|
177
|
+
case "Identifier": return node.name === "undefined" ? void 0 : dynamic;
|
|
178
|
+
case "UnaryExpression": {
|
|
179
|
+
if (node.operator === "void") return staticValue(node.argument) === dynamic ? dynamic : void 0;
|
|
180
|
+
const value = staticValue(node.argument);
|
|
181
|
+
if (node.operator === "-" && (typeof value === "number" || typeof value === "bigint")) return -value;
|
|
182
|
+
return dynamic;
|
|
183
|
+
}
|
|
184
|
+
case "ArrayExpression": {
|
|
185
|
+
const values = [];
|
|
186
|
+
for (const element of node.elements) {
|
|
187
|
+
if (element === null || element.type === "SpreadElement") return dynamic;
|
|
188
|
+
const value = staticValue(element);
|
|
189
|
+
if (value === dynamic) return dynamic;
|
|
190
|
+
values.push(value);
|
|
191
|
+
}
|
|
192
|
+
return values;
|
|
193
|
+
}
|
|
194
|
+
case "ObjectExpression": {
|
|
195
|
+
const values = {};
|
|
196
|
+
for (const property of objectProperties(node)) {
|
|
197
|
+
if (property.key === void 0 || property.node.type !== "Property" || property.node.kind !== "init" || property.node.method || property.value === void 0) return dynamic;
|
|
198
|
+
const value = staticValue(property.value);
|
|
199
|
+
if (value === dynamic) return dynamic;
|
|
200
|
+
Object.defineProperty(values, property.key, {
|
|
201
|
+
configurable: true,
|
|
202
|
+
enumerable: true,
|
|
203
|
+
value,
|
|
204
|
+
writable: true
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
return values;
|
|
208
|
+
}
|
|
209
|
+
default: return dynamic;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/** The static string value of an expression, or undefined when it is not a string literal. */
|
|
213
|
+
function staticString(node) {
|
|
214
|
+
if (node === void 0) return;
|
|
215
|
+
const value = staticValue(node);
|
|
216
|
+
return typeof value === "string" ? value : void 0;
|
|
217
|
+
}
|
|
218
|
+
function isLineTerminator(char) {
|
|
219
|
+
return char === "\n" || char === "\r" || char === "\u2028" || char === "\u2029";
|
|
220
|
+
}
|
|
221
|
+
/** Comments, JSX text, and string, template, and regular expression literals, sorted by position. Templates are not split. */
|
|
222
|
+
function literalSpans(module) {
|
|
223
|
+
const spans = module.comments.map((comment) => ({
|
|
224
|
+
end: comment.end,
|
|
225
|
+
inert: true,
|
|
226
|
+
start: comment.start
|
|
227
|
+
}));
|
|
228
|
+
walk(module.program, (node) => {
|
|
229
|
+
if (node.type === "TemplateLiteral" || node.type === "JSXText") {
|
|
230
|
+
spans.push({
|
|
231
|
+
end: node.end,
|
|
232
|
+
inert: node.type === "JSXText",
|
|
233
|
+
start: node.start
|
|
234
|
+
});
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (node.type === "Literal" && (typeof node.value === "string" || "regex" in node)) spans.push({
|
|
238
|
+
end: node.end,
|
|
239
|
+
inert: false,
|
|
240
|
+
start: node.start
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
return spans.sort((left, right) => left.start - right.start);
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The module source with comments, strings, templates, regular expressions, and JSX text replaced by spaces. Line
|
|
247
|
+
* terminators and all positions stay the same, so text matches map back to the source.
|
|
248
|
+
*/
|
|
249
|
+
function maskLiterals(module) {
|
|
250
|
+
const output = module.source.split("");
|
|
251
|
+
for (const span of literalSpans(module)) for (let index = span.start; index < span.end; index++) if (!isLineTerminator(output[index] ?? "")) output[index] = " ";
|
|
252
|
+
return output.join("");
|
|
253
|
+
}
|
|
254
|
+
const codeTokenPattern = /(?:0[xX][\da-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|(?:\d[\d_]*(?:\.[\d_]*)?|\.\d[\d_]*)(?:[eE][+-]?[\d_]+)?)n?|(?:[\p{ID_Start}$_]|\\u\{[\da-fA-F]+\}|\\u[\da-fA-F]{4})(?:[\p{ID_Continue}$]|\\u\{[\da-fA-F]+\}|\\u[\da-fA-F]{4})*|\S/gu;
|
|
255
|
+
function decodeIdentifier(token) {
|
|
256
|
+
return token.replace(/\\u(?:\{([\da-fA-F]+)\}|([\da-fA-F]{4}))/g, (_escape, point, unit) => String.fromCodePoint(Number.parseInt(point ?? unit ?? "0", 16)));
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Splits a module into tokens. The parser finds literals and comments, so a `/` is never confused between division
|
|
260
|
+
* and a regular expression. Identifier escapes are decoded.
|
|
261
|
+
*/
|
|
262
|
+
function moduleTokens(module) {
|
|
263
|
+
const { source } = module;
|
|
264
|
+
const tokens = [];
|
|
265
|
+
const starts = [];
|
|
266
|
+
const lineBreaks = /* @__PURE__ */ new Set();
|
|
267
|
+
let previousEnd = 0;
|
|
268
|
+
const push = (token, start) => {
|
|
269
|
+
for (let index = previousEnd; index < start; index++) if (isLineTerminator(source[index] ?? "")) {
|
|
270
|
+
lineBreaks.add(tokens.length);
|
|
271
|
+
break;
|
|
272
|
+
}
|
|
273
|
+
tokens.push(token);
|
|
274
|
+
starts.push(start);
|
|
275
|
+
previousEnd = start + token.length;
|
|
276
|
+
};
|
|
277
|
+
const scanCode = (start, end) => {
|
|
278
|
+
const pattern = new RegExp(codeTokenPattern.source, codeTokenPattern.flags);
|
|
279
|
+
const code = source.slice(start, end);
|
|
280
|
+
for (const match of code.matchAll(pattern)) {
|
|
281
|
+
const token = match[0];
|
|
282
|
+
push(/^[\p{ID_Start}$_\\]/u.test(token) ? decodeIdentifier(token) : token, start + match.index);
|
|
283
|
+
previousEnd = start + match.index + token.length;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
let cursor = 0;
|
|
287
|
+
for (const span of literalSpans(module)) {
|
|
288
|
+
if (span.start < cursor) continue;
|
|
289
|
+
scanCode(cursor, span.start);
|
|
290
|
+
if (!span.inert) push(source.slice(span.start, span.end), span.start);
|
|
291
|
+
cursor = span.end;
|
|
292
|
+
}
|
|
293
|
+
scanCode(cursor, source.length);
|
|
294
|
+
return {
|
|
295
|
+
lineBreaks,
|
|
296
|
+
starts,
|
|
297
|
+
tokens
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
/** The source of each `${...}` substitution in a template literal, such as the source of one template token. */
|
|
301
|
+
function templateExpressionSources(template) {
|
|
302
|
+
const module = scanModule(`(${template})`);
|
|
303
|
+
const statement = module.program.body[0];
|
|
304
|
+
if (statement?.type !== "ExpressionStatement") return [];
|
|
305
|
+
const expression = unwrapExpression(statement.expression);
|
|
306
|
+
const literal = expression.type === "TaggedTemplateExpression" ? expression.quasi : expression;
|
|
307
|
+
if (literal.type !== "TemplateLiteral") return [];
|
|
308
|
+
return literal.expressions.map((_node, index) => module.source.slice(literal.quasis[index]?.end ?? 0, literal.quasis[index + 1]?.start ?? 0));
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
export { argumentExpression, defaultExportExpression, dynamic, exportNames, findCalls, findDefaultExportCall, findProperty, maskLiterals, moduleTokens, nodeText, objectProperties, scanModule, staticString, staticValue, templateExpressionSources, unwrapExpression, walk };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as queueErrorDiagnostics } from "./error-diagnostics-BRartC1z.js";
|
|
2
1
|
import { n as isRecord } from "./object-D8pRdprI.js";
|
|
2
|
+
import { t as queueErrorDiagnostics } from "./error-diagnostics-DukggGP6.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
//#region ../internal/src/runtime/cloudflare-env-lookup.ts
|
|
5
5
|
/** The key of the AsyncLocalStorage store on `globalThis`. Every bundled copy of this module shares the store. */
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { R as ResolvedQueueOptions, T as QueueDriverOptions } from "./types-klaR79hV.js";
|
|
2
2
|
//#region src/internal/runtime/types.d.ts
|
|
3
|
-
/** Only the generated development integration enables handler error details. */
|
|
4
3
|
interface QueueDevelopmentOptions {
|
|
5
4
|
development?: boolean;
|
|
6
5
|
}
|