@getforma/core 1.0.7 → 1.0.9

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 (48) hide show
  1. package/README.md +4 -4
  2. package/dist/{chunk-OUVOAYIO.js → chunk-3G7ET4O5.js} +33 -9
  3. package/dist/chunk-3G7ET4O5.js.map +1 -0
  4. package/dist/{chunk-DCTOXHPF.cjs → chunk-6FW5E54W.cjs} +38 -12
  5. package/dist/chunk-6FW5E54W.cjs.map +1 -0
  6. package/dist/{chunk-FJGTMWKY.js → chunk-AFRFF7XL.js} +67 -23
  7. package/dist/chunk-AFRFF7XL.js.map +1 -0
  8. package/dist/{chunk-OZCHIVAZ.js → chunk-HLM5BZZQ.js} +2 -2
  9. package/dist/chunk-HLM5BZZQ.js.map +1 -0
  10. package/dist/{chunk-3U57L2TY.cjs → chunk-QLPCVK7C.cjs} +2 -2
  11. package/dist/chunk-QLPCVK7C.cjs.map +1 -0
  12. package/dist/{chunk-SZSKW57A.cjs → chunk-T33QUD2Y.cjs} +102 -58
  13. package/dist/chunk-T33QUD2Y.cjs.map +1 -0
  14. package/dist/formajs-runtime-hardened.global.js.map +1 -1
  15. package/dist/formajs-runtime.global.js.map +1 -1
  16. package/dist/formajs.global.js +102 -26
  17. package/dist/formajs.global.js.map +1 -1
  18. package/dist/http.cjs +11 -11
  19. package/dist/http.js +2 -2
  20. package/dist/index.cjs +72 -61
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +166 -11
  23. package/dist/index.d.ts +166 -11
  24. package/dist/index.js +16 -9
  25. package/dist/index.js.map +1 -1
  26. package/dist/{resource-Cd0cGOxS.d.ts → resource-BHsgURy0.d.ts} +3 -1
  27. package/dist/{resource-DK98lW5e.d.cts → resource-DeEzxUz6.d.cts} +3 -1
  28. package/dist/runtime-hardened.cjs.map +1 -1
  29. package/dist/runtime-hardened.js.map +1 -1
  30. package/dist/runtime.cjs +29 -29
  31. package/dist/runtime.js +3 -3
  32. package/dist/server.cjs +7 -7
  33. package/dist/server.d.cts +2 -2
  34. package/dist/server.d.ts +2 -2
  35. package/dist/server.js +2 -2
  36. package/dist/{signal-YlS1kgfh.d.cts → signal-C9v4akyJ.d.cts} +2 -0
  37. package/dist/{signal-YlS1kgfh.d.ts → signal-C9v4akyJ.d.ts} +2 -0
  38. package/dist/tc39-compat.cjs +3 -3
  39. package/dist/tc39-compat.d.cts +1 -1
  40. package/dist/tc39-compat.d.ts +1 -1
  41. package/dist/tc39-compat.js +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunk-3U57L2TY.cjs.map +0 -1
  44. package/dist/chunk-DCTOXHPF.cjs.map +0 -1
  45. package/dist/chunk-FJGTMWKY.js.map +0 -1
  46. package/dist/chunk-OUVOAYIO.js.map +0 -1
  47. package/dist/chunk-OZCHIVAZ.js.map +0 -1
  48. package/dist/chunk-SZSKW57A.cjs.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./jsx.d.ts" />
2
- import { S as SignalGetter } from './signal-YlS1kgfh.cjs';
3
- export { a as SignalOptions, b as SignalSetter, c as createSignal } from './signal-YlS1kgfh.cjs';
4
- export { R as Resource, a as ResourceOptions, c as createResource } from './resource-DK98lW5e.cjs';
2
+ import { S as SignalGetter } from './signal-C9v4akyJ.cjs';
3
+ export { a as SignalOptions, b as SignalSetter, c as createSignal } from './signal-C9v4akyJ.cjs';
4
+ export { R as Resource, a as ResourceOptions, c as createResource } from './resource-DeEzxUz6.cjs';
5
5
  export { getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, trigger } from 'alien-signals';
6
6
 
7
7
  declare function createEffect(fn: () => void | (() => void)): () => void;
@@ -134,6 +134,11 @@ declare function untrack<T>(fn: () => T): T;
134
134
  * Uses alien-signals' `effectScope` under the hood for native graph-level
135
135
  * effect tracking, with a userland disposer list for non-effect cleanup
136
136
  * (e.g., event listeners, DOM references, timers).
137
+ *
138
+ * Roots created inside another root are automatically owned by the parent
139
+ * (Solid-style). When the parent is disposed, all child roots are disposed
140
+ * too. Use {@link createUnownedRoot} for roots that must outlive their
141
+ * lexical parent (e.g., mount points, test harnesses).
137
142
  */
