sibujs 3.3.1 → 3.3.2

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 (60) hide show
  1. package/dist/browser.cjs +21 -15
  2. package/dist/browser.js +5 -5
  3. package/dist/build.cjs +48 -20
  4. package/dist/build.js +13 -13
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-IKLYI3RF.js → chunk-2ARSB7NG.js} +36 -13
  7. package/dist/{chunk-TEFZT5PJ.js → chunk-4NJEAPLI.js} +1 -1
  8. package/dist/{chunk-F7FXQ3QS.js → chunk-5VH3GIDX.js} +1 -1
  9. package/dist/{chunk-RYMOSG5B.js → chunk-62V653X2.js} +16 -21
  10. package/dist/{chunk-XH2RTYEQ.js → chunk-655B7MMR.js} +3 -3
  11. package/dist/{chunk-37BUKSLH.js → chunk-6TCOWMGY.js} +1 -1
  12. package/dist/{chunk-6LTFHJQG.js → chunk-A7CZH3GN.js} +3 -3
  13. package/dist/{chunk-ULLTNDRA.js → chunk-AEOLHSSQ.js} +3 -3
  14. package/dist/chunk-CCSJMTRN.js +15 -0
  15. package/dist/{chunk-R3QEDXFS.js → chunk-EX77FXTT.js} +1 -1
  16. package/dist/{chunk-ZUVLC7TM.js → chunk-FJIRS3FM.js} +1 -1
  17. package/dist/{chunk-Z37APKBV.js → chunk-FJO2ZL4Q.js} +4 -4
  18. package/dist/{chunk-WW6DAGGR.js → chunk-G6N3LMO2.js} +1 -1
  19. package/dist/{chunk-WL7BIR6O.js → chunk-IQJ36UTJ.js} +1 -1
  20. package/dist/{chunk-WZG2SZOT.js → chunk-JCQG2I2G.js} +1 -1
  21. package/dist/{chunk-MHBCEJQO.js → chunk-N5TQVEKE.js} +2 -2
  22. package/dist/{chunk-4UUMSLSL.js → chunk-P7C7SEJV.js} +4 -4
  23. package/dist/{chunk-VOVVTOEA.js → chunk-Q46YIQYW.js} +2 -2
  24. package/dist/{chunk-NHKQKKZU.js → chunk-QCFBIVIQ.js} +1 -1
  25. package/dist/{chunk-SLMFA3ZZ.js → chunk-RLTFJYDN.js} +2 -2
  26. package/dist/{chunk-GOJMFRBL.js → chunk-S3NFJO6L.js} +20 -14
  27. package/dist/{chunk-AMIKDMLP.js → chunk-YUBEOWII.js} +5 -5
  28. package/dist/{chunk-M5KBNOSJ.js → chunk-YUR5SX7F.js} +2 -2
  29. package/dist/{chunk-LU2MQXQQ.js → chunk-ZEUP4TUD.js} +2 -2
  30. package/dist/data.cjs +21 -15
  31. package/dist/data.js +7 -7
  32. package/dist/devtools.cjs +21 -15
  33. package/dist/devtools.js +5 -5
  34. package/dist/ecosystem.cjs +21 -15
  35. package/dist/ecosystem.js +8 -8
  36. package/dist/extras.cjs +32 -31
  37. package/dist/extras.js +22 -22
  38. package/dist/index.cjs +50 -20
  39. package/dist/index.d.cts +20 -7
  40. package/dist/index.d.ts +20 -7
  41. package/dist/index.js +17 -13
  42. package/dist/motion.cjs +1 -1
  43. package/dist/motion.js +3 -3
  44. package/dist/patterns.cjs +21 -15
  45. package/dist/patterns.js +6 -6
  46. package/dist/performance.cjs +21 -15
  47. package/dist/performance.js +6 -6
  48. package/dist/plugins.cjs +110 -103
  49. package/dist/plugins.js +95 -94
  50. package/dist/{ssr-6D67RAVB.js → ssr-2PPULEK2.js} +2 -2
  51. package/dist/ssr.cjs +21 -15
  52. package/dist/ssr.js +9 -9
  53. package/dist/testing.cjs +21 -15
  54. package/dist/testing.js +3 -3
  55. package/dist/ui.cjs +36 -34
  56. package/dist/ui.js +8 -8
  57. package/dist/widgets.cjs +21 -15
  58. package/dist/widgets.js +7 -7
  59. package/package.json +1 -1
  60. package/dist/chunk-YT6HQ6AM.js +0 -14
