sibujs 4.4.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/README.md +11 -0
- package/dist/browser.cjs +339 -130
- package/dist/browser.d.cts +61 -16
- package/dist/browser.d.ts +61 -16
- package/dist/browser.js +8 -6
- package/dist/build.cjs +273 -82
- 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-VCTAEPSB.js → chunk-47M47FOM.js} +11 -3
- package/dist/chunk-5HZXGZ6T.js +24 -0
- package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
- package/dist/{chunk-3BTTCZ5J.js → chunk-5Q4R7HCL.js} +42 -4
- package/dist/{chunk-ADM46X22.js → chunk-7GQCWFOE.js} +157 -61
- package/dist/{chunk-4Z3SPQ67.js → chunk-7NCARGJW.js} +16 -8
- package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
- package/dist/{chunk-LQFGQNMV.js → chunk-AIF3Z2T7.js} +302 -39
- package/dist/{chunk-UCALUKB5.js → chunk-BAAG6ZTI.js} +98 -29
- package/dist/{chunk-NVNJH22U.js → chunk-D33YTSX5.js} +2 -2
- package/dist/{chunk-M2F7TZHH.js → chunk-DKGBBKOF.js} +136 -80
- package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
- package/dist/{chunk-HFCOH2GN.js → chunk-HYXDKS4N.js} +153 -110
- package/dist/chunk-J6FW5TV6.js +233 -0
- package/dist/{chunk-36S2YPP4.js → chunk-JSXPZCET.js} +1 -1
- package/dist/chunk-NYNYSPK7.js +318 -0
- package/dist/{chunk-HQSEH5F6.js → chunk-ORMZXBKQ.js} +108 -45
- package/dist/{chunk-LYVUX7NT.js → chunk-OXUY2A6L.js} +287 -130
- package/dist/{chunk-6GSIXTWX.js → chunk-PK6FK2G2.js} +187 -66
- package/dist/{chunk-W2EQ7X2L.js → chunk-QE4TTDU3.js} +47 -9
- package/dist/{chunk-XLO7SLIX.js → chunk-SXXVZMKZ.js} +262 -70
- package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
- package/dist/{chunk-RR7M3FHM.js → chunk-UZQ6ALFS.js} +3 -3
- package/dist/{chunk-PNIRUQ4C.js → chunk-VVWPJ543.js} +6 -8
- package/dist/{chunk-7GIHSAWB.js → chunk-XC4MEKGA.js} +3 -3
- package/dist/{chunk-SKPTERHP.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-CNZxEB9G.d.ts → customElement-MmInOW1U.d.cts} +59 -10
- package/dist/{customElement-CNZxEB9G.d.cts → customElement-MmInOW1U.d.ts} +59 -10
- package/dist/data.cjs +293 -125
- package/dist/data.d.cts +47 -9
- package/dist/data.d.ts +47 -9
- package/dist/data.js +12 -9
- package/dist/devtools.cjs +121 -58
- package/dist/devtools.js +7 -8
- package/dist/dispose-GEIG2KOF.js +28 -0
- package/dist/ecosystem.cjs +391 -112
- package/dist/ecosystem.d.cts +31 -7
- package/dist/ecosystem.d.ts +31 -7
- package/dist/ecosystem.js +12 -12
- package/dist/extras.cjs +2250 -879
- package/dist/extras.d.cts +10 -9
- package/dist/extras.d.ts +10 -9
- package/dist/extras.js +39 -28
- package/dist/index.cjs +273 -82
- package/dist/index.d.cts +44 -154
- package/dist/index.d.ts +44 -154
- package/dist/index.js +24 -27
- package/dist/motion.cjs +137 -42
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +397 -48
- package/dist/patterns.d.cts +32 -9
- package/dist/patterns.d.ts +32 -9
- package/dist/patterns.js +8 -8
- package/dist/performance.cjs +338 -217
- 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 +587 -203
- 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 +214 -73
- 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-DFstCLQV.d.cts +117 -0
- package/dist/tagFactory-DkaNVUNV.d.ts +117 -0
- package/dist/testing.cjs +2481 -2153
- package/dist/testing.d.cts +56 -5
- package/dist/testing.d.ts +56 -5
- package/dist/testing.js +580 -307
- package/dist/ui.cjs +798 -328
- package/dist/ui.d.cts +40 -7
- package/dist/ui.d.ts +40 -7
- package/dist/ui.js +151 -56
- package/dist/widgets.cjs +319 -285
- package/dist/widgets.js +9 -10
- package/package.json +2 -2
- package/dist/chunk-2WLZ6757.js +0 -149
- package/dist/chunk-7NBDXVHS.js +0 -60
- package/dist/chunk-CCSJMTRN.js +0 -15
- package/dist/chunk-QKRPLZ2V.js +0 -108
- 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
- package/dist/tagFactory-Bzupt4Pj.d.cts +0 -55
- package/dist/tagFactory-Bzupt4Pj.d.ts +0 -55
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sanitizeUrl
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2INLLLMZ.js";
|
|
4
4
|
import {
|
|
5
5
|
globalSingleton
|
|
6
6
|
} from "./chunk-7ZHH77QA.js";
|
|
7
7
|
import {
|
|
8
8
|
effect
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import {
|
|
11
|
-
dispose,
|
|
12
|
-
replaceChildrenSafely
|
|
13
|
-
} from "./chunk-QKRPLZ2V.js";
|
|
9
|
+
} from "./chunk-XC4MEKGA.js";
|
|
14
10
|
import {
|
|
15
11
|
signal
|
|
16
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-D33YTSX5.js";
|
|
17
13
|
import {
|
|
18
14
|
DEV,
|
|
19
15
|
devWarn,
|
|
16
|
+
dispose,
|
|
17
|
+
registerDisposer,
|
|
18
|
+
replaceChildrenSafely,
|
|
20
19
|
reportError
|
|
21
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-NYNYSPK7.js";
|
|
22
21
|
|
|
23
22
|
// src/performance/scheduler.ts
|
|
24
23
|
var Priority = {
|
|
@@ -44,28 +43,34 @@ function insertTask(task) {
|
|
|
44
43
|
}
|
|
45
44
|
taskQueue.splice(i, 0, task);
|
|
46
45
|
}
|
|
46
|
+
function runTask(callback) {
|
|
47
|
+
try {
|
|
48
|
+
callback();
|
|
49
|
+
} catch (err) {
|
|
50
|
+
reportError(err, { phase: "scheduler", name: "scheduleUpdate" });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
47
53
|
function processQueue() {
|
|
48
54
|
if (_sched.isProcessing || taskQueue.length === 0) return;
|
|
49
55
|
_sched.isProcessing = true;
|
|
50
56
|
const startTime = performance.now();
|
|
51
57
|
const timeSlice = 5;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
try {
|
|
59
|
+
while (taskQueue.length > 0) {
|
|
60
|
+
const task = taskQueue[0];
|
|
61
|
+
if (task.cancelled) {
|
|
62
|
+
taskQueue.shift();
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (task.priority > Priority.IMMEDIATE && performance.now() - startTime > timeSlice) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
55
68
|
taskQueue.shift();
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
if (task.priority > Priority.IMMEDIATE && performance.now() - startTime > timeSlice) {
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
taskQueue.shift();
|
|
62
|
-
try {
|
|
63
|
-
task.callback();
|
|
64
|
-
} catch (e) {
|
|
65
|
-
console.error("[Scheduler] Task error:", e);
|
|
69
|
+
runTask(task.callback);
|
|
66
70
|
}
|
|
71
|
+
} finally {
|
|
72
|
+
_sched.isProcessing = false;
|
|
67
73
|
}
|
|
68
|
-
_sched.isProcessing = false;
|
|
69
74
|
if (taskQueue.length > 0) {
|
|
70
75
|
scheduleFrame();
|
|
71
76
|
}
|
|
@@ -133,11 +138,7 @@ function scheduleUpdate(priority, callback) {
|
|
|
133
138
|
cancelled: false
|
|
134
139
|
};
|
|
135
140
|
if (priority === Priority.IMMEDIATE) {
|
|
136
|
-
|
|
137
|
-
callback();
|
|
138
|
-
} catch (e) {
|
|
139
|
-
console.error("[Scheduler] Immediate task error:", e);
|
|
140
|
-
}
|
|
141
|
+
runTask(callback);
|
|
141
142
|
return () => {
|
|
142
143
|
};
|
|
143
144
|
}
|
|
@@ -157,14 +158,15 @@ function flushScheduler() {
|
|
|
157
158
|
_sched.scheduledHandle = null;
|
|
158
159
|
_sched.scheduledKind = null;
|
|
159
160
|
_sched.microtaskScheduled = false;
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
task.callback
|
|
161
|
+
try {
|
|
162
|
+
while (taskQueue.length > 0) {
|
|
163
|
+
const task = taskQueue.shift();
|
|
164
|
+
if (!task) break;
|
|
165
|
+
if (!task.cancelled) runTask(task.callback);
|
|
165
166
|
}
|
|
167
|
+
} finally {
|
|
168
|
+
_sched.isProcessing = false;
|
|
166
169
|
}
|
|
167
|
-
_sched.isProcessing = false;
|
|
168
170
|
}
|
|
169
171
|
function pendingTasks() {
|
|
170
172
|
return taskQueue.filter((t) => !t.cancelled).length;
|
|
@@ -300,11 +302,16 @@ function getDOMPool() {
|
|
|
300
302
|
return _defaultPool;
|
|
301
303
|
}
|
|
302
304
|
var preloadedResources = /* @__PURE__ */ new Set();
|
|
305
|
+
function hintKey(rel, as, crossorigin, href) {
|
|
306
|
+
return `${rel}\0${as}\0${crossorigin}\0${href}`;
|
|
307
|
+
}
|
|
303
308
|
function preloadResource(url, type = "fetch") {
|
|
304
309
|
const safe = sanitizeUrl(url);
|
|
305
310
|
if (!safe) return;
|
|
306
|
-
|
|
307
|
-
|
|
311
|
+
const as = type === "script" || type === "style" || type === "image" ? type : "fetch";
|
|
312
|
+
const key = hintKey("preload", as, as === "fetch" ? "anonymous" : "", safe);
|
|
313
|
+
if (preloadedResources.has(key)) return;
|
|
314
|
+
preloadedResources.add(key);
|
|
308
315
|
const link = document.createElement("link");
|
|
309
316
|
link.rel = "preload";
|
|
310
317
|
link.href = safe;
|
|
@@ -327,8 +334,9 @@ function preloadResource(url, type = "fetch") {
|
|
|
327
334
|
function prefetch(url) {
|
|
328
335
|
const safe = sanitizeUrl(url);
|
|
329
336
|
if (!safe) return;
|
|
330
|
-
|
|
331
|
-
preloadedResources.
|
|
337
|
+
const key = hintKey("prefetch", "", "", safe);
|
|
338
|
+
if (preloadedResources.has(key)) return;
|
|
339
|
+
preloadedResources.add(key);
|
|
332
340
|
const link = document.createElement("link");
|
|
333
341
|
link.rel = "prefetch";
|
|
334
342
|
link.href = safe;
|
|
@@ -391,65 +399,92 @@ function block(factory) {
|
|
|
391
399
|
}
|
|
392
400
|
|
|
393
401
|
// src/performance/normalize.ts
|
|
402
|
+
function dict(source) {
|
|
403
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
404
|
+
if (source) {
|
|
405
|
+
for (const key of Object.keys(source)) defineOwn(out, key, source[key]);
|
|
406
|
+
}
|
|
407
|
+
return out;
|
|
408
|
+
}
|
|
409
|
+
function ownGet(obj, key) {
|
|
410
|
+
return obj !== void 0 && Object.hasOwn(obj, key) ? obj[key] : void 0;
|
|
411
|
+
}
|
|
412
|
+
function defineOwn(obj, key, value) {
|
|
413
|
+
Object.defineProperty(obj, key, { value, writable: true, enumerable: true, configurable: true });
|
|
414
|
+
}
|
|
415
|
+
function readEntityId(entity, idKey, typeName) {
|
|
416
|
+
const raw = entity !== null && typeof entity === "object" && Object.hasOwn(entity, idKey) ? entity[idKey] : void 0;
|
|
417
|
+
if (typeof raw === "string") return raw;
|
|
418
|
+
if (typeof raw === "number" && Number.isFinite(raw)) return String(raw);
|
|
419
|
+
throw new TypeError(
|
|
420
|
+
`[normalize] "${typeName}" entity has no valid "${idKey}" (expected a string or finite number, got ${raw === null ? "null" : typeof raw})`
|
|
421
|
+
);
|
|
422
|
+
}
|
|
394
423
|
function normalizedStore(schema) {
|
|
395
424
|
const idKey = schema.idKey || "id";
|
|
396
425
|
const [getState, setState] = signal({
|
|
397
426
|
ids: [],
|
|
398
|
-
entities:
|
|
427
|
+
entities: dict()
|
|
399
428
|
});
|
|
400
|
-
const idOf = (entity) =>
|
|
429
|
+
const idOf = (entity) => readEntityId(entity, idKey, schema.name);
|
|
401
430
|
function add(entity) {
|
|
402
431
|
const id = idOf(entity);
|
|
403
432
|
setState((prev) => {
|
|
404
|
-
const ids = prev.
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
};
|
|
433
|
+
const ids = Object.hasOwn(prev.entities, id) ? prev.ids : [...prev.ids, id];
|
|
434
|
+
const entities = dict(prev.entities);
|
|
435
|
+
defineOwn(entities, id, entity);
|
|
436
|
+
return { ids, entities };
|
|
409
437
|
});
|
|
410
438
|
}
|
|
411
439
|
function addMany(entities) {
|
|
440
|
+
const ids = entities.map(idOf);
|
|
412
441
|
setState((prev) => {
|
|
413
442
|
const nextIds = [...prev.ids];
|
|
414
|
-
const nextEntities =
|
|
415
|
-
|
|
416
|
-
const id =
|
|
417
|
-
if (!
|
|
443
|
+
const nextEntities = dict(prev.entities);
|
|
444
|
+
entities.forEach((entity, i) => {
|
|
445
|
+
const id = ids[i];
|
|
446
|
+
if (!Object.hasOwn(nextEntities, id)) {
|
|
418
447
|
nextIds.push(id);
|
|
419
448
|
}
|
|
420
|
-
nextEntities
|
|
421
|
-
}
|
|
449
|
+
defineOwn(nextEntities, id, entity);
|
|
450
|
+
});
|
|
422
451
|
return { ids: nextIds, entities: nextEntities };
|
|
423
452
|
});
|
|
424
453
|
}
|
|
425
454
|
function get(id) {
|
|
426
|
-
|
|
427
|
-
return state.entities[id];
|
|
455
|
+
return ownGet(getState().entities, id);
|
|
428
456
|
}
|
|
429
457
|
function getAll() {
|
|
430
458
|
const state = getState();
|
|
431
459
|
return state.ids.map((id) => state.entities[id]);
|
|
432
460
|
}
|
|
433
461
|
function update(id, partial) {
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
462
|
+
const prev = getState();
|
|
463
|
+
if (!Object.hasOwn(prev.entities, id)) return;
|
|
464
|
+
if (partial !== null && typeof partial === "object" && Object.hasOwn(partial, idKey)) {
|
|
465
|
+
const nextId = readEntityId(partial, idKey, schema.name);
|
|
466
|
+
if (nextId !== id) {
|
|
467
|
+
throw new Error(
|
|
468
|
+
`[normalizedStore] update("${id}") cannot change "${idKey}" to "${nextId}"; remove and re-add the entity instead.`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
setState((current) => {
|
|
473
|
+
const existing = ownGet(current.entities, id);
|
|
474
|
+
if (!existing) return current;
|
|
475
|
+
const entities = dict(current.entities);
|
|
476
|
+
defineOwn(entities, id, { ...existing, ...partial });
|
|
477
|
+
return { ids: current.ids, entities };
|
|
444
478
|
});
|
|
445
479
|
}
|
|
446
480
|
function remove(id) {
|
|
447
481
|
setState((prev) => {
|
|
448
|
-
if (!prev.entities
|
|
449
|
-
const
|
|
482
|
+
if (!Object.hasOwn(prev.entities, id)) return prev;
|
|
483
|
+
const entities = dict(prev.entities);
|
|
484
|
+
delete entities[id];
|
|
450
485
|
return {
|
|
451
486
|
ids: prev.ids.filter((existingId) => existingId !== id),
|
|
452
|
-
entities
|
|
487
|
+
entities
|
|
453
488
|
};
|
|
454
489
|
});
|
|
455
490
|
}
|
|
@@ -460,31 +495,37 @@ function normalizedStore(schema) {
|
|
|
460
495
|
return { add, addMany, get, getAll, update, remove, select, getState };
|
|
461
496
|
}
|
|
462
497
|
function normalize(data, schema) {
|
|
463
|
-
const entities =
|
|
498
|
+
const entities = dict();
|
|
464
499
|
function ensureTable(name) {
|
|
465
|
-
|
|
466
|
-
|
|
500
|
+
let table = ownGet(entities, name);
|
|
501
|
+
if (!table) {
|
|
502
|
+
table = dict();
|
|
503
|
+
defineOwn(entities, name, table);
|
|
467
504
|
}
|
|
468
|
-
return
|
|
505
|
+
return table;
|
|
469
506
|
}
|
|
470
507
|
function normalizeEntity(entity, entitySchema) {
|
|
471
508
|
const entityIdKey = entitySchema.idKey || "id";
|
|
472
|
-
const id =
|
|
509
|
+
const id = readEntityId(entity, entityIdKey, entitySchema.name);
|
|
473
510
|
const table = ensureTable(entitySchema.name);
|
|
474
511
|
const flat = { ...entity };
|
|
475
512
|
if (entitySchema.relations) {
|
|
476
513
|
for (const [field, relationType] of Object.entries(entitySchema.relations)) {
|
|
477
|
-
const value = entity[field];
|
|
514
|
+
const value = Object.hasOwn(entity, field) ? entity[field] : void 0;
|
|
478
515
|
if (value == null) continue;
|
|
479
516
|
const relSchema = { name: relationType };
|
|
480
517
|
if (Array.isArray(value)) {
|
|
481
|
-
|
|
518
|
+
defineOwn(
|
|
519
|
+
flat,
|
|
520
|
+
field,
|
|
521
|
+
value.map((item) => normalizeEntity(item, relSchema))
|
|
522
|
+
);
|
|
482
523
|
} else if (typeof value === "object") {
|
|
483
|
-
flat
|
|
524
|
+
defineOwn(flat, field, normalizeEntity(value, relSchema));
|
|
484
525
|
}
|
|
485
526
|
}
|
|
486
527
|
}
|
|
487
|
-
table
|
|
528
|
+
defineOwn(table, id, flat);
|
|
488
529
|
return id;
|
|
489
530
|
}
|
|
490
531
|
if (Array.isArray(data)) {
|
|
@@ -495,20 +536,24 @@ function normalize(data, schema) {
|
|
|
495
536
|
return { result, entities };
|
|
496
537
|
}
|
|
497
538
|
function denormalize(id, entities, schema) {
|
|
498
|
-
const table = entities
|
|
539
|
+
const table = ownGet(entities, schema.name);
|
|
499
540
|
if (!table) return void 0;
|
|
500
|
-
const entity = table
|
|
541
|
+
const entity = ownGet(table, id);
|
|
501
542
|
if (!entity) return void 0;
|
|
502
543
|
const result = { ...entity };
|
|
503
544
|
if (schema.relations) {
|
|
504
545
|
for (const [field, relationType] of Object.entries(schema.relations)) {
|
|
505
|
-
const value = entity
|
|
546
|
+
const value = ownGet(entity, field);
|
|
506
547
|
if (value == null) continue;
|
|
507
548
|
const relSchema = { name: relationType };
|
|
508
549
|
if (Array.isArray(value)) {
|
|
509
|
-
|
|
550
|
+
defineOwn(
|
|
551
|
+
result,
|
|
552
|
+
field,
|
|
553
|
+
value.map((relId) => denormalize(relId, entities, relSchema))
|
|
554
|
+
);
|
|
510
555
|
} else if (typeof value === "string") {
|
|
511
|
-
result
|
|
556
|
+
defineOwn(result, field, denormalize(value, entities, relSchema));
|
|
512
557
|
}
|
|
513
558
|
}
|
|
514
559
|
}
|
|
@@ -718,13 +763,24 @@ function lazyChunk(id, loader, registry, fallback) {
|
|
|
718
763
|
if (fallback) {
|
|
719
764
|
container.appendChild(fallback());
|
|
720
765
|
}
|
|
766
|
+
let disposed = false;
|
|
767
|
+
registerDisposer(container, () => {
|
|
768
|
+
disposed = true;
|
|
769
|
+
});
|
|
721
770
|
registry.load(id, async () => {
|
|
722
771
|
const mod = await loader();
|
|
723
772
|
return typeof mod === "function" ? mod : mod.default;
|
|
724
773
|
}).then((component) => {
|
|
774
|
+
if (disposed) return;
|
|
775
|
+
const node = component();
|
|
776
|
+
if (disposed) {
|
|
777
|
+
dispose(node);
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
725
780
|
clearChildren(container);
|
|
726
|
-
container.appendChild(
|
|
781
|
+
container.appendChild(node);
|
|
727
782
|
}).catch((err) => {
|
|
783
|
+
if (disposed) return;
|
|
728
784
|
clearChildren(container);
|
|
729
785
|
const errorEl = document.createElement("div");
|
|
730
786
|
errorEl.textContent = `Failed to load chunk '${id}': ${err.message}`;
|
|
@@ -6,17 +6,15 @@ import {
|
|
|
6
6
|
sanitizeAttributeString,
|
|
7
7
|
sanitizeUrl,
|
|
8
8
|
stripControlChars
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-2INLLLMZ.js";
|
|
10
10
|
import {
|
|
11
11
|
getSSRStore
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-7XHATCIH.js";
|
|
13
13
|
import {
|
|
14
|
+
DEV,
|
|
14
15
|
dispose,
|
|
15
16
|
replaceChildrenSafely
|
|
16
|
-
} from "./chunk-
|
|
17
|
-
import {
|
|
18
|
-
DEV
|
|
19
|
-
} from "./chunk-2WLZ6757.js";
|
|
17
|
+
} from "./chunk-NYNYSPK7.js";
|
|
20
18
|
|
|
21
19
|
// src/utils/metaRefresh.ts
|
|
22
20
|
function isAsciiWhitespace(ch) {
|
|
@@ -446,7 +444,7 @@ function renderToDocument(component, options = {}) {
|
|
|
446
444
|
<head>
|
|
447
445
|
<meta charset="UTF-8" />
|
|
448
446
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
449
|
-
${options.title ? `<title>${escapeHtml(options.title)}</title>` : ""}
|
|
447
|
+
${options.title != null ? `<title>${escapeHtml(options.title)}</title>` : ""}
|
|
450
448
|
${metaTags}
|
|
451
449
|
${linkTags}
|
|
452
450
|
${options.headExtra || ""}
|
|
@@ -621,16 +619,32 @@ function ssrSuspense(props) {
|
|
|
621
619
|
const timeoutPromise = new Promise((_, reject) => {
|
|
622
620
|
timer = setTimeout(() => reject(new Error(`[SibuJS SSR] ssrSuspense timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
623
621
|
});
|
|
624
|
-
|
|
622
|
+
let contentPromise;
|
|
623
|
+
try {
|
|
624
|
+
contentPromise = Promise.resolve(props.content());
|
|
625
|
+
} catch (err) {
|
|
626
|
+
contentPromise = Promise.reject(err);
|
|
627
|
+
}
|
|
628
|
+
const toFallback = (err) => {
|
|
629
|
+
if (DEV) console.warn("[SibuJS SSR] ssrSuspense rejected:", err);
|
|
630
|
+
return { id, html: fallbackHtml };
|
|
631
|
+
};
|
|
632
|
+
const clearTimer = () => {
|
|
633
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
634
|
+
};
|
|
635
|
+
const raced = Promise.race([contentPromise, timeoutPromise]);
|
|
625
636
|
const promise = raced.then(
|
|
626
637
|
(resolvedEl) => {
|
|
627
|
-
|
|
628
|
-
|
|
638
|
+
clearTimer();
|
|
639
|
+
try {
|
|
640
|
+
return { id, html: renderToString(resolvedEl) };
|
|
641
|
+
} catch (err) {
|
|
642
|
+
return toFallback(err);
|
|
643
|
+
}
|
|
629
644
|
},
|
|
630
645
|
(err) => {
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
return { id, html: fallbackHtml };
|
|
646
|
+
clearTimer();
|
|
647
|
+
return toFallback(err);
|
|
634
648
|
}
|
|
635
649
|
);
|
|
636
650
|
promise.catch(noop);
|