sibujs 4.5.0 → 4.7.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.
Files changed (116) hide show
  1. package/README.md +1 -1
  2. package/dist/browser.cjs +326 -133
  3. package/dist/browser.d.cts +46 -14
  4. package/dist/browser.d.ts +46 -14
  5. package/dist/browser.js +8 -6
  6. package/dist/build.cjs +2094 -1033
  7. package/dist/build.d.cts +133 -44
  8. package/dist/build.d.ts +133 -44
  9. package/dist/build.js +1372 -574
  10. package/dist/cdn.dev.global.js +10 -10
  11. package/dist/cdn.full.dev.global.js +11 -11
  12. package/dist/cdn.full.global.js +10 -10
  13. package/dist/cdn.global.js +10 -10
  14. package/dist/{chunk-2DCGACUU.js → chunk-2BPG2XDA.js} +251 -66
  15. package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
  16. package/dist/{chunk-4PMLNECI.js → chunk-3QWBSL5R.js} +98 -29
  17. package/dist/{chunk-KKLW7YWL.js → chunk-4AWA2PVD.js} +275 -144
  18. package/dist/chunk-5HZXGZ6T.js +24 -0
  19. package/dist/{chunk-PCT43HW3.js → chunk-7LUJQAOJ.js} +1 -1
  20. package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
  21. package/dist/chunk-BC2SECJD.js +44 -0
  22. package/dist/{chunk-TBYTO6BS.js → chunk-BSY63EM6.js} +136 -80
  23. package/dist/{chunk-FTIR4QW2.js → chunk-DKXRACVN.js} +6 -8
  24. package/dist/{chunk-ONOHFDLG.js → chunk-FNJXNGYZ.js} +3 -3
  25. package/dist/{chunk-XZZOBQAY.js → chunk-FQRUXCEE.js} +6 -5
  26. package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
  27. package/dist/chunk-J6FW5TV6.js +233 -0
  28. package/dist/{chunk-UGRX3S57.js → chunk-JWKYU5GV.js} +22 -4
  29. package/dist/chunk-NYNYSPK7.js +318 -0
  30. package/dist/{chunk-RBTPLM32.js → chunk-RUSSKG6G.js} +13 -12
  31. package/dist/{chunk-7LN645I6.js → chunk-SLM3IA34.js} +3 -3
  32. package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
  33. package/dist/{chunk-B3WHI2QA.js → chunk-UNWRJRKC.js} +55 -31
  34. package/dist/{chunk-KEISJXBU.js → chunk-UOL2ECCS.js} +44 -17
  35. package/dist/{chunk-RJE2BNI4.js → chunk-VZSG24LS.js} +108 -45
  36. package/dist/{chunk-RIXRAYIU.js → chunk-WEQ3DMVL.js} +10 -4
  37. package/dist/{chunk-3JZ4L5TJ.js → chunk-WOLJZUFQ.js} +354 -90
  38. package/dist/{chunk-S373NSMK.js → chunk-XYV3EDB7.js} +283 -123
  39. package/dist/{chunk-VZKNK2V7.js → chunk-XZR4PXRE.js} +296 -38
  40. package/dist/{chunk-GW3SCCZG.js → chunk-Z3OHK6QT.js} +153 -110
  41. package/dist/{chunk-OMJJM3KM.js → chunk-ZVL7TY4K.js} +287 -130
  42. package/dist/{contracts-DBdg9J_a.d.ts → contracts-CLqzJnOV.d.ts} +36 -17
  43. package/dist/{contracts-DBdg9J_a.d.cts → contracts-CTOJXu-x.d.cts} +36 -17
  44. package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
  45. package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
  46. package/dist/data.cjs +410 -155
  47. package/dist/data.d.cts +166 -12
  48. package/dist/data.d.ts +166 -12
  49. package/dist/data.js +12 -9
  50. package/dist/devtools.cjs +98 -61
  51. package/dist/devtools.js +7 -8
  52. package/dist/dispose-GEIG2KOF.js +28 -0
  53. package/dist/ecosystem.cjs +372 -126
  54. package/dist/ecosystem.d.cts +20 -3
  55. package/dist/ecosystem.d.ts +20 -3
  56. package/dist/ecosystem.js +12 -12
  57. package/dist/extras.cjs +2366 -909
  58. package/dist/extras.d.cts +11 -9
  59. package/dist/extras.d.ts +11 -9
  60. package/dist/extras.js +39 -28
  61. package/dist/index.cjs +421 -158
  62. package/dist/index.d.cts +213 -171
  63. package/dist/index.d.ts +213 -171
  64. package/dist/index.js +24 -27
  65. package/dist/motion.cjs +118 -44
  66. package/dist/motion.js +5 -5
  67. package/dist/patterns.cjs +344 -53
  68. package/dist/patterns.d.cts +28 -9
  69. package/dist/patterns.d.ts +28 -9
  70. package/dist/patterns.js +8 -8
  71. package/dist/performance.cjs +325 -220
  72. package/dist/performance.d.cts +2 -2
  73. package/dist/performance.d.ts +2 -2
  74. package/dist/performance.js +8 -9
  75. package/dist/plugin-DVgSnTfK.d.cts +112 -0
  76. package/dist/plugin-DVgSnTfK.d.ts +112 -0
  77. package/dist/plugins.cjs +664 -233
  78. package/dist/plugins.d.cts +127 -14
  79. package/dist/plugins.d.ts +127 -14
  80. package/dist/plugins.js +96 -42
  81. package/dist/signal-EotCj4hS.d.cts +110 -0
  82. package/dist/signal-EotCj4hS.d.ts +110 -0
  83. package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
  84. package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
  85. package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
  86. package/dist/ssr.cjs +229 -84
  87. package/dist/ssr.d.cts +9 -3
  88. package/dist/ssr.d.ts +9 -3
  89. package/dist/ssr.js +11 -12
  90. package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
  91. package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
  92. package/dist/tagFactory-8qL9LCIx.d.cts +156 -0
  93. package/dist/tagFactory-BL2fymez.d.ts +156 -0
  94. package/dist/testing.cjs +2503 -2191
  95. package/dist/testing.d.cts +56 -5
  96. package/dist/testing.d.ts +56 -5
  97. package/dist/testing.js +580 -307
  98. package/dist/types-CJFViL6Q.d.cts +26 -0
  99. package/dist/types-CJFViL6Q.d.ts +26 -0
  100. package/dist/ui.cjs +732 -329
  101. package/dist/ui.d.cts +41 -7
  102. package/dist/ui.d.ts +41 -7
  103. package/dist/ui.js +151 -56
  104. package/dist/widgets.cjs +267 -291
  105. package/dist/widgets.js +9 -10
  106. package/package.json +4 -2
  107. package/dist/chunk-2WLZ6757.js +0 -149
  108. package/dist/chunk-CCSJMTRN.js +0 -15
  109. package/dist/chunk-QKRPLZ2V.js +0 -108
  110. package/dist/chunk-VUF4ALSW.js +0 -60
  111. package/dist/chunk-WWV3SJ3L.js +0 -131
  112. package/dist/dispose-46BOMMQJ.js +0 -19
  113. package/dist/plugin-D30wlGW5.d.cts +0 -71
  114. package/dist/plugin-D30wlGW5.d.ts +0 -71
  115. package/dist/tagFactory-DVoDpHye.d.cts +0 -215
  116. package/dist/tagFactory-DVoDpHye.d.ts +0 -215