package/dist/devtools.cjs CHANGED
@@ -609,7 +609,7 @@ function forEachSubscriber(signal2, visit) {
609
609
 
610
610
  // src/reactivity/track.ts
611
611
  var _isDev3 = isDev();
612
- var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
612
+ var _runtimeVersion = true ? "3.3.2" : "dev";
613
613
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
614
614
  function resolveReactiveApi() {
615
615
  const g = globalThis;
@@ -1767,23 +1767,29 @@ function formatError(error, context, seen = /* @__PURE__ */ new Set([error])) {
1767
1767
  }
1768
1768
 
1769
1769
  // src/core/ssr-context.ts
1770
- var als = null;
1771
- try {
1772
- if (typeof process !== "undefined" && process.versions && process.versions.node) {
1773
- let mod = null;
1774
- const getBuiltin = process.getBuiltinModule;
1775
- if (typeof getBuiltin === "function") {
1776
- mod = getBuiltin("node:async_hooks");
1777
- } else {
1778
- const req = Function("return typeof require==='function'?require:null")();
1779
- if (req) mod = req("node:async_hooks");
1770
+ var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
1771
+ function detectSSRShared() {
1772
+ let detected = null;
1773
+ try {
1774
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
1775
+ let mod = null;
1776
+ const getBuiltin = process.getBuiltinModule;
1777
+ if (typeof getBuiltin === "function") {
1778
+ mod = getBuiltin("node:async_hooks");
1779
+ } else {
1780
+ const req = Function("return typeof require==='function'?require:null")();
1781
+ if (req) mod = req("node:async_hooks");
1782
+ }
1783
+ if (mod) detected = new mod.AsyncLocalStorage();
1780
1784
  }
1781
- if (mod) als = new mod.AsyncLocalStorage();
1785
+ } catch {
1786
+ detected = null;
1782
1787
  }
1783
- } catch {
1784
- als = null;
1788
+ return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
1785
1789
  }
1786
- var fallbackStore = { ssr: false, suspenseIdCounter: 0 };
1790
+ var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
1791
+ var als = _shared.als;
1792
+ var fallbackStore = _shared.fallbackStore;
1787
1793
  function getSSRStore() {
1788
1794
  if (als) {
1789
1795
  const s = als.getStore();
package/dist/devtools.js CHANGED
@@ -35,13 +35,13 @@ import {
35
35
  trackCleanup,
36
36
  walkDependencyGraph,
37
37
  withErrorTracking
38
- } from "./chunk-ULLTNDRA.js";
38
+ } from "./chunk-AEOLHSSQ.js";
39
39
  import "./chunk-5VGSK6D2.js";
40
40
  import "./chunk-L3GAGWCC.js";
41
- import "./chunk-MHBCEJQO.js";
42
- import "./chunk-GOJMFRBL.js";
43
- import "./chunk-WZG2SZOT.js";
44
- import "./chunk-TEFZT5PJ.js";
41
+ import "./chunk-N5TQVEKE.js";
42
+ import "./chunk-S3NFJO6L.js";
43
+ import "./chunk-JCQG2I2G.js";
44
+ import "./chunk-4NJEAPLI.js";
45
45
  import {
46
46
  isDev
47
47
  } from "./chunk-COY6PUD2.js";
@@ -469,7 +469,7 @@ function forEachSubscriber(signal2, visit) {
469
469
 
470
470
  // src/reactivity/track.ts
471
471
  var _isDev3 = isDev();
472
- var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
472
+ var _runtimeVersion = true ? "3.3.2" : "dev";
473
473
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
474
474
  function resolveReactiveApi() {
475
475
  const g = globalThis;
@@ -526,23 +526,29 @@ var getSubscriberDeps2 = API.getSubscriberDeps;
526
526
  var forEachSubscriber2 = API.forEachSubscriber;
527
527
 
528
528
  // src/core/ssr-context.ts
529
- var als = null;
530
- try {
531
- if (typeof process !== "undefined" && process.versions && process.versions.node) {
532
- let mod = null;
533
- const getBuiltin = process.getBuiltinModule;
534
- if (typeof getBuiltin === "function") {
535
- mod = getBuiltin("node:async_hooks");
536
- } else {
537
- const req = Function("return typeof require==='function'?require:null")();
538
- if (req) mod = req("node:async_hooks");
529
+ var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
530
+ function detectSSRShared() {
531
+ let detected = null;
532
+ try {
533
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
534
+ let mod = null;
535
+ const getBuiltin = process.getBuiltinModule;
536
+ if (typeof getBuiltin === "function") {
537
+ mod = getBuiltin("node:async_hooks");
538
+ } else {
539
+ const req = Function("return typeof require==='function'?require:null")();
540
+ if (req) mod = req("node:async_hooks");
541
+ }
542
+ if (mod) detected = new mod.AsyncLocalStorage();
539
543
  }
540
- if (mod) als = new mod.AsyncLocalStorage();
544
+ } catch {
545
+ detected = null;
541
546
  }
542
- } catch {
543
- als = null;
547
+ return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
544
548
  }
545
- var fallbackStore = { ssr: false, suspenseIdCounter: 0 };
549
+ var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
550
+ var als = _shared.als;
551
+ var fallbackStore = _shared.fallbackStore;
546
552
  function getSSRStore() {
547
553
  if (als) {
548
554
  const s = als.getStore();
package/dist/ecosystem.js CHANGED
@@ -7,17 +7,17 @@ import {
7
7
  mobXAdapter,
8
8
  reduxAdapter,
9
9
  zustandAdapter
10
- } from "./chunk-4UUMSLSL.js";
10
+ } from "./chunk-P7C7SEJV.js";
11
11
  import "./chunk-3JHCYHWN.js";
12
- import "./chunk-LU2MQXQQ.js";
13
- import "./chunk-NHKQKKZU.js";
14
- import "./chunk-WW6DAGGR.js";
12
+ import "./chunk-ZEUP4TUD.js";
13
+ import "./chunk-QCFBIVIQ.js";
14
+ import "./chunk-G6N3LMO2.js";
15
15
  import "./chunk-5VGSK6D2.js";
16
16
  import "./chunk-L3GAGWCC.js";
17
- import "./chunk-MHBCEJQO.js";
18
- import "./chunk-GOJMFRBL.js";
19
- import "./chunk-WZG2SZOT.js";
20
- import "./chunk-TEFZT5PJ.js";
17
+ import "./chunk-N5TQVEKE.js";
18
+ import "./chunk-S3NFJO6L.js";
19
+ import "./chunk-JCQG2I2G.js";
20
+ import "./chunk-4NJEAPLI.js";
21
21
  import "./chunk-COY6PUD2.js";
22
22
  export {
23
23
  antdAdapter,
package/dist/extras.cjs CHANGED
@@ -753,7 +753,7 @@ function forEachSubscriber(signal2, visit) {
753
753
 
754
754
  // src/reactivity/track.ts
755
755
  var _isDev3 = isDev();
756
- var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
756
+ var _runtimeVersion = true ? "3.3.2" : "dev";
757
757
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
758
758
  function resolveReactiveApi() {
759
759
  const g2 = globalThis;
@@ -889,23 +889,29 @@ function derived(getter, options) {
889
889
  }
890
890
 
891
891
  // src/core/ssr-context.ts
892
- var als = null;
893
- try {
894
- if (typeof process !== "undefined" && process.versions && process.versions.node) {
895
- let mod = null;
896
- const getBuiltin = process.getBuiltinModule;
897
- if (typeof getBuiltin === "function") {
898
- mod = getBuiltin("node:async_hooks");
899
- } else {
900
- const req = Function("return typeof require==='function'?require:null")();
901
- if (req) mod = req("node:async_hooks");
892
+ var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
893
+ function detectSSRShared() {
894
+ let detected = null;
895
+ try {
896
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
897
+ let mod = null;
898
+ const getBuiltin = process.getBuiltinModule;
899
+ if (typeof getBuiltin === "function") {
900
+ mod = getBuiltin("node:async_hooks");
901
+ } else {
902
+ const req = Function("return typeof require==='function'?require:null")();
903
+ if (req) mod = req("node:async_hooks");
904
+ }
905
+ if (mod) detected = new mod.AsyncLocalStorage();
902
906
  }
903
- if (mod) als = new mod.AsyncLocalStorage();
907
+ } catch {
908
+ detected = null;
904
909
  }
905
- } catch {
906
- als = null;
910
+ return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
907
911
  }
908
- var fallbackStore = { ssr: false, suspenseIdCounter: 0 };
912
+ var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
913
+ var als = _shared.als;
914
+ var fallbackStore = _shared.fallbackStore;
909
915
  function getSSRStore() {
910
916
  if (als) {
911
917
  const s2 = als.getStore();
@@ -4836,23 +4842,18 @@ function custom(fn, message) {
4836
4842
  return (value) => fn(value) ? null : message;
4837
4843
  }
4838
4844
  function bindField(field, extras) {
4845
+ const readControlValue = (target) => {
4846
+ if ("checked" in target && target.type === "checkbox") {
4847
+ return target.checked;
4848
+ }
4849
+ if (target instanceof HTMLSelectElement && target.multiple) {
4850
+ return Array.from(target.selectedOptions, (o) => o.value);
4851
+ }
4852
+ return target.value;
4853
+ };
4839
4854
  const fieldOn = {
4840
- input: (e) => {
4841
- const target = e.target;
4842
- if (target.type === "checkbox") {
4843
- field.set(target.checked);
4844
- } else {
4845
- field.set(target.value);
4846
- }
4847
- },
4848
- change: (e) => {
4849
- const target = e.target;
4850
- if ("checked" in target && target.type === "checkbox") {
4851
- field.set(target.checked);
4852
- } else {
4853
- field.set(target.value);
4854
- }
4855
- },
4855
+ input: (e) => field.set(readControlValue(e.target)),
4856
+ change: (e) => field.set(readControlValue(e.target)),
4856
4857
  blur: () => field.touch()
4857
4858
  };
4858
4859
  const { on: extraOn, value: _ignoreValue, ...restExtras } = extras ?? {};
package/dist/extras.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  optimisticList,
6
6
  persisted,
7
7
  timeline
8
- } from "./chunk-XH2RTYEQ.js";
8
+ } from "./chunk-655B7MMR.js";
9
9
  import {
10
10
  DOMPool,
11
11
  Features,
@@ -41,7 +41,7 @@ import {
41
41
  transitionState,
42
42
  uniqueId,
43
43
  yieldToMain
44
- } from "./chunk-M5KBNOSJ.js";
44
+ } from "./chunk-YUR5SX7F.js";
45
45
  import {
46
46
  VERSION,
47
47
  bundlerMetadata,
@@ -62,7 +62,7 @@ import {
62
62
  preloadCritical,
63
63
  prerenderRoutes,
64
64
  satisfies
65
- } from "./chunk-ZUVLC7TM.js";
65
+ } from "./chunk-FJIRS3FM.js";
66
66
  import {
67
67
  Head,
68
68
  clearWasmCache,
@@ -87,7 +87,7 @@ import {
87
87
  wasm,
88
88
  worker,
89
89
  workerFn
90
- } from "./chunk-6LTFHJQG.js";
90
+ } from "./chunk-A7CZH3GN.js";
91
91
  import {
92
92
  FocusTrap,
93
93
  VirtualList,
@@ -128,7 +128,7 @@ import {
128
128
  toast,
129
129
  withScopedStyle,
130
130
  zipMask
131
- } from "./chunk-RYMOSG5B.js";
131
+ } from "./chunk-62V653X2.js";
132
132
  import {
133
133
  RenderProp,
134
134
  assertType,
@@ -155,7 +155,7 @@ import {
155
155
  select,
156
156
  tabs,
157
157
  tooltip
158
- } from "./chunk-Z37APKBV.js";
158
+ } from "./chunk-FJO2ZL4Q.js";
159
159
  import {
160
160
  animationFrame,
161
161
  battery,
@@ -193,7 +193,7 @@ import {
193
193
  visibility,
194
194
  wakeLock,
195
195
  windowSize
196
- } from "./chunk-VOVVTOEA.js";
196
+ } from "./chunk-Q46YIQYW.js";
197
197
  import "./chunk-H3SRKIYX.js";
198
198
  import {
199
199
  __resetQueryCache,
@@ -217,7 +217,7 @@ import {
217
217
  syncAdapter,
218
218
  throttle,
219
219
  withRetry
220
- } from "./chunk-AMIKDMLP.js";
220
+ } from "./chunk-YUBEOWII.js";
221
221
  import {
222
222
  SibuError,
223
223
  checkLeaks,
@@ -255,7 +255,7 @@ import {
255
255
  trackCleanup,
256
256
  walkDependencyGraph,
257
257
  withErrorTracking
258
- } from "./chunk-ULLTNDRA.js";
258
+ } from "./chunk-AEOLHSSQ.js";
259
259
  import {
260
260
  antdAdapter,
261
261
  chakraAdapter,
@@ -265,7 +265,7 @@ import {
265
265
  mobXAdapter,
266
266
  reduxAdapter,
267
267
  zustandAdapter
268
- } from "./chunk-4UUMSLSL.js";
268
+ } from "./chunk-P7C7SEJV.js";
269
269
  import {
270
270
  createPlugin,
271
271
  createPluginRegistry,
@@ -277,8 +277,8 @@ import {
277
277
  triggerPluginMount,
278
278
  triggerPluginUnmount
279
279
  } from "./chunk-3JHCYHWN.js";
280
- import "./chunk-37BUKSLH.js";
281
- import "./chunk-SLMFA3ZZ.js";
280
+ import "./chunk-6TCOWMGY.js";
281
+ import "./chunk-RLTFJYDN.js";
282
282
  import {
283
283
  collectStream,
284
284
  deserializeState,
@@ -298,15 +298,15 @@ import {
298
298
  ssrSuspense,
299
299
  suspenseSwapScript,
300
300
  trustHTML
301
- } from "./chunk-R3QEDXFS.js";
302
- import "./chunk-F7FXQ3QS.js";
303
- import "./chunk-LU2MQXQQ.js";
304
- import "./chunk-NHKQKKZU.js";
305
- import "./chunk-WW6DAGGR.js";
301
+ } from "./chunk-EX77FXTT.js";
302
+ import "./chunk-5VH3GIDX.js";
303
+ import "./chunk-ZEUP4TUD.js";
304
+ import "./chunk-QCFBIVIQ.js";
305
+ import "./chunk-G6N3LMO2.js";
306
306
  import "./chunk-5VGSK6D2.js";
307
307
  import "./chunk-L3GAGWCC.js";
308
- import "./chunk-MHBCEJQO.js";
309
- import "./chunk-GOJMFRBL.js";
308
+ import "./chunk-N5TQVEKE.js";
309
+ import "./chunk-S3NFJO6L.js";
310
310
  import {
311
311
  TransitionGroup,
312
312
  animate,
@@ -328,9 +328,9 @@ import {
328
328
  stagger,
329
329
  transition,
330
330
  viewTransition
331
- } from "./chunk-WL7BIR6O.js";
332
- import "./chunk-WZG2SZOT.js";
333
- import "./chunk-TEFZT5PJ.js";
331
+ } from "./chunk-IQJ36UTJ.js";
332
+ import "./chunk-JCQG2I2G.js";
333
+ import "./chunk-4NJEAPLI.js";
334
334
  import "./chunk-COY6PUD2.js";
335
335
  export {
336
336
  DOMPool,
package/dist/index.cjs CHANGED
@@ -99,6 +99,7 @@ __export(index_exports, {
99
99
  footer: () => footer,
100
100
  form: () => form,
101
101
  g: () => g,
102
+ getAction: () => getAction,
102
103
  getRequestScopedCache: () => getRequestScopedCache,
103
104
  getSSRStore: () => getSSRStore,
104
105
  getSlot: () => getSlot,
@@ -167,6 +168,7 @@ __export(index_exports, {
167
168
  reactiveArray: () => reactiveArray,
168
169
  rect: () => rect,
169
170
  ref: () => ref,
171
+ registerAction: () => registerAction,
170
172
  registerComponent: () => registerComponent,
171
173
  registerDisposer: () => registerDisposer,
172
174
  resolveComponent: () => resolveComponent,
@@ -755,7 +757,7 @@ function forEachSubscriber(signal2, visit) {
755
757
 
756
758
  // src/reactivity/track.ts
757
759
  var _isDev3 = isDev();
758
- var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
760
+ var _runtimeVersion = true ? "3.3.2" : "dev";
759
761
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
760
762
  function resolveReactiveApi() {
761
763
  const g2 = globalThis;
@@ -2329,7 +2331,21 @@ function KeepAlive(activeKey, cases, options) {
2329
2331
  }
2330
2332
 
2331
2333
  // src/core/rendering/action.ts
2332
- function action(element, actionFn, param2) {
2334
+ var ACTIONS_KEY = /* @__PURE__ */ Symbol.for("sibujs.actions.v1");
2335
+ var _actions = globalThis[ACTIONS_KEY] ?? (globalThis[ACTIONS_KEY] = /* @__PURE__ */ new Map());
2336
+ function registerAction(name, fn) {
2337
+ _actions.set(name, fn);
2338
+ }
2339
+ function getAction(name) {
2340
+ return _actions.get(name);
2341
+ }
2342
+ function action(element, action2, param2) {
2343
+ const actionFn = typeof action2 === "string" ? getAction(action2) : action2;
2344
+ if (!actionFn) {
2345
+ throw new Error(
2346
+ `[SibuJS] No action registered under the name "${action2}". Register it with registerAction() before applying it by name.`
2347
+ );
2348
+ }
2333
2349
  const cleanup3 = actionFn(element, param2);
2334
2350
  if (typeof cleanup3 === "function") {
2335
2351
  registerDisposer(element, cleanup3);
@@ -2406,6 +2422,11 @@ var trapFocus = (element) => {
2406
2422
  element.addEventListener("keydown", handler);
2407
2423
  return () => element.removeEventListener("keydown", handler);
2408
2424
  };
2425
+ registerAction("clickOutside", clickOutside);
2426
+ registerAction("longPress", longPress);
2427
+ registerAction("copyOnClick", copyOnClick);
2428
+ registerAction("autoResize", autoResize);
2429
+ registerAction("trapFocus", trapFocus);
2409
2430
 
2410
2431
  // src/core/rendering/catch.ts
2411
2432
  var globalErrorHandler = null;
@@ -2454,13 +2475,14 @@ function setGlobalErrorHandler(handler) {
2454
2475
  }
2455
2476
 
2456
2477
  // src/core/rendering/createId.ts
2457
- var idCounter = 0;
2478
+ var COUNTER_KEY = /* @__PURE__ */ Symbol.for("sibujs.createId.v1");
2479
+ var _counter = globalThis[COUNTER_KEY] ?? (globalThis[COUNTER_KEY] = { n: 0 });
2458
2480
  function createId(prefix = "sibu") {
2459
- idCounter++;
2460
- return `${prefix}-${idCounter}`;
2481
+ _counter.n++;
2482
+ return `${prefix}-${_counter.n}`;
2461
2483
  }
2462
2484
  function __resetIdCounter() {
2463
- idCounter = 0;
2485
+ _counter.n = 0;
2464
2486
  }
2465
2487
 
2466
2488
  // src/reactivity/batch.ts
@@ -2584,23 +2606,29 @@ function signal(initial, options) {
2584
2606
  }
2585
2607
 
2586
2608
  // src/core/ssr-context.ts
2587
- var als = null;
2588
- try {
2589
- if (typeof process !== "undefined" && process.versions && process.versions.node) {
2590
- let mod = null;
2591
- const getBuiltin = process.getBuiltinModule;
2592
- if (typeof getBuiltin === "function") {
2593
- mod = getBuiltin("node:async_hooks");
2594
- } else {
2595
- const req = Function("return typeof require==='function'?require:null")();
2596
- if (req) mod = req("node:async_hooks");
2609
+ var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
2610
+ function detectSSRShared() {
2611
+ let detected = null;
2612
+ try {
2613
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
2614
+ let mod = null;
2615
+ const getBuiltin = process.getBuiltinModule;
2616
+ if (typeof getBuiltin === "function") {
2617
+ mod = getBuiltin("node:async_hooks");
2618
+ } else {
2619
+ const req = Function("return typeof require==='function'?require:null")();
2620
+ if (req) mod = req("node:async_hooks");
2621
+ }
2622
+ if (mod) detected = new mod.AsyncLocalStorage();
2597
2623
  }
2598
- if (mod) als = new mod.AsyncLocalStorage();
2624
+ } catch {
2625
+ detected = null;
2599
2626
  }
2600
- } catch {
2601
- als = null;
2627
+ return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
2602
2628
  }
2603
- var fallbackStore = { ssr: false, suspenseIdCounter: 0 };
2629
+ var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
2630
+ var als = _shared.als;
2631
+ var fallbackStore = _shared.fallbackStore;
2604
2632
  function getSSRStore() {
2605
2633
  if (als) {
2606
2634
  const s2 = als.getStore();
@@ -4724,6 +4752,7 @@ function Loading(props = {}) {
4724
4752
  footer,
4725
4753
  form,
4726
4754
  g,
4755
+ getAction,
4727
4756
  getRequestScopedCache,
4728
4757
  getSSRStore,
4729
4758
  getSlot,
@@ -4792,6 +4821,7 @@ function Loading(props = {}) {
4792
4821
  reactiveArray,
4793
4822
  rect,
4794
4823
  ref,
4824
+ registerAction,
4795
4825
  registerComponent,
4796
4826
  registerDisposer,
4797
4827
  resolveComponent,
package/dist/index.d.cts CHANGED
@@ -525,29 +525,42 @@ declare function KeepAlive(activeKey: () => string, cases: Record<string, () =>
525
525
  * a cleanup function that runs when the element is disposed.
526
526
  */
527
527
  type ActionFn<T = void> = (element: HTMLElement, param: T) => (() => void) | undefined;
528
+ /**
529
+ * Register a reusable action under a name so it can be applied by string —
530
+ * `action(el, "name", param)` — or looked up via {@link getAction}.
531
+ *
532
+ * Re-registering the same name overwrites the previous action. The built-in
533
+ * actions (`clickOutside`, `longPress`, `copyOnClick`, `autoResize`,
534
+ * `trapFocus`) are auto-registered under their export names.
535
+ */
536
+ declare function registerAction<T>(name: string, fn: ActionFn<T>): void;
537
+ /** Look up a registered action by name, or `undefined` if none is registered. */
538
+ declare function getAction<T = unknown>(name: string): ActionFn<T> | undefined;
528
539
  /**
529
540
  * Attach a reusable action (element-level behavior) to an element.
530
541
  * The action's cleanup function (if returned) is automatically registered
531
542
  * via `registerDisposer`, so it runs when the element is disposed.
532
543
  *
533
- * Actions are composable multiple can be applied to the same element.
544
+ * The action may be passed directly, or by the name it was registered under
545
+ * (see {@link registerAction}). Actions are composable — multiple can be
546
+ * applied to the same element.
534
547
  *
535
548
  * @param element The target element
536
- * @param actionFn The action function
549
+ * @param action The action function, or the name of a registered action
537
550
  * @param param Optional parameter passed to the action
538
551
  *
539
552
  * @example
540
553
  * ```ts
541
554
  * div({
542
555
  * onElement: (el) => {
543
- * action(el, clickOutside, () => setOpen(false));
544
- * action(el, longPress, { duration: 500, callback: onLongPress });
556
+ * action(el, clickOutside, () => setOpen(false)); // by reference
557
+ * action(el, "longPress", { duration: 500, callback: onLongPress }); // by name
545
558
  * },
546
559
  * }, "Content");
547
560
  * ```
548
561
  */
549
- declare function action<T>(element: HTMLElement, actionFn: ActionFn<T>, param: T): void;
550
- declare function action(element: HTMLElement, actionFn: ActionFn<void>): void;
562
+ declare function action<T>(element: HTMLElement, action: ActionFn<T> | string, param: T): void;
563
+ declare function action(element: HTMLElement, action: ActionFn<void> | string): void;
551
564
  /**
552
565
  * Fires a callback when the user clicks outside the element.
553
566
  * Useful for closing dropdowns, modals, and popovers.
@@ -1615,4 +1628,4 @@ interface LoadingProps {
1615
1628
  */
1616
1629
  declare function Loading(props?: LoadingProps): HTMLElement;
1617
1630
 
1618
- export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectBody, type EffectOptions, ErrorBoundary, type ErrorBoundaryOptions, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OnCleanup, type OptionProps, Portal, type Ref, type SSRStore, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getRequestScopedCache, getSSRStore, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerComponent, registerDisposer, resolveComponent, retrack, rp, rt, ruby, runInSSRContext, s, samp, script, section, select, setGlobalErrorHandler, setMaxDrainIterations, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, takePendingError, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track$1 as track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
1631
+ export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectBody, type EffectOptions, ErrorBoundary, type ErrorBoundaryOptions, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OnCleanup, type OptionProps, Portal, type Ref, type SSRStore, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getAction, getRequestScopedCache, getSSRStore, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerAction, registerComponent, registerDisposer, resolveComponent, retrack, rp, rt, ruby, runInSSRContext, s, samp, script, section, select, setGlobalErrorHandler, setMaxDrainIterations, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, takePendingError, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track$1 as track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
package/dist/index.d.ts CHANGED
@@ -525,29 +525,42 @@ declare function KeepAlive(activeKey: () => string, cases: Record<string, () =>
525
525
  * a cleanup function that runs when the element is disposed.
526
526
  */
527
527
  type ActionFn<T = void> = (element: HTMLElement, param: T) => (() => void) | undefined;
528
+ /**
529
+ * Register a reusable action under a name so it can be applied by string —
530
+ * `action(el, "name", param)` — or looked up via {@link getAction}.
531
+ *
532
+ * Re-registering the same name overwrites the previous action. The built-in
533
+ * actions (`clickOutside`, `longPress`, `copyOnClick`, `autoResize`,
534
+ * `trapFocus`) are auto-registered under their export names.
535
+ */
536
+ declare function registerAction<T>(name: string, fn: ActionFn<T>): void;
537
+ /** Look up a registered action by name, or `undefined` if none is registered. */
538
+ declare function getAction<T = unknown>(name: string): ActionFn<T> | undefined;
528
539
  /**
529
540
  * Attach a reusable action (element-level behavior) to an element.
530
541
  * The action's cleanup function (if returned) is automatically registered
531
542
  * via `registerDisposer`, so it runs when the element is disposed.
532
543
  *
533
- * Actions are composable multiple can be applied to the same element.
544
+ * The action may be passed directly, or by the name it was registered under
545
+ * (see {@link registerAction}). Actions are composable — multiple can be
546
+ * applied to the same element.
534
547
  *
535
548
  * @param element The target element
536
- * @param actionFn The action function
549
+ * @param action The action function, or the name of a registered action
537
550
  * @param param Optional parameter passed to the action
538
551
  *
539
552
  * @example
540
553
  * ```ts
541
554
  * div({
542
555
  * onElement: (el) => {
543
- * action(el, clickOutside, () => setOpen(false));
544
- * action(el, longPress, { duration: 500, callback: onLongPress });
556
+ * action(el, clickOutside, () => setOpen(false)); // by reference
557
+ * action(el, "longPress", { duration: 500, callback: onLongPress }); // by name
545
558
  * },
546
559
  * }, "Content");
547
560
  * ```
548
561
  */
549
- declare function action<T>(element: HTMLElement, actionFn: ActionFn<T>, param: T): void;
550
- declare function action(element: HTMLElement, actionFn: ActionFn<void>): void;
562
+ declare function action<T>(element: HTMLElement, action: ActionFn<T> | string, param: T): void;
563
+ declare function action(element: HTMLElement, action: ActionFn<void> | string): void;
551
564
  /**
552
565
  * Fires a callback when the user clicks outside the element.
553
566
  * Useful for closing dropdowns, modals, and popovers.
@@ -1615,4 +1628,4 @@ interface LoadingProps {
1615
1628
  */
1616
1629
  declare function Loading(props?: LoadingProps): HTMLElement;
1617
1630
 
1618
- export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectBody, type EffectOptions, ErrorBoundary, type ErrorBoundaryOptions, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OnCleanup, type OptionProps, Portal, type Ref, type SSRStore, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getRequestScopedCache, getSSRStore, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerComponent, registerDisposer, resolveComponent, retrack, rp, rt, ruby, runInSSRContext, s, samp, script, section, select, setGlobalErrorHandler, setMaxDrainIterations, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, takePendingError, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track$1 as track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };
1631
+ export { type Accessor, type ActionFn, type AnchorProps, type ArrayActions, type AsyncDerivedState, type AudioProps, type ButtonProps, type Context, DynamicComponent, type EffectBody, type EffectOptions, ErrorBoundary, type ErrorBoundaryOptions, type ErrorBoundaryProps, ErrorDisplay, type ErrorDisplayProps, type ErrorSeverity, type FormProps, Fragment, type ImgProps, type InputProps, type InputType, KeepAlive, type KeepAliveOptions, type LabelProps, Loading, type LoadingProps, type LongPressOptions, type MediaProps, NodeChild, NodeChildren, type OnCleanup, type OptionProps, Portal, type Ref, type SSRStore, type SelectProps, type SignalOptions, type SlotFn, type Slots, type StoreActions, Suspense, type SuspenseProps, TagProps, type TextareaProps, type TypedTagFunction, type VideoProps, __resetIdCounter, a, abbr, action, address, area, array, article, aside, asyncDerived, audio, autoResize, b, base, batch, bdi, bdo, bindDynamic, blockquote, body, br, button, canvas, caption, catchError, catchErrorAsync, center, checkLeaks, circle, cite, clickOutside, clipPath, code, col, colgroup, context, copyOnClick, createId, customElement, data, datalist, dd, deepEqual, deepSignal, defer, defs, del, derived, details, dfn, dialog, disableSSR, dispose, div, dl, dt, each, effect, ellipse, em, embed, enableSSR, enqueueBatchedSignal, fieldset, figcaption, figure, font, footer, form, g, getAction, getRequestScopedCache, getSSRStore, getSlot, h1, h2, h3, h4, h5, h6, head, header, hr, html, i, iframe, img, input, ins, isBatching, isSSR, kbd, label, lazy, legend, li, line, linearGradient, link, longPress, main, map, mark, marker, marquee, mask, match, math, menu, meta, meter, mount, nav, nextTick, noscript, object, ol, on, onCleanup, onMount, onUnmount, optgroup, option, output, p, param, path, pattern, picture, polygon, polyline, portal, pre, progress, q, radialGradient, reactiveArray, rect, ref, registerAction, registerComponent, registerDisposer, resolveComponent, retrack, rp, rt, ruby, runInSSRContext, s, samp, script, section, select, setGlobalErrorHandler, setMaxDrainIterations, show, signal, slot, small, source, span, stop, store, strict, strictEffect, strong, style, sub, summary, sup, svg, symbol, table, takePendingError, tbody, td, template, text, textarea, tfoot, th, thead, time, title, tr, track$1 as track, transition, trapFocus, tspan, u, ul, unregisterComponent, untracked, use, var_, video, watch, when, withSSR, writable };