@teyik0/furin 0.8.0-alpha.0 → 0.9.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/adapter/bun/app.d.ts +1 -0
- package/dist/adapter/bun.d.ts +3 -1
- package/dist/adapter/runtime-build.d.ts +8 -5
- package/dist/adapter/vercel.js +8 -8
- package/dist/build/client.d.ts +2 -2
- package/dist/build/discover-mounts-process.d.ts +1 -1
- package/dist/build/discover-pages-process.d.ts +1 -0
- package/dist/build/discover-pages.d.ts +11 -0
- package/dist/build/discovery-module.d.ts +3 -0
- package/dist/build/discovery-plugins.d.ts +34 -0
- package/dist/build/elysia-aot.d.ts +1 -1
- package/dist/build/entry-template.ts +6 -1
- package/dist/build/hydrate.d.ts +3 -2
- package/dist/build/index.js +7688 -8458
- package/dist/build/preload-manifest.d.ts +2 -2
- package/dist/build/route-metadata.d.ts +31 -0
- package/dist/build/route-types.d.ts +1 -1
- package/dist/build/shared.d.ts +2 -2
- package/dist/build/types.d.ts +11 -0
- package/dist/cli/dev-worker.d.ts +1 -0
- package/dist/cli/dev-worker.ts +129 -0
- package/dist/cli/dev.d.ts +1 -0
- package/dist/cli/index.js +7814 -8473
- package/dist/client/browser-events-runtime.d.ts +2 -2
- package/dist/client/browser-events.d.ts +2 -0
- package/dist/client/chunks/{client-brdfd773.js → client-rjhxgt64.js} +187 -4
- package/dist/client/dev-error-overlay.ts +18 -1
- package/dist/client/link.js +127 -170
- package/dist/client/query-store.d.ts +5 -0
- package/dist/client/router/navigation-controller.d.ts +2 -0
- package/dist/client/router/use-fetch-interception.d.ts +1 -1
- package/dist/client/router/use-sync-stream.d.ts +1 -1
- package/dist/client/{router/sync-catch-up.d.ts → sync-catch-up.d.ts} +5 -3
- package/dist/client/sync-client.d.ts +74 -0
- package/dist/client.d.ts +1 -0
- package/dist/client.js +533 -145
- package/dist/config.d.ts +6 -1
- package/dist/config.js +3 -1
- package/dist/define-route.d.ts +3 -3
- package/dist/furin.d.ts +2 -1
- package/dist/furin.js +1168 -393
- package/dist/plugin/index.js +5 -5
- package/dist/plugin/route-registry.d.ts +22 -2
- package/dist/rsc/build/index.d.ts +4 -3
- package/dist/server/dev/server-only-module.d.ts +5 -0
- package/dist/server/internal.js +241 -129
- package/dist/server/logging/ingest-plugin.d.ts +1 -2
- package/dist/server/production-server.js +36 -33
- package/dist/server/render/index.d.ts +0 -1
- package/dist/server/render/index.ts +0 -1
- package/dist/server/render/shell.d.ts +1 -13
- package/dist/server/render/shell.ts +1 -90
- package/dist/server/server-entry.d.ts +5 -0
- package/dist/server/server-entry.js +36 -0
- package/dist/server/static-export.js +241 -129
- package/dist/server/sync/adapter.d.ts +4 -3
- package/dist/server/sync/config.d.ts +7 -0
- package/dist/server/sync/connection.d.ts +13 -0
- package/dist/server/sync/drizzle/index.js +5 -4
- package/dist/server/sync/index.d.ts +3 -0
- package/dist/server/sync/index.js +1361 -243
- package/dist/server/sync/invalidate-sync.d.ts +6 -2
- package/dist/server/sync/local-client.d.ts +9 -0
- package/dist/server/sync/postgres/index.d.ts +1 -1
- package/dist/server/sync/postgres/index.js +2 -2
- package/dist/server/sync/prisma/index.js +2 -2
- package/dist/server/sync/redis/index.d.ts +1 -1
- package/dist/server/sync/redis/index.js +4 -3
- package/dist/server/sync/redis/scripts.d.ts +1 -1
- package/dist/server/sync/runtime.d.ts +3 -0
- package/dist/server/sync/sqlite/index.d.ts +1 -1
- package/dist/server/sync/sqlite/index.js +3 -2
- package/dist/shared/browser-events.d.ts +4 -0
- package/dist/shared/not-found.d.ts +1 -1
- package/dist/sync-client.d.ts +3 -0
- package/dist/sync-client.js +1600 -0
- package/package.json +14 -9
- package/src/adapter/README.md +7 -0
- package/src/adapter/build.ts +34 -33
- package/src/adapter/bun/app.ts +5 -0
- package/src/adapter/bun/server.ts +2 -2
- package/src/adapter/bun.ts +18 -2
- package/src/adapter/furin-app.d.ts +1 -0
- package/src/adapter/package.ts +1 -0
- package/src/adapter/runtime-build.ts +18 -12
- package/src/adapter/static.ts +17 -13
- package/src/build/client.ts +7 -5
- package/src/build/discover-mounts-process.ts +5 -1
- package/src/build/discover-pages-process.ts +151 -0
- package/src/build/discover-pages.ts +69 -0
- package/src/build/discovery-module.ts +70 -0
- package/src/build/discovery-plugins.ts +101 -0
- package/src/build/elysia-aot-worker.ts +9 -8
- package/src/build/elysia-aot.ts +110 -75
- package/src/build/entry-template.ts +6 -1
- package/src/build/hydrate.ts +11 -8
- package/src/build/index.ts +6 -50
- package/src/build/preload-manifest.ts +3 -3
- package/src/build/route-metadata.ts +90 -0
- package/src/build/route-types.ts +1 -1
- package/src/build/shared.ts +6 -8
- package/src/build/types.ts +9 -0
- package/src/cli/config.ts +4 -0
- package/src/cli/dev-worker.ts +129 -0
- package/src/cli/dev.ts +106 -0
- package/src/cli/index.ts +24 -1
- package/src/client/browser-events-runtime.ts +97 -23
- package/src/client/browser-events.ts +8 -0
- package/src/client/dev-error-overlay.ts +18 -1
- package/src/client/link.tsx +21 -22
- package/src/client/query-store.ts +54 -3
- package/src/client/router/context.ts +8 -7
- package/src/client/router/navigation-controller.ts +45 -12
- package/src/client/router/provider.tsx +11 -2
- package/src/client/router/use-fetch-interception.ts +1 -1
- package/src/client/router/use-sync-stream.ts +96 -44
- package/src/client/{router/sync-catch-up.ts → sync-catch-up.ts} +28 -12
- package/src/client/sync-client.ts +528 -0
- package/src/client/sync.ts +11 -4
- package/src/client.ts +10 -0
- package/src/config.ts +17 -10
- package/src/furin.ts +5 -0
- package/src/plugin/route-registry.ts +53 -7
- package/src/rsc/build/index.ts +6 -3
- package/src/server/browser-events/plugin.ts +79 -25
- package/src/server/dev/rewrite-module-specifiers.ts +2 -1
- package/src/server/dev/server-only-module.ts +23 -0
- package/src/server/dev/symbolicate.ts +4 -3
- package/src/server/dev-page-imports.ts +3 -1
- package/src/server/dev-page-plugin.ts +18 -1
- package/src/server/logging/ingest-plugin.ts +3 -9
- package/src/server/render/index.ts +0 -1
- package/src/server/render/shell.ts +1 -90
- package/src/server/server-entry.ts +39 -0
- package/src/server/sync/adapter.ts +7 -3
- package/src/server/sync/config.ts +12 -6
- package/src/server/sync/connection.ts +71 -0
- package/src/server/sync/index.ts +3 -0
- package/src/server/sync/invalidate-sync.ts +30 -5
- package/src/server/sync/local-client.ts +84 -0
- package/src/server/sync/plugin.ts +27 -20
- package/src/server/sync/postgres/index.ts +9 -2
- package/src/server/sync/redis/index.ts +5 -1
- package/src/server/sync/redis/scripts.ts +1 -1
- package/src/server/sync/runtime.ts +56 -18
- package/src/server/sync/sqlite/index.ts +6 -2
- package/src/server/sync/stream.ts +17 -5
- package/src/shared/browser-events.ts +1 -1
- package/src/shared/not-found.ts +1 -1
- package/src/sync-client.ts +14 -0
- package/dist/server/logger.d.ts +0 -10
- package/src/server/logger.ts +0 -34
package/dist/furin.js
CHANGED
|
@@ -4672,6 +4672,45 @@ class QueryStore {
|
|
|
4672
4672
|
generation() {
|
|
4673
4673
|
return this.epoch;
|
|
4674
4674
|
}
|
|
4675
|
+
clear(preserveData) {
|
|
4676
|
+
this.epoch += 1;
|
|
4677
|
+
if (!preserveData) {
|
|
4678
|
+
this.session = undefined;
|
|
4679
|
+
}
|
|
4680
|
+
this.projections.clear();
|
|
4681
|
+
for (const entry of this.entries.values()) {
|
|
4682
|
+
if (!preserveData) {
|
|
4683
|
+
entry.base = undefined;
|
|
4684
|
+
entry.identity = undefined;
|
|
4685
|
+
}
|
|
4686
|
+
entry.promise = undefined;
|
|
4687
|
+
entry.stale = true;
|
|
4688
|
+
entry.version += 1;
|
|
4689
|
+
entry.snapshot = { data: entry.base, error: null, isFetching: false };
|
|
4690
|
+
this.publish(entry);
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
dispose() {
|
|
4694
|
+
this.epoch += 1;
|
|
4695
|
+
for (const entry of this.entries.values()) {
|
|
4696
|
+
entry.listeners.clear();
|
|
4697
|
+
}
|
|
4698
|
+
this.entries.clear();
|
|
4699
|
+
this.requests = [];
|
|
4700
|
+
this.projections.clear();
|
|
4701
|
+
this.listeners.clear();
|
|
4702
|
+
}
|
|
4703
|
+
setError(url, error) {
|
|
4704
|
+
const entry = this.entry(url);
|
|
4705
|
+
entry.base = undefined;
|
|
4706
|
+
entry.stale = false;
|
|
4707
|
+
entry.version += 1;
|
|
4708
|
+
entry.snapshot = { data: undefined, error, isFetching: false };
|
|
4709
|
+
for (const projection of this.projections) {
|
|
4710
|
+
projection.transforms.delete(entry);
|
|
4711
|
+
}
|
|
4712
|
+
this.publish(entry);
|
|
4713
|
+
}
|
|
4675
4714
|
version(url) {
|
|
4676
4715
|
return this.entry(url).version;
|
|
4677
4716
|
}
|
|
@@ -4713,7 +4752,7 @@ class QueryStore {
|
|
|
4713
4752
|
const { epoch } = this;
|
|
4714
4753
|
entry.snapshot = { ...entry.snapshot, isFetching: true };
|
|
4715
4754
|
this.publish(entry);
|
|
4716
|
-
|
|
4755
|
+
const promise = Promise.resolve().then(() => entry.load?.()).then((result) => {
|
|
4717
4756
|
if (!result || epoch !== this.epoch || version !== entry.version || this.pending(entry)) {
|
|
4718
4757
|
return;
|
|
4719
4758
|
}
|
|
@@ -4727,6 +4766,9 @@ class QueryStore {
|
|
|
4727
4766
|
entry.snapshot = { ...entry.snapshot, error };
|
|
4728
4767
|
}
|
|
4729
4768
|
}).finally(() => {
|
|
4769
|
+
if (entry.promise !== promise) {
|
|
4770
|
+
return;
|
|
4771
|
+
}
|
|
4730
4772
|
entry.promise = undefined;
|
|
4731
4773
|
entry.snapshot = { ...entry.snapshot, isFetching: false };
|
|
4732
4774
|
this.publish(entry);
|
|
@@ -4734,13 +4776,14 @@ class QueryStore {
|
|
|
4734
4776
|
this.fetch(url);
|
|
4735
4777
|
}
|
|
4736
4778
|
});
|
|
4737
|
-
|
|
4779
|
+
entry.promise = promise;
|
|
4780
|
+
return promise;
|
|
4738
4781
|
}
|
|
4739
4782
|
invalidate(identities) {
|
|
4740
4783
|
const tags = new Set(identities.map(queryTag));
|
|
4741
4784
|
let affected = false;
|
|
4742
4785
|
for (const [url, entry] of this.entries) {
|
|
4743
|
-
if (entry.identity && queryTags(entry.identity).some((tag) => tags.has(tag))) {
|
|
4786
|
+
if (entry.identity && queryTags(entry.identity).some((tag) => tags.has(tag)) || !entry.identity && entry.load && identities.length > 0) {
|
|
4744
4787
|
affected = true;
|
|
4745
4788
|
this.invalidateEntry(url, entry);
|
|
4746
4789
|
}
|
|
@@ -5061,16 +5104,16 @@ var init_page_cache_state = __esm(() => {
|
|
|
5061
5104
|
}));
|
|
5062
5105
|
});
|
|
5063
5106
|
|
|
5064
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5107
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/error-brand-D4i1NkSd.mjs
|
|
5065
5108
|
function isEvlogError(error) {
|
|
5066
5109
|
return typeof error === "object" && error !== null && error[evlogErrorBrand] === true;
|
|
5067
5110
|
}
|
|
5068
5111
|
var evlogErrorBrand;
|
|
5069
|
-
var
|
|
5112
|
+
var init_error_brand_D4i1NkSd = __esm(() => {
|
|
5070
5113
|
evlogErrorBrand = Symbol.for("evlog.error.brand");
|
|
5071
5114
|
});
|
|
5072
5115
|
|
|
5073
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5116
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/utils.mjs
|
|
5074
5117
|
function elapsedMs(startTime) {
|
|
5075
5118
|
return Math.max(0, Date.now() - startTime);
|
|
5076
5119
|
}
|
|
@@ -5211,7 +5254,7 @@ function readErrorField(error, key) {
|
|
|
5211
5254
|
}
|
|
5212
5255
|
var LEVEL_ORDER, colors, levelColorMap, cssColors, cssLevelColorMap, SENSITIVE_HEADERS, SENSITIVE_HEADER_SET, patternCache, _isoDate, _isoCachedSecond = -1, _isoCachedPrefix = "";
|
|
5213
5256
|
var init_utils = __esm(() => {
|
|
5214
|
-
|
|
5257
|
+
init_error_brand_D4i1NkSd();
|
|
5215
5258
|
LEVEL_ORDER = {
|
|
5216
5259
|
trace: 0,
|
|
5217
5260
|
debug: 0,
|
|
@@ -5271,7 +5314,7 @@ var init_utils = __esm(() => {
|
|
|
5271
5314
|
_isoDate = /* @__PURE__ */ new Date;
|
|
5272
5315
|
});
|
|
5273
5316
|
|
|
5274
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5317
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/globalRegistry-DxlJ7DCO.mjs
|
|
5275
5318
|
function logPluginError(name, hook, err) {
|
|
5276
5319
|
console.error(`[evlog/${name}] ${hook} failed:`, err);
|
|
5277
5320
|
}
|
|
@@ -5434,7 +5477,7 @@ function getSharedStorage(id, create) {
|
|
|
5434
5477
|
return storage;
|
|
5435
5478
|
}
|
|
5436
5479
|
var emptyRunner, EVLOG_MAJOR = 2, REGISTRY_KEY, MAJORS_KEY, globalConfig;
|
|
5437
|
-
var
|
|
5480
|
+
var init_globalRegistry_DxlJ7DCO = __esm(() => {
|
|
5438
5481
|
init_utils();
|
|
5439
5482
|
emptyRunner = createPluginRunner([]);
|
|
5440
5483
|
REGISTRY_KEY = Symbol.for(`evlog.registry.v${EVLOG_MAJOR}`);
|
|
@@ -5442,7 +5485,7 @@ var init_globalRegistry_27hBAWF = __esm(() => {
|
|
|
5442
5485
|
globalConfig = getRegistry().config;
|
|
5443
5486
|
});
|
|
5444
5487
|
|
|
5445
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5488
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/pretty-error-DnkXIALi.mjs
|
|
5446
5489
|
function pushTreeSpacer(children) {
|
|
5447
5490
|
children.push(PRETTY_ERROR_TREE_SPACER);
|
|
5448
5491
|
}
|
|
@@ -5734,14 +5777,14 @@ function buildErrorEntries(error, options = {}) {
|
|
|
5734
5777
|
}];
|
|
5735
5778
|
}
|
|
5736
5779
|
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 = " ";
|
|
5737
|
-
var
|
|
5780
|
+
var init_pretty_error_DnkXIALi = __esm(() => {
|
|
5738
5781
|
init_utils();
|
|
5739
5782
|
SKIP_PATH_RE = /(?:^|[/\\])(?:node_modules|\.nuxt|\.next|\.output)(?:[/\\]|$)/;
|
|
5740
5783
|
SKIP_FRAME_PATH_RE = /(?:^|[/\\])(?:packages[/\\]evlog|evlog[/\\](?:dist|src))(?:[/\\]|$)/;
|
|
5741
5784
|
SKIP_FRAME_FN_RE = /^(?:createError|EvlogError|new EvlogError)$/;
|
|
5742
5785
|
});
|
|
5743
5786
|
|
|
5744
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5787
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/dev-terminal-CDXEC6Wl.mjs
|
|
5745
5788
|
function finalizePrettyError(partial, frameworkOverlay, pretty, inDev) {
|
|
5746
5789
|
const compact = partial.compact ?? (inDev && pretty);
|
|
5747
5790
|
const detail = partial.detail ?? (frameworkOverlay ? "guidance" : "full");
|
|
@@ -5776,7 +5819,7 @@ function resolveDevTerminal(input = {}) {
|
|
|
5776
5819
|
};
|
|
5777
5820
|
}
|
|
5778
5821
|
var DEV_PRESETS;
|
|
5779
|
-
var
|
|
5822
|
+
var init_dev_terminal_CDXEC6Wl = __esm(() => {
|
|
5780
5823
|
init_utils();
|
|
5781
5824
|
DEV_PRESETS = {
|
|
5782
5825
|
evlog: {
|
|
@@ -5794,7 +5837,7 @@ var init_dev_terminal_Brarc6vc = __esm(() => {
|
|
|
5794
5837
|
};
|
|
5795
5838
|
});
|
|
5796
5839
|
|
|
5797
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5840
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/wideEventChannel-BABjYpvc.mjs
|
|
5798
5841
|
function hasWideEventPublisher() {
|
|
5799
5842
|
return publisher !== null;
|
|
5800
5843
|
}
|
|
@@ -5808,9 +5851,9 @@ function publishWideEvent(event) {
|
|
|
5808
5851
|
}
|
|
5809
5852
|
}
|
|
5810
5853
|
var publisher = null;
|
|
5811
|
-
var
|
|
5854
|
+
var init_wideEventChannel_BABjYpvc = () => {};
|
|
5812
5855
|
|
|
5813
|
-
// ../../node_modules/.bun/evlog@2.
|
|
5856
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/serialize-error-CHmRO35i.mjs
|
|
5814
5857
|
function payloadFieldsHiddenBy(error) {
|
|
5815
5858
|
const { toJSON } = error;
|
|
5816
5859
|
if (typeof toJSON !== "function" || isEvlogError(error))
|
|
@@ -5910,8 +5953,12 @@ function createErrorSerializer(formatStack = (stack) => stack) {
|
|
|
5910
5953
|
changed = true;
|
|
5911
5954
|
}
|
|
5912
5955
|
}
|
|
5913
|
-
if (changed)
|
|
5956
|
+
if (changed) {
|
|
5957
|
+
const proto = Object.getPrototypeOf(value);
|
|
5914
5958
|
copy = Object.fromEntries(entries);
|
|
5959
|
+
if (proto !== Object.prototype)
|
|
5960
|
+
Object.setPrototypeOf(copy, proto);
|
|
5961
|
+
}
|
|
5915
5962
|
}
|
|
5916
5963
|
ancestors.delete(value);
|
|
5917
5964
|
return copy ?? value;
|
|
@@ -5922,8 +5969,8 @@ function createErrorSerializer(formatStack = (stack) => stack) {
|
|
|
5922
5969
|
};
|
|
5923
5970
|
}
|
|
5924
5971
|
var ERROR_FIELDS, NONE, H3_INPUT_FIELDS;
|
|
5925
|
-
var
|
|
5926
|
-
|
|
5972
|
+
var init_serialize_error_CHmRO35i = __esm(() => {
|
|
5973
|
+
init_error_brand_D4i1NkSd();
|
|
5927
5974
|
init_utils();
|
|
5928
5975
|
ERROR_FIELDS = [
|
|
5929
5976
|
"code",
|
|
@@ -5951,7 +5998,7 @@ var init_serialize_error_DHkLgVsh = __esm(() => {
|
|
|
5951
5998
|
};
|
|
5952
5999
|
});
|
|
5953
6000
|
|
|
5954
|
-
// ../../node_modules/.bun/evlog@2.
|
|
6001
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/headers-DpB4nPAJ.mjs
|
|
5955
6002
|
function extractSafeHeaders(headers) {
|
|
5956
6003
|
const raw = {};
|
|
5957
6004
|
headers.forEach((value, key) => {
|
|
@@ -5968,11 +6015,11 @@ function extractSafeNodeHeaders(headers) {
|
|
|
5968
6015
|
}
|
|
5969
6016
|
return filterSafeHeaders(raw);
|
|
5970
6017
|
}
|
|
5971
|
-
var
|
|
6018
|
+
var init_headers_DpB4nPAJ = __esm(() => {
|
|
5972
6019
|
init_utils();
|
|
5973
6020
|
});
|
|
5974
6021
|
|
|
5975
|
-
// ../../node_modules/.bun/evlog@2.
|
|
6022
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/audit-D3F0XCdQ.mjs
|
|
5976
6023
|
function normalizeRedactPathPattern(pattern) {
|
|
5977
6024
|
if (!pattern.includes("*") && !pattern.includes("."))
|
|
5978
6025
|
return `**.${pattern}`;
|
|
@@ -6122,7 +6169,8 @@ function resolveRedactConfig(input) {
|
|
|
6122
6169
|
...input,
|
|
6123
6170
|
_pathMatchers: compileRedactPathMatchers(input.paths)
|
|
6124
6171
|
};
|
|
6125
|
-
const
|
|
6172
|
+
const { builtins } = input;
|
|
6173
|
+
const maskers = Array.isArray(builtins) ? Object.keys(builtinPatterns).filter((name) => builtins.includes(name)).map((name) => builtinPatterns[name]).map((b) => [cloneRegex(b.pattern), b.mask]) : allBuiltinMaskers();
|
|
6126
6174
|
return {
|
|
6127
6175
|
...input,
|
|
6128
6176
|
_maskers: maskers,
|
|
@@ -6289,8 +6337,6 @@ function setField(target, key, value) {
|
|
|
6289
6337
|
}
|
|
6290
6338
|
function writableChild(target, key) {
|
|
6291
6339
|
const child = target[key];
|
|
6292
|
-
if (!isPlainRecord(child))
|
|
6293
|
-
return child;
|
|
6294
6340
|
const copy = { ...child };
|
|
6295
6341
|
const { toJSON } = child;
|
|
6296
6342
|
if (typeof toJSON === "function" && !Object.hasOwn(copy, "toJSON"))
|
|
@@ -6311,7 +6357,7 @@ function mergeInto(target, source) {
|
|
|
6311
6357
|
const targetVal = key === "__proto__" && !Object.hasOwn(target, key) ? undefined : target[key];
|
|
6312
6358
|
if (sourceVal === targetVal)
|
|
6313
6359
|
continue;
|
|
6314
|
-
if (
|
|
6360
|
+
if (isPlainRecord(sourceVal) && isPlainRecord(targetVal))
|
|
6315
6361
|
mergeInto(writableChild(target, key), sourceVal);
|
|
6316
6362
|
else if (Array.isArray(targetVal) && Array.isArray(sourceVal))
|
|
6317
6363
|
setField(target, key, [...targetVal, ...sourceVal]);
|
|
@@ -6896,7 +6942,7 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
6896
6942
|
const deferDrain = internalOptions?._deferDrain ?? false;
|
|
6897
6943
|
const waitUntil = internalOptions?.waitUntil;
|
|
6898
6944
|
const startTime = Date.now();
|
|
6899
|
-
const context = { ...initialContext };
|
|
6945
|
+
const context = { ...serializeErrorsIn(initialContext) };
|
|
6900
6946
|
let hasError = false;
|
|
6901
6947
|
let hasFatal = false;
|
|
6902
6948
|
let hasWarn = false;
|
|
@@ -6918,7 +6964,7 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
6918
6964
|
return;
|
|
6919
6965
|
}
|
|
6920
6966
|
const fields = buildAuditFields(input);
|
|
6921
|
-
if (!
|
|
6967
|
+
if (!isPlainRecord(context.audit))
|
|
6922
6968
|
context.audit = fields;
|
|
6923
6969
|
else
|
|
6924
6970
|
mergeInto(writableChild(context, "audit"), fields);
|
|
@@ -6964,7 +7010,7 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
6964
7010
|
if (errorContext)
|
|
6965
7011
|
mergeFields(context, errorContext);
|
|
6966
7012
|
const errorObj = serializeError(err);
|
|
6967
|
-
if (
|
|
7013
|
+
if (isPlainRecord(context.error))
|
|
6968
7014
|
mergeInto(writableChild(context, "error"), errorObj);
|
|
6969
7015
|
else
|
|
6970
7016
|
context.error = errorObj;
|
|
@@ -7053,7 +7099,7 @@ function createLogger(initialContext = {}, internalOptions) {
|
|
|
7053
7099
|
return null;
|
|
7054
7100
|
}
|
|
7055
7101
|
if (overrides) {
|
|
7056
|
-
const obj = overrides;
|
|
7102
|
+
const obj = serializeErrorsIn(overrides);
|
|
7057
7103
|
for (const key in obj)
|
|
7058
7104
|
if (key !== "_forceKeep" && key !== "_durationMs")
|
|
7059
7105
|
context[key] = obj[key];
|
|
@@ -7183,14 +7229,25 @@ function finalizeAudit(event) {
|
|
|
7183
7229
|
_testCollector?.(decorated, event);
|
|
7184
7230
|
}
|
|
7185
7231
|
var DEFAULT_REPLACEMENT = "[REDACTED]", builtinPatterns, SECRET_KEY, globallyRedacted, serializeError, serializeErrorsIn, 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, CAPTURED_LINE_MAX_LENGTH = 160, CAPTURED_MAX_LINES = 8, _log, noopLogger, _testCollector = null;
|
|
7186
|
-
var
|
|
7232
|
+
var init_audit_D3F0XCdQ = __esm(() => {
|
|
7187
7233
|
init_utils();
|
|
7188
|
-
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
|
|
7234
|
+
init_globalRegistry_DxlJ7DCO();
|
|
7235
|
+
init_pretty_error_DnkXIALi();
|
|
7236
|
+
init_dev_terminal_CDXEC6Wl();
|
|
7237
|
+
init_wideEventChannel_BABjYpvc();
|
|
7238
|
+
init_serialize_error_CHmRO35i();
|
|
7193
7239
|
builtinPatterns = {
|
|
7240
|
+
bearer: {
|
|
7241
|
+
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
7242
|
+
mask: () => "Bearer ***"
|
|
7243
|
+
},
|
|
7244
|
+
iban: {
|
|
7245
|
+
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,
|
|
7246
|
+
mask: (m) => {
|
|
7247
|
+
const clean = m.replace(/[\s-]/g, "");
|
|
7248
|
+
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
7249
|
+
}
|
|
7250
|
+
},
|
|
7194
7251
|
creditCard: {
|
|
7195
7252
|
pattern: /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g,
|
|
7196
7253
|
mask: (m) => `****${m.replace(/[\s-]/g, "").slice(-4)}`
|
|
@@ -7224,17 +7281,6 @@ var init_audit_C5ZK3s_B = __esm(() => {
|
|
|
7224
7281
|
jwt: {
|
|
7225
7282
|
pattern: /\beyJ(?:(?!-eyJ)[\w-])*\.[\w-]*\.[\w-]*\b/g,
|
|
7226
7283
|
mask: () => "eyJ***.***"
|
|
7227
|
-
},
|
|
7228
|
-
bearer: {
|
|
7229
|
-
pattern: /\bBearer\s+[\w\-.~+/]{8,}=*/gi,
|
|
7230
|
-
mask: () => "Bearer ***"
|
|
7231
|
-
},
|
|
7232
|
-
iban: {
|
|
7233
|
-
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,
|
|
7234
|
-
mask: (m) => {
|
|
7235
|
-
const clean = m.replace(/[\s-]/g, "");
|
|
7236
|
-
return `${clean.slice(0, 4)}****${clean.slice(-3)}`;
|
|
7237
|
-
}
|
|
7238
7284
|
}
|
|
7239
7285
|
};
|
|
7240
7286
|
SECRET_KEY = /(?:password|passwd|secret|token)$/i;
|
|
@@ -7272,12 +7318,12 @@ var init_audit_C5ZK3s_B = __esm(() => {
|
|
|
7272
7318
|
initLogger(__EVLOG_CONFIG__);
|
|
7273
7319
|
});
|
|
7274
7320
|
|
|
7275
|
-
// ../../node_modules/.bun/evlog@2.
|
|
7321
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/index.mjs
|
|
7276
7322
|
var init_dist = __esm(() => {
|
|
7277
|
-
|
|
7323
|
+
init_audit_D3F0XCdQ();
|
|
7278
7324
|
});
|
|
7279
7325
|
|
|
7280
|
-
// ../../node_modules/.bun/evlog@2.
|
|
7326
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/errors-Cl1GMJa_.mjs
|
|
7281
7327
|
function extractErrorStatus(error) {
|
|
7282
7328
|
if (error === null || typeof error !== "object")
|
|
7283
7329
|
return 500;
|
|
@@ -7285,9 +7331,9 @@ function extractErrorStatus(error) {
|
|
|
7285
7331
|
const status = Number(raw);
|
|
7286
7332
|
return Number.isFinite(status) ? status : 500;
|
|
7287
7333
|
}
|
|
7288
|
-
var
|
|
7334
|
+
var init_errors_Cl1GMJa_ = () => {};
|
|
7289
7335
|
|
|
7290
|
-
// ../../node_modules/.bun/evlog@2.
|
|
7336
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/middleware-fmopETyt.mjs
|
|
7291
7337
|
function shouldLog(path, include, exclude) {
|
|
7292
7338
|
if (exclude && exclude.length > 0) {
|
|
7293
7339
|
if (exclude.some((pattern) => matchesPattern(path, pattern)))
|
|
@@ -7595,12 +7641,12 @@ function createMiddlewareLogger(options) {
|
|
|
7595
7641
|
};
|
|
7596
7642
|
}
|
|
7597
7643
|
var noopResult, runnerCache;
|
|
7598
|
-
var
|
|
7644
|
+
var init_middleware_fmopETyt = __esm(() => {
|
|
7599
7645
|
init_utils();
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7646
|
+
init_audit_D3F0XCdQ();
|
|
7647
|
+
init_globalRegistry_DxlJ7DCO();
|
|
7648
|
+
init_wideEventChannel_BABjYpvc();
|
|
7649
|
+
init_errors_Cl1GMJa_();
|
|
7604
7650
|
noopResult = {
|
|
7605
7651
|
logger: noopLogger,
|
|
7606
7652
|
finish: () => Promise.resolve(null),
|
|
@@ -7610,7 +7656,7 @@ var init_middleware_CmfmqXwL = __esm(() => {
|
|
|
7610
7656
|
runnerCache = /* @__PURE__ */ new WeakMap;
|
|
7611
7657
|
});
|
|
7612
7658
|
|
|
7613
|
-
// ../../node_modules/.bun/evlog@2.
|
|
7659
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/integration-D9IUwqvW.mjs
|
|
7614
7660
|
function attachForkToLogger(storage, parent, middlewareOptions, lifecycle) {
|
|
7615
7661
|
parent.fork = (label, fn) => forkBackgroundLogger({
|
|
7616
7662
|
storage,
|
|
@@ -7714,14 +7760,14 @@ function defineFrameworkIntegration(spec) {
|
|
|
7714
7760
|
};
|
|
7715
7761
|
} };
|
|
7716
7762
|
}
|
|
7717
|
-
var
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7763
|
+
var init_integration_D9IUwqvW = __esm(() => {
|
|
7764
|
+
init_audit_D3F0XCdQ();
|
|
7765
|
+
init_headers_DpB4nPAJ();
|
|
7766
|
+
init_errors_Cl1GMJa_();
|
|
7767
|
+
init_middleware_fmopETyt();
|
|
7722
7768
|
});
|
|
7723
7769
|
|
|
7724
|
-
// ../../node_modules/.bun/evlog@2.
|
|
7770
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/toolkit/storage.mjs
|
|
7725
7771
|
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
7726
7772
|
function createLoggerStorage(contextHint, id = contextHint) {
|
|
7727
7773
|
const storage = getSharedStorage(id, () => new AsyncLocalStorage3);
|
|
@@ -7737,13 +7783,13 @@ function createLoggerStorage(contextHint, id = contextHint) {
|
|
|
7737
7783
|
};
|
|
7738
7784
|
}
|
|
7739
7785
|
var init_storage = __esm(() => {
|
|
7740
|
-
|
|
7786
|
+
init_globalRegistry_DxlJ7DCO();
|
|
7741
7787
|
});
|
|
7742
7788
|
|
|
7743
|
-
// ../../node_modules/.bun/evlog@2.
|
|
7789
|
+
// ../../node_modules/.bun/evlog@2.34.0+86bc96d63db325a2/node_modules/evlog/dist/toolkit.mjs
|
|
7744
7790
|
var init_toolkit = __esm(() => {
|
|
7745
|
-
|
|
7746
|
-
|
|
7791
|
+
init_middleware_fmopETyt();
|
|
7792
|
+
init_integration_D9IUwqvW();
|
|
7747
7793
|
init_storage();
|
|
7748
7794
|
});
|
|
7749
7795
|
|
|
@@ -8446,12 +8492,7 @@ function getSyncPath() {
|
|
|
8446
8492
|
return currentInstance().syncPath;
|
|
8447
8493
|
}
|
|
8448
8494
|
function syncRuntimeOptions(sync) {
|
|
8449
|
-
return
|
|
8450
|
-
adapter: sync.adapter,
|
|
8451
|
-
notifier: sync.notifier,
|
|
8452
|
-
principal: sync.principal,
|
|
8453
|
-
secret: sync.secret
|
|
8454
|
-
};
|
|
8495
|
+
return sync;
|
|
8455
8496
|
}
|
|
8456
8497
|
var SYNC_DEFAULT_PATH = "/_furin/sync";
|
|
8457
8498
|
var init_config = __esm(() => {
|
|
@@ -10293,6 +10334,112 @@ function validateRouteChain(chain, root, pagePath) {
|
|
|
10293
10334
|
}
|
|
10294
10335
|
}
|
|
10295
10336
|
|
|
10337
|
+
// src/client/sync-catch-up.ts
|
|
10338
|
+
function changeInvalidations(change) {
|
|
10339
|
+
const paths = [];
|
|
10340
|
+
const queries = [...change.queries ?? []];
|
|
10341
|
+
for (const entry of change.invalidations) {
|
|
10342
|
+
if (typeof entry === "string") {
|
|
10343
|
+
const trimmed = entry.trim();
|
|
10344
|
+
const type = trimmed.endsWith(":layout") ? "layout" : "page";
|
|
10345
|
+
const path = trimmed.replace(LAYOUT_SUFFIX_RE, "");
|
|
10346
|
+
paths.push(encodeInvalidationEntry(path, type));
|
|
10347
|
+
} else if (entry.kind === "path") {
|
|
10348
|
+
paths.push(encodeInvalidationEntry(entry.path, entry.type));
|
|
10349
|
+
} else {
|
|
10350
|
+
for (const tag of entry.tags) {
|
|
10351
|
+
const identity = queryFromTag(tag);
|
|
10352
|
+
if (identity) {
|
|
10353
|
+
queries.push(identity);
|
|
10354
|
+
} else {
|
|
10355
|
+
paths.push("/:layout");
|
|
10356
|
+
}
|
|
10357
|
+
}
|
|
10358
|
+
}
|
|
10359
|
+
}
|
|
10360
|
+
return { paths, queries };
|
|
10361
|
+
}
|
|
10362
|
+
function createSyncCatchUp(options) {
|
|
10363
|
+
let currentCursor;
|
|
10364
|
+
let running;
|
|
10365
|
+
let requested = false;
|
|
10366
|
+
let lastReset = Number.NEGATIVE_INFINITY;
|
|
10367
|
+
let pendingReset;
|
|
10368
|
+
let closed = false;
|
|
10369
|
+
const refreshAfterReset = () => {
|
|
10370
|
+
pendingReset = undefined;
|
|
10371
|
+
lastReset = Date.now();
|
|
10372
|
+
options.onReset?.();
|
|
10373
|
+
options.onInvalidations(["/:layout"]);
|
|
10374
|
+
};
|
|
10375
|
+
const scheduleResetRefresh = () => {
|
|
10376
|
+
if (pendingReset) {
|
|
10377
|
+
return;
|
|
10378
|
+
}
|
|
10379
|
+
const wait = lastReset + RESET_REFRESH_INTERVAL_MS - Date.now();
|
|
10380
|
+
if (wait <= 0) {
|
|
10381
|
+
refreshAfterReset();
|
|
10382
|
+
} else {
|
|
10383
|
+
pendingReset = setTimeout(refreshAfterReset, wait);
|
|
10384
|
+
}
|
|
10385
|
+
};
|
|
10386
|
+
const readUntilCurrent = async () => {
|
|
10387
|
+
do {
|
|
10388
|
+
requested = false;
|
|
10389
|
+
let page;
|
|
10390
|
+
do {
|
|
10391
|
+
page = await options.fetchPage(currentCursor ?? "0");
|
|
10392
|
+
if (closed) {
|
|
10393
|
+
return;
|
|
10394
|
+
}
|
|
10395
|
+
if (page.reset) {
|
|
10396
|
+
currentCursor = page.cursor;
|
|
10397
|
+
scheduleResetRefresh();
|
|
10398
|
+
break;
|
|
10399
|
+
}
|
|
10400
|
+
for (const change of page.changes) {
|
|
10401
|
+
applyChange(change);
|
|
10402
|
+
}
|
|
10403
|
+
currentCursor = page.cursor;
|
|
10404
|
+
} while (page.hasMore);
|
|
10405
|
+
} while (requested && !closed);
|
|
10406
|
+
};
|
|
10407
|
+
const applyChange = (change) => {
|
|
10408
|
+
const { paths, queries } = changeInvalidations(change);
|
|
10409
|
+
options.onInvalidations(paths);
|
|
10410
|
+
if (queries.length > 0) {
|
|
10411
|
+
options.onQueries?.(queries);
|
|
10412
|
+
}
|
|
10413
|
+
};
|
|
10414
|
+
return {
|
|
10415
|
+
catchUp() {
|
|
10416
|
+
if (closed) {
|
|
10417
|
+
return Promise.resolve();
|
|
10418
|
+
}
|
|
10419
|
+
requested = true;
|
|
10420
|
+
if (!running) {
|
|
10421
|
+
running = readUntilCurrent().finally(() => {
|
|
10422
|
+
running = undefined;
|
|
10423
|
+
});
|
|
10424
|
+
}
|
|
10425
|
+
return running;
|
|
10426
|
+
},
|
|
10427
|
+
cursor: () => currentCursor,
|
|
10428
|
+
close() {
|
|
10429
|
+
closed = true;
|
|
10430
|
+
clearTimeout(pendingReset);
|
|
10431
|
+
},
|
|
10432
|
+
seed(cursor) {
|
|
10433
|
+
currentCursor ??= cursor;
|
|
10434
|
+
}
|
|
10435
|
+
};
|
|
10436
|
+
}
|
|
10437
|
+
var LAYOUT_SUFFIX_RE, RESET_REFRESH_INTERVAL_MS = 1000;
|
|
10438
|
+
var init_sync_catch_up = __esm(() => {
|
|
10439
|
+
init_invalidation_header();
|
|
10440
|
+
LAYOUT_SUFFIX_RE = /:layout$/;
|
|
10441
|
+
});
|
|
10442
|
+
|
|
10296
10443
|
// src/shared/navigation-data.ts
|
|
10297
10444
|
function stripNavigationDataSearch(search) {
|
|
10298
10445
|
const entries = search.slice(1).split("&");
|
|
@@ -10376,6 +10523,7 @@ var init_router = () => {};
|
|
|
10376
10523
|
|
|
10377
10524
|
// src/client/link.tsx
|
|
10378
10525
|
import { createElement as createElement4, useCallback as useCallback3, useEffect as useEffect2, useRef, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
10526
|
+
import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
|
|
10379
10527
|
function resolveLinkHref({ to, params, search, hash }, router2) {
|
|
10380
10528
|
const resolvedTo = applyLinkParams(to, params);
|
|
10381
10529
|
const searchDefaults = findSearchDefaultsForRouteTarget(resolvedTo, router2.searchRoutes);
|
|
@@ -10443,12 +10591,12 @@ function LinkInteractive({
|
|
|
10443
10591
|
if (target !== null) {
|
|
10444
10592
|
prefetch(target, { staleTime: effectiveStaleTime });
|
|
10445
10593
|
}
|
|
10446
|
-
}, [prefetch,
|
|
10594
|
+
}, [prefetch, effectiveStaleTime, router2.basePath]);
|
|
10447
10595
|
useEffect2(() => {
|
|
10448
10596
|
if (effectivePreload === "render") {
|
|
10449
10597
|
triggerPrefetch();
|
|
10450
10598
|
}
|
|
10451
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
10599
|
+
}, [effectivePreload, triggerPrefetch, logicalHref]);
|
|
10452
10600
|
useEffect2(() => {
|
|
10453
10601
|
if (effectivePreload !== "viewport" || !anchorRef.current) {
|
|
10454
10602
|
return;
|
|
@@ -10461,7 +10609,7 @@ function LinkInteractive({
|
|
|
10461
10609
|
}, { rootMargin: "200px" });
|
|
10462
10610
|
observer.observe(anchorRef.current);
|
|
10463
10611
|
return () => observer.disconnect();
|
|
10464
|
-
}, [effectivePreload, triggerPrefetch]);
|
|
10612
|
+
}, [effectivePreload, triggerPrefetch, logicalHref]);
|
|
10465
10613
|
useEffect2(() => () => {
|
|
10466
10614
|
if (intentTimerRef.current !== null) {
|
|
10467
10615
|
clearTimeout(intentTimerRef.current);
|
|
@@ -10490,7 +10638,7 @@ function LinkInteractive({
|
|
|
10490
10638
|
}
|
|
10491
10639
|
e.preventDefault();
|
|
10492
10640
|
if (typeof window !== "undefined" && router2.navigate === CLIENT_FALLBACK_ROUTER.navigate) {
|
|
10493
|
-
window.location.href
|
|
10641
|
+
window.location.assign(href);
|
|
10494
10642
|
return;
|
|
10495
10643
|
}
|
|
10496
10644
|
router2.navigate(target, { replace, resetScroll: resetScroll ?? true });
|
|
@@ -10514,7 +10662,7 @@ function LinkInteractive({
|
|
|
10514
10662
|
triggerPrefetch();
|
|
10515
10663
|
}
|
|
10516
10664
|
};
|
|
10517
|
-
return
|
|
10665
|
+
return /* @__PURE__ */ jsxDEV2("a", {
|
|
10518
10666
|
"data-furin-link": true,
|
|
10519
10667
|
href,
|
|
10520
10668
|
onClick: handleClick,
|
|
@@ -10525,8 +10673,9 @@ function LinkInteractive({
|
|
|
10525
10673
|
...isActive ? { "data-status": "active" } : {},
|
|
10526
10674
|
...anchorProps,
|
|
10527
10675
|
...extraProps,
|
|
10528
|
-
...disabled ? { "aria-disabled": true } : {}
|
|
10529
|
-
|
|
10676
|
+
...disabled ? { "aria-disabled": true } : {},
|
|
10677
|
+
children: resolvedChildren
|
|
10678
|
+
}, undefined, false, undefined, this);
|
|
10530
10679
|
}
|
|
10531
10680
|
function renderLinkElement(props, router2) {
|
|
10532
10681
|
const { activeHref, href } = resolveLinkHref(props, router2);
|
|
@@ -10595,7 +10744,7 @@ var init_link = __esm(() => {
|
|
|
10595
10744
|
});
|
|
10596
10745
|
|
|
10597
10746
|
// src/client/default-screens.tsx
|
|
10598
|
-
import { jsxDEV as
|
|
10747
|
+
import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
|
|
10599
10748
|
function CornerBracket({ corner }) {
|
|
10600
10749
|
const top = corner === "tl" || corner === "tr";
|
|
10601
10750
|
const left = corner === "tl" || corner === "bl";
|
|
@@ -10606,38 +10755,38 @@ function CornerBracket({ corner }) {
|
|
|
10606
10755
|
[`border${top ? "Top" : "Bottom"}`]: `2px solid ${COLOR_BRACKET}`,
|
|
10607
10756
|
[`border${left ? "Left" : "Right"}`]: `2px solid ${COLOR_BRACKET}`
|
|
10608
10757
|
};
|
|
10609
|
-
return /* @__PURE__ */
|
|
10758
|
+
return /* @__PURE__ */ jsxDEV3("span", {
|
|
10610
10759
|
"aria-hidden": "true",
|
|
10611
10760
|
style
|
|
10612
10761
|
}, undefined, false, undefined, this);
|
|
10613
10762
|
}
|
|
10614
10763
|
function ScreenFrame({ badge, children }) {
|
|
10615
|
-
return /* @__PURE__ */
|
|
10764
|
+
return /* @__PURE__ */ jsxDEV3("div", {
|
|
10616
10765
|
style: PAGE_STYLE,
|
|
10617
10766
|
children: [
|
|
10618
|
-
/* @__PURE__ */
|
|
10767
|
+
/* @__PURE__ */ jsxDEV3("style", {
|
|
10619
10768
|
children: RESET_CSS
|
|
10620
10769
|
}, undefined, false, undefined, this),
|
|
10621
|
-
/* @__PURE__ */
|
|
10770
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10622
10771
|
style: FRAME_STYLE,
|
|
10623
10772
|
children: [
|
|
10624
|
-
/* @__PURE__ */
|
|
10773
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10625
10774
|
corner: "tl"
|
|
10626
10775
|
}, undefined, false, undefined, this),
|
|
10627
|
-
/* @__PURE__ */
|
|
10776
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10628
10777
|
corner: "tr"
|
|
10629
10778
|
}, undefined, false, undefined, this),
|
|
10630
|
-
/* @__PURE__ */
|
|
10779
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10631
10780
|
corner: "bl"
|
|
10632
10781
|
}, undefined, false, undefined, this),
|
|
10633
|
-
/* @__PURE__ */
|
|
10782
|
+
/* @__PURE__ */ jsxDEV3(CornerBracket, {
|
|
10634
10783
|
corner: "br"
|
|
10635
10784
|
}, undefined, false, undefined, this),
|
|
10636
|
-
/* @__PURE__ */
|
|
10785
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10637
10786
|
style: CARD_STYLE,
|
|
10638
10787
|
children: [
|
|
10639
10788
|
badge,
|
|
10640
|
-
/* @__PURE__ */
|
|
10789
|
+
/* @__PURE__ */ jsxDEV3("hr", {
|
|
10641
10790
|
style: DIVIDER_STYLE
|
|
10642
10791
|
}, undefined, false, undefined, this),
|
|
10643
10792
|
children
|
|
@@ -10649,41 +10798,41 @@ function ScreenFrame({ badge, children }) {
|
|
|
10649
10798
|
}, undefined, true, undefined, this);
|
|
10650
10799
|
}
|
|
10651
10800
|
function DefaultErrorScreen({ message, digest, reset }) {
|
|
10652
|
-
return /* @__PURE__ */
|
|
10653
|
-
badge: /* @__PURE__ */
|
|
10801
|
+
return /* @__PURE__ */ jsxDEV3(ScreenFrame, {
|
|
10802
|
+
badge: /* @__PURE__ */ jsxDEV3("div", {
|
|
10654
10803
|
style: BADGE_STYLE,
|
|
10655
10804
|
children: "500 \u2014 ERROR"
|
|
10656
10805
|
}, undefined, false, undefined, this),
|
|
10657
10806
|
children: [
|
|
10658
|
-
/* @__PURE__ */
|
|
10807
|
+
/* @__PURE__ */ jsxDEV3("h1", {
|
|
10659
10808
|
style: HEADING_STYLE,
|
|
10660
10809
|
children: "Something went wrong"
|
|
10661
10810
|
}, undefined, false, undefined, this),
|
|
10662
|
-
/* @__PURE__ */
|
|
10811
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10663
10812
|
style: CODE_BOX_STYLE,
|
|
10664
10813
|
children: [
|
|
10665
|
-
/* @__PURE__ */
|
|
10814
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
10666
10815
|
style: CODE_LABEL_STYLE,
|
|
10667
10816
|
children: "CODE:"
|
|
10668
10817
|
}, undefined, false, undefined, this),
|
|
10669
|
-
/* @__PURE__ */
|
|
10818
|
+
/* @__PURE__ */ jsxDEV3("span", {
|
|
10670
10819
|
children: digest
|
|
10671
10820
|
}, undefined, false, undefined, this)
|
|
10672
10821
|
]
|
|
10673
10822
|
}, undefined, true, undefined, this),
|
|
10674
|
-
/* @__PURE__ */
|
|
10823
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
10675
10824
|
style: DESCRIPTION_WRAPPER_STYLE,
|
|
10676
10825
|
children: message ? message : "We encountered an unexpected error. Please try again or return to the home page."
|
|
10677
10826
|
}, undefined, false, undefined, this),
|
|
10678
|
-
/* @__PURE__ */
|
|
10827
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10679
10828
|
style: ACTIONS_STYLE,
|
|
10680
10829
|
children: [
|
|
10681
|
-
/* @__PURE__ */
|
|
10830
|
+
/* @__PURE__ */ jsxDEV3(Link, {
|
|
10682
10831
|
style: BUTTON_PRIMARY,
|
|
10683
10832
|
to: "/",
|
|
10684
10833
|
children: "Go Home"
|
|
10685
10834
|
}, undefined, false, undefined, this),
|
|
10686
|
-
/* @__PURE__ */
|
|
10835
|
+
/* @__PURE__ */ jsxDEV3("button", {
|
|
10687
10836
|
onClick: reset,
|
|
10688
10837
|
style: BUTTON_SECONDARY,
|
|
10689
10838
|
type: "button",
|
|
@@ -10695,23 +10844,23 @@ function DefaultErrorScreen({ message, digest, reset }) {
|
|
|
10695
10844
|
}, undefined, true, undefined, this);
|
|
10696
10845
|
}
|
|
10697
10846
|
function DefaultNotFoundScreen({ message }) {
|
|
10698
|
-
return /* @__PURE__ */
|
|
10699
|
-
badge: /* @__PURE__ */
|
|
10847
|
+
return /* @__PURE__ */ jsxDEV3(ScreenFrame, {
|
|
10848
|
+
badge: /* @__PURE__ */ jsxDEV3("div", {
|
|
10700
10849
|
style: BADGE_STYLE,
|
|
10701
10850
|
children: "404 \u2014 NOT FOUND"
|
|
10702
10851
|
}, undefined, false, undefined, this),
|
|
10703
10852
|
children: [
|
|
10704
|
-
/* @__PURE__ */
|
|
10853
|
+
/* @__PURE__ */ jsxDEV3("h1", {
|
|
10705
10854
|
style: HEADING_STYLE,
|
|
10706
10855
|
children: "This page does not exist"
|
|
10707
10856
|
}, undefined, false, undefined, this),
|
|
10708
|
-
/* @__PURE__ */
|
|
10857
|
+
/* @__PURE__ */ jsxDEV3("p", {
|
|
10709
10858
|
style: DESCRIPTION_WRAPPER_STYLE,
|
|
10710
10859
|
children: message ? message : "The page you are looking for could not be found. It may have been moved or removed."
|
|
10711
10860
|
}, undefined, false, undefined, this),
|
|
10712
|
-
/* @__PURE__ */
|
|
10861
|
+
/* @__PURE__ */ jsxDEV3("div", {
|
|
10713
10862
|
style: ACTIONS_STYLE,
|
|
10714
|
-
children: /* @__PURE__ */
|
|
10863
|
+
children: /* @__PURE__ */ jsxDEV3(Link, {
|
|
10715
10864
|
style: BUTTON_PRIMARY,
|
|
10716
10865
|
to: "/",
|
|
10717
10866
|
children: "Go Home"
|
|
@@ -10720,11 +10869,11 @@ function DefaultNotFoundScreen({ message }) {
|
|
|
10720
10869
|
]
|
|
10721
10870
|
}, undefined, true, undefined, this);
|
|
10722
10871
|
}
|
|
10723
|
-
var FONT_SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', FONT_MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', COLOR_BG = "#000000", COLOR_TEXT = "#ffffff", COLOR_TEXT_DIM = "rgba(255, 255, 255, 0.7)", COLOR_TEXT_MUTED = "rgba(255, 255, 255, 0.45)", COLOR_GRID = "rgba(255, 255, 255, 0.04)", COLOR_BRACKET = "rgba(255, 255, 255, 0.55)", COLOR_DANGER_DIM = "rgba(239, 68, 68, 0.6)", PAGE_STYLE, FRAME_STYLE, BRACKET_BASE, CARD_STYLE, BADGE_STYLE, HEADING_STYLE, CODE_BOX_STYLE, CODE_LABEL_STYLE, DESCRIPTION_WRAPPER_STYLE, ACTIONS_STYLE, BUTTON_BASE, BUTTON_PRIMARY, BUTTON_SECONDARY, DIVIDER_STYLE, RESET_CSS, DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */
|
|
10872
|
+
var FONT_SANS = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', FONT_MONO = 'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace', COLOR_BG = "#000000", COLOR_TEXT = "#ffffff", COLOR_TEXT_DIM = "rgba(255, 255, 255, 0.7)", COLOR_TEXT_MUTED = "rgba(255, 255, 255, 0.45)", COLOR_GRID = "rgba(255, 255, 255, 0.04)", COLOR_BRACKET = "rgba(255, 255, 255, 0.55)", COLOR_DANGER_DIM = "rgba(239, 68, 68, 0.6)", PAGE_STYLE, FRAME_STYLE, BRACKET_BASE, CARD_STYLE, BADGE_STYLE, HEADING_STYLE, CODE_BOX_STYLE, CODE_LABEL_STYLE, DESCRIPTION_WRAPPER_STYLE, ACTIONS_STYLE, BUTTON_BASE, BUTTON_PRIMARY, BUTTON_SECONDARY, DIVIDER_STYLE, RESET_CSS, DefaultErrorFallback = ({ error, reset }) => /* @__PURE__ */ jsxDEV3(DefaultErrorScreen, {
|
|
10724
10873
|
digest: error.digest,
|
|
10725
10874
|
message: error.message,
|
|
10726
10875
|
reset
|
|
10727
|
-
}, undefined, false, undefined, this), DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */
|
|
10876
|
+
}, undefined, false, undefined, this), DefaultNotFoundFallback = ({ error }) => /* @__PURE__ */ jsxDEV3(DefaultNotFoundScreen, {
|
|
10728
10877
|
message: error.message
|
|
10729
10878
|
}, undefined, false, undefined, this);
|
|
10730
10879
|
var init_default_screens = __esm(() => {
|
|
@@ -10864,7 +11013,7 @@ html, body {
|
|
|
10864
11013
|
|
|
10865
11014
|
// src/client/boundaries.tsx
|
|
10866
11015
|
import { Component, Fragment as Fragment2 } from "react";
|
|
10867
|
-
import { jsxDEV as
|
|
11016
|
+
import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
|
|
10868
11017
|
function getServerDigest(error) {
|
|
10869
11018
|
if (typeof error !== "object" && typeof error !== "function" || error === null) {
|
|
10870
11019
|
return;
|
|
@@ -10888,14 +11037,14 @@ function wrapSegmentBoundaries(inner, segment, options) {
|
|
|
10888
11037
|
}
|
|
10889
11038
|
let wrapped = inner;
|
|
10890
11039
|
if (segment.notFound) {
|
|
10891
|
-
wrapped = /* @__PURE__ */
|
|
11040
|
+
wrapped = /* @__PURE__ */ jsxDEV4(FurinNotFoundBoundary, {
|
|
10892
11041
|
fallback: segment.notFound,
|
|
10893
11042
|
resetKey: options?.resetKey,
|
|
10894
11043
|
children: wrapped
|
|
10895
11044
|
}, undefined, false, undefined, this);
|
|
10896
11045
|
}
|
|
10897
11046
|
if (segment.error) {
|
|
10898
|
-
wrapped = /* @__PURE__ */
|
|
11047
|
+
wrapped = /* @__PURE__ */ jsxDEV4(FurinErrorBoundary, {
|
|
10899
11048
|
fallback: segment.error,
|
|
10900
11049
|
onReset: options?.onReset,
|
|
10901
11050
|
resetKey: options?.resetKey,
|
|
@@ -10948,15 +11097,15 @@ var init_boundaries = __esm(() => {
|
|
|
10948
11097
|
const serverDigest = getServerDigest(error);
|
|
10949
11098
|
const finalDigest = serverDigest ?? digest ?? this.props.digest ?? computeErrorDigest(error);
|
|
10950
11099
|
const message = this.props.fallback ? error.message : getPublicErrorMessage(error);
|
|
10951
|
-
const fallback = /* @__PURE__ */
|
|
11100
|
+
const fallback = /* @__PURE__ */ jsxDEV4(Fallback, {
|
|
10952
11101
|
error: { digest: finalDigest, message, status: DEFAULT_ERROR_STATUS },
|
|
10953
11102
|
reset: typeof window === "undefined" ? SERVER_RESET_NOOP : this.reset
|
|
10954
11103
|
}, undefined, false, undefined, this);
|
|
10955
|
-
return this.props.document ? /* @__PURE__ */
|
|
11104
|
+
return this.props.document ? /* @__PURE__ */ jsxDEV4(FurinDocumentFallback, {
|
|
10956
11105
|
children: fallback
|
|
10957
11106
|
}, undefined, false, undefined, this) : fallback;
|
|
10958
11107
|
}
|
|
10959
|
-
return /* @__PURE__ */
|
|
11108
|
+
return /* @__PURE__ */ jsxDEV4(Fragment2, {
|
|
10960
11109
|
children: this.props.children
|
|
10961
11110
|
}, epoch, false, undefined, this);
|
|
10962
11111
|
}
|
|
@@ -10978,11 +11127,11 @@ var init_boundaries = __esm(() => {
|
|
|
10978
11127
|
throw error;
|
|
10979
11128
|
}
|
|
10980
11129
|
const Fallback = this.props.fallback ?? DefaultNotFoundFallback;
|
|
10981
|
-
return /* @__PURE__ */
|
|
11130
|
+
return /* @__PURE__ */ jsxDEV4(Fallback, {
|
|
10982
11131
|
error: { data: error.data, message: error.message }
|
|
10983
11132
|
}, undefined, false, undefined, this);
|
|
10984
11133
|
}
|
|
10985
|
-
return /* @__PURE__ */
|
|
11134
|
+
return /* @__PURE__ */ jsxDEV4(Fragment2, {
|
|
10986
11135
|
children: this.props.children
|
|
10987
11136
|
}, epoch, false, undefined, this);
|
|
10988
11137
|
}
|
|
@@ -11095,10 +11244,10 @@ var init_route_element = __esm(() => {
|
|
|
11095
11244
|
});
|
|
11096
11245
|
|
|
11097
11246
|
// src/server/render/element.tsx
|
|
11098
|
-
import { jsxDEV as
|
|
11247
|
+
import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
|
|
11099
11248
|
function buildNotFoundElement(component, error) {
|
|
11100
11249
|
const NotFound = component ?? DefaultNotFoundFallback;
|
|
11101
|
-
return /* @__PURE__ */
|
|
11250
|
+
return /* @__PURE__ */ jsxDEV5(NotFound, {
|
|
11102
11251
|
error: { data: error.data, message: error.message }
|
|
11103
11252
|
}, undefined, false, undefined, this);
|
|
11104
11253
|
}
|
|
@@ -11127,7 +11276,7 @@ function errorMessageForRender(component, error, messageOverride) {
|
|
|
11127
11276
|
function buildErrorElement(component, error, digest, messageOverride, status) {
|
|
11128
11277
|
const ErrorView = component ?? DefaultErrorFallback;
|
|
11129
11278
|
const message = errorMessageForRender(component, error, messageOverride);
|
|
11130
|
-
return /* @__PURE__ */
|
|
11279
|
+
return /* @__PURE__ */ jsxDEV5(ErrorView, {
|
|
11131
11280
|
error: { digest, message, status },
|
|
11132
11281
|
reset: SERVER_RESET_NOOP2
|
|
11133
11282
|
}, undefined, false, undefined, this);
|
|
@@ -11152,7 +11301,7 @@ var resolveModuleHrefs = () => [], resolveNonce = () => {
|
|
|
11152
11301
|
var init_client_module = () => {};
|
|
11153
11302
|
|
|
11154
11303
|
// src/client/browser-events-runtime.ts
|
|
11155
|
-
function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
11304
|
+
function installBrowserEventsRuntime(browser, moduleUrlValue, transport, sync) {
|
|
11156
11305
|
const runtimeKey = Symbol.for("furin.browser-events.runtime");
|
|
11157
11306
|
const runtimeWindow = browser;
|
|
11158
11307
|
if (runtimeWindow[runtimeKey]) {
|
|
@@ -11171,7 +11320,8 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11171
11320
|
return false;
|
|
11172
11321
|
}
|
|
11173
11322
|
if (candidate.channel === "sync") {
|
|
11174
|
-
|
|
11323
|
+
const data = candidate.data;
|
|
11324
|
+
return typeof data.cursor === "string" || data.context === "changed";
|
|
11175
11325
|
}
|
|
11176
11326
|
return candidate.channel === "diagnostic" || candidate.channel === "devtools";
|
|
11177
11327
|
};
|
|
@@ -11203,6 +11353,9 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11203
11353
|
let eventSource;
|
|
11204
11354
|
let status = "connecting";
|
|
11205
11355
|
let suspended = false;
|
|
11356
|
+
let authPaused = false;
|
|
11357
|
+
let authorized = !sync;
|
|
11358
|
+
let authenticating;
|
|
11206
11359
|
const updateStatus = (next) => {
|
|
11207
11360
|
if (status === next) {
|
|
11208
11361
|
return;
|
|
@@ -11240,7 +11393,63 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11240
11393
|
}
|
|
11241
11394
|
} catch {}
|
|
11242
11395
|
};
|
|
11396
|
+
const retry = () => {
|
|
11397
|
+
if (suspended || authPaused || reconnectTimer !== undefined) {
|
|
11398
|
+
return;
|
|
11399
|
+
}
|
|
11400
|
+
updateStatus("reconnecting");
|
|
11401
|
+
const baseDelay = Math.min(250 * 2 ** reconnectAttempt, maxReconnectDelayMs);
|
|
11402
|
+
const delay = transport === "sse" ? baseDelay : Math.min(Math.round(baseDelay * (0.8 + Math.random() * 0.4)), maxReconnectDelayMs);
|
|
11403
|
+
reconnectAttempt += 1;
|
|
11404
|
+
reconnectTimer = browser.setTimeout(() => {
|
|
11405
|
+
reconnectTimer = undefined;
|
|
11406
|
+
connect();
|
|
11407
|
+
}, delay);
|
|
11408
|
+
};
|
|
11409
|
+
const authenticate = async () => {
|
|
11410
|
+
if (authenticating) {
|
|
11411
|
+
return;
|
|
11412
|
+
}
|
|
11413
|
+
const current = new AbortController;
|
|
11414
|
+
authenticating = current;
|
|
11415
|
+
try {
|
|
11416
|
+
const response = await browser.fetch(eventsUrl(), {
|
|
11417
|
+
method: "HEAD",
|
|
11418
|
+
credentials: "same-origin",
|
|
11419
|
+
cache: "no-store",
|
|
11420
|
+
signal: current.signal
|
|
11421
|
+
});
|
|
11422
|
+
if (current.signal.aborted) {
|
|
11423
|
+
return;
|
|
11424
|
+
}
|
|
11425
|
+
if (response.status === 401 || response.status === 403) {
|
|
11426
|
+
dispatch({ channel: "sync", data: { context: "changed" }, version: protocolVersion });
|
|
11427
|
+
setSyncAuthentication(false);
|
|
11428
|
+
return;
|
|
11429
|
+
}
|
|
11430
|
+
if (!response.ok) {
|
|
11431
|
+
throw new Error(`Sync authentication failed: ${response.status}`);
|
|
11432
|
+
}
|
|
11433
|
+
authorized = true;
|
|
11434
|
+
connect();
|
|
11435
|
+
} catch {
|
|
11436
|
+
if (!current.signal.aborted) {
|
|
11437
|
+
retry();
|
|
11438
|
+
}
|
|
11439
|
+
} finally {
|
|
11440
|
+
if (authenticating === current) {
|
|
11441
|
+
authenticating = undefined;
|
|
11442
|
+
}
|
|
11443
|
+
}
|
|
11444
|
+
};
|
|
11243
11445
|
const connect = () => {
|
|
11446
|
+
if (suspended || authPaused) {
|
|
11447
|
+
return;
|
|
11448
|
+
}
|
|
11449
|
+
if (!authorized) {
|
|
11450
|
+
authenticate();
|
|
11451
|
+
return;
|
|
11452
|
+
}
|
|
11244
11453
|
if (transport === "sse") {
|
|
11245
11454
|
if (suspended || eventSource !== undefined && eventSource.readyState !== runtimeWindow.EventSource.CLOSED) {
|
|
11246
11455
|
return;
|
|
@@ -11261,12 +11470,8 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11261
11470
|
return;
|
|
11262
11471
|
}
|
|
11263
11472
|
eventSource = undefined;
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
reconnectTimer = browser.setTimeout(() => {
|
|
11267
|
-
reconnectTimer = undefined;
|
|
11268
|
-
connect();
|
|
11269
|
-
}, delay);
|
|
11473
|
+
authorized = !sync;
|
|
11474
|
+
retry();
|
|
11270
11475
|
});
|
|
11271
11476
|
return;
|
|
11272
11477
|
}
|
|
@@ -11288,19 +11493,16 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11288
11493
|
if (suspended || reconnectTimer !== undefined) {
|
|
11289
11494
|
return;
|
|
11290
11495
|
}
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
const delay = Math.min(Math.round(baseDelay * (0.8 + Math.random() * 0.4)), maxReconnectDelayMs);
|
|
11294
|
-
reconnectAttempt += 1;
|
|
11295
|
-
reconnectTimer = browser.setTimeout(() => {
|
|
11296
|
-
reconnectTimer = undefined;
|
|
11297
|
-
connect();
|
|
11298
|
-
}, delay);
|
|
11496
|
+
authorized = !sync;
|
|
11497
|
+
retry();
|
|
11299
11498
|
});
|
|
11300
11499
|
connection.addEventListener("error", () => connection.close());
|
|
11301
11500
|
};
|
|
11302
11501
|
const suspend = () => {
|
|
11303
11502
|
suspended = true;
|
|
11503
|
+
authenticating?.abort();
|
|
11504
|
+
authenticating = undefined;
|
|
11505
|
+
authorized = !sync;
|
|
11304
11506
|
if (reconnectTimer !== undefined) {
|
|
11305
11507
|
browser.clearTimeout(reconnectTimer);
|
|
11306
11508
|
reconnectTimer = undefined;
|
|
@@ -11311,16 +11513,32 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11311
11513
|
eventSource = undefined;
|
|
11312
11514
|
};
|
|
11313
11515
|
const resume = () => {
|
|
11516
|
+
if (authPaused) {
|
|
11517
|
+
return;
|
|
11518
|
+
}
|
|
11314
11519
|
suspended = false;
|
|
11315
11520
|
if (socket === undefined && eventSource === undefined) {
|
|
11316
11521
|
updateStatus("connecting");
|
|
11317
11522
|
}
|
|
11318
11523
|
connect();
|
|
11319
11524
|
};
|
|
11525
|
+
const setSyncAuthentication = (valid) => {
|
|
11526
|
+
if (valid) {
|
|
11527
|
+
if (authPaused) {
|
|
11528
|
+
authPaused = false;
|
|
11529
|
+
resume();
|
|
11530
|
+
}
|
|
11531
|
+
} else if (!authPaused) {
|
|
11532
|
+
authPaused = true;
|
|
11533
|
+
suspend();
|
|
11534
|
+
updateStatus("unauthorized");
|
|
11535
|
+
}
|
|
11536
|
+
};
|
|
11320
11537
|
browser.addEventListener("pagehide", suspend);
|
|
11321
11538
|
browser.addEventListener("pageshow", resume);
|
|
11322
11539
|
connect();
|
|
11323
11540
|
runtimeWindow[runtimeKey] = {
|
|
11541
|
+
setSyncAuthentication,
|
|
11324
11542
|
subscribe(channel, listener) {
|
|
11325
11543
|
const channelListeners = listeners[channel];
|
|
11326
11544
|
channelListeners.add(listener);
|
|
@@ -11336,133 +11554,73 @@ function installBrowserEventsRuntime(browser, moduleUrlValue, transport) {
|
|
|
11336
11554
|
}
|
|
11337
11555
|
};
|
|
11338
11556
|
}
|
|
11339
|
-
function browserEventsClientSource() {
|
|
11340
|
-
return `(${installBrowserEventsRuntime.toString()})(window, import.meta.url);
|
|
11557
|
+
function browserEventsClientSource(sync) {
|
|
11558
|
+
return `(${installBrowserEventsRuntime.toString()})(window, import.meta.url, undefined, ${sync === true});
|
|
11341
11559
|
`;
|
|
11342
11560
|
}
|
|
11343
11561
|
function browserEventsSseClientSource() {
|
|
11344
|
-
return `(${installBrowserEventsRuntime.toString()})(window, import.meta.url, "sse");
|
|
11562
|
+
return `(${installBrowserEventsRuntime.toString()})(window, import.meta.url, "sse", true);
|
|
11345
11563
|
`;
|
|
11346
11564
|
}
|
|
11347
11565
|
|
|
11348
11566
|
// src/shared/browser-events.ts
|
|
11349
11567
|
var BROWSER_EVENT_PROTOCOL_VERSION = 1;
|
|
11350
11568
|
|
|
11351
|
-
// src/server/sync/
|
|
11352
|
-
function
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
if (principalSecrets.get(adapter) !== secret) {
|
|
11358
|
-
throw new Error("[furin] Sync runtimes sharing a SyncAdapter must use the same secret.");
|
|
11359
|
-
}
|
|
11569
|
+
// src/server/sync/connection.ts
|
|
11570
|
+
async function verifiedSyncPrincipal(sync, context) {
|
|
11571
|
+
try {
|
|
11572
|
+
const principal = await sync.principal(context);
|
|
11573
|
+
return principal.length > 0 ? principal : undefined;
|
|
11574
|
+
} catch {
|
|
11360
11575
|
return;
|
|
11361
11576
|
}
|
|
11362
|
-
principalSecrets.set(adapter, secret);
|
|
11363
|
-
if (secret === undefined && !development) {
|
|
11364
|
-
console.warn("[furin] sync.secret is not set: principal hashes sent to browsers and stored in the sync journal are unkeyed SHA-256 and can be reversed with a dictionary. Set sync.secret to a random value of at least 32 characters.");
|
|
11365
|
-
}
|
|
11366
|
-
}
|
|
11367
|
-
function principalHash(adapter, principal) {
|
|
11368
|
-
const secret = principalSecrets.get(adapter);
|
|
11369
|
-
const hasher = secret === undefined ? new Bun.CryptoHasher("sha256") : new Bun.CryptoHasher("sha256", secret);
|
|
11370
|
-
return hasher.update(principal).digest("hex");
|
|
11371
11577
|
}
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
return page;
|
|
11378
|
-
}
|
|
11578
|
+
function releaseLease(lease) {
|
|
11579
|
+
try {
|
|
11580
|
+
lease?.release();
|
|
11581
|
+
} catch (error) {
|
|
11582
|
+
_log.warn({ action: "sync_connection_release_failed", error: String(error) });
|
|
11379
11583
|
}
|
|
11380
|
-
const cursor = await adapter.currentCursor();
|
|
11381
|
-
return {
|
|
11382
|
-
changes: [],
|
|
11383
|
-
cursor,
|
|
11384
|
-
hasMore: false,
|
|
11385
|
-
reset: input.after !== undefined && input.after !== cursor
|
|
11386
|
-
};
|
|
11387
|
-
}
|
|
11388
|
-
var MIN_SECRET_LENGTH = 32, principalJournals, changePrincipals, principalSecrets;
|
|
11389
|
-
var init_principal_journal = __esm(() => {
|
|
11390
|
-
principalJournals = new WeakSet;
|
|
11391
|
-
changePrincipals = new WeakMap;
|
|
11392
|
-
principalSecrets = new WeakMap;
|
|
11393
|
-
});
|
|
11394
|
-
|
|
11395
|
-
// src/server/sync/queries.ts
|
|
11396
|
-
function isMutationMethod(method) {
|
|
11397
|
-
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS";
|
|
11398
|
-
}
|
|
11399
|
-
function markInternalRead(request) {
|
|
11400
|
-
internalReads.add(request);
|
|
11401
11584
|
}
|
|
11402
|
-
function
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11407
|
-
|
|
11408
|
-
function requestInvalidate(request) {
|
|
11409
|
-
return (target, params) => {
|
|
11410
|
-
if (!isMutationMethod(request.method)) {
|
|
11411
|
-
throw new Error(`[furin] invalidate() was called while handling a ${request.method}: only a mutation invalidates.`);
|
|
11412
|
-
}
|
|
11413
|
-
if (sealed.has(request)) {
|
|
11414
|
-
if (IS_DEV) {
|
|
11415
|
-
throw new Error("[furin] invalidate() was called after mutation() resolved: call it inside the mutation() callback to commit it with the transaction.");
|
|
11416
|
-
}
|
|
11417
|
-
return;
|
|
11418
|
-
}
|
|
11419
|
-
let invalidations = collected.get(request);
|
|
11420
|
-
if (!invalidations) {
|
|
11421
|
-
invalidations = { queries: [], rules: [] };
|
|
11422
|
-
collected.set(request, invalidations);
|
|
11423
|
-
}
|
|
11424
|
-
if (typeof target !== "string") {
|
|
11425
|
-
invalidations.rules.push(target);
|
|
11426
|
-
return;
|
|
11585
|
+
function createSyncConnectionLifetime(sync, context, changed) {
|
|
11586
|
+
let closed = false;
|
|
11587
|
+
let lease;
|
|
11588
|
+
const onAbort = () => {
|
|
11589
|
+
if (!closed) {
|
|
11590
|
+
changed();
|
|
11427
11591
|
}
|
|
11428
|
-
const identity = { id: target, scope: params ?? {} };
|
|
11429
|
-
queryTag(identity);
|
|
11430
|
-
invalidations.queries.push(identity);
|
|
11431
11592
|
};
|
|
11432
|
-
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
11436
|
-
}
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
11440
|
-
|
|
11441
|
-
|
|
11442
|
-
|
|
11443
|
-
}
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
return;
|
|
11447
|
-
}
|
|
11448
|
-
const queries = [];
|
|
11449
|
-
for (const rule of Array.isArray(input) ? input : [input]) {
|
|
11450
|
-
for (const tag of rule.tags ?? []) {
|
|
11451
|
-
const identity = queryFromTag(tag);
|
|
11452
|
-
if (identity) {
|
|
11453
|
-
queries.push(identity);
|
|
11593
|
+
return {
|
|
11594
|
+
async acquire() {
|
|
11595
|
+
if (closed) {
|
|
11596
|
+
return;
|
|
11597
|
+
}
|
|
11598
|
+
const acquired = await sync.connection?.(context);
|
|
11599
|
+
if (closed) {
|
|
11600
|
+
releaseLease(acquired);
|
|
11601
|
+
return;
|
|
11602
|
+
}
|
|
11603
|
+
lease = acquired;
|
|
11604
|
+
lease?.signal.addEventListener("abort", onAbort, { once: true });
|
|
11605
|
+
if (lease?.signal.aborted) {
|
|
11606
|
+
onAbort();
|
|
11454
11607
|
}
|
|
11608
|
+
},
|
|
11609
|
+
close() {
|
|
11610
|
+
if (closed) {
|
|
11611
|
+
return;
|
|
11612
|
+
}
|
|
11613
|
+
closed = true;
|
|
11614
|
+
lease?.signal.removeEventListener("abort", onAbort);
|
|
11615
|
+
releaseLease(lease);
|
|
11616
|
+
lease = undefined;
|
|
11455
11617
|
}
|
|
11456
|
-
}
|
|
11457
|
-
if (queries.length > 0) {
|
|
11458
|
-
context.set.headers["x-furin-queries"] = serializeQueryHeader(queries);
|
|
11459
|
-
}
|
|
11618
|
+
};
|
|
11460
11619
|
}
|
|
11461
|
-
var
|
|
11462
|
-
var
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
internalReads = new WeakSet;
|
|
11620
|
+
var LOCAL_SYNC_CONNECTION;
|
|
11621
|
+
var init_connection = __esm(() => {
|
|
11622
|
+
init_dist();
|
|
11623
|
+
LOCAL_SYNC_CONNECTION = Symbol.for("furin.sync.local-connection.v1");
|
|
11466
11624
|
});
|
|
11467
11625
|
|
|
11468
11626
|
// src/server/sync/notifier.ts
|
|
@@ -11557,7 +11715,52 @@ class PollingSyncNotifier {
|
|
|
11557
11715
|
}
|
|
11558
11716
|
}
|
|
11559
11717
|
|
|
11718
|
+
// src/server/sync/principal-journal.ts
|
|
11719
|
+
function configurePrincipalSecret(adapter, secret, development) {
|
|
11720
|
+
if (secret !== undefined && (typeof secret !== "string" || secret.length < MIN_SECRET_LENGTH)) {
|
|
11721
|
+
throw new Error(`[furin] sync.secret must be a string of at least ${MIN_SECRET_LENGTH} characters.`);
|
|
11722
|
+
}
|
|
11723
|
+
if (principalSecrets.has(adapter)) {
|
|
11724
|
+
if (principalSecrets.get(adapter) !== secret) {
|
|
11725
|
+
throw new Error("[furin] Sync runtimes sharing a SyncAdapter must use the same secret.");
|
|
11726
|
+
}
|
|
11727
|
+
return;
|
|
11728
|
+
}
|
|
11729
|
+
principalSecrets.set(adapter, secret);
|
|
11730
|
+
if (secret === undefined && !development) {
|
|
11731
|
+
console.warn("[furin] sync.secret is not set: principal hashes sent to browsers and stored in the sync journal are unkeyed SHA-256 and can be reversed with a dictionary. Set sync.secret to a random value of at least 32 characters.");
|
|
11732
|
+
}
|
|
11733
|
+
}
|
|
11734
|
+
function principalHash(adapter, principal) {
|
|
11735
|
+
const secret = principalSecrets.get(adapter);
|
|
11736
|
+
const hasher = secret === undefined ? new Bun.CryptoHasher("sha256") : new Bun.CryptoHasher("sha256", secret);
|
|
11737
|
+
return hasher.update(principal).digest("hex");
|
|
11738
|
+
}
|
|
11739
|
+
async function readPrincipalChanges(adapter, input, principal) {
|
|
11740
|
+
if (principalJournals.has(adapter)) {
|
|
11741
|
+
const page = await adapter.readChanges(input);
|
|
11742
|
+
const hash = principalHash(adapter, principal);
|
|
11743
|
+
if (page.changes.every((change) => changePrincipals.get(change) === hash)) {
|
|
11744
|
+
return page;
|
|
11745
|
+
}
|
|
11746
|
+
}
|
|
11747
|
+
const cursor = await adapter.currentCursor();
|
|
11748
|
+
return {
|
|
11749
|
+
changes: [],
|
|
11750
|
+
cursor,
|
|
11751
|
+
hasMore: false,
|
|
11752
|
+
reset: input.after !== undefined && input.after !== cursor
|
|
11753
|
+
};
|
|
11754
|
+
}
|
|
11755
|
+
var MIN_SECRET_LENGTH = 32, principalJournals, changePrincipals, principalSecrets;
|
|
11756
|
+
var init_principal_journal = __esm(() => {
|
|
11757
|
+
principalJournals = new WeakSet;
|
|
11758
|
+
changePrincipals = new WeakMap;
|
|
11759
|
+
principalSecrets = new WeakMap;
|
|
11760
|
+
});
|
|
11761
|
+
|
|
11560
11762
|
// src/server/sync/runtime.ts
|
|
11763
|
+
import { inAotBuild } from "elysia";
|
|
11561
11764
|
function publishCursor(runtime, cursor) {
|
|
11562
11765
|
const alreadyPublished = runtime.adapter.publishesNotifications !== false && runtime.adapter.notificationChannel !== undefined && runtime.adapter.notificationChannel === runtime.notifier.notificationChannel;
|
|
11563
11766
|
if (!alreadyPublished) {
|
|
@@ -11566,32 +11769,135 @@ function publishCursor(runtime, cursor) {
|
|
|
11566
11769
|
});
|
|
11567
11770
|
}
|
|
11568
11771
|
}
|
|
11569
|
-
function
|
|
11570
|
-
if (
|
|
11571
|
-
|
|
11772
|
+
function prepareSyncRuntime(options, development) {
|
|
11773
|
+
if (inAotBuild()) {
|
|
11774
|
+
return;
|
|
11775
|
+
}
|
|
11776
|
+
if (typeof options.adapter === "function" && !factoryAdapters.has(options)) {
|
|
11777
|
+
const adapter = options.adapter();
|
|
11778
|
+
if (adapter instanceof Promise) {
|
|
11779
|
+
throw new Error("[furin] Sync adapter factories must return an adapter synchronously.");
|
|
11780
|
+
}
|
|
11781
|
+
factoryAdapters.set(options, adapter);
|
|
11782
|
+
}
|
|
11783
|
+
resolveSyncRuntime(options, development);
|
|
11784
|
+
}
|
|
11785
|
+
function resolveSyncRuntime(options, development) {
|
|
11786
|
+
if (inAotBuild()) {
|
|
11787
|
+
throw new Error("[furin] Sync runtime is unavailable during AOT compilation.");
|
|
11788
|
+
}
|
|
11789
|
+
const existingRuntime = runtimes.get(options)?.get(development);
|
|
11790
|
+
if (existingRuntime) {
|
|
11791
|
+
return existingRuntime;
|
|
11792
|
+
}
|
|
11793
|
+
const adapter = typeof options.adapter === "function" ? factoryAdapters.get(options) : options.adapter;
|
|
11794
|
+
if (!adapter) {
|
|
11795
|
+
throw new Error("[furin] Compose furinSync(sync) or furin({ sync }) before using a Sync adapter factory.");
|
|
11796
|
+
}
|
|
11797
|
+
if (!development && adapter.scope === "process-local") {
|
|
11798
|
+
throw new Error("[furin] Production sync cannot use a process-local SyncAdapter.");
|
|
11799
|
+
}
|
|
11800
|
+
configurePrincipalSecret(adapter, options.secret, development);
|
|
11801
|
+
if (options.notifier && adapter.notificationChannel !== undefined && options.notifier.notificationChannel !== undefined && adapter.notificationChannel !== options.notifier.notificationChannel) {
|
|
11802
|
+
throw new Error("[furin] SyncAdapter and SyncNotifier notification channels do not match.");
|
|
11803
|
+
}
|
|
11804
|
+
if (!(options.notifier || development) && adapter.scope === "distributed") {
|
|
11805
|
+
throw new Error("[furin] Distributed production sync requires an explicit SyncNotifier. Configure the adapter notifier or pass PollingSyncNotifier as a compatibility fallback.");
|
|
11806
|
+
}
|
|
11807
|
+
let notifier = options.notifier ?? pollingNotifiers.get(adapter);
|
|
11808
|
+
if (!notifier) {
|
|
11809
|
+
const polling = new PollingSyncNotifier(adapter, POLL_INTERVAL_MS);
|
|
11810
|
+
pollingNotifiers.set(adapter, polling);
|
|
11811
|
+
notifier = polling;
|
|
11812
|
+
}
|
|
11813
|
+
const runtime = { adapter, development, notifier };
|
|
11814
|
+
let modes = runtimes.get(options);
|
|
11815
|
+
if (!modes) {
|
|
11816
|
+
modes = new Map;
|
|
11817
|
+
runtimes.set(options, modes);
|
|
11818
|
+
}
|
|
11819
|
+
modes.set(development, runtime);
|
|
11820
|
+
return runtime;
|
|
11821
|
+
}
|
|
11822
|
+
var POLL_INTERVAL_MS = 250, pollingNotifiers, factoryAdapters, runtimes;
|
|
11823
|
+
var init_runtime = __esm(() => {
|
|
11824
|
+
init_principal_journal();
|
|
11825
|
+
pollingNotifiers = new WeakMap;
|
|
11826
|
+
factoryAdapters = new WeakMap;
|
|
11827
|
+
runtimes = new WeakMap;
|
|
11828
|
+
});
|
|
11829
|
+
|
|
11830
|
+
// src/server/sync/queries.ts
|
|
11831
|
+
function isMutationMethod(method) {
|
|
11832
|
+
return method !== "GET" && method !== "HEAD" && method !== "OPTIONS";
|
|
11833
|
+
}
|
|
11834
|
+
function markInternalRead(request) {
|
|
11835
|
+
internalReads.add(request);
|
|
11836
|
+
}
|
|
11837
|
+
function isInternalRead(request) {
|
|
11838
|
+
return internalReads.has(request);
|
|
11839
|
+
}
|
|
11840
|
+
function sealInvalidations(request) {
|
|
11841
|
+
sealed.add(request);
|
|
11842
|
+
}
|
|
11843
|
+
function requestInvalidate(request) {
|
|
11844
|
+
return (target, params) => {
|
|
11845
|
+
if (!isMutationMethod(request.method)) {
|
|
11846
|
+
throw new Error(`[furin] invalidate() was called while handling a ${request.method}: only a mutation invalidates.`);
|
|
11847
|
+
}
|
|
11848
|
+
if (sealed.has(request)) {
|
|
11849
|
+
if (IS_DEV) {
|
|
11850
|
+
throw new Error("[furin] invalidate() was called after mutation() resolved: call it inside the mutation() callback to commit it with the transaction.");
|
|
11851
|
+
}
|
|
11852
|
+
return;
|
|
11853
|
+
}
|
|
11854
|
+
let invalidations = collected.get(request);
|
|
11855
|
+
if (!invalidations) {
|
|
11856
|
+
invalidations = { queries: [], rules: [] };
|
|
11857
|
+
collected.set(request, invalidations);
|
|
11858
|
+
}
|
|
11859
|
+
if (typeof target !== "string") {
|
|
11860
|
+
invalidations.rules.push(target);
|
|
11861
|
+
return;
|
|
11862
|
+
}
|
|
11863
|
+
const identity = { id: target, scope: params ?? {} };
|
|
11864
|
+
queryTag(identity);
|
|
11865
|
+
invalidations.queries.push(identity);
|
|
11866
|
+
};
|
|
11867
|
+
}
|
|
11868
|
+
function urlIdentity(context) {
|
|
11869
|
+
const scope = Object.fromEntries(Object.entries(context.params ?? {}).filter(([, value]) => value !== undefined));
|
|
11870
|
+
return { id: context.route ?? context.path, scope };
|
|
11871
|
+
}
|
|
11872
|
+
function resolveSyncInvalidations(context) {
|
|
11873
|
+
const invalidations = collected.get(context.request);
|
|
11874
|
+
return [
|
|
11875
|
+
...invalidations?.rules ?? [],
|
|
11876
|
+
{ tags: [...invalidations?.queries ?? [], urlIdentity(context)].map(queryTag) }
|
|
11877
|
+
];
|
|
11878
|
+
}
|
|
11879
|
+
function appendQueryInvalidations(input, context) {
|
|
11880
|
+
if (input === undefined) {
|
|
11881
|
+
return;
|
|
11572
11882
|
}
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11883
|
+
const queries = [];
|
|
11884
|
+
for (const rule of Array.isArray(input) ? input : [input]) {
|
|
11885
|
+
for (const tag of rule.tags ?? []) {
|
|
11886
|
+
const identity = queryFromTag(tag);
|
|
11887
|
+
if (identity) {
|
|
11888
|
+
queries.push(identity);
|
|
11889
|
+
}
|
|
11577
11890
|
}
|
|
11578
|
-
return { adapter: options.adapter, development, notifier: options.notifier };
|
|
11579
11891
|
}
|
|
11580
|
-
if (
|
|
11581
|
-
|
|
11582
|
-
}
|
|
11583
|
-
const existing = pollingNotifiers.get(options.adapter);
|
|
11584
|
-
if (existing) {
|
|
11585
|
-
return { adapter: options.adapter, development, notifier: existing };
|
|
11892
|
+
if (queries.length > 0) {
|
|
11893
|
+
context.set.headers["x-furin-queries"] = serializeQueryHeader(queries);
|
|
11586
11894
|
}
|
|
11587
|
-
const notifier = new PollingSyncNotifier(options.adapter, POLL_INTERVAL_MS);
|
|
11588
|
-
pollingNotifiers.set(options.adapter, notifier);
|
|
11589
|
-
return { adapter: options.adapter, development, notifier };
|
|
11590
11895
|
}
|
|
11591
|
-
var
|
|
11592
|
-
var
|
|
11593
|
-
|
|
11594
|
-
|
|
11896
|
+
var collected, sealed, internalReads;
|
|
11897
|
+
var init_queries = __esm(() => {
|
|
11898
|
+
collected = new WeakMap;
|
|
11899
|
+
sealed = new WeakSet;
|
|
11900
|
+
internalReads = new WeakSet;
|
|
11595
11901
|
});
|
|
11596
11902
|
|
|
11597
11903
|
// src/server/sync/stream.ts
|
|
@@ -11724,8 +12030,9 @@ function createSyncChangesPlugin(options) {
|
|
|
11724
12030
|
}
|
|
11725
12031
|
function createRuntimeSyncChangesPlugin(options, development) {
|
|
11726
12032
|
const syncPath = options.path ?? defaultSyncPath;
|
|
11727
|
-
|
|
12033
|
+
prepareSyncRuntime(options, development);
|
|
11728
12034
|
return new Elysia7({ name: `furin-sync-changes-${syncPath}` }).get(`${syncPath}/changes`, async (context) => {
|
|
12035
|
+
const runtime = resolveSyncRuntime(options, development);
|
|
11729
12036
|
const { request, set } = context;
|
|
11730
12037
|
markInternalRead(request);
|
|
11731
12038
|
set.headers["cache-control"] = "no-store";
|
|
@@ -11733,16 +12040,23 @@ function createRuntimeSyncChangesPlugin(options, development) {
|
|
|
11733
12040
|
if ("error" in query) {
|
|
11734
12041
|
return query.error;
|
|
11735
12042
|
}
|
|
11736
|
-
const principal = await options
|
|
11737
|
-
if (principal
|
|
12043
|
+
const principal = await verifiedSyncPrincipal(options, context);
|
|
12044
|
+
if (principal === undefined) {
|
|
11738
12045
|
return new Response("Unauthorized", { status: 401 });
|
|
11739
12046
|
}
|
|
12047
|
+
set.headers["x-furin-sync-session"] = principalHash(runtime.adapter, principal);
|
|
12048
|
+
const connect = request[LOCAL_SYNC_CONNECTION];
|
|
12049
|
+
if (connect) {
|
|
12050
|
+
await connect(context, options);
|
|
12051
|
+
return new Response(null, { status: 204 });
|
|
12052
|
+
}
|
|
11740
12053
|
return readPrincipalChanges(runtime.adapter, query, principal);
|
|
11741
12054
|
});
|
|
11742
12055
|
}
|
|
11743
12056
|
var BROADCAST_WINDOW_MS = 100, DEFAULT_CHANGE_LIMIT = 100, MAX_CHANGE_LIMIT = 500, MAX_CURSOR_LENGTH = 128, DEVELOPMENT_SAFETY_POLL_INTERVAL_MS = 250, PRODUCTION_SAFETY_POLL_INTERVAL_MS = 15000, UNSIGNED_INTEGER_PATTERN, defaultSyncPath = "/_furin/sync", noOpSubscription, cursorStates, resolvedStates, pendingUnsubscriptions, unsubscriptions;
|
|
11744
12057
|
var init_stream = __esm(() => {
|
|
11745
12058
|
init_config();
|
|
12059
|
+
init_connection();
|
|
11746
12060
|
init_principal_journal();
|
|
11747
12061
|
init_queries();
|
|
11748
12062
|
init_runtime();
|
|
@@ -11817,12 +12131,6 @@ function createConnectionCapacity() {
|
|
|
11817
12131
|
}
|
|
11818
12132
|
};
|
|
11819
12133
|
}
|
|
11820
|
-
async function verifiedPrincipal(sync, context) {
|
|
11821
|
-
try {
|
|
11822
|
-
const principal = await sync.principal(context);
|
|
11823
|
-
return principal.length > 0 ? principal : undefined;
|
|
11824
|
-
} catch {}
|
|
11825
|
-
}
|
|
11826
12134
|
function peerAddressKey(request, server) {
|
|
11827
12135
|
return `address:${server?.requestIP(request)?.address ?? "unknown"}`;
|
|
11828
12136
|
}
|
|
@@ -11856,30 +12164,44 @@ function createBrowserEventsPlugin(options) {
|
|
|
11856
12164
|
const capacity = createConnectionCapacity();
|
|
11857
12165
|
const peers = new WeakMap;
|
|
11858
12166
|
const { development, sources = [], sync } = options;
|
|
12167
|
+
if (sync) {
|
|
12168
|
+
prepareSyncRuntime(sync, development);
|
|
12169
|
+
}
|
|
12170
|
+
const clientSource = browserEventsClientSource(sync !== undefined);
|
|
12171
|
+
const authenticate = async (context) => {
|
|
12172
|
+
const forbidden = forbiddenBrowserRequest(context.request, context.server, development);
|
|
12173
|
+
if (forbidden) {
|
|
12174
|
+
return forbidden;
|
|
12175
|
+
}
|
|
12176
|
+
return new Response(null, {
|
|
12177
|
+
status: !sync || sources.length > 0 || await verifiedSyncPrincipal(sync, context) !== undefined ? 200 : 401,
|
|
12178
|
+
headers: { "cache-control": "no-store" }
|
|
12179
|
+
});
|
|
12180
|
+
};
|
|
11859
12181
|
return new Elysia8({ name: "furin-browser-events" }).use(websocket()).get(CLIENT_PATH2, ({ request, server }) => {
|
|
11860
12182
|
const forbidden = forbiddenBrowserRequest(request, server, development);
|
|
11861
12183
|
if (forbidden) {
|
|
11862
12184
|
return forbidden;
|
|
11863
12185
|
}
|
|
11864
|
-
return new Response(
|
|
12186
|
+
return new Response(clientSource, {
|
|
11865
12187
|
headers: {
|
|
11866
12188
|
"cache-control": "no-store",
|
|
11867
12189
|
"content-type": "text/javascript; charset=utf-8",
|
|
11868
12190
|
"x-content-type-options": "nosniff"
|
|
11869
12191
|
}
|
|
11870
12192
|
});
|
|
11871
|
-
}).ws(SOCKET_PATH, {
|
|
12193
|
+
}).head(SOCKET_PATH, (context) => authenticate(context)).ws(SOCKET_PATH, {
|
|
11872
12194
|
async beforeHandle(context) {
|
|
11873
12195
|
const { request, server } = context;
|
|
11874
12196
|
const forbidden = forbiddenBrowserRequest(request, server, development);
|
|
11875
12197
|
if (forbidden) {
|
|
11876
12198
|
return forbidden;
|
|
11877
12199
|
}
|
|
11878
|
-
const principal = sync && await
|
|
12200
|
+
const principal = sync && await verifiedSyncPrincipal(sync, context);
|
|
11879
12201
|
if (sync && principal === undefined && sources.length === 0) {
|
|
11880
12202
|
return new Response("Unauthorized", { status: 401 });
|
|
11881
12203
|
}
|
|
11882
|
-
const peer = principal ? { key: `principal:${principal}`, sync: true } : { key: peerAddressKey(request, server), sync: false };
|
|
12204
|
+
const peer = principal ? { key: `principal:${principal}`, sync: true, context } : { key: peerAddressKey(request, server), sync: false };
|
|
11883
12205
|
if (capacity.full(peer.key)) {
|
|
11884
12206
|
return Response.json({ code: "FURIN_BROWSER_EVENTS_CAPACITY" }, { status: 503 });
|
|
11885
12207
|
}
|
|
@@ -11931,6 +12253,21 @@ function createBrowserEventsPlugin(options) {
|
|
|
11931
12253
|
};
|
|
11932
12254
|
try {
|
|
11933
12255
|
if (sync !== undefined && peer.sync) {
|
|
12256
|
+
const access = createSyncConnectionLifetime(sync, peer.context, () => {
|
|
12257
|
+
send({
|
|
12258
|
+
channel: "sync",
|
|
12259
|
+
data: { context: "changed" },
|
|
12260
|
+
version: BROWSER_EVENT_PROTOCOL_VERSION
|
|
12261
|
+
});
|
|
12262
|
+
releaseConnection(state);
|
|
12263
|
+
connections.delete(ws.id);
|
|
12264
|
+
ws.close(4410, "Sync context changed");
|
|
12265
|
+
});
|
|
12266
|
+
keep({ unsubscribe: access.close });
|
|
12267
|
+
await access.acquire();
|
|
12268
|
+
if (state.closed) {
|
|
12269
|
+
return;
|
|
12270
|
+
}
|
|
11934
12271
|
const subscription = await subscribeSyncCursor(sync, development, (cursor) => send({
|
|
11935
12272
|
channel: "sync",
|
|
11936
12273
|
data: { cursor },
|
|
@@ -11962,8 +12299,18 @@ function createSseBrowserEventsPlugin({
|
|
|
11962
12299
|
development,
|
|
11963
12300
|
sync
|
|
11964
12301
|
}) {
|
|
12302
|
+
prepareSyncRuntime(sync, development);
|
|
11965
12303
|
const capacity = createConnectionCapacity();
|
|
11966
|
-
return new Elysia8({ name: "furin-browser-events-sse" }).
|
|
12304
|
+
return new Elysia8({ name: "furin-browser-events-sse" }).head(SOCKET_PATH, async (context) => {
|
|
12305
|
+
const forbidden = forbiddenBrowserRequest(context.request, context.server, development);
|
|
12306
|
+
if (forbidden) {
|
|
12307
|
+
return forbidden;
|
|
12308
|
+
}
|
|
12309
|
+
return new Response(null, {
|
|
12310
|
+
status: await verifiedSyncPrincipal(sync, context) === undefined ? 401 : 200,
|
|
12311
|
+
headers: { "cache-control": "no-store" }
|
|
12312
|
+
});
|
|
12313
|
+
}).get(CLIENT_PATH2, ({ request, server }) => {
|
|
11967
12314
|
const forbidden = forbiddenBrowserRequest(request, server, development);
|
|
11968
12315
|
if (forbidden) {
|
|
11969
12316
|
return forbidden;
|
|
@@ -11981,7 +12328,7 @@ function createSseBrowserEventsPlugin({
|
|
|
11981
12328
|
if (forbidden) {
|
|
11982
12329
|
return forbidden;
|
|
11983
12330
|
}
|
|
11984
|
-
const principal = await
|
|
12331
|
+
const principal = await verifiedSyncPrincipal(sync, context);
|
|
11985
12332
|
if (principal === undefined) {
|
|
11986
12333
|
return new Response("Unauthorized", { status: 401 });
|
|
11987
12334
|
}
|
|
@@ -12007,6 +12354,7 @@ function createSseBrowserEventsPlugin({
|
|
|
12007
12354
|
let closed = false;
|
|
12008
12355
|
let subscription;
|
|
12009
12356
|
let lifetime;
|
|
12357
|
+
let access;
|
|
12010
12358
|
const send = (event) => {
|
|
12011
12359
|
if (!closed) {
|
|
12012
12360
|
controller.enqueue(SSE_ENCODER.encode(`data: ${serialized(event)}
|
|
@@ -12041,6 +12389,7 @@ function createSseBrowserEventsPlugin({
|
|
|
12041
12389
|
clearTimeout(lifetime);
|
|
12042
12390
|
}
|
|
12043
12391
|
request.signal.removeEventListener("abort", onAbort);
|
|
12392
|
+
access?.close();
|
|
12044
12393
|
subscription?.unsubscribe();
|
|
12045
12394
|
releaseCapacity();
|
|
12046
12395
|
};
|
|
@@ -12054,7 +12403,22 @@ function createSseBrowserEventsPlugin({
|
|
|
12054
12403
|
controller.enqueue(SSE_ENCODER.encode(`: connected
|
|
12055
12404
|
|
|
12056
12405
|
`));
|
|
12057
|
-
|
|
12406
|
+
access = createSyncConnectionLifetime(sync, context, () => {
|
|
12407
|
+
send({
|
|
12408
|
+
channel: "sync",
|
|
12409
|
+
data: { context: "changed" },
|
|
12410
|
+
version: BROWSER_EVENT_PROTOCOL_VERSION
|
|
12411
|
+
});
|
|
12412
|
+
finish();
|
|
12413
|
+
});
|
|
12414
|
+
access.acquire().then(() => closed ? undefined : subscribeSyncCursor(sync, development, (cursor) => send({
|
|
12415
|
+
channel: "sync",
|
|
12416
|
+
data: { cursor },
|
|
12417
|
+
version: BROWSER_EVENT_PROTOCOL_VERSION
|
|
12418
|
+
}))).then((next) => {
|
|
12419
|
+
if (!next) {
|
|
12420
|
+
return;
|
|
12421
|
+
}
|
|
12058
12422
|
if (closed) {
|
|
12059
12423
|
next.unsubscribe();
|
|
12060
12424
|
} else {
|
|
@@ -12083,11 +12447,12 @@ function injectBrowserEventsClient(html, basePath) {
|
|
|
12083
12447
|
}
|
|
12084
12448
|
return html.includes("</head>") ? html.replace("</head>", `${script}</head>`) : `${script}${html}`;
|
|
12085
12449
|
}
|
|
12086
|
-
var CLIENT_PATH2 = "/_furin/events/client.js", SOCKET_PATH = "/_furin/events", HEARTBEAT_INTERVAL_MS = 30000, SSE_CONNECTION_LIFETIME_MS = 60000, MAX_BROWSER_EVENT_CONNECTIONS = 100, MAX_BROWSER_EVENT_CONNECTIONS_PER_PEER = 10,
|
|
12450
|
+
var CLIENT_PATH2 = "/_furin/events/client.js", SOCKET_PATH = "/_furin/events", HEARTBEAT_INTERVAL_MS = 30000, SSE_CONNECTION_LIFETIME_MS = 60000, MAX_BROWSER_EVENT_CONNECTIONS = 100, MAX_BROWSER_EVENT_CONNECTIONS_PER_PEER = 10, SSE_CLIENT_SOURCE, SSE_ENCODER;
|
|
12087
12451
|
var init_plugin2 = __esm(() => {
|
|
12452
|
+
init_connection();
|
|
12453
|
+
init_runtime();
|
|
12088
12454
|
init_stream();
|
|
12089
12455
|
init_shutdown();
|
|
12090
|
-
CLIENT_SOURCE = browserEventsClientSource();
|
|
12091
12456
|
SSE_CLIENT_SOURCE = browserEventsSseClientSource();
|
|
12092
12457
|
SSE_ENCODER = new TextEncoder;
|
|
12093
12458
|
});
|
|
@@ -12592,7 +12957,7 @@ function parseGeneratedFrames(stack) {
|
|
|
12592
12957
|
const frames = [];
|
|
12593
12958
|
for (const line of stack.split(`
|
|
12594
12959
|
`)) {
|
|
12595
|
-
const match = STACK_FRAME_RE.exec(line);
|
|
12960
|
+
const match = STACK_FRAME_RE.exec(line) ?? WEBKIT_FRAME_RE.exec(line);
|
|
12596
12961
|
if (!(match?.[2] && match[3] && match[4])) {
|
|
12597
12962
|
continue;
|
|
12598
12963
|
}
|
|
@@ -12683,11 +13048,12 @@ async function symbolicateStack(input) {
|
|
|
12683
13048
|
location: applicationFrame?.original ?? applicationFrame?.generated
|
|
12684
13049
|
};
|
|
12685
13050
|
}
|
|
12686
|
-
var STACK_FRAME_RE, SOURCE_MAP_RE, BUN_ROOT_CHUNK_RE, SOURCE_MAP_CACHE_LIMIT = 100, sourceMaps;
|
|
13051
|
+
var STACK_FRAME_RE, WEBKIT_FRAME_RE, SOURCE_MAP_RE, BUN_ROOT_CHUNK_RE, SOURCE_MAP_CACHE_LIMIT = 100, sourceMaps;
|
|
12687
13052
|
var init_symbolicate = __esm(() => {
|
|
12688
13053
|
init_trace_mapping();
|
|
12689
13054
|
STACK_FRAME_RE = /^\s*at\s+(?:(.*?)\s+\()?((?:https?:\/\/|file:\/\/|bun:\/\/).+):(\d+):(\d+)\)?$/;
|
|
12690
|
-
|
|
13055
|
+
WEBKIT_FRAME_RE = /^(.*?)@((?:https?:\/\/|file:\/\/|bun:\/\/).+):(\d+):(\d+)$/;
|
|
13056
|
+
SOURCE_MAP_RE = /^\s*\/\/[#@]\s*sourceMappingURL=(\S+)\s*$/m;
|
|
12691
13057
|
BUN_ROOT_CHUNK_RE = /^\/chunk-[^/]+\.js$/;
|
|
12692
13058
|
sourceMaps = new Map;
|
|
12693
13059
|
});
|
|
@@ -18417,35 +18783,6 @@ function parseSource(code, lang) {
|
|
|
18417
18783
|
}
|
|
18418
18784
|
var init_parser = () => {};
|
|
18419
18785
|
|
|
18420
|
-
// src/shared/utils/ast-walk.ts
|
|
18421
|
-
function isNode(value) {
|
|
18422
|
-
return "type" in value && typeof value.type === "string";
|
|
18423
|
-
}
|
|
18424
|
-
function walkAST(node, visitor) {
|
|
18425
|
-
if (!node || typeof node !== "object") {
|
|
18426
|
-
return;
|
|
18427
|
-
}
|
|
18428
|
-
if (Array.isArray(node)) {
|
|
18429
|
-
for (const child of node) {
|
|
18430
|
-
walkAST(child, visitor);
|
|
18431
|
-
}
|
|
18432
|
-
return;
|
|
18433
|
-
}
|
|
18434
|
-
if (!isNode(node)) {
|
|
18435
|
-
return;
|
|
18436
|
-
}
|
|
18437
|
-
visitor(node);
|
|
18438
|
-
for (const [key, child] of Object.entries(node)) {
|
|
18439
|
-
if (!SKIP_KEYS.has(key)) {
|
|
18440
|
-
walkAST(child, visitor);
|
|
18441
|
-
}
|
|
18442
|
-
}
|
|
18443
|
-
}
|
|
18444
|
-
var SKIP_KEYS;
|
|
18445
|
-
var init_ast_walk = __esm(() => {
|
|
18446
|
-
SKIP_KEYS = new Set(["type", "start", "end", "comments"]);
|
|
18447
|
-
});
|
|
18448
|
-
|
|
18449
18786
|
// src/plugin/module-transform.ts
|
|
18450
18787
|
function parseModule(code, filename) {
|
|
18451
18788
|
const { diagnostics, program } = parseSource(code, detectLangFromPath(filename));
|
|
@@ -18478,6 +18815,35 @@ var init_module_transform = __esm(() => {
|
|
|
18478
18815
|
init_parser();
|
|
18479
18816
|
});
|
|
18480
18817
|
|
|
18818
|
+
// src/shared/utils/ast-walk.ts
|
|
18819
|
+
function isNode(value) {
|
|
18820
|
+
return "type" in value && typeof value.type === "string";
|
|
18821
|
+
}
|
|
18822
|
+
function walkAST(node, visitor) {
|
|
18823
|
+
if (!node || typeof node !== "object") {
|
|
18824
|
+
return;
|
|
18825
|
+
}
|
|
18826
|
+
if (Array.isArray(node)) {
|
|
18827
|
+
for (const child of node) {
|
|
18828
|
+
walkAST(child, visitor);
|
|
18829
|
+
}
|
|
18830
|
+
return;
|
|
18831
|
+
}
|
|
18832
|
+
if (!isNode(node)) {
|
|
18833
|
+
return;
|
|
18834
|
+
}
|
|
18835
|
+
visitor(node);
|
|
18836
|
+
for (const [key, child] of Object.entries(node)) {
|
|
18837
|
+
if (!SKIP_KEYS.has(key)) {
|
|
18838
|
+
walkAST(child, visitor);
|
|
18839
|
+
}
|
|
18840
|
+
}
|
|
18841
|
+
}
|
|
18842
|
+
var SKIP_KEYS;
|
|
18843
|
+
var init_ast_walk = __esm(() => {
|
|
18844
|
+
SKIP_KEYS = new Set(["type", "start", "end", "comments"]);
|
|
18845
|
+
});
|
|
18846
|
+
|
|
18481
18847
|
// src/plugin/dead-code-elimination.ts
|
|
18482
18848
|
function isTypeAssertion(node) {
|
|
18483
18849
|
return TYPE_ASSERTION_NODES.has(node.type);
|
|
@@ -18791,7 +19157,7 @@ var init_dead_code_elimination = __esm(() => {
|
|
|
18791
19157
|
WALK_SKIPPED_KEYS = new Set(["type", "start", "end"]);
|
|
18792
19158
|
});
|
|
18793
19159
|
|
|
18794
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
19160
|
+
// ../../node_modules/.bun/yuku-ast@0.13.0/node_modules/yuku-ast/dist/aliases.js
|
|
18795
19161
|
var ALIAS_GROUPS, ALIAS_NAMES;
|
|
18796
19162
|
var init_aliases = __esm(() => {
|
|
18797
19163
|
ALIAS_GROUPS = {
|
|
@@ -18950,7 +19316,7 @@ var init_aliases = __esm(() => {
|
|
|
18950
19316
|
ALIAS_NAMES = Object.keys(ALIAS_GROUPS);
|
|
18951
19317
|
});
|
|
18952
19318
|
|
|
18953
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
19319
|
+
// ../../node_modules/.bun/yuku-ast@0.13.0/node_modules/yuku-ast/dist/generated.js
|
|
18954
19320
|
function ck(type, keys) {
|
|
18955
19321
|
const prev = KEYS[type];
|
|
18956
19322
|
if (prev === undefined)
|
|
@@ -19325,7 +19691,7 @@ var init_generated = __esm(() => {
|
|
|
19325
19691
|
NODE_TYPES = [...new Set(TYPES)];
|
|
19326
19692
|
});
|
|
19327
19693
|
|
|
19328
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
19694
|
+
// ../../node_modules/.bun/yuku-ast@0.13.0/node_modules/yuku-ast/dist/context.js
|
|
19329
19695
|
class WalkContext {
|
|
19330
19696
|
_ancestors = [];
|
|
19331
19697
|
_node = null;
|
|
@@ -19393,7 +19759,7 @@ class WalkContext {
|
|
|
19393
19759
|
}
|
|
19394
19760
|
}
|
|
19395
19761
|
|
|
19396
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
19762
|
+
// ../../node_modules/.bun/yuku-ast@0.13.0/node_modules/yuku-ast/dist/walk.js
|
|
19397
19763
|
function createDispatch(visitors) {
|
|
19398
19764
|
let enter = null;
|
|
19399
19765
|
let leave = null;
|
|
@@ -19535,7 +19901,7 @@ var init_walk = __esm(() => {
|
|
|
19535
19901
|
init_generated();
|
|
19536
19902
|
});
|
|
19537
19903
|
|
|
19538
|
-
// ../../node_modules/.bun/yuku-ast@0.
|
|
19904
|
+
// ../../node_modules/.bun/yuku-ast@0.13.0/node_modules/yuku-ast/dist/index.js
|
|
19539
19905
|
var init_dist3 = __esm(() => {
|
|
19540
19906
|
init_walk();
|
|
19541
19907
|
});
|
|
@@ -20740,6 +21106,28 @@ var init_error = __esm(() => {
|
|
|
20740
21106
|
init_stack_location();
|
|
20741
21107
|
});
|
|
20742
21108
|
|
|
21109
|
+
// src/server/dev/server-only-module.ts
|
|
21110
|
+
import { readFileSync as readFileSync5, statSync as statSync3 } from "fs";
|
|
21111
|
+
function isServerOnlyModule(path) {
|
|
21112
|
+
const stats = statSync3(path, { throwIfNoEntry: false });
|
|
21113
|
+
if (!stats) {
|
|
21114
|
+
return false;
|
|
21115
|
+
}
|
|
21116
|
+
const { mtimeMs } = stats;
|
|
21117
|
+
const cached = cache.get(path);
|
|
21118
|
+
if (cached?.mtimeMs === mtimeMs) {
|
|
21119
|
+
return cached.serverOnly;
|
|
21120
|
+
}
|
|
21121
|
+
const serverOnly = SERVER_ONLY_IMPORT.test(readFileSync5(path, "utf8"));
|
|
21122
|
+
cache.set(path, { mtimeMs, serverOnly });
|
|
21123
|
+
return serverOnly;
|
|
21124
|
+
}
|
|
21125
|
+
var SERVER_ONLY_IMPORT, cache;
|
|
21126
|
+
var init_server_only_module = __esm(() => {
|
|
21127
|
+
SERVER_ONLY_IMPORT = /^\s*import\s+["'](?:@teyik0\/)?furin\/server-only["'];?\s*$/m;
|
|
21128
|
+
cache = new Map;
|
|
21129
|
+
});
|
|
21130
|
+
|
|
20743
21131
|
// src/server/dev/rewrite-module-specifiers.ts
|
|
20744
21132
|
import { dirname as dirname6, resolve as resolve7 } from "path";
|
|
20745
21133
|
function sourcePosition2(source, byteOffset) {
|
|
@@ -20764,7 +21152,7 @@ function relativeSpecifier(node) {
|
|
|
20764
21152
|
function resolvedSpecifier(specifier, directory, versioned) {
|
|
20765
21153
|
const path = versioned ? Bun.resolveSync(specifier, directory) : resolve7(directory, specifier);
|
|
20766
21154
|
const normalized = path.replaceAll("\\", "/");
|
|
20767
|
-
return versioned && SCRIPT_FILE_FILTER.test(normalized) ? `${normalized}?furin-server&t=${routeModuleSourceVersion(normalized)}` : normalized;
|
|
21155
|
+
return versioned && SCRIPT_FILE_FILTER.test(normalized) && !isServerOnlyModule(path) ? `${normalized}?furin-server&t=${routeModuleSourceVersion(normalized)}` : normalized;
|
|
20768
21156
|
}
|
|
20769
21157
|
function rewriteModuleSpecifiers(input) {
|
|
20770
21158
|
const { diagnostics, program } = parseSource(input.code, detectLangFromPath(input.filePath));
|
|
@@ -20792,6 +21180,7 @@ var init_rewrite_module_specifiers = __esm(() => {
|
|
|
20792
21180
|
init_ast_walk();
|
|
20793
21181
|
init_lang_detect();
|
|
20794
21182
|
init_source_version();
|
|
21183
|
+
init_server_only_module();
|
|
20795
21184
|
});
|
|
20796
21185
|
|
|
20797
21186
|
// src/server/dev-page-imports.ts
|
|
@@ -20854,7 +21243,7 @@ function rewriteBareImports(source, dir, loader) {
|
|
|
20854
21243
|
} catch {
|
|
20855
21244
|
return;
|
|
20856
21245
|
}
|
|
20857
|
-
if (WORKSPACE_SOURCE_FILTER.test(resolved) && specifier !== "furin" && !specifier.startsWith("furin/") && specifier !== "@teyik0/furin" && !specifier.startsWith("@teyik0/furin/")) {
|
|
21246
|
+
if (WORKSPACE_SOURCE_FILTER.test(resolved) && specifier !== "furin" && !specifier.startsWith("furin/") && specifier !== "@teyik0/furin" && !specifier.startsWith("@teyik0/furin/") && !isServerOnlyModule(resolved)) {
|
|
20858
21247
|
resolved = `${resolved}?furin-server&t=${routeModuleSourceVersion(resolved)}`;
|
|
20859
21248
|
}
|
|
20860
21249
|
output.update(literal.start, literal.end, JSON.stringify(resolved));
|
|
@@ -20867,6 +21256,7 @@ var init_dev_page_imports = __esm(() => {
|
|
|
20867
21256
|
init_parser();
|
|
20868
21257
|
init_ast_walk();
|
|
20869
21258
|
init_rewrite_module_specifiers();
|
|
21259
|
+
init_server_only_module();
|
|
20870
21260
|
init_source_version();
|
|
20871
21261
|
WORKSPACE_SOURCE_FILTER = /^(?!.*(?:[\\/]node_modules[\\/]|[\\/]\.bun[\\/]))(?!.*\.(?:test|spec)\.(?:[cm]?[jt]s|[jt]sx)$).*\.(?:m?[jt]s|[jt]sx)$/;
|
|
20872
21262
|
SINGLETON_PKGS = [
|
|
@@ -20886,7 +21276,7 @@ var init_dev_page_imports = __esm(() => {
|
|
|
20886
21276
|
});
|
|
20887
21277
|
|
|
20888
21278
|
// src/server/dev-page-plugin.ts
|
|
20889
|
-
import { statSync as
|
|
21279
|
+
import { statSync as statSync4 } from "fs";
|
|
20890
21280
|
import { dirname as dirname8, isAbsolute as isAbsolute5 } from "path";
|
|
20891
21281
|
function getSourceLoader(filePath) {
|
|
20892
21282
|
return SCRIPT_FILE_FILTER.test(filePath) ? detectLoaderFromPath(filePath) : null;
|
|
@@ -20901,7 +21291,7 @@ function recordDevImports(source, filePath) {
|
|
|
20901
21291
|
if (!isAbsolute5(path) || getSourceLoader(path)) {
|
|
20902
21292
|
continue;
|
|
20903
21293
|
}
|
|
20904
|
-
const stats =
|
|
21294
|
+
const stats = statSync4(path, { bigint: true, throwIfNoEntry: false });
|
|
20905
21295
|
if (!stats) {
|
|
20906
21296
|
continue;
|
|
20907
21297
|
}
|
|
@@ -20960,7 +21350,13 @@ function transformDevSource(raw, filePath, options) {
|
|
|
20960
21350
|
if (!options.renderFragment) {
|
|
20961
21351
|
recordDevImports(raw, filePath);
|
|
20962
21352
|
}
|
|
20963
|
-
const
|
|
21353
|
+
const server = parseModule(raw, filePath);
|
|
21354
|
+
for (const statement of server.program.body) {
|
|
21355
|
+
if (statement.type === "ImportDeclaration" && statement.specifiers.length === 0 && CSS_IMPORT.test(statement.source.value)) {
|
|
21356
|
+
removeRange(server, statement.start, statement.end);
|
|
21357
|
+
}
|
|
21358
|
+
}
|
|
21359
|
+
const isomorphicSource = transformIsomorphicFunctions(server.source.toString(), filePath, "server").code;
|
|
20964
21360
|
const split = options.renderFragment ? undefined : splitDevPage(isomorphicSource, filePath, `${filePath}?furin-render&t=${routeModuleSourceVersion(filePath)}`);
|
|
20965
21361
|
const serverSource = split?.contract ?? isomorphicSource;
|
|
20966
21362
|
let result = options.rewriteRelativeImports ? rewriteRelativeImportsWithVersion(serverSource, filePath, true) : serverSource;
|
|
@@ -21077,8 +21473,9 @@ function registerDevPagePlugin() {
|
|
|
21077
21473
|
}
|
|
21078
21474
|
});
|
|
21079
21475
|
}
|
|
21080
|
-
var FURIN_SERVER_FILTER, FURIN_RENDER_FILTER, COMMONJS_FILE_RE, ANY_FILTER, T_PARAM_RE, STRIP_FURIN_SERVER_RE, STRIP_T_PARAM_RE, DELETED_DEV_PAGE_CONTENTS = "export const route = undefined;", _pluginRegistered = false, pluginSourceStamps;
|
|
21476
|
+
var FURIN_SERVER_FILTER, FURIN_RENDER_FILTER, COMMONJS_FILE_RE, ANY_FILTER, T_PARAM_RE, STRIP_FURIN_SERVER_RE, STRIP_T_PARAM_RE, DELETED_DEV_PAGE_CONTENTS = "export const route = undefined;", CSS_IMPORT, _pluginRegistered = false, pluginSourceStamps;
|
|
21081
21477
|
var init_dev_page_plugin = __esm(() => {
|
|
21478
|
+
init_module_transform();
|
|
21082
21479
|
init_transform_dev_page();
|
|
21083
21480
|
init_transform_isomorphic();
|
|
21084
21481
|
init_dev_loader();
|
|
@@ -21095,11 +21492,12 @@ var init_dev_page_plugin = __esm(() => {
|
|
|
21095
21492
|
T_PARAM_RE = /&t=(\d+)/;
|
|
21096
21493
|
STRIP_FURIN_SERVER_RE = /\?furin-server.*$/;
|
|
21097
21494
|
STRIP_T_PARAM_RE = /\?t=\d+$/;
|
|
21495
|
+
CSS_IMPORT = /\.css(?:\?.*)?$/;
|
|
21098
21496
|
pluginSourceStamps = new Map;
|
|
21099
21497
|
});
|
|
21100
21498
|
|
|
21101
21499
|
// src/plugin/route-modules.ts
|
|
21102
|
-
import { existsSync as existsSync8, readFileSync as
|
|
21500
|
+
import { existsSync as existsSync8, readFileSync as readFileSync6, realpathSync as realpathSync3, statSync as statSync5 } from "fs";
|
|
21103
21501
|
import { dirname as dirname9, isAbsolute as isAbsolute6, join as join6, relative as relative8, sep as sep2 } from "path";
|
|
21104
21502
|
function validateRouteParams(path, schemas) {
|
|
21105
21503
|
const pathParams = path.split("/").filter((segment) => segment === "*" || segment.startsWith(":")).map((segment) => segment === "*" ? segment : segment.slice(1));
|
|
@@ -21143,7 +21541,7 @@ function resolveRouteModuleImports(dependencyPath, packageRoot) {
|
|
|
21143
21541
|
if (!SCRIPT_FILE_FILTER.test(dependencyPath)) {
|
|
21144
21542
|
return [];
|
|
21145
21543
|
}
|
|
21146
|
-
const source =
|
|
21544
|
+
const source = readFileSync6(dependencyPath, "utf8");
|
|
21147
21545
|
const transpiler = new Bun.Transpiler({ loader: detectLoaderFromPath(dependencyPath) });
|
|
21148
21546
|
const resolvedImports = [];
|
|
21149
21547
|
for (const imported of transpiler.scanImports(source)) {
|
|
@@ -21172,7 +21570,7 @@ function collectRouteModuleDependencies(sourcePath) {
|
|
|
21172
21570
|
visited.add(dependencyPath);
|
|
21173
21571
|
let mtimeMs;
|
|
21174
21572
|
try {
|
|
21175
|
-
({ mtimeMs } =
|
|
21573
|
+
({ mtimeMs } = statSync5(dependencyPath));
|
|
21176
21574
|
} catch {
|
|
21177
21575
|
continue;
|
|
21178
21576
|
}
|
|
@@ -21191,7 +21589,7 @@ var init_route_modules = __esm(() => {
|
|
|
21191
21589
|
});
|
|
21192
21590
|
|
|
21193
21591
|
// src/plugin/dev-routes.ts
|
|
21194
|
-
import { existsSync as existsSync9, readFileSync as
|
|
21592
|
+
import { existsSync as existsSync9, readFileSync as readFileSync7, statSync as statSync6, watch } from "fs";
|
|
21195
21593
|
import { dirname as dirname10, relative as relative9, resolve as resolve9, sep as sep3 } from "path";
|
|
21196
21594
|
import { Elysia as Elysia16 } from "elysia";
|
|
21197
21595
|
function routeTopologySource(instance) {
|
|
@@ -21212,7 +21610,7 @@ function routeDependencyPaths(instance) {
|
|
|
21212
21610
|
function routeFilesSignature(instance) {
|
|
21213
21611
|
return routeDependencyPaths(instance).map((path) => {
|
|
21214
21612
|
try {
|
|
21215
|
-
const stats =
|
|
21613
|
+
const stats = statSync6(path, { bigint: true });
|
|
21216
21614
|
return `${path}\x00${stats.mtimeNs}:${stats.size}`;
|
|
21217
21615
|
} catch {
|
|
21218
21616
|
return `${path}\x00missing`;
|
|
@@ -21309,7 +21707,7 @@ function reportChangedSourceError(state, directory, filename) {
|
|
|
21309
21707
|
return;
|
|
21310
21708
|
}
|
|
21311
21709
|
try {
|
|
21312
|
-
const source =
|
|
21710
|
+
const source = readFileSync7(sourcePath, "utf8");
|
|
21313
21711
|
const loader = detectLoaderFromPath(sourcePath);
|
|
21314
21712
|
new Bun.Transpiler({ loader }).transformSync(source, loader);
|
|
21315
21713
|
} catch (error) {
|
|
@@ -21551,7 +21949,7 @@ var init_dev_routes = __esm(() => {
|
|
|
21551
21949
|
});
|
|
21552
21950
|
|
|
21553
21951
|
// src/plugin/route-config.ts
|
|
21554
|
-
import { existsSync as existsSync10, readFileSync as
|
|
21952
|
+
import { existsSync as existsSync10, readFileSync as readFileSync8, writeFileSync } from "fs";
|
|
21555
21953
|
import { basename as basename3, join as join7, relative as relative10, resolve as resolve10 } from "path";
|
|
21556
21954
|
function withoutExtension(path) {
|
|
21557
21955
|
return path.replace(EXTENSION_RE, "");
|
|
@@ -21611,7 +22009,7 @@ function findRouteExport(program, imports) {
|
|
|
21611
22009
|
}
|
|
21612
22010
|
function readSource(file) {
|
|
21613
22011
|
try {
|
|
21614
|
-
return
|
|
22012
|
+
return readFileSync8(file, "utf8");
|
|
21615
22013
|
} catch {}
|
|
21616
22014
|
}
|
|
21617
22015
|
function parseRoute(file) {
|
|
@@ -21844,6 +22242,37 @@ var init_route_config = __esm(() => {
|
|
|
21844
22242
|
PATH_SEPARATOR_RE = /[\\/]/;
|
|
21845
22243
|
});
|
|
21846
22244
|
|
|
22245
|
+
// src/build/route-metadata.ts
|
|
22246
|
+
function routeBuildInfo(route) {
|
|
22247
|
+
if ("build" in route) {
|
|
22248
|
+
return route.build;
|
|
22249
|
+
}
|
|
22250
|
+
const chain = route.routeChain ?? [];
|
|
22251
|
+
const query = mergeRouteSchemas(chain, "query");
|
|
22252
|
+
let queryKeys = [];
|
|
22253
|
+
if (query !== undefined) {
|
|
22254
|
+
queryKeys = isTypeBoxObjectSchema(query) ? Object.keys(query.properties).toSorted() : null;
|
|
22255
|
+
}
|
|
22256
|
+
return {
|
|
22257
|
+
documentMode: resolveDocumentMode({ ...route, routeChain: chain }),
|
|
22258
|
+
documentRevalidate: resolveDocumentRevalidate({ ...route, routeChain: chain }),
|
|
22259
|
+
hasLayout: chain.some((entry) => !!entry.layout),
|
|
22260
|
+
hasRequestLoader: chain.some((entry) => entry.requestLoader !== undefined),
|
|
22261
|
+
hasStaticParams: route.page.staticParams !== undefined || chain.some((entry) => entry.staticParams !== undefined),
|
|
22262
|
+
mixed: hasMixedLoaderModes({ ...route, routeChain: chain }),
|
|
22263
|
+
queryKeys,
|
|
22264
|
+
revalidate: resolveRouteRevalidate(route.page),
|
|
22265
|
+
searchDefaults: collectSearchDefaults(query)
|
|
22266
|
+
};
|
|
22267
|
+
}
|
|
22268
|
+
var init_route_metadata = __esm(() => {
|
|
22269
|
+
init_loaders();
|
|
22270
|
+
init_patterns();
|
|
22271
|
+
init_schema_merge();
|
|
22272
|
+
init_elysia_contract();
|
|
22273
|
+
init_search_params();
|
|
22274
|
+
});
|
|
22275
|
+
|
|
21847
22276
|
// src/rsc/build/paths.ts
|
|
21848
22277
|
import { dirname as dirname11, join as join8 } from "path";
|
|
21849
22278
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -21881,7 +22310,7 @@ ${body}
|
|
|
21881
22310
|
}
|
|
21882
22311
|
|
|
21883
22312
|
// src/build/route-types.ts
|
|
21884
|
-
import { existsSync as existsSync11, readFileSync as
|
|
22313
|
+
import { existsSync as existsSync11, readFileSync as readFileSync9, renameSync, writeFileSync as writeFileSync2 } from "fs";
|
|
21885
22314
|
import { extname as extname3, join as join9, relative as relative11, resolve as resolve11 } from "path";
|
|
21886
22315
|
function tagKeyToPropertyName(tag) {
|
|
21887
22316
|
return /^[$A-Z_a-z][$\w]*$/.test(tag) ? tag : JSON.stringify(tag);
|
|
@@ -21964,7 +22393,7 @@ import "@teyik0/furin/routes";
|
|
|
21964
22393
|
${apps === undefined ? "" : fileRoutesDeclaration(apps, projectRoot)}${routeMapDeclaration(entries)}${tagBlock}
|
|
21965
22394
|
`;
|
|
21966
22395
|
const typesPath = join9(projectRoot, "furin-env.d.ts");
|
|
21967
|
-
const existing = existsSync11(typesPath) ?
|
|
22396
|
+
const existing = existsSync11(typesPath) ? readFileSync9(typesPath, "utf8") : "";
|
|
21968
22397
|
if (content === existing) {
|
|
21969
22398
|
return false;
|
|
21970
22399
|
}
|
|
@@ -21990,7 +22419,7 @@ var init_shared2 = __esm(() => {
|
|
|
21990
22419
|
});
|
|
21991
22420
|
|
|
21992
22421
|
// src/build/hydrate.ts
|
|
21993
|
-
import { existsSync as existsSync12, mkdirSync, readFileSync as
|
|
22422
|
+
import { existsSync as existsSync12, mkdirSync, readFileSync as readFileSync10, writeFileSync as writeFileSync3 } from "fs";
|
|
21994
22423
|
import { dirname as dirname12, join as join10 } from "path";
|
|
21995
22424
|
function generateClientReferenceEntry(boundaries) {
|
|
21996
22425
|
if (boundaries.length === 0) {
|
|
@@ -22027,7 +22456,7 @@ function hydrateEntry(routes, rootLayout, basePath, clientLogging, modulePathKey
|
|
|
22027
22456
|
for (const route of clientRoutes) {
|
|
22028
22457
|
const resolvedPage = route.path.replace(/\\/g, "/");
|
|
22029
22458
|
const regexPattern = buildRouteRegex(route.pattern).regex.source;
|
|
22030
|
-
const searchDefaults =
|
|
22459
|
+
const searchDefaults = routeBuildInfo(route).searchDefaults;
|
|
22031
22460
|
const boundaryIdents = new Map;
|
|
22032
22461
|
const layoutPaths = (route.routeChain ?? []).slice(1).filter((entry) => entry.layout && entry.sourcePath).map((entry) => entry.sourcePath);
|
|
22033
22462
|
activeHotComponentKeys.add(`page:${modulePathKey(resolvedPage)}`);
|
|
@@ -22102,6 +22531,12 @@ const __furinBasePath = ${basePathLiteral};
|
|
|
22102
22531
|
${loggerSetup}
|
|
22103
22532
|
|
|
22104
22533
|
if (import.meta.hot) {
|
|
22534
|
+
import.meta.hot.on("bun:beforeUpdate", () => {
|
|
22535
|
+
window.dispatchEvent(new Event("furin:hmr-before-update"));
|
|
22536
|
+
});
|
|
22537
|
+
import.meta.hot.on("bun:afterUpdate", () => {
|
|
22538
|
+
window.dispatchEvent(new Event("furin:hmr-after-update"));
|
|
22539
|
+
});
|
|
22105
22540
|
const connectionState = ((window as unknown as {
|
|
22106
22541
|
__FURIN_HMR_CONNECTION__?: { disconnected: boolean; installed: boolean };
|
|
22107
22542
|
}).__FURIN_HMR_CONNECTION__ ??= { disconnected: false, installed: false });
|
|
@@ -22403,7 +22838,7 @@ if (import.meta.hot) import.meta.hot.data.furinServerSourceVersion = ${JSON.stri
|
|
|
22403
22838
|
`;
|
|
22404
22839
|
const hydrateCode = generateClientReferenceEntry(clientBoundaries ?? []) + generateHydrateEntry(routes, rootLayout, basePath, clientLogging) + serverVersion;
|
|
22405
22840
|
const hydratePath = join10(outDir, "_hydrate.tsx");
|
|
22406
|
-
const existingHydrate = existsSync12(hydratePath) ?
|
|
22841
|
+
const existingHydrate = existsSync12(hydratePath) ? readFileSync10(hydratePath, "utf8") : "";
|
|
22407
22842
|
let changed = false;
|
|
22408
22843
|
if (hydrateCode !== existingHydrate) {
|
|
22409
22844
|
writeFileSync3(hydratePath, hydrateCode);
|
|
@@ -22411,7 +22846,7 @@ if (import.meta.hot) import.meta.hot.data.furinServerSourceVersion = ${JSON.stri
|
|
|
22411
22846
|
}
|
|
22412
22847
|
const indexHtml = generateIndexHtml();
|
|
22413
22848
|
const indexPath = join10(outDir, "index.html");
|
|
22414
|
-
const existingIndex = existsSync12(indexPath) ?
|
|
22849
|
+
const existingIndex = existsSync12(indexPath) ? readFileSync10(indexPath, "utf8") : "";
|
|
22415
22850
|
if (indexHtml !== existingIndex) {
|
|
22416
22851
|
writeFileSync3(indexPath, indexHtml);
|
|
22417
22852
|
changed = true;
|
|
@@ -22424,8 +22859,7 @@ if (import.meta.hot) import.meta.hot.data.furinServerSourceVersion = ${JSON.stri
|
|
|
22424
22859
|
var devRouteTypesApps;
|
|
22425
22860
|
var init_hydrate = __esm(() => {
|
|
22426
22861
|
init_patterns();
|
|
22427
|
-
|
|
22428
|
-
init_search_params();
|
|
22862
|
+
init_route_metadata();
|
|
22429
22863
|
init_paths();
|
|
22430
22864
|
init_route_types();
|
|
22431
22865
|
init_shared2();
|
|
@@ -22709,7 +23143,7 @@ var init_discover = __esm(() => {
|
|
|
22709
23143
|
});
|
|
22710
23144
|
|
|
22711
23145
|
// src/plugin/hmr-dependencies.ts
|
|
22712
|
-
import { readFileSync as
|
|
23146
|
+
import { readFileSync as readFileSync11 } from "fs";
|
|
22713
23147
|
import { dirname as dirname13, isAbsolute as isAbsolute7, resolve as resolve12 } from "path";
|
|
22714
23148
|
function hmrDependencySignature(imports, filename) {
|
|
22715
23149
|
const routePath = resolve12(filename);
|
|
@@ -22728,7 +23162,7 @@ function hmrDependencySignature(imports, filename) {
|
|
|
22728
23162
|
return true;
|
|
22729
23163
|
}
|
|
22730
23164
|
visited.add(path);
|
|
22731
|
-
const source =
|
|
23165
|
+
const source = readFileSync11(path, "utf8");
|
|
22732
23166
|
hash.update(source);
|
|
22733
23167
|
if (SCRIPT_FILE_FILTER.test(path)) {
|
|
22734
23168
|
const transpiler = new Bun.Transpiler({ loader: detectLoaderFromPath(path) });
|
|
@@ -22886,7 +23320,7 @@ var exports_runtime = {};
|
|
|
22886
23320
|
__export(exports_runtime, {
|
|
22887
23321
|
createDevRuntime: () => createDevRuntime
|
|
22888
23322
|
});
|
|
22889
|
-
import { existsSync as existsSync13, readFileSync as
|
|
23323
|
+
import { existsSync as existsSync13, readFileSync as readFileSync12 } from "fs";
|
|
22890
23324
|
import { basename as basename4, dirname as dirname14, join as join11, resolve as resolve13 } from "path";
|
|
22891
23325
|
import { staticPlugin as staticPlugin2 } from "@elysia/static";
|
|
22892
23326
|
import { Elysia as Elysia17, file as file2 } from "elysia";
|
|
@@ -23017,7 +23451,7 @@ async function createDevRuntime(instance, resolvedPagesDir, options) {
|
|
|
23017
23451
|
const nextSignatures = new Map(paths.map((path) => {
|
|
23018
23452
|
let signature;
|
|
23019
23453
|
try {
|
|
23020
|
-
signature = getHmrDataSignature(
|
|
23454
|
+
signature = getHmrDataSignature(readFileSync12(path, "utf8"), path);
|
|
23021
23455
|
if (signature.startsWith("external:")) {
|
|
23022
23456
|
signature = graph.sourceVersion(path);
|
|
23023
23457
|
}
|
|
@@ -23284,28 +23718,6 @@ async function readBoundedBytes(stream, maxBytes) {
|
|
|
23284
23718
|
// src/server/logging/ingest-plugin.ts
|
|
23285
23719
|
init_instrumentation();
|
|
23286
23720
|
init_evlog();
|
|
23287
|
-
|
|
23288
|
-
// src/server/logger.ts
|
|
23289
|
-
init_dist();
|
|
23290
|
-
var FURIN_LOGGER_SAMPLING = Symbol.for("@teyik0/furin/logger-sampling");
|
|
23291
|
-
function loggerState() {
|
|
23292
|
-
return globalThis;
|
|
23293
|
-
}
|
|
23294
|
-
function initializeFurinLogger(config) {
|
|
23295
|
-
const state = loggerState();
|
|
23296
|
-
const sampling = JSON.stringify(config.sampling ?? null);
|
|
23297
|
-
const active = state[FURIN_LOGGER_SAMPLING];
|
|
23298
|
-
if (active === undefined) {
|
|
23299
|
-
initLogger(config);
|
|
23300
|
-
state[FURIN_LOGGER_SAMPLING] = sampling;
|
|
23301
|
-
return;
|
|
23302
|
-
}
|
|
23303
|
-
if (config.sampling !== undefined && sampling !== active) {
|
|
23304
|
-
throw new Error(`[furin] logger.sampling is process-wide (evlog initLogger): this process already samples with ${active}, so ${sampling} would be ignored. Pass the same sampling to every furin() instance, or omit it on later ones.`);
|
|
23305
|
-
}
|
|
23306
|
-
}
|
|
23307
|
-
|
|
23308
|
-
// src/server/logging/ingest-plugin.ts
|
|
23309
23721
|
var MAX_BROWSER_INGEST_BYTES = 64 * 1024;
|
|
23310
23722
|
var MAX_BROWSER_INGEST_EVENTS = 100;
|
|
23311
23723
|
var PROTOTYPE_POLLUTION_KEYS = new Set(["__proto__", "constructor", "prototype"]);
|
|
@@ -23350,12 +23762,7 @@ function createLoggerOptions(prefix, syncPath, logger) {
|
|
|
23350
23762
|
};
|
|
23351
23763
|
}
|
|
23352
23764
|
function createLoggerPlugin(instance, logger, clientLogging) {
|
|
23353
|
-
const
|
|
23354
|
-
initializeFurinLogger({
|
|
23355
|
-
env: { service: "furin" },
|
|
23356
|
-
...sampling ? { sampling } : {}
|
|
23357
|
-
});
|
|
23358
|
-
const options = createLoggerOptions(instance.prefix, instance.syncPath, elysiaLoggerOptions);
|
|
23765
|
+
const options = createLoggerOptions(instance.prefix, instance.syncPath, logger ?? {});
|
|
23359
23766
|
setFurinEvlogOptions(instance, options);
|
|
23360
23767
|
const app = new Elysia10().use(createFurinEvlog(options));
|
|
23361
23768
|
if (!clientLogging) {
|
|
@@ -24339,10 +24746,13 @@ function idempotentRouteMacro(_idempotent) {
|
|
|
24339
24746
|
};
|
|
24340
24747
|
}
|
|
24341
24748
|
function createSyncPlugin(options, owner) {
|
|
24342
|
-
const
|
|
24343
|
-
|
|
24749
|
+
const development = IS_DEV;
|
|
24750
|
+
prepareSyncRuntime(options, development);
|
|
24751
|
+
const runtime = () => resolveSyncRuntime(options, development);
|
|
24344
24752
|
function mutationFor(ctx) {
|
|
24345
24753
|
const mutation = async (callback) => {
|
|
24754
|
+
const resolved = runtime();
|
|
24755
|
+
const transactional = "executeMutation" in resolved.adapter ? resolved.adapter : undefined;
|
|
24346
24756
|
const active = activeMutations.get(ctx.request);
|
|
24347
24757
|
if (!(transactional && active)) {
|
|
24348
24758
|
throw new Error("[furin] mutation() requires a transactional sync adapter and an enabled mutation route.");
|
|
@@ -24357,7 +24767,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24357
24767
|
app: syncValidationApp(ctx),
|
|
24358
24768
|
context: ctx,
|
|
24359
24769
|
lease: active.lease,
|
|
24360
|
-
runtime,
|
|
24770
|
+
runtime: resolved,
|
|
24361
24771
|
onCommit: (result) => atomicResponses.set(ctx.request, result)
|
|
24362
24772
|
}, callback);
|
|
24363
24773
|
} finally {
|
|
@@ -24392,7 +24802,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24392
24802
|
}
|
|
24393
24803
|
const key = `${ctx.request.method}:${url.pathname}:${idempotencyKey}`;
|
|
24394
24804
|
const fingerprint = createMutationFingerprint({ body: ctx.body, request: ctx.request });
|
|
24395
|
-
const result = await runtime.adapter.beginMutation({ fingerprint, key, principal });
|
|
24805
|
+
const result = await runtime().adapter.beginMutation({ fingerprint, key, principal });
|
|
24396
24806
|
if (result.kind === "replay") {
|
|
24397
24807
|
return replayResponse(result.response);
|
|
24398
24808
|
}
|
|
@@ -24406,7 +24816,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24406
24816
|
if (activeMutations.get(ctx.request) === active) {
|
|
24407
24817
|
scheduleRenewal();
|
|
24408
24818
|
}
|
|
24409
|
-
await runtime.adapter.renewMutation(result.lease).catch(() => {
|
|
24819
|
+
await runtime().adapter.renewMutation(result.lease).catch(() => {
|
|
24410
24820
|
return;
|
|
24411
24821
|
});
|
|
24412
24822
|
}, renewAfter);
|
|
@@ -24426,7 +24836,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24426
24836
|
async function abortMutation(request) {
|
|
24427
24837
|
const active = releaseMutation(request);
|
|
24428
24838
|
if (active) {
|
|
24429
|
-
await runtime.adapter.abortMutation(active.lease);
|
|
24839
|
+
await runtime().adapter.abortMutation(active.lease);
|
|
24430
24840
|
}
|
|
24431
24841
|
}
|
|
24432
24842
|
async function applyInvalidations(ctx) {
|
|
@@ -24450,7 +24860,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24450
24860
|
const result = await storeResponse(ctx.responseValue, ctx.set);
|
|
24451
24861
|
const invalidations = await applyInvalidations(ctx);
|
|
24452
24862
|
const response = mergeStoredResponseHeaders(result.response, result.kind === "unreplayable" ? ctx.set.headers : effectiveResponseHeaders(ctx.responseValue, ctx.set));
|
|
24453
|
-
const completion = await runtime.adapter.completeMutation({
|
|
24863
|
+
const completion = await runtime().adapter.completeMutation({
|
|
24454
24864
|
invalidations,
|
|
24455
24865
|
lease: active.lease,
|
|
24456
24866
|
response
|
|
@@ -24459,7 +24869,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24459
24869
|
return leaseLostResponse();
|
|
24460
24870
|
}
|
|
24461
24871
|
if (completion.cursor !== undefined) {
|
|
24462
|
-
publishCursor(runtime, completion.cursor);
|
|
24872
|
+
publishCursor(runtime(), completion.cursor);
|
|
24463
24873
|
}
|
|
24464
24874
|
if (result.kind === "unreplayable") {
|
|
24465
24875
|
return replayResponse(response);
|
|
@@ -24471,7 +24881,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24471
24881
|
}
|
|
24472
24882
|
const invalidations = await applyInvalidations(ctx);
|
|
24473
24883
|
try {
|
|
24474
|
-
publishCursor(runtime, await runtime.adapter.appendInvalidations(invalidations));
|
|
24884
|
+
publishCursor(runtime(), await runtime().adapter.appendInvalidations(invalidations));
|
|
24475
24885
|
} catch {
|
|
24476
24886
|
getLogger().warn("Sync journal append failed after a non-idempotent mutation");
|
|
24477
24887
|
}
|
|
@@ -24496,12 +24906,12 @@ function createSyncPlugin(options, owner) {
|
|
|
24496
24906
|
}
|
|
24497
24907
|
try {
|
|
24498
24908
|
if (!isSuccessfulMutationResponse(ctx)) {
|
|
24499
|
-
await runtime.adapter.abortMutation(active.lease);
|
|
24909
|
+
await runtime().adapter.abortMutation(active.lease);
|
|
24500
24910
|
return;
|
|
24501
24911
|
}
|
|
24502
24912
|
return await persistMutation(ctx, active);
|
|
24503
24913
|
} catch (error) {
|
|
24504
|
-
await runtime.adapter.abortMutation(active.lease).catch(() => {
|
|
24914
|
+
await runtime().adapter.abortMutation(active.lease).catch(() => {
|
|
24505
24915
|
return;
|
|
24506
24916
|
});
|
|
24507
24917
|
throw error;
|
|
@@ -24541,7 +24951,7 @@ function createSyncPlugin(options, owner) {
|
|
|
24541
24951
|
}
|
|
24542
24952
|
const identity = {
|
|
24543
24953
|
...urlIdentity(ctx),
|
|
24544
|
-
session: principalHash(
|
|
24954
|
+
session: principalHash(runtime().adapter, principal)
|
|
24545
24955
|
};
|
|
24546
24956
|
ctx.set.headers["x-furin-query"] = serializeQueryHeader(identity);
|
|
24547
24957
|
}).onError("global", MutationLeaseLost, hideTransportResponse(({ request }) => Promise.resolve(requestOwners.get(request) === owner ? leaseLostResponse() : undefined))).onError("global", hideTransportResponse(async ({ request }) => {
|
|
@@ -24572,9 +24982,7 @@ function furinSync(options) {
|
|
|
24572
24982
|
requestOwners.set(request, routeOwner);
|
|
24573
24983
|
});
|
|
24574
24984
|
installMutationHandlers(app);
|
|
24575
|
-
|
|
24576
|
-
bindSyncValidation(app);
|
|
24577
|
-
}
|
|
24985
|
+
bindSyncValidation(app);
|
|
24578
24986
|
return app.use(createSyncPlugin(options, owner));
|
|
24579
24987
|
};
|
|
24580
24988
|
}
|
|
@@ -24601,13 +25009,379 @@ init_element();
|
|
|
24601
25009
|
init_not_found2();
|
|
24602
25010
|
// src/server/sync/invalidate-sync.ts
|
|
24603
25011
|
init_runtime();
|
|
24604
|
-
async function invalidateSync(sync, target,
|
|
25012
|
+
async function invalidateSync(sync, target, paramsOrOptions, options) {
|
|
25013
|
+
const provenance = typeof target === "string" ? options : paramsOrOptions;
|
|
25014
|
+
if (provenance?.principal === "") {
|
|
25015
|
+
throw new Error("[furin] Sync invalidation principal must not be empty.");
|
|
25016
|
+
}
|
|
24605
25017
|
const runtime = resolveSyncRuntime(sync, IS_DEV);
|
|
24606
|
-
const rule = typeof target === "string" ? {
|
|
25018
|
+
const rule = typeof target === "string" ? {
|
|
25019
|
+
tags: [
|
|
25020
|
+
queryTag({ id: target, scope: paramsOrOptions ?? {} })
|
|
25021
|
+
]
|
|
25022
|
+
} : target;
|
|
24607
25023
|
await runInvalidationRules(rule);
|
|
24608
|
-
publishCursor(runtime, await runtime.adapter.appendInvalidations(normalizedInvalidations(rule)));
|
|
25024
|
+
publishCursor(runtime, await runtime.adapter.appendInvalidations(normalizedInvalidations(rule), provenance?.principal));
|
|
25025
|
+
}
|
|
25026
|
+
|
|
25027
|
+
// src/client/sync-client.ts
|
|
25028
|
+
init_query_store();
|
|
25029
|
+
init_sync_catch_up();
|
|
25030
|
+
function isEdenError(error) {
|
|
25031
|
+
return error instanceof Error && "status" in error && typeof error.status === "number" && "value" in error;
|
|
25032
|
+
}
|
|
25033
|
+
class SyncClientError extends Error {
|
|
25034
|
+
status;
|
|
25035
|
+
static [Symbol.hasInstance](error) {
|
|
25036
|
+
return error instanceof Error && error.name === "SyncClientError" && "status" in error;
|
|
25037
|
+
}
|
|
25038
|
+
constructor(message, status, cause) {
|
|
25039
|
+
super(message, { cause });
|
|
25040
|
+
this.name = "SyncClientError";
|
|
25041
|
+
this.status = status;
|
|
25042
|
+
}
|
|
25043
|
+
}
|
|
25044
|
+
function createSyncClientRuntime(options, transport) {
|
|
25045
|
+
const queries = new QueryStore(undefined);
|
|
25046
|
+
const listeners = new Set;
|
|
25047
|
+
const subscriptions = new Map;
|
|
25048
|
+
let state = { status: "idle", error: null };
|
|
25049
|
+
let controller = new AbortController;
|
|
25050
|
+
let ready = Promise.withResolvers();
|
|
25051
|
+
let connection;
|
|
25052
|
+
let timer;
|
|
25053
|
+
let attempt = 0;
|
|
25054
|
+
let generation = 0;
|
|
25055
|
+
let session;
|
|
25056
|
+
const publish = (status, error, reason) => {
|
|
25057
|
+
state = { status, error, reason };
|
|
25058
|
+
for (const listener of listeners) {
|
|
25059
|
+
listener(state);
|
|
25060
|
+
}
|
|
25061
|
+
};
|
|
25062
|
+
const headers = async () => new Headers(typeof options.headers === "function" ? await options.headers() : options.headers);
|
|
25063
|
+
const asError = (error) => error instanceof SyncClientError ? error : new SyncClientError("Sync connection failed", undefined, error);
|
|
25064
|
+
const unauthorized = (error) => error.status === 401 || error.status === 403;
|
|
25065
|
+
const active = () => state.status !== "closed" && state.status !== "unauthorized";
|
|
25066
|
+
const createRecovery = () => createSyncCatchUp({
|
|
25067
|
+
fetchPage: async (after) => {
|
|
25068
|
+
const { signal } = controller;
|
|
25069
|
+
const requestHeaders = await headers();
|
|
25070
|
+
signal.throwIfAborted();
|
|
25071
|
+
const response = await transport.fetchChanges(after, requestHeaders, signal);
|
|
25072
|
+
signal.throwIfAborted();
|
|
25073
|
+
if (!response.ok) {
|
|
25074
|
+
throw new SyncClientError("Sync recovery refused", response.status);
|
|
25075
|
+
}
|
|
25076
|
+
const page = await response.json();
|
|
25077
|
+
signal.throwIfAborted();
|
|
25078
|
+
const identity = response.headers.get("x-furin-sync-session");
|
|
25079
|
+
if (identity !== null) {
|
|
25080
|
+
if (session !== undefined && identity !== session) {
|
|
25081
|
+
reconnect();
|
|
25082
|
+
}
|
|
25083
|
+
session = identity;
|
|
25084
|
+
}
|
|
25085
|
+
return page;
|
|
25086
|
+
},
|
|
25087
|
+
onInvalidations: (paths) => {
|
|
25088
|
+
if (paths.includes("/:layout")) {
|
|
25089
|
+
queries.invalidateAll();
|
|
25090
|
+
}
|
|
25091
|
+
},
|
|
25092
|
+
onQueries: (identities) => queries.invalidate(identities)
|
|
25093
|
+
});
|
|
25094
|
+
let recovery = createRecovery();
|
|
25095
|
+
const releaseConnection = () => {
|
|
25096
|
+
connection?.stop?.();
|
|
25097
|
+
connection = undefined;
|
|
25098
|
+
clearTimeout(timer);
|
|
25099
|
+
timer = undefined;
|
|
25100
|
+
};
|
|
25101
|
+
const fail = (value) => {
|
|
25102
|
+
if (!active()) {
|
|
25103
|
+
return;
|
|
25104
|
+
}
|
|
25105
|
+
const error = asError(value);
|
|
25106
|
+
releaseConnection();
|
|
25107
|
+
if (unauthorized(error)) {
|
|
25108
|
+
generation += 1;
|
|
25109
|
+
const epoch = generation;
|
|
25110
|
+
recovery.close();
|
|
25111
|
+
state = { status: "unauthorized", error };
|
|
25112
|
+
controller.abort();
|
|
25113
|
+
ready.resolve();
|
|
25114
|
+
queries.clear();
|
|
25115
|
+
if (epoch === generation) {
|
|
25116
|
+
publish("unauthorized", error);
|
|
25117
|
+
}
|
|
25118
|
+
return;
|
|
25119
|
+
}
|
|
25120
|
+
const delay = Math.min(250 * 2 ** attempt, 5000);
|
|
25121
|
+
attempt += 1;
|
|
25122
|
+
timer = setTimeout(() => {
|
|
25123
|
+
timer = undefined;
|
|
25124
|
+
connect();
|
|
25125
|
+
}, delay);
|
|
25126
|
+
publish("reconnecting", error, "network");
|
|
25127
|
+
};
|
|
25128
|
+
const checkAccess = (url, status, error) => {
|
|
25129
|
+
if (status === 403) {
|
|
25130
|
+
queries.setError(url, error);
|
|
25131
|
+
} else if (status === 401) {
|
|
25132
|
+
fail(new SyncClientError("Live query access refused", status));
|
|
25133
|
+
if (state.status === "unauthorized") {
|
|
25134
|
+
queries.setError(url, error);
|
|
25135
|
+
}
|
|
25136
|
+
}
|
|
25137
|
+
};
|
|
25138
|
+
const connect = async () => {
|
|
25139
|
+
const epoch = generation;
|
|
25140
|
+
try {
|
|
25141
|
+
await recovery.catchUp();
|
|
25142
|
+
if (epoch !== generation || !active()) {
|
|
25143
|
+
return;
|
|
25144
|
+
}
|
|
25145
|
+
const requestHeaders = await headers();
|
|
25146
|
+
if (epoch !== generation || !active()) {
|
|
25147
|
+
return;
|
|
25148
|
+
}
|
|
25149
|
+
const current = {};
|
|
25150
|
+
connection = current;
|
|
25151
|
+
const stop = await transport.subscribe({
|
|
25152
|
+
headers: requestHeaders,
|
|
25153
|
+
signal: controller.signal,
|
|
25154
|
+
onContextChange: () => {
|
|
25155
|
+
if (epoch === generation && connection === current && active()) {
|
|
25156
|
+
reconnect(undefined, true);
|
|
25157
|
+
}
|
|
25158
|
+
},
|
|
25159
|
+
onCursor: () => {
|
|
25160
|
+
recovery.catchUp().then(() => {
|
|
25161
|
+
if (epoch === generation && active() && connection === current) {
|
|
25162
|
+
const reconnecting = state.status === "reconnecting";
|
|
25163
|
+
attempt = 0;
|
|
25164
|
+
ready.resolve();
|
|
25165
|
+
publish("connected", null);
|
|
25166
|
+
if (reconnecting && epoch === generation && connection === current) {
|
|
25167
|
+
for (const url of subscriptions.values()) {
|
|
25168
|
+
queries.fetch(url);
|
|
25169
|
+
}
|
|
25170
|
+
}
|
|
25171
|
+
}
|
|
25172
|
+
}).catch((error) => {
|
|
25173
|
+
if (epoch === generation && connection === current) {
|
|
25174
|
+
fail(error);
|
|
25175
|
+
}
|
|
25176
|
+
});
|
|
25177
|
+
},
|
|
25178
|
+
onError: (error) => {
|
|
25179
|
+
if (epoch === generation && connection === current) {
|
|
25180
|
+
fail(error);
|
|
25181
|
+
}
|
|
25182
|
+
}
|
|
25183
|
+
});
|
|
25184
|
+
if (epoch !== generation || !active() || connection !== current) {
|
|
25185
|
+
stop();
|
|
25186
|
+
return;
|
|
25187
|
+
}
|
|
25188
|
+
current.stop = stop;
|
|
25189
|
+
} catch (error) {
|
|
25190
|
+
if (epoch === generation) {
|
|
25191
|
+
fail(error);
|
|
25192
|
+
}
|
|
25193
|
+
}
|
|
25194
|
+
};
|
|
25195
|
+
function reconnect(reconnectOptions, automatic) {
|
|
25196
|
+
if (state.status === "closed") {
|
|
25197
|
+
return;
|
|
25198
|
+
}
|
|
25199
|
+
generation += 1;
|
|
25200
|
+
const epoch = generation;
|
|
25201
|
+
releaseConnection();
|
|
25202
|
+
const cursor = reconnectOptions?.preserveCache ? recovery.cursor() : undefined;
|
|
25203
|
+
recovery.close();
|
|
25204
|
+
controller.abort();
|
|
25205
|
+
ready.resolve();
|
|
25206
|
+
controller = new AbortController;
|
|
25207
|
+
ready = Promise.withResolvers();
|
|
25208
|
+
recovery = createRecovery();
|
|
25209
|
+
if (cursor === undefined) {
|
|
25210
|
+
session = undefined;
|
|
25211
|
+
} else {
|
|
25212
|
+
recovery.seed(cursor);
|
|
25213
|
+
}
|
|
25214
|
+
const delay = Math.min(250 * 2 ** attempt, 5000);
|
|
25215
|
+
attempt = automatic ? attempt + 1 : 0;
|
|
25216
|
+
queries.clear(reconnectOptions?.preserveCache);
|
|
25217
|
+
if (epoch !== generation) {
|
|
25218
|
+
return;
|
|
25219
|
+
}
|
|
25220
|
+
publish(automatic ? "reconnecting" : "connecting", null, reconnectOptions?.preserveCache ? "credentials" : "context");
|
|
25221
|
+
if (epoch !== generation) {
|
|
25222
|
+
return;
|
|
25223
|
+
}
|
|
25224
|
+
if (automatic) {
|
|
25225
|
+
timer = setTimeout(() => {
|
|
25226
|
+
timer = undefined;
|
|
25227
|
+
connect();
|
|
25228
|
+
}, delay);
|
|
25229
|
+
} else {
|
|
25230
|
+
connect();
|
|
25231
|
+
}
|
|
25232
|
+
queries.invalidateAll();
|
|
25233
|
+
}
|
|
25234
|
+
return {
|
|
25235
|
+
subscribe(query, listener) {
|
|
25236
|
+
if (state.status === "closed") {
|
|
25237
|
+
throw new SyncClientError("Sync client is closed", undefined);
|
|
25238
|
+
}
|
|
25239
|
+
const { reference, options: readOptions } = query[LIVE_QUERY];
|
|
25240
|
+
if (!transport.accepts(reference)) {
|
|
25241
|
+
throw new SyncClientError("Live query belongs to a different server", undefined);
|
|
25242
|
+
}
|
|
25243
|
+
const url = queries.readKey(reference, readOptions);
|
|
25244
|
+
queries.bind(url, async () => {
|
|
25245
|
+
const { signal } = controller;
|
|
25246
|
+
try {
|
|
25247
|
+
await ready.promise;
|
|
25248
|
+
signal.throwIfAborted();
|
|
25249
|
+
const read = readOptions;
|
|
25250
|
+
const fetch2 = { ...options.fetch, ...read?.fetch };
|
|
25251
|
+
fetch2.signal = fetch2.signal ? AbortSignal.any([signal, fetch2.signal]) : signal;
|
|
25252
|
+
const result = await reference.load({
|
|
25253
|
+
...read,
|
|
25254
|
+
...options.headers === undefined ? {} : { headers: [read?.headers, await headers()] },
|
|
25255
|
+
fetch: fetch2
|
|
25256
|
+
});
|
|
25257
|
+
signal.throwIfAborted();
|
|
25258
|
+
checkAccess(url, result.response?.status, result.error);
|
|
25259
|
+
return result;
|
|
25260
|
+
} catch (error) {
|
|
25261
|
+
if (signal.aborted) {
|
|
25262
|
+
throw asError(signal.reason);
|
|
25263
|
+
}
|
|
25264
|
+
if (isEdenError(error)) {
|
|
25265
|
+
checkAccess(url, error.status, error);
|
|
25266
|
+
return { data: null, error };
|
|
25267
|
+
}
|
|
25268
|
+
throw asError(error);
|
|
25269
|
+
}
|
|
25270
|
+
}, reference.client);
|
|
25271
|
+
let stopped = false;
|
|
25272
|
+
const unlisten = queries.subscribe(url, () => {
|
|
25273
|
+
if (!stopped) {
|
|
25274
|
+
listener(queries.snapshot(url));
|
|
25275
|
+
}
|
|
25276
|
+
});
|
|
25277
|
+
const stop = () => {
|
|
25278
|
+
stopped = true;
|
|
25279
|
+
unlisten();
|
|
25280
|
+
subscriptions.delete(stop);
|
|
25281
|
+
};
|
|
25282
|
+
subscriptions.set(stop, url);
|
|
25283
|
+
listener(queries.snapshot(url));
|
|
25284
|
+
if (!subscriptions.has(stop)) {
|
|
25285
|
+
return stop;
|
|
25286
|
+
}
|
|
25287
|
+
if (state.status === "idle") {
|
|
25288
|
+
publish("connecting", null);
|
|
25289
|
+
connect();
|
|
25290
|
+
}
|
|
25291
|
+
queries.fetch(url);
|
|
25292
|
+
return stop;
|
|
25293
|
+
},
|
|
25294
|
+
getConnectionState: () => state,
|
|
25295
|
+
subscribeConnection(listener) {
|
|
25296
|
+
if (state.status === "closed") {
|
|
25297
|
+
listener(state);
|
|
25298
|
+
return () => {
|
|
25299
|
+
return;
|
|
25300
|
+
};
|
|
25301
|
+
}
|
|
25302
|
+
listeners.add(listener);
|
|
25303
|
+
listener(state);
|
|
25304
|
+
return () => {
|
|
25305
|
+
listeners.delete(listener);
|
|
25306
|
+
};
|
|
25307
|
+
},
|
|
25308
|
+
reconnect,
|
|
25309
|
+
close() {
|
|
25310
|
+
if (state.status === "closed") {
|
|
25311
|
+
return;
|
|
25312
|
+
}
|
|
25313
|
+
generation += 1;
|
|
25314
|
+
publish("closed", null);
|
|
25315
|
+
releaseConnection();
|
|
25316
|
+
recovery.close();
|
|
25317
|
+
controller.abort();
|
|
25318
|
+
ready.resolve();
|
|
25319
|
+
for (const stop of subscriptions.keys()) {
|
|
25320
|
+
stop();
|
|
25321
|
+
}
|
|
25322
|
+
listeners.clear();
|
|
25323
|
+
queries.dispose();
|
|
25324
|
+
}
|
|
25325
|
+
};
|
|
24609
25326
|
}
|
|
24610
25327
|
|
|
25328
|
+
// src/server/sync/local-client.ts
|
|
25329
|
+
init_connection();
|
|
25330
|
+
init_stream();
|
|
25331
|
+
function createLocalSyncClient(options) {
|
|
25332
|
+
const changesUrl = new URL(`${options.syncPath ?? options.sync.path ?? "/_furin/sync"}/changes`, "http://e.ly");
|
|
25333
|
+
return createSyncClientRuntime(options, {
|
|
25334
|
+
accepts: (reference) => reference.application === options.app,
|
|
25335
|
+
fetchChanges: (after, headers, signal) => {
|
|
25336
|
+
const url = new URL(changesUrl);
|
|
25337
|
+
url.searchParams.set("after", after ?? "0");
|
|
25338
|
+
return options.app.handle(new Request(url, { ...options.fetch, headers, signal }));
|
|
25339
|
+
},
|
|
25340
|
+
subscribe: async ({ headers, signal, onCursor, onContextChange }) => {
|
|
25341
|
+
let access;
|
|
25342
|
+
let unsubscribe;
|
|
25343
|
+
const stop = () => {
|
|
25344
|
+
signal.removeEventListener("abort", stop);
|
|
25345
|
+
access?.close();
|
|
25346
|
+
unsubscribe?.();
|
|
25347
|
+
};
|
|
25348
|
+
signal.addEventListener("abort", stop, { once: true });
|
|
25349
|
+
const request = new Request(changesUrl, {
|
|
25350
|
+
...options.fetch,
|
|
25351
|
+
headers,
|
|
25352
|
+
signal
|
|
25353
|
+
});
|
|
25354
|
+
request[LOCAL_SYNC_CONNECTION] = async (context, sync) => {
|
|
25355
|
+
access = createSyncConnectionLifetime(sync, context, onContextChange);
|
|
25356
|
+
await access.acquire();
|
|
25357
|
+
if (signal.aborted) {
|
|
25358
|
+
return;
|
|
25359
|
+
}
|
|
25360
|
+
const subscription = await subscribeSyncCursor(sync, IS_DEV, onCursor);
|
|
25361
|
+
if (signal.aborted) {
|
|
25362
|
+
subscription.unsubscribe();
|
|
25363
|
+
} else {
|
|
25364
|
+
({ unsubscribe } = subscription);
|
|
25365
|
+
}
|
|
25366
|
+
};
|
|
25367
|
+
try {
|
|
25368
|
+
signal.throwIfAborted();
|
|
25369
|
+
const response = await options.app.handle(request);
|
|
25370
|
+
signal.throwIfAborted();
|
|
25371
|
+
if (!response.ok) {
|
|
25372
|
+
throw new SyncClientError("Local sync connection refused", response.status);
|
|
25373
|
+
}
|
|
25374
|
+
if (!access) {
|
|
25375
|
+
throw new SyncClientError("Local sync endpoint does not support event connections", undefined);
|
|
25376
|
+
}
|
|
25377
|
+
return stop;
|
|
25378
|
+
} catch (error) {
|
|
25379
|
+
stop();
|
|
25380
|
+
throw error;
|
|
25381
|
+
}
|
|
25382
|
+
}
|
|
25383
|
+
});
|
|
25384
|
+
}
|
|
24611
25385
|
// src/server/sync/index.ts
|
|
24612
25386
|
var furinSync2 = furinSync;
|
|
24613
25387
|
var invalidateSync2 = invalidateSync;
|
|
@@ -24802,6 +25576,7 @@ export {
|
|
|
24802
25576
|
Scripts,
|
|
24803
25577
|
buildErrorElement,
|
|
24804
25578
|
createIsomorphicFn,
|
|
25579
|
+
createLocalSyncClient,
|
|
24805
25580
|
defer,
|
|
24806
25581
|
defineRootRoute,
|
|
24807
25582
|
defineRoute,
|