@getforma/core 0.3.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +201 -13
  2. package/dist/{chunk-KX5WRZH7.js → chunk-DPSAVBCP.js} +3 -4
  3. package/dist/chunk-DPSAVBCP.js.map +1 -0
  4. package/dist/{chunk-FPSLC62A.cjs → chunk-KH3F5NRU.cjs} +2 -4
  5. package/dist/chunk-KH3F5NRU.cjs.map +1 -0
  6. package/dist/{chunk-VKKPX4YU.js → chunk-TKGUHASG.js} +79 -19
  7. package/dist/chunk-TKGUHASG.js.map +1 -0
  8. package/dist/{chunk-VP5EOGM5.cjs → chunk-YSKF3VRA.cjs} +87 -26
  9. package/dist/chunk-YSKF3VRA.cjs.map +1 -0
  10. package/dist/forma-runtime-csp.js +2 -0
  11. package/dist/forma-runtime.js +2 -0
  12. package/dist/formajs-runtime-hardened.global.js +1 -1
  13. package/dist/formajs-runtime-hardened.global.js.map +1 -1
  14. package/dist/formajs-runtime.global.js +1 -1
  15. package/dist/formajs-runtime.global.js.map +1 -1
  16. package/dist/formajs.global.js +1 -1
  17. package/dist/formajs.global.js.map +1 -1
  18. package/dist/index.cjs +154 -96
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +83 -35
  21. package/dist/index.d.ts +83 -35
  22. package/dist/index.js +99 -40
  23. package/dist/index.js.map +1 -1
  24. package/dist/runtime-hardened.cjs +224 -60
  25. package/dist/runtime-hardened.cjs.map +1 -1
  26. package/dist/runtime-hardened.d.cts +86 -0
  27. package/dist/runtime-hardened.d.ts +86 -0
  28. package/dist/runtime-hardened.js +225 -61
  29. package/dist/runtime-hardened.js.map +1 -1
  30. package/dist/runtime.cjs +248 -83
  31. package/dist/runtime.cjs.map +1 -1
  32. package/dist/runtime.js +226 -61
  33. package/dist/runtime.js.map +1 -1
  34. package/dist/ssr/index.cjs +69 -73
  35. package/dist/ssr/index.cjs.map +1 -1
  36. package/dist/ssr/index.d.cts +4 -0
  37. package/dist/ssr/index.d.ts +4 -0
  38. package/dist/ssr/index.js +69 -73
  39. package/dist/ssr/index.js.map +1 -1
  40. package/dist/tc39-compat.cjs +3 -3
  41. package/dist/tc39-compat.js +1 -1
  42. package/package.json +24 -3
  43. package/dist/chunk-FPSLC62A.cjs.map +0 -1
  44. package/dist/chunk-KX5WRZH7.js.map +0 -1
  45. package/dist/chunk-VKKPX4YU.js.map +0 -1
  46. package/dist/chunk-VP5EOGM5.cjs.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,13 +1,13 @@
1
1
  'use strict';
2
2
 
3
- var chunkVP5EOGM5_cjs = require('./chunk-VP5EOGM5.cjs');
4
- var chunkFPSLC62A_cjs = require('./chunk-FPSLC62A.cjs');
3
+ var chunkYSKF3VRA_cjs = require('./chunk-YSKF3VRA.cjs');
4
+ var chunkKH3F5NRU_cjs = require('./chunk-KH3F5NRU.cjs');
5
5
 
6
6
  // src/dom/text.ts
