@vite-hub/queue 0.4.1 → 0.5.1
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 +2 -2
- package/dist/{client-B53_G4ky.js → client-CwoCdKct.js} +9 -12
- package/dist/{cloudflare-GosJefIK.js → cloudflare-BMc35cBD.js} +2 -4
- package/dist/{cloudflare-client-CoISDpIx.js → cloudflare-client-xWteD-su.js} +7 -10
- package/dist/{cloudflare-resource-name-BIfBglC2.js → cloudflare-resource-name-Bv8Z7nDU.js} +3 -4
- package/dist/{config-B2eaXaT5.js → config-Bzp1xmdh.js} +4 -9
- package/dist/definition-CIiFfst2.js +26 -0
- package/dist/durability.d.ts +1 -3
- package/dist/durability.js +1 -2
- package/dist/{duration-tujyhAKt.js → duration-C5w_-Rf4.js} +14 -9
- package/dist/{error-diagnostics-mJXBjmQx.js → error-diagnostics-Dv6nKZQW.js} +9 -6
- package/dist/{error-diagnostics-CQ4BUqRe.js → error-diagnostics-kKXseq8d.js} +10 -3
- package/dist/{handler-response-B6lz9nCn.js → handler-response-CchTXVjm.js} +10 -7
- package/dist/index.d.ts +1 -9
- package/dist/index.js +5 -24
- package/dist/{inspect-PeuckaC3.js → inspect-CwdWUhPj.js} +1 -2
- package/dist/internal/runtime/cloudflare-client.d.ts +2 -4
- package/dist/internal/runtime/cloudflare-client.js +1 -2
- package/dist/internal/runtime/cloudflare-vite.d.ts +2 -9
- package/dist/internal/runtime/cloudflare-vite.js +13 -16
- package/dist/internal/runtime/local-client.d.ts +4 -6
- package/dist/internal/runtime/local-client.js +5 -6
- package/dist/internal/runtime/postgres-client.d.ts +6 -8
- package/dist/internal/runtime/postgres-client.js +18 -13
- package/dist/internal/runtime/state.d.ts +3 -5
- package/dist/internal/runtime/state.js +1 -2
- package/dist/internal/runtime/vercel-client.d.ts +2 -4
- package/dist/internal/runtime/vercel-client.js +5 -8
- package/dist/internal/runtime/worker-client.d.ts +3 -5
- package/dist/internal/runtime/worker-client.js +2 -3
- package/dist/{invariant-D8_xBqmZ.js → invariant-CmdvZ3vp.js} +1 -2
- package/dist/{local-CUaWoRUx.d.ts → local-B72WRWkS.d.ts} +1 -3
- package/dist/{local-Di0FrVUw.js → local-RX10a_Sq.js} +26 -21
- package/dist/{object-D8pRdprI.js → object-DRSmpe04.js} +1 -2
- package/dist/{operation-definition-nmRu_O3V.d.ts → operation-definition-CqZkx1Rm.d.ts} +8 -6
- package/dist/{operations-BVV-9Q0N.js → operations-CoEXxfUW.js} +7 -14
- package/dist/operations.d.ts +3 -7
- package/dist/operations.js +10 -16
- package/dist/runtime/hosted.d.ts +2 -4
- package/dist/runtime/hosted.js +4 -5
- package/dist/scan-module-BaqBao0J.js +309 -0
- package/dist/{state-DLqTqF6V.js → state-DqxeV11k.js} +5 -8
- package/dist/{types-Dsbb_Pvp.d.ts → types-BevEYrUV.d.ts} +1 -4
- package/dist/{types-CiuSIPR0.d.ts → types-BzPGPV9z.d.ts} +8 -4
- package/dist/{vercel-region-B95MAMXN.js → vercel-region-DEsR1YJQ.js} +2 -3
- package/dist/{vercel-C_4vqxcl.js → vercel-sUJOxFBB.js} +2 -3
- package/dist/vite.d.ts +8 -30
- package/dist/vite.js +148 -139
- package/package.json +10 -10
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { runtimeErrorDiagnostics } from "@vite-hub/runtime";
|
|
7
|
-
|
|
8
|
-
/** The HTTP status that the CLI, the Console, and Agents report for each code of a failed operation. */
|
|
1
|
+
import { t as redactInspectionText } from "./inspect-CwdWUhPj.js";
|
|
2
|
+
import { t as queueErrorDiagnostics } from "./error-diagnostics-Dv6nKZQW.js";
|
|
3
|
+
import { a as normalizePublicQueueIdentifier, r as isQueueError } from "./duration-C5w_-Rf4.js";
|
|
4
|
+
import { i as getQueueRuntimeConfig, o as getQueueRuntimeJobStore, s as listQueueDefinitionNames } from "./state-DqxeV11k.js";
|
|
5
|
+
import { n as dynamicQueue } from "./client-CwoCdKct.js";
|
|
6
|
+
import { runtimeErrorDiagnostics } from "@vite-hub/runtime/internal/error-diagnostics";
|
|
7
|
+
// src/runtime/operations.ts
|
|
9
8
|
const statuses = {
|
|
10
9
|
QUEUE_DEFINITION_NAME_INVALID: 400,
|
|
11
10
|
QUEUE_DEFINITION_NOT_FOUND: 404,
|
|
@@ -18,7 +17,6 @@ const statuses = {
|
|
|
18
17
|
QUEUE_PROVIDER_INVALID_RESPONSE: 502,
|
|
19
18
|
QUEUE_UNSUPPORTED_OPTION: 400
|
|
20
19
|
};
|
|
21
|
-
/** Gives a Queue catalog error the status and the redacted message that the CLI and the Console report. */
|
|
22
20
|
function failure(error) {
|
|
23
21
|
if (runtimeErrorDiagnostics.RUNTIME_DURATION_INVALID.is(error)) return Object.assign(error, {
|
|
24
22
|
status: 400,
|
|
@@ -86,10 +84,6 @@ async function sendToQueue(input) {
|
|
|
86
84
|
status: "queued"
|
|
87
85
|
};
|
|
88
86
|
}
|
|
89
|
-
/**
|
|
90
|
-
* The stored jobs of the local or postgres provider. Cloudflare and Vercel do not let a producer read their queue, so
|
|
91
|
-
* their jobs do not list.
|
|
92
|
-
*/
|
|
93
87
|
async function localJobs() {
|
|
94
88
|
const config = getQueueRuntimeConfig();
|
|
95
89
|
if (config === false) throw failure(queueErrorDiagnostics.QUEUE_DISABLED());
|
|
@@ -125,5 +119,4 @@ async function retryQueueJob(id) {
|
|
|
125
119
|
async function clearQueueJobs(input) {
|
|
126
120
|
return { cleared: await (await localJobs()).clear(input) };
|
|
127
121
|
}
|
|
128
|
-
//#endregion
|
|
129
122
|
export { clearQueueJobs, listQueueJobs, listQueues, retryQueueJob, sendToQueue, showQueueJob };
|
package/dist/operations.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./local-
|
|
3
|
-
import {
|
|
4
|
-
//#region src/runtime/operations.d.ts
|
|
1
|
+
import { t as AnyOperation } from "./operation-definition-CqZkx1Rm.js";
|
|
2
|
+
import "./local-B72WRWkS.js";
|
|
3
|
+
import { A as QueueJobStore, d as LocalQueueJob, f as LocalQueueJobDetail, h as LocalQueueStatus, p as LocalQueueRules, w as QueueDriver } from "./types-BzPGPV9z.js";
|
|
5
4
|
interface QueueListResult {
|
|
6
5
|
/** `undefined` when the runtime has not installed a Queue configuration. */
|
|
7
6
|
provider?: QueueDriver;
|
|
@@ -58,13 +57,10 @@ interface QueueSendOperationInput {
|
|
|
58
57
|
payload: unknown;
|
|
59
58
|
queue: string;
|
|
60
59
|
}
|
|
61
|
-
//#endregion
|
|
62
|
-
//#region src/operations.d.ts
|
|
63
60
|
/**
|
|
64
61
|
* The `queue.*` operations: list and send, and the stored jobs of the local and postgres providers. `vite dev` runs
|
|
65
62
|
* every job with the local provider. Cloudflare and Vercel do not let a producer read their queue, so the job
|
|
66
63
|
* operations fail there.
|
|
67
64
|
*/
|
|
68
65
|
export declare const queueOperations: readonly AnyOperation[];
|
|
69
|
-
//#endregion
|
|
70
66
|
export type { LocalQueueJob, LocalQueueJobDetail, QueueJobsClearInput, QueueJobsListInput, QueueJobsListResult, QueueListResult, QueueSendOperationInput, QueueSendOperationResult };
|
package/dist/operations.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as isRecordOrFunction } from "./object-
|
|
2
|
-
import { t as internalErrorDiagnostics } from "./error-diagnostics-
|
|
3
|
-
|
|
1
|
+
import { r as isRecordOrFunction } from "./object-DRSmpe04.js";
|
|
2
|
+
import { t as internalErrorDiagnostics } from "./error-diagnostics-kKXseq8d.js";
|
|
3
|
+
// ../internal/src/standard-schema.ts
|
|
4
4
|
function readOwn(value, key) {
|
|
5
5
|
if (value === null || Object(value) !== value) return;
|
|
6
6
|
try {
|
|
@@ -29,8 +29,7 @@ function standardJsonSchema(schema, direction, target = "draft-2020-12", library
|
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
//#region ../../node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@6.0.3_/node_modules/@valibot/to-json-schema/dist/index.mjs
|
|
32
|
+
// ../../node_modules/.pnpm/@valibot+to-json-schema@1.8.0_valibot@1.5.0_typescript@6.0.3_/node_modules/@valibot/to-json-schema/dist/index.mjs
|
|
34
33
|
/**
|
|
35
34
|
* Adds an error message to the errors array.
|
|
36
35
|
*
|
|
@@ -712,8 +711,7 @@ function toJsonSchema(schema, config) {
|
|
|
712
711
|
if (context.referenceMap.size) jsonSchema.$defs = context.definitions;
|
|
713
712
|
return jsonSchema;
|
|
714
713
|
}
|
|
715
|
-
|
|
716
|
-
//#region ../internal/src/valibot.ts
|
|
714
|
+
// ../internal/src/valibot.ts
|
|
717
715
|
const valibotTargets = /* @__PURE__ */ new Set([
|
|
718
716
|
"draft-07",
|
|
719
717
|
"draft-2020-12",
|
|
@@ -754,8 +752,7 @@ function withValibotJsonSchema(schema, options = {}) {
|
|
|
754
752
|
}
|
|
755
753
|
};
|
|
756
754
|
}
|
|
757
|
-
|
|
758
|
-
//#region ../internal/src/operation-definition.ts
|
|
755
|
+
// ../internal/src/operation-definition.ts
|
|
759
756
|
const nameFormat = /^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*$/;
|
|
760
757
|
const kinds = /* @__PURE__ */ new Set([
|
|
761
758
|
"read",
|
|
@@ -815,8 +812,7 @@ function isSectionId(section) {
|
|
|
815
812
|
function operationInputJsonSchema(operation) {
|
|
816
813
|
return standardJsonSchema(operation.input, "input") ?? { type: "object" };
|
|
817
814
|
}
|
|
818
|
-
|
|
819
|
-
//#region ../internal/src/operations.ts
|
|
815
|
+
// ../internal/src/operations.ts
|
|
820
816
|
/** Align rows of text cells in columns for CLI output. The last column is not padded. */
|
|
821
817
|
function table(rows) {
|
|
822
818
|
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
@@ -1161,9 +1157,8 @@ function pipe(...pipe$1) {
|
|
|
1161
1157
|
}
|
|
1162
1158
|
});
|
|
1163
1159
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
const runtime = () => import("./operations-BVV-9Q0N.js");
|
|
1160
|
+
// src/operations.ts
|
|
1161
|
+
const runtime = () => import("./operations-CoEXxfUW.js");
|
|
1167
1162
|
function defineQueueOperation(definition) {
|
|
1168
1163
|
return defineOperation({
|
|
1169
1164
|
...definition,
|
|
@@ -1268,7 +1263,7 @@ const queueOperations = [
|
|
|
1268
1263
|
}),
|
|
1269
1264
|
defineQueueOperation({
|
|
1270
1265
|
cli: {
|
|
1271
|
-
command: "jobs
|
|
1266
|
+
command: "jobs get",
|
|
1272
1267
|
format: formatJob,
|
|
1273
1268
|
namespace: "queue",
|
|
1274
1269
|
positional: ["id"]
|
|
@@ -1308,5 +1303,4 @@ const queueOperations = [
|
|
|
1308
1303
|
run: async (input) => (await runtime()).clearQueueJobs(input)
|
|
1309
1304
|
})
|
|
1310
1305
|
];
|
|
1311
|
-
//#endregion
|
|
1312
1306
|
export { queueOperations };
|
package/dist/runtime/hosted.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { x as QueueDefinition } from "../types-
|
|
2
|
-
//#region src/runtime/hosted.d.ts
|
|
1
|
+
import { x as QueueDefinition } from "../types-BzPGPV9z.js";
|
|
3
2
|
export declare const hostedVercelWaitUntil: (promise: Promise<unknown>) => void | undefined;
|
|
4
3
|
/** Handle one Vercel Queue delivery. The generated consumer route is a Fetchable module that passes its Request here. */
|
|
5
|
-
export declare function handleHostedVercelQueueCallback(request: Request, name: string, definition: QueueDefinition): Promise<Response>;
|
|
6
|
-
//#endregion
|
|
4
|
+
export declare function handleHostedVercelQueueCallback(request: Request, name: string, definition: QueueDefinition): Promise<Response>;
|
package/dist/runtime/hosted.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { t as queueErrorDiagnostics } from "../error-diagnostics-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { t as queueErrorDiagnostics } from "../error-diagnostics-Dv6nKZQW.js";
|
|
2
|
+
import { i as reportQueueDeliveryError, r as isNonRetryableQueueError, t as checkQueueHandlerResponse } from "../handler-response-CchTXVjm.js";
|
|
3
|
+
import { n as dynamicQueue } from "../client-CwoCdKct.js";
|
|
4
4
|
import { runInRunScopes } from "@vite-hub/runtime/internal/run-scope";
|
|
5
5
|
import { waitUntil } from "@vercel/functions";
|
|
6
|
-
|
|
6
|
+
// src/runtime/hosted.ts
|
|
7
7
|
const hostedVercelWaitUntil = waitUntil;
|
|
8
8
|
function createVercelJobHandler(definition) {
|
|
9
9
|
return async (payload, metadata) => {
|
|
@@ -47,5 +47,4 @@ async function handleHostedVercelQueueCallback(request, name, definition) {
|
|
|
47
47
|
if (result instanceof Response) return result;
|
|
48
48
|
return result === void 0 ? new Response(null, { status: 204 }) : Response.json(result);
|
|
49
49
|
}
|
|
50
|
-
//#endregion
|
|
51
50
|
export { handleHostedVercelQueueCallback, hostedVercelWaitUntil };
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { parseSync } from "vite";
|
|
2
|
+
// ../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
|
+
// ../internal/src/build/scan-module.ts
|
|
26
|
+
/**
|
|
27
|
+
* Reads facts from JavaScript and TypeScript modules at build and dev time. The scanner parses each module once with
|
|
28
|
+
* the oxc parser that Vite ships through Rolldown, and never runs it. Values that are not static literals read as
|
|
29
|
+
* `dynamic`, so callers can report their own diagnostics.
|
|
30
|
+
*/
|
|
31
|
+
/** The value of an expression that the scanner cannot read without running the module. */
|
|
32
|
+
const dynamic = Symbol("dynamic");
|
|
33
|
+
/** Parses a module once. `file` selects the grammar from its extension and defaults to TypeScript. */
|
|
34
|
+
function scanModule(source, file = "module.ts") {
|
|
35
|
+
const result = parseSync(file, source, {
|
|
36
|
+
lang: moduleLanguage(file),
|
|
37
|
+
preserveParens: false,
|
|
38
|
+
sourceType: "module"
|
|
39
|
+
});
|
|
40
|
+
return {
|
|
41
|
+
comments: result.comments,
|
|
42
|
+
errors: result.errors,
|
|
43
|
+
file,
|
|
44
|
+
program: result.program,
|
|
45
|
+
source
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Lists the names that a module exports. A default export reads as `default`. Type-only exports are left out. */
|
|
49
|
+
function exportNames(source, file = "module.ts") {
|
|
50
|
+
const { module } = parseSync(file, source, {
|
|
51
|
+
lang: moduleLanguage(file),
|
|
52
|
+
sourceType: "module"
|
|
53
|
+
});
|
|
54
|
+
return module.staticExports.flatMap((statement) => statement.entries).flatMap((entry) => {
|
|
55
|
+
if (entry.isType) return [];
|
|
56
|
+
if (entry.exportName.kind === "Default") return ["default"];
|
|
57
|
+
return entry.exportName.name === null ? [] : [entry.exportName.name];
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/** The source text of a node. */
|
|
61
|
+
function nodeText(module, node) {
|
|
62
|
+
return module.source.slice(node.start, node.end);
|
|
63
|
+
}
|
|
64
|
+
/** Removes parentheses, `as`, `satisfies`, `!`, and `<T>` assertions around an expression. */
|
|
65
|
+
function unwrapExpression(node) {
|
|
66
|
+
while (node.type === "ParenthesizedExpression" || node.type === "TSAsExpression" || node.type === "TSSatisfiesExpression" || node.type === "TSNonNullExpression" || node.type === "TSTypeAssertion") node = node.expression;
|
|
67
|
+
return node;
|
|
68
|
+
}
|
|
69
|
+
/** A call argument without assertions, or undefined for a spread or missing argument. */
|
|
70
|
+
function argumentExpression(argument) {
|
|
71
|
+
return argument === void 0 || argument.type === "SpreadElement" ? void 0 : unwrapExpression(argument);
|
|
72
|
+
}
|
|
73
|
+
/** Calls whose callee is a plain identifier in `names`, such as `defineCollection(...)`, in source order. */
|
|
74
|
+
function findCalls(module, names) {
|
|
75
|
+
const wanted = new Set(names);
|
|
76
|
+
const calls = [];
|
|
77
|
+
walk(module.program, (node) => {
|
|
78
|
+
if (node.type === "CallExpression" && node.callee.type === "Identifier" && wanted.has(node.callee.name)) calls.push(node);
|
|
79
|
+
});
|
|
80
|
+
return calls.sort((left, right) => left.start - right.start);
|
|
81
|
+
}
|
|
82
|
+
/** The expression of `export default <expression>`, without assertions. Declarations return undefined. */
|
|
83
|
+
function defaultExportExpression(module) {
|
|
84
|
+
for (const statement of module.program.body) {
|
|
85
|
+
if (statement.type !== "ExportDefaultDeclaration") continue;
|
|
86
|
+
const declaration = statement.declaration;
|
|
87
|
+
if (declaration.type === "FunctionDeclaration" || declaration.type === "ClassDeclaration" || declaration.type === "TSInterfaceDeclaration") return;
|
|
88
|
+
return unwrapExpression(declaration);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Finds `export default defineX({ ... })` for one of `names`. With `positionalOptionsIndex`, a call whose first
|
|
93
|
+
* argument is not an object and that has more than one argument reads its options from that argument. Returns
|
|
94
|
+
* undefined when the options are not an object literal.
|
|
95
|
+
*/
|
|
96
|
+
function findDefaultExportCall(module, names, options = {}) {
|
|
97
|
+
const call = defaultExportExpression(module);
|
|
98
|
+
if (call?.type !== "CallExpression" || call.callee.type !== "Identifier" || !names.includes(call.callee.name)) return;
|
|
99
|
+
const name = call.callee.name;
|
|
100
|
+
const first = argumentExpression(call.arguments[0]);
|
|
101
|
+
if (first?.type === "ObjectExpression") return {
|
|
102
|
+
call,
|
|
103
|
+
name,
|
|
104
|
+
options: first
|
|
105
|
+
};
|
|
106
|
+
if (options.positionalOptionsIndex === void 0 || first === void 0 || call.arguments.length < 2) return;
|
|
107
|
+
const positional = call.arguments[options.positionalOptionsIndex];
|
|
108
|
+
if (positional === void 0) return {
|
|
109
|
+
call,
|
|
110
|
+
name
|
|
111
|
+
};
|
|
112
|
+
const object = argumentExpression(positional);
|
|
113
|
+
return object?.type === "ObjectExpression" ? {
|
|
114
|
+
call,
|
|
115
|
+
name,
|
|
116
|
+
options: object
|
|
117
|
+
} : void 0;
|
|
118
|
+
}
|
|
119
|
+
function staticKey(property) {
|
|
120
|
+
const key = property.key;
|
|
121
|
+
if (key.type === "Identifier" && !property.computed) return key.name;
|
|
122
|
+
if (key.type === "PrivateIdentifier") return;
|
|
123
|
+
const value = staticValue(key);
|
|
124
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "bigint" ? String(value) : void 0;
|
|
125
|
+
}
|
|
126
|
+
/** The members of an object literal in source order. */
|
|
127
|
+
function objectProperties(object) {
|
|
128
|
+
return object.properties.map((node) => node.type === "SpreadElement" ? {
|
|
129
|
+
computed: false,
|
|
130
|
+
key: void 0,
|
|
131
|
+
node,
|
|
132
|
+
value: void 0
|
|
133
|
+
} : {
|
|
134
|
+
computed: node.computed,
|
|
135
|
+
key: staticKey(node),
|
|
136
|
+
node,
|
|
137
|
+
value: unwrapExpression(node.value)
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
/** The last member named `name`, which is the one that the object keeps at runtime. */
|
|
141
|
+
function findProperty(object, name) {
|
|
142
|
+
return objectProperties(object).findLast((property) => property.key === name);
|
|
143
|
+
}
|
|
144
|
+
/** The value of a template literal without substitutions. */
|
|
145
|
+
function staticTemplate(node) {
|
|
146
|
+
if (node.expressions.length) return dynamic;
|
|
147
|
+
return node.quasis[0]?.value.cooked ?? dynamic;
|
|
148
|
+
}
|
|
149
|
+
const escapePattern = /\\(u\{[^}]*\}?|u[\s\S]{0,4}|x[\s\S]{0,2}|0\d|[\s\S])/g;
|
|
150
|
+
/**
|
|
151
|
+
* True when a string literal has an escape that strict mode code rejects. The parser recovers from some bad escapes
|
|
152
|
+
* and accepts legacy octal escapes, so the scanner checks them again.
|
|
153
|
+
*/
|
|
154
|
+
function hasInvalidEscape(raw) {
|
|
155
|
+
for (const [, escape = ""] of raw.matchAll(escapePattern)) if (escape.startsWith("u{")) {
|
|
156
|
+
const code = escape.slice(2, -1);
|
|
157
|
+
if (!escape.endsWith("}") || !/^[\da-fA-F]+$/.test(code) || Number.parseInt(code, 16) > 1114111) return true;
|
|
158
|
+
} else if (escape.startsWith("u")) {
|
|
159
|
+
if (!/^u[\da-fA-F]{4}$/.test(escape)) return true;
|
|
160
|
+
} else if (escape.startsWith("x")) {
|
|
161
|
+
if (!/^x[\da-fA-F]{2}$/.test(escape)) return true;
|
|
162
|
+
} else if (/^(?:[1-9]|0\d)$/.test(escape)) return true;
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Reads a literal value: strings, numbers, booleans, `null`, `undefined`, template literals without substitutions,
|
|
167
|
+
* and arrays and objects of these. Any other expression gives `dynamic`.
|
|
168
|
+
*/
|
|
169
|
+
function staticValue(node) {
|
|
170
|
+
node = unwrapExpression(node);
|
|
171
|
+
switch (node.type) {
|
|
172
|
+
case "Literal":
|
|
173
|
+
if ("regex" in node) return dynamic;
|
|
174
|
+
return typeof node.value === "string" && hasInvalidEscape(node.raw ?? "") ? dynamic : node.value;
|
|
175
|
+
case "TemplateLiteral": return staticTemplate(node);
|
|
176
|
+
case "Identifier": return node.name === "undefined" ? void 0 : dynamic;
|
|
177
|
+
case "UnaryExpression": {
|
|
178
|
+
if (node.operator === "void") return staticValue(node.argument) === dynamic ? dynamic : void 0;
|
|
179
|
+
const value = staticValue(node.argument);
|
|
180
|
+
if (node.operator === "-" && (typeof value === "number" || typeof value === "bigint")) return -value;
|
|
181
|
+
return dynamic;
|
|
182
|
+
}
|
|
183
|
+
case "ArrayExpression": {
|
|
184
|
+
const values = [];
|
|
185
|
+
for (const element of node.elements) {
|
|
186
|
+
if (element === null || element.type === "SpreadElement") return dynamic;
|
|
187
|
+
const value = staticValue(element);
|
|
188
|
+
if (value === dynamic) return dynamic;
|
|
189
|
+
values.push(value);
|
|
190
|
+
}
|
|
191
|
+
return values;
|
|
192
|
+
}
|
|
193
|
+
case "ObjectExpression": {
|
|
194
|
+
const values = {};
|
|
195
|
+
for (const property of objectProperties(node)) {
|
|
196
|
+
if (property.key === void 0 || property.node.type !== "Property" || property.node.kind !== "init" || property.node.method || property.value === void 0) return dynamic;
|
|
197
|
+
const value = staticValue(property.value);
|
|
198
|
+
if (value === dynamic) return dynamic;
|
|
199
|
+
Object.defineProperty(values, property.key, {
|
|
200
|
+
configurable: true,
|
|
201
|
+
enumerable: true,
|
|
202
|
+
value,
|
|
203
|
+
writable: true
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return values;
|
|
207
|
+
}
|
|
208
|
+
default: return dynamic;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/** The static string value of an expression, or undefined when it is not a string literal. */
|
|
212
|
+
function staticString(node) {
|
|
213
|
+
if (node === void 0) return;
|
|
214
|
+
const value = staticValue(node);
|
|
215
|
+
return typeof value === "string" ? value : void 0;
|
|
216
|
+
}
|
|
217
|
+
function isLineTerminator(char) {
|
|
218
|
+
return char === "\n" || char === "\r" || char === "\u2028" || char === "\u2029";
|
|
219
|
+
}
|
|
220
|
+
/** Comments, JSX text, and string, template, and regular expression literals, sorted by position. Templates are not split. */
|
|
221
|
+
function literalSpans(module) {
|
|
222
|
+
const spans = module.comments.map((comment) => ({
|
|
223
|
+
end: comment.end,
|
|
224
|
+
inert: true,
|
|
225
|
+
start: comment.start
|
|
226
|
+
}));
|
|
227
|
+
walk(module.program, (node) => {
|
|
228
|
+
if (node.type === "TemplateLiteral" || node.type === "JSXText") {
|
|
229
|
+
spans.push({
|
|
230
|
+
end: node.end,
|
|
231
|
+
inert: node.type === "JSXText",
|
|
232
|
+
start: node.start
|
|
233
|
+
});
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
if (node.type === "Literal" && (typeof node.value === "string" || "regex" in node)) spans.push({
|
|
237
|
+
end: node.end,
|
|
238
|
+
inert: false,
|
|
239
|
+
start: node.start
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
return spans.sort((left, right) => left.start - right.start);
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* The module source with comments, strings, templates, regular expressions, and JSX text replaced by spaces. Line
|
|
246
|
+
* terminators and all positions stay the same, so text matches map back to the source.
|
|
247
|
+
*/
|
|
248
|
+
function maskLiterals(module) {
|
|
249
|
+
const output = module.source.split("");
|
|
250
|
+
for (const span of literalSpans(module)) for (let index = span.start; index < span.end; index++) if (!isLineTerminator(output[index] ?? "")) output[index] = " ";
|
|
251
|
+
return output.join("");
|
|
252
|
+
}
|
|
253
|
+
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;
|
|
254
|
+
function decodeIdentifier(token) {
|
|
255
|
+
return token.replace(/\\u(?:\{([\da-fA-F]+)\}|([\da-fA-F]{4}))/g, (_escape, point, unit) => String.fromCodePoint(Number.parseInt(point ?? unit ?? "0", 16)));
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Splits a module into tokens. The parser finds literals and comments, so a `/` is never confused between division
|
|
259
|
+
* and a regular expression. Identifier escapes are decoded.
|
|
260
|
+
*/
|
|
261
|
+
function moduleTokens(module) {
|
|
262
|
+
const { source } = module;
|
|
263
|
+
const tokens = [];
|
|
264
|
+
const starts = [];
|
|
265
|
+
const lineBreaks = /* @__PURE__ */ new Set();
|
|
266
|
+
let previousEnd = 0;
|
|
267
|
+
const push = (token, start) => {
|
|
268
|
+
for (let index = previousEnd; index < start; index++) if (isLineTerminator(source[index] ?? "")) {
|
|
269
|
+
lineBreaks.add(tokens.length);
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
tokens.push(token);
|
|
273
|
+
starts.push(start);
|
|
274
|
+
previousEnd = start + token.length;
|
|
275
|
+
};
|
|
276
|
+
const scanCode = (start, end) => {
|
|
277
|
+
const pattern = new RegExp(codeTokenPattern.source, codeTokenPattern.flags);
|
|
278
|
+
const code = source.slice(start, end);
|
|
279
|
+
for (const match of code.matchAll(pattern)) {
|
|
280
|
+
const token = match[0];
|
|
281
|
+
push(/^[\p{ID_Start}$_\\]/u.test(token) ? decodeIdentifier(token) : token, start + match.index);
|
|
282
|
+
previousEnd = start + match.index + token.length;
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
let cursor = 0;
|
|
286
|
+
for (const span of literalSpans(module)) {
|
|
287
|
+
if (span.start < cursor) continue;
|
|
288
|
+
scanCode(cursor, span.start);
|
|
289
|
+
if (!span.inert) push(source.slice(span.start, span.end), span.start);
|
|
290
|
+
cursor = span.end;
|
|
291
|
+
}
|
|
292
|
+
scanCode(cursor, source.length);
|
|
293
|
+
return {
|
|
294
|
+
lineBreaks,
|
|
295
|
+
starts,
|
|
296
|
+
tokens
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/** The source of each `${...}` substitution in a template literal, such as the source of one template token. */
|
|
300
|
+
function templateExpressionSources(template) {
|
|
301
|
+
const module = scanModule(`(${template})`);
|
|
302
|
+
const statement = module.program.body[0];
|
|
303
|
+
if (statement?.type !== "ExpressionStatement") return [];
|
|
304
|
+
const expression = unwrapExpression(statement.expression);
|
|
305
|
+
const literal = expression.type === "TaggedTemplateExpression" ? expression.quasi : expression;
|
|
306
|
+
if (literal.type !== "TemplateLiteral") return [];
|
|
307
|
+
return literal.expressions.map((_node, index) => module.source.slice(literal.quasis[index]?.end ?? 0, literal.quasis[index + 1]?.start ?? 0));
|
|
308
|
+
}
|
|
309
|
+
export { argumentExpression, defaultExportExpression, dynamic, exportNames, findCalls, findDefaultExportCall, findProperty, maskLiterals, moduleTokens, nodeText, objectProperties, scanModule, staticString, staticValue, templateExpressionSources, unwrapExpression, walk };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as isRecord } from "./object-
|
|
2
|
-
import { t as queueErrorDiagnostics } from "./error-diagnostics-
|
|
1
|
+
import { n as isRecord } from "./object-DRSmpe04.js";
|
|
2
|
+
import { t as queueErrorDiagnostics } from "./error-diagnostics-Dv6nKZQW.js";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
|
-
|
|
4
|
+
// ../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. */
|
|
6
6
|
const activeEnvStorageKey = Symbol.for("vitehub.cloudflare.env-storage");
|
|
7
7
|
let activeEnv;
|
|
@@ -41,8 +41,7 @@ function getCloudflareEnv(event, options = {}) {
|
|
|
41
41
|
for (const candidate of [ownValue(target, "env"), ...cloudflareOwners(target).map((owner) => ownValue(owner, "env"))]) if (candidate) return candidate;
|
|
42
42
|
return options.fallback === false ? void 0 : getActiveCloudflareEnv();
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
//#region ../internal/src/runtime/cloudflare-env.ts
|
|
44
|
+
// ../internal/src/runtime/cloudflare-env.ts
|
|
46
45
|
const runtimeGlobal = globalThis;
|
|
47
46
|
const activeEnvStorage = runtimeGlobal[activeEnvStorageKey] ||= new AsyncLocalStorage();
|
|
48
47
|
const globalEnvProbe = Symbol("vitehub.cloudflare.global-env-probe");
|
|
@@ -113,8 +112,7 @@ function createCloudflareRuntimeEvent(env, context) {
|
|
|
113
112
|
waitUntil
|
|
114
113
|
};
|
|
115
114
|
}
|
|
116
|
-
|
|
117
|
-
//#region src/internal/runtime/state.ts
|
|
115
|
+
// src/internal/runtime/state.ts
|
|
118
116
|
let runtimeConfig;
|
|
119
117
|
let runtimeClientFactory;
|
|
120
118
|
let registryOverride;
|
|
@@ -192,5 +190,4 @@ async function loadQueueDefinition(name) {
|
|
|
192
190
|
if (isQueueDefinition(loaded)) return loaded;
|
|
193
191
|
if (isRecord(loaded) && Object.hasOwn(loaded, "default") && isQueueDefinition(loaded.default)) return loaded.default;
|
|
194
192
|
}
|
|
195
|
-
//#endregion
|
|
196
193
|
export { runWithActiveCloudflareEnv as _, getQueueRuntimeEvent as a, loadQueueDefinition as c, setQueueRuntimeConfig as d, setQueueRuntimeEventDefaults as f, resolveWaitUntil as g, createCloudflareRuntimeEvent as h, getQueueRuntimeConfig as i, missingQueueDefinitionError as l, setQueueRuntimeRegistry as m, getOrCreateQueueClient as n, getQueueRuntimeJobStore as o, setQueueRuntimeJobStore as p, getQueueRuntimeClientFactory as r, listQueueDefinitionNames as s, enterQueueRuntimeEvent as t, runWithQueueRuntimeEvent as u, getCloudflareEnv as v };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { R as ResolvedQueueOptions, T as QueueDriverOptions } from "./types-
|
|
2
|
-
//#region src/internal/runtime/types.d.ts
|
|
3
|
-
/** Only the generated development integration enables handler error details. */
|
|
1
|
+
import { R as ResolvedQueueOptions, T as QueueDriverOptions } from "./types-BzPGPV9z.js";
|
|
4
2
|
interface QueueDevelopmentOptions {
|
|
5
3
|
development?: boolean;
|
|
6
4
|
}
|
|
7
5
|
type QueueRuntimeOptions = ResolvedQueueOptions & QueueDevelopmentOptions;
|
|
8
6
|
type QueueRuntimeDriverOptions = QueueDriverOptions & QueueDevelopmentOptions;
|
|
9
|
-
//#endregion
|
|
10
7
|
export { QueueRuntimeOptions as n, QueueRuntimeDriverOptions as t };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Duration, Result } from "@vite-hub/runtime";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
type QueueDriver = "cloudflare" | "local" | "postgres" | "vercel";
|
|
4
3
|
/** The Queue drivers that run jobs in a Node server process. */
|
|
5
4
|
type NodeQueueDriver = "local" | "postgres";
|
|
@@ -52,6 +51,8 @@ interface CloudflareQueueBatchHandlerOptions<T = unknown> {
|
|
|
52
51
|
concurrency?: number;
|
|
53
52
|
onError?: (error: unknown, message: CloudflareQueueMessage<T>, batch: CloudflareQueueMessageBatch<T>) => CloudflareQueueBatchErrorAction | void | Promise<CloudflareQueueBatchErrorAction | void>;
|
|
54
53
|
onMessage: (message: CloudflareQueueMessage<T>, batch: CloudflareQueueMessageBatch<T>) => unknown | Promise<unknown>;
|
|
54
|
+
/** The Queue Definition name in delivery error reports. Defaults to the name that `batch.queue` encodes. */
|
|
55
|
+
queue?: string;
|
|
55
56
|
}
|
|
56
57
|
type VercelQueueRetryDirective = {
|
|
57
58
|
acknowledge: true;
|
|
@@ -156,7 +157,6 @@ interface LocalQueueDriverOptions extends QueueSharedOptions {
|
|
|
156
157
|
*/
|
|
157
158
|
type LocalQueueRules = QueueDriver;
|
|
158
159
|
interface LocalQueueModuleDriverOptions extends QueueSharedOptions {
|
|
159
|
-
/** Directory of the stored jobs, relative to the working directory. Defaults to `.vitehub/data/queue`. */
|
|
160
160
|
base?: string;
|
|
161
161
|
driver: "local";
|
|
162
162
|
}
|
|
@@ -207,6 +207,11 @@ interface QueueDefinitionOptions {
|
|
|
207
207
|
cache?: boolean;
|
|
208
208
|
callbackOptions?: VercelQueueCallbackOptions;
|
|
209
209
|
concurrency?: number;
|
|
210
|
+
/**
|
|
211
|
+
* Cloudflare: the most messages in one batch, from 1 to 100. Cloudflare's default is 10. Write it as a number literal,
|
|
212
|
+
* because the build reads it from the file to configure the consumer.
|
|
213
|
+
*/
|
|
214
|
+
maxBatchSize?: number;
|
|
210
215
|
onDispatchError?: (error: unknown, context: {
|
|
211
216
|
name: string;
|
|
212
217
|
}) => unknown | Promise<unknown>;
|
|
@@ -396,7 +401,7 @@ interface LocalQueueJob {
|
|
|
396
401
|
queue: string;
|
|
397
402
|
state: "dead" | "pending" | "running";
|
|
398
403
|
}
|
|
399
|
-
/** One stored job with its payload, as `vitehub queue jobs
|
|
404
|
+
/** One stored job with its payload, as `vitehub queue jobs get` shows it. */
|
|
400
405
|
interface LocalQueueJobDetail extends LocalQueueJob {
|
|
401
406
|
/** The local provider only: the file of the job. */
|
|
402
407
|
file?: string;
|
|
@@ -436,5 +441,4 @@ interface QueueJobStore {
|
|
|
436
441
|
readonly rules: LocalQueueDeliveryRules;
|
|
437
442
|
status: () => Promise<LocalQueueStatus>;
|
|
438
443
|
}
|
|
439
|
-
//#endregion
|
|
440
444
|
export { QueueJobStore as A, VercelQueueCallbackOptions as B, QueueDefinitionRegistry as C, QueueErrorCode as D, QueueEnqueueOptions as E, QueueRegistry as F, VercelQueueSendBatchMessage as G, VercelQueueErrorCode as H, QueueSendResult as I, VercelQueueSendBatchOptions as K, ResolvedLocalQueueOptions as L, QueueName as M, QueueOptions as N, QueueHandler as O, QueuePayload as P, ResolvedQueueOptions as R, QueueDefinitionOptions as S, QueueDriverOptions as T, VercelQueueRetryDirective as U, VercelQueueClient as V, VercelQueueRetryHandler as W, PostgresQueueClient as _, CloudflareQueueMessageBatch as a, QueueClient as b, LocalQueueClient as c, LocalQueueJob as d, LocalQueueJobDetail as f, NodeQueueDriver as g, LocalQueueStatus as h, CloudflareQueueMessage as i, QueueModuleDriverOptions as j, QueueJob as k, LocalQueueDriverOptions as l, LocalQueueSendBatchMessage as m, CloudflareQueueClient as n, CloudflareQueueSendBatchItem as o, LocalQueueRules as p, VercelQueueSendResult as q, CloudflareQueueErrorCode as r, DiscoveredQueueDefinition as s, CloudflareQueueBatchHandlerOptions as t, LocalQueueErrorCode as u, PostgresQueueDriverOptions as v, QueueDriver as w, QueueDefinition as x, PostgresQueueErrorCode as y, VercelQueueBatchSendResult as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as getQueueRuntimeEvent } from "./state-
|
|
2
|
-
|
|
1
|
+
import { a as getQueueRuntimeEvent } from "./state-DqxeV11k.js";
|
|
2
|
+
// src/internal/vercel-region.ts
|
|
3
3
|
function readHeader(headers, name) {
|
|
4
4
|
const get = headers?.get;
|
|
5
5
|
const value = typeof get === "function" ? get.call(headers, name) : headers?.[name];
|
|
@@ -22,5 +22,4 @@ function resolveVercelQueueRegion(explicitRegion) {
|
|
|
22
22
|
requestScoped: event !== void 0
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { resolveVercelQueueRegion as t };
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { r as encodeNameHex } from "./cloudflare-
|
|
2
|
-
|
|
1
|
+
import { r as encodeNameHex } from "./cloudflare-BMc35cBD.js";
|
|
2
|
+
// src/integrations/vercel.ts
|
|
3
3
|
const vercelQueueTopicPrefix = "topic--";
|
|
4
4
|
function getVercelQueueTopicName(name) {
|
|
5
5
|
return `${vercelQueueTopicPrefix}${encodeNameHex(name)}`;
|
|
6
6
|
}
|
|
7
|
-
//#endregion
|
|
8
7
|
export { getVercelQueueTopicName as t };
|