@@ -0,0 +1,44 @@
1
+ import {
2
+ getRequestStore,
3
+ isSSR
4
+ } from "./chunk-7XHATCIH.js";
5
+ import {
6
+ reactiveBinding
7
+ } from "./chunk-JWKYU5GV.js";
8
+
9
+ // src/core/rendering/createId.ts
10
+ var COUNTER_KEY = /* @__PURE__ */ Symbol.for("sibujs.createId.v1");
11
+ var _counter = globalThis[COUNTER_KEY] ?? (globalThis[COUNTER_KEY] = { n: 0 });
12
+ function createId(prefix = "sibu") {
13
+ const request = getRequestStore();
14
+ if (request) {
15
+ request.idCounter = (request.idCounter ?? 0) + 1;
16
+ return `${prefix}-${request.idCounter}`;
17
+ }
18
+ _counter.n++;
19
+ return `${prefix}-${_counter.n}`;
20
+ }
21
+ function __resetIdCounter() {
22
+ _counter.n = 0;
23
+ }
24
+ function idSegment(key) {
25
+ let out = "";
26
+ for (const ch of String(key)) {
27
+ out += /[A-Za-z0-9-]/.test(ch) ? ch : `_${(ch.codePointAt(0) ?? 0).toString(16)}_`;
28
+ }
29
+ return out;
30
+ }
31
+
32
+ // src/reactivity/domBinding.ts
33
+ function domBinding(commit, ownerNode) {
34
+ if (isSSR()) return () => {
35
+ };
36
+ return reactiveBinding(commit, ownerNode);
37
+ }
38
+
39
+ export {
40
+ createId,
41
+ __resetIdCounter,
42
+ idSegment,
43
+ domBinding
44
+ };
@@ -1,24 +1,23 @@
1
1
  import {
2
2
  sanitizeUrl
3
- } from "./chunk-IXKSNWV5.js";
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-RIXRAYIU.js";
10
- import {
11
- dispose,
12
- replaceChildrenSafely
13
- } from "./chunk-QKRPLZ2V.js";
9
+ } from "./chunk-WEQ3DMVL.js";
14
10
  import {
15
11
  signal
16
- } from "./chunk-XZZOBQAY.js";
12
+ } from "./chunk-FQRUXCEE.js";
17
13
  import {
18
14
  DEV,
19
15
  devWarn,
16
+ dispose,
17
+ registerDisposer,
18
+ replaceChildrenSafely,
20
19
  reportError
21
- } from "./chunk-2WLZ6757.js";
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
- while (taskQueue.length > 0) {
53
- const task = taskQueue[0];
54
- if (task.cancelled) {
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
- continue;
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
- try {
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
- while (taskQueue.length > 0) {
161
- const task = taskQueue.shift();
162
- if (!task) break;
163
- if (!task.cancelled) {
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
- if (preloadedResources.has(safe)) return;
307
- preloadedResources.add(safe);
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
- if (preloadedResources.has(safe)) return;
331
- preloadedResources.add(safe);
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) => String(entity[idKey]);
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.ids.includes(id) ? prev.ids : [...prev.ids, id];
405
- return {
406
- ids,
407
- entities: { ...prev.entities, [id]: entity }
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 = { ...prev.entities };
415
- for (const entity of entities) {
416
- const id = idOf(entity);
417
- if (!nextIds.includes(id)) {
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[id] = entity;
421
- }
449
+ defineOwn(nextEntities, id, entity);
450
+ });
422
451
  return { ids: nextIds, entities: nextEntities };
423
452
  });
424
453
  }
425
454
  function get(id) {
426
- const state = getState();
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
- setState((prev) => {
435
- const existing = prev.entities[id];
436
- if (!existing) return prev;
437
- return {
438
- ids: prev.ids,
439
- entities: {
440
- ...prev.entities,
441
- [id]: { ...existing, ...partial }
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[id]) return prev;
449
- const { [id]: _, ...remainingEntities } = prev.entities;
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: remainingEntities
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
- if (!entities[name]) {
466
- entities[name] = {};
500
+ let table = ownGet(entities, name);
501
+ if (!table) {
502
+ table = dict();
503
+ defineOwn(entities, name, table);
467
504
  }
468
- return entities[name];
505
+ return table;
469
506
  }
470
507
  function normalizeEntity(entity, entitySchema) {
471
508
  const entityIdKey = entitySchema.idKey || "id";
472
- const id = String(entity[entityIdKey]);
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
- flat[field] = value.map((item) => normalizeEntity(item, relSchema));
518
+ defineOwn(
519
+ flat,
520
+ field,
521
+ value.map((item) => normalizeEntity(item, relSchema))
522
+ );
482
523
  } else if (typeof value === "object") {
483
- flat[field] = normalizeEntity(value, relSchema);
524
+ defineOwn(flat, field, normalizeEntity(value, relSchema));
484
525
  }
485
526
  }
486
527
  }
487
- table[id] = flat;
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[schema.name];
539
+ const table = ownGet(entities, schema.name);
499
540
  if (!table) return void 0;
500
- const entity = table[id];
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[field];
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
- result[field] = value.map((relId) => denormalize(relId, entities, relSchema));
550
+ defineOwn(
551
+ result,
552
+ field,
553
+ value.map((relId) => denormalize(relId, entities, relSchema))
554
+ );
510
555
  } else if (typeof value === "string") {
511
- result[field] = denormalize(value, entities, relSchema);
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(component());
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}`;
@@ -1,26 +1,24 @@
1
1
  import {
2
2
  stripHtml
3
- } from "./chunk-IXKSNWV5.js";
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-RIXRAYIU.js";
10
- import {
11
- dispose
12
- } from "./chunk-QKRPLZ2V.js";
9
+ } from "./chunk-WEQ3DMVL.js";
13
10
  import {
14
11
  signal
15
- } from "./chunk-XZZOBQAY.js";
12
+ } from "./chunk-FQRUXCEE.js";
16
13
  import {
17
14
  forEachSubscriber,
18
15
  getSubscriberCount,
19
16
  getSubscriberDeps
20
- } from "./chunk-UGRX3S57.js";
17
+ } from "./chunk-JWKYU5GV.js";
21
18
  import {
19
+ dispose,
22
20
  isDev
23
- } from "./chunk-2WLZ6757.js";
21
+ } from "./chunk-NYNYSPK7.js";
24
22
 
25
23
  // src/devtools/debug.ts
26
24
  var debugEnabled = false;
@@ -2,15 +2,15 @@ import {
2
2
  isEventHandlerAttr,
3
3
  isHtmlContentAttribute,
4
4
  sanitizeAttributeString
5
- } from "./chunk-IXKSNWV5.js";
5
+ } from "./chunk-2INLLLMZ.js";
6
6
  import {
7
7
  reactiveBinding
8
- } from "./chunk-UGRX3S57.js";
8
+ } from "./chunk-JWKYU5GV.js";
9
9
  import {
10
10
  DEV,
11
11
  devWarn,
12
12
  reportError
13
- } from "./chunk-2WLZ6757.js";
13
+ } from "./chunk-NYNYSPK7.js";
14
14
 
15
15
  // src/utils/setSafeAttribute.ts
16
16
  var HTML_NS = "http://www.w3.org/1999/xhtml";
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  drainNotificationQueue,
3
+ emitDevtools,
3
4
  notifySubscribers,
4
5
  queueSignalNotification,
5
6
  recordDependency
6
- } from "./chunk-UGRX3S57.js";
7
+ } from "./chunk-JWKYU5GV.js";
7
8
  import {
8
9
  DEV
9
- } from "./chunk-2WLZ6757.js";
10
+ } from "./chunk-NYNYSPK7.js";
10
11
 
11
12
  // src/reactivity/batch.ts
12
13
  var batchDepth = 0;
@@ -91,7 +92,7 @@ function signal(initial, options) {
91
92
  state.__v++;
92
93
  if (DEV) {
93
94
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
94
- if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
95
+ if (hook) emitDevtools(hook, "signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
95
96
  }
96
97
  if (!enqueueBatchedSignal(state)) {
97
98
  notifySubscribers(state);
@@ -105,7 +106,7 @@ function signal(initial, options) {
105
106
  state.value = newValue;
106
107
  state.__v++;
107
108
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
108
- if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
109
+ if (hook) emitDevtools(hook, "signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
109
110
  if (!enqueueBatchedSignal(state)) {
110
111
  notifySubscribers(state);
111
112
  }
@@ -124,7 +125,7 @@ function signal(initial, options) {
124
125
  }
125
126
  if (DEV) {
126
127
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
127
- if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
128
+ if (hook) emitDevtools(hook, "signal:create", { signal: state, name: debugName, getter: get, initial });
128
129
  }
129
130
  return [get, set];
130
131
  }
@@ -6,17 +6,15 @@ import {
6
6
  sanitizeAttributeString,
7
7
  sanitizeUrl,
8
8
  stripControlChars
9
- } from "./chunk-IXKSNWV5.js";
9
+ } from "./chunk-2INLLLMZ.js";
10
10
  import {
11
11
  getSSRStore
12
- } from "./chunk-5DXA2J44.js";
12
+ } from "./chunk-7XHATCIH.js";
13
13
  import {
14
+ DEV,
14
15
  dispose,
15
16
  replaceChildrenSafely
16
- } from "./chunk-QKRPLZ2V.js";
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
- const raced = Promise.race([props.content(), timeoutPromise]);
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
- if (timer) clearTimeout(timer);
628
- return { id, html: renderToString(resolvedEl) };
638
+ clearTimer();
639
+ try {
640
+ return { id, html: renderToString(resolvedEl) };
641
+ } catch (err) {
642
+ return toFallback(err);
643
+ }
629
644
  },
630
645
  (err) => {
631
- if (timer) clearTimeout(timer);
632
- if (DEV) console.warn("[SibuJS SSR] ssrSuspense rejected:", err);
633
- return { id, html: fallbackHtml };
646
+ clearTimer();
647
+ return toFallback(err);
634
648
  }
635
649
  );
636
650
  promise.catch(noop);