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.
Files changed (109) hide show
  1. package/dist/browser.cjs +309 -129
  2. package/dist/browser.d.cts +46 -14
  3. package/dist/browser.d.ts +46 -14
  4. package/dist/browser.js +8 -6
  5. package/dist/build.cjs +184 -72
  6. package/dist/build.js +15 -16
  7. package/dist/cdn.dev.global.js +12 -12
  8. package/dist/cdn.full.dev.global.js +11 -11
  9. package/dist/cdn.full.global.js +10 -10
  10. package/dist/cdn.global.js +12 -12
  11. package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
  12. package/dist/chunk-3ISI6ACU.js +44 -0
  13. package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
  14. package/dist/chunk-5HZXGZ6T.js +24 -0
  15. package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
  16. package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
  17. package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
  18. package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
  19. package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
  20. package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
  21. package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
  22. package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
  23. package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
  24. package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
  25. package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
  26. package/dist/chunk-J6FW5TV6.js +233 -0
  27. package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
  28. package/dist/chunk-NYNYSPK7.js +318 -0
  29. package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
  30. package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
  31. package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
  32. package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
  33. package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
  34. package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
  35. package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
  36. package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
  37. package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
  38. package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
  39. package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
  40. package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
  41. package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
  42. package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
  43. package/dist/data.cjs +213 -117
  44. package/dist/data.d.cts +47 -9
  45. package/dist/data.d.ts +47 -9
  46. package/dist/data.js +12 -9
  47. package/dist/devtools.cjs +81 -57
  48. package/dist/devtools.js +7 -8
  49. package/dist/dispose-GEIG2KOF.js +28 -0
  50. package/dist/ecosystem.cjs +309 -104
  51. package/dist/ecosystem.d.cts +19 -3
  52. package/dist/ecosystem.d.ts +19 -3
  53. package/dist/ecosystem.js +12 -12
  54. package/dist/extras.cjs +2133 -863
  55. package/dist/extras.d.cts +10 -9
  56. package/dist/extras.d.ts +10 -9
  57. package/dist/extras.js +39 -28
  58. package/dist/index.cjs +184 -72
  59. package/dist/index.d.cts +22 -5
  60. package/dist/index.d.ts +22 -5
  61. package/dist/index.js +24 -27
  62. package/dist/motion.cjs +107 -41
  63. package/dist/motion.js +5 -5
  64. package/dist/patterns.cjs +317 -39
  65. package/dist/patterns.d.cts +27 -9
  66. package/dist/patterns.d.ts +27 -9
  67. package/dist/patterns.js +8 -8
  68. package/dist/performance.cjs +308 -216
  69. package/dist/performance.d.cts +2 -2
  70. package/dist/performance.d.ts +2 -2
  71. package/dist/performance.js +8 -9
  72. package/dist/plugin-DVgSnTfK.d.cts +112 -0
  73. package/dist/plugin-DVgSnTfK.d.ts +112 -0
  74. package/dist/plugins.cjs +549 -202
  75. package/dist/plugins.d.cts +3 -3
  76. package/dist/plugins.d.ts +3 -3
  77. package/dist/plugins.js +35 -23
  78. package/dist/signal-EotCj4hS.d.cts +110 -0
  79. package/dist/signal-EotCj4hS.d.ts +110 -0
  80. package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
  81. package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
  82. package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
  83. package/dist/ssr.cjs +176 -72
  84. package/dist/ssr.d.cts +9 -3
  85. package/dist/ssr.d.ts +9 -3
  86. package/dist/ssr.js +11 -12
  87. package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
  88. package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
  89. package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
  90. package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
  91. package/dist/testing.cjs +2484 -2185
  92. package/dist/testing.d.cts +56 -5
  93. package/dist/testing.d.ts +56 -5
  94. package/dist/testing.js +580 -307
  95. package/dist/ui.cjs +707 -317
  96. package/dist/ui.d.cts +40 -7
  97. package/dist/ui.d.ts +40 -7
  98. package/dist/ui.js +151 -56
  99. package/dist/widgets.cjs +246 -278
  100. package/dist/widgets.js +9 -10
  101. package/package.json +1 -1
  102. package/dist/chunk-2WLZ6757.js +0 -149
  103. package/dist/chunk-CCSJMTRN.js +0 -15
  104. package/dist/chunk-QKRPLZ2V.js +0 -108
  105. package/dist/chunk-VUF4ALSW.js +0 -60
  106. package/dist/chunk-WWV3SJ3L.js +0 -131
  107. package/dist/dispose-46BOMMQJ.js +0 -19
  108. package/dist/plugin-D30wlGW5.d.cts +0 -71
  109. package/dist/plugin-D30wlGW5.d.ts +0 -71
