@getforma/core 1.0.7 → 1.0.8

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-SZSKW57A.cjs → chunk-7L3KHGEA.cjs} +42 -42
  3. package/dist/chunk-7L3KHGEA.cjs.map +1 -0
  4. package/dist/{chunk-FJGTMWKY.js → chunk-7Q7LIV23.js} +6 -6
  5. package/dist/chunk-7Q7LIV23.js.map +1 -0
  6. package/dist/{chunk-DCTOXHPF.cjs → chunk-BARF67I6.cjs} +8 -8
  7. package/dist/chunk-BARF67I6.cjs.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-OUVOAYIO.js → chunk-TBWZZ3SI.js} +3 -3
  13. package/dist/chunk-TBWZZ3SI.js.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 +2 -2
  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 +61 -61
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +141 -10
  23. package/dist/index.d.ts +141 -10
  24. package/dist/index.js +6 -6
  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;
@@ -223,7 +223,9 @@ declare function on<T, U>(deps: () => T, fn: (value: T, prev: T | undefined) =>
223
223
  * React equivalent: useRef
224
224
  * SolidJS equivalent: (none — uses plain variables in setup)
225
225
  */
226
+ /** A mutable container that does NOT trigger reactivity when written to. */
226
227
  interface Ref<T> {
228
+ /** The stored value. Mutating this does not notify effects. */
227
229
  current: T;
228
230
  }
229
231
  /**
@@ -257,6 +259,7 @@ declare function createRef<T>(initialValue: T): Ref<T>;
257
259
  * SolidJS equivalent: (none — uses createSignal + helpers)
258
260
  */
259
261
 
262
+ /** A function that dispatches an action to a reducer. */
260
263
  type Dispatch<A> = (action: A) => void;
261
264
  /**
262
265
  * Create a reducer — predictable state updates via dispatched actions.
@@ -285,6 +288,7 @@ type Dispatch<A> = (action: A) => void;
285
288
  */
286
289
  declare function createReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [state: SignalGetter<S>, dispatch: Dispatch<A>];
287
290
 
291
+ /** Callback signature for the global {@link onError} handler. */
288
292
  type ErrorHandler = (error: unknown, info?: {
289
293
  source?: string;
290
294
  }) => void;
@@ -428,12 +432,18 @@ declare function mount(component: () => HTMLElement | DocumentFragment, containe
428
432
  *
429
433
  * Total module budget: <2KB minified.
430
434
  */
435
+ /** Return value from {@link reconcileList} — the new nodes and items arrays. */
431
436
  interface ReconcileResult<T> {
437
+ /** The DOM nodes currently in the list, in order. */
432
438
  nodes: Node[];
439
+ /** The items array corresponding to the current nodes. */
433
440
  items: T[];
434
441
  }
442
+ /** Animation hooks for list transitions. */
435
443
  interface ListTransitionHooks {
444
+ /** Called after a new node is inserted into the DOM. */
436
445
  onInsert?: (node: Node) => void;
446
+ /** Called before a node is removed. Call `done()` when the exit animation finishes. */
437
447
  onBeforeRemove?: (node: Node, done: () => void) => void;
438
448
  }
439
449
  interface CreateListOptions {
@@ -530,7 +540,7 @@ declare function createList<T>(items: () => T[], keyFn: (item: T) => string | nu
530
540
  * Returns a DocumentFragment with comment markers. The content between
531
541
  * markers is swapped reactively when `when()` changes.
532
542
  */
533
- declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node): DocumentFragment;
543
+ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node | null): DocumentFragment;
534
544
 
535
545
  /**
536
546
  * Forma DOM - Switch (Multi-branch Conditional)
@@ -546,8 +556,11 @@ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: ()
546
556
  *
547
557
  * SolidJS equivalent: <Switch><Match when={}>
548
558
  */
559
+ /** A single branch for {@link createSwitch}. */
549
560
  interface SwitchCase<T> {
561
+ /** The value that activates this branch. */
550
562
  match: T;
563
+ /** Factory function that renders this branch's DOM. */
551
564
  render: () => Node;
552
565
  }
553
566
  /**
@@ -747,10 +760,15 @@ declare function deactivateAllIslands(root?: Element | Document): void;
747
760
  * Reactivity comes from signals, not re-rendering.
748
761
  * Backed by alien-signals via forma/reactive.
749
762
  */
763
+ /** A teardown function that disposes effects and cleans up resources. */
750
764
  type CleanupFn = () => void;
765
+ /** A function that runs once to build the component's DOM tree. */
751
766
  type SetupFn = () => HTMLElement | DocumentFragment;
767
+ /** Definition object passed to {@link defineComponent}. */
752
768
  interface ComponentDef {
769
+ /** The setup function that builds the component's DOM and reactive bindings. */
753
770
  setup: SetupFn;
771
+ /** Optional debug name for devtools inspection. */
754
772
  name?: string;
755
773
  }
756
774
  /**
@@ -793,6 +811,7 @@ declare function trackDisposer(dispose: () => void): void;
793
811
  * inject() reads the top, component teardown pops automatically.
794
812
  * Zero dependencies -- native browser APIs only.
795
813
  */
814
+ /** A typed dependency injection context created by {@link createContext}. */
796
815
  interface Context<T> {
797
816
  /** Unique identifier for this context. */
798
817
  readonly id: symbol;
@@ -850,6 +869,7 @@ declare function unprovide<T>(ctx: Context<T>): void;
850
869
  *
851
870
  * Backed by alien-signals via forma/reactive.
852
871
  */
872
+ /** Setter for a reactive store — accepts a partial update object or updater function. */
853
873
  type StoreSetter<T extends object> = (partial: Partial<T> | ((prev: T) => Partial<T>)) => void;
854
874
  /**
855
875
  * Create a deep reactive store.
@@ -897,6 +917,7 @@ declare function createStore<T extends object>(initial: T): [get: T, set: StoreS
897
917
  * with reactive canUndo/canRedo signals.
898
918
  * Zero dependencies -- native browser APIs only.
899
919
  */
920
+ /** Undo/redo controls returned by {@link createHistory}. */
900
921
  interface HistoryControls<T> {
901
922
  /** Undo the last change, restoring the previous value. */
902
923
  undo: () => void;
@@ -938,6 +959,7 @@ declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], o
938
959
  * Reads stored value on creation; writes on every signal change.
939
960
  * Zero dependencies -- native browser APIs only.
940
961
  */
962
+ /** Options for {@link persist} — storage backend, serialization, and validation. */
941
963
  interface PersistOptions<T> {
942
964
  /** Storage backend. Defaults to localStorage. */
943
965
  storage?: Storage;
@@ -963,39 +985,126 @@ interface PersistOptions<T> {
963
985
  */
964
986
  declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): void;
965
987
 
988
+ /**
989
+ * A typed publish/subscribe event bus.
990
+ *
991
+ * The type parameter `T` maps event names to their payload types,
992
+ * ensuring type-safe event emission and subscription.
993
+ */
966
994
  interface EventBus<T extends Record<string, unknown>> {
995
+ /** Subscribe to an event. Returns an unsubscribe function. */
967
996
  on<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
997
+ /** Subscribe to an event, automatically unsubscribing after the first firing. */
968
998
  once<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
999
+ /** Emit an event to all current subscribers. */
969
1000
  emit<K extends keyof T>(event: K, payload: T[K]): void;
1001
+ /** Remove a specific handler from an event. */
970
1002
  off<K extends keyof T>(event: K, handler: (payload: T[K]) => void): void;
1003
+ /** Remove all handlers for all events. */
971
1004
  clear(): void;
972
1005
  }
1006
+ /**
1007
+ * Create a typed event bus for publish/subscribe messaging.
1008
+ *
1009
+ * ```ts
1010
+ * type Events = { save: { id: number }; delete: { id: number } };
1011
+ * const bus = createBus<Events>();
1012
+ *
1013
+ * const unsub = bus.on('save', (payload) => console.log(payload.id));
1014
+ * bus.emit('save', { id: 42 });
1015
+ * unsub();
1016
+ * ```
1017
+ */
973
1018
  declare function createBus<T extends Record<string, unknown> = Record<string, unknown>>(): EventBus<T>;
974
1019
 
1020
+ /**
1021
+ * Attach a single event listener on a parent that fires for children matching
1022
+ * a CSS selector. Efficient for large/dynamic lists — one listener instead of
1023
+ * one per child.
1024
+ *
1025
+ * ```ts
1026
+ * const unsub = delegate(ul, 'li', 'click', (e, li) => {
1027
+ * console.log('Clicked:', li.textContent);
1028
+ * });
1029
+ * ```
1030
+ *
1031
+ * @param container The parent element or document to listen on.
1032
+ * @param selector CSS selector to match against delegated targets.
1033
+ * @param event DOM event name (e.g. `'click'`, `'input'`).
1034
+ * @param handler Called with the event and the matched child element.
1035
+ * @param options Standard `addEventListener` options (capture, passive, etc.).
1036
+ * @returns An unsubscribe function that removes the listener.
1037
+ */
975
1038
  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
1039
 
977
1040
  type KeyCombo = string;
1041
+ /** Options for the {@link onKey} keyboard shortcut handler. */
978
1042
  interface KeyOptions {
1043
+ /** Element or document to listen on. Defaults to `document`. */
979
1044
  target?: EventTarget;
1045
+ /** Whether to call `e.preventDefault()`. Defaults to `true`. */
980
1046
  preventDefault?: boolean;
981
1047
  }
1048
+ /**
1049
+ * Listen for a keyboard shortcut and invoke a handler when it fires.
1050
+ *
1051
+ * Supports modifier keys: `ctrl`, `shift`, `alt`, `meta`/`cmd`.
1052
+ *
1053
+ * ```ts
1054
+ * const unsub = onKey('ctrl+s', (e) => save());
1055
+ * const unsub2 = onKey('escape', () => close(), { target: modal });
1056
+ * ```
1057
+ *
1058
+ * @param combo Key combination string (e.g. `'ctrl+s'`, `'shift+enter'`).
1059
+ * @param handler Called when the combo is pressed.
1060
+ * @param options Optional target element and preventDefault behavior.
1061
+ * @returns An unsubscribe function that removes the listener.
1062
+ */
982
1063
  declare function onKey(combo: KeyCombo, handler: (e: KeyboardEvent) => void, options?: KeyOptions): () => void;
983
1064
 
1065
+ /**
1066
+ * Select a single element by CSS selector. Returns `null` if not found.
1067
+ *
1068
+ * ```ts
1069
+ * const btn = $<HTMLButtonElement>('.submit-btn');
1070
+ * const inner = $('span', container);
1071
+ * ```
1072
+ */
984
1073
  declare function $<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T | null;
1074
+ /**
1075
+ * Select all elements matching a CSS selector, returned as a plain array.
1076
+ *
1077
+ * ```ts
1078
+ * const items = $$<HTMLLIElement>('ul > li');
1079
+ * items.forEach((li) => li.classList.add('active'));
1080
+ * ```
1081
+ */
985
1082
  declare function $$<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T[];
986
1083
 
1084
+ /** Add one or more CSS classes to an element. */
987
1085
  declare function addClass(el: HTMLElement, ...classes: string[]): void;
1086
+ /** Remove one or more CSS classes from an element. */
988
1087
  declare function removeClass(el: HTMLElement, ...classes: string[]): void;
1088
+ /** Toggle a CSS class on an element. Returns the resulting state. */
989
1089
  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
1090
  /**
994
- * Set raw HTML on an element. **No sanitization is performed.**
1091
+ * Apply multiple inline styles to an element at once.
995
1092
  *
996
- * Prefer `setText()` for user-controlled content. Only use this when you
997
- * trust the HTML source (e.g., server-rendered markup you control).
1093
+ * ```ts
1094
+ * setStyle(el, { opacity: '0', transform: 'translateY(-10px)' });
1095
+ * ```
1096
+ */
1097
+ declare function setStyle(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
1098
+ /**
1099
+ * Set or remove multiple attributes on an element.
998
1100
  *
1101
+ * - `false` / `null` removes the attribute.
1102
+ * - `true` sets it as a boolean attribute (empty string).
1103
+ * - A string sets the attribute value.
1104
+ */
1105
+ declare function setAttr(el: HTMLElement, attrs: Record<string, string | boolean | null>): void;
1106
+ /** Set an element's text content. Safe for user-controlled strings. */
1107
+ declare function setText(el: HTMLElement, text: string): void;
999
1108
  /**
1000
1109
  * Set raw HTML on an element. **No sanitization is performed.**
1001
1110
  *
@@ -1004,15 +1113,37 @@ declare function setText(el: HTMLElement, text: string): void;
1004
1113
  */
1005
1114
  declare function setHTMLUnsafe(el: HTMLElement, html: string): void;
1006
1115
 
1116
+ /** Find the closest ancestor matching a CSS selector. */
1007
1117
  declare function closest<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector: string): T | null;
1118
+ /** Get direct child elements, optionally filtered by a CSS selector. */
1008
1119
  declare function children<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1120
+ /** Get sibling elements (excluding the element itself), optionally filtered. */
1009
1121
  declare function siblings<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1122
+ /** Get the parent element, or `null` if detached. */
1010
1123
  declare function parent<T extends HTMLElement = HTMLElement>(el: HTMLElement): T | null;
1124
+ /** Find the next sibling element, optionally matching a CSS selector. */
1011
1125
  declare function nextSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1126
+ /** Find the previous sibling element, optionally matching a CSS selector. */
1012
1127
  declare function prevSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1013
1128
 
1129
+ /**
1130
+ * Observe element size changes via `ResizeObserver`.
1131
+ *
1132
+ * @returns A disconnect function that stops observing.
1133
+ */
1014
1134
  declare function onResize(el: HTMLElement, handler: (entry: ResizeObserverEntry) => void): () => void;
1135
+ /**
1136
+ * Observe element visibility changes via `IntersectionObserver`.
1137
+ *
1138
+ * @returns A disconnect function that stops observing.
1139
+ */
1015
1140
  declare function onIntersect(el: HTMLElement, handler: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): () => void;
1141
+ /**
1142
+ * Observe DOM mutations (child additions/removals, attribute changes) via
1143
+ * `MutationObserver`. Defaults to `{ childList: true, subtree: true }`.
1144
+ *
1145
+ * @returns A disconnect function that stops observing.
1146
+ */
1016
1147
  declare function onMutation(el: HTMLElement, handler: (mutations: MutationRecord[]) => void, options?: MutationObserverInit): () => void;
1017
1148
 
1018
1149
  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 };
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;
@@ -223,7 +223,9 @@ declare function on<T, U>(deps: () => T, fn: (value: T, prev: T | undefined) =>
223
223
  * React equivalent: useRef
224
224
  * SolidJS equivalent: (none — uses plain variables in setup)
225
225
  */
226
+ /** A mutable container that does NOT trigger reactivity when written to. */
226
227
  interface Ref<T> {
228
+ /** The stored value. Mutating this does not notify effects. */
227
229
  current: T;
228
230
  }
229
231
  /**
@@ -257,6 +259,7 @@ declare function createRef<T>(initialValue: T): Ref<T>;
257
259
  * SolidJS equivalent: (none — uses createSignal + helpers)
258
260
  */
259
261
 
262
+ /** A function that dispatches an action to a reducer. */
260
263
  type Dispatch<A> = (action: A) => void;
261
264
  /**
262
265
  * Create a reducer — predictable state updates via dispatched actions.
@@ -285,6 +288,7 @@ type Dispatch<A> = (action: A) => void;
285
288
  */
286
289
  declare function createReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [state: SignalGetter<S>, dispatch: Dispatch<A>];
287
290
 
291
+ /** Callback signature for the global {@link onError} handler. */
288
292
  type ErrorHandler = (error: unknown, info?: {
289
293
  source?: string;
290
294
  }) => void;
@@ -428,12 +432,18 @@ declare function mount(component: () => HTMLElement | DocumentFragment, containe
428
432
  *
429
433
  * Total module budget: <2KB minified.
430
434
  */
435
+ /** Return value from {@link reconcileList} — the new nodes and items arrays. */
431
436
  interface ReconcileResult<T> {
437
+ /** The DOM nodes currently in the list, in order. */
432
438
  nodes: Node[];
439
+ /** The items array corresponding to the current nodes. */
433
440
  items: T[];
434
441
  }
442
+ /** Animation hooks for list transitions. */
435
443
  interface ListTransitionHooks {
444
+ /** Called after a new node is inserted into the DOM. */
436
445
  onInsert?: (node: Node) => void;
446
+ /** Called before a node is removed. Call `done()` when the exit animation finishes. */
437
447
  onBeforeRemove?: (node: Node, done: () => void) => void;
438
448
  }
439
449
  interface CreateListOptions {
@@ -530,7 +540,7 @@ declare function createList<T>(items: () => T[], keyFn: (item: T) => string | nu
530
540
  * Returns a DocumentFragment with comment markers. The content between
531
541
  * markers is swapped reactively when `when()` changes.
532
542
  */
533
- declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node): DocumentFragment;
543
+ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: () => Node | null): DocumentFragment;
534
544
 
535
545
  /**
536
546
  * Forma DOM - Switch (Multi-branch Conditional)
@@ -546,8 +556,11 @@ declare function createShow(when: () => unknown, thenFn: () => Node, elseFn?: ()
546
556
  *
547
557
  * SolidJS equivalent: <Switch><Match when={}>
548
558
  */
559
+ /** A single branch for {@link createSwitch}. */
549
560
  interface SwitchCase<T> {
561
+ /** The value that activates this branch. */
550
562
  match: T;
563
+ /** Factory function that renders this branch's DOM. */
551
564
  render: () => Node;
552
565
  }
553
566
  /**
@@ -747,10 +760,15 @@ declare function deactivateAllIslands(root?: Element | Document): void;
747
760
  * Reactivity comes from signals, not re-rendering.
748
761
  * Backed by alien-signals via forma/reactive.
749
762
  */
763
+ /** A teardown function that disposes effects and cleans up resources. */
750
764
  type CleanupFn = () => void;
765
+ /** A function that runs once to build the component's DOM tree. */
751
766
  type SetupFn = () => HTMLElement | DocumentFragment;
767
+ /** Definition object passed to {@link defineComponent}. */
752
768
  interface ComponentDef {
769
+ /** The setup function that builds the component's DOM and reactive bindings. */
753
770
  setup: SetupFn;
771
+ /** Optional debug name for devtools inspection. */
754
772
  name?: string;
755
773
  }
756
774
  /**
@@ -793,6 +811,7 @@ declare function trackDisposer(dispose: () => void): void;
793
811
  * inject() reads the top, component teardown pops automatically.
794
812
  * Zero dependencies -- native browser APIs only.
795
813
  */
814
+ /** A typed dependency injection context created by {@link createContext}. */
796
815
  interface Context<T> {
797
816
  /** Unique identifier for this context. */
798
817
  readonly id: symbol;
@@ -850,6 +869,7 @@ declare function unprovide<T>(ctx: Context<T>): void;
850
869
  *
851
870
  * Backed by alien-signals via forma/reactive.
852
871
  */
872
+ /** Setter for a reactive store — accepts a partial update object or updater function. */
853
873
  type StoreSetter<T extends object> = (partial: Partial<T> | ((prev: T) => Partial<T>)) => void;
854
874
  /**
855
875
  * Create a deep reactive store.
@@ -897,6 +917,7 @@ declare function createStore<T extends object>(initial: T): [get: T, set: StoreS
897
917
  * with reactive canUndo/canRedo signals.
898
918
  * Zero dependencies -- native browser APIs only.
899
919
  */
920
+ /** Undo/redo controls returned by {@link createHistory}. */
900
921
  interface HistoryControls<T> {
901
922
  /** Undo the last change, restoring the previous value. */
902
923
  undo: () => void;
@@ -938,6 +959,7 @@ declare function createHistory<T>(source: [get: () => T, set: (v: T) => void], o
938
959
  * Reads stored value on creation; writes on every signal change.
939
960
  * Zero dependencies -- native browser APIs only.
940
961
  */
962
+ /** Options for {@link persist} — storage backend, serialization, and validation. */
941
963
  interface PersistOptions<T> {
942
964
  /** Storage backend. Defaults to localStorage. */
943
965
  storage?: Storage;
@@ -963,39 +985,126 @@ interface PersistOptions<T> {
963
985
  */
964
986
  declare function persist<T>(source: [get: () => T, set: (v: T) => void], key: string, options?: PersistOptions<T>): void;
965
987
 
988
+ /**
989
+ * A typed publish/subscribe event bus.
990
+ *
991
+ * The type parameter `T` maps event names to their payload types,
992
+ * ensuring type-safe event emission and subscription.
993
+ */
966
994
  interface EventBus<T extends Record<string, unknown>> {
995
+ /** Subscribe to an event. Returns an unsubscribe function. */
967
996
  on<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
997
+ /** Subscribe to an event, automatically unsubscribing after the first firing. */
968
998
  once<K extends keyof T>(event: K, handler: (payload: T[K]) => void): () => void;
999
+ /** Emit an event to all current subscribers. */
969
1000
  emit<K extends keyof T>(event: K, payload: T[K]): void;
1001
+ /** Remove a specific handler from an event. */
970
1002
  off<K extends keyof T>(event: K, handler: (payload: T[K]) => void): void;
1003
+ /** Remove all handlers for all events. */
971
1004
  clear(): void;
972
1005
  }
1006
+ /**
1007
+ * Create a typed event bus for publish/subscribe messaging.
1008
+ *
1009
+ * ```ts
1010
+ * type Events = { save: { id: number }; delete: { id: number } };
1011
+ * const bus = createBus<Events>();
1012
+ *
1013
+ * const unsub = bus.on('save', (payload) => console.log(payload.id));
1014
+ * bus.emit('save', { id: 42 });
1015
+ * unsub();
1016
+ * ```
1017
+ */
973
1018
  declare function createBus<T extends Record<string, unknown> = Record<string, unknown>>(): EventBus<T>;
974
1019
 
1020
+ /**
1021
+ * Attach a single event listener on a parent that fires for children matching
1022
+ * a CSS selector. Efficient for large/dynamic lists — one listener instead of
1023
+ * one per child.
1024
+ *
1025
+ * ```ts
1026
+ * const unsub = delegate(ul, 'li', 'click', (e, li) => {
1027
+ * console.log('Clicked:', li.textContent);
1028
+ * });
1029
+ * ```
1030
+ *
1031
+ * @param container The parent element or document to listen on.
1032
+ * @param selector CSS selector to match against delegated targets.
1033
+ * @param event DOM event name (e.g. `'click'`, `'input'`).
1034
+ * @param handler Called with the event and the matched child element.
1035
+ * @param options Standard `addEventListener` options (capture, passive, etc.).
1036
+ * @returns An unsubscribe function that removes the listener.
1037
+ */
975
1038
  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
1039
 
977
1040
  type KeyCombo = string;
1041
+ /** Options for the {@link onKey} keyboard shortcut handler. */
978
1042
  interface KeyOptions {
1043
+ /** Element or document to listen on. Defaults to `document`. */
979
1044
  target?: EventTarget;
1045
+ /** Whether to call `e.preventDefault()`. Defaults to `true`. */
980
1046
  preventDefault?: boolean;
981
1047
  }
1048
+ /**
1049
+ * Listen for a keyboard shortcut and invoke a handler when it fires.
1050
+ *
1051
+ * Supports modifier keys: `ctrl`, `shift`, `alt`, `meta`/`cmd`.
1052
+ *
1053
+ * ```ts
1054
+ * const unsub = onKey('ctrl+s', (e) => save());
1055
+ * const unsub2 = onKey('escape', () => close(), { target: modal });
1056
+ * ```
1057
+ *
1058
+ * @param combo Key combination string (e.g. `'ctrl+s'`, `'shift+enter'`).
1059
+ * @param handler Called when the combo is pressed.
1060
+ * @param options Optional target element and preventDefault behavior.
1061
+ * @returns An unsubscribe function that removes the listener.
1062
+ */
982
1063
  declare function onKey(combo: KeyCombo, handler: (e: KeyboardEvent) => void, options?: KeyOptions): () => void;
983
1064
 
1065
+ /**
1066
+ * Select a single element by CSS selector. Returns `null` if not found.
1067
+ *
1068
+ * ```ts
1069
+ * const btn = $<HTMLButtonElement>('.submit-btn');
1070
+ * const inner = $('span', container);
1071
+ * ```
1072
+ */
984
1073
  declare function $<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T | null;
1074
+ /**
1075
+ * Select all elements matching a CSS selector, returned as a plain array.
1076
+ *
1077
+ * ```ts
1078
+ * const items = $$<HTMLLIElement>('ul > li');
1079
+ * items.forEach((li) => li.classList.add('active'));
1080
+ * ```
1081
+ */
985
1082
  declare function $$<T extends HTMLElement = HTMLElement>(selector: string, parent?: ParentNode): T[];
986
1083
 
1084
+ /** Add one or more CSS classes to an element. */
987
1085
  declare function addClass(el: HTMLElement, ...classes: string[]): void;
1086
+ /** Remove one or more CSS classes from an element. */
988
1087
  declare function removeClass(el: HTMLElement, ...classes: string[]): void;
1088
+ /** Toggle a CSS class on an element. Returns the resulting state. */
989
1089
  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
1090
  /**
994
- * Set raw HTML on an element. **No sanitization is performed.**
1091
+ * Apply multiple inline styles to an element at once.
995
1092
  *
996
- * Prefer `setText()` for user-controlled content. Only use this when you
997
- * trust the HTML source (e.g., server-rendered markup you control).
1093
+ * ```ts
1094
+ * setStyle(el, { opacity: '0', transform: 'translateY(-10px)' });
1095
+ * ```
1096
+ */
1097
+ declare function setStyle(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
1098
+ /**
1099
+ * Set or remove multiple attributes on an element.
998
1100
  *
1101
+ * - `false` / `null` removes the attribute.
1102
+ * - `true` sets it as a boolean attribute (empty string).
1103
+ * - A string sets the attribute value.
1104
+ */
1105
+ declare function setAttr(el: HTMLElement, attrs: Record<string, string | boolean | null>): void;
1106
+ /** Set an element's text content. Safe for user-controlled strings. */
1107
+ declare function setText(el: HTMLElement, text: string): void;
999
1108
  /**
1000
1109
  * Set raw HTML on an element. **No sanitization is performed.**
1001
1110
  *
@@ -1004,15 +1113,37 @@ declare function setText(el: HTMLElement, text: string): void;
1004
1113
  */
1005
1114
  declare function setHTMLUnsafe(el: HTMLElement, html: string): void;
1006
1115
 
1116
+ /** Find the closest ancestor matching a CSS selector. */
1007
1117
  declare function closest<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector: string): T | null;
1118
+ /** Get direct child elements, optionally filtered by a CSS selector. */
1008
1119
  declare function children<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1120
+ /** Get sibling elements (excluding the element itself), optionally filtered. */
1009
1121
  declare function siblings<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T[];
1122
+ /** Get the parent element, or `null` if detached. */
1010
1123
  declare function parent<T extends HTMLElement = HTMLElement>(el: HTMLElement): T | null;
1124
+ /** Find the next sibling element, optionally matching a CSS selector. */
1011
1125
  declare function nextSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1126
+ /** Find the previous sibling element, optionally matching a CSS selector. */
1012
1127
  declare function prevSibling<T extends HTMLElement = HTMLElement>(el: HTMLElement, selector?: string): T | null;
1013
1128
 
1129
+ /**
1130
+ * Observe element size changes via `ResizeObserver`.
1131
+ *
1132
+ * @returns A disconnect function that stops observing.
1133
+ */
1014
1134
  declare function onResize(el: HTMLElement, handler: (entry: ResizeObserverEntry) => void): () => void;
1135
+ /**
1136
+ * Observe element visibility changes via `IntersectionObserver`.
1137
+ *
1138
+ * @returns A disconnect function that stops observing.
1139
+ */
1015
1140
  declare function onIntersect(el: HTMLElement, handler: (entry: IntersectionObserverEntry) => void, options?: IntersectionObserverInit): () => void;
1141
+ /**
1142
+ * Observe DOM mutations (child additions/removals, attribute changes) via
1143
+ * `MutationObserver`. Defaults to `{ childList: true, subtree: true }`.
1144
+ *
1145
+ * @returns A disconnect function that stops observing.
1146
+ */
1016
1147
  declare function onMutation(el: HTMLElement, handler: (mutations: MutationRecord[]) => void, options?: MutationObserverInit): () => void;
1017
1148
 
1018
1149
  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 };
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
- import { hydrateIsland } from './chunk-FJGTMWKY.js';
2
- export { Fragment, cleanup, createList, createShow, fragment, h, hydrateIsland, reconcileList } from './chunk-FJGTMWKY.js';
3
- import { internalEffect, createRoot, untrack, createEffect, pushSuspenseContext, popSuspenseContext, __DEV__, reportError, batch } from './chunk-OUVOAYIO.js';
4
- export { batch, createEffect, createMemo, createReducer, createRef, createResource, createRoot, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, on, onCleanup, onError, trigger, untrack } from './chunk-OUVOAYIO.js';
5
- import { createSignal } from './chunk-OZCHIVAZ.js';
6
- export { createComputed, createSignal } from './chunk-OZCHIVAZ.js';
1
+ import { hydrateIsland } from './chunk-7Q7LIV23.js';
2
+ export { Fragment, cleanup, createList, createShow, fragment, h, hydrateIsland, reconcileList } from './chunk-7Q7LIV23.js';
3
+ import { internalEffect, createRoot, untrack, createEffect, pushSuspenseContext, popSuspenseContext, __DEV__, reportError, batch } from './chunk-TBWZZ3SI.js';
4
+ export { batch, createEffect, createMemo, createReducer, createRef, createResource, createRoot, getBatchDepth, isComputed, isEffect, isEffectScope, isSignal, on, onCleanup, onError, trigger, untrack } from './chunk-TBWZZ3SI.js';
5
+ import { createSignal } from './chunk-HLM5BZZQ.js';
6
+ export { createComputed, createSignal } from './chunk-HLM5BZZQ.js';
7
7
 
8
8
  // src/dom/text.ts
9
9
  function createText(value) {