@teyik0/furin 0.4.0-alpha.1 → 0.4.0-alpha.2
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/dist/adapter/bun.d.ts +2 -18
- package/dist/adapter/package.d.ts +2 -2
- package/dist/adapter/runtime-build.d.ts +33 -0
- package/dist/adapter/vercel.d.ts +3 -0
- package/dist/build/client.d.ts +1 -1
- package/dist/build/compile-entry.d.ts +4 -3
- package/dist/build/compile-entry.ts +24 -69
- package/dist/build/entry-template.d.ts +4 -2
- package/dist/build/entry-template.ts +31 -8
- package/dist/build/index.d.ts +1 -1
- package/dist/build/index.js +8596 -6375
- package/dist/build/ssg-cache.d.ts +13 -0
- package/dist/build/types.d.ts +25 -2
- package/dist/build/virtual-entry.d.ts +8 -0
- package/dist/cache.d.ts +5 -0
- package/dist/cache.js +97 -0
- package/dist/cli/index.js +9099 -6771
- package/dist/cli/preview.d.ts +7 -0
- package/dist/client/boundaries.d.ts +1 -0
- package/dist/client/browser-events-runtime.d.ts +2 -0
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/define-route.d.ts +9 -8
- package/dist/client/dev-error-overlay.d.ts +1 -0
- package/dist/client/dev-error-overlay.ts +201 -0
- package/dist/client/document.d.ts +1 -0
- package/dist/client/hmr.d.ts +4 -2
- package/dist/client/link.js +251 -82
- package/dist/client/router/provider.d.ts +1 -1
- package/dist/client/router/sync-catch-up.d.ts +1 -1
- package/dist/client/router/types.d.ts +8 -10
- package/dist/client.js +37 -23
- package/dist/config.d.ts +17 -0
- package/dist/config.js +9 -1
- package/dist/define-route.d.ts +11 -8
- package/dist/devtools/protocol.d.ts +2 -2
- package/dist/furin.d.ts +1 -1
- package/dist/furin.js +12991 -9491
- package/dist/plugin/index.js +476 -7
- package/dist/plugin/routes.d.ts +4 -3
- package/dist/rsc/build/index.d.ts +5 -1
- package/dist/server/browser-events/plugin.d.ts +11 -0
- package/dist/server/browser-events/types.d.ts +9 -0
- package/dist/server/cache/invalidation.d.ts +1 -2
- package/dist/server/cache/isr.d.ts +1 -0
- package/dist/server/cache/purger.d.ts +7 -0
- package/dist/server/cache/runtime-cache.d.ts +21 -0
- package/dist/server/dev/browser-events.d.ts +4 -0
- package/dist/server/dev/diagnostics.d.ts +39 -0
- package/dist/server/dev/error.d.ts +17 -0
- package/dist/server/dev/graph.d.ts +86 -0
- package/dist/server/dev/plugin.d.ts +9 -0
- package/dist/server/dev/request-security.d.ts +1 -0
- package/dist/server/dev/rewrite-module-specifiers.d.ts +7 -0
- package/dist/server/dev/runtime.production.d.ts +5 -0
- package/dist/server/dev/symbolicate.d.ts +11 -0
- package/dist/server/dev/transform-failure.d.ts +4 -0
- package/dist/server/dev-page-plugin.production.d.ts +1 -0
- package/dist/server/devtools/hub.d.ts +3 -2
- package/dist/server/devtools/instrumentation.d.ts +1 -1
- package/dist/server/devtools/instrumentation.production.d.ts +1 -1
- package/dist/server/devtools/plugin.d.ts +1 -1
- package/dist/server/external-prerender.d.ts +2 -0
- package/dist/server/instance.d.ts +2 -2
- package/dist/server/internal.d.ts +14 -2
- package/dist/server/internal.js +436 -1
- package/dist/server/render/element.d.ts +1 -0
- package/dist/server/render/index.d.ts +1 -1
- package/dist/server/render/index.ts +1 -1
- package/dist/server/render/ppr-document.d.ts +21 -0
- package/dist/server/render/ppr-request.d.ts +26 -0
- package/dist/server/render/ppr-route.d.ts +3 -1
- package/dist/server/render/shell.ts +0 -12
- package/dist/server/render/ssg.d.ts +2 -0
- package/dist/server/render/ssr.d.ts +17 -6
- package/dist/server/router/hmr.production.d.ts +2 -0
- package/dist/server/router/patterns.d.ts +1 -0
- package/dist/server/router/plugin.d.ts +3 -1
- package/dist/server/sync/adapter.d.ts +13 -0
- package/dist/server/sync/config.d.ts +5 -5
- package/dist/server/sync/index.d.ts +6 -6
- package/dist/server/sync/index.js +491 -516
- package/dist/server/sync/notifier.d.ts +1 -0
- package/dist/server/sync/postgres/index.d.ts +12 -1
- package/dist/server/sync/postgres/index.js +101 -6
- package/dist/server/sync/stream.d.ts +4 -13
- package/dist/shared/await.d.ts +3 -3
- package/dist/shared/browser-events.d.ts +22 -0
- package/dist/shared/compact-json.d.ts +8 -0
- package/dist/shared/deferred-ndjson.d.ts +6 -5
- package/dist/shared/dev-diagnostics.d.ts +36 -0
- package/dist/shared/prefix.d.ts +2 -0
- package/package.json +16 -7
- package/src/adapter/README.md +45 -0
- package/src/adapter/bun.ts +45 -268
- package/src/adapter/package.ts +15 -9
- package/src/adapter/runtime-build.ts +375 -0
- package/src/adapter/static.ts +79 -2
- package/src/adapter/vercel.ts +857 -0
- package/src/build/client.ts +38 -13
- package/src/build/compile-entry.ts +24 -69
- package/src/build/entry-template.ts +31 -8
- package/src/build/hydrate.ts +60 -20
- package/src/build/index.ts +19 -5
- package/src/build/production-instrumentation.ts +56 -4
- package/src/build/shared.ts +2 -1
- package/src/build/ssg-cache.ts +97 -11
- package/src/build/types.ts +31 -2
- package/src/build/virtual-entry.ts +27 -0
- package/src/cache.ts +14 -0
- package/src/cli/index.ts +55 -3
- package/src/cli/preview.ts +90 -0
- package/src/client/boundaries.tsx +10 -1
- package/src/client/browser-events-runtime.ts +204 -0
- package/src/client/browser-events.ts +22 -0
- package/src/client/define-route.ts +7 -17
- package/src/client/dev-error-overlay.ts +201 -0
- package/src/client/document.tsx +4 -7
- package/src/client/hmr.ts +26 -3
- package/src/client/router/boundary-tree.tsx +4 -4
- package/src/client/router/provider.tsx +165 -63
- package/src/client/router/sync-catch-up.ts +3 -4
- package/src/client/router/types.ts +6 -6
- package/src/config.ts +25 -0
- package/src/define-route.ts +20 -7
- package/src/devtools/devtools-element.js +56 -77
- package/src/devtools/protocol.ts +2 -2
- package/src/furin.ts +157 -77
- package/src/plugin/routes.ts +206 -36
- package/src/plugin/transform-client.ts +685 -3
- package/src/react-dom-edge.d.ts +6 -0
- package/src/rsc/build/index.ts +15 -3
- package/src/server/auto-invalidate/runtime.ts +5 -2
- package/src/server/browser-events/plugin.ts +168 -0
- package/src/server/browser-events/types.ts +11 -0
- package/src/server/cache/dev-loader.ts +30 -29
- package/src/server/cache/invalidation.ts +13 -22
- package/src/server/cache/isr.ts +9 -0
- package/src/server/cache/purger.ts +41 -0
- package/src/server/cache/runtime-cache.ts +137 -0
- package/src/server/dev/browser-events.ts +54 -0
- package/src/server/dev/diagnostics.ts +297 -0
- package/src/server/dev/error.ts +148 -0
- package/src/server/dev/graph.ts +438 -0
- package/src/server/dev/plugin.ts +130 -0
- package/src/server/dev/request-security.ts +38 -0
- package/src/server/dev/rewrite-module-specifiers.ts +81 -0
- package/src/server/dev/runtime.production.ts +24 -0
- package/src/server/dev/symbolicate.ts +135 -0
- package/src/server/dev/transform-failure.ts +8 -0
- package/src/server/dev-page-plugin.production.ts +3 -0
- package/src/server/dev-page-plugin.ts +92 -53
- package/src/server/devtools/hub.ts +6 -5
- package/src/server/devtools/instrumentation.production.ts +1 -1
- package/src/server/devtools/instrumentation.ts +12 -6
- package/src/server/devtools/plugin.ts +7 -150
- package/src/server/external-prerender.ts +10 -0
- package/src/server/instance.ts +3 -3
- package/src/server/internal.ts +39 -2
- package/src/server/render/assemble.ts +4 -4
- package/src/server/render/document.tsx +13 -4
- package/src/server/render/element.tsx +18 -14
- package/src/server/render/index.ts +1 -1
- package/src/server/render/isr.ts +44 -19
- package/src/server/render/loaders.ts +13 -3
- package/src/server/render/not-found.ts +28 -4
- package/src/server/render/ppr-document.ts +239 -0
- package/src/server/render/ppr-request.ts +104 -0
- package/src/server/render/ppr-route.ts +152 -31
- package/src/server/render/shell.ts +0 -12
- package/src/server/render/ssg.ts +38 -20
- package/src/server/render/ssr.ts +211 -83
- package/src/server/render/template.ts +47 -11
- package/src/server/router/defined-route.ts +7 -39
- package/src/server/router/hmr.production.ts +7 -0
- package/src/server/router/hmr.ts +106 -67
- package/src/server/router/patterns.ts +5 -1
- package/src/server/router/plugin.ts +124 -35
- package/src/server/router/source-version.ts +3 -10
- package/src/server/sync/adapter.ts +13 -0
- package/src/server/sync/config.ts +12 -12
- package/src/server/sync/index.ts +8 -8
- package/src/server/sync/notifier.ts +1 -0
- package/src/server/sync/plugin.ts +4 -1
- package/src/server/sync/postgres/index.ts +111 -5
- package/src/server/sync/runtime.ts +12 -0
- package/src/server/sync/stream.ts +78 -113
- package/src/shared/await.tsx +3 -3
- package/src/shared/browser-events.ts +28 -0
- package/src/shared/compact-json.ts +77 -0
- package/src/shared/deferred-ndjson.ts +20 -6
- package/src/shared/dev-diagnostics.ts +44 -0
- package/src/shared/prefix.ts +8 -0
- package/src/shared/route-map.ts +10 -1
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var __esm = (fn, res, err) => () => {
|
|
3
|
+
if (fn)
|
|
4
|
+
try {
|
|
5
|
+
res = fn(fn = 0);
|
|
6
|
+
} catch (e) {
|
|
7
|
+
err = [e];
|
|
8
|
+
}
|
|
9
|
+
if (err)
|
|
10
|
+
throw err[0];
|
|
11
|
+
return res;
|
|
12
|
+
};
|
|
4
13
|
|
|
5
14
|
// src/server/instance.ts
|
|
6
15
|
import { AsyncLocalStorage } from "async_hooks";
|
|
7
|
-
var _requestScope = new AsyncLocalStorage;
|
|
8
|
-
var _instances = new Map;
|
|
9
|
-
var _defaultInstance = null;
|
|
10
16
|
function createInstance(prefix, pagesDir) {
|
|
11
17
|
return {
|
|
12
18
|
buildId: "",
|
|
@@ -14,7 +20,7 @@ function createInstance(prefix, pagesDir) {
|
|
|
14
20
|
prefix,
|
|
15
21
|
registrationEpoch: 0,
|
|
16
22
|
state: new Map,
|
|
17
|
-
|
|
23
|
+
syncPath: undefined
|
|
18
24
|
};
|
|
19
25
|
}
|
|
20
26
|
function defaultInstance() {
|
|
@@ -63,32 +69,42 @@ function instanceSlot(init) {
|
|
|
63
69
|
return value;
|
|
64
70
|
};
|
|
65
71
|
}
|
|
72
|
+
var _requestScope, _instances, _defaultInstance = null;
|
|
73
|
+
var init_instance = __esm(() => {
|
|
74
|
+
_requestScope = new AsyncLocalStorage;
|
|
75
|
+
_instances = new Map;
|
|
76
|
+
});
|
|
66
77
|
|
|
67
78
|
// src/server/sync/config.ts
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
function resolveSyncStreamPath(sync) {
|
|
79
|
+
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
80
|
+
function resolveSyncPath(sync) {
|
|
71
81
|
if (!sync) {
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
|
-
return sync.
|
|
84
|
+
return sync.path ?? SYNC_DEFAULT_PATH;
|
|
75
85
|
}
|
|
76
|
-
function
|
|
77
|
-
const override =
|
|
86
|
+
function getSyncPath() {
|
|
87
|
+
const override = requestSyncPath.getStore();
|
|
78
88
|
if (override !== undefined) {
|
|
79
89
|
return override;
|
|
80
90
|
}
|
|
81
|
-
return currentInstance().
|
|
91
|
+
return currentInstance().syncPath;
|
|
82
92
|
}
|
|
83
|
-
function
|
|
84
|
-
return
|
|
93
|
+
function runWithSyncPath(path, fn) {
|
|
94
|
+
return requestSyncPath.run(path, fn);
|
|
85
95
|
}
|
|
86
96
|
function syncRuntimeOptions(sync) {
|
|
87
97
|
return { adapter: sync.adapter, notifier: sync.notifier, principal: sync.principal };
|
|
88
98
|
}
|
|
99
|
+
var SYNC_DEFAULT_PATH = "/_furin/sync", requestSyncPath;
|
|
100
|
+
var init_config = __esm(() => {
|
|
101
|
+
init_instance();
|
|
102
|
+
requestSyncPath = new AsyncLocalStorage2;
|
|
103
|
+
});
|
|
89
104
|
|
|
90
105
|
// src/server/sync/notifier.ts
|
|
91
106
|
class PollingSyncNotifier {
|
|
107
|
+
recovery = "self";
|
|
92
108
|
adapter;
|
|
93
109
|
intervalMs;
|
|
94
110
|
listeners = new Set;
|
|
@@ -178,12 +194,7 @@ class PollingSyncNotifier {
|
|
|
178
194
|
}
|
|
179
195
|
}
|
|
180
196
|
|
|
181
|
-
//
|
|
182
|
-
import { Elysia } from "elysia";
|
|
183
|
-
|
|
184
|
-
// src/server/context-logger.ts
|
|
185
|
-
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
186
|
-
// ../../node_modules/.bun/evlog@2.28.1+4cac44d0f5802a4d/node_modules/evlog/dist/utils.mjs
|
|
197
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/utils.mjs
|
|
187
198
|
function elapsedMs(startTime) {
|
|
188
199
|
return Math.max(0, Date.now() - startTime);
|
|
189
200
|
}
|
|
@@ -222,71 +233,21 @@ function detectEnvironment() {
|
|
|
222
233
|
region: env.VERCEL_REGION || env.AWS_REGION || env.FLY_REGION || env.CF_REGION
|
|
223
234
|
};
|
|
224
235
|
}
|
|
225
|
-
var LEVEL_ORDER = {
|
|
226
|
-
debug: 0,
|
|
227
|
-
info: 1,
|
|
228
|
-
warn: 2,
|
|
229
|
-
error: 3
|
|
230
|
-
};
|
|
231
236
|
function isLevelEnabled(level, minLevel) {
|
|
232
237
|
return LEVEL_ORDER[level] >= LEVEL_ORDER[minLevel];
|
|
233
238
|
}
|
|
234
239
|
function getConsoleMethod(level) {
|
|
235
240
|
return level;
|
|
236
241
|
}
|
|
237
|
-
var colors = {
|
|
238
|
-
reset: "\x1B[0m",
|
|
239
|
-
bold: "\x1B[1m",
|
|
240
|
-
dim: "\x1B[2m",
|
|
241
|
-
red: "\x1B[31m",
|
|
242
|
-
green: "\x1B[32m",
|
|
243
|
-
yellow: "\x1B[33m",
|
|
244
|
-
blue: "\x1B[34m",
|
|
245
|
-
magenta: "\x1B[35m",
|
|
246
|
-
cyan: "\x1B[36m",
|
|
247
|
-
white: "\x1B[37m",
|
|
248
|
-
gray: "\x1B[90m"
|
|
249
|
-
};
|
|
250
|
-
var levelColorMap = {
|
|
251
|
-
error: colors.red,
|
|
252
|
-
warn: colors.yellow,
|
|
253
|
-
info: colors.cyan,
|
|
254
|
-
debug: colors.gray
|
|
255
|
-
};
|
|
256
242
|
function getLevelColor(level) {
|
|
257
243
|
return levelColorMap[level] ?? colors.white;
|
|
258
244
|
}
|
|
259
|
-
var cssColors = {
|
|
260
|
-
dim: "color: #6b7280",
|
|
261
|
-
red: "color: #ef4444; font-weight: bold",
|
|
262
|
-
green: "color: #22c55e",
|
|
263
|
-
yellow: "color: #f59e0b; font-weight: bold",
|
|
264
|
-
cyan: "color: #06b6d4; font-weight: bold",
|
|
265
|
-
gray: "color: #6b7280; font-weight: bold",
|
|
266
|
-
reset: "color: inherit; font-weight: normal"
|
|
267
|
-
};
|
|
268
|
-
var cssLevelColorMap = {
|
|
269
|
-
error: cssColors.red,
|
|
270
|
-
warn: cssColors.yellow,
|
|
271
|
-
info: cssColors.cyan,
|
|
272
|
-
debug: cssColors.gray
|
|
273
|
-
};
|
|
274
245
|
function getCssLevelColor(level) {
|
|
275
246
|
return cssLevelColorMap[level] ?? cssColors.reset;
|
|
276
247
|
}
|
|
277
248
|
function escapeFormatString(str) {
|
|
278
249
|
return str.replace(/%/g, "%%");
|
|
279
250
|
}
|
|
280
|
-
var SENSITIVE_HEADERS = [
|
|
281
|
-
"authorization",
|
|
282
|
-
"cookie",
|
|
283
|
-
"set-cookie",
|
|
284
|
-
"x-api-key",
|
|
285
|
-
"x-auth-token",
|
|
286
|
-
"proxy-authorization"
|
|
287
|
-
];
|
|
288
|
-
var SENSITIVE_HEADER_SET = new Set(SENSITIVE_HEADERS);
|
|
289
|
-
var patternCache = /* @__PURE__ */ new Map;
|
|
290
251
|
function globToRegExp(pattern, separator = "/") {
|
|
291
252
|
const cacheKey = `${separator}:${pattern}`;
|
|
292
253
|
let regex = patternCache.get(cacheKey);
|
|
@@ -302,9 +263,6 @@ function globToRegExp(pattern, separator = "/") {
|
|
|
302
263
|
function matchesPattern(path, pattern) {
|
|
303
264
|
return globToRegExp(pattern, "/").test(path);
|
|
304
265
|
}
|
|
305
|
-
var _isoDate = /* @__PURE__ */ new Date;
|
|
306
|
-
var _isoCachedSecond = -1;
|
|
307
|
-
var _isoCachedPrefix = "";
|
|
308
266
|
function isoNow() {
|
|
309
267
|
const now = Date.now();
|
|
310
268
|
const sec = Math.floor(now / 1000);
|
|
@@ -315,9 +273,62 @@ function isoNow() {
|
|
|
315
273
|
}
|
|
316
274
|
return `${_isoCachedPrefix}.${String(now % 1000).padStart(3, "0")}Z`;
|
|
317
275
|
}
|
|
276
|
+
var LEVEL_ORDER, colors, levelColorMap, cssColors, cssLevelColorMap, SENSITIVE_HEADERS, SENSITIVE_HEADER_SET, patternCache, _isoDate, _isoCachedSecond = -1, _isoCachedPrefix = "";
|
|
277
|
+
var init_utils = __esm(() => {
|
|
278
|
+
LEVEL_ORDER = {
|
|
279
|
+
debug: 0,
|
|
280
|
+
info: 1,
|
|
281
|
+
warn: 2,
|
|
282
|
+
error: 3
|
|
283
|
+
};
|
|
284
|
+
colors = {
|
|
285
|
+
reset: "\x1B[0m",
|
|
286
|
+
bold: "\x1B[1m",
|
|
287
|
+
dim: "\x1B[2m",
|
|
288
|
+
red: "\x1B[31m",
|
|
289
|
+
green: "\x1B[32m",
|
|
290
|
+
yellow: "\x1B[33m",
|
|
291
|
+
blue: "\x1B[34m",
|
|
292
|
+
magenta: "\x1B[35m",
|
|
293
|
+
cyan: "\x1B[36m",
|
|
294
|
+
white: "\x1B[37m",
|
|
295
|
+
gray: "\x1B[90m"
|
|
296
|
+
};
|
|
297
|
+
levelColorMap = {
|
|
298
|
+
error: colors.red,
|
|
299
|
+
warn: colors.yellow,
|
|
300
|
+
info: colors.cyan,
|
|
301
|
+
debug: colors.gray
|
|
302
|
+
};
|
|
303
|
+
cssColors = {
|
|
304
|
+
dim: "color: #6b7280",
|
|
305
|
+
red: "color: #ef4444; font-weight: bold",
|
|
306
|
+
green: "color: #22c55e",
|
|
307
|
+
yellow: "color: #f59e0b; font-weight: bold",
|
|
308
|
+
cyan: "color: #06b6d4; font-weight: bold",
|
|
309
|
+
gray: "color: #6b7280; font-weight: bold",
|
|
310
|
+
reset: "color: inherit; font-weight: normal"
|
|
311
|
+
};
|
|
312
|
+
cssLevelColorMap = {
|
|
313
|
+
error: cssColors.red,
|
|
314
|
+
warn: cssColors.yellow,
|
|
315
|
+
info: cssColors.cyan,
|
|
316
|
+
debug: cssColors.gray
|
|
317
|
+
};
|
|
318
|
+
SENSITIVE_HEADERS = [
|
|
319
|
+
"authorization",
|
|
320
|
+
"cookie",
|
|
321
|
+
"set-cookie",
|
|
322
|
+
"x-api-key",
|
|
323
|
+
"x-auth-token",
|
|
324
|
+
"proxy-authorization"
|
|
325
|
+
];
|
|
326
|
+
SENSITIVE_HEADER_SET = new Set(SENSITIVE_HEADERS);
|
|
327
|
+
patternCache = /* @__PURE__ */ new Map;
|
|
328
|
+
_isoDate = /* @__PURE__ */ new Date;
|
|
329
|
+
});
|
|
318
330
|
|
|
319
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
320
|
-
var DEFAULT_REPLACEMENT = "[REDACTED]";
|
|
331
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/redact-C7FmdhwI.mjs
|
|
321
332
|
function normalizeRedactPathPattern(pattern) {
|
|
322
333
|
if (!pattern.includes("*") && !pattern.includes("."))
|
|
323
334
|
return `**.${pattern}`;
|
|
@@ -433,53 +444,6 @@ function setRedacted(record, key, value, path) {
|
|
|
433
444
|
}
|
|
434
445
|
console.warn(`[evlog] redact could not rewrite read-only field "${path}" \u2014 value left as-is`);
|
|
435
446
|
}
|
|
436
|
-
var builtinPatterns = {
|
|
437
|
-
creditCard: {
|
|
438
|
-
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
439
|
-
mask: (m) => `****${m.replace(/[\s-]/g, "").slice(-4)}`
|
|
440
|
-
},
|
|
441
|
-
email: {
|
|
442
|
-
pattern: /[\w.+-]+@[\w-]+\.[\w.]+/g,
|
|
443
|
-
mask: (m) => {
|
|
444
|
-
if (m.indexOf("@") < 1)
|
|
445
|
-
return "***@***";
|
|
446
|
-
const tld = m.slice(m.lastIndexOf("."));
|
|
447
|
-
return `${m[0]}***@***${tld}`;
|
|
448
|
-
}
|
|
449
|
-
},
|
|
450
|
-
ipv4: {
|
|
451
|
-
pattern: /\b(?!0\.0\.0\.0\b)(?!127\.0\.0\.1\b)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,
|
|
452
|
-
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
453
|
-
},
|
|
454
|
-
phone: {
|
|
455
|
-
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
456
|
-
mask: (m) => {
|
|
457
|
-
const digits = m.replace(/[^\d]/g, "");
|
|
458
|
-
if (m.startsWith("+") && digits.length > 4) {
|
|
459
|
-
const ccMatch = m.match(/^\+\d{1,3}/);
|
|
460
|
-
return `${ccMatch ? ccMatch[0] : "+"}******${digits.slice(-2)}`;
|
|
461
|
-
}
|
|
462
|
-
if (digits.length > 2)
|
|
463
|
-
return `${"*".repeat(digits.length - 2)}${digits.slice(-2)}`;
|
|
464
|
-
return "***";
|
|
465
|
-
}
|
|
466
|
-
},
|
|
467
|
-
jwt: {
|
|
468
|
-
pattern: /\beyJ[\w-]*\.[\w-]*\.[\w-]*\b/g,
|
|
469
|
-
mask: () => "eyJ***.***"
|
|
470
|
-
},
|
|
471
|
-
bearer: {
|
|
472
|
-
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
473
|
-
mask: () => "Bearer ***"
|
|
474
|
-
},
|
|
475
|
-
iban: {
|
|
476
|
-
pattern: /\b[A-Z]{2}\d{2}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{0,4}[\s-]?[\dA-Z]{0,4}[\s-]?[\dA-Z]{0,4}\b/g,
|
|
477
|
-
mask: (m) => {
|
|
478
|
-
const clean = m.replace(/[\s-]/g, "");
|
|
479
|
-
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
447
|
function resolveRedactConfig(input) {
|
|
484
448
|
if (input === undefined || input === false)
|
|
485
449
|
return;
|
|
@@ -503,7 +467,6 @@ function allBuiltinMaskers() {
|
|
|
503
467
|
function cloneRegex(re) {
|
|
504
468
|
return new RegExp(re.source, re.flags);
|
|
505
469
|
}
|
|
506
|
-
var globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
507
470
|
function markGloballyRedacted(event) {
|
|
508
471
|
Object.defineProperty(event, globallyRedacted, {
|
|
509
472
|
value: true,
|
|
@@ -618,8 +581,60 @@ function applyMaskers(value, maskers) {
|
|
|
618
581
|
result = result.replace(pattern, mask);
|
|
619
582
|
return result;
|
|
620
583
|
}
|
|
584
|
+
var DEFAULT_REPLACEMENT = "[REDACTED]", builtinPatterns, globallyRedacted;
|
|
585
|
+
var init_redact_C7FmdhwI = __esm(() => {
|
|
586
|
+
init_utils();
|
|
587
|
+
builtinPatterns = {
|
|
588
|
+
creditCard: {
|
|
589
|
+
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
590
|
+
mask: (m) => `****${m.replace(/[\s-]/g, "").slice(-4)}`
|
|
591
|
+
},
|
|
592
|
+
email: {
|
|
593
|
+
pattern: /[\w.+-]+@[\w-]+\.[\w.]+/g,
|
|
594
|
+
mask: (m) => {
|
|
595
|
+
if (m.indexOf("@") < 1)
|
|
596
|
+
return "***@***";
|
|
597
|
+
const tld = m.slice(m.lastIndexOf("."));
|
|
598
|
+
return `${m[0]}***@***${tld}`;
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
ipv4: {
|
|
602
|
+
pattern: /\b(?!0\.0\.0\.0\b)(?!127\.0\.0\.1\b)\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/g,
|
|
603
|
+
mask: (m) => `***.***.***.${m.split(".").pop()}`
|
|
604
|
+
},
|
|
605
|
+
phone: {
|
|
606
|
+
pattern: /(?:\+\d{1,3}[\s.-]?\(?\d{1,4}\)?|\(\d{1,4}\))(?:[\s.-]?\d{2,4}){2,4}\b/g,
|
|
607
|
+
mask: (m) => {
|
|
608
|
+
const digits = m.replace(/[^\d]/g, "");
|
|
609
|
+
if (m.startsWith("+") && digits.length > 4) {
|
|
610
|
+
const ccMatch = m.match(/^\+\d{1,3}/);
|
|
611
|
+
return `${ccMatch ? ccMatch[0] : "+"}******${digits.slice(-2)}`;
|
|
612
|
+
}
|
|
613
|
+
if (digits.length > 2)
|
|
614
|
+
return `${"*".repeat(digits.length - 2)}${digits.slice(-2)}`;
|
|
615
|
+
return "***";
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
jwt: {
|
|
619
|
+
pattern: /\beyJ[\w-]*\.[\w-]*\.[\w-]*\b/g,
|
|
620
|
+
mask: () => "eyJ***.***"
|
|
621
|
+
},
|
|
622
|
+
bearer: {
|
|
623
|
+
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
624
|
+
mask: () => "Bearer ***"
|
|
625
|
+
},
|
|
626
|
+
iban: {
|
|
627
|
+
pattern: /\b[A-Z]{2}\d{2}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{4}[\s-]?[\dA-Z]{0,4}[\s-]?[\dA-Z]{0,4}[\s-]?[\dA-Z]{0,4}\b/g,
|
|
628
|
+
mask: (m) => {
|
|
629
|
+
const clean = m.replace(/[\s-]/g, "");
|
|
630
|
+
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
globallyRedacted = Symbol.for("evlog.globallyRedacted");
|
|
635
|
+
});
|
|
621
636
|
|
|
622
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
637
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/globalRegistry-Bh3bIGwA.mjs
|
|
623
638
|
function logPluginError(name, hook, err) {
|
|
624
639
|
console.error(`[evlog/${name}] ${hook} failed:`, err);
|
|
625
640
|
}
|
|
@@ -727,13 +742,9 @@ function createPluginRunner(plugins = []) {
|
|
|
727
742
|
}
|
|
728
743
|
};
|
|
729
744
|
}
|
|
730
|
-
var emptyRunner = createPluginRunner([]);
|
|
731
745
|
function getEmptyPluginRunner() {
|
|
732
746
|
return emptyRunner;
|
|
733
747
|
}
|
|
734
|
-
var EVLOG_MAJOR = 2;
|
|
735
|
-
var REGISTRY_KEY = Symbol.for(`evlog.registry.v${EVLOG_MAJOR}`);
|
|
736
|
-
var MAJORS_KEY = Symbol.for("evlog.majors");
|
|
737
748
|
function createConfig() {
|
|
738
749
|
return {
|
|
739
750
|
env: {
|
|
@@ -775,17 +786,19 @@ function getRegistry() {
|
|
|
775
786
|
storages: /* @__PURE__ */ new Map
|
|
776
787
|
};
|
|
777
788
|
}
|
|
778
|
-
var
|
|
789
|
+
var emptyRunner, EVLOG_MAJOR = 2, REGISTRY_KEY, MAJORS_KEY, globalConfig;
|
|
790
|
+
var init_globalRegistry_Bh3bIGwA = __esm(() => {
|
|
791
|
+
init_utils();
|
|
792
|
+
emptyRunner = createPluginRunner([]);
|
|
793
|
+
REGISTRY_KEY = Symbol.for(`evlog.registry.v${EVLOG_MAJOR}`);
|
|
794
|
+
MAJORS_KEY = Symbol.for("evlog.majors");
|
|
795
|
+
globalConfig = getRegistry().config;
|
|
796
|
+
});
|
|
779
797
|
|
|
780
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
781
|
-
var snippetReader = null;
|
|
782
|
-
var PRETTY_ERROR_TREE_SPACER = "__EVLOG_TREE_SPACER__";
|
|
798
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/pretty-error-DTIHxnBN.mjs
|
|
783
799
|
function pushTreeSpacer(children) {
|
|
784
800
|
children.push(PRETTY_ERROR_TREE_SPACER);
|
|
785
801
|
}
|
|
786
|
-
var SKIP_PATH_RE = /(?:^|[/\\])(?:node_modules|\.nuxt|\.next|\.output)(?:[/\\]|$)/;
|
|
787
|
-
var SKIP_FRAME_PATH_RE = /(?:^|[/\\])(?:packages[/\\]evlog|evlog[/\\](?:dist|src))(?:[/\\]|$)/;
|
|
788
|
-
var SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
789
802
|
function isPlainObject(val) {
|
|
790
803
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
791
804
|
}
|
|
@@ -1002,8 +1015,6 @@ function formatCollapsedFrame(frame, cwd) {
|
|
|
1002
1015
|
return `${prefix}${fn} (${loc})`;
|
|
1003
1016
|
return `${prefix}${loc}`;
|
|
1004
1017
|
}
|
|
1005
|
-
var GUIDANCE_WRAP_WIDTH = 76;
|
|
1006
|
-
var GUIDANCE_CONTINUATION = " ";
|
|
1007
1018
|
function formatGuidanceLine(label, text, labelColor) {
|
|
1008
1019
|
const prefix = `${labelColor}${label}:${colors.reset} `;
|
|
1009
1020
|
const lines = [];
|
|
@@ -1077,22 +1088,15 @@ function buildErrorEntries(error, options = {}) {
|
|
|
1077
1088
|
children: children.length > 0 ? children : undefined
|
|
1078
1089
|
}];
|
|
1079
1090
|
}
|
|
1091
|
+
var snippetReader = null, PRETTY_ERROR_TREE_SPACER = "__EVLOG_TREE_SPACER__", SKIP_PATH_RE, SKIP_FRAME_PATH_RE, SKIP_FRAME_FN_RE, GUIDANCE_WRAP_WIDTH = 76, GUIDANCE_CONTINUATION = " ";
|
|
1092
|
+
var init_pretty_error_DTIHxnBN = __esm(() => {
|
|
1093
|
+
init_utils();
|
|
1094
|
+
SKIP_PATH_RE = /(?:^|[/\\])(?:node_modules|\.nuxt|\.next|\.output)(?:[/\\]|$)/;
|
|
1095
|
+
SKIP_FRAME_PATH_RE = /(?:^|[/\\])(?:packages[/\\]evlog|evlog[/\\](?:dist|src))(?:[/\\]|$)/;
|
|
1096
|
+
SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
1097
|
+
});
|
|
1080
1098
|
|
|
1081
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
1082
|
-
var DEV_PRESETS = {
|
|
1083
|
-
evlog: {
|
|
1084
|
-
frameworkOverlay: false,
|
|
1085
|
-
detail: "full"
|
|
1086
|
-
},
|
|
1087
|
-
nitro: {
|
|
1088
|
-
frameworkOverlay: true,
|
|
1089
|
-
detail: "guidance"
|
|
1090
|
-
},
|
|
1091
|
-
both: {
|
|
1092
|
-
frameworkOverlay: true,
|
|
1093
|
-
detail: "full"
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1099
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/dev-terminal-Brarc6vc.mjs
|
|
1096
1100
|
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
1097
1101
|
const compact = partial.compact ?? (inDev && pretty);
|
|
1098
1102
|
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
@@ -1126,9 +1130,26 @@ function resolveDevTerminal(input = {}) {
|
|
|
1126
1130
|
prettyError: finalizePrettyError(prettyError, frameworkOverlay, pretty, inDev)
|
|
1127
1131
|
};
|
|
1128
1132
|
}
|
|
1133
|
+
var DEV_PRESETS;
|
|
1134
|
+
var init_dev_terminal_Brarc6vc = __esm(() => {
|
|
1135
|
+
init_utils();
|
|
1136
|
+
DEV_PRESETS = {
|
|
1137
|
+
evlog: {
|
|
1138
|
+
frameworkOverlay: false,
|
|
1139
|
+
detail: "full"
|
|
1140
|
+
},
|
|
1141
|
+
nitro: {
|
|
1142
|
+
frameworkOverlay: true,
|
|
1143
|
+
detail: "guidance"
|
|
1144
|
+
},
|
|
1145
|
+
both: {
|
|
1146
|
+
frameworkOverlay: true,
|
|
1147
|
+
detail: "full"
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
});
|
|
1129
1151
|
|
|
1130
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
1131
|
-
var publisher = null;
|
|
1152
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/wideEventChannel-BUDW48oP.mjs
|
|
1132
1153
|
function publishWideEvent(event) {
|
|
1133
1154
|
if (!publisher)
|
|
1134
1155
|
return;
|
|
@@ -1138,126 +1159,134 @@ function publishWideEvent(event) {
|
|
|
1138
1159
|
console.error("[evlog] diagnostics channel publish failed:", err);
|
|
1139
1160
|
}
|
|
1140
1161
|
}
|
|
1162
|
+
var publisher = null;
|
|
1163
|
+
var init_wideEventChannel_BUDW48oP = () => {};
|
|
1141
1164
|
|
|
1142
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
1143
|
-
var evlogErrorBrand = Symbol.for("evlog.error.brand");
|
|
1165
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/error-brand-D0-DCPvr.mjs
|
|
1144
1166
|
function isEvlogError(error) {
|
|
1145
1167
|
return typeof error === "object" && error !== null && error[evlogErrorBrand] === true;
|
|
1146
1168
|
}
|
|
1169
|
+
var evlogErrorBrand;
|
|
1170
|
+
var init_error_brand_D0_DCPvr = __esm(() => {
|
|
1171
|
+
evlogErrorBrand = Symbol.for("evlog.error.brand");
|
|
1172
|
+
});
|
|
1147
1173
|
|
|
1148
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
1149
|
-
var evlogErrorInternalKey
|
|
1150
|
-
var
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
lines.push(`${
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1174
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/error.mjs
|
|
1175
|
+
var evlogErrorInternalKey, evlogErrorDataKey, EvlogError;
|
|
1176
|
+
var init_error = __esm(() => {
|
|
1177
|
+
init_utils();
|
|
1178
|
+
init_error_brand_D0_DCPvr();
|
|
1179
|
+
evlogErrorInternalKey = Symbol.for("evlog.error.internal");
|
|
1180
|
+
evlogErrorDataKey = Symbol.for("evlog.error.data");
|
|
1181
|
+
EvlogError = class EvlogError extends Error {
|
|
1182
|
+
static isEvlogError(error) {
|
|
1183
|
+
return isEvlogError(error);
|
|
1184
|
+
}
|
|
1185
|
+
code;
|
|
1186
|
+
status;
|
|
1187
|
+
why;
|
|
1188
|
+
fix;
|
|
1189
|
+
link;
|
|
1190
|
+
get internal() {
|
|
1191
|
+
return this[evlogErrorInternalKey];
|
|
1192
|
+
}
|
|
1193
|
+
constructor(options) {
|
|
1194
|
+
const opts = typeof options === "string" ? { message: options } : options;
|
|
1195
|
+
super(opts.message, { cause: opts.cause });
|
|
1196
|
+
this.name = "EvlogError";
|
|
1197
|
+
this.code = opts.code;
|
|
1198
|
+
this.status = opts.status ?? 500;
|
|
1199
|
+
this.why = opts.why;
|
|
1200
|
+
this.fix = opts.fix;
|
|
1201
|
+
this.link = opts.link;
|
|
1202
|
+
if (opts.internal !== undefined)
|
|
1203
|
+
Object.defineProperty(this, evlogErrorInternalKey, {
|
|
1204
|
+
value: opts.internal,
|
|
1205
|
+
enumerable: false,
|
|
1206
|
+
writable: false,
|
|
1207
|
+
configurable: true
|
|
1208
|
+
});
|
|
1209
|
+
if (opts.data !== undefined)
|
|
1210
|
+
Object.defineProperty(this, evlogErrorDataKey, {
|
|
1211
|
+
value: opts.data,
|
|
1212
|
+
enumerable: false,
|
|
1213
|
+
writable: false,
|
|
1214
|
+
configurable: true
|
|
1215
|
+
});
|
|
1216
|
+
if (Error.captureStackTrace)
|
|
1217
|
+
Error.captureStackTrace(this, EvlogError);
|
|
1218
|
+
}
|
|
1219
|
+
get statusText() {
|
|
1220
|
+
return this.message;
|
|
1221
|
+
}
|
|
1222
|
+
get statusCode() {
|
|
1223
|
+
return this.status;
|
|
1224
|
+
}
|
|
1225
|
+
get statusMessage() {
|
|
1226
|
+
return this.message;
|
|
1227
|
+
}
|
|
1228
|
+
get data() {
|
|
1229
|
+
const extra = this[evlogErrorDataKey];
|
|
1230
|
+
if (!extra && !this.code && !this.why && !this.fix && !this.link)
|
|
1231
|
+
return;
|
|
1232
|
+
return {
|
|
1233
|
+
...extra,
|
|
1234
|
+
...this.code !== undefined && { code: this.code },
|
|
1235
|
+
...this.why !== undefined && { why: this.why },
|
|
1236
|
+
...this.fix !== undefined && { fix: this.fix },
|
|
1237
|
+
...this.link !== undefined && { link: this.link }
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
toString() {
|
|
1241
|
+
const useColors = isServer();
|
|
1242
|
+
const red = useColors ? colors.red : "";
|
|
1243
|
+
const yellow = useColors ? colors.yellow : "";
|
|
1244
|
+
const cyan = useColors ? colors.cyan : "";
|
|
1245
|
+
const dim = useColors ? colors.dim : "";
|
|
1246
|
+
const reset = useColors ? colors.reset : "";
|
|
1247
|
+
const bold = useColors ? colors.bold : "";
|
|
1248
|
+
const lines = [];
|
|
1249
|
+
lines.push(`${red}${bold}Error:${reset} ${this.message}`);
|
|
1250
|
+
if (this.code)
|
|
1251
|
+
lines.push(`${dim}Code:${reset} ${this.code}`);
|
|
1252
|
+
if (this.why)
|
|
1253
|
+
lines.push(`${yellow}Why:${reset} ${this.why}`);
|
|
1254
|
+
if (this.fix)
|
|
1255
|
+
lines.push(`${cyan}Fix:${reset} ${this.fix}`);
|
|
1256
|
+
if (this.link)
|
|
1257
|
+
lines.push(`${dim}More info:${reset} ${this.link}`);
|
|
1258
|
+
if (this.cause)
|
|
1259
|
+
lines.push(`${dim}Caused by:${reset} ${this.cause.message}`);
|
|
1260
|
+
return lines.join(`
|
|
1231
1261
|
`);
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
};
|
|
1247
|
-
Object.defineProperty(EvlogError.prototype, evlogErrorBrand, {
|
|
1248
|
-
|
|
1249
|
-
|
|
1262
|
+
}
|
|
1263
|
+
toJSON() {
|
|
1264
|
+
const { data } = this;
|
|
1265
|
+
return {
|
|
1266
|
+
name: this.name,
|
|
1267
|
+
message: this.message,
|
|
1268
|
+
status: this.status,
|
|
1269
|
+
...data && { data },
|
|
1270
|
+
...this.cause instanceof Error && { cause: {
|
|
1271
|
+
name: this.cause.name,
|
|
1272
|
+
message: this.cause.message
|
|
1273
|
+
} }
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
Object.defineProperty(EvlogError.prototype, evlogErrorBrand, {
|
|
1278
|
+
value: true,
|
|
1279
|
+
enumerable: false
|
|
1280
|
+
});
|
|
1250
1281
|
});
|
|
1251
1282
|
|
|
1252
|
-
// ../../node_modules/.bun/evlog@2.28.1+
|
|
1253
|
-
var nativeStdoutWrite = typeof process !== "undefined" && typeof process.stdout?.write === "function" ? process.stdout.write.bind(process.stdout) : undefined;
|
|
1283
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/audit-CW8wdQDm.mjs
|
|
1254
1284
|
function writePrettyStdout(text) {
|
|
1255
1285
|
(globalThis.__evlogNativeStdoutWrite ?? nativeStdoutWrite)?.(text);
|
|
1256
1286
|
}
|
|
1257
1287
|
function isPlainObject$1(val) {
|
|
1258
1288
|
return val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1259
1289
|
}
|
|
1260
|
-
var POST_EMIT_FORK_HINT = "For intentional background work tied to this request, use log.fork('label', fn) when your integration supports it (see https://evlog.dev).";
|
|
1261
1290
|
function warnPostEmit(method, detail) {
|
|
1262
1291
|
console.warn(`[evlog] ${method} called after the wide event was emitted \u2014 ${detail} This data will not appear in observability. ${POST_EMIT_FORK_HINT}`);
|
|
1263
1292
|
}
|
|
@@ -1277,12 +1306,10 @@ function mergeInto(target, source) {
|
|
|
1277
1306
|
Reflect.set(target, key, sourceVal);
|
|
1278
1307
|
}
|
|
1279
1308
|
}
|
|
1280
|
-
var pendingDrainState = /* @__PURE__ */ new WeakMap;
|
|
1281
1309
|
function isAiOnlyFieldUpdate(data) {
|
|
1282
1310
|
const keys = Object.keys(data);
|
|
1283
1311
|
return keys.length === 1 && keys[0] === "ai";
|
|
1284
1312
|
}
|
|
1285
|
-
var state = globalConfig;
|
|
1286
1313
|
function initLogger(config = {}) {
|
|
1287
1314
|
state.enabled = config.enabled ?? true;
|
|
1288
1315
|
const detected = detectEnvironment();
|
|
@@ -1782,26 +1809,6 @@ function createLogMethod(level) {
|
|
|
1782
1809
|
emitTaggedLog(level, "log", String(tagOrEvent));
|
|
1783
1810
|
};
|
|
1784
1811
|
}
|
|
1785
|
-
var _log = {
|
|
1786
|
-
info: createLogMethod("info"),
|
|
1787
|
-
error: createLogMethod("error"),
|
|
1788
|
-
warn: createLogMethod("warn"),
|
|
1789
|
-
debug: createLogMethod("debug")
|
|
1790
|
-
};
|
|
1791
|
-
var noopLogger = {
|
|
1792
|
-
set() {},
|
|
1793
|
-
setLevel() {},
|
|
1794
|
-
error() {},
|
|
1795
|
-
info() {},
|
|
1796
|
-
warn() {},
|
|
1797
|
-
emit() {
|
|
1798
|
-
return null;
|
|
1799
|
-
},
|
|
1800
|
-
getContext() {
|
|
1801
|
-
return {};
|
|
1802
|
-
},
|
|
1803
|
-
audit: Object.assign(() => {}, { deny: () => {} })
|
|
1804
|
-
};
|
|
1805
1812
|
function createLogger(initialContext = {}, internalOptions) {
|
|
1806
1813
|
if (!state.enabled)
|
|
1807
1814
|
return noopLogger;
|
|
@@ -1982,8 +1989,6 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
1982
1989
|
}
|
|
1983
1990
|
};
|
|
1984
1991
|
}
|
|
1985
|
-
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
1986
|
-
initLogger(__EVLOG_CONFIG__);
|
|
1987
1992
|
function isPlainObject2(value) {
|
|
1988
1993
|
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
1989
1994
|
return false;
|
|
@@ -2045,7 +2050,6 @@ function buildAuditFields(input) {
|
|
|
2045
2050
|
version: input.version ?? 1
|
|
2046
2051
|
};
|
|
2047
2052
|
}
|
|
2048
|
-
var _testCollector = null;
|
|
2049
2053
|
function decorateAudit(audit, timestamp) {
|
|
2050
2054
|
if (audit.idempotencyKey)
|
|
2051
2055
|
return audit;
|
|
@@ -2077,13 +2081,161 @@ function finalizeAudit(event) {
|
|
|
2077
2081
|
event.audit = decorated;
|
|
2078
2082
|
_testCollector?.(decorated, event);
|
|
2079
2083
|
}
|
|
2084
|
+
var nativeStdoutWrite, POST_EMIT_FORK_HINT = "For intentional background work tied to this request, use log.fork('label', fn) when your integration supports it (see https://evlog.dev).", pendingDrainState, state, _log, noopLogger, _testCollector = null;
|
|
2085
|
+
var init_audit_CW8wdQDm = __esm(() => {
|
|
2086
|
+
init_utils();
|
|
2087
|
+
init_redact_C7FmdhwI();
|
|
2088
|
+
init_globalRegistry_Bh3bIGwA();
|
|
2089
|
+
init_pretty_error_DTIHxnBN();
|
|
2090
|
+
init_dev_terminal_Brarc6vc();
|
|
2091
|
+
init_wideEventChannel_BUDW48oP();
|
|
2092
|
+
init_error();
|
|
2093
|
+
nativeStdoutWrite = typeof process !== "undefined" && typeof process.stdout?.write === "function" ? process.stdout.write.bind(process.stdout) : undefined;
|
|
2094
|
+
pendingDrainState = /* @__PURE__ */ new WeakMap;
|
|
2095
|
+
state = globalConfig;
|
|
2096
|
+
_log = {
|
|
2097
|
+
info: createLogMethod("info"),
|
|
2098
|
+
error: createLogMethod("error"),
|
|
2099
|
+
warn: createLogMethod("warn"),
|
|
2100
|
+
debug: createLogMethod("debug")
|
|
2101
|
+
};
|
|
2102
|
+
noopLogger = {
|
|
2103
|
+
set() {},
|
|
2104
|
+
setLevel() {},
|
|
2105
|
+
error() {},
|
|
2106
|
+
info() {},
|
|
2107
|
+
warn() {},
|
|
2108
|
+
emit() {
|
|
2109
|
+
return null;
|
|
2110
|
+
},
|
|
2111
|
+
getContext() {
|
|
2112
|
+
return {};
|
|
2113
|
+
},
|
|
2114
|
+
audit: Object.assign(() => {}, { deny: () => {} })
|
|
2115
|
+
};
|
|
2116
|
+
if (typeof __EVLOG_CONFIG__ !== "undefined")
|
|
2117
|
+
initLogger(__EVLOG_CONFIG__);
|
|
2118
|
+
});
|
|
2119
|
+
|
|
2120
|
+
// ../../node_modules/.bun/evlog@2.28.1+70108eec0745116d/node_modules/evlog/dist/index.mjs
|
|
2121
|
+
var init_dist = __esm(() => {
|
|
2122
|
+
init_audit_CW8wdQDm();
|
|
2123
|
+
});
|
|
2124
|
+
|
|
2080
2125
|
// src/server/context-logger.ts
|
|
2081
|
-
|
|
2126
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
2127
|
+
var syntheticRenderStorage;
|
|
2128
|
+
var init_context_logger = __esm(() => {
|
|
2129
|
+
init_dist();
|
|
2130
|
+
syntheticRenderStorage = new AsyncLocalStorage4;
|
|
2131
|
+
});
|
|
2132
|
+
|
|
2133
|
+
// src/server/runtime-env.ts
|
|
2134
|
+
var IS_DEV = true;
|
|
2135
|
+
|
|
2136
|
+
// src/server/sync/runtime.ts
|
|
2137
|
+
function resolveSyncRuntime(options) {
|
|
2138
|
+
if (!IS_DEV && options.adapter.scope === "process-local") {
|
|
2139
|
+
throw new Error("[furin] Production sync cannot use a process-local SyncAdapter.");
|
|
2140
|
+
}
|
|
2141
|
+
if (options.notifier) {
|
|
2142
|
+
if (options.adapter.notificationChannel !== undefined && options.notifier.notificationChannel !== undefined && options.adapter.notificationChannel !== options.notifier.notificationChannel) {
|
|
2143
|
+
throw new Error("[furin] SyncAdapter and SyncNotifier notification channels do not match.");
|
|
2144
|
+
}
|
|
2145
|
+
return { adapter: options.adapter, notifier: options.notifier };
|
|
2146
|
+
}
|
|
2147
|
+
if (!IS_DEV && options.adapter.scope === "distributed") {
|
|
2148
|
+
throw new Error("[furin] Distributed production sync requires an explicit SyncNotifier. Configure the adapter notifier or pass PollingSyncNotifier as a compatibility fallback.");
|
|
2149
|
+
}
|
|
2150
|
+
const existing = pollingNotifiers.get(options.adapter);
|
|
2151
|
+
if (existing) {
|
|
2152
|
+
return { adapter: options.adapter, notifier: existing };
|
|
2153
|
+
}
|
|
2154
|
+
const notifier = new PollingSyncNotifier(options.adapter, POLL_INTERVAL_MS);
|
|
2155
|
+
pollingNotifiers.set(options.adapter, notifier);
|
|
2156
|
+
return { adapter: options.adapter, notifier };
|
|
2157
|
+
}
|
|
2158
|
+
var POLL_INTERVAL_MS = 250, pollingNotifiers;
|
|
2159
|
+
var init_runtime = __esm(() => {
|
|
2160
|
+
pollingNotifiers = new WeakMap;
|
|
2161
|
+
});
|
|
2162
|
+
|
|
2163
|
+
// src/server/sync/stream.ts
|
|
2164
|
+
import { Elysia } from "elysia";
|
|
2165
|
+
function parseChangeQuery(request) {
|
|
2166
|
+
const url = new URL(request.url);
|
|
2167
|
+
const after = url.searchParams.get("after") ?? undefined;
|
|
2168
|
+
if (after !== undefined && (after.length === 0 || after.length > MAX_CURSOR_LENGTH)) {
|
|
2169
|
+
return { error: Response.json({ code: "FURIN_INVALID_SYNC_CURSOR" }, { status: 400 }) };
|
|
2170
|
+
}
|
|
2171
|
+
const limitValue = url.searchParams.get("limit");
|
|
2172
|
+
if (limitValue !== null && !UNSIGNED_INTEGER_PATTERN.test(limitValue)) {
|
|
2173
|
+
return { error: Response.json({ code: "FURIN_INVALID_SYNC_LIMIT" }, { status: 400 }) };
|
|
2174
|
+
}
|
|
2175
|
+
const limit = limitValue === null ? DEFAULT_CHANGE_LIMIT : Number.parseInt(limitValue, 10);
|
|
2176
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_CHANGE_LIMIT) {
|
|
2177
|
+
return { error: Response.json({ code: "FURIN_INVALID_SYNC_LIMIT" }, { status: 400 }) };
|
|
2178
|
+
}
|
|
2179
|
+
return { after, limit };
|
|
2180
|
+
}
|
|
2181
|
+
function clientInvalidations(change) {
|
|
2182
|
+
const entries = new Set;
|
|
2183
|
+
for (const invalidation of change.invalidations) {
|
|
2184
|
+
if (invalidation.kind === "tags") {
|
|
2185
|
+
entries.add("/:layout");
|
|
2186
|
+
} else {
|
|
2187
|
+
entries.add(invalidation.type === "layout" ? `${invalidation.path}:layout` : invalidation.path);
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
return [...entries];
|
|
2191
|
+
}
|
|
2192
|
+
function createSyncChangesPlugin(options) {
|
|
2193
|
+
const syncPath = options.path ?? defaultSyncPath;
|
|
2194
|
+
const runtime = resolveSyncRuntime(syncRuntimeOptions(options));
|
|
2195
|
+
return new Elysia({ name: `furin-sync-changes-${syncPath}` }).get(`${syncPath}/changes`, async ({ request, set }) => {
|
|
2196
|
+
set.headers["cache-control"] = "no-store";
|
|
2197
|
+
const query = parseChangeQuery(request);
|
|
2198
|
+
if ("error" in query) {
|
|
2199
|
+
return query.error;
|
|
2200
|
+
}
|
|
2201
|
+
const page = await runtime.adapter.readChanges(query);
|
|
2202
|
+
return {
|
|
2203
|
+
...page,
|
|
2204
|
+
changes: page.changes.map((change) => ({
|
|
2205
|
+
cursor: change.cursor,
|
|
2206
|
+
invalidations: clientInvalidations(change)
|
|
2207
|
+
}))
|
|
2208
|
+
};
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
var DEFAULT_CHANGE_LIMIT = 100, MAX_CHANGE_LIMIT = 500, MAX_CURSOR_LENGTH = 128, UNSIGNED_INTEGER_PATTERN, defaultSyncPath = "/_furin/sync", cursorStates, resolvedStates;
|
|
2212
|
+
var init_stream = __esm(() => {
|
|
2213
|
+
init_config();
|
|
2214
|
+
init_runtime();
|
|
2215
|
+
UNSIGNED_INTEGER_PATTERN = /^\d+$/;
|
|
2216
|
+
cursorStates = new Map;
|
|
2217
|
+
resolvedStates = new Set;
|
|
2218
|
+
});
|
|
2219
|
+
|
|
2220
|
+
// src/server/sync/index.ts
|
|
2221
|
+
init_config();
|
|
2222
|
+
|
|
2223
|
+
// src/server/sync/plugin.ts
|
|
2224
|
+
import { Elysia as Elysia2 } from "elysia";
|
|
2225
|
+
|
|
2226
|
+
// src/shared/prefix.ts
|
|
2227
|
+
function physicalPath(prefix, path) {
|
|
2228
|
+
if (prefix === "") {
|
|
2229
|
+
return path;
|
|
2230
|
+
}
|
|
2231
|
+
return path === "/" ? prefix : `${prefix}${path}`;
|
|
2232
|
+
}
|
|
2082
2233
|
|
|
2083
2234
|
// src/devtools/protocol.ts
|
|
2084
|
-
var DEVTOOLS_PROTOCOL_VERSION =
|
|
2235
|
+
var DEVTOOLS_PROTOCOL_VERSION = 2;
|
|
2085
2236
|
|
|
2086
2237
|
// src/server/devtools/hub.ts
|
|
2238
|
+
init_instance();
|
|
2087
2239
|
var EVENT_LIMIT = 1000;
|
|
2088
2240
|
var instanceDevtoolsHub = instanceSlot(() => ({ events: [], listeners: new Set, sequence: 0 }));
|
|
2089
2241
|
function devtoolsInstanceId() {
|
|
@@ -2110,6 +2262,8 @@ function appendDevtoolsEvent(event) {
|
|
|
2110
2262
|
}
|
|
2111
2263
|
|
|
2112
2264
|
// src/server/auto-invalidate/registry.ts
|
|
2265
|
+
init_instance();
|
|
2266
|
+
|
|
2113
2267
|
class AutoInvalidateRegistry {
|
|
2114
2268
|
pathToTags = new Map;
|
|
2115
2269
|
tagToPaths = new Map;
|
|
@@ -2167,6 +2321,7 @@ function getAutoInvalidateRegistry(instance) {
|
|
|
2167
2321
|
}
|
|
2168
2322
|
|
|
2169
2323
|
// src/server/cache/registry.ts
|
|
2324
|
+
init_instance();
|
|
2170
2325
|
var instanceInvalidators = instanceSlot(() => new Map);
|
|
2171
2326
|
function getCacheInvalidators(instance) {
|
|
2172
2327
|
return instanceInvalidators(instance).values();
|
|
@@ -2182,8 +2337,8 @@ function pathWithoutSearch(path) {
|
|
|
2182
2337
|
}
|
|
2183
2338
|
|
|
2184
2339
|
// src/server/devtools/request-context.ts
|
|
2185
|
-
import { AsyncLocalStorage as
|
|
2186
|
-
var requestContext = new
|
|
2340
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
2341
|
+
var requestContext = new AsyncLocalStorage3;
|
|
2187
2342
|
function currentDevtoolsRequest() {
|
|
2188
2343
|
return requestContext.getStore();
|
|
2189
2344
|
}
|
|
@@ -2196,8 +2351,29 @@ function currentInstrumentationRequest() {
|
|
|
2196
2351
|
return currentDevtoolsRequest();
|
|
2197
2352
|
}
|
|
2198
2353
|
|
|
2199
|
-
// src/server/
|
|
2200
|
-
|
|
2354
|
+
// src/server/cache/invalidation.ts
|
|
2355
|
+
init_instance();
|
|
2356
|
+
// src/server/cache/purger.ts
|
|
2357
|
+
var pathPurger;
|
|
2358
|
+
var tagPurger;
|
|
2359
|
+
function callCachePurger(paths) {
|
|
2360
|
+
dispatch(pathPurger, paths);
|
|
2361
|
+
}
|
|
2362
|
+
function callCacheTagPurger(tags) {
|
|
2363
|
+
dispatch(tagPurger, tags);
|
|
2364
|
+
}
|
|
2365
|
+
function dispatch(purger, keys) {
|
|
2366
|
+
if (!purger || keys.length === 0) {
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
Promise.resolve().then(() => purger(keys)).catch(async (error) => {
|
|
2370
|
+
await Promise.resolve().then(() => init_context_logger());
|
|
2371
|
+
const logger = createLogger({});
|
|
2372
|
+
logger.set({ furin: { action: "cdn_purge_failed", keys } });
|
|
2373
|
+
logger.error(error instanceof Error ? error : new Error(String(error)));
|
|
2374
|
+
logger.emit();
|
|
2375
|
+
});
|
|
2376
|
+
}
|
|
2201
2377
|
|
|
2202
2378
|
// src/server/cache/invalidation.ts
|
|
2203
2379
|
var _globalPendingInvalidations = new Set;
|
|
@@ -2216,22 +2392,8 @@ function consumePendingInvalidations() {
|
|
|
2216
2392
|
function peekPendingInvalidations() {
|
|
2217
2393
|
return [..._activeInvalidationSet()];
|
|
2218
2394
|
}
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
if (!_cachePurger || paths.length === 0) {
|
|
2222
|
-
return;
|
|
2223
|
-
}
|
|
2224
|
-
_cachePurger(paths).catch((err) => {
|
|
2225
|
-
const logger = createLogger({});
|
|
2226
|
-
logger.set({
|
|
2227
|
-
furin: {
|
|
2228
|
-
action: "cdn_purge_failed",
|
|
2229
|
-
paths
|
|
2230
|
-
}
|
|
2231
|
-
});
|
|
2232
|
-
logger.error(err instanceof Error ? err : new Error(String(err)));
|
|
2233
|
-
logger.emit();
|
|
2234
|
-
});
|
|
2395
|
+
function callCachePurger2(paths) {
|
|
2396
|
+
callCachePurger(paths);
|
|
2235
2397
|
}
|
|
2236
2398
|
function revalidatePath(path, type) {
|
|
2237
2399
|
let deleted = false;
|
|
@@ -2239,12 +2401,12 @@ function revalidatePath(path, type) {
|
|
|
2239
2401
|
for (const instance of allInstances()) {
|
|
2240
2402
|
const result = revalidatePathForInstance(instance, path, type);
|
|
2241
2403
|
deleted = result.deleted || deleted;
|
|
2242
|
-
purgedPaths.push(
|
|
2404
|
+
purgedPaths.push(physicalPath(instance.prefix, path));
|
|
2243
2405
|
for (const purged of result.purgedPaths) {
|
|
2244
|
-
purgedPaths.push(
|
|
2406
|
+
purgedPaths.push(physicalPath(instance.prefix, purged));
|
|
2245
2407
|
}
|
|
2246
2408
|
}
|
|
2247
|
-
|
|
2409
|
+
callCachePurger2(dedupePaths(purgedPaths));
|
|
2248
2410
|
return deleted;
|
|
2249
2411
|
}
|
|
2250
2412
|
function revalidatePathForInstance(instance, path, type, emitPathEvent) {
|
|
@@ -2278,6 +2440,7 @@ function dedupePaths(paths) {
|
|
|
2278
2440
|
}
|
|
2279
2441
|
|
|
2280
2442
|
// src/server/auto-invalidate/runtime.ts
|
|
2443
|
+
init_instance();
|
|
2281
2444
|
function toRules(input) {
|
|
2282
2445
|
return Array.isArray(input) ? input : [input];
|
|
2283
2446
|
}
|
|
@@ -2369,6 +2532,7 @@ function revalidateTag(tags) {
|
|
|
2369
2532
|
const tagList = typeof tags === "string" ? [tags] : [...tags];
|
|
2370
2533
|
let deleted = false;
|
|
2371
2534
|
const purgedPaths = new Set;
|
|
2535
|
+
callCacheTagPurger(tagList);
|
|
2372
2536
|
for (const instance of allInstances()) {
|
|
2373
2537
|
let instanceDeleted = false;
|
|
2374
2538
|
const instancePurgedPaths = new Set;
|
|
@@ -2377,10 +2541,10 @@ function revalidateTag(tags) {
|
|
|
2377
2541
|
const result = revalidatePathForInstance(instance, logicalPath, "page", false);
|
|
2378
2542
|
deleted = result.deleted || deleted;
|
|
2379
2543
|
instanceDeleted = result.deleted || instanceDeleted;
|
|
2380
|
-
purgedPaths.add(
|
|
2544
|
+
purgedPaths.add(physicalPath(instance.prefix, logicalPath));
|
|
2381
2545
|
instancePurgedPaths.add(logicalPath);
|
|
2382
2546
|
for (const purged of result.purgedPaths) {
|
|
2383
|
-
purgedPaths.add(
|
|
2547
|
+
purgedPaths.add(physicalPath(instance.prefix, purged));
|
|
2384
2548
|
instancePurgedPaths.add(purged);
|
|
2385
2549
|
}
|
|
2386
2550
|
}
|
|
@@ -2400,7 +2564,7 @@ function revalidateTag(tags) {
|
|
|
2400
2564
|
});
|
|
2401
2565
|
}
|
|
2402
2566
|
}
|
|
2403
|
-
|
|
2567
|
+
callCachePurger2([...purgedPaths]);
|
|
2404
2568
|
return deleted;
|
|
2405
2569
|
}
|
|
2406
2570
|
function runInvalidationRules(input) {
|
|
@@ -2618,26 +2782,8 @@ function replayResponse(stored) {
|
|
|
2618
2782
|
});
|
|
2619
2783
|
}
|
|
2620
2784
|
|
|
2621
|
-
// src/server/sync/runtime.ts
|
|
2622
|
-
var POLL_INTERVAL_MS = 250;
|
|
2623
|
-
var pollingNotifiers = new WeakMap;
|
|
2624
|
-
function resolveSyncRuntime(options) {
|
|
2625
|
-
if (!IS_DEV && options.adapter.scope === "process-local") {
|
|
2626
|
-
throw new Error("[furin] Production sync cannot use a process-local SyncAdapter.");
|
|
2627
|
-
}
|
|
2628
|
-
if (options.notifier) {
|
|
2629
|
-
return { adapter: options.adapter, notifier: options.notifier };
|
|
2630
|
-
}
|
|
2631
|
-
const existing = pollingNotifiers.get(options.adapter);
|
|
2632
|
-
if (existing) {
|
|
2633
|
-
return { adapter: options.adapter, notifier: existing };
|
|
2634
|
-
}
|
|
2635
|
-
const notifier = new PollingSyncNotifier(options.adapter, POLL_INTERVAL_MS);
|
|
2636
|
-
pollingNotifiers.set(options.adapter, notifier);
|
|
2637
|
-
return { adapter: options.adapter, notifier };
|
|
2638
|
-
}
|
|
2639
|
-
|
|
2640
2785
|
// src/server/sync/plugin.ts
|
|
2786
|
+
init_runtime();
|
|
2641
2787
|
var routeMetadata = new WeakMap;
|
|
2642
2788
|
var activeMutations = new WeakMap;
|
|
2643
2789
|
function hideTransportResponse(hook) {
|
|
@@ -2788,7 +2934,8 @@ function furinSync(options) {
|
|
|
2788
2934
|
if (completion.kind === "lost") {
|
|
2789
2935
|
return leaseLostResponse();
|
|
2790
2936
|
}
|
|
2791
|
-
|
|
2937
|
+
const notificationAlreadyPublished = runtime.adapter.notificationChannel !== undefined && runtime.adapter.notificationChannel === runtime.notifier.notificationChannel;
|
|
2938
|
+
if (completion.cursor !== undefined && !notificationAlreadyPublished) {
|
|
2792
2939
|
runtime.notifier.publish(completion.cursor).catch(() => {
|
|
2793
2940
|
return;
|
|
2794
2941
|
});
|
|
@@ -2822,7 +2969,7 @@ function furinSync(options) {
|
|
|
2822
2969
|
}
|
|
2823
2970
|
const beginMutationHook = hideTransportResponse(beginMutation);
|
|
2824
2971
|
const finishMutationHook = hideTransportResponse(finishMutation);
|
|
2825
|
-
return new
|
|
2972
|
+
return new Elysia2({ name: "furin-sync" }).macro({
|
|
2826
2973
|
sync(input) {
|
|
2827
2974
|
return {
|
|
2828
2975
|
transform({ request }) {
|
|
@@ -2833,191 +2980,19 @@ function furinSync(options) {
|
|
|
2833
2980
|
}).onBeforeHandle({ as: "global" }, beginMutationHook).onAfterHandle({ as: "global" }, finishMutationHook).onError({ as: "global" }, ({ request }) => abortMutation(request));
|
|
2834
2981
|
}
|
|
2835
2982
|
|
|
2836
|
-
// src/server/sync/stream.ts
|
|
2837
|
-
import { Elysia as Elysia2 } from "elysia";
|
|
2838
|
-
var DEFAULT_CHANGE_LIMIT = 100;
|
|
2839
|
-
var MAX_CHANGE_LIMIT = 500;
|
|
2840
|
-
var MAX_STREAM_CLIENTS = 100;
|
|
2841
|
-
var MAX_CURSOR_LENGTH = 128;
|
|
2842
|
-
var SAFETY_POLL_INTERVAL_MS = IS_DEV ? 250 : 15000;
|
|
2843
|
-
var UNSIGNED_INTEGER_PATTERN = /^\d+$/;
|
|
2844
|
-
var defaultStreamPath = "/_furin/sync";
|
|
2845
|
-
var encoder = new TextEncoder;
|
|
2846
|
-
var noOpSubscription = {
|
|
2847
|
-
unsubscribe: () => Promise.resolve()
|
|
2848
|
-
};
|
|
2849
|
-
var streams = new Map;
|
|
2850
|
-
var resolvedStates = new Set;
|
|
2851
|
-
function encodeSseCursor(cursor) {
|
|
2852
|
-
return encoder.encode(`id: ${cursor}
|
|
2853
|
-
event: furin.sync
|
|
2854
|
-
retry: 3000
|
|
2855
|
-
data: ${JSON.stringify({ cursor })}
|
|
2856
|
-
|
|
2857
|
-
`);
|
|
2858
|
-
}
|
|
2859
|
-
function closeClient(state, client) {
|
|
2860
|
-
const heartbeat = state.clients.get(client);
|
|
2861
|
-
state.clients.delete(client);
|
|
2862
|
-
if (heartbeat) {
|
|
2863
|
-
clearInterval(heartbeat);
|
|
2864
|
-
}
|
|
2865
|
-
try {
|
|
2866
|
-
client.close();
|
|
2867
|
-
} catch {}
|
|
2868
|
-
}
|
|
2869
|
-
function notifyState(state, cursor) {
|
|
2870
|
-
if (state.cursor === cursor) {
|
|
2871
|
-
return;
|
|
2872
|
-
}
|
|
2873
|
-
state.cursor = cursor;
|
|
2874
|
-
const chunk = encodeSseCursor(cursor);
|
|
2875
|
-
for (const client of state.clients.keys()) {
|
|
2876
|
-
if (client.desiredSize === null || client.desiredSize <= 0) {
|
|
2877
|
-
closeClient(state, client);
|
|
2878
|
-
continue;
|
|
2879
|
-
}
|
|
2880
|
-
try {
|
|
2881
|
-
client.enqueue(chunk);
|
|
2882
|
-
} catch {
|
|
2883
|
-
closeClient(state, client);
|
|
2884
|
-
}
|
|
2885
|
-
}
|
|
2886
|
-
}
|
|
2887
|
-
async function createStreamState(runtime) {
|
|
2888
|
-
const state = {};
|
|
2889
|
-
state.clients = new Map;
|
|
2890
|
-
state.cursor = await runtime.adapter.currentCursor();
|
|
2891
|
-
state.safetyPoll = setInterval(() => {
|
|
2892
|
-
runtime.adapter.currentCursor().then((cursor) => notifyState(state, cursor)).catch(() => {
|
|
2893
|
-
return;
|
|
2894
|
-
});
|
|
2895
|
-
}, SAFETY_POLL_INTERVAL_MS);
|
|
2896
|
-
state.safetyPoll.unref?.();
|
|
2897
|
-
state.subscription = await runtime.notifier.subscribe((cursor) => notifyState(state, cursor)).catch(() => noOpSubscription);
|
|
2898
|
-
resolvedStates.add(state);
|
|
2899
|
-
return state;
|
|
2900
|
-
}
|
|
2901
|
-
function getStreamState(runtime) {
|
|
2902
|
-
const existing = streams.get(runtime.adapter);
|
|
2903
|
-
if (existing) {
|
|
2904
|
-
return existing;
|
|
2905
|
-
}
|
|
2906
|
-
const state = createStreamState(runtime);
|
|
2907
|
-
streams.set(runtime.adapter, state);
|
|
2908
|
-
state.catch(() => {
|
|
2909
|
-
if (streams.get(runtime.adapter) === state) {
|
|
2910
|
-
streams.delete(runtime.adapter);
|
|
2911
|
-
}
|
|
2912
|
-
});
|
|
2913
|
-
return state;
|
|
2914
|
-
}
|
|
2915
|
-
function parseChangeQuery(request) {
|
|
2916
|
-
const url = new URL(request.url);
|
|
2917
|
-
const after = url.searchParams.get("after") ?? undefined;
|
|
2918
|
-
if (after !== undefined && (after.length === 0 || after.length > MAX_CURSOR_LENGTH)) {
|
|
2919
|
-
return { error: Response.json({ code: "FURIN_INVALID_SYNC_CURSOR" }, { status: 400 }) };
|
|
2920
|
-
}
|
|
2921
|
-
const limitValue = url.searchParams.get("limit");
|
|
2922
|
-
if (limitValue !== null && !UNSIGNED_INTEGER_PATTERN.test(limitValue)) {
|
|
2923
|
-
return { error: Response.json({ code: "FURIN_INVALID_SYNC_LIMIT" }, { status: 400 }) };
|
|
2924
|
-
}
|
|
2925
|
-
const limit = limitValue === null ? DEFAULT_CHANGE_LIMIT : Number.parseInt(limitValue, 10);
|
|
2926
|
-
if (!Number.isInteger(limit) || limit < 1 || limit > MAX_CHANGE_LIMIT) {
|
|
2927
|
-
return { error: Response.json({ code: "FURIN_INVALID_SYNC_LIMIT" }, { status: 400 }) };
|
|
2928
|
-
}
|
|
2929
|
-
return { after, limit };
|
|
2930
|
-
}
|
|
2931
|
-
function clientInvalidations(change) {
|
|
2932
|
-
const entries = new Set;
|
|
2933
|
-
for (const invalidation of change.invalidations) {
|
|
2934
|
-
if (invalidation.kind === "tags") {
|
|
2935
|
-
entries.add("/:layout");
|
|
2936
|
-
} else {
|
|
2937
|
-
entries.add(invalidation.type === "layout" ? `${invalidation.path}:layout` : invalidation.path);
|
|
2938
|
-
}
|
|
2939
|
-
}
|
|
2940
|
-
return [...entries];
|
|
2941
|
-
}
|
|
2942
|
-
function createSyncStreamPlugin(options) {
|
|
2943
|
-
const streamPath = options.streamPath ?? defaultStreamPath;
|
|
2944
|
-
const runtime = resolveSyncRuntime(syncRuntimeOptions(options));
|
|
2945
|
-
return new Elysia2({ name: `furin-sync-stream-${streamPath}` }).get(`${streamPath}/changes`, async ({ request, set }) => {
|
|
2946
|
-
set.headers["cache-control"] = "no-store";
|
|
2947
|
-
const query = parseChangeQuery(request);
|
|
2948
|
-
if ("error" in query) {
|
|
2949
|
-
return query.error;
|
|
2950
|
-
}
|
|
2951
|
-
const page = await runtime.adapter.readChanges(query);
|
|
2952
|
-
return {
|
|
2953
|
-
...page,
|
|
2954
|
-
changes: page.changes.map((change) => ({
|
|
2955
|
-
cursor: change.cursor,
|
|
2956
|
-
invalidations: clientInvalidations(change)
|
|
2957
|
-
}))
|
|
2958
|
-
};
|
|
2959
|
-
}).get(streamPath, async () => {
|
|
2960
|
-
const state = await getStreamState(runtime);
|
|
2961
|
-
if (state.clients.size >= MAX_STREAM_CLIENTS) {
|
|
2962
|
-
return Response.json({ code: "FURIN_SYNC_STREAM_CAPACITY" }, { status: 503 });
|
|
2963
|
-
}
|
|
2964
|
-
let controllerRef;
|
|
2965
|
-
let heartbeat;
|
|
2966
|
-
const stream = new ReadableStream({
|
|
2967
|
-
cancel() {
|
|
2968
|
-
if (controllerRef) {
|
|
2969
|
-
closeClient(state, controllerRef);
|
|
2970
|
-
}
|
|
2971
|
-
if (heartbeat) {
|
|
2972
|
-
clearInterval(heartbeat);
|
|
2973
|
-
}
|
|
2974
|
-
},
|
|
2975
|
-
start(controller) {
|
|
2976
|
-
controllerRef = controller;
|
|
2977
|
-
controller.enqueue(encoder.encode(`: connected
|
|
2978
|
-
retry: 3000
|
|
2979
|
-
|
|
2980
|
-
`));
|
|
2981
|
-
state.clients.set(controller, undefined);
|
|
2982
|
-
heartbeat = setInterval(() => {
|
|
2983
|
-
if (controller.desiredSize === null || controller.desiredSize <= 0) {
|
|
2984
|
-
closeClient(state, controller);
|
|
2985
|
-
return;
|
|
2986
|
-
}
|
|
2987
|
-
try {
|
|
2988
|
-
controller.enqueue(encoder.encode(`: heartbeat
|
|
2989
|
-
|
|
2990
|
-
`));
|
|
2991
|
-
} catch {
|
|
2992
|
-
closeClient(state, controller);
|
|
2993
|
-
}
|
|
2994
|
-
}, 15000);
|
|
2995
|
-
heartbeat.unref?.();
|
|
2996
|
-
state.clients.set(controller, heartbeat);
|
|
2997
|
-
}
|
|
2998
|
-
});
|
|
2999
|
-
return new Response(stream, {
|
|
3000
|
-
headers: {
|
|
3001
|
-
"cache-control": "no-cache, no-transform",
|
|
3002
|
-
connection: "keep-alive",
|
|
3003
|
-
"content-type": "text/event-stream; charset=utf-8"
|
|
3004
|
-
}
|
|
3005
|
-
});
|
|
3006
|
-
});
|
|
3007
|
-
}
|
|
3008
|
-
|
|
3009
2983
|
// src/server/sync/index.ts
|
|
3010
|
-
|
|
2984
|
+
init_stream();
|
|
2985
|
+
var createSyncChangesPlugin2 = createSyncChangesPlugin;
|
|
3011
2986
|
var furinSync2 = furinSync;
|
|
3012
|
-
var
|
|
2987
|
+
var getSyncPath2 = getSyncPath;
|
|
3013
2988
|
var PollingSyncNotifier2 = PollingSyncNotifier;
|
|
3014
|
-
var
|
|
3015
|
-
var
|
|
2989
|
+
var resolveSyncPath2 = resolveSyncPath;
|
|
2990
|
+
var runWithSyncPath2 = runWithSyncPath;
|
|
3016
2991
|
export {
|
|
3017
2992
|
PollingSyncNotifier2 as PollingSyncNotifier,
|
|
3018
|
-
|
|
2993
|
+
createSyncChangesPlugin2 as createSyncChangesPlugin,
|
|
3019
2994
|
furinSync2 as furinSync,
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
2995
|
+
getSyncPath2 as getSyncPath,
|
|
2996
|
+
resolveSyncPath2 as resolveSyncPath,
|
|
2997
|
+
runWithSyncPath2 as runWithSyncPath
|
|
3023
2998
|
};
|