138
143
  /**
139
144
  * Create a reactive root scope.
@@ -143,6 +148,9 @@ declare function untrack<T>(fn: () => T): T;
143
148
  * userland level (via registerDisposer). The returned `dispose` function
144
149
  * tears down everything.
145
150
  *
151
+ * Roots created inside another root are automatically owned by the parent.
152
+ * When the parent is disposed, this root is disposed too.
153
+ *
146
154
  * ```ts
147
155
  * const dispose = createRoot(() => {
148
156
  * createEffect(() => console.log(count()));
@@ -152,6 +160,22 @@ declare function untrack<T>(fn: () => T): T;
152
160
  * ```
153
161
  */
154
162
  declare function createRoot<T>(fn: (dispose: () => void) => T): T;
163
+ /**
164
+ * Create a reactive root that is NOT owned by any parent root.
165
+ *
166
+ * Use this for roots that must outlive their lexical parent:
167
+ * top-level mount points, island hydration, test harnesses, etc.
168
+ *
169
+ * ```ts
170
+ * createRoot(() => {
171
+ * // This root outlives the parent even though it's nested:
172
+ * createUnownedRoot((dispose) => {
173
+ * // effects here survive parent disposal
174
+ * });
175
+ * });
176
+ * ```
177
+ */
178
+ declare function createUnownedRoot<T>(fn: (dispose: () => void) => T): T;
155
179
 
156
180
  /**
157
181
  * Register a cleanup function in the current reactive scope.
@@ -223,7 +247,9 @@ declare function on<T, U>(deps: () => T, fn: (value: T, prev: T | undefined) =>
223
247
  * React equivalent: useRef
224
248
  * SolidJS equivalent: (none — uses plain variables in setup)
225
249
  */
250
+ /** A mutable container that does NOT trigger reactivity when written to. */
226
251
  interface Ref<T> {
252
+ /** The stored value. Mutating this does not notify effects. */
227
253
  current: T;
228
254
  }
229
255
  /**
@@ -257,6 +283,7 @@ declare function createRef<T>(initialValue: T): Ref<T>;
257
283
  * SolidJS equivalent: (none — uses createSignal + helpers)
258
284
  */
259
285
 
286
+ /** A function that dispatches an action to a reducer. */
260
287
  type Dispatch<A> = (action: A) => void;
261
288
  /**
262
289
  * Create a reducer — predictable state updates via dispatched actions.
@@ -285,6 +312,7 @@ type Dispatch<A> = (action: A) => void;
285
312
  */
286
313
  declare function createReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [state: SignalGetter<S>, dispatch: Dispatch<A>];
287
314
 
315
+ /** Callback signature for the global {@link onError} handler. */
288
316
  type ErrorHandler = (error: unknown, info?: {
289
317
  source?: string;
290
318
  }) => void;