package/dist/ssr.cjs CHANGED
@@ -186,6 +186,23 @@ function reportDrainRunaway(label2, executed, remaining) {
186
186
  );
187
187
  }
188
188
  var activeBindingCount = 0;
189
+ function resolveCapture(capture) {
190
+ let frame = capture;
191
+ while (frame?.closed) frame = frame.forwardTo;
192
+ return frame ?? null;
193
+ }
194
+ var registrationCaptures = [];
195
+ function currentDisposerCapture() {
196
+ return resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
197
+ }
198
+ function beginDisposerCapture(capture) {
199
+ if (capture === null && registrationCaptures.length === 0) return false;
200
+ registrationCaptures.push(resolveCapture(capture));
201
+ return true;
202
+ }
203
+ function endDisposerCapture() {
204
+ registrationCaptures.pop();
205
+ }
189
206
  function registerDisposer(node, teardown) {
190
207
  let disposers = elementDisposers.get(node);
191
208
  if (!disposers) {
@@ -194,6 +211,8 @@ function registerDisposer(node, teardown) {
194
211
  }
195
212
  disposers.push(teardown);
196
213
  if (DEV) activeBindingCount++;
214
+ const capture = resolveCapture(registrationCaptures[registrationCaptures.length - 1]);
215
+ if (capture) capture.entries.push([node, teardown]);
197
216
  }
198
217
  function dispose(node) {
199
218
  const stack = [node];
@@ -207,33 +226,34 @@ function dispose(node) {
207
226
  }
208
227
  }
209
228
  for (let i2 = order.length - 1; i2 >= 0; i2--) {
210
- const current = order[i2];
211
- if (elementDisposers.has(current)) {
212
- let executed = 0;
213
- let runaway = false;
214
- while (!runaway) {
215
- const pending = elementDisposers.get(current);
216
- if (!pending || pending.length === 0) break;
217
- const snapshot = pending.slice();
218
- elementDisposers.delete(current);
219
- if (DEV) activeBindingCount -= snapshot.length;
220
- for (let i3 = 0; i3 < snapshot.length; i3++) {
221
- if (executed >= MAX_DRAIN_TEARDOWNS) {
222
- const rest = snapshot.slice(i3);
223
- const added = elementDisposers.get(current);
224
- elementDisposers.set(current, added ? rest.concat(added) : rest);
225
- if (DEV) activeBindingCount += rest.length;
226
- reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
227
- runaway = true;
228
- break;
229
- }
230
- executed++;
231
- try {
232
- snapshot[i3]();
233
- } catch (err) {
234
- reportError(err, { phase: "cleanup", name: "disposer" });
235
- }
236
- }
229
+ disposeNodeOwn(order[i2]);
230
+ }
231
+ }
232
+ function disposeNodeOwn(node) {
233
+ if (!elementDisposers.has(node)) return;
234
+ let executed = 0;
235
+ let runaway = false;
236
+ while (!runaway) {
237
+ const pending = elementDisposers.get(node);
238
+ if (!pending || pending.length === 0) break;
239
+ const snapshot = pending.slice();
240
+ elementDisposers.delete(node);
241
+ if (DEV) activeBindingCount -= snapshot.length;
242
+ for (let i2 = 0; i2 < snapshot.length; i2++) {
243
+ if (executed >= MAX_DRAIN_TEARDOWNS) {
244
+ const rest = snapshot.slice(i2);
245
+ const added = elementDisposers.get(node);
246
+ elementDisposers.set(node, added ? rest.concat(added) : rest);
247
+ if (DEV) activeBindingCount += rest.length;
248
+ reportDrainRunaway("dispose", executed, rest.length + (added?.length ?? 0));
249
+ runaway = true;
250
+ break;
251
+ }
252
+ executed++;
253
+ try {
254
+ snapshot[i2]();
255
+ } catch (err) {
256
+ reportError(err, { phase: "cleanup", name: "disposer" });
237
257
  }
238
258
  }
239
259
  }
@@ -938,7 +958,7 @@ function renderToDocument(component, options = {}) {
938
958
  <head>
939
959
  <meta charset="UTF-8" />
940
960
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
941
- ${options.title ? `<title>${escapeHtml(options.title)}</title>` : ""}
961
+ ${options.title != null ? `<title>${escapeHtml(options.title)}</title>` : ""}
942
962
  ${metaTags}
943
963
  ${linkTags}
944
964
  ${options.headExtra || ""}
@@ -1113,16 +1133,32 @@ function ssrSuspense(props) {
1113
1133
  const timeoutPromise = new Promise((_, reject) => {
1114
1134
  timer = setTimeout(() => reject(new Error(`[SibuJS SSR] ssrSuspense timed out after ${timeoutMs}ms`)), timeoutMs);
1115
1135
  });
1116
- const raced = Promise.race([props.content(), timeoutPromise]);
1136
+ let contentPromise;
1137
+ try {
1138
+ contentPromise = Promise.resolve(props.content());
1139
+ } catch (err) {
1140
+ contentPromise = Promise.reject(err);
1141
+ }
1142
+ const toFallback = (err) => {
1143
+ if (DEV) console.warn("[SibuJS SSR] ssrSuspense rejected:", err);
1144
+ return { id, html: fallbackHtml };
1145
+ };
1146
+ const clearTimer = () => {
1147
+ if (timer !== void 0) clearTimeout(timer);
1148
+ };
1149
+ const raced = Promise.race([contentPromise, timeoutPromise]);
1117
1150
  const promise = raced.then(
1118
1151
  (resolvedEl) => {
1119
- if (timer) clearTimeout(timer);
1120
- return { id, html: renderToString(resolvedEl) };
1152
+ clearTimer();
1153
+ try {
1154
+ return { id, html: renderToString(resolvedEl) };
1155
+ } catch (err) {
1156
+ return toFallback(err);
1157
+ }
1121
1158
  },
1122
1159
  (err) => {
1123
- if (timer) clearTimeout(timer);
1124
- if (DEV) console.warn("[SibuJS SSR] ssrSuspense rejected:", err);
1125
- return { id, html: fallbackHtml };
1160
+ clearTimer();
1161
+ return toFallback(err);
1126
1162
  }
1127
1163
  );
1128
1164
  promise.catch(noop);
@@ -1343,6 +1379,7 @@ function retrack(effectFn, subscriber) {
1343
1379
  }
1344
1380
  currentSubscriber = subscriber;
1345
1381
  const sub2 = subscriber;
1382
+ if (sub2._cap === void 0) sub2._cap = currentDisposerCapture();
1346
1383
  const epoch = ++subscriberEpochCounter;
1347
1384
  sub2._epoch = epoch;
1348
1385
  sub2._structDirty = false;
@@ -1534,7 +1571,12 @@ function drainQueue() {
1534
1571
  quarantined.add(sub2);
1535
1572
  continue;
1536
1573
  }
1537
- safeInvoke(sub2);
1574
+ const pushed = beginDisposerCapture(sub2._cap ?? null);
1575
+ try {
1576
+ safeInvoke(sub2);
1577
+ } finally {
1578
+ if (pushed) endDisposerCapture();
1579
+ }
1538
1580
  }
1539
1581
  }
1540
1582
  function drainNotificationQueue() {
@@ -1670,7 +1712,7 @@ function forEachSubscriber(signal2, visit) {
1670
1712
  }
1671
1713
 
1672
1714
  // src/reactivity/track.ts
1673
- var _runtimeVersion = true ? "4.5.0" : "dev";
1715
+ var _runtimeVersion = true ? "4.6.0" : "dev";
1674
1716
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
1675
1717
  function resolveReactiveApi() {
1676
1718
  const g2 = globalThis;
@@ -2036,7 +2078,7 @@ function Head(props) {
2036
2078
  };
2037
2079
  const apply = () => {
2038
2080
  cleanup3();
2039
- if (props.title) {
2081
+ if (props.title != null) {
2040
2082
  if (typeof props.title === "function") {
2041
2083
  const getter = props.title;
2042
2084
  let lease = null;
@@ -2091,13 +2133,14 @@ function Head(props) {
2091
2133
  return anchor;
2092
2134
  }
2093
2135
  function setStructuredData(data2) {
2094
- const existing = document.head.querySelector('script[type="application/ld+json"][data-sibu]');
2095
- if (existing) existing.remove();
2136
+ const json = escapeScriptJsonLocal(JSON.stringify(data2));
2096
2137
  const script2 = document.createElement("script");
2097
2138
  script2.type = "application/ld+json";
2098
2139
  script2.setAttribute("data-sibu", "true");
2099
- script2.textContent = escapeScriptJsonLocal(JSON.stringify(data2));
2100
- document.head.appendChild(script2);
2140
+ script2.textContent = json;
2141
+ const existing = document.head.querySelector('script[type="application/ld+json"][data-sibu]');
2142
+ if (existing) existing.replaceWith(script2);
2143
+ else document.head.appendChild(script2);
2101
2144
  }
2102
2145
  function setCanonical(url) {
2103
2146
  let link2 = document.head.querySelector('link[rel="canonical"]');
@@ -2254,15 +2297,31 @@ function signal(initial, options) {
2254
2297
  // src/platform/incrementalRegeneration.ts
2255
2298
  function createISR(options) {
2256
2299
  const { revalidateAfter, fetcher, initialData } = options;
2300
+ if (!Number.isFinite(revalidateAfter) || revalidateAfter <= 0) {
2301
+ throw new RangeError(`[SibuJS ISR] revalidateAfter must be a positive finite number, got ${revalidateAfter}`);
2302
+ }
2257
2303
  const [data2, setData] = signal(initialData);
2258
- const [timestamp, setTimestamp] = signal(initialData !== void 0 ? Date.now() : 0);
2304
+ const [stale, setStale] = signal(initialData === void 0);
2259
2305
  const controller = new AbortController();
2260
2306
  let inFlight = false;
2261
2307
  let disposed = false;
2262
- const isStale = () => {
2263
- const ts = timestamp();
2264
- if (ts === 0) return true;
2265
- return Date.now() - ts >= revalidateAfter;
2308
+ let deadline;
2309
+ const clearDeadline = () => {
2310
+ if (deadline !== void 0) {
2311
+ clearTimeout(deadline);
2312
+ deadline = void 0;
2313
+ }
2314
+ };
2315
+ const armDeadline = () => {
2316
+ clearDeadline();
2317
+ deadline = setTimeout(() => {
2318
+ deadline = void 0;
2319
+ if (disposed) return;
2320
+ setStale(true);
2321
+ revalidate().catch((err) => {
2322
+ if (typeof console !== "undefined") console.warn("[SibuJS ISR] revalidate failed", err);
2323
+ });
2324
+ }, revalidateAfter);
2266
2325
  };
2267
2326
  const revalidate = async () => {
2268
2327
  if (disposed || inFlight) return;
@@ -2271,8 +2330,14 @@ function createISR(options) {
2271
2330
  try {
2272
2331
  const result = await fetcher({ signal: controller.signal });
2273
2332
  if (disposed || controller.signal.aborted) return;
2274
- setData(result);
2275
- setTimestamp(Date.now());
2333
+ batch(() => {
2334
+ setData(result);
2335
+ setStale(false);
2336
+ });
2337
+ armDeadline();
2338
+ } catch (err) {
2339
+ if (!disposed && !controller.signal.aborted) armDeadline();
2340
+ throw err;
2276
2341
  } finally {
2277
2342
  inFlight = false;
2278
2343
  }
@@ -2281,19 +2346,16 @@ function createISR(options) {
2281
2346
  revalidate().catch((err) => {
2282
2347
  if (typeof console !== "undefined") console.warn("[SibuJS ISR] initial fetch failed", err);
2283
2348
  });
2349
+ } else {
2350
+ armDeadline();
2284
2351
  }
2285
- const intervalId = setInterval(() => {
2286
- revalidate().catch((err) => {
2287
- if (typeof console !== "undefined") console.warn("[SibuJS ISR] revalidate failed", err);
2288
- });
2289
- }, revalidateAfter);
2290
2352
  const dispose2 = () => {
2291
2353
  if (disposed) return;
2292
2354
  disposed = true;
2293
- clearInterval(intervalId);
2355
+ clearDeadline();
2294
2356
  controller.abort();
2295
2357
  };
2296
- return { data: data2, isStale, revalidate, dispose: dispose2 };
2358
+ return { data: data2, isStale: stale, revalidate, dispose: dispose2 };
2297
2359
  }
2298
2360
 
2299
2361
  // src/platform/routeActions.ts
@@ -3203,13 +3265,13 @@ function createSharedScope(initialState) {
3203
3265
  for (const key of Object.keys(initialState)) {
3204
3266
  const [get2, set2] = signal(initialState[key]);
3205
3267
  signals.set(key, { get: get2, set: set2 });
3206
- subscribers.set(key, /* @__PURE__ */ new Set());
3268
+ subscribers.set(key, /* @__PURE__ */ new Map());
3207
3269
  }
3208
3270
  function ensureSignal(key) {
3209
3271
  if (!signals.has(key)) {
3210
3272
  const [get2, set2] = signal(void 0);
3211
3273
  signals.set(key, { get: get2, set: set2 });
3212
- subscribers.set(key, /* @__PURE__ */ new Set());
3274
+ subscribers.set(key, /* @__PURE__ */ new Map());
3213
3275
  }
3214
3276
  }
3215
3277
  function get(key) {
@@ -3220,9 +3282,14 @@ function createSharedScope(initialState) {
3220
3282
  ensureSignal(key);
3221
3283
  signals.get(key)?.set(value);
3222
3284
  const subs = subscribers.get(key);
3223
- if (subs) {
3224
- for (const cb of subs) {
3225
- cb(value);
3285
+ if (subs && subs.size > 0) {
3286
+ for (const subscription of Array.from(subs.values())) {
3287
+ if (!subscription.active) continue;
3288
+ try {
3289
+ subscription.callback(value);
3290
+ } catch (err) {
3291
+ reportError(err, { phase: "event", name: `sharedScope(${String(key)})` });
3292
+ }
3226
3293
  }
3227
3294
  }
3228
3295
  }
@@ -3233,9 +3300,17 @@ function createSharedScope(initialState) {
3233
3300
  return () => {
3234
3301
  };
3235
3302
  }
3236
- subs.add(callback);
3303
+ const cb = callback;
3304
+ let subscription = subs.get(cb);
3305
+ if (!subscription) {
3306
+ subscription = { callback: cb, active: true };
3307
+ subs.set(cb, subscription);
3308
+ }
3309
+ const own = subscription;
3237
3310
  return () => {
3238
- subs.delete(callback);
3311
+ if (subs.get(cb) !== own) return;
3312
+ own.active = false;
3313
+ subs.delete(cb);
3239
3314
  };
3240
3315
  }
3241
3316
  return { get, set, subscribe };
@@ -3366,6 +3441,11 @@ function serviceWorker(scriptUrl, options) {
3366
3441
  }
3367
3442
 
3368
3443
  // src/platform/worker.ts
3444
+ function toError(err) {
3445
+ if (err instanceof Error) return err;
3446
+ if (err !== null && typeof err === "object" && "name" in err && "message" in err) return err;
3447
+ return new Error(String(err));
3448
+ }
3369
3449
  function worker(workerFn2) {
3370
3450
  const [result, setResult] = signal(null);
3371
3451
  const [error, setError] = signal(null);
@@ -3388,8 +3468,11 @@ function worker(workerFn2) {
3388
3468
  worker2 = new Worker(blobUrl);
3389
3469
  worker2.addEventListener("message", (e) => {
3390
3470
  revokeBlobUrl();
3391
- setResult(e.data);
3392
- setLoading(false);
3471
+ batch(() => {
3472
+ setResult(e.data);
3473
+ setError(null);
3474
+ setLoading(false);
3475
+ });
3393
3476
  });
3394
3477
  worker2.addEventListener("error", (e) => {
3395
3478
  revokeBlobUrl();
@@ -3406,10 +3489,17 @@ function worker(workerFn2) {
3406
3489
  }
3407
3490
  function post(data2) {
3408
3491
  if (!worker2) return;
3409
- setLoading(true);
3410
- setError(null);
3411
- setResult(null);
3412
- worker2.postMessage(data2);
3492
+ try {
3493
+ worker2.postMessage(data2);
3494
+ } catch (err) {
3495
+ setError(toError(err));
3496
+ return;
3497
+ }
3498
+ batch(() => {
3499
+ setLoading(true);
3500
+ setError(null);
3501
+ setResult(null);
3502
+ });
3413
3503
  }
3414
3504
  function terminate() {
3415
3505
  if (!worker2) return;
@@ -3473,9 +3563,14 @@ function workerFn(fn) {
3473
3563
  reject(new Error("Worker is not available"));
3474
3564
  return;
3475
3565
  }
3476
- setLoading(true);
3566
+ try {
3567
+ worker2.postMessage(args);
3568
+ } catch (err) {
3569
+ reject(toError(err));
3570
+ return;
3571
+ }
3477
3572
  queue.push({ resolve, reject });
3478
- worker2.postMessage(args);
3573
+ setLoading(true);
3479
3574
  });
3480
3575
  }
3481
3576
  function terminate() {
@@ -3505,7 +3600,11 @@ function createWorkerPool(workerFn2, poolSize) {
3505
3600
  }
3506
3601
  };
3507
3602
  function dispatchNext(idx) {
3508
- if (!alive || inflight[idx] || queues[idx].length === 0) return;
3603
+ while (alive && !inflight[idx] && queues[idx].length > 0) {
3604
+ dispatchOne(idx);
3605
+ }
3606
+ }
3607
+ function dispatchOne(idx) {
3509
3608
  const w = workers[idx];
3510
3609
  const slot2 = queues[idx].shift();
3511
3610
  const onMsg = (e) => {
@@ -3530,10 +3629,15 @@ function createWorkerPool(workerFn2, poolSize) {
3530
3629
  slot2.reject(new Error(e.message || "Worker error"));
3531
3630
  dispatchNext(idx);
3532
3631
  };
3632
+ try {
3633
+ w.postMessage(slot2.data);
3634
+ } catch (err) {
3635
+ slot2.reject(toError(err));
3636
+ return;
3637
+ }
3533
3638
  inflight[idx] = { ...slot2, onMsg, onErr };
3534
3639
  w.addEventListener("message", onMsg);
3535
3640
  w.addEventListener("error", onErr);
3536
- w.postMessage(slot2.data);
3537
3641
  }
3538
3642
  try {
3539
3643
  if (typeof Worker === "undefined") {
package/dist/ssr.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate, b as hydrateIslands, f as hydrateProgressively, i as isDangerousMetaRefresh, g as island, r as renderToDocument, j as renderToReadableStream, k as renderToStream, l as renderToString, m as renderToSuspenseStream, n as resetSSRState, s as serializeState, o as ssrSuspense, p as suspenseSwapScript, t as trustHTML } from './ssr-BiPRdZ6n.cjs';
1
+ export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate, b as hydrateIslands, f as hydrateProgressively, i as isDangerousMetaRefresh, g as island, r as renderToDocument, j as renderToReadableStream, k as renderToStream, l as renderToString, m as renderToSuspenseStream, n as resetSSRState, s as serializeState, o as ssrSuspense, p as suspenseSwapScript, t as trustHTML } from './ssr-Bli9XRW5.cjs';
2
2
 
3
3
  interface HeadProps {
4
4
  title?: string | (() => string);
@@ -482,8 +482,14 @@ interface ISROptions<T> {
482
482
  }
483
483
  /**
484
484
  * Creates an Incremental Static Regeneration (ISR) resource.
485
- * Data is fetched initially, then automatically revalidated after the
486
- * specified interval using setInterval.
485
+ * Data is fetched initially, then automatically revalidated once it goes stale.
486
+ *
487
+ * `isStale()` is a reactive signal: it flips to `true` when `revalidateAfter`
488
+ * elapses since the last successful fetch (effects re-run at that moment), stays
489
+ * `true` while a revalidation is pending or after one fails, and returns to
490
+ * `false` when a revalidation succeeds.
491
+ *
492
+ * @throws RangeError when `revalidateAfter` is not a positive finite number.
487
493
  */
488
494
  declare function createISR<T>(options: ISROptions<T>): {
489
495
  data: () => T | undefined;
package/dist/ssr.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate, b as hydrateIslands, f as hydrateProgressively, i as isDangerousMetaRefresh, g as island, r as renderToDocument, j as renderToReadableStream, k as renderToStream, l as renderToString, m as renderToSuspenseStream, n as resetSSRState, s as serializeState, o as ssrSuspense, p as suspenseSwapScript, t as trustHTML } from './ssr-BiPRdZ6n.js';
1
+ export { H as HydrateOptions, a as HydrationMismatch, T as TrustedHTML, c as collectStream, d as deserializeState, e as escapeScriptJson, h as hydrate, b as hydrateIslands, f as hydrateProgressively, i as isDangerousMetaRefresh, g as island, r as renderToDocument, j as renderToReadableStream, k as renderToStream, l as renderToString, m as renderToSuspenseStream, n as resetSSRState, s as serializeState, o as ssrSuspense, p as suspenseSwapScript, t as trustHTML } from './ssr-Bli9XRW5.js';
2
2
 
3
3
  interface HeadProps {
4
4
  title?: string | (() => string);
@@ -482,8 +482,14 @@ interface ISROptions<T> {
482
482
  }
483
483
  /**
484
484
  * Creates an Incremental Static Regeneration (ISR) resource.
485
- * Data is fetched initially, then automatically revalidated after the
486
- * specified interval using setInterval.
485
+ * Data is fetched initially, then automatically revalidated once it goes stale.
486
+ *
487
+ * `isStale()` is a reactive signal: it flips to `true` when `revalidateAfter`
488
+ * elapses since the last successful fetch (effects re-run at that moment), stays
489
+ * `true` while a revalidation is pending or after one fails, and returns to
490
+ * `false` when a revalidation succeeds.
491
+ *
492
+ * @throws RangeError when `revalidateAfter` is not a positive finite number.
487
493
  */
488
494
  declare function createISR<T>(options: ISROptions<T>): {
489
495
  data: () => T | undefined;
package/dist/ssr.js CHANGED
@@ -23,9 +23,9 @@ import {
23
23
  wasm,
24
24
  worker,
25
25
  workerFn
26
- } from "./chunk-RJE2BNI4.js";
26
+ } from "./chunk-ORMZXBKQ.js";
27
27
  import "./chunk-52XFPGSN.js";
28
- import "./chunk-PCT43HW3.js";
28
+ import "./chunk-JSXPZCET.js";
29
29
  import {
30
30
  collectStream,
31
31
  deserializeState,
@@ -45,17 +45,16 @@ import {
45
45
  ssrSuspense,
46
46
  suspenseSwapScript,
47
47
  trustHTML
48
- } from "./chunk-NIOYEGBQ.js";
49
- import "./chunk-KEISJXBU.js";
50
- import "./chunk-ONOHFDLG.js";
51
- import "./chunk-IXKSNWV5.js";
48
+ } from "./chunk-HURREPU2.js";
49
+ import "./chunk-VVWPJ543.js";
50
+ import "./chunk-47M47FOM.js";
51
+ import "./chunk-2INLLLMZ.js";
52
52
  import "./chunk-7ZHH77QA.js";
53
- import "./chunk-RIXRAYIU.js";
54
- import "./chunk-5DXA2J44.js";
55
- import "./chunk-QKRPLZ2V.js";
56
- import "./chunk-XZZOBQAY.js";
57
- import "./chunk-UGRX3S57.js";
58
- import "./chunk-2WLZ6757.js";
53
+ import "./chunk-XC4MEKGA.js";
54
+ import "./chunk-7XHATCIH.js";
55
+ import "./chunk-D33YTSX5.js";
56
+ import "./chunk-5Q4R7HCL.js";
57
+ import "./chunk-NYNYSPK7.js";
59
58
  export {
60
59
  Head,
61
60
  clearWasmCache,