@workflow/web 5.0.0-beta.5 → 5.0.0-beta.51

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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/build/client/assets/app-9JVnf-IU.css +1 -0
  3. package/build/client/assets/arrow-up-right-D35zSWdr.js +15 -0
  4. package/build/client/assets/{entry.client-DtOpLtMQ.js → entry.client-DmlDFlyx.js} +25 -185
  5. package/build/client/assets/{highlighted-body-B3W2YXNL-L1CrwoL_.js → highlighted-body-B3W2YXNL-CaN05-wF.js} +2 -2
  6. package/build/client/assets/{home-B6UmDDP6.js → home-CERPMYFB.js} +1762 -291
  7. package/build/client/assets/index-HqNj_XIX.js +200 -0
  8. package/build/client/assets/{index-BsV8i_Jn.js → index-thGVuYbY.js} +19 -19
  9. package/build/client/assets/loader-circle-BS067e3l.js +12 -0
  10. package/build/client/assets/manifest-e59a5df7.js +1 -0
  11. package/build/client/assets/mermaid-3ZIDBTTL-D8CjRQta.css +1 -0
  12. package/build/client/assets/{mermaid-3ZIDBTTL-BQLU7GUr.js → mermaid-3ZIDBTTL-DX-qOY9c.js} +17613 -12954
  13. package/build/client/assets/root-Bl5xphvU.css +1 -0
  14. package/build/client/assets/{root-Yk3JVwUh.js → root-D0H-cabN.js} +17 -42
  15. package/build/client/assets/{run-detail-DMUaWXhb.js → run-detail-C7nNgL_7.js} +2215 -1599
  16. package/build/client/assets/run-detail-CWoGxu_0.css +1 -0
  17. package/build/client/assets/{workflow-graph-viewer-yqeN-U_2.js → workflow-graph-viewer-nSzDqm6s.js} +5111 -5254
  18. package/build/client/assets/zstd-B5R2yJjB.wasm +0 -0
  19. package/build/client/assets/zstd-browser-decoder-DtSP7rJ_.js +27 -0
  20. package/build/server/assets/{server-build-DtcOUEHS.js → app-8hyjFpMO.js} +77875 -59603
  21. package/build/server/assets/{highlighted-body-B3W2YXNL-CZjJIpdD.js → highlighted-body-B3W2YXNL-DY_BqM6l.js} +16 -8
  22. package/build/server/assets/index-Az8HzIf_.js +174 -0
  23. package/build/server/assets/index-BfLBLRRi.js +204 -0
  24. package/build/server/assets/index-CETb4fkq.js +1164 -0
  25. package/build/server/assets/index-CvyMHP_b.js +1262 -0
  26. package/build/server/assets/{mermaid-3ZIDBTTL-Cc8IPTBj.js → mermaid-3ZIDBTTL-Bca_z0-z.js} +17 -9
  27. package/build/server/assets/{token-DHnArVm7.js → token-BcUtceXk.js} +5 -2
  28. package/build/server/assets/{token-util-B3uKeZ0s.js → token-util-BgQCuyAc.js} +5 -2
  29. package/build/server/assets/websocket-server-D2905vlr.js +3669 -0
  30. package/build/server/assets/wrapper-BxY6HvLW.js +69 -0
  31. package/build/server/assets/ws-transport-nlG6b7qI.js +551 -0
  32. package/build/server/assets/zstd-browser-decoder-Ce8lEOjC.js +72 -0
  33. package/build/server/index.js +50 -2
  34. package/handler.d.ts +22 -0
  35. package/handler.js +186 -0
  36. package/package.json +27 -13
  37. package/registry.d.ts +29 -0
  38. package/registry.js +89 -0
  39. package/build/client/assets/encryption-CEh0YXii.js +0 -28
  40. package/build/client/assets/index-B4xuge0I.js +0 -249
  41. package/build/client/assets/manifest-e4c1c787.js +0 -1
  42. package/build/client/assets/mermaid-3ZIDBTTL-DKxHcEOp.css +0 -1
  43. package/build/client/assets/root-C0Tu5TVN.css +0 -1
  44. package/build/client/assets/server-build-DqaxIrF0.css +0 -1
  45. package/build/client/assets/worker-CqHKTA7D.js +0 -115
  46. package/build/server/assets/app-L1V62FgT.js +0 -9213
  47. package/build/server/assets/index-BwtNigf1.js +0 -80
  48. package/build/server/assets/index-meg9qk8y.js +0 -1282
@@ -0,0 +1,1262 @@
1
+ import { createRequire as __wkfCreateRequire } from "node:module";
2
+ if (typeof require === "undefined") {
3
+ globalThis.require = __wkfCreateRequire(import.meta.url);
4
+ }
5
+ function _mergeNamespaces(n, m) {
6
+ for (var i = 0; i < m.length; i++) {
7
+ const e = m[i];
8
+ if (typeof e !== "string" && !Array.isArray(e)) {
9
+ for (const k in e) {
10
+ if (k !== "default" && !(k in n)) {
11
+ const d = Object.getOwnPropertyDescriptor(e, k);
12
+ if (d) {
13
+ Object.defineProperty(n, k, d.get ? d : {
14
+ enumerable: true,
15
+ get: () => e[k]
16
+ });
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
22
+ return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
23
+ }
24
+ var headers;
25
+ var hasRequiredHeaders;
26
+ function requireHeaders() {
27
+ if (hasRequiredHeaders) return headers;
28
+ hasRequiredHeaders = 1;
29
+ var __defProp = Object.defineProperty;
30
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
31
+ var __getOwnPropNames = Object.getOwnPropertyNames;
32
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
33
+ var __export = (target, all) => {
34
+ for (var name in all)
35
+ __defProp(target, name, { get: all[name], enumerable: true });
36
+ };
37
+ var __copyProps = (to, from, except, desc) => {
38
+ if (from && typeof from === "object" || typeof from === "function") {
39
+ for (let key of __getOwnPropNames(from))
40
+ if (!__hasOwnProp.call(to, key) && key !== except)
41
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
42
+ }
43
+ return to;
44
+ };
45
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
+ var headers_exports = {};
47
+ __export(headers_exports, {
48
+ CITY_HEADER_NAME: () => CITY_HEADER_NAME,
49
+ COUNTRY_HEADER_NAME: () => COUNTRY_HEADER_NAME,
50
+ EMOJI_FLAG_UNICODE_STARTING_POSITION: () => EMOJI_FLAG_UNICODE_STARTING_POSITION,
51
+ IP_HEADER_NAME: () => IP_HEADER_NAME,
52
+ LATITUDE_HEADER_NAME: () => LATITUDE_HEADER_NAME,
53
+ LONGITUDE_HEADER_NAME: () => LONGITUDE_HEADER_NAME,
54
+ POSTAL_CODE_HEADER_NAME: () => POSTAL_CODE_HEADER_NAME,
55
+ REGION_HEADER_NAME: () => REGION_HEADER_NAME,
56
+ REQUEST_ID_HEADER_NAME: () => REQUEST_ID_HEADER_NAME,
57
+ geolocation: () => geolocation,
58
+ ipAddress: () => ipAddress
59
+ });
60
+ headers = __toCommonJS(headers_exports);
61
+ const CITY_HEADER_NAME = "x-vercel-ip-city";
62
+ const COUNTRY_HEADER_NAME = "x-vercel-ip-country";
63
+ const IP_HEADER_NAME = "x-real-ip";
64
+ const LATITUDE_HEADER_NAME = "x-vercel-ip-latitude";
65
+ const LONGITUDE_HEADER_NAME = "x-vercel-ip-longitude";
66
+ const REGION_HEADER_NAME = "x-vercel-ip-country-region";
67
+ const POSTAL_CODE_HEADER_NAME = "x-vercel-ip-postal-code";
68
+ const REQUEST_ID_HEADER_NAME = "x-vercel-id";
69
+ const EMOJI_FLAG_UNICODE_STARTING_POSITION = 127397;
70
+ function getHeader(headers2, key) {
71
+ return headers2.get(key) ?? void 0;
72
+ }
73
+ function getHeaderWithDecode(request, key) {
74
+ const header = getHeader(request.headers, key);
75
+ return header ? decodeURIComponent(header) : void 0;
76
+ }
77
+ function getFlag(countryCode) {
78
+ const regex = new RegExp("^[A-Z]{2}$").test(countryCode);
79
+ if (!countryCode || !regex)
80
+ return void 0;
81
+ return String.fromCodePoint(
82
+ ...countryCode.split("").map((char) => EMOJI_FLAG_UNICODE_STARTING_POSITION + char.charCodeAt(0))
83
+ );
84
+ }
85
+ function ipAddress(input) {
86
+ const headers2 = "headers" in input ? input.headers : input;
87
+ return getHeader(headers2, IP_HEADER_NAME);
88
+ }
89
+ function getRegionFromRequestId(requestId) {
90
+ if (!requestId) {
91
+ return "dev1";
92
+ }
93
+ return requestId.split(":")[0];
94
+ }
95
+ function geolocation(request) {
96
+ return {
97
+ // city name may be encoded to support multi-byte characters
98
+ city: getHeaderWithDecode(request, CITY_HEADER_NAME),
99
+ country: getHeader(request.headers, COUNTRY_HEADER_NAME),
100
+ flag: getFlag(getHeader(request.headers, COUNTRY_HEADER_NAME)),
101
+ countryRegion: getHeader(request.headers, REGION_HEADER_NAME),
102
+ region: getRegionFromRequestId(
103
+ getHeader(request.headers, REQUEST_ID_HEADER_NAME)
104
+ ),
105
+ latitude: getHeader(request.headers, LATITUDE_HEADER_NAME),
106
+ longitude: getHeader(request.headers, LONGITUDE_HEADER_NAME),
107
+ postalCode: getHeader(request.headers, POSTAL_CODE_HEADER_NAME)
108
+ };
109
+ }
110
+ return headers;
111
+ }
112
+ var getEnv_1;
113
+ var hasRequiredGetEnv;
114
+ function requireGetEnv() {
115
+ if (hasRequiredGetEnv) return getEnv_1;
116
+ hasRequiredGetEnv = 1;
117
+ var __defProp = Object.defineProperty;
118
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
119
+ var __getOwnPropNames = Object.getOwnPropertyNames;
120
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
121
+ var __export = (target, all) => {
122
+ for (var name in all)
123
+ __defProp(target, name, { get: all[name], enumerable: true });
124
+ };
125
+ var __copyProps = (to, from, except, desc) => {
126
+ if (from && typeof from === "object" || typeof from === "function") {
127
+ for (let key of __getOwnPropNames(from))
128
+ if (!__hasOwnProp.call(to, key) && key !== except)
129
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
130
+ }
131
+ return to;
132
+ };
133
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
134
+ var get_env_exports = {};
135
+ __export(get_env_exports, {
136
+ getEnv: () => getEnv
137
+ });
138
+ getEnv_1 = __toCommonJS(get_env_exports);
139
+ const getEnv = (env = process.env) => ({
140
+ /**
141
+ * An indicator to show that System Environment Variables have been exposed to your project's Deployments.
142
+ * @example "1"
143
+ */
144
+ VERCEL: get(env, "VERCEL"),
145
+ /**
146
+ * An indicator that the code is running in a Continuous Integration environment.
147
+ * @example "1"
148
+ */
149
+ CI: get(env, "CI"),
150
+ /**
151
+ * The Environment that the app is deployed and running on.
152
+ * @example "production"
153
+ */
154
+ VERCEL_ENV: get(env, "VERCEL_ENV"),
155
+ /**
156
+ * The domain name of the generated deployment URL. The value does not include the protocol scheme https://.
157
+ * NOTE: This Variable cannot be used in conjunction with Standard Deployment Protection.
158
+ * @example "*.vercel.app"
159
+ */
160
+ VERCEL_URL: get(env, "VERCEL_URL"),
161
+ /**
162
+ * The domain name of the generated Git branch URL. The value does not include the protocol scheme https://.
163
+ * @example "*-git-*.vercel.app"
164
+ */
165
+ VERCEL_BRANCH_URL: get(env, "VERCEL_BRANCH_URL"),
166
+ /**
167
+ * A production domain name of the project. This is useful to reliably generate links that point to production such as OG-image URLs.
168
+ * The value does not include the protocol scheme https://.
169
+ * @example "myproject.vercel.app"
170
+ */
171
+ VERCEL_PROJECT_PRODUCTION_URL: get(env, "VERCEL_PROJECT_PRODUCTION_URL"),
172
+ /**
173
+ * The ID of the Region where the app is running.
174
+ *
175
+ * Possible values:
176
+ * - arn1 (Stockholm, Sweden)
177
+ * - bom1 (Mumbai, India)
178
+ * - cdg1 (Paris, France)
179
+ * - cle1 (Cleveland, USA)
180
+ * - cpt1 (Cape Town, South Africa)
181
+ * - dub1 (Dublin, Ireland)
182
+ * - fra1 (Frankfurt, Germany)
183
+ * - gru1 (São Paulo, Brazil)
184
+ * - hkg1 (Hong Kong)
185
+ * - hnd1 (Tokyo, Japan)
186
+ * - iad1 (Washington, D.C., USA)
187
+ * - icn1 (Seoul, South Korea)
188
+ * - kix1 (Osaka, Japan)
189
+ * - lhr1 (London, United Kingdom)
190
+ * - pdx1 (Portland, USA)
191
+ * - sfo1 (San Francisco, USA)
192
+ * - sin1 (Singapore)
193
+ * - syd1 (Sydney, Australia)
194
+ * - dev1 (Development Region)
195
+ *
196
+ * @example "iad1"
197
+ */
198
+ VERCEL_REGION: get(env, "VERCEL_REGION"),
199
+ /**
200
+ * The unique identifier for the deployment, which can be used to implement Skew Protection.
201
+ * @example "dpl_7Gw5ZMBpQA8h9GF832KGp7nwbuh3"
202
+ */
203
+ VERCEL_DEPLOYMENT_ID: get(env, "VERCEL_DEPLOYMENT_ID"),
204
+ /**
205
+ * When Skew Protection is enabled in Project Settings, this value is set to 1.
206
+ * @example "1"
207
+ */
208
+ VERCEL_SKEW_PROTECTION_ENABLED: get(env, "VERCEL_SKEW_PROTECTION_ENABLED"),
209
+ /**
210
+ * The Protection Bypass for Automation value, if the secret has been generated in the project's Deployment Protection settings.
211
+ */
212
+ VERCEL_AUTOMATION_BYPASS_SECRET: get(env, "VERCEL_AUTOMATION_BYPASS_SECRET"),
213
+ /**
214
+ * The Git Provider the deployment is triggered from.
215
+ * @example "github"
216
+ */
217
+ VERCEL_GIT_PROVIDER: get(env, "VERCEL_GIT_PROVIDER"),
218
+ /**
219
+ * The origin repository the deployment is triggered from.
220
+ * @example "my-site"
221
+ */
222
+ VERCEL_GIT_REPO_SLUG: get(env, "VERCEL_GIT_REPO_SLUG"),
223
+ /**
224
+ * The account that owns the repository the deployment is triggered from.
225
+ * @example "acme"
226
+ */
227
+ VERCEL_GIT_REPO_OWNER: get(env, "VERCEL_GIT_REPO_OWNER"),
228
+ /**
229
+ * The ID of the repository the deployment is triggered from.
230
+ * @example "117716146"
231
+ */
232
+ VERCEL_GIT_REPO_ID: get(env, "VERCEL_GIT_REPO_ID"),
233
+ /**
234
+ * The git branch of the commit the deployment was triggered by.
235
+ * @example "improve-about-page"
236
+ */
237
+ VERCEL_GIT_COMMIT_REF: get(env, "VERCEL_GIT_COMMIT_REF"),
238
+ /**
239
+ * The git SHA of the commit the deployment was triggered by.
240
+ * @example "fa1eade47b73733d6312d5abfad33ce9e4068081"
241
+ */
242
+ VERCEL_GIT_COMMIT_SHA: get(env, "VERCEL_GIT_COMMIT_SHA"),
243
+ /**
244
+ * The message attached to the commit the deployment was triggered by.
245
+ * @example "Update about page"
246
+ */
247
+ VERCEL_GIT_COMMIT_MESSAGE: get(env, "VERCEL_GIT_COMMIT_MESSAGE"),
248
+ /**
249
+ * The username attached to the author of the commit that the project was deployed by.
250
+ * @example "johndoe"
251
+ */
252
+ VERCEL_GIT_COMMIT_AUTHOR_LOGIN: get(env, "VERCEL_GIT_COMMIT_AUTHOR_LOGIN"),
253
+ /**
254
+ * The name attached to the author of the commit that the project was deployed by.
255
+ * @example "John Doe"
256
+ */
257
+ VERCEL_GIT_COMMIT_AUTHOR_NAME: get(env, "VERCEL_GIT_COMMIT_AUTHOR_NAME"),
258
+ /**
259
+ * The git SHA of the last successful deployment for the project and branch.
260
+ * NOTE: This Variable is only exposed when an Ignored Build Step is provided.
261
+ * @example "fa1eade47b73733d6312d5abfad33ce9e4068080"
262
+ */
263
+ VERCEL_GIT_PREVIOUS_SHA: get(env, "VERCEL_GIT_PREVIOUS_SHA"),
264
+ /**
265
+ * The pull request id the deployment was triggered by. If a deployment is created on a branch before a pull request is made, this value will be an empty string.
266
+ * @example "23"
267
+ */
268
+ VERCEL_GIT_PULL_REQUEST_ID: get(env, "VERCEL_GIT_PULL_REQUEST_ID")
269
+ });
270
+ const get = (env, key) => {
271
+ const value = env[key];
272
+ return value === "" ? void 0 : value;
273
+ };
274
+ return getEnv_1;
275
+ }
276
+ var getContext_1;
277
+ var hasRequiredGetContext;
278
+ function requireGetContext() {
279
+ if (hasRequiredGetContext) return getContext_1;
280
+ hasRequiredGetContext = 1;
281
+ var __defProp = Object.defineProperty;
282
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
283
+ var __getOwnPropNames = Object.getOwnPropertyNames;
284
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
285
+ var __export = (target, all) => {
286
+ for (var name in all)
287
+ __defProp(target, name, { get: all[name], enumerable: true });
288
+ };
289
+ var __copyProps = (to, from, except, desc) => {
290
+ if (from && typeof from === "object" || typeof from === "function") {
291
+ for (let key of __getOwnPropNames(from))
292
+ if (!__hasOwnProp.call(to, key) && key !== except)
293
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
294
+ }
295
+ return to;
296
+ };
297
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
298
+ var get_context_exports = {};
299
+ __export(get_context_exports, {
300
+ SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
301
+ getContext: () => getContext
302
+ });
303
+ getContext_1 = __toCommonJS(get_context_exports);
304
+ const SYMBOL_FOR_REQ_CONTEXT = Symbol.for("@vercel/request-context");
305
+ function getContext() {
306
+ var _a, _b;
307
+ const fromSymbol = globalThis;
308
+ return ((_b = (_a = fromSymbol[SYMBOL_FOR_REQ_CONTEXT]) == null ? void 0 : _a.get) == null ? void 0 : _b.call(_a)) ?? {};
309
+ }
310
+ return getContext_1;
311
+ }
312
+ var deadline;
313
+ var hasRequiredDeadline;
314
+ function requireDeadline() {
315
+ if (hasRequiredDeadline) return deadline;
316
+ hasRequiredDeadline = 1;
317
+ var __defProp = Object.defineProperty;
318
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
319
+ var __getOwnPropNames = Object.getOwnPropertyNames;
320
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
321
+ var __export = (target, all) => {
322
+ for (var name in all)
323
+ __defProp(target, name, { get: all[name], enumerable: true });
324
+ };
325
+ var __copyProps = (to, from, except, desc) => {
326
+ if (from && typeof from === "object" || typeof from === "function") {
327
+ for (let key of __getOwnPropNames(from))
328
+ if (!__hasOwnProp.call(to, key) && key !== except)
329
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
330
+ }
331
+ return to;
332
+ };
333
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
334
+ var deadline_exports = {};
335
+ __export(deadline_exports, {
336
+ getDeadline: () => getDeadline
337
+ });
338
+ deadline = __toCommonJS(deadline_exports);
339
+ var import_get_context = requireGetContext();
340
+ function getDeadline() {
341
+ const deadline2 = (0, import_get_context.getContext)().deadline;
342
+ if (deadline2 === void 0) {
343
+ return void 0;
344
+ }
345
+ const date = new Date(deadline2);
346
+ if (isNaN(date.getTime())) {
347
+ return void 0;
348
+ }
349
+ return date;
350
+ }
351
+ return deadline;
352
+ }
353
+ var waitUntil_1;
354
+ var hasRequiredWaitUntil;
355
+ function requireWaitUntil() {
356
+ if (hasRequiredWaitUntil) return waitUntil_1;
357
+ hasRequiredWaitUntil = 1;
358
+ var __defProp = Object.defineProperty;
359
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
360
+ var __getOwnPropNames = Object.getOwnPropertyNames;
361
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
362
+ var __export = (target, all) => {
363
+ for (var name in all)
364
+ __defProp(target, name, { get: all[name], enumerable: true });
365
+ };
366
+ var __copyProps = (to, from, except, desc) => {
367
+ if (from && typeof from === "object" || typeof from === "function") {
368
+ for (let key of __getOwnPropNames(from))
369
+ if (!__hasOwnProp.call(to, key) && key !== except)
370
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
371
+ }
372
+ return to;
373
+ };
374
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
375
+ var wait_until_exports = {};
376
+ __export(wait_until_exports, {
377
+ waitUntil: () => waitUntil
378
+ });
379
+ waitUntil_1 = __toCommonJS(wait_until_exports);
380
+ var import_get_context = requireGetContext();
381
+ const waitUntil = (promise) => {
382
+ var _a, _b;
383
+ if (promise === null || typeof promise !== "object" || typeof promise.then !== "function") {
384
+ throw new TypeError(
385
+ `waitUntil can only be called with a Promise, got ${typeof promise}`
386
+ );
387
+ }
388
+ return (_b = (_a = (0, import_get_context.getContext)()).waitUntil) == null ? void 0 : _b.call(_a, promise);
389
+ };
390
+ return waitUntil_1;
391
+ }
392
+ var middleware;
393
+ var hasRequiredMiddleware;
394
+ function requireMiddleware() {
395
+ if (hasRequiredMiddleware) return middleware;
396
+ hasRequiredMiddleware = 1;
397
+ var __defProp = Object.defineProperty;
398
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
399
+ var __getOwnPropNames = Object.getOwnPropertyNames;
400
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
401
+ var __export = (target, all) => {
402
+ for (var name in all)
403
+ __defProp(target, name, { get: all[name], enumerable: true });
404
+ };
405
+ var __copyProps = (to, from, except, desc) => {
406
+ if (from && typeof from === "object" || typeof from === "function") {
407
+ for (let key of __getOwnPropNames(from))
408
+ if (!__hasOwnProp.call(to, key) && key !== except)
409
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
410
+ }
411
+ return to;
412
+ };
413
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
414
+ var middleware_exports = {};
415
+ __export(middleware_exports, {
416
+ next: () => next,
417
+ rewrite: () => rewrite
418
+ });
419
+ middleware = __toCommonJS(middleware_exports);
420
+ function handleMiddlewareField(init, headers2) {
421
+ var _a;
422
+ if ((_a = init == null ? void 0 : init.request) == null ? void 0 : _a.headers) {
423
+ if (!(init.request.headers instanceof Headers)) {
424
+ throw new Error("request.headers must be an instance of Headers");
425
+ }
426
+ const keys = [];
427
+ for (const [key, value] of init.request.headers) {
428
+ headers2.set("x-middleware-request-" + key, value);
429
+ keys.push(key);
430
+ }
431
+ headers2.set("x-middleware-override-headers", keys.join(","));
432
+ }
433
+ }
434
+ function rewrite(destination, init) {
435
+ const headers2 = new Headers((init == null ? void 0 : init.headers) ?? {});
436
+ headers2.set("x-middleware-rewrite", String(destination));
437
+ handleMiddlewareField(init, headers2);
438
+ return new Response(null, {
439
+ ...init,
440
+ headers: headers2
441
+ });
442
+ }
443
+ function next(init) {
444
+ const headers2 = new Headers((init == null ? void 0 : init.headers) ?? {});
445
+ headers2.set("x-middleware-next", "1");
446
+ handleMiddlewareField(init, headers2);
447
+ return new Response(null, {
448
+ ...init,
449
+ headers: headers2
450
+ });
451
+ }
452
+ return middleware;
453
+ }
454
+ var inMemoryCache;
455
+ var hasRequiredInMemoryCache;
456
+ function requireInMemoryCache() {
457
+ if (hasRequiredInMemoryCache) return inMemoryCache;
458
+ hasRequiredInMemoryCache = 1;
459
+ var __defProp = Object.defineProperty;
460
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
461
+ var __getOwnPropNames = Object.getOwnPropertyNames;
462
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
463
+ var __export = (target, all) => {
464
+ for (var name in all)
465
+ __defProp(target, name, { get: all[name], enumerable: true });
466
+ };
467
+ var __copyProps = (to, from, except, desc) => {
468
+ if (from && typeof from === "object" || typeof from === "function") {
469
+ for (let key of __getOwnPropNames(from))
470
+ if (!__hasOwnProp.call(to, key) && key !== except)
471
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
472
+ }
473
+ return to;
474
+ };
475
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
476
+ var in_memory_cache_exports = {};
477
+ __export(in_memory_cache_exports, {
478
+ InMemoryCache: () => InMemoryCache
479
+ });
480
+ inMemoryCache = __toCommonJS(in_memory_cache_exports);
481
+ class InMemoryCache {
482
+ constructor() {
483
+ this.cache = {};
484
+ }
485
+ async get(key) {
486
+ const entry = this.cache[key];
487
+ if (entry) {
488
+ if (entry.ttl && entry.lastModified + entry.ttl * 1e3 < Date.now()) {
489
+ await this.delete(key);
490
+ return null;
491
+ }
492
+ return JSON.parse(entry.value);
493
+ }
494
+ return null;
495
+ }
496
+ async set(key, value, options) {
497
+ const serialized = JSON.stringify(value ?? null);
498
+ this.cache[key] = {
499
+ value: serialized,
500
+ lastModified: Date.now(),
501
+ ttl: options == null ? void 0 : options.ttl,
502
+ tags: new Set((options == null ? void 0 : options.tags) || [])
503
+ };
504
+ }
505
+ async delete(key) {
506
+ delete this.cache[key];
507
+ }
508
+ async expireTag(tag) {
509
+ const tags = Array.isArray(tag) ? tag : [tag];
510
+ for (const key in this.cache) {
511
+ if (Object.prototype.hasOwnProperty.call(this.cache, key)) {
512
+ const entry = this.cache[key];
513
+ if (tags.some((t) => entry.tags.has(t))) {
514
+ delete this.cache[key];
515
+ }
516
+ }
517
+ }
518
+ }
519
+ }
520
+ return inMemoryCache;
521
+ }
522
+ var buildClient;
523
+ var hasRequiredBuildClient;
524
+ function requireBuildClient() {
525
+ if (hasRequiredBuildClient) return buildClient;
526
+ hasRequiredBuildClient = 1;
527
+ var __defProp = Object.defineProperty;
528
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
529
+ var __getOwnPropNames = Object.getOwnPropertyNames;
530
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
531
+ var __export = (target, all) => {
532
+ for (var name in all)
533
+ __defProp(target, name, { get: all[name], enumerable: true });
534
+ };
535
+ var __copyProps = (to, from, except, desc) => {
536
+ if (from && typeof from === "object" || typeof from === "function") {
537
+ for (let key of __getOwnPropNames(from))
538
+ if (!__hasOwnProp.call(to, key) && key !== except)
539
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
540
+ }
541
+ return to;
542
+ };
543
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
544
+ var build_client_exports = {};
545
+ __export(build_client_exports, {
546
+ BuildCache: () => BuildCache
547
+ });
548
+ buildClient = __toCommonJS(build_client_exports);
549
+ var import_index = requireCache();
550
+ class BuildCache {
551
+ constructor({
552
+ endpoint,
553
+ headers: headers2,
554
+ onError,
555
+ timeout = 500
556
+ }) {
557
+ this.get = async (key) => {
558
+ var _a, _b, _c, _d;
559
+ const controller = new AbortController();
560
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
561
+ try {
562
+ const res = await fetch(`${this.endpoint}${key}`, {
563
+ headers: this.headers,
564
+ method: "GET",
565
+ signal: controller.signal
566
+ });
567
+ if (res.status === 404) {
568
+ clearTimeout(timeoutId);
569
+ return null;
570
+ }
571
+ if (res.status === 200) {
572
+ const cacheState = res.headers.get(
573
+ import_index.HEADERS_VERCEL_CACHE_STATE
574
+ );
575
+ if (cacheState !== import_index.PkgCacheState.Fresh) {
576
+ (_b = (_a = res.body) == null ? void 0 : _a.cancel) == null ? void 0 : _b.call(_a);
577
+ clearTimeout(timeoutId);
578
+ return null;
579
+ }
580
+ const result = await res.json();
581
+ clearTimeout(timeoutId);
582
+ return result;
583
+ } else {
584
+ clearTimeout(timeoutId);
585
+ throw new Error(`Failed to get cache: ${res.statusText}`);
586
+ }
587
+ } catch (error) {
588
+ clearTimeout(timeoutId);
589
+ if (error.name === "AbortError") {
590
+ const timeoutError = new Error(
591
+ `Cache request timed out after ${this.timeout}ms`
592
+ );
593
+ timeoutError.stack = error.stack;
594
+ (_c = this.onError) == null ? void 0 : _c.call(this, timeoutError);
595
+ } else {
596
+ (_d = this.onError) == null ? void 0 : _d.call(this, error);
597
+ }
598
+ return null;
599
+ }
600
+ };
601
+ this.set = async (key, value, options) => {
602
+ var _a, _b;
603
+ const controller = new AbortController();
604
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
605
+ try {
606
+ const optionalHeaders = {};
607
+ if (options == null ? void 0 : options.ttl) {
608
+ optionalHeaders[import_index.HEADERS_VERCEL_REVALIDATE] = options.ttl.toString();
609
+ }
610
+ if ((options == null ? void 0 : options.tags) && options.tags.length > 0) {
611
+ optionalHeaders[import_index.HEADERS_VERCEL_CACHE_TAGS] = options.tags.join(",");
612
+ }
613
+ if (options == null ? void 0 : options.name) {
614
+ optionalHeaders[import_index.HEADERS_VERCEL_CACHE_ITEM_NAME] = options.name;
615
+ }
616
+ const res = await fetch(`${this.endpoint}${key}`, {
617
+ method: "POST",
618
+ headers: {
619
+ ...this.headers,
620
+ ...optionalHeaders
621
+ },
622
+ body: JSON.stringify(value),
623
+ signal: controller.signal
624
+ });
625
+ clearTimeout(timeoutId);
626
+ if (res.status !== 200) {
627
+ throw new Error(`Failed to set cache: ${res.status} ${res.statusText}`);
628
+ }
629
+ } catch (error) {
630
+ clearTimeout(timeoutId);
631
+ if (error.name === "AbortError") {
632
+ const timeoutError = new Error(
633
+ `Cache request timed out after ${this.timeout}ms`
634
+ );
635
+ timeoutError.stack = error.stack;
636
+ (_a = this.onError) == null ? void 0 : _a.call(this, timeoutError);
637
+ } else {
638
+ (_b = this.onError) == null ? void 0 : _b.call(this, error);
639
+ }
640
+ }
641
+ };
642
+ this.delete = async (key) => {
643
+ var _a, _b;
644
+ const controller = new AbortController();
645
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
646
+ try {
647
+ const res = await fetch(`${this.endpoint}${key}`, {
648
+ method: "DELETE",
649
+ headers: this.headers,
650
+ signal: controller.signal
651
+ });
652
+ clearTimeout(timeoutId);
653
+ if (res.status !== 200) {
654
+ throw new Error(`Failed to delete cache: ${res.statusText}`);
655
+ }
656
+ } catch (error) {
657
+ clearTimeout(timeoutId);
658
+ if (error.name === "AbortError") {
659
+ const timeoutError = new Error(
660
+ `Cache request timed out after ${this.timeout}ms`
661
+ );
662
+ timeoutError.stack = error.stack;
663
+ (_a = this.onError) == null ? void 0 : _a.call(this, timeoutError);
664
+ } else {
665
+ (_b = this.onError) == null ? void 0 : _b.call(this, error);
666
+ }
667
+ }
668
+ };
669
+ this.expireTag = async (tag) => {
670
+ var _a, _b;
671
+ const controller = new AbortController();
672
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
673
+ try {
674
+ if (Array.isArray(tag)) {
675
+ tag = tag.join(",");
676
+ }
677
+ const res = await fetch(`${this.endpoint}revalidate?tags=${tag}`, {
678
+ method: "POST",
679
+ headers: this.headers,
680
+ signal: controller.signal
681
+ });
682
+ clearTimeout(timeoutId);
683
+ if (res.status !== 200) {
684
+ throw new Error(`Failed to revalidate tag: ${res.statusText}`);
685
+ }
686
+ } catch (error) {
687
+ clearTimeout(timeoutId);
688
+ if (error.name === "AbortError") {
689
+ const timeoutError = new Error(
690
+ `Cache request timed out after ${this.timeout}ms`
691
+ );
692
+ timeoutError.stack = error.stack;
693
+ (_a = this.onError) == null ? void 0 : _a.call(this, timeoutError);
694
+ } else {
695
+ (_b = this.onError) == null ? void 0 : _b.call(this, error);
696
+ }
697
+ }
698
+ };
699
+ this.endpoint = endpoint;
700
+ this.headers = headers2;
701
+ this.onError = onError;
702
+ this.timeout = timeout;
703
+ }
704
+ }
705
+ return buildClient;
706
+ }
707
+ var cache;
708
+ var hasRequiredCache;
709
+ function requireCache() {
710
+ if (hasRequiredCache) return cache;
711
+ hasRequiredCache = 1;
712
+ var __defProp = Object.defineProperty;
713
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
714
+ var __getOwnPropNames = Object.getOwnPropertyNames;
715
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
716
+ var __export = (target, all) => {
717
+ for (var name in all)
718
+ __defProp(target, name, { get: all[name], enumerable: true });
719
+ };
720
+ var __copyProps = (to, from, except, desc) => {
721
+ if (from && typeof from === "object" || typeof from === "function") {
722
+ for (let key of __getOwnPropNames(from))
723
+ if (!__hasOwnProp.call(to, key) && key !== except)
724
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
725
+ }
726
+ return to;
727
+ };
728
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
729
+ var cache_exports = {};
730
+ __export(cache_exports, {
731
+ HEADERS_VERCEL_CACHE_ITEM_NAME: () => HEADERS_VERCEL_CACHE_ITEM_NAME,
732
+ HEADERS_VERCEL_CACHE_STATE: () => HEADERS_VERCEL_CACHE_STATE,
733
+ HEADERS_VERCEL_CACHE_TAGS: () => HEADERS_VERCEL_CACHE_TAGS,
734
+ HEADERS_VERCEL_REVALIDATE: () => HEADERS_VERCEL_REVALIDATE,
735
+ PkgCacheState: () => PkgCacheState,
736
+ getCache: () => getCache
737
+ });
738
+ cache = __toCommonJS(cache_exports);
739
+ var import_get_context = requireGetContext();
740
+ var import_in_memory_cache = requireInMemoryCache();
741
+ var import_build_client = requireBuildClient();
742
+ const defaultKeyHashFunction = (key) => {
743
+ let hash = 5381;
744
+ for (let i = 0; i < key.length; i++) {
745
+ hash = hash * 33 ^ key.charCodeAt(i);
746
+ }
747
+ return (hash >>> 0).toString(16);
748
+ };
749
+ const defaultNamespaceSeparator = "$";
750
+ let inMemoryCacheInstance = null;
751
+ let buildCacheInstance = null;
752
+ const getCache = (cacheOptions) => {
753
+ const resolveCache = () => {
754
+ let cache2;
755
+ if ((0, import_get_context.getContext)().cache) {
756
+ cache2 = (0, import_get_context.getContext)().cache;
757
+ } else {
758
+ cache2 = getCacheImplementation(
759
+ process.env.SUSPENSE_CACHE_DEBUG === "true"
760
+ );
761
+ }
762
+ return cache2;
763
+ };
764
+ return wrapWithKeyTransformation(
765
+ resolveCache,
766
+ createKeyTransformer(cacheOptions)
767
+ );
768
+ };
769
+ function createKeyTransformer(cacheOptions) {
770
+ const hashFunction = (cacheOptions == null ? void 0 : cacheOptions.keyHashFunction) || defaultKeyHashFunction;
771
+ return (key) => {
772
+ if (!(cacheOptions == null ? void 0 : cacheOptions.namespace))
773
+ return hashFunction(key);
774
+ const separator = cacheOptions.namespaceSeparator || defaultNamespaceSeparator;
775
+ return `${cacheOptions.namespace}${separator}${hashFunction(key)}`;
776
+ };
777
+ }
778
+ function wrapWithKeyTransformation(resolveCache, makeKey) {
779
+ return {
780
+ get: (key) => {
781
+ return resolveCache().get(makeKey(key));
782
+ },
783
+ set: (key, value, options) => {
784
+ return resolveCache().set(makeKey(key), value, {
785
+ ...options,
786
+ name: (options == null ? void 0 : options.name) ?? key
787
+ });
788
+ },
789
+ delete: (key) => {
790
+ return resolveCache().delete(makeKey(key));
791
+ },
792
+ expireTag: (tag) => {
793
+ return resolveCache().expireTag(tag);
794
+ }
795
+ };
796
+ }
797
+ let warnedCacheUnavailable = false;
798
+ function getCacheImplementation(debug) {
799
+ if (!inMemoryCacheInstance) {
800
+ inMemoryCacheInstance = new import_in_memory_cache.InMemoryCache();
801
+ }
802
+ if (process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE === "true") {
803
+ debug && console.log("Using InMemoryCache as build cache is disabled");
804
+ return inMemoryCacheInstance;
805
+ }
806
+ const { RUNTIME_CACHE_ENDPOINT, RUNTIME_CACHE_HEADERS } = process.env;
807
+ if (debug) {
808
+ console.log("Runtime cache environment variables:", {
809
+ RUNTIME_CACHE_ENDPOINT,
810
+ RUNTIME_CACHE_HEADERS
811
+ });
812
+ }
813
+ if (!RUNTIME_CACHE_ENDPOINT || !RUNTIME_CACHE_HEADERS) {
814
+ if (!warnedCacheUnavailable) {
815
+ console.warn(
816
+ "Runtime Cache unavailable in this environment. Falling back to in-memory cache."
817
+ );
818
+ warnedCacheUnavailable = true;
819
+ }
820
+ return inMemoryCacheInstance;
821
+ }
822
+ if (!buildCacheInstance) {
823
+ let parsedHeaders = {};
824
+ try {
825
+ parsedHeaders = JSON.parse(RUNTIME_CACHE_HEADERS);
826
+ } catch (e) {
827
+ console.error("Failed to parse RUNTIME_CACHE_HEADERS:", e);
828
+ return inMemoryCacheInstance;
829
+ }
830
+ let timeout = 500;
831
+ if (process.env.RUNTIME_CACHE_TIMEOUT) {
832
+ const parsed = parseInt(process.env.RUNTIME_CACHE_TIMEOUT, 10);
833
+ if (!isNaN(parsed) && parsed > 0) {
834
+ timeout = parsed;
835
+ } else {
836
+ console.warn(
837
+ `Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${timeout}ms`
838
+ );
839
+ }
840
+ }
841
+ buildCacheInstance = new import_build_client.BuildCache({
842
+ endpoint: RUNTIME_CACHE_ENDPOINT,
843
+ headers: parsedHeaders,
844
+ onError: (error) => console.error(error),
845
+ timeout
846
+ });
847
+ }
848
+ return buildCacheInstance;
849
+ }
850
+ var PkgCacheState = /* @__PURE__ */ ((PkgCacheState2) => {
851
+ PkgCacheState2["Fresh"] = "fresh";
852
+ PkgCacheState2["Stale"] = "stale";
853
+ PkgCacheState2["Expired"] = "expired";
854
+ PkgCacheState2["NotFound"] = "notFound";
855
+ PkgCacheState2["Error"] = "error";
856
+ return PkgCacheState2;
857
+ })(PkgCacheState || {});
858
+ const HEADERS_VERCEL_CACHE_STATE = "x-vercel-cache-state";
859
+ const HEADERS_VERCEL_REVALIDATE = "x-vercel-revalidate";
860
+ const HEADERS_VERCEL_CACHE_TAGS = "x-vercel-cache-tags";
861
+ const HEADERS_VERCEL_CACHE_ITEM_NAME = "x-vercel-cache-item-name";
862
+ return cache;
863
+ }
864
+ var dbConnections;
865
+ var hasRequiredDbConnections;
866
+ function requireDbConnections() {
867
+ if (hasRequiredDbConnections) return dbConnections;
868
+ hasRequiredDbConnections = 1;
869
+ var __defProp = Object.defineProperty;
870
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
871
+ var __getOwnPropNames = Object.getOwnPropertyNames;
872
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
873
+ var __export = (target, all) => {
874
+ for (var name in all)
875
+ __defProp(target, name, { get: all[name], enumerable: true });
876
+ };
877
+ var __copyProps = (to, from, except, desc) => {
878
+ if (from && typeof from === "object" || typeof from === "function") {
879
+ for (let key of __getOwnPropNames(from))
880
+ if (!__hasOwnProp.call(to, key) && key !== except)
881
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
882
+ }
883
+ return to;
884
+ };
885
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
886
+ var db_connections_exports = {};
887
+ __export(db_connections_exports, {
888
+ attachDatabasePool: () => attachDatabasePool,
889
+ experimental_attachDatabasePool: () => experimental_attachDatabasePool
890
+ });
891
+ dbConnections = __toCommonJS(db_connections_exports);
892
+ var import_get_context = requireGetContext();
893
+ const DEBUG = !!process.env.DEBUG;
894
+ function getIdleTimeout(dbPool) {
895
+ if ("options" in dbPool && dbPool.options) {
896
+ if ("idleTimeoutMillis" in dbPool.options) {
897
+ return typeof dbPool.options.idleTimeoutMillis === "number" ? dbPool.options.idleTimeoutMillis : 1e4;
898
+ }
899
+ if ("maxIdleTimeMS" in dbPool.options) {
900
+ return typeof dbPool.options.maxIdleTimeMS === "number" ? dbPool.options.maxIdleTimeMS : 0;
901
+ }
902
+ if ("status" in dbPool) {
903
+ return 5e3;
904
+ }
905
+ if ("connect" in dbPool && "execute" in dbPool) {
906
+ return 3e4;
907
+ }
908
+ }
909
+ if ("config" in dbPool && dbPool.config) {
910
+ if ("connectionConfig" in dbPool.config && dbPool.config.connectionConfig) {
911
+ return dbPool.config.connectionConfig.idleTimeout || 6e4;
912
+ }
913
+ if ("idleTimeout" in dbPool.config) {
914
+ return typeof dbPool.config.idleTimeout === "number" ? dbPool.config.idleTimeout : 6e4;
915
+ }
916
+ }
917
+ if ("poolTimeout" in dbPool) {
918
+ return typeof dbPool.poolTimeout === "number" ? dbPool.poolTimeout : 6e4;
919
+ }
920
+ if ("idleTimeout" in dbPool) {
921
+ return typeof dbPool.idleTimeout === "number" ? dbPool.idleTimeout : 0;
922
+ }
923
+ return 1e4;
924
+ }
925
+ let idleTimeout = null;
926
+ let idleTimeoutResolve = () => {
927
+ };
928
+ const bootTime = Date.now();
929
+ const maximumDuration = 15 * 60 * 1e3 - 1e3;
930
+ function waitUntilIdleTimeout(dbPool) {
931
+ if (!process.env.VERCEL_URL || // This is not set during builds where we don't need to wait for idle connections using the mechanism
932
+ !process.env.VERCEL_REGION) {
933
+ return;
934
+ }
935
+ if (idleTimeout) {
936
+ clearTimeout(idleTimeout);
937
+ idleTimeoutResolve();
938
+ }
939
+ const promise = new Promise((resolve) => {
940
+ idleTimeoutResolve = resolve;
941
+ });
942
+ const waitTime = Math.min(
943
+ getIdleTimeout(dbPool) + 100,
944
+ Math.max(100, maximumDuration - (Date.now() - bootTime))
945
+ );
946
+ idleTimeout = setTimeout(() => {
947
+ idleTimeoutResolve == null ? void 0 : idleTimeoutResolve();
948
+ if (DEBUG) {
949
+ console.log("Database pool idle timeout reached. Releasing connections.");
950
+ }
951
+ }, waitTime);
952
+ const requestContext = (0, import_get_context.getContext)();
953
+ if (requestContext == null ? void 0 : requestContext.waitUntil) {
954
+ requestContext.waitUntil(promise);
955
+ } else {
956
+ console.warn("Pool release event triggered outside of request scope.");
957
+ }
958
+ }
959
+ function attachDatabasePool(dbPool) {
960
+ if (idleTimeout) {
961
+ idleTimeoutResolve == null ? void 0 : idleTimeoutResolve();
962
+ clearTimeout(idleTimeout);
963
+ }
964
+ if ("on" in dbPool && dbPool.on && "options" in dbPool && "idleTimeoutMillis" in dbPool.options) {
965
+ const pgPool = dbPool;
966
+ pgPool.on("release", () => {
967
+ if (DEBUG) {
968
+ console.log("Client released from pool");
969
+ }
970
+ waitUntilIdleTimeout(dbPool);
971
+ });
972
+ return;
973
+ } else if ("on" in dbPool && dbPool.on && "config" in dbPool && dbPool.config && "connectionConfig" in dbPool.config) {
974
+ const mysqlPool = dbPool;
975
+ mysqlPool.on("release", () => {
976
+ if (DEBUG) {
977
+ console.log("MySQL client released from pool");
978
+ }
979
+ waitUntilIdleTimeout(dbPool);
980
+ });
981
+ return;
982
+ } else if ("on" in dbPool && dbPool.on && "config" in dbPool && dbPool.config && "idleTimeout" in dbPool.config) {
983
+ const mysql2Pool = dbPool;
984
+ mysql2Pool.on("release", () => {
985
+ if (DEBUG) {
986
+ console.log("MySQL2/MariaDB client released from pool");
987
+ }
988
+ waitUntilIdleTimeout(dbPool);
989
+ });
990
+ return;
991
+ }
992
+ if ("on" in dbPool && dbPool.on && "options" in dbPool && dbPool.options && "maxIdleTimeMS" in dbPool.options) {
993
+ const mongoPool = dbPool;
994
+ mongoPool.on("connectionCheckedOut", () => {
995
+ if (DEBUG) {
996
+ console.log("MongoDB connection checked out");
997
+ }
998
+ waitUntilIdleTimeout(dbPool);
999
+ });
1000
+ return;
1001
+ }
1002
+ if ("on" in dbPool && dbPool.on && "options" in dbPool && dbPool.options && "socket" in dbPool.options) {
1003
+ const redisPool = dbPool;
1004
+ redisPool.on("end", () => {
1005
+ if (DEBUG) {
1006
+ console.log("Redis connection ended");
1007
+ }
1008
+ waitUntilIdleTimeout(dbPool);
1009
+ });
1010
+ return;
1011
+ }
1012
+ throw new Error("Unsupported database pool type");
1013
+ }
1014
+ const experimental_attachDatabasePool = attachDatabasePool;
1015
+ return dbConnections;
1016
+ }
1017
+ var purge;
1018
+ var hasRequiredPurge;
1019
+ function requirePurge() {
1020
+ if (hasRequiredPurge) return purge;
1021
+ hasRequiredPurge = 1;
1022
+ var __defProp = Object.defineProperty;
1023
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1024
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1025
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1026
+ var __export = (target, all) => {
1027
+ for (var name in all)
1028
+ __defProp(target, name, { get: all[name], enumerable: true });
1029
+ };
1030
+ var __copyProps = (to, from, except, desc) => {
1031
+ if (from && typeof from === "object" || typeof from === "function") {
1032
+ for (let key of __getOwnPropNames(from))
1033
+ if (!__hasOwnProp.call(to, key) && key !== except)
1034
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1035
+ }
1036
+ return to;
1037
+ };
1038
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1039
+ var purge_exports = {};
1040
+ __export(purge_exports, {
1041
+ dangerouslyDeleteBySrcImage: () => dangerouslyDeleteBySrcImage,
1042
+ dangerouslyDeleteByTag: () => dangerouslyDeleteByTag,
1043
+ invalidateBySrcImage: () => invalidateBySrcImage,
1044
+ invalidateByTag: () => invalidateByTag
1045
+ });
1046
+ purge = __toCommonJS(purge_exports);
1047
+ var import_get_context = requireGetContext();
1048
+ const invalidateByTag = (tag) => {
1049
+ const api = (0, import_get_context.getContext)().purge;
1050
+ if (api) {
1051
+ return api.invalidateByTag(tag);
1052
+ }
1053
+ return Promise.resolve();
1054
+ };
1055
+ const dangerouslyDeleteByTag = (tag, options) => {
1056
+ const api = (0, import_get_context.getContext)().purge;
1057
+ if (api) {
1058
+ return api.dangerouslyDeleteByTag(tag, options);
1059
+ }
1060
+ return Promise.resolve();
1061
+ };
1062
+ const invalidateBySrcImage = (src) => {
1063
+ const api = (0, import_get_context.getContext)().purge;
1064
+ return api ? api.invalidateBySrcImage(src) : Promise.resolve();
1065
+ };
1066
+ const dangerouslyDeleteBySrcImage = (src, options) => {
1067
+ const api = (0, import_get_context.getContext)().purge;
1068
+ return api ? api.dangerouslyDeleteBySrcImage(src, options) : Promise.resolve();
1069
+ };
1070
+ return purge;
1071
+ }
1072
+ var addcachetag;
1073
+ var hasRequiredAddcachetag;
1074
+ function requireAddcachetag() {
1075
+ if (hasRequiredAddcachetag) return addcachetag;
1076
+ hasRequiredAddcachetag = 1;
1077
+ var __defProp = Object.defineProperty;
1078
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1079
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1080
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1081
+ var __export = (target, all) => {
1082
+ for (var name in all)
1083
+ __defProp(target, name, { get: all[name], enumerable: true });
1084
+ };
1085
+ var __copyProps = (to, from, except, desc) => {
1086
+ if (from && typeof from === "object" || typeof from === "function") {
1087
+ for (let key of __getOwnPropNames(from))
1088
+ if (!__hasOwnProp.call(to, key) && key !== except)
1089
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1090
+ }
1091
+ return to;
1092
+ };
1093
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1094
+ var addcachetag_exports = {};
1095
+ __export(addcachetag_exports, {
1096
+ addCacheTag: () => addCacheTag
1097
+ });
1098
+ addcachetag = __toCommonJS(addcachetag_exports);
1099
+ var import_get_context = requireGetContext();
1100
+ const addCacheTag = (tag) => {
1101
+ const addCacheTag2 = (0, import_get_context.getContext)().addCacheTag;
1102
+ if (addCacheTag2) {
1103
+ return addCacheTag2(tag);
1104
+ }
1105
+ return Promise.resolve();
1106
+ };
1107
+ return addcachetag;
1108
+ }
1109
+ var websocket;
1110
+ var hasRequiredWebsocket;
1111
+ function requireWebsocket() {
1112
+ if (hasRequiredWebsocket) return websocket;
1113
+ hasRequiredWebsocket = 1;
1114
+ var __defProp = Object.defineProperty;
1115
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1116
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1117
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1118
+ var __export = (target, all) => {
1119
+ for (var name in all)
1120
+ __defProp(target, name, { get: all[name], enumerable: true });
1121
+ };
1122
+ var __copyProps = (to, from, except, desc) => {
1123
+ if (from && typeof from === "object" || typeof from === "function") {
1124
+ for (let key of __getOwnPropNames(from))
1125
+ if (!__hasOwnProp.call(to, key) && key !== except)
1126
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1127
+ }
1128
+ return to;
1129
+ };
1130
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1131
+ var websocket_exports = {};
1132
+ __export(websocket_exports, {
1133
+ experimental_upgradeWebSocket: () => experimental_upgradeWebSocket
1134
+ });
1135
+ websocket = __toCommonJS(websocket_exports);
1136
+ var import_get_context = requireGetContext();
1137
+ const DEFAULT_MAX_PAYLOAD = 256 * 1024;
1138
+ async function loadWebSocketServer() {
1139
+ try {
1140
+ const ws = await import("./wrapper-BxY6HvLW.js");
1141
+ return ws.WebSocketServer;
1142
+ } catch {
1143
+ throw new Error(
1144
+ 'The "ws" package is required for experimental_upgradeWebSocket(). Install it with: npm install ws'
1145
+ );
1146
+ }
1147
+ }
1148
+ async function experimental_upgradeWebSocket(handler, options = {}) {
1149
+ const ctx = (0, import_get_context.getContext)();
1150
+ if (typeof ctx.upgradeWebSocket !== "function") {
1151
+ throw new Error(
1152
+ "experimental_upgradeWebSocket is not available in the current runtime environment. This feature requires a Vercel runtime that supports WebSocket upgrades."
1153
+ );
1154
+ }
1155
+ const WebSocketServer = await loadWebSocketServer();
1156
+ const { req, socket, head } = ctx.upgradeWebSocket();
1157
+ const wss = new WebSocketServer({
1158
+ noServer: true,
1159
+ maxPayload: options.maxPayload ?? DEFAULT_MAX_PAYLOAD
1160
+ });
1161
+ const ws = await new Promise((resolve, reject) => {
1162
+ const cleanup = () => {
1163
+ socket.removeListener("error", onError);
1164
+ socket.removeListener("close", onClose);
1165
+ };
1166
+ const rejectUpgrade = (err) => {
1167
+ cleanup();
1168
+ if (err instanceof Error) {
1169
+ reject(err);
1170
+ return;
1171
+ }
1172
+ const error = new Error("WebSocket upgrade failed");
1173
+ error.cause = err;
1174
+ reject(error);
1175
+ };
1176
+ const resolveUpgrade = (ws2) => {
1177
+ cleanup();
1178
+ resolve(ws2);
1179
+ };
1180
+ const onError = (err) => rejectUpgrade(err);
1181
+ const onClose = () => rejectUpgrade(
1182
+ new Error("socket closed before the WebSocket upgrade completed")
1183
+ );
1184
+ socket.once("error", onError);
1185
+ socket.once("close", onClose);
1186
+ try {
1187
+ wss.handleUpgrade(req, socket, head, resolveUpgrade);
1188
+ } catch (err) {
1189
+ rejectUpgrade(err);
1190
+ }
1191
+ });
1192
+ try {
1193
+ await handler(ws);
1194
+ } catch (err) {
1195
+ ws.close(1011, "WebSocket handler failed");
1196
+ throw err;
1197
+ }
1198
+ return new Response(null, { status: 204 });
1199
+ }
1200
+ return websocket;
1201
+ }
1202
+ var functions;
1203
+ var hasRequiredFunctions;
1204
+ function requireFunctions() {
1205
+ if (hasRequiredFunctions) return functions;
1206
+ hasRequiredFunctions = 1;
1207
+ var __defProp = Object.defineProperty;
1208
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
1209
+ var __getOwnPropNames = Object.getOwnPropertyNames;
1210
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
1211
+ var __export = (target, all) => {
1212
+ for (var name in all)
1213
+ __defProp(target, name, { get: all[name], enumerable: true });
1214
+ };
1215
+ var __copyProps = (to, from, except, desc) => {
1216
+ if (from && typeof from === "object" || typeof from === "function") {
1217
+ for (let key of __getOwnPropNames(from))
1218
+ if (!__hasOwnProp.call(to, key) && key !== except)
1219
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
1220
+ }
1221
+ return to;
1222
+ };
1223
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1224
+ var src_exports = {};
1225
+ __export(src_exports, {
1226
+ addCacheTag: () => import_addcachetag.addCacheTag,
1227
+ attachDatabasePool: () => import_db_connections.attachDatabasePool,
1228
+ dangerouslyDeleteBySrcImage: () => import_purge.dangerouslyDeleteBySrcImage,
1229
+ dangerouslyDeleteByTag: () => import_purge.dangerouslyDeleteByTag,
1230
+ experimental_attachDatabasePool: () => import_db_connections.experimental_attachDatabasePool,
1231
+ experimental_upgradeWebSocket: () => import_websocket.experimental_upgradeWebSocket,
1232
+ geolocation: () => import_headers.geolocation,
1233
+ getCache: () => import_cache.getCache,
1234
+ getDeadline: () => import_deadline.getDeadline,
1235
+ getEnv: () => import_get_env.getEnv,
1236
+ invalidateBySrcImage: () => import_purge.invalidateBySrcImage,
1237
+ invalidateByTag: () => import_purge.invalidateByTag,
1238
+ ipAddress: () => import_headers.ipAddress,
1239
+ next: () => import_middleware.next,
1240
+ rewrite: () => import_middleware.rewrite,
1241
+ waitUntil: () => import_wait_until.waitUntil
1242
+ });
1243
+ functions = __toCommonJS(src_exports);
1244
+ var import_headers = requireHeaders();
1245
+ var import_get_env = requireGetEnv();
1246
+ var import_deadline = requireDeadline();
1247
+ var import_wait_until = requireWaitUntil();
1248
+ var import_middleware = requireMiddleware();
1249
+ var import_cache = requireCache();
1250
+ var import_db_connections = requireDbConnections();
1251
+ var import_purge = requirePurge();
1252
+ var import_addcachetag = requireAddcachetag();
1253
+ var import_websocket = requireWebsocket();
1254
+ return functions;
1255
+ }
1256
+ var functionsExports = requireFunctions();
1257
+ const index = /* @__PURE__ */ _mergeNamespaces({
1258
+ __proto__: null
1259
+ }, [functionsExports]);
1260
+ export {
1261
+ index as i
1262
+ };