@@ -428,12 +456,18 @@ declare function mount(component: () => HTMLElement | DocumentFragment, containe
428
456
  *
429
457
  * Total module budget: <2KB minified.
430
458
  */
459
+ /** Return value from {@link reconcileList} — the new nodes and items arrays. */
431
460
  interface ReconcileResult<T> {
461
+ /** The DOM nodes currently in the list, in order. */
432
462
  nodes: Node[];
463
+ /** The items array corresponding to the current nodes. */
433
464
  items: T[];
434
465
  }
466
+ /** Animation hooks for list transitions. */
435
467
  interface ListTransitionHooks {
468
+ /** Called after a new node is inserted into the DOM. */
436
469
  onInsert?: (node: Node) => void;
470
+ /** Called before a node is removed. Call `done()` when the exit animation finishes. */
437
471
  onBeforeRemove?: (node: Node, done: () => void) => void;
438
472
  }
439
473
  interface CreateListOptions {
@@ -530,7 +564,7 @@ declare function createList<T>(items: () => T[], keyFn: (item: T) => string | nu
530
564
  * Returns a DocumentFragment with comment markers. The content between
531
565
  * markers is swapped reactively when `when()` changes.
532
566
  */
533
- declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node): DocumentFragment;
567
+ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node | null): DocumentFragment;
534
568
 
535
569
  /**
536
570
  * Forma DOM - Switch (Multi-branch Conditional)
@@ -546,8 +580,11 @@ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: ()
546
580
  *
547
581
  * SolidJS equivalent: <Switch><Match when={}>
548
582
  */
583
+ /** A single branch for {@link createSwitch}. */
549
584
  interface SwitchCase<T> {
585
+ /** The value that activates this branch. */
550
586
  match: T;
587
+ /** Factory function that renders this branch's DOM. */
551
588
  render: () => Node;
552
589
  }
553
590
  /**
@@ -747,10 +784,15 @@ declare function deactivateAllIslands(root?: Element | Document): void;
747
784
  * Reactivity comes from signals, not re-rendering.
748
785
  * Backed by alien-signals via forma/reactive.
749
786
  */
787
+ /** A teardown function that disposes effects and cleans up resources. */
750
788
  type CleanupFn = () => void;
789
+ /** A function that runs once to build the component's DOM tree. */
751
790
  type SetupFn = () => HTMLElement | DocumentFragment;
791
+ /** Definition object passed to {@link defineComponent}. */
752
792
  interface ComponentDef {
793
+ /** The setup function that builds the component's DOM and reactive bindings. */
753
794
  setup: SetupFn;
795
+ /** Optional debug name for devtools inspection. */
754
796
  name?: string;
755
797
  }
756
798
  /**
@@ -793,6 +835,7 @@ declare function trackDisposer(dispose: () => void): void;
793
835
  * inject() reads the top, component teardown pops automatically.
794
836
  * Zero dependencies -- native browser APIs only.
795
837
  */
838
+ /** A typed dependency injection context created by {@link createContext}. */
796
839
  interface Context<T> {
797
840
  /** Unique identifier for this context. */
798
841
  readonly id: symbol;
@@ -850,6 +893,7 @@ declare function unprovide<T>(ctx: Context<T>): void;
850
893
  *
851
894
  * Backed by alien-signals via forma/reactive.
852
895
  */
896
+ /** Setter for a reactive store — accepts a partial update object or updater function. */
853
897
  type StoreSetter<T extends object> = (partial: Partial<T> | ((prev: T) => Partial<T>)) => void;
854
898
  /**
855
899
  * Create a deep reactive store.
@@ -897,6 +941,7 @@ declare function createStore<T extends object>(initial: T): [get: T, set: StoreS
897
941
  * with reactive canUndo/canRedo signals.
898
942
  * Zero dependencies -- native browser APIs only.
899
943
  */
944
+ /** Undo/redo controls returned by {@link createHistory}. */
900
945
  interface HistoryControls<T> {
901
946
  /** Undo the last change, restoring the previous value. */
902
947
  undo: () => void;
@@ -938,6 +983,7 @@ declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], o
938
983
  * Reads stored value on creation; writes on every signal change.
939
984
  * Zero dependencies -- native browser APIs only.
940
985
  */
986
+ /** Options for {@link persist} — storage backend, serialization, and validation. */
941
987
  interface PersistOptions<T> {
942
988
  /** Storage backend. Defaults to localStorage. */
943
989
  storage?: Storage;
@@ -963,39 +1009,126 @@ interface PersistOptions<T> {
963
1009
  */
964
1010
  declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): void;
965
1011
 
1012
+ /**
1013
+ * A typed publish/subscribe event bus.
1014
+ *
1015
+ * The type parameter `T` maps event names to their payload types,
1016
+ * ensuring type-safe event emission and subscription.
1017
+ */
966
1018
  interface EventBus<T extends Record<string, unknown>> {
1019
+ /** Subscribe to an event. Returns an unsubscribe function. */
967
1020
  on<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
1021
+ /** Subscribe to an event, automatically unsubscribing after the first firing. */
968
1022
  once<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
1023
+ /** Emit an event to all current subscribers. */
969
1024
  emit<K extends keyof T>(event: K, payload: T[K]): void;
1025
+ /** Remove a specific handler from an event. */
970
1026
  off<K extends keyof T>(event: K, handler: (payload: T[K]) => void): void;
1027
+ /** Remove all handlers for all events. */
971
1028
  clear(): void;
972
1029
  }
1030
+ /**
1031
+ * Create a typed event bus for publish/subscribe messaging.
1032
+ *
1033
+ * ```ts
1034
+ * type Events = { save: { id: number }; delete: { id: number } };
1035
+ * const bus = createBus<Events>();
1036
+ *
1037
+ * const unsub = bus.on('save', (payload) => console.log(payload.id));
1038
+ * bus.emit('save', { id: 42 });
1039
+ * unsub();
1040
+ * ```
1041
+ */
973
1042
  declare function createBus<T extends Record<string, unknown> = Record<string, unknown>>(): EventBus<T>;
974
1043
 
1044
+ /**
1045
+ * Attach a single event listener on a parent that fires for children matching
1046
+ * a CSS selector. Efficient for large/dynamic lists — one listener instead of
1047
+ * one per child.
1048
+ *
1049
+ * ```ts
1050
+ * const unsub = delegate(ul, 'li', 'click', (e, li) => {
1051
+ * console.log('Clicked:', li.textContent);
1052
+ * });
1053
+ * ```
1054
+ *
1055
+ * @param container The parent element or document to listen on.
1056
+ * @param selector CSS selector to match against delegated targets.
1057
+ * @param event DOM event name (e.g. `'click'`, `'input'`).
1058
+ * @param handler Called with the event and the matched child element.
1059
+ * @param options Standard `addEventListener` options (capture, passive, etc.).
1060
+ * @returns An unsubscribe function that removes the listener.
1061
+ */
975
1062
  declare function delegate<K extends keyof HTMLElementEventMap>(container: HTMLElement | Document, selector: string, event: K, handler: (e: HTMLElementEventMap[K], matchedEl: HTMLElement) => void, options?: AddEventListenerOptions): () => void;
976
1063
 
977
1064
  type KeyCombo = string;
1065
+ /** Options for the {@link onKey} keyboard shortcut handler. */
978
1066
  interface KeyOptions {
1067
+ /** Element or document to listen on. Defaults to `document`. */
979
1068
  target?: EventTarget;
1069
+ /** Whether to call `e.preventDefault()`. Defaults to `true`. */
980
1070
  preventDefault?: boolean;
981
1071
  }
1072
+ /**
1073
+ * Listen for a keyboard shortcut and invoke a handler when it fires.
1074
+ *
1075
+ * Supports modifier keys: `ctrl`, `shift`, `alt`, `meta`/`cmd`.
1076
+ *
1077
+ * ```ts
1078
+ * const unsub = onKey('ctrl+s', (e) => save());
1079
+ * const unsub2 = onKey('escape', () => close(), { target: modal });
1080
+ * ```
1081
+ *
1082
+ * @param combo Key combination string (e.g. `'ctrl+s'`, `'shift+enter'`).
1083
+ * @param handler Called when the combo is pressed.
1084
+ * @param options Optional target element and preventDefault behavior.
1085
+ * @returns An unsubscribe function that removes the listener.
1086
+ */
982
1087
  declare function onKey(combo: KeyCombo, handler: (e: KeyboardEvent) => void, options?: KeyOptions): () => void;
983
1088
 
1089
+ /**
1090
+ * Select a single element by CSS selector. Returns `null` if not found.
1091
+ *
1092
+ * ```ts
1093
+ * const btn = $<HTMLButtonElement>('.submit-btn');
1094
+ * const inner = $('span', container);
1095
+ * ```
1096
+ */
984
1097
  declare function $<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T | null;
1098
+ /**
1099
+ * Select all elements matching a CSS selector, returned as a plain array.
1100
+ *
1101
+ * ```ts
1102
+ * const items = $$<HTMLLIElement>('ul > li');
1103
+ * items.forEach((li) => li.classList.add('active'));
1104
+ * ```
1105
+ */
985
1106
  declare function $$<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T[];
986
1107
 
1108
+ /** Add one or more CSS classes to an element. */
987
1109
  declare function addClass(el: HTMLElement, ...classes: string[]): void;
1110
+ /** Remove one or more CSS classes from an element. */
988
1111
  declare function removeClass(el: HTMLElement, ...classes: string[]): void;
1112
+ /** Toggle a CSS class on an element. Returns the resulting state. */
989
1113
  declare function toggleClass(el: HTMLElement, className: string, force?: boolean): boolean;
990
- declare function setStyle(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
991
- declare function setAttr(el: HTMLElement, attrs: Record<string, string | boolean | null>): void;
992
- declare function setText(el: HTMLElement, text: string): void;
993
1114
  /**
994
- * Set raw HTML on an element. **No sanitization is performed.**
1115
+ * Apply multiple inline styles to an element at once.
995
1116
  *
996
- * Prefer `setText()` for user-controlled content. Only use this when you
997
- * trust the HTML source (e.g., server-rendered markup you control).
1117
+ * ```ts
1118
+ * setStyle(el, { opacity: '0', transform: 'translateY(-10px)' });
1119
+ * ```
1120
+ */
1121
+ declare function setStyle(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
1122
+ /**
1123
+ * Set or remove multiple attributes on an element.
998
1124
  *
1125
+ * - `false` / `null` removes the attribute.
1126
+ * - `true` sets it as a boolean attribute (empty string).
1127
+ * - A string sets the attribute value.
1128
+ */
1129
+ declare function setAttr(el: HTMLElement, attrs: Record<string, string | boolean | null>): void;
1130
+ /** Set an element's text content. Safe for user-controlled strings. */
1131
+ declare function setText(el: HTMLElement, text: string): void;
999
1132
  /**
1000
1133
  * Set raw HTML on an element. **No sanitization is performed.**
1001
1134
  *
@@ -1004,15 +1137,37 @@ declare function setText(el: HTMLElement, text: string): void;
1004
1137
  */
1005
1138
  declare function setHTMLUnsafe(el: HTMLElement, html: string): void;
1006
1139
 
1140
+ /** Find the closest ancestor matching a CSS selector. */
1007
1141
  declare function closest<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector: string): T | null;
1142
+ /** Get direct child elements, optionally filtered by a CSS selector. */
1008
1143
  declare function children<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1144
+ /** Get sibling elements (excluding the element itself), optionally filtered. */
1009
1145
  declare function siblings<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1146
+ /** Get the parent element, or `null` if detached. */
1010
1147
  declare function parent<T extends HTMLElement = HTMLElement>(el: HTMLElement): T | null;
1148
+ /** Find the next sibling element, optionally matching a CSS selector. */
1011
1149
  declare function nextSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1150
+ /** Find the previous sibling element, optionally matching a CSS selector. */
1012
1151
  declare function prevSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1013
1152
 
1153
+ /**
1154
+ * Observe element size changes via `ResizeObserver`.
1155
+ *
1156
+ * @returns A disconnect function that stops observing.
1157
+ */
1014
1158
  declare function onResize(el: HTMLElement, handler: (entry: ResizeObserverEntry) => void): () => void;
1159
+ /**
1160
+ * Observe element visibility changes via `IntersectionObserver`.
1161
+ *
1162
+ * @returns A disconnect function that stops observing.
1163
+ */
1015
1164
  declare function onIntersect(el: HTMLElement, handler: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): () => void;
1165
+ /**
1166
+ * Observe DOM mutations (child additions/removals, attribute changes) via
1167
+ * `MutationObserver`. Defaults to `{ childList: true, subtree: true }`.
1168
+ *
1169
+ * @returns A disconnect function that stops observing.
1170
+ */
1016
1171
  declare function onMutation(el: HTMLElement, handler: (mutations: MutationRecord[]) => void, options?: MutationObserverInit): () => void;
1017
1172
 
1018
- export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
1173
+ export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, createUnownedRoot, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference path="./jsx.d.ts" />
2
- import { S as SignalGetter } from './signal-YlS1kgfh.js';
3
- export { a as SignalOptions, b as SignalSetter, c as createSignal } from './signal-YlS1kgfh.js';
4
- export { R as Resource, a as ResourceOptions, c as createResource } from './resource-Cd0cGOxS.js';
2
+ import { S as SignalGetter } from './signal-C9v4akyJ.js';
3
+ export { a as SignalOptions, b as SignalSetter, c as createSignal } from './signal-C9v4akyJ.js';
4
+ export { R as Resource, a as ResourceOptions, c as createResource } from './resource-BHsgURy0.js';
5
5
  export { getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, trigger } from 'alien-signals';
6
6
 
7
7
  declare function createEffect(fn: () => void | (() => void)): () => void;
@@ -134,6 +134,11 @@ declare function untrack<T>(fn: () => T): T;
134
134
  * Uses alien-signals' `effectScope` under the hood for native graph-level
135
135
  * effect tracking, with a userland disposer list for non-effect cleanup
136
136
  * (e.g., event listeners, DOM references, timers).
137
+ *
138
+ * Roots created inside another root are automatically owned by the parent
139
+ * (Solid-style). When the parent is disposed, all child roots are disposed
140
+ * too. Use {@link createUnownedRoot} for roots that must outlive their
141
+ * lexical parent (e.g., mount points, test harnesses).
137
142
  */
138
143
  /**
139
144
  * Create a reactive root scope.
@@ -143,6 +148,9 @@ declare function untrack<T>(fn: () => T): T;
143
148
  * userland level (via registerDisposer). The returned `dispose` function
144
149
  * tears down everything.
145
150
  *
151
+ * Roots created inside another root are automatically owned by the parent.
152
+ * When the parent is disposed, this root is disposed too.
153
+ *
146
154
  * ```ts
147
155
  * const dispose = createRoot(() => {
148
156
  * createEffect(() => console.log(count()));
@@ -152,6 +160,22 @@ declare function untrack<T>(fn: () => T): T;
152
160
  * ```
153
161
  */
154
162
  declare function createRoot<T>(fn: (dispose: () => void) => T): T;
163
+ /**
164
+ * Create a reactive root that is NOT owned by any parent root.
165
+ *
166
+ * Use this for roots that must outlive their lexical parent:
167
+ * top-level mount points, island hydration, test harnesses, etc.
168
+ *
169
+ * ```ts
170
+ * createRoot(() => {
171
+ * // This root outlives the parent even though it's nested:
172
+ * createUnownedRoot((dispose) => {
173
+ * // effects here survive parent disposal
174
+ * });
175
+ * });
176
+ * ```
177
+ */
178
+ declare function createUnownedRoot<T>(fn: (dispose: () => void) => T): T;
155
179
 
156
180
  /**
157
181
  * Register a cleanup function in the current reactive scope.
@@ -223,7 +247,9 @@ declare function on<T, U>(deps: () => T, fn: (value: T, prev: T | undefined) =>
223
247
  * React equivalent: useRef
224
248
  * SolidJS equivalent: (none — uses plain variables in setup)
225
249
  */
250
+ /** A mutable container that does NOT trigger reactivity when written to. */
226
251
  interface Ref<T> {
252
+ /** The stored value. Mutating this does not notify effects. */
227
253
  current: T;
228
254
  }
229
255
  /**
@@ -257,6 +283,7 @@ declare function createRef<T>(initialValue: T): Ref<T>;
257
283
  * SolidJS equivalent: (none — uses createSignal + helpers)
258
284
  */
259
285
 
286
+ /** A function that dispatches an action to a reducer. */
260
287
  type Dispatch<A> = (action: A) => void;
261
288
  /**
262
289
  * Create a reducer — predictable state updates via dispatched actions.
@@ -285,6 +312,7 @@ type Dispatch<A> = (action: A) => void;
285
312
  */
286
313
  declare function createReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [state: SignalGetter<S>, dispatch: Dispatch<A>];
287
314
 
315
+ /** Callback signature for the global {@link onError} handler. */
288
316
  type ErrorHandler = (error: unknown, info?: {
289
317
  source?: string;
290
318
  }) => void;
@@ -428,12 +456,18 @@ declare function mount(component: () => HTMLElement | DocumentFragment, containe
428
456
  *
429
457
  * Total module budget: <2KB minified.
430
458
  */
459
+ /** Return value from {@link reconcileList} — the new nodes and items arrays. */
431
460
  interface ReconcileResult<T> {
461
+ /** The DOM nodes currently in the list, in order. */
432
462
  nodes: Node[];
463
+ /** The items array corresponding to the current nodes. */
433
464
  items: T[];
434
465
  }
466
+ /** Animation hooks for list transitions. */
435
467
  interface ListTransitionHooks {
468
+ /** Called after a new node is inserted into the DOM. */
436
469
  onInsert?: (node: Node) => void;
470
+ /** Called before a node is removed. Call `done()` when the exit animation finishes. */
437
471
  onBeforeRemove?: (node: Node, done: () => void) => void;
438
472
  }
439
473
  interface CreateListOptions {
@@ -530,7 +564,7 @@ declare function createList<T>(items: () => T[], keyFn: (item: T) => string | nu
530
564
  * Returns a DocumentFragment with comment markers. The content between
531
565
  * markers is swapped reactively when `when()` changes.
532
566
  */
533
- declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node): DocumentFragment;
567
+ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node | null): DocumentFragment;
534
568
 
535
569
  /**
536
570
  * Forma DOM - Switch (Multi-branch Conditional)
@@ -546,8 +580,11 @@ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: ()
546
580
  *
547
581
  * SolidJS equivalent: <Switch><Match when={}>
548
582
  */
583
+ /** A single branch for {@link createSwitch}. */
549
584
  interface SwitchCase<T> {
585
+ /** The value that activates this branch. */
550
586
  match: T;
587
+ /** Factory function that renders this branch's DOM. */
551
588
  render: () => Node;
552
589
  }
553
590
  /**
@@ -747,10 +784,15 @@ declare function deactivateAllIslands(root?: Element | Document): void;
747
784
  * Reactivity comes from signals, not re-rendering.
748
785
  * Backed by alien-signals via forma/reactive.
749
786
  */
787
+ /** A teardown function that disposes effects and cleans up resources. */
750
788
  type CleanupFn = () => void;
789
+ /** A function that runs once to build the component's DOM tree. */
751
790
  type SetupFn = () => HTMLElement | DocumentFragment;
791
+ /** Definition object passed to {@link defineComponent}. */
752
792
  interface ComponentDef {
793
+ /** The setup function that builds the component's DOM and reactive bindings. */
753
794
  setup: SetupFn;
795
+ /** Optional debug name for devtools inspection. */
754
796
  name?: string;
755
797
  }
756
798
  /**
@@ -793,6 +835,7 @@ declare function trackDisposer(dispose: () => void): void;
793
835
  * inject() reads the top, component teardown pops automatically.
794
836
  * Zero dependencies -- native browser APIs only.
795
837
  */
838
+ /** A typed dependency injection context created by {@link createContext}. */
796
839
  interface Context<T> {
797
840
  /** Unique identifier for this context. */
798
841
  readonly id: symbol;
@@ -850,6 +893,7 @@ declare function unprovide<T>(ctx: Context<T>): void;
850
893
  *
851
894
  * Backed by alien-signals via forma/reactive.
852
895
  */
896
+ /** Setter for a reactive store — accepts a partial update object or updater function. */
853
897
  type StoreSetter<T extends object> = (partial: Partial<T> | ((prev: T) => Partial<T>)) => void;
854
898
  /**
855
899
  * Create a deep reactive store.
@@ -897,6 +941,7 @@ declare function createStore<T extends object>(initial: T): [get: T, set: StoreS
897
941
  * with reactive canUndo/canRedo signals.
898
942
  * Zero dependencies -- native browser APIs only.
899
943
  */
944
+ /** Undo/redo controls returned by {@link createHistory}. */
900
945
  interface HistoryControls<T> {
901
946
  /** Undo the last change, restoring the previous value. */
902
947
  undo: () => void;
@@ -938,6 +983,7 @@ declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], o
938
983
  * Reads stored value on creation; writes on every signal change.
939
984
  * Zero dependencies -- native browser APIs only.
940
985
  */
986
+ /** Options for {@link persist} — storage backend, serialization, and validation. */
941
987
  interface PersistOptions<T> {
942
988
  /** Storage backend. Defaults to localStorage. */
943
989
  storage?: Storage;
@@ -963,39 +1009,126 @@ interface PersistOptions<T> {
963
1009
  */
964
1010
  declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): void;
965
1011
 
1012
+ /**
1013
+ * A typed publish/subscribe event bus.
1014
+ *
1015
+ * The type parameter `T` maps event names to their payload types,
1016
+ * ensuring type-safe event emission and subscription.
1017
+ */
966
1018
  interface EventBus<T extends Record<string, unknown>> {
1019
+ /** Subscribe to an event. Returns an unsubscribe function. */
967
1020
  on<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
1021
+ /** Subscribe to an event, automatically unsubscribing after the first firing. */
968
1022
  once<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
1023
+ /** Emit an event to all current subscribers. */
969
1024
  emit<K extends keyof T>(event: K, payload: T[K]): void;
1025
+ /** Remove a specific handler from an event. */
970
1026
  off<K extends keyof T>(event: K, handler: (payload: T[K]) => void): void;
1027
+ /** Remove all handlers for all events. */
971
1028
  clear(): void;
972
1029
  }
1030
+ /**
1031
+ * Create a typed event bus for publish/subscribe messaging.
1032
+ *
1033
+ * ```ts
1034
+ * type Events = { save: { id: number }; delete: { id: number } };
1035
+ * const bus = createBus<Events>();
1036
+ *
1037
+ * const unsub = bus.on('save', (payload) => console.log(payload.id));
1038
+ * bus.emit('save', { id: 42 });
1039
+ * unsub();
1040
+ * ```
1041
+ */
973
1042
  declare function createBus<T extends Record<string, unknown> = Record<string, unknown>>(): EventBus<T>;
974
1043
 
1044
+ /**
1045
+ * Attach a single event listener on a parent that fires for children matching
1046
+ * a CSS selector. Efficient for large/dynamic lists — one listener instead of
1047
+ * one per child.
1048
+ *
1049
+ * ```ts
1050
+ * const unsub = delegate(ul, 'li', 'click', (e, li) => {
1051
+ * console.log('Clicked:', li.textContent);
1052
+ * });
1053
+ * ```
1054
+ *
1055
+ * @param container The parent element or document to listen on.
1056
+ * @param selector CSS selector to match against delegated targets.
1057
+ * @param event DOM event name (e.g. `'click'`, `'input'`).
1058
+ * @param handler Called with the event and the matched child element.
1059
+ * @param options Standard `addEventListener` options (capture, passive, etc.).
1060
+ * @returns An unsubscribe function that removes the listener.
1061
+ */
975
1062
  declare function delegate<K extends keyof HTMLElementEventMap>(container: HTMLElement | Document, selector: string, event: K, handler: (e: HTMLElementEventMap[K], matchedEl: HTMLElement) => void, options?: AddEventListenerOptions): () => void;
976
1063
 
977
1064
  type KeyCombo = string;
1065
+ /** Options for the {@link onKey} keyboard shortcut handler. */
978
1066
  interface KeyOptions {
1067
+ /** Element or document to listen on. Defaults to `document`. */
979
1068
  target?: EventTarget;
1069
+ /** Whether to call `e.preventDefault()`. Defaults to `true`. */
980
1070
  preventDefault?: boolean;
981
1071
  }
1072
+ /**
1073
+ * Listen for a keyboard shortcut and invoke a handler when it fires.
1074
+ *
1075
+ * Supports modifier keys: `ctrl`, `shift`, `alt`, `meta`/`cmd`.
1076
+ *
1077
+ * ```ts
1078
+ * const unsub = onKey('ctrl+s', (e) => save());
1079
+ * const unsub2 = onKey('escape', () => close(), { target: modal });
1080
+ * ```
1081
+ *
1082
+ * @param combo Key combination string (e.g. `'ctrl+s'`, `'shift+enter'`).
1083
+ * @param handler Called when the combo is pressed.
1084
+ * @param options Optional target element and preventDefault behavior.
1085
+ * @returns An unsubscribe function that removes the listener.
1086
+ */
982
1087
  declare function onKey(combo: KeyCombo, handler: (e: KeyboardEvent) => void, options?: KeyOptions): () => void;
983
1088
 
1089
+ /**
1090
+ * Select a single element by CSS selector. Returns `null` if not found.
1091
+ *
1092
+ * ```ts
1093
+ * const btn = $<HTMLButtonElement>('.submit-btn');
1094
+ * const inner = $('span', container);
1095
+ * ```
1096
+ */
984
1097
  declare function $<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T | null;
1098
+ /**
1099
+ * Select all elements matching a CSS selector, returned as a plain array.
1100
+ *
1101
+ * ```ts
1102
+ * const items = $$<HTMLLIElement>('ul > li');
1103
+ * items.forEach((li) => li.classList.add('active'));
1104
+ * ```
1105
+ */
985
1106
  declare function $$<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T[];
986
1107
 
1108
+ /** Add one or more CSS classes to an element. */
987
1109
  declare function addClass(el: HTMLElement, ...classes: string[]): void;
1110
+ /** Remove one or more CSS classes from an element. */
988
1111
  declare function removeClass(el: HTMLElement, ...classes: string[]): void;
1112
+ /** Toggle a CSS class on an element. Returns the resulting state. */
989
1113
  declare function toggleClass(el: HTMLElement, className: string, force?: boolean): boolean;
990
- declare function setStyle(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
991
- declare function setAttr(el: HTMLElement, attrs: Record<string, string | boolean | null>): void;
992
- declare function setText(el: HTMLElement, text: string): void;
993
1114
  /**
994
- * Set raw HTML on an element. **No sanitization is performed.**
1115
+ * Apply multiple inline styles to an element at once.
995
1116
  *
996
- * Prefer `setText()` for user-controlled content. Only use this when you
997
- * trust the HTML source (e.g., server-rendered markup you control).
1117
+ * ```ts
1118
+ * setStyle(el, { opacity: '0', transform: 'translateY(-10px)' });
1119
+ * ```
1120
+ */
1121
+ declare function setStyle(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
1122
+ /**
1123
+ * Set or remove multiple attributes on an element.
998
1124
  *
1125
+ * - `false` / `null` removes the attribute.
1126
+ * - `true` sets it as a boolean attribute (empty string).
1127
+ * - A string sets the attribute value.
1128
+ */
1129
+ declare function setAttr(el: HTMLElement, attrs: Record<string, string | boolean | null>): void;
1130
+ /** Set an element's text content. Safe for user-controlled strings. */
1131
+ declare function setText(el: HTMLElement, text: string): void;
999
1132
  /**
1000
1133
  * Set raw HTML on an element. **No sanitization is performed.**
1001
1134
  *
@@ -1004,15 +1137,37 @@ declare function setText(el: HTMLElement, text: string): void;
1004
1137
  */
1005
1138
  declare function setHTMLUnsafe(el: HTMLElement, html: string): void;
1006
1139
 
1140
+ /** Find the closest ancestor matching a CSS selector. */
1007
1141
  declare function closest<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector: string): T | null;
1142
+ /** Get direct child elements, optionally filtered by a CSS selector. */
1008
1143
  declare function children<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1144
+ /** Get sibling elements (excluding the element itself), optionally filtered. */
1009
1145
  declare function siblings<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1146
+ /** Get the parent element, or `null` if detached. */
1010
1147
  declare function parent<T extends HTMLElement = HTMLElement>(el: HTMLElement): T | null;
1148
+ /** Find the next sibling element, optionally matching a CSS selector. */
1011
1149
  declare function nextSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1150
+ /** Find the previous sibling element, optionally matching a CSS selector. */
1012
1151
  declare function prevSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1013
1152
 
1153
+ /**
1154
+ * Observe element size changes via `ResizeObserver`.
1155
+ *
1156
+ * @returns A disconnect function that stops observing.
1157
+ */
1014
1158
  declare function onResize(el: HTMLElement, handler: (entry: ResizeObserverEntry) => void): () => void;
1159
+ /**
1160
+ * Observe element visibility changes via `IntersectionObserver`.
1161
+ *
1162
+ * @returns A disconnect function that stops observing.
1163
+ */
1015
1164
  declare function onIntersect(el: HTMLElement, handler: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): () => void;
1165
+ /**
1166
+ * Observe DOM mutations (child additions/removals, attribute changes) via
1167
+ * `MutationObserver`. Defaults to `{ childList: true, subtree: true }`.
1168
+ *
1169
+ * @returns A disconnect function that stops observing.
1170
+ */
1016
1171
  declare function onMutation(el: HTMLElement, handler: (mutations: MutationRecord[]) => void, options?: MutationObserverInit): () => void;
1017
1172
 
1018
- export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };
1173
+ export { $, $$, type CleanupFn, type ComponentDef, type Context, type CreateListOptions, type Dispatch, type ErrorHandler, type EventBus, Fragment, type HistoryControls, type IslandHydrateFn, type KeyOptions, type ListTransitionHooks, type PersistOptions, type ReconcileResult, type Ref, type SetupFn, SignalGetter, type StoreSetter, type SwitchCase, activateIslands, addClass, batch, children, cleanup, closest, createBus, createComputed, createContext, createEffect, createErrorBoundary, createHistory, createList, createMemo, createPortal, createReducer, createRef, createRoot, createShow, createStore, createSuspense, createSwitch, createText, createUnownedRoot, deactivateAllIslands, deactivateIsland, defineComponent, delegate, disposeComponent, fragment, h, hydrateIsland, inject, mount, nextSibling, on, onCleanup, onError, onIntersect, onKey, onMount, onMutation, onResize, onUnmount, parent, persist, prevSibling, provide, reconcileList, removeClass, setAttr, setHTMLUnsafe, setStyle, setText, siblings, template, templateMany, toggleClass, trackDisposer, unprovide, untrack };