7
7
  function createText(value) {
8
8
  if (typeof value === "function") {
9
9
  const node = new Text("");
10
- chunkVP5EOGM5_cjs.internalEffect(() => {
10
+ chunkYSKF3VRA_cjs.internalEffect(() => {
11
11
  node.data = value();
12
12
  });
13
13
  return node;
@@ -23,12 +23,12 @@ function mount(component, container) {
23
23
  }
24
24
  let disposeRoot;
25
25
  if (target.hasAttribute("data-forma-ssr")) {
26
- chunkVP5EOGM5_cjs.createRoot((dispose) => {
26
+ chunkYSKF3VRA_cjs.createRoot((dispose) => {
27
27
  disposeRoot = dispose;
28
- chunkVP5EOGM5_cjs.hydrateIsland(component, target);
28
+ chunkYSKF3VRA_cjs.hydrateIsland(component, target);
29
29
  });
30
30
  } else {
31
- const dom = chunkVP5EOGM5_cjs.createRoot((dispose) => {
31
+ const dom = chunkYSKF3VRA_cjs.createRoot((dispose) => {
32
32
  disposeRoot = dispose;
33
33
  return component();
34
34
  });
@@ -54,7 +54,7 @@ function createSwitch(value, cases, fallback) {
54
54
  const cache = /* @__PURE__ */ new Map();
55
55
  let currentNode = null;
56
56
  let currentMatch = UNSET;
57
- const switchDispose = chunkVP5EOGM5_cjs.internalEffect(() => {
57
+ const switchDispose = chunkYSKF3VRA_cjs.internalEffect(() => {
58
58
  const val = value();
59
59
  if (val === currentMatch) return;
60
60
  const DEBUG = typeof globalThis.__FORMA_DEBUG__ !== "undefined";
@@ -89,9 +89,9 @@ function createSwitch(value, cases, fallback) {
89
89
  let entry = cache.get(val);
90
90
  if (!entry) {
91
91
  let branchDispose;
92
- const node = chunkVP5EOGM5_cjs.createRoot((dispose) => {
92
+ const node = chunkYSKF3VRA_cjs.createRoot((dispose) => {
93
93
  branchDispose = dispose;
94
- return chunkVP5EOGM5_cjs.untrack(() => matchedCase.render());
94
+ return chunkYSKF3VRA_cjs.untrack(() => matchedCase.render());
95
95
  });
96
96
  entry = { node, dispose: branchDispose };
97
97
  cache.set(val, entry);
@@ -134,7 +134,7 @@ function createPortal(children2, target) {
134
134
  }
135
135
  mountedNode = null;
136
136
  };
137
- chunkVP5EOGM5_cjs.createEffect(() => {
137
+ chunkYSKF3VRA_cjs.createEffect(() => {
138
138
  const node = children2();
139
139
  removeMountedNode();
140
140
  mountedNode = node;
@@ -153,9 +153,9 @@ function createErrorBoundary(tryFn, catchFn) {
153
153
  const fragment2 = document.createDocumentFragment();
154
154
  fragment2.appendChild(startMarker);
155
155
  fragment2.appendChild(endMarker);
156
- const [retryCount, setRetryCount] = chunkFPSLC62A_cjs.createSignal(0);
156
+ const [retryCount, setRetryCount] = chunkKH3F5NRU_cjs.createSignal(0);
157
157
  let currentNode = null;
158
- chunkVP5EOGM5_cjs.internalEffect(() => {
158
+ chunkYSKF3VRA_cjs.internalEffect(() => {
159
159
  retryCount();
160
160
  const parent2 = startMarker.parentNode;
161
161
  if (!parent2) return;
@@ -183,7 +183,7 @@ function createSuspense(fallback, children2) {
183
183
  const fragment2 = document.createDocumentFragment();
184
184
  fragment2.appendChild(startMarker);
185
185
  fragment2.appendChild(endMarker);
186
- const [pending, setPending] = chunkFPSLC62A_cjs.createSignal(0);
186
+ const [pending, setPending] = chunkKH3F5NRU_cjs.createSignal(0);
187
187
  let currentNode = null;
188
188
  let resolvedNode = null;
189
189
  let fallbackNode = null;
@@ -195,13 +195,13 @@ function createSuspense(fallback, children2) {
195
195
  setPending((p) => Math.max(0, p - 1));
196
196
  }
197
197
  };
198
- chunkVP5EOGM5_cjs.pushSuspenseContext(ctx);
198
+ chunkYSKF3VRA_cjs.pushSuspenseContext(ctx);
199
199
  try {
200
200
  resolvedNode = children2();
201
201
  } finally {
202
- chunkVP5EOGM5_cjs.popSuspenseContext();
202
+ chunkYSKF3VRA_cjs.popSuspenseContext();
203
203
  }
204
- chunkVP5EOGM5_cjs.internalEffect(() => {
204
+ chunkYSKF3VRA_cjs.internalEffect(() => {
205
205
  const parent2 = startMarker.parentNode;
206
206
  if (!parent2) return;
207
207
  const isPending = pending() > 0;
@@ -238,14 +238,11 @@ function activateIslands(registry2) {
238
238
  const componentName = root.getAttribute("data-forma-component");
239
239
  const hydrateFn = registry2[componentName];
240
240
  if (!hydrateFn) {
241
- console.warn(`[forma] No hydrate function for island "${componentName}" (id=${id})`);
241
+ if (chunkYSKF3VRA_cjs.__DEV__) console.warn(`[forma] No hydrate function for island "${componentName}" (id=${id})`);
242
242
  root.setAttribute("data-forma-status", "error");
243
243
  continue;
244
244
  }
245
245
  const trigger = root.getAttribute("data-forma-hydrate") || "load";
246
- if (trigger === "interaction" || trigger === "idle") {
247
- console.warn(`[forma] Trigger "${trigger}" not yet implemented for island "${componentName}" (id=${id}), falling back to load`);
248
- }
249
246
  if (trigger === "visible") {
250
247
  const observer = new IntersectionObserver(
251
248
  (entries) => {
@@ -258,23 +255,52 @@ function activateIslands(registry2) {
258
255
  { rootMargin: "200px" }
259
256
  );
260
257
  observer.observe(root);
258
+ } else if (trigger === "idle") {
259
+ const hydrate = () => hydrateIslandRoot(root, id, componentName, hydrateFn, sharedProps);
260
+ if (typeof requestIdleCallback === "function") {
261
+ requestIdleCallback(hydrate);
262
+ } else {
263
+ setTimeout(hydrate, 200);
264
+ }
265
+ } else if (trigger === "interaction") {
266
+ const hydrate = () => {
267
+ root.removeEventListener("pointerdown", hydrate, true);
268
+ root.removeEventListener("focusin", hydrate, true);
269
+ hydrateIslandRoot(root, id, componentName, hydrateFn, sharedProps);
270
+ };
271
+ root.addEventListener("pointerdown", hydrate, { capture: true, once: true });
272
+ root.addEventListener("focusin", hydrate, { capture: true, once: true });
261
273
  } else {
262
274
  hydrateIslandRoot(root, id, componentName, hydrateFn, sharedProps);
263
275
  }
264
276
  }
265
277
  }
278
+ function deactivateIsland(el) {
279
+ const dispose = el.__formaDispose;
280
+ if (typeof dispose === "function") {
281
+ dispose();
282
+ delete el.__formaDispose;
283
+ el.setAttribute("data-forma-status", "disposed");
284
+ }
285
+ }
286
+ function deactivateAllIslands(root = document) {
287
+ const islands = root.querySelectorAll('[data-forma-status="active"]');
288
+ for (const island of islands) {
289
+ deactivateIsland(island);
290
+ }
291
+ }
266
292
  function hydrateIslandRoot(root, id, componentName, hydrateFn, sharedProps) {
267
293
  try {
268
294
  const props = loadIslandProps(root, id, sharedProps);
269
295
  root.setAttribute("data-forma-status", "hydrating");
270
296
  let activeRoot = root;
271
- chunkVP5EOGM5_cjs.createRoot((dispose) => {
272
- activeRoot = chunkVP5EOGM5_cjs.hydrateIsland(() => hydrateFn(props), root);
297
+ chunkYSKF3VRA_cjs.createRoot((dispose) => {
298
+ activeRoot = chunkYSKF3VRA_cjs.hydrateIsland(() => hydrateFn(root, props), root);
273
299
  activeRoot.__formaDispose = dispose;
274
300
  });
275
301
  activeRoot.setAttribute("data-forma-status", "active");
276
302
  } catch (err) {
277
- console.error(`[forma] Island "${componentName}" (id=${id}) failed:`, err);
303
+ if (chunkYSKF3VRA_cjs.__DEV__) console.error(`[forma] Island "${componentName}" (id=${id}) failed:`, err);
278
304
  root.setAttribute("data-forma-status", "error");
279
305
  }
280
306
  }
@@ -322,13 +348,15 @@ function defineComponent(setupOrDef) {
322
348
  for (const cb of ctx.unmountCallbacks) {
323
349
  try {
324
350
  cb();
325
- } catch {
351
+ } catch (e) {
352
+ chunkYSKF3VRA_cjs.reportError(e, "onUnmount");
326
353
  }
327
354
  }
328
355
  for (const d of ctx.disposers) {
329
356
  try {
330
357
  d();
331
- } catch {
358
+ } catch (e) {
359
+ chunkYSKF3VRA_cjs.reportError(e, "component disposer");
332
360
  }
333
361
  }
334
362
  ctx.disposers.length = 0;
@@ -342,7 +370,8 @@ function defineComponent(setupOrDef) {
342
370
  if (typeof cleanup2 === "function") {
343
371
  ctx.unmountCallbacks.push(cleanup2);
344
372
  }
345
- } catch {
373
+ } catch (e) {
374
+ chunkYSKF3VRA_cjs.reportError(e, "onMount");
346
375
  }
347
376
  }
348
377
  return dom;
@@ -443,7 +472,7 @@ function createStore(initial) {
443
472
  function getSignal(path, initialValue) {
444
473
  let pair = signals.get(path);
445
474
  if (!pair) {
446
- pair = chunkFPSLC62A_cjs.createSignal(initialValue);
475
+ pair = chunkKH3F5NRU_cjs.createSignal(initialValue);
447
476
  signals.set(path, pair);
448
477
  registerChild(path);
449
478
  }
@@ -483,7 +512,7 @@ function createStore(initial) {
483
512
  if (isArr && ARRAY_MUTATORS.has(key)) {
484
513
  return (...args) => {
485
514
  let result;
486
- chunkVP5EOGM5_cjs.batch(() => {
515
+ chunkYSKF3VRA_cjs.batch(() => {
487
516
  const rawArgs = args.map(
488
517
  (a) => a != null && typeof a === "object" && a[RAW] ? a[RAW] : a
489
518
  );
@@ -597,11 +626,11 @@ function createStore(initial) {
597
626
  }
598
627
  const rootProxy = wrap(initial, "");
599
628
  function getCurrentSnapshot() {
600
- return chunkVP5EOGM5_cjs.untrack(() => deepClone(initial));
629
+ return chunkYSKF3VRA_cjs.untrack(() => deepClone(initial));
601
630
  }
602
631
  const setter = (partial) => {
603
632
  const updates = typeof partial === "function" ? partial(getCurrentSnapshot()) : partial;
604
- chunkVP5EOGM5_cjs.batch(() => {
633
+ chunkYSKF3VRA_cjs.batch(() => {
605
634
  for (const key of Object.keys(updates)) {
606
635
  rootProxy[key] = updates[key];
607
636
  }
@@ -616,11 +645,11 @@ function createHistory(source, options) {
616
645
  const maxLength = options?.maxLength ?? 100;
617
646
  let _stack = [sourceGet()];
618
647
  let _cursor = 0;
619
- const [stackSignal, setStackSignal] = chunkFPSLC62A_cjs.createValueSignal([..._stack]);
620
- const [cursorSignal, setCursorSignal] = chunkFPSLC62A_cjs.createValueSignal(_cursor);
621
- const [stackLenSignal, setStackLenSignal] = chunkFPSLC62A_cjs.createValueSignal(_stack.length);
648
+ const [stackSignal, setStackSignal] = chunkKH3F5NRU_cjs.createSignal([..._stack]);
649
+ const [cursorSignal, setCursorSignal] = chunkKH3F5NRU_cjs.createSignal(_cursor);
650
+ const [stackLenSignal, setStackLenSignal] = chunkKH3F5NRU_cjs.createSignal(_stack.length);
622
651
  function syncSignals() {
623
- chunkVP5EOGM5_cjs.batch(() => {
652
+ chunkYSKF3VRA_cjs.batch(() => {
624
653
  setStackSignal([..._stack]);
625
654
  setCursorSignal(_cursor);
626
655
  setStackLenSignal(_stack.length);
@@ -628,7 +657,7 @@ function createHistory(source, options) {
628
657
  }
629
658
  let ignoreNext = false;
630
659
  let isFirstRun = true;
631
- chunkVP5EOGM5_cjs.internalEffect(() => {
660
+ chunkYSKF3VRA_cjs.internalEffect(() => {
632
661
  const value = sourceGet();
633
662
  if (isFirstRun) {
634
663
  isFirstRun = false;
@@ -685,15 +714,18 @@ function persist(source, key, options) {
685
714
  const storage = options?.storage ?? globalThis.localStorage;
686
715
  const serialize = options?.serialize ?? JSON.stringify;
687
716
  const deserialize = options?.deserialize ?? JSON.parse;
717
+ const validate = options?.validate;
688
718
  try {
689
719
  const stored = storage.getItem(key);
690
720
  if (stored !== null) {
691
721
  const value = deserialize(stored);
692
- sourceSet(value);
722
+ if (!validate || validate(value)) {
723
+ sourceSet(value);
724
+ }
693
725
  }
694
726
  } catch {
695
727
  }
696
- chunkVP5EOGM5_cjs.internalEffect(() => {
728
+ chunkYSKF3VRA_cjs.internalEffect(() => {
697
729
  const value = sourceGet();
698
730
  try {
699
731
  const serialized = serialize(value);
@@ -870,6 +902,9 @@ function setText(el, text) {
870
902
  function setHTML(el, html) {
871
903
  el.innerHTML = html;
872
904
  }
905
+ function setHTMLUnsafe(el, html) {
906
+ el.innerHTML = html;
907
+ }
873
908
 
874
909
  // src/dom-utils/traverse.ts
875
910
  function closest(el, selector) {
@@ -953,20 +988,26 @@ function onMutation(el, handler, options) {
953
988
  function createLocalStorage(key, options) {
954
989
  const serialize = options?.serialize ?? JSON.stringify;
955
990
  const deserialize = options?.deserialize ?? JSON.parse;
991
+ const validate = options?.validate;
956
992
  return {
957
993
  key,
958
994
  get() {
959
995
  try {
960
996
  const raw = localStorage.getItem(key);
961
997
  if (raw === null) return null;
962
- return deserialize(raw);
998
+ const value = deserialize(raw);
999
+ if (validate && !validate(value)) return null;
1000
+ return value;
963
1001
  } catch {
964
1002
  return null;
965
1003
  }
966
1004
  },
967
1005
  set(value) {
968
- const serialized = serialize(value);
969
- localStorage.setItem(key, serialized);
1006
+ try {
1007
+ const serialized = serialize(value);
1008
+ localStorage.setItem(key, serialized);
1009
+ } catch {
1010
+ }
970
1011
  },
971
1012
  remove() {
972
1013
  localStorage.removeItem(key);
@@ -978,20 +1019,26 @@ function createLocalStorage(key, options) {
978
1019
  function createSessionStorage(key, options) {
979
1020
  const serialize = options?.serialize ?? JSON.stringify;
980
1021
  const deserialize = options?.deserialize ?? JSON.parse;
1022
+ const validate = options?.validate;
981
1023
  return {
982
1024
  key,
983
1025
  get() {
984
1026
  try {
985
1027
  const raw = sessionStorage.getItem(key);
986
1028
  if (raw === null) return null;
987
- return deserialize(raw);
1029
+ const value = deserialize(raw);
1030
+ if (validate && !validate(value)) return null;
1031
+ return value;
988
1032
  } catch {
989
1033
  return null;
990
1034
  }
991
1035
  },
992
1036
  set(value) {
993
- const serialized = serialize(value);
994
- sessionStorage.setItem(key, serialized);
1037
+ try {
1038
+ const serialized = serialize(value);
1039
+ sessionStorage.setItem(key, serialized);
1040
+ } catch {
1041
+ }
995
1042
  },
996
1043
  remove() {
997
1044
  sessionStorage.removeItem(key);
@@ -1083,9 +1130,9 @@ function createIndexedDB(dbName, storeName = "default") {
1083
1130
 
1084
1131
  // src/http/fetch.ts
1085
1132
  function createFetch(url, options) {
1086
- const [data, setData] = chunkFPSLC62A_cjs.createSignal(null);
1087
- const [error, setError] = chunkFPSLC62A_cjs.createSignal(null);
1088
- const [loading, setLoading] = chunkFPSLC62A_cjs.createSignal(false);
1133
+ const [data, setData] = chunkKH3F5NRU_cjs.createSignal(null);
1134
+ const [error, setError] = chunkKH3F5NRU_cjs.createSignal(null);
1135
+ const [loading, setLoading] = chunkKH3F5NRU_cjs.createSignal(false);
1089
1136
  let currentController = null;
1090
1137
  function resolveURL() {
1091
1138
  const raw = typeof url === "function" ? url() : url;
@@ -1122,7 +1169,7 @@ function createFetch(url, options) {
1122
1169
  const transformed = transform ? transform(json) : json;
1123
1170
  setData(transformed);
1124
1171
  } catch (err) {
1125
- if (err?.name === "AbortError") {
1172
+ if (err instanceof Error && err.name === "AbortError") {
1126
1173
  return;
1127
1174
  }
1128
1175
  setError(err instanceof Error ? err : new Error(String(err)));
@@ -1135,7 +1182,7 @@ function createFetch(url, options) {
1135
1182
  }
1136
1183
  }
1137
1184
  if (typeof url === "function") {
1138
- chunkVP5EOGM5_cjs.internalEffect(() => {
1185
+ chunkYSKF3VRA_cjs.internalEffect(() => {
1139
1186
  url();
1140
1187
  execute();
1141
1188
  });
@@ -1164,9 +1211,9 @@ async function fetchJSON(url, options) {
1164
1211
 
1165
1212
  // src/http/sse.ts
1166
1213
  function createSSE(url, options) {
1167
- const [data, setData] = chunkFPSLC62A_cjs.createSignal(null);
1168
- const [error, setError] = chunkFPSLC62A_cjs.createSignal(null);
1169
- const [connected, setConnected] = chunkFPSLC62A_cjs.createSignal(false);
1214
+ const [data, setData] = chunkKH3F5NRU_cjs.createSignal(null);
1215
+ const [error, setError] = chunkKH3F5NRU_cjs.createSignal(null);
1216
+ const [connected, setConnected] = chunkKH3F5NRU_cjs.createSignal(false);
1170
1217
  const source = new EventSource(url, {
1171
1218
  withCredentials: options?.withCredentials ?? false
1172
1219
  });
@@ -1174,13 +1221,15 @@ function createSSE(url, options) {
1174
1221
  setConnected(true);
1175
1222
  setError(null);
1176
1223
  };
1177
- source.onmessage = (event) => {
1224
+ const parseMessage = options?.parse ?? ((raw) => {
1178
1225
  try {
1179
- const parsed = JSON.parse(event.data);
1180
- setData(parsed);
1226
+ return JSON.parse(raw);
1181
1227
  } catch {
1182
- setData(event.data);
1228
+ return raw;
1183
1229
  }
1230
+ });
1231
+ source.onmessage = (event) => {
1232
+ setData(parseMessage(event.data));
1184
1233
  };
1185
1234
  source.onerror = (event) => {
1186
1235
  setError(event);
@@ -1195,12 +1244,15 @@ function createSSE(url, options) {
1195
1244
  setConnected(false);
1196
1245
  },
1197
1246
  on(event, handler) {
1198
- const listener = (e) => {
1247
+ const parseEvent = options?.parse ?? ((raw) => {
1199
1248
  try {
1200
- handler(JSON.parse(e.data));
1249
+ return JSON.parse(raw);
1201
1250
  } catch {
1202
- handler(e.data);
1251
+ return raw;
1203
1252
  }
1253
+ });
1254
+ const listener = (e) => {
1255
+ handler(parseEvent(e.data));
1204
1256
  };
1205
1257
  source.addEventListener(event, listener);
1206
1258
  return () => {
@@ -1215,8 +1267,8 @@ function createWebSocket(url, options) {
1215
1267
  const shouldReconnect = options?.reconnect ?? true;
1216
1268
  const baseInterval = options?.reconnectInterval ?? 1e3;
1217
1269
  const maxReconnects = options?.maxReconnects ?? 5;
1218
- const [data, setData] = chunkFPSLC62A_cjs.createSignal(null);
1219
- const [status, setStatus] = chunkFPSLC62A_cjs.createSignal("connecting");
1270
+ const [data, setData] = chunkKH3F5NRU_cjs.createSignal(null);
1271
+ const [status, setStatus] = chunkKH3F5NRU_cjs.createSignal("connecting");
1220
1272
  const handlers = /* @__PURE__ */ new Set();
1221
1273
  let socket = null;
1222
1274
  let reconnectCount = 0;
@@ -1230,13 +1282,15 @@ function createWebSocket(url, options) {
1230
1282
  setStatus("open");
1231
1283
  reconnectCount = 0;
1232
1284
  };
1233
- socket.onmessage = (event) => {
1234
- let parsed;
1285
+ const parseMessage = options?.parse ?? ((raw) => {
1235
1286
  try {
1236
- parsed = JSON.parse(event.data);
1287
+ return JSON.parse(raw);
1237
1288
  } catch {
1238
- parsed = event.data;
1289
+ return raw;
1239
1290
  }
1291
+ });
1292
+ socket.onmessage = (event) => {
1293
+ const parsed = parseMessage(event.data);
1240
1294
  setData(parsed);
1241
1295
  for (const handler of handlers) {
1242
1296
  handler(parsed);
@@ -1290,21 +1344,21 @@ function createWebSocket(url, options) {
1290
1344
 
1291
1345
  // src/server/action.ts
1292
1346
  function createAction(serverFn, options) {
1293
- const [pending, setPending] = chunkFPSLC62A_cjs.createValueSignal(false);
1294
- const [error, setError] = chunkFPSLC62A_cjs.createValueSignal(void 0);
1347
+ const [pending, setPending] = chunkKH3F5NRU_cjs.createSignal(false);
1348
+ const [error, setError] = chunkKH3F5NRU_cjs.createSignal(void 0);
1295
1349
  const action = async (...args) => {
1296
1350
  setPending(true);
1297
1351
  setError(void 0);
1298
1352
  if (options?.optimistic) {
1299
1353
  try {
1300
- chunkVP5EOGM5_cjs.batch(() => options.optimistic(...args));
1354
+ chunkYSKF3VRA_cjs.batch(() => options.optimistic(...args));
1301
1355
  } catch {
1302
1356
  }
1303
1357
  }
1304
1358
  try {
1305
1359
  const result = await serverFn(...args);
1306
1360
  if (options?.onSuccess) {
1307
- chunkVP5EOGM5_cjs.batch(() => options.onSuccess(result, ...args));
1361
+ chunkYSKF3VRA_cjs.batch(() => options.onSuccess(result, ...args));
1308
1362
  }
1309
1363
  if (options?.invalidates) {
1310
1364
  for (const resource of options.invalidates) {
@@ -1316,7 +1370,7 @@ function createAction(serverFn, options) {
1316
1370
  } catch (err) {
1317
1371
  if (options?.onError) {
1318
1372
  try {
1319
- chunkVP5EOGM5_cjs.batch(() => options.onError(err, ...args));
1373
+ chunkYSKF3VRA_cjs.batch(() => options.onError(err, ...args));
1320
1374
  } catch {
1321
1375
  }
1322
1376
  }
@@ -1349,6 +1403,10 @@ function applyRevalidation(revalidateData) {
1349
1403
  }
1350
1404
  }
1351
1405
  function enableAutoRevalidation() {
1406
+ if (typeof window === "undefined") {
1407
+ return () => {
1408
+ };
1409
+ }
1352
1410
  const handler = (event) => {
1353
1411
  const detail = event.detail;
1354
1412
  if (detail && typeof detail === "object") {
@@ -1417,9 +1475,10 @@ async function handleRPC(endpoint, body, revalidateData) {
1417
1475
  if (revalidateData) {
1418
1476
  return { data: result, __revalidate: revalidateData };
1419
1477
  }
1420
- return result;
1478
+ return { data: result };
1421
1479
  } catch (err) {
1422
- const message = err instanceof Error ? err.message : String(err);
1480
+ const isDev = typeof process !== "undefined" && process.env?.NODE_ENV === "development";
1481
+ const message = isDev && err instanceof Error ? err.message : "Internal server error";
1423
1482
  return { error: message };
1424
1483
  }
1425
1484
  }
@@ -1479,91 +1538,87 @@ async function renderIsland(slotsJson, islandId) {
1479
1538
 
1480
1539
  Object.defineProperty(exports, "Fragment", {
1481
1540
  enumerable: true,
1482
- get: function () { return chunkVP5EOGM5_cjs.Fragment; }
1541
+ get: function () { return chunkYSKF3VRA_cjs.Fragment; }
1483
1542
  });
1484
1543
  Object.defineProperty(exports, "batch", {
1485
1544
  enumerable: true,
1486
- get: function () { return chunkVP5EOGM5_cjs.batch; }
1545
+ get: function () { return chunkYSKF3VRA_cjs.batch; }
1487
1546
  });
1488
1547
  Object.defineProperty(exports, "cleanup", {
1489
1548
  enumerable: true,
1490
- get: function () { return chunkVP5EOGM5_cjs.cleanup; }
1549
+ get: function () { return chunkYSKF3VRA_cjs.cleanup; }
1491
1550
  });
1492
1551
  Object.defineProperty(exports, "createEffect", {
1493
1552
  enumerable: true,
1494
- get: function () { return chunkVP5EOGM5_cjs.createEffect; }
1553
+ get: function () { return chunkYSKF3VRA_cjs.createEffect; }
1495
1554
  });
1496
1555
  Object.defineProperty(exports, "createList", {
1497
1556
  enumerable: true,
1498
- get: function () { return chunkVP5EOGM5_cjs.createList; }
1557
+ get: function () { return chunkYSKF3VRA_cjs.createList; }
1499
1558
  });
1500
1559
  Object.defineProperty(exports, "createMemo", {
1501
1560
  enumerable: true,
1502
- get: function () { return chunkVP5EOGM5_cjs.createMemo; }
1561
+ get: function () { return chunkYSKF3VRA_cjs.createMemo; }
1503
1562
  });
1504
1563
  Object.defineProperty(exports, "createReducer", {
1505
1564
  enumerable: true,
1506
- get: function () { return chunkVP5EOGM5_cjs.createReducer; }
1565
+ get: function () { return chunkYSKF3VRA_cjs.createReducer; }
1507
1566
  });
1508
1567
  Object.defineProperty(exports, "createRef", {
1509
1568
  enumerable: true,
1510
- get: function () { return chunkVP5EOGM5_cjs.createRef; }
1569
+ get: function () { return chunkYSKF3VRA_cjs.createRef; }
1511
1570
  });
1512
1571
  Object.defineProperty(exports, "createResource", {
1513
1572
  enumerable: true,
1514
- get: function () { return chunkVP5EOGM5_cjs.createResource; }
1573
+ get: function () { return chunkYSKF3VRA_cjs.createResource; }
1515
1574
  });
1516
1575
  Object.defineProperty(exports, "createRoot", {
1517
1576
  enumerable: true,
1518
- get: function () { return chunkVP5EOGM5_cjs.createRoot; }
1577
+ get: function () { return chunkYSKF3VRA_cjs.createRoot; }
1519
1578
  });
1520
1579
  Object.defineProperty(exports, "createShow", {
1521
1580
  enumerable: true,
1522
- get: function () { return chunkVP5EOGM5_cjs.createShow; }
1581
+ get: function () { return chunkYSKF3VRA_cjs.createShow; }
1523
1582
  });
1524
1583
  Object.defineProperty(exports, "fragment", {
1525
1584
  enumerable: true,
1526
- get: function () { return chunkVP5EOGM5_cjs.fragment; }
1585
+ get: function () { return chunkYSKF3VRA_cjs.fragment; }
1527
1586
  });
1528
1587
  Object.defineProperty(exports, "h", {
1529
1588
  enumerable: true,
1530
- get: function () { return chunkVP5EOGM5_cjs.h; }
1589
+ get: function () { return chunkYSKF3VRA_cjs.h; }
1531
1590
  });
1532
1591
  Object.defineProperty(exports, "hydrateIsland", {
1533
1592
  enumerable: true,
1534
- get: function () { return chunkVP5EOGM5_cjs.hydrateIsland; }
1535
- });
1536
- Object.defineProperty(exports, "longestIncreasingSubsequence", {
1537
- enumerable: true,
1538
- get: function () { return chunkVP5EOGM5_cjs.longestIncreasingSubsequence; }
1593
+ get: function () { return chunkYSKF3VRA_cjs.hydrateIsland; }
1539
1594
  });
1540
1595
  Object.defineProperty(exports, "on", {
1541
1596
  enumerable: true,
1542
- get: function () { return chunkVP5EOGM5_cjs.on; }
1597
+ get: function () { return chunkYSKF3VRA_cjs.on; }
1543
1598
  });
1544
1599
  Object.defineProperty(exports, "onCleanup", {
1545
1600
  enumerable: true,
1546
- get: function () { return chunkVP5EOGM5_cjs.onCleanup; }
1601
+ get: function () { return chunkYSKF3VRA_cjs.onCleanup; }
1547
1602
  });
1548
1603
  Object.defineProperty(exports, "onError", {
1549
1604
  enumerable: true,
1550
- get: function () { return chunkVP5EOGM5_cjs.onError; }
1605
+ get: function () { return chunkYSKF3VRA_cjs.onError; }
1551
1606
  });
1552
1607
  Object.defineProperty(exports, "reconcileList", {
1553
1608
  enumerable: true,
1554
- get: function () { return chunkVP5EOGM5_cjs.reconcileList; }
1609
+ get: function () { return chunkYSKF3VRA_cjs.reconcileList; }
1555
1610
  });
1556
1611
  Object.defineProperty(exports, "untrack", {
1557
1612
  enumerable: true,
1558
- get: function () { return chunkVP5EOGM5_cjs.untrack; }
1613
+ get: function () { return chunkYSKF3VRA_cjs.untrack; }
1559
1614
  });
1560
1615
  Object.defineProperty(exports, "createComputed", {
1561
1616
  enumerable: true,
1562
- get: function () { return chunkFPSLC62A_cjs.createComputed; }
1617
+ get: function () { return chunkKH3F5NRU_cjs.createComputed; }
1563
1618
  });
1564
1619
  Object.defineProperty(exports, "createSignal", {
1565
1620
  enumerable: true,
1566
- get: function () { return chunkFPSLC62A_cjs.createSignal; }
1621
+ get: function () { return chunkKH3F5NRU_cjs.createSignal; }
1567
1622
  });
1568
1623
  exports.$ = $;
1569
1624
  exports.$$ = $$;
@@ -1590,6 +1645,8 @@ exports.createSuspense = createSuspense;
1590
1645
  exports.createSwitch = createSwitch;
1591
1646
  exports.createText = createText;
1592
1647
  exports.createWebSocket = createWebSocket;
1648
+ exports.deactivateAllIslands = deactivateAllIslands;
1649
+ exports.deactivateIsland = deactivateIsland;
1593
1650
  exports.defineComponent = defineComponent;
1594
1651
  exports.delegate = delegate;
1595
1652
  exports.disposeComponent = disposeComponent;
@@ -1618,6 +1675,7 @@ exports.renderIsland = renderIsland;
1618
1675
  exports.renderLocal = renderLocal;
1619
1676
  exports.setAttr = setAttr;
1620
1677
  exports.setHTML = setHTML;
1678
+ exports.setHTMLUnsafe = setHTMLUnsafe;
1621
1679
  exports.setStyle = setStyle;
1622
1680
  exports.setText = setText;
1623
1681
  exports.siblings = siblings;