sibujs 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +309 -129
- package/dist/browser.d.cts +46 -14
- package/dist/browser.d.ts +46 -14
- package/dist/browser.js +8 -6
- package/dist/build.cjs +184 -72
- package/dist/build.js +15 -16
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +11 -11
- package/dist/cdn.full.global.js +10 -10
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
- package/dist/chunk-3ISI6ACU.js +44 -0
- package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
- package/dist/chunk-5HZXGZ6T.js +24 -0
- package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
- package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
- package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
- package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
- package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
- package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
- package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
- package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
- package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
- package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
- package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
- package/dist/chunk-J6FW5TV6.js +233 -0
- package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
- package/dist/chunk-NYNYSPK7.js +318 -0
- package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
- package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
- package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
- package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
- package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
- package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
- package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
- package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
- package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
- package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
- package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
- package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
- package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
- package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
- package/dist/data.cjs +213 -117
- package/dist/data.d.cts +47 -9
- package/dist/data.d.ts +47 -9
- package/dist/data.js +12 -9
- package/dist/devtools.cjs +81 -57
- package/dist/devtools.js +7 -8
- package/dist/dispose-GEIG2KOF.js +28 -0
- package/dist/ecosystem.cjs +309 -104
- package/dist/ecosystem.d.cts +19 -3
- package/dist/ecosystem.d.ts +19 -3
- package/dist/ecosystem.js +12 -12
- package/dist/extras.cjs +2133 -863
- package/dist/extras.d.cts +10 -9
- package/dist/extras.d.ts +10 -9
- package/dist/extras.js +39 -28
- package/dist/index.cjs +184 -72
- package/dist/index.d.cts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +24 -27
- package/dist/motion.cjs +107 -41
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +317 -39
- package/dist/patterns.d.cts +27 -9
- package/dist/patterns.d.ts +27 -9
- package/dist/patterns.js +8 -8
- package/dist/performance.cjs +308 -216
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +8 -9
- package/dist/plugin-DVgSnTfK.d.cts +112 -0
- package/dist/plugin-DVgSnTfK.d.ts +112 -0
- package/dist/plugins.cjs +549 -202
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +35 -23
- package/dist/signal-EotCj4hS.d.cts +110 -0
- package/dist/signal-EotCj4hS.d.ts +110 -0
- package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
- package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
- package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
- package/dist/ssr.cjs +176 -72
- package/dist/ssr.d.cts +9 -3
- package/dist/ssr.d.ts +9 -3
- package/dist/ssr.js +11 -12
- package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
- package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
- package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
- package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
- package/dist/testing.cjs +2484 -2185
- package/dist/testing.d.cts +56 -5
- package/dist/testing.d.ts +56 -5
- package/dist/testing.js +580 -307
- package/dist/ui.cjs +707 -317
- package/dist/ui.d.cts +40 -7
- package/dist/ui.d.ts +40 -7
- package/dist/ui.js +151 -56
- package/dist/widgets.cjs +246 -278
- package/dist/widgets.js +9 -10
- package/package.json +1 -1
- package/dist/chunk-2WLZ6757.js +0 -149
- package/dist/chunk-CCSJMTRN.js +0 -15
- package/dist/chunk-QKRPLZ2V.js +0 -108
- package/dist/chunk-VUF4ALSW.js +0 -60
- package/dist/chunk-WWV3SJ3L.js +0 -131
- package/dist/dispose-46BOMMQJ.js +0 -19
- package/dist/plugin-D30wlGW5.d.cts +0 -71
- package/dist/plugin-D30wlGW5.d.ts +0 -71
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
context
|
|
3
|
-
} from "./chunk-VUF4ALSW.js";
|
|
4
1
|
import {
|
|
5
2
|
derived
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QE4TTDU3.js";
|
|
7
4
|
import {
|
|
8
5
|
sanitizeUrl
|
|
9
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2INLLLMZ.js";
|
|
10
7
|
import {
|
|
11
8
|
globalSingleton
|
|
12
9
|
} from "./chunk-7ZHH77QA.js";
|
|
13
10
|
import {
|
|
14
11
|
effect
|
|
15
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-XC4MEKGA.js";
|
|
16
13
|
import {
|
|
17
14
|
getRequestScopedCache
|
|
18
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7XHATCIH.js";
|
|
19
16
|
import {
|
|
20
17
|
batch,
|
|
21
18
|
signal
|
|
22
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-D33YTSX5.js";
|
|
20
|
+
import {
|
|
21
|
+
reportError
|
|
22
|
+
} from "./chunk-NYNYSPK7.js";
|
|
23
23
|
|
|
24
24
|
// src/data/abort.ts
|
|
25
25
|
function isAbortError(error) {
|
|
@@ -476,7 +476,7 @@ function mutation(mutationFn, options = {}) {
|
|
|
476
476
|
abortController = new AbortController();
|
|
477
477
|
const signal2 = abortController.signal;
|
|
478
478
|
const myRun = ++runId;
|
|
479
|
-
let
|
|
479
|
+
let context;
|
|
480
480
|
batch(() => {
|
|
481
481
|
setLoading(true);
|
|
482
482
|
setError(void 0);
|
|
@@ -484,7 +484,7 @@ function mutation(mutationFn, options = {}) {
|
|
|
484
484
|
});
|
|
485
485
|
try {
|
|
486
486
|
if (options.onMutate) {
|
|
487
|
-
|
|
487
|
+
context = await options.onMutate(variables);
|
|
488
488
|
}
|
|
489
489
|
const result = await withRetry(() => mutationFn(variables, signal2), options.retry, void 0, signal2);
|
|
490
490
|
if (myRun !== runId) return result;
|
|
@@ -495,8 +495,8 @@ function mutation(mutationFn, options = {}) {
|
|
|
495
495
|
setLoading(false);
|
|
496
496
|
setStatus("success");
|
|
497
497
|
});
|
|
498
|
-
runCallback("mutation onSuccess", () => options.onSuccess?.(result, variables,
|
|
499
|
-
runCallback("mutation onSettled", () => options.onSettled?.(result, void 0, variables,
|
|
498
|
+
runCallback("mutation onSuccess", () => options.onSuccess?.(result, variables, context));
|
|
499
|
+
runCallback("mutation onSettled", () => options.onSettled?.(result, void 0, variables, context));
|
|
500
500
|
return result;
|
|
501
501
|
} catch (err) {
|
|
502
502
|
if (isAbortError(err)) {
|
|
@@ -518,8 +518,8 @@ function mutation(mutationFn, options = {}) {
|
|
|
518
518
|
setLoading(false);
|
|
519
519
|
setStatus("error");
|
|
520
520
|
});
|
|
521
|
-
runCallback("mutation onError", () => options.onError?.(errorObj, variables,
|
|
522
|
-
runCallback("mutation onSettled", () => options.onSettled?.(void 0, errorObj, variables,
|
|
521
|
+
runCallback("mutation onError", () => options.onError?.(errorObj, variables, context));
|
|
522
|
+
runCallback("mutation onSettled", () => options.onSettled?.(void 0, errorObj, variables, context));
|
|
523
523
|
throw errorObj;
|
|
524
524
|
}
|
|
525
525
|
}
|
|
@@ -657,18 +657,21 @@ function infiniteQuery(key, fetcher, options) {
|
|
|
657
657
|
}
|
|
658
658
|
});
|
|
659
659
|
function fetchNextPage() {
|
|
660
|
+
if (disposed) return Promise.resolve();
|
|
660
661
|
if (inFlight) return inFlight;
|
|
661
662
|
const param = nextPageParam();
|
|
662
663
|
if (param === void 0) return Promise.resolve();
|
|
663
664
|
return fetchPage(param, "next");
|
|
664
665
|
}
|
|
665
666
|
function fetchPreviousPage() {
|
|
667
|
+
if (disposed) return Promise.resolve();
|
|
666
668
|
if (inFlight) return inFlight;
|
|
667
669
|
const param = prevPageParam();
|
|
668
670
|
if (param === void 0) return Promise.resolve();
|
|
669
671
|
return fetchPage(param, "prev");
|
|
670
672
|
}
|
|
671
673
|
async function refetch() {
|
|
674
|
+
if (disposed) return;
|
|
672
675
|
batch(() => {
|
|
673
676
|
setPages([]);
|
|
674
677
|
setNextPageParam(initialPageParam);
|
|
@@ -752,25 +755,26 @@ function throttle(getter, interval) {
|
|
|
752
755
|
let pending = null;
|
|
753
756
|
let lastEmitted = getter();
|
|
754
757
|
let timer = null;
|
|
758
|
+
function emit(value) {
|
|
759
|
+
setThrottled(value);
|
|
760
|
+
lastEmitted = value;
|
|
761
|
+
cooldown = true;
|
|
762
|
+
pending = null;
|
|
763
|
+
timer = setTimeout(endWindow, interval);
|
|
764
|
+
}
|
|
765
|
+
function endWindow() {
|
|
766
|
+
timer = null;
|
|
767
|
+
if (pending !== null && !Object.is(pending.value, lastEmitted)) {
|
|
768
|
+
emit(pending.value);
|
|
769
|
+
return;
|
|
770
|
+
}
|
|
771
|
+
pending = null;
|
|
772
|
+
cooldown = false;
|
|
773
|
+
}
|
|
755
774
|
const stop = effect(() => {
|
|
756
775
|
const value = getter();
|
|
757
776
|
if (!cooldown) {
|
|
758
|
-
if (!Object.is(value, lastEmitted))
|
|
759
|
-
setThrottled(value);
|
|
760
|
-
lastEmitted = value;
|
|
761
|
-
cooldown = true;
|
|
762
|
-
pending = null;
|
|
763
|
-
timer = setTimeout(() => {
|
|
764
|
-
timer = null;
|
|
765
|
-
cooldown = false;
|
|
766
|
-
if (pending !== null) {
|
|
767
|
-
const trailingValue = pending.value;
|
|
768
|
-
pending = null;
|
|
769
|
-
setThrottled(trailingValue);
|
|
770
|
-
lastEmitted = trailingValue;
|
|
771
|
-
}
|
|
772
|
-
}, interval);
|
|
773
|
-
}
|
|
777
|
+
if (!Object.is(value, lastEmitted)) emit(value);
|
|
774
778
|
} else {
|
|
775
779
|
pending = { value };
|
|
776
780
|
}
|
|
@@ -844,7 +848,7 @@ function resource(sourceOrFetcher, fetcherOrOptions, maybeOptions) {
|
|
|
844
848
|
});
|
|
845
849
|
runCallback("resource onError", () => options.onError?.(errorObj));
|
|
846
850
|
} finally {
|
|
847
|
-
if (version === fetchVersion) {
|
|
851
|
+
if (!disposed && version === fetchVersion) {
|
|
848
852
|
runCallback("resource onSettled", () => options.onSettled?.());
|
|
849
853
|
}
|
|
850
854
|
}
|
|
@@ -1151,15 +1155,54 @@ function syncAdapter(config) {
|
|
|
1151
1155
|
}
|
|
1152
1156
|
|
|
1153
1157
|
// src/data/routeLoader.ts
|
|
1154
|
-
var
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
+
var _clientScope = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.routeLoader.v2"), () => ({ stack: [] }));
|
|
1159
|
+
var _disposed = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.routeLoader.disposed.v1"), () => /* @__PURE__ */ new WeakSet());
|
|
1160
|
+
function currentScope() {
|
|
1161
|
+
const cache = getRequestScopedCache("routeLoader");
|
|
1162
|
+
if (!cache) return _clientScope;
|
|
1163
|
+
let scope = cache.get("scope");
|
|
1164
|
+
if (!scope) {
|
|
1165
|
+
scope = { stack: [] };
|
|
1166
|
+
cache.set("scope", scope);
|
|
1167
|
+
}
|
|
1168
|
+
return scope;
|
|
1169
|
+
}
|
|
1170
|
+
function executeLoader(loader, context, options) {
|
|
1171
|
+
const res = resource(({ signal: signal2 }) => loader(context, { signal: signal2 }), options);
|
|
1172
|
+
const disposeResource = res.dispose;
|
|
1173
|
+
res.dispose = () => {
|
|
1174
|
+
_disposed.add(res);
|
|
1175
|
+
disposeResource();
|
|
1176
|
+
};
|
|
1158
1177
|
return res;
|
|
1159
1178
|
}
|
|
1179
|
+
function renderWithLoader(loader, render) {
|
|
1180
|
+
if (_disposed.has(loader)) {
|
|
1181
|
+
throw new Error("renderWithLoader: the loader resource has been disposed");
|
|
1182
|
+
}
|
|
1183
|
+
const scope = currentScope();
|
|
1184
|
+
const entry = loader;
|
|
1185
|
+
scope.stack.push(entry);
|
|
1186
|
+
try {
|
|
1187
|
+
return render();
|
|
1188
|
+
} finally {
|
|
1189
|
+
const index = scope.stack.lastIndexOf(entry);
|
|
1190
|
+
if (index !== -1) scope.stack.splice(index, 1);
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
function withLoader(loader, context, render, options) {
|
|
1194
|
+
const res = executeLoader(loader, context, options);
|
|
1195
|
+
try {
|
|
1196
|
+
return { view: renderWithLoader(res, render), resource: res };
|
|
1197
|
+
} catch (err) {
|
|
1198
|
+
res.dispose();
|
|
1199
|
+
throw err;
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1160
1202
|
function loaderData() {
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1203
|
+
const scope = currentScope();
|
|
1204
|
+
const resource2 = scope.stack[scope.stack.length - 1];
|
|
1205
|
+
if (!resource2 || _disposed.has(resource2)) {
|
|
1163
1206
|
throw new Error("loaderData must be used inside a route with a loader");
|
|
1164
1207
|
}
|
|
1165
1208
|
return {
|
|
@@ -1168,7 +1211,7 @@ function loaderData() {
|
|
|
1168
1211
|
error: resource2.error
|
|
1169
1212
|
};
|
|
1170
1213
|
}
|
|
1171
|
-
async function preloadRoute(route,
|
|
1214
|
+
async function preloadRoute(route, context, callerSignal) {
|
|
1172
1215
|
if (!route.loader) return void 0;
|
|
1173
1216
|
const controller = new AbortController();
|
|
1174
1217
|
let onAbort = null;
|
|
@@ -1181,7 +1224,7 @@ async function preloadRoute(route, context2, callerSignal) {
|
|
|
1181
1224
|
}
|
|
1182
1225
|
}
|
|
1183
1226
|
try {
|
|
1184
|
-
return await route.loader(
|
|
1227
|
+
return await route.loader(context, { signal: controller.signal });
|
|
1185
1228
|
} finally {
|
|
1186
1229
|
if (onAbort) callerSignal?.removeEventListener("abort", onAbort);
|
|
1187
1230
|
}
|
|
@@ -1209,34 +1252,73 @@ function socket(url, options) {
|
|
|
1209
1252
|
let heartbeatTimer = null;
|
|
1210
1253
|
let disposed = false;
|
|
1211
1254
|
let manuallyClosed = false;
|
|
1255
|
+
let lifecycle = 0;
|
|
1212
1256
|
function getUrl() {
|
|
1213
1257
|
return typeof url === "function" ? url() : url;
|
|
1214
1258
|
}
|
|
1215
1259
|
function connect() {
|
|
1216
1260
|
if (disposed) return;
|
|
1261
|
+
const generation = lifecycle;
|
|
1262
|
+
const invalidated = () => disposed || generation !== lifecycle;
|
|
1217
1263
|
if (typeof WebSocket === "undefined") {
|
|
1218
1264
|
setStatus("closed");
|
|
1219
1265
|
return;
|
|
1220
1266
|
}
|
|
1221
|
-
|
|
1267
|
+
let rawUrl;
|
|
1268
|
+
try {
|
|
1269
|
+
rawUrl = getUrl();
|
|
1270
|
+
} catch (error) {
|
|
1271
|
+
setStatus("closed");
|
|
1272
|
+
reportError(error, { phase: "async", name: "socket" });
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
if (invalidated()) {
|
|
1276
|
+
setStatus("closed");
|
|
1277
|
+
return;
|
|
1278
|
+
}
|
|
1279
|
+
const safeUrl = validateWsUrl(rawUrl);
|
|
1222
1280
|
if (safeUrl === null) {
|
|
1223
1281
|
setStatus("closed");
|
|
1224
1282
|
return;
|
|
1225
1283
|
}
|
|
1226
1284
|
setStatus("connecting");
|
|
1227
|
-
|
|
1228
|
-
|
|
1285
|
+
if (invalidated()) {
|
|
1286
|
+
setStatus("closed");
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
let instance;
|
|
1290
|
+
try {
|
|
1291
|
+
instance = new WebSocket(safeUrl, protocols);
|
|
1292
|
+
} catch (error) {
|
|
1293
|
+
setStatus("closed");
|
|
1294
|
+
reportError(error, { phase: "async", name: "socket" });
|
|
1295
|
+
return;
|
|
1296
|
+
}
|
|
1297
|
+
if (invalidated()) {
|
|
1298
|
+
instance.close();
|
|
1299
|
+
setStatus("closed");
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
ws = instance;
|
|
1303
|
+
instance.onopen = () => {
|
|
1304
|
+
if (ws !== instance) return;
|
|
1305
|
+
const openGeneration = lifecycle;
|
|
1229
1306
|
setStatus("open");
|
|
1307
|
+
if (disposed || openGeneration !== lifecycle || ws !== instance) return;
|
|
1230
1308
|
reconnectCount = 0;
|
|
1231
1309
|
startHeartbeat();
|
|
1232
1310
|
};
|
|
1233
|
-
|
|
1311
|
+
instance.onmessage = (event) => {
|
|
1312
|
+
if (ws !== instance) return;
|
|
1234
1313
|
setData(event.data);
|
|
1235
1314
|
};
|
|
1236
|
-
|
|
1315
|
+
instance.onclose = () => {
|
|
1316
|
+
if (ws !== instance) return;
|
|
1317
|
+
ws = null;
|
|
1318
|
+
const closeGeneration = lifecycle;
|
|
1237
1319
|
setStatus("closed");
|
|
1238
1320
|
stopHeartbeat();
|
|
1239
|
-
const wasManual = manuallyClosed;
|
|
1321
|
+
const wasManual = manuallyClosed || closeGeneration !== lifecycle;
|
|
1240
1322
|
manuallyClosed = false;
|
|
1241
1323
|
if (autoReconnect && !disposed && !wasManual && reconnectCount < maxReconnects) {
|
|
1242
1324
|
const cap = 3e4;
|
|
@@ -1250,7 +1332,7 @@ function socket(url, options) {
|
|
|
1250
1332
|
}, jittered);
|
|
1251
1333
|
}
|
|
1252
1334
|
};
|
|
1253
|
-
|
|
1335
|
+
instance.onerror = () => {
|
|
1254
1336
|
};
|
|
1255
1337
|
}
|
|
1256
1338
|
function startHeartbeat() {
|
|
@@ -1274,13 +1356,23 @@ function socket(url, options) {
|
|
|
1274
1356
|
}
|
|
1275
1357
|
}
|
|
1276
1358
|
function close() {
|
|
1359
|
+
lifecycle++;
|
|
1277
1360
|
manuallyClosed = true;
|
|
1278
1361
|
if (reconnectTimer !== null) {
|
|
1279
1362
|
clearTimeout(reconnectTimer);
|
|
1280
1363
|
reconnectTimer = null;
|
|
1281
1364
|
}
|
|
1282
1365
|
stopHeartbeat();
|
|
1283
|
-
if (ws) {
|
|
1366
|
+
if (!ws) {
|
|
1367
|
+
setStatus("closed");
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
if (ws.readyState === WebSocket.CLOSED) {
|
|
1371
|
+
ws = null;
|
|
1372
|
+
setStatus("closed");
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
if (ws.readyState !== WebSocket.CLOSING) {
|
|
1284
1376
|
setStatus("closing");
|
|
1285
1377
|
ws.close();
|
|
1286
1378
|
}
|
|
@@ -1311,6 +1403,7 @@ function stream(url, options) {
|
|
|
1311
1403
|
let disposed = false;
|
|
1312
1404
|
let reconnectTimer = null;
|
|
1313
1405
|
let attempts = 0;
|
|
1406
|
+
let closeGeneration = 0;
|
|
1314
1407
|
function connect() {
|
|
1315
1408
|
if (disposed) return;
|
|
1316
1409
|
if (typeof EventSource === "undefined") {
|
|
@@ -1322,44 +1415,64 @@ function stream(url, options) {
|
|
|
1322
1415
|
setStatus("closed");
|
|
1323
1416
|
return;
|
|
1324
1417
|
}
|
|
1418
|
+
const generation = closeGeneration;
|
|
1325
1419
|
setStatus("connecting");
|
|
1326
|
-
|
|
1420
|
+
if (disposed || generation !== closeGeneration) return;
|
|
1421
|
+
const instance = new EventSource(safeUrl, {
|
|
1327
1422
|
withCredentials: options?.withCredentials ?? false
|
|
1328
1423
|
});
|
|
1329
|
-
|
|
1424
|
+
if (disposed || generation !== closeGeneration) {
|
|
1425
|
+
instance.close();
|
|
1426
|
+
return;
|
|
1427
|
+
}
|
|
1428
|
+
source = instance;
|
|
1429
|
+
const live = () => !disposed && source === instance;
|
|
1430
|
+
instance.onopen = () => {
|
|
1431
|
+
if (!live()) return;
|
|
1330
1432
|
setStatus("open");
|
|
1331
1433
|
attempts = 0;
|
|
1332
1434
|
};
|
|
1333
|
-
|
|
1435
|
+
instance.onmessage = (evt) => {
|
|
1436
|
+
if (!live()) return;
|
|
1334
1437
|
setData(evt.data);
|
|
1335
1438
|
setEvent(evt.type);
|
|
1336
1439
|
};
|
|
1337
|
-
|
|
1338
|
-
if (
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1440
|
+
instance.onerror = () => {
|
|
1441
|
+
if (!live() || instance.readyState !== EventSource.CLOSED) return;
|
|
1442
|
+
detach(instance);
|
|
1443
|
+
source = null;
|
|
1444
|
+
const generation2 = closeGeneration;
|
|
1445
|
+
setStatus("closed");
|
|
1446
|
+
if (disposed || generation2 !== closeGeneration) return;
|
|
1447
|
+
if (autoReconnect && attempts < maxReconnects) {
|
|
1448
|
+
const delay = Math.min(maxMs, baseMs * 2 ** attempts);
|
|
1449
|
+
const jittered = delay * (0.5 + Math.random() * 0.5);
|
|
1450
|
+
attempts++;
|
|
1451
|
+
reconnectTimer = setTimeout(() => {
|
|
1452
|
+
reconnectTimer = null;
|
|
1453
|
+
connect();
|
|
1454
|
+
}, jittered);
|
|
1350
1455
|
}
|
|
1351
1456
|
};
|
|
1352
1457
|
}
|
|
1458
|
+
function detach(instance) {
|
|
1459
|
+
instance.onopen = null;
|
|
1460
|
+
instance.onmessage = null;
|
|
1461
|
+
instance.onerror = null;
|
|
1462
|
+
}
|
|
1353
1463
|
function close() {
|
|
1464
|
+
closeGeneration++;
|
|
1354
1465
|
if (reconnectTimer !== null) {
|
|
1355
1466
|
clearTimeout(reconnectTimer);
|
|
1356
1467
|
reconnectTimer = null;
|
|
1357
1468
|
}
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
setStatus("closed");
|
|
1469
|
+
const instance = source;
|
|
1470
|
+
if (instance) {
|
|
1361
1471
|
source = null;
|
|
1472
|
+
detach(instance);
|
|
1473
|
+
instance.close();
|
|
1362
1474
|
}
|
|
1475
|
+
setStatus("closed");
|
|
1363
1476
|
}
|
|
1364
1477
|
function dispose() {
|
|
1365
1478
|
disposed = true;
|
|
@@ -1387,6 +1500,8 @@ export {
|
|
|
1387
1500
|
offlineStore,
|
|
1388
1501
|
syncAdapter,
|
|
1389
1502
|
executeLoader,
|
|
1503
|
+
renderWithLoader,
|
|
1504
|
+
withLoader,
|
|
1390
1505
|
loaderData,
|
|
1391
1506
|
preloadRoute,
|
|
1392
1507
|
socket,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
recordDependency,
|
|
5
5
|
retrack,
|
|
6
6
|
track
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5Q4R7HCL.js";
|
|
8
8
|
import {
|
|
9
9
|
devAssert
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-NYNYSPK7.js";
|
|
11
11
|
|
|
12
12
|
// src/core/signals/derived.ts
|
|
13
13
|
function derived(getter, options) {
|