@hyperfixi/behaviors 3.3.0 → 4.0.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 (232) hide show
  1. package/CHANGELOG.md +199 -1
  2. package/README.md +29 -9
  3. package/dist/all.browser.global.js +45 -100
  4. package/dist/all.browser.global.js.map +1 -1
  5. package/dist/autodismiss.browser.global.js +5 -11
  6. package/dist/autodismiss.browser.global.js.map +1 -1
  7. package/dist/behaviors/autodismiss.cjs +19 -22
  8. package/dist/behaviors/autodismiss.cjs.map +1 -1
  9. package/dist/behaviors/autodismiss.d.cts +4 -4
  10. package/dist/behaviors/autodismiss.d.ts +4 -4
  11. package/dist/behaviors/autodismiss.js +3 -3
  12. package/dist/behaviors/clickoutside.cjs +19 -18
  13. package/dist/behaviors/clickoutside.cjs.map +1 -1
  14. package/dist/behaviors/clickoutside.d.cts +4 -4
  15. package/dist/behaviors/clickoutside.d.ts +4 -4
  16. package/dist/behaviors/clickoutside.js +3 -3
  17. package/dist/behaviors/clipboard.cjs +18 -19
  18. package/dist/behaviors/clipboard.cjs.map +1 -1
  19. package/dist/behaviors/clipboard.d.cts +4 -4
  20. package/dist/behaviors/clipboard.d.ts +4 -4
  21. package/dist/behaviors/clipboard.js +3 -3
  22. package/dist/behaviors/draggable.cjs +20 -25
  23. package/dist/behaviors/draggable.cjs.map +1 -1
  24. package/dist/behaviors/draggable.d.cts +4 -4
  25. package/dist/behaviors/draggable.d.ts +4 -4
  26. package/dist/behaviors/draggable.js +3 -3
  27. package/dist/behaviors/focustrap.cjs +18 -19
  28. package/dist/behaviors/focustrap.cjs.map +1 -1
  29. package/dist/behaviors/focustrap.d.cts +4 -4
  30. package/dist/behaviors/focustrap.d.ts +4 -4
  31. package/dist/behaviors/focustrap.js +3 -3
  32. package/dist/behaviors/removable.cjs +18 -21
  33. package/dist/behaviors/removable.cjs.map +1 -1
  34. package/dist/behaviors/removable.d.cts +4 -3
  35. package/dist/behaviors/removable.d.ts +4 -3
  36. package/dist/behaviors/removable.js +3 -3
  37. package/dist/behaviors/resizable.cjs +19 -19
  38. package/dist/behaviors/resizable.cjs.map +1 -1
  39. package/dist/behaviors/resizable.d.cts +4 -4
  40. package/dist/behaviors/resizable.d.ts +4 -4
  41. package/dist/behaviors/resizable.js +3 -3
  42. package/dist/behaviors/scrollreveal.cjs +19 -22
  43. package/dist/behaviors/scrollreveal.cjs.map +1 -1
  44. package/dist/behaviors/scrollreveal.d.cts +4 -4
  45. package/dist/behaviors/scrollreveal.d.ts +4 -4
  46. package/dist/behaviors/scrollreveal.js +3 -3
  47. package/dist/behaviors/sortable.cjs +19 -20
  48. package/dist/behaviors/sortable.cjs.map +1 -1
  49. package/dist/behaviors/sortable.d.cts +4 -4
  50. package/dist/behaviors/sortable.d.ts +4 -4
  51. package/dist/behaviors/sortable.js +3 -3
  52. package/dist/behaviors/tabs.cjs +20 -25
  53. package/dist/behaviors/tabs.cjs.map +1 -1
  54. package/dist/behaviors/tabs.d.cts +4 -4
  55. package/dist/behaviors/tabs.d.ts +4 -4
  56. package/dist/behaviors/tabs.js +3 -3
  57. package/dist/behaviors/toggleable.cjs +25 -26
  58. package/dist/behaviors/toggleable.cjs.map +1 -1
  59. package/dist/behaviors/toggleable.d.cts +4 -4
  60. package/dist/behaviors/toggleable.d.ts +4 -4
  61. package/dist/behaviors/toggleable.js +3 -3
  62. package/dist/chunk-2GIS4DCY.js +30 -0
  63. package/dist/chunk-2GIS4DCY.js.map +1 -0
  64. package/dist/chunk-3BCBZR6R.js +30 -0
  65. package/dist/chunk-3BCBZR6R.js.map +1 -0
  66. package/dist/chunk-4YUIDZAO.js +30 -0
  67. package/dist/chunk-4YUIDZAO.js.map +1 -0
  68. package/dist/{chunk-XYZ7FOXJ.js → chunk-AQCOK5J5.js} +10 -14
  69. package/dist/chunk-AQCOK5J5.js.map +1 -0
  70. package/dist/chunk-ATGHQQC7.js +30 -0
  71. package/dist/chunk-ATGHQQC7.js.map +1 -0
  72. package/dist/{chunk-HQDYH45I.js → chunk-CWLAXLWR.js} +5 -13
  73. package/dist/chunk-CWLAXLWR.js.map +1 -0
  74. package/dist/chunk-DMWN52SV.js +30 -0
  75. package/dist/chunk-DMWN52SV.js.map +1 -0
  76. package/dist/{chunk-PDMOOWFW.js → chunk-EIVPVTUI.js} +4 -8
  77. package/dist/{chunk-PDMOOWFW.js.map → chunk-EIVPVTUI.js.map} +1 -1
  78. package/dist/chunk-HHTEMPIT.js +30 -0
  79. package/dist/chunk-HHTEMPIT.js.map +1 -0
  80. package/dist/{chunk-26IX7QU7.js → chunk-HJESSMKB.js} +4 -6
  81. package/dist/{chunk-26IX7QU7.js.map → chunk-HJESSMKB.js.map} +1 -1
  82. package/dist/{chunk-5S7WN3ZQ.js → chunk-IFAH652L.js} +4 -7
  83. package/dist/chunk-IFAH652L.js.map +1 -0
  84. package/dist/chunk-IUGJG4RA.js +30 -0
  85. package/dist/chunk-IUGJG4RA.js.map +1 -0
  86. package/dist/{chunk-ZR66E3T6.js → chunk-JNLVXPHR.js} +13 -13
  87. package/dist/chunk-KEZEGPEX.js +30 -0
  88. package/dist/chunk-KEZEGPEX.js.map +1 -0
  89. package/dist/{chunk-66U2RSYJ.js → chunk-KP4GNXYS.js} +4 -10
  90. package/dist/chunk-KP4GNXYS.js.map +1 -0
  91. package/dist/chunk-KXQMCN4O.js +30 -0
  92. package/dist/chunk-KXQMCN4O.js.map +1 -0
  93. package/dist/{chunk-YXS27XM6.js → chunk-KYBOZ7C4.js} +3 -7
  94. package/dist/chunk-KYBOZ7C4.js.map +1 -0
  95. package/dist/chunk-LBWM6TTU.js +30 -0
  96. package/dist/chunk-LBWM6TTU.js.map +1 -0
  97. package/dist/{chunk-3DVDS7CT.js → chunk-LCDONZBX.js} +5 -5
  98. package/dist/chunk-LCDONZBX.js.map +1 -0
  99. package/dist/{chunk-OJ3YWO3W.js → chunk-NE76IBV2.js} +3 -7
  100. package/dist/chunk-NE76IBV2.js.map +1 -0
  101. package/dist/{chunk-HMU342XE.js → chunk-PVO6TZCZ.js} +3 -9
  102. package/dist/{chunk-HMU342XE.js.map → chunk-PVO6TZCZ.js.map} +1 -1
  103. package/dist/{chunk-URZGNPTQ.js → chunk-RILYRQ72.js} +4 -10
  104. package/dist/chunk-RILYRQ72.js.map +1 -0
  105. package/dist/{chunk-FBQ3X3UY.js → chunk-U4QMFVAM.js} +5 -13
  106. package/dist/chunk-U4QMFVAM.js.map +1 -0
  107. package/dist/chunk-VWDTOSE3.js +26 -0
  108. package/dist/chunk-VWDTOSE3.js.map +1 -0
  109. package/dist/chunk-YRQBU2OW.js +30 -0
  110. package/dist/chunk-YRQBU2OW.js.map +1 -0
  111. package/dist/clickoutside.browser.global.js +5 -7
  112. package/dist/clickoutside.browser.global.js.map +1 -1
  113. package/dist/clipboard.browser.global.js +4 -8
  114. package/dist/clipboard.browser.global.js.map +1 -1
  115. package/dist/core.browser.global.js +13 -25
  116. package/dist/core.browser.global.js.map +1 -1
  117. package/dist/draggable.browser.global.js +5 -13
  118. package/dist/draggable.browser.global.js.map +1 -1
  119. package/dist/focustrap.browser.global.js +4 -8
  120. package/dist/focustrap.browser.global.js.map +1 -1
  121. package/dist/index.cjs +96 -271
  122. package/dist/index.cjs.map +1 -1
  123. package/dist/index.d.cts +10 -10
  124. package/dist/index.d.ts +10 -10
  125. package/dist/index.js +42 -55
  126. package/dist/index.js.map +1 -1
  127. package/dist/loaders.cjs +75 -237
  128. package/dist/loaders.cjs.map +1 -1
  129. package/dist/loaders.js +13 -13
  130. package/dist/registry.cjs +4 -4
  131. package/dist/registry.cjs.map +1 -1
  132. package/dist/registry.d.cts +5 -6
  133. package/dist/registry.d.ts +5 -6
  134. package/dist/registry.js +1 -1
  135. package/dist/removable.browser.global.js +3 -9
  136. package/dist/removable.browser.global.js.map +1 -1
  137. package/dist/resizable.browser.global.js +4 -7
  138. package/dist/resizable.browser.global.js.map +1 -1
  139. package/dist/resolver.browser.global.js +45 -100
  140. package/dist/resolver.browser.global.js.map +1 -1
  141. package/dist/schemas/index.cjs +38 -93
  142. package/dist/schemas/index.cjs.map +1 -1
  143. package/dist/schemas/index.d.cts +2 -2
  144. package/dist/schemas/index.d.ts +2 -2
  145. package/dist/schemas/index.js +11 -11
  146. package/dist/schemas/index.js.map +1 -1
  147. package/dist/scrollreveal.browser.global.js +5 -11
  148. package/dist/scrollreveal.browser.global.js.map +1 -1
  149. package/dist/sortable.browser.global.js +5 -9
  150. package/dist/sortable.browser.global.js.map +1 -1
  151. package/dist/tabs.browser.global.js +6 -14
  152. package/dist/tabs.browser.global.js.map +1 -1
  153. package/dist/toggleable.browser.global.js +9 -13
  154. package/dist/toggleable.browser.global.js.map +1 -1
  155. package/dist/{types-DCCtVQS5.d.cts → types-CbA4L8XJ.d.cts} +16 -23
  156. package/dist/{types-DCCtVQS5.d.ts → types-CbA4L8XJ.d.ts} +16 -23
  157. package/package.json +5 -5
  158. package/src/behavior-resolver.ts +24 -56
  159. package/src/behaviors/autodismiss.test.ts +12 -20
  160. package/src/behaviors/autodismiss.ts +8 -23
  161. package/src/behaviors/clickoutside.test.ts +13 -21
  162. package/src/behaviors/clickoutside.ts +8 -23
  163. package/src/behaviors/clipboard.test.ts +12 -34
  164. package/src/behaviors/clipboard.ts +8 -23
  165. package/src/behaviors/curated-runtime.test.ts +22 -24
  166. package/src/behaviors/draggable.ts +10 -24
  167. package/src/behaviors/experimental-runtime.test.ts +19 -18
  168. package/src/behaviors/focustrap.test.ts +12 -20
  169. package/src/behaviors/focustrap.ts +8 -23
  170. package/src/behaviors/integration.test.ts +19 -54
  171. package/src/behaviors/optional-runtime.test.ts +17 -22
  172. package/src/behaviors/removable.ts +6 -20
  173. package/src/behaviors/resizable.ts +9 -24
  174. package/src/behaviors/scrollreveal.test.ts +13 -21
  175. package/src/behaviors/scrollreveal.ts +8 -23
  176. package/src/behaviors/sortable.ts +7 -22
  177. package/src/behaviors/tabs.test.ts +12 -34
  178. package/src/behaviors/tabs.ts +8 -23
  179. package/src/behaviors/toggleable.ts +10 -26
  180. package/src/browser-resolver-bundle.ts +20 -30
  181. package/src/core-bundle.ts +11 -11
  182. package/src/index.test.ts +2 -2
  183. package/src/index.ts +30 -47
  184. package/src/registry.test.ts +9 -34
  185. package/src/registry.ts +7 -11
  186. package/src/schemas/autodismiss.schema.ts +3 -9
  187. package/src/schemas/clickoutside.schema.ts +3 -5
  188. package/src/schemas/clipboard.schema.ts +2 -6
  189. package/src/schemas/draggable.schema.ts +4 -12
  190. package/src/schemas/focustrap.schema.ts +2 -6
  191. package/src/schemas/index.ts +2 -1
  192. package/src/schemas/removable.schema.ts +2 -8
  193. package/src/schemas/resizable.schema.ts +3 -6
  194. package/src/schemas/scrollreveal.schema.ts +3 -9
  195. package/src/schemas/sortable.schema.ts +3 -7
  196. package/src/schemas/tabs.schema.ts +4 -12
  197. package/src/schemas/toggleable.schema.ts +10 -13
  198. package/src/schemas/types.ts +37 -30
  199. package/dist/chunk-2HUF6RMI.js +0 -40
  200. package/dist/chunk-2HUF6RMI.js.map +0 -1
  201. package/dist/chunk-3DVDS7CT.js.map +0 -1
  202. package/dist/chunk-5S7WN3ZQ.js.map +0 -1
  203. package/dist/chunk-66U2RSYJ.js.map +0 -1
  204. package/dist/chunk-6TJXDCAQ.js +0 -11
  205. package/dist/chunk-6TJXDCAQ.js.map +0 -1
  206. package/dist/chunk-7TPDLB7W.js +0 -40
  207. package/dist/chunk-7TPDLB7W.js.map +0 -1
  208. package/dist/chunk-CR3J7VV6.js +0 -40
  209. package/dist/chunk-CR3J7VV6.js.map +0 -1
  210. package/dist/chunk-EDBG2F57.js +0 -40
  211. package/dist/chunk-EDBG2F57.js.map +0 -1
  212. package/dist/chunk-FBQ3X3UY.js.map +0 -1
  213. package/dist/chunk-HQDYH45I.js.map +0 -1
  214. package/dist/chunk-HX663BJ4.js +0 -40
  215. package/dist/chunk-HX663BJ4.js.map +0 -1
  216. package/dist/chunk-KROW43CG.js +0 -40
  217. package/dist/chunk-KROW43CG.js.map +0 -1
  218. package/dist/chunk-L52AGCMP.js +0 -40
  219. package/dist/chunk-L52AGCMP.js.map +0 -1
  220. package/dist/chunk-MTI5PSRH.js +0 -40
  221. package/dist/chunk-MTI5PSRH.js.map +0 -1
  222. package/dist/chunk-OJ3YWO3W.js.map +0 -1
  223. package/dist/chunk-ORBJ7MRW.js +0 -40
  224. package/dist/chunk-ORBJ7MRW.js.map +0 -1
  225. package/dist/chunk-SLSCZV4A.js +0 -40
  226. package/dist/chunk-SLSCZV4A.js.map +0 -1
  227. package/dist/chunk-URZGNPTQ.js.map +0 -1
  228. package/dist/chunk-WKBRZGGL.js +0 -40
  229. package/dist/chunk-WKBRZGGL.js.map +0 -1
  230. package/dist/chunk-XYZ7FOXJ.js.map +0 -1
  231. package/dist/chunk-YXS27XM6.js.map +0 -1
  232. /package/dist/{chunk-ZR66E3T6.js.map → chunk-JNLVXPHR.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -48,18 +48,11 @@ var init_draggable_schema = __esm({
48
48
  requirements: ["position: absolute or position: fixed on the element"],
49
49
  source: `
50
50
  behavior Draggable(dragHandle)
51
- init
52
- if no dragHandle set dragHandle to me
53
- end
54
- on pointerdown(clientX, clientY) from dragHandle
51
+ on pointerdown(clientX, clientY) from (dragHandle or me)
55
52
  halt the event
56
53
  trigger draggable:start
57
- measure x
58
- set startX to it
59
- measure y
60
- set startY to it
61
- set xoff to clientX - startX
62
- set yoff to clientY - startY
54
+ set xoff to clientX - my offsetLeft
55
+ set yoff to clientY - my offsetTop
63
56
  repeat until event pointerup from document
64
57
  wait for pointermove(clientX, clientY) or
65
58
  pointerup(clientX, clientY) from document
@@ -68,8 +61,7 @@ behavior Draggable(dragHandle)
68
61
  end
69
62
  trigger draggable:end
70
63
  end
71
- end
72
- `.trim()
64
+ end`.trim()
73
65
  };
74
66
  }
75
67
  });
@@ -78,7 +70,21 @@ end
78
70
  function resolveRuntime() {
79
71
  if (typeof window === "undefined") return null;
80
72
  const win = window;
81
- return win.lokascript || win.hyperfixi || null;
73
+ const host = win.hyperfixi ?? win._hyperscript;
74
+ return host && typeof host.evaluate === "function" ? host : null;
75
+ }
76
+ function defineBehavior(schema, host) {
77
+ const hf = host ?? resolveRuntime();
78
+ if (!hf) {
79
+ throw new Error(
80
+ `No hyperscript host found: load @hyperfixi/engine (hyperfixi-hs.js) before defining ${schema.name}.`
81
+ );
82
+ }
83
+ try {
84
+ hf.evaluate(schema.source);
85
+ } catch (e) {
86
+ throw new Error(`Failed to define ${schema.name} behavior: ${e.message}`);
87
+ }
82
88
  }
83
89
  var init_types = __esm({
84
90
  "src/schemas/types.ts"() {
@@ -94,19 +100,8 @@ __export(draggable_exports, {
94
100
  draggableSource: () => draggableSource,
95
101
  registerDraggable: () => registerDraggable
96
102
  });
97
- async function registerDraggable(hyperfixi) {
98
- const hf = hyperfixi || resolveRuntime();
99
- if (!hf) {
100
- throw new Error(
101
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
102
- );
103
- }
104
- const result = hf.compileSync(draggableSchema.source, { traditional: true });
105
- if (!result.ok) {
106
- throw new Error(`Failed to compile Draggable behavior: ${JSON.stringify(result.errors)}`);
107
- }
108
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
109
- await hf.execute(result.ast, ctx);
103
+ async function registerDraggable(host) {
104
+ defineBehavior(draggableSchema, host);
110
105
  }
111
106
  var draggableSource, draggableMetadata, draggable_default;
112
107
  var init_draggable = __esm({
@@ -168,12 +163,7 @@ var init_removable_schema = __esm({
168
163
  ],
169
164
  source: `
170
165
  behavior Removable(triggerEl, confirmRemoval, effect)
171
- init
172
- if triggerEl is undefined
173
- set triggerEl to me
174
- end
175
- end
176
- on click from triggerEl
166
+ on click from (triggerEl or me)
177
167
  if confirmRemoval
178
168
  js(me)
179
169
  if (!window.confirm("Are you sure?")) return "cancel";
@@ -189,8 +179,7 @@ behavior Removable(triggerEl, confirmRemoval, effect)
189
179
  trigger removable:removed
190
180
  remove me
191
181
  end
192
- end
193
- `.trim()
182
+ end`.trim()
194
183
  };
195
184
  }
196
185
  });
@@ -203,19 +192,8 @@ __export(removable_exports, {
203
192
  removableMetadata: () => removableMetadata,
204
193
  removableSource: () => removableSource
205
194
  });
206
- async function registerRemovable(hyperfixi) {
207
- const hf = hyperfixi || resolveRuntime();
208
- if (!hf) {
209
- throw new Error(
210
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
211
- );
212
- }
213
- const result = hf.compileSync(removableSchema.source, { traditional: true });
214
- if (!result.ok) {
215
- throw new Error(`Failed to compile Removable behavior: ${JSON.stringify(result.errors)}`);
216
- }
217
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
218
- await hf.execute(result.ast, ctx);
195
+ async function registerRemovable(host) {
196
+ defineBehavior(removableSchema, host);
219
197
  }
220
198
  var removableSource, removableMetadata, removable_default;
221
199
  var init_removable = __esm({
@@ -256,11 +234,11 @@ var init_toggleable_schema = __esm({
256
234
  description: "CSS class to toggle"
257
235
  },
258
236
  {
259
- name: "target",
237
+ name: "targetEl",
260
238
  type: "selector",
261
239
  optional: true,
262
240
  default: "me",
263
- description: "Element to toggle the class on"
241
+ description: "Element to toggle the class on (not `target`: that is hyperscript's name for the event target)"
264
242
  }
265
243
  ],
266
244
  events: [
@@ -268,20 +246,16 @@ var init_toggleable_schema = __esm({
268
246
  { name: "toggleable:off", description: "Fired when class is removed" }
269
247
  ],
270
248
  source: `
271
- behavior Toggleable(cls, target)
249
+ behavior Toggleable(cls, targetEl)
272
250
  init
273
- if cls is undefined
274
- set cls to "active"
275
- end
276
- if target is undefined
277
- set target to me
278
- end
251
+ if cls is undefined set element's cls to "active" end
252
+ if targetEl is undefined set element's targetEl to me end
279
253
  end
280
254
  on click
281
- toggle .{cls} on target
282
- js(target, cls)
283
- var eventName = target.classList.contains(cls) ? 'toggleable:on' : 'toggleable:off';
284
- target.dispatchEvent(new CustomEvent(eventName, { bubbles: true }));
255
+ toggle .{cls} on targetEl
256
+ js(targetEl, cls)
257
+ var eventName = targetEl.classList.contains(cls) ? 'toggleable:on' : 'toggleable:off';
258
+ targetEl.dispatchEvent(new CustomEvent(eventName, { bubbles: true }));
285
259
  end
286
260
  end
287
261
  end`.trim()
@@ -297,19 +271,8 @@ __export(toggleable_exports, {
297
271
  toggleableMetadata: () => toggleableMetadata,
298
272
  toggleableSource: () => toggleableSource
299
273
  });
300
- async function registerToggleable(hyperfixi) {
301
- const hf = hyperfixi || resolveRuntime();
302
- if (!hf) {
303
- throw new Error(
304
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
305
- );
306
- }
307
- const result = hf.compileSync(toggleableSchema.source, { traditional: true });
308
- if (!result.ok) {
309
- throw new Error(`Failed to compile Toggleable behavior: ${JSON.stringify(result.errors)}`);
310
- }
311
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
312
- await hf.execute(result.ast, ctx);
274
+ async function registerToggleable(host) {
275
+ defineBehavior(toggleableSchema, host);
313
276
  }
314
277
  var toggleableSource, toggleableMetadata, toggleable_default;
315
278
  var init_toggleable = __esm({
@@ -361,24 +324,20 @@ var init_sortable_schema = __esm({
361
324
  requirements: ["Users must handle DOM reordering in sortable:move event handlers"],
362
325
  source: `
363
326
  behavior Sortable(dragClass)
364
- init
365
- if dragClass is undefined
366
- set dragClass to "sorting"
367
- end
368
- end
369
327
  on pointerdown(clientY) from me
370
328
  set item to the target.closest("li")
371
329
  if item is null
372
330
  exit
373
331
  end
374
332
  halt the event
375
- add .{dragClass} to item
333
+ set cls to dragClass or "sorting"
334
+ add .{cls} to item
376
335
  trigger sortable:start on me
377
336
  repeat until event pointerup from document
378
337
  wait for pointermove(clientY) or pointerup(clientY) from document
379
338
  trigger sortable:move on me
380
339
  end
381
- remove .{dragClass} from item
340
+ remove .{cls} from item
382
341
  trigger sortable:end on me
383
342
  end
384
343
  end`.trim()
@@ -394,19 +353,8 @@ __export(sortable_exports, {
394
353
  sortableMetadata: () => sortableMetadata,
395
354
  sortableSource: () => sortableSource
396
355
  });
397
- async function registerSortable(hyperfixi) {
398
- const hf = hyperfixi || resolveRuntime();
399
- if (!hf) {
400
- throw new Error(
401
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
402
- );
403
- }
404
- const result = hf.compileSync(sortableSchema.source, { traditional: true });
405
- if (!result.ok) {
406
- throw new Error(`Failed to compile Sortable behavior: ${JSON.stringify(result.errors)}`);
407
- }
408
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
409
- await hf.execute(result.ast, ctx);
356
+ async function registerSortable(host) {
357
+ defineBehavior(sortableSchema, host);
410
358
  }
411
359
  var sortableSource, sortableMetadata, sortable_default;
412
360
  var init_sortable = __esm({
@@ -478,10 +426,8 @@ behavior Resizable(minWidth, minHeight, maxWidth, maxHeight)
478
426
  on pointerdown(clientX, clientY) from me
479
427
  halt the event
480
428
  trigger resizable:start
481
- measure width
482
- set startWidth to it
483
- measure height
484
- set startHeight to it
429
+ set startWidth to my offsetWidth
430
+ set startHeight to my offsetHeight
485
431
  set startX to clientX
486
432
  set startY to clientY
487
433
  repeat until event pointerup from document
@@ -498,8 +444,7 @@ behavior Resizable(minWidth, minHeight, maxWidth, maxHeight)
498
444
  end
499
445
  trigger resizable:end
500
446
  end
501
- end
502
- `.trim()
447
+ end`.trim()
503
448
  };
504
449
  }
505
450
  });
@@ -512,19 +457,8 @@ __export(resizable_exports, {
512
457
  resizableMetadata: () => resizableMetadata,
513
458
  resizableSource: () => resizableSource
514
459
  });
515
- async function registerResizable(hyperfixi) {
516
- const hf = hyperfixi || resolveRuntime();
517
- if (!hf) {
518
- throw new Error(
519
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
520
- );
521
- }
522
- const result = hf.compileSync(resizableSchema.source, { traditional: true });
523
- if (!result.ok) {
524
- throw new Error(`Failed to compile Resizable behavior: ${JSON.stringify(result.errors)}`);
525
- }
526
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
527
- await hf.execute(result.ast, ctx);
460
+ async function registerResizable(host) {
461
+ defineBehavior(resizableSchema, host);
528
462
  }
529
463
  var resizableSource, resizableMetadata, resizable_default;
530
464
  var init_resizable = __esm({
@@ -595,12 +529,8 @@ var init_clipboard_schema = __esm({
595
529
  source: `
596
530
  behavior Clipboard(text, source, feedback, feedbackDuration)
597
531
  init
598
- if feedbackDuration is undefined
599
- set feedbackDuration to 2000
600
- end
601
- if source is undefined
602
- set source to me
603
- end
532
+ if feedbackDuration is undefined set element's feedbackDuration to 2000 end
533
+ if source is undefined set element's source to me end
604
534
  end
605
535
  on click
606
536
  if text is not undefined
@@ -650,19 +580,8 @@ __export(clipboard_exports, {
650
580
  default: () => clipboard_default,
651
581
  registerClipboard: () => registerClipboard
652
582
  });
653
- async function registerClipboard(hyperfixi) {
654
- const hf = hyperfixi || resolveRuntime();
655
- if (!hf) {
656
- throw new Error(
657
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
658
- );
659
- }
660
- const result = hf.compileSync(clipboardSchema.source, { traditional: true });
661
- if (!result.ok) {
662
- throw new Error(`Failed to compile Clipboard behavior: ${JSON.stringify(result.errors)}`);
663
- }
664
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
665
- await hf.execute(result.ast, ctx);
583
+ async function registerClipboard(host) {
584
+ defineBehavior(clipboardSchema, host);
666
585
  }
667
586
  var clipboardSource, clipboardMetadata, clipboard_default;
668
587
  var init_clipboard = __esm({
@@ -730,15 +649,9 @@ var init_autodismiss_schema = __esm({
730
649
  source: `
731
650
  behavior AutoDismiss(delay, pauseOnHover, effect)
732
651
  init
733
- if delay is undefined
734
- set delay to 5000
735
- end
736
- if pauseOnHover is undefined
737
- set pauseOnHover to true
738
- end
739
- if effect is undefined
740
- set effect to "none"
741
- end
652
+ if delay is undefined set element's delay to 5000 end
653
+ if pauseOnHover is undefined set element's pauseOnHover to true end
654
+ if effect is undefined set element's effect to "none" end
742
655
  js(me, delay, effect, pauseOnHover)
743
656
  me.dispatchEvent(new CustomEvent('autodismiss:start', { bubbles: true }));
744
657
  var remaining = delay;
@@ -793,19 +706,8 @@ __export(autodismiss_exports, {
793
706
  default: () => autodismiss_default,
794
707
  registerAutoDismiss: () => registerAutoDismiss
795
708
  });
796
- async function registerAutoDismiss(hyperfixi) {
797
- const hf = hyperfixi || resolveRuntime();
798
- if (!hf) {
799
- throw new Error(
800
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
801
- );
802
- }
803
- const result = hf.compileSync(autoDismissSchema.source, { traditional: true });
804
- if (!result.ok) {
805
- throw new Error(`Failed to compile AutoDismiss behavior: ${JSON.stringify(result.errors)}`);
806
- }
807
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
808
- await hf.execute(result.ast, ctx);
709
+ async function registerAutoDismiss(host) {
710
+ defineBehavior(autoDismissSchema, host);
809
711
  }
810
712
  var autoDismissSource, autoDismissMetadata, autodismiss_default;
811
713
  var init_autodismiss = __esm({
@@ -861,9 +763,7 @@ var init_clickoutside_schema = __esm({
861
763
  source: `
862
764
  behavior ClickOutside(active)
863
765
  init
864
- if active is undefined
865
- set active to true
866
- end
766
+ if active is undefined set element's active to true end
867
767
  end
868
768
  on pointerdown from document
869
769
  js(me, active, event)
@@ -874,10 +774,10 @@ behavior ClickOutside(active)
874
774
  end
875
775
  end
876
776
  on clickoutside:activate
877
- set active to true
777
+ set element's active to true
878
778
  end
879
779
  on clickoutside:deactivate
880
- set active to false
780
+ set element's active to false
881
781
  end
882
782
  end`.trim()
883
783
  };
@@ -892,19 +792,8 @@ __export(clickoutside_exports, {
892
792
  default: () => clickoutside_default,
893
793
  registerClickOutside: () => registerClickOutside
894
794
  });
895
- async function registerClickOutside(hyperfixi) {
896
- const hf = hyperfixi || resolveRuntime();
897
- if (!hf) {
898
- throw new Error(
899
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
900
- );
901
- }
902
- const result = hf.compileSync(clickOutsideSchema.source, { traditional: true });
903
- if (!result.ok) {
904
- throw new Error(`Failed to compile ClickOutside behavior: ${JSON.stringify(result.errors)}`);
905
- }
906
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
907
- await hf.execute(result.ast, ctx);
795
+ async function registerClickOutside(host) {
796
+ defineBehavior(clickOutsideSchema, host);
908
797
  }
909
798
  var clickOutsideSource, clickOutsideMetadata, clickoutside_default;
910
799
  var init_clickoutside = __esm({
@@ -969,12 +858,8 @@ var init_focustrap_schema = __esm({
969
858
  source: `
970
859
  behavior FocusTrap(active, initialFocus, returnFocus)
971
860
  init
972
- if active is undefined
973
- set active to true
974
- end
975
- if returnFocus is undefined
976
- set returnFocus to true
977
- end
861
+ if active is undefined set element's active to true end
862
+ if returnFocus is undefined set element's returnFocus to true end
978
863
  js(me, active, initialFocus, returnFocus)
979
864
  var FOCUSABLE = 'a[href],button:not(:disabled),input:not(:disabled),select:not(:disabled),textarea:not(:disabled),[tabindex]:not([tabindex="-1"])';
980
865
  var isActive = false;
@@ -1027,19 +912,8 @@ __export(focustrap_exports, {
1027
912
  focusTrapSource: () => focusTrapSource,
1028
913
  registerFocusTrap: () => registerFocusTrap
1029
914
  });
1030
- async function registerFocusTrap(hyperfixi) {
1031
- const hf = hyperfixi || resolveRuntime();
1032
- if (!hf) {
1033
- throw new Error(
1034
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
1035
- );
1036
- }
1037
- const result = hf.compileSync(focusTrapSchema.source, { traditional: true });
1038
- if (!result.ok) {
1039
- throw new Error(`Failed to compile FocusTrap behavior: ${JSON.stringify(result.errors)}`);
1040
- }
1041
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
1042
- await hf.execute(result.ast, ctx);
915
+ async function registerFocusTrap(host) {
916
+ defineBehavior(focusTrapSchema, host);
1043
917
  }
1044
918
  var focusTrapSource, focusTrapMetadata, focustrap_default;
1045
919
  var init_focustrap = __esm({
@@ -1102,15 +976,9 @@ var init_scrollreveal_schema = __esm({
1102
976
  source: `
1103
977
  behavior ScrollReveal(cls, threshold, once)
1104
978
  init
1105
- if cls is undefined
1106
- set cls to "revealed"
1107
- end
1108
- if threshold is undefined
1109
- set threshold to 0.1
1110
- end
1111
- if once is undefined
1112
- set once to true
1113
- end
979
+ if cls is undefined set element's cls to "revealed" end
980
+ if threshold is undefined set element's threshold to 0.1 end
981
+ if once is undefined set element's once to true end
1114
982
  js(me, cls, threshold, once)
1115
983
  var obs = new IntersectionObserver(function(entries) {
1116
984
  for (var i = 0; i < entries.length; i++) {
@@ -1140,19 +1008,8 @@ __export(scrollreveal_exports, {
1140
1008
  scrollRevealMetadata: () => scrollRevealMetadata,
1141
1009
  scrollRevealSource: () => scrollRevealSource
1142
1010
  });
1143
- async function registerScrollReveal(hyperfixi) {
1144
- const hf = hyperfixi || resolveRuntime();
1145
- if (!hf) {
1146
- throw new Error(
1147
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
1148
- );
1149
- }
1150
- const result = hf.compileSync(scrollRevealSchema.source, { traditional: true });
1151
- if (!result.ok) {
1152
- throw new Error(`Failed to compile ScrollReveal behavior: ${JSON.stringify(result.errors)}`);
1153
- }
1154
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
1155
- await hf.execute(result.ast, ctx);
1011
+ async function registerScrollReveal(host) {
1012
+ defineBehavior(scrollRevealSchema, host);
1156
1013
  }
1157
1014
  var scrollRevealSource, scrollRevealMetadata, scrollreveal_default;
1158
1015
  var init_scrollreveal = __esm({
@@ -1231,18 +1088,10 @@ var init_tabs_schema = __esm({
1231
1088
  source: `
1232
1089
  behavior Tabs(orientation, activeTab, wrap, activeClass)
1233
1090
  init
1234
- if orientation is undefined
1235
- set orientation to "horizontal"
1236
- end
1237
- if activeTab is undefined
1238
- set activeTab to 0
1239
- end
1240
- if wrap is undefined
1241
- set wrap to true
1242
- end
1243
- if activeClass is undefined
1244
- set activeClass to "active"
1245
- end
1091
+ if orientation is undefined set element's orientation to "horizontal" end
1092
+ if activeTab is undefined set element's activeTab to 0 end
1093
+ if wrap is undefined set element's wrap to true end
1094
+ if activeClass is undefined set element's activeClass to "active" end
1246
1095
  js(me, orientation, activeTab, wrap, activeClass)
1247
1096
  var tabs = Array.from(me.querySelectorAll('[role="tab"]'));
1248
1097
  var panels = Array.from(me.querySelectorAll('[role="tabpanel"]'));
@@ -1320,19 +1169,8 @@ __export(tabs_exports, {
1320
1169
  tabsMetadata: () => tabsMetadata,
1321
1170
  tabsSource: () => tabsSource
1322
1171
  });
1323
- async function registerTabs(hyperfixi) {
1324
- const hf = hyperfixi || resolveRuntime();
1325
- if (!hf) {
1326
- throw new Error(
1327
- "LokaScript not found. Make sure @hyperfixi/core is loaded before registering behaviors."
1328
- );
1329
- }
1330
- const result = hf.compileSync(tabsSchema.source, { traditional: true });
1331
- if (!result.ok) {
1332
- throw new Error(`Failed to compile Tabs behavior: ${JSON.stringify(result.errors)}`);
1333
- }
1334
- const ctx = hf.createContext ? hf.createContext() : { locals: /* @__PURE__ */ new Map(), globals: /* @__PURE__ */ new Map() };
1335
- await hf.execute(result.ast, ctx);
1172
+ async function registerTabs(host) {
1173
+ defineBehavior(tabsSchema, host);
1336
1174
  }
1337
1175
  var tabsSource, tabsMetadata, tabs_default;
1338
1176
  var init_tabs = __esm({
@@ -1585,12 +1423,12 @@ async function loadAll() {
1585
1423
  )
1586
1424
  );
1587
1425
  }
1588
- async function registerWithRuntime(name, hyperfixi) {
1426
+ async function registerWithRuntime(name, host) {
1589
1427
  const module2 = await loadBehavior(name);
1590
- await module2.register(hyperfixi);
1428
+ await module2.register(host);
1591
1429
  }
1592
- async function registerAllWithRuntime(hyperfixi) {
1593
- const registrations = Array.from(behaviors.values()).map((module2) => module2.register(hyperfixi));
1430
+ async function registerAllWithRuntime(host) {
1431
+ const registrations = Array.from(behaviors.values()).map((module2) => module2.register(host));
1594
1432
  await Promise.all(registrations);
1595
1433
  }
1596
1434
 
@@ -1746,41 +1584,28 @@ init_focustrap();
1746
1584
  init_scrollreveal();
1747
1585
  init_tabs();
1748
1586
  init_types();
1749
- async function registerAll(hyperfixi) {
1587
+ async function registerAll(host) {
1750
1588
  await Promise.all([
1751
- registerDraggable(hyperfixi),
1752
- registerRemovable(hyperfixi),
1753
- registerToggleable(hyperfixi),
1754
- registerSortable(hyperfixi),
1755
- registerResizable(hyperfixi),
1756
- registerClipboard(hyperfixi),
1757
- registerAutoDismiss(hyperfixi),
1758
- registerClickOutside(hyperfixi),
1759
- registerFocusTrap(hyperfixi),
1760
- registerScrollReveal(hyperfixi),
1761
- registerTabs(hyperfixi)
1589
+ registerDraggable(host),
1590
+ registerRemovable(host),
1591
+ registerToggleable(host),
1592
+ registerSortable(host),
1593
+ registerResizable(host),
1594
+ registerClipboard(host),
1595
+ registerAutoDismiss(host),
1596
+ registerClickOutside(host),
1597
+ registerFocusTrap(host),
1598
+ registerScrollReveal(host),
1599
+ registerTabs(host)
1762
1600
  ]);
1763
1601
  }
1764
1602
  var ready = null;
1765
- var _runtime = resolveRuntime();
1766
- if (_runtime) {
1767
- const lsWin = window;
1768
- ready = registerAll(_runtime);
1769
- lsWin.__hyperfixi_behaviors_ready = ready;
1770
- ready.then(() => {
1771
- const hf = _runtime;
1772
- const savedPromise = lsWin.__hyperfixi_behaviors_ready;
1773
- delete lsWin.__hyperfixi_behaviors_ready;
1774
- if (hf.attributeProcessor?.scanAndProcessAll) {
1775
- hf.attributeProcessor.scanAndProcessAll().finally(() => {
1776
- lsWin.__hyperfixi_behaviors_ready = savedPromise;
1777
- });
1778
- } else if (hf.processNode) {
1779
- hf.processNode(document);
1780
- lsWin.__hyperfixi_behaviors_ready = savedPromise;
1781
- }
1603
+ var _host = resolveRuntime();
1604
+ if (_host) {
1605
+ ready = registerAll(_host).then(() => {
1606
+ if (document.readyState !== "loading") _host.processNode?.(document.body);
1782
1607
  }).catch((err) => {
1783
- console.error("[behaviors] Auto-registration failed:", err);
1608
+ console.error("[behaviors] Auto-definition failed:", err);
1784
1609
  });
1785
1610
  }
1786
1611
  // Annotate the CommonJS export names for ESM import in node: