@but212/atom-effect-jquery 0.31.0 → 0.32.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 (78) hide show
  1. package/README.md +32 -28
  2. package/dist/atom-effect-jquery.min.js +9 -5
  3. package/dist/atom-effect-jquery.min.js.map +1 -1
  4. package/dist/bindings/chainable.d.ts +2 -0
  5. package/dist/bindings/chainable.d.ts.map +1 -0
  6. package/dist/bindings/form.d.ts +33 -0
  7. package/dist/bindings/form.d.ts.map +1 -0
  8. package/dist/bindings/input-binding.d.ts +31 -0
  9. package/dist/bindings/input-binding.d.ts.map +1 -0
  10. package/dist/bindings/list/context.d.ts +82 -0
  11. package/dist/bindings/list/context.d.ts.map +1 -0
  12. package/dist/bindings/list/diff.d.ts +24 -0
  13. package/dist/bindings/list/diff.d.ts.map +1 -0
  14. package/dist/bindings/list/dom.d.ts +50 -0
  15. package/dist/bindings/list/dom.d.ts.map +1 -0
  16. package/dist/bindings/list/index.d.ts +19 -0
  17. package/dist/bindings/list/index.d.ts.map +1 -0
  18. package/dist/bindings/list/types.d.ts +100 -0
  19. package/dist/bindings/list/types.d.ts.map +1 -0
  20. package/dist/bindings/list/utils.d.ts +33 -0
  21. package/dist/bindings/list/utils.d.ts.map +1 -0
  22. package/dist/bindings/mount.d.ts +2 -0
  23. package/dist/bindings/mount.d.ts.map +1 -0
  24. package/dist/bindings/unified.d.ts +135 -0
  25. package/dist/bindings/unified.d.ts.map +1 -0
  26. package/dist/constants.d.ts +108 -0
  27. package/dist/constants.d.ts.map +1 -0
  28. package/dist/core/dom.d.ts +26 -0
  29. package/dist/core/dom.d.ts.map +1 -0
  30. package/dist/core/effect-factory.d.ts +34 -0
  31. package/dist/core/effect-factory.d.ts.map +1 -0
  32. package/dist/core/jquery-patch.d.ts +12 -0
  33. package/dist/core/jquery-patch.d.ts.map +1 -0
  34. package/dist/core/namespace.d.ts +11 -0
  35. package/dist/core/namespace.d.ts.map +1 -0
  36. package/dist/core/navigation.d.ts +172 -0
  37. package/dist/core/navigation.d.ts.map +1 -0
  38. package/dist/core/registry.d.ts +189 -0
  39. package/dist/core/registry.d.ts.map +1 -0
  40. package/dist/core/symbols.d.ts +33 -0
  41. package/dist/core/symbols.d.ts.map +1 -0
  42. package/dist/features/fetch.d.ts +2 -0
  43. package/dist/features/fetch.d.ts.map +1 -0
  44. package/dist/features/nav.d.ts +23 -0
  45. package/dist/features/nav.d.ts.map +1 -0
  46. package/dist/features/route/core.d.ts +83 -0
  47. package/dist/features/route/core.d.ts.map +1 -0
  48. package/dist/features/route/index.d.ts +43 -0
  49. package/dist/features/route/index.d.ts.map +1 -0
  50. package/dist/features/route/router.d.ts +74 -0
  51. package/dist/features/route/router.d.ts.map +1 -0
  52. package/dist/features/route/types.d.ts +60 -0
  53. package/dist/features/route/types.d.ts.map +1 -0
  54. package/dist/features/route/view.d.ts +116 -0
  55. package/dist/features/route/view.d.ts.map +1 -0
  56. package/dist/features/web-component/index.d.ts +33 -0
  57. package/dist/features/web-component/index.d.ts.map +1 -0
  58. package/dist/features/web-component/setup.d.ts +77 -0
  59. package/dist/features/web-component/setup.d.ts.map +1 -0
  60. package/dist/features/web-component/state.d.ts +47 -0
  61. package/dist/features/web-component/state.d.ts.map +1 -0
  62. package/dist/features/web-component/utils.d.ts +13 -0
  63. package/dist/features/web-component/utils.d.ts.map +1 -0
  64. package/dist/index.cjs +9 -5
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.ts +30 -230
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.mjs +4559 -2964
  69. package/dist/index.mjs.map +1 -1
  70. package/dist/types.d.ts +476 -0
  71. package/dist/types.d.ts.map +1 -0
  72. package/dist/utils/debug.d.ts +40 -0
  73. package/dist/utils/debug.d.ts.map +1 -0
  74. package/dist/utils/index.d.ts +61 -0
  75. package/dist/utils/index.d.ts.map +1 -0
  76. package/dist/utils/sanitize.d.ts +52 -0
  77. package/dist/utils/sanitize.d.ts.map +1 -0
  78. package/package.json +10 -8
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=chainable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chainable.d.ts","sourceRoot":"","sources":["../../src/bindings/chainable.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { WritableAtom } from '@but212/atom-effect';
2
+ import { FormOptions } from '../types';
3
+ /**
4
+ * Establishes a two-way reactive binding between a `<form>` and an object atom.
5
+ *
6
+ * When to use:
7
+ * - Recommended for synchronizing standard HTML forms with complex, nested
8
+ * reactive state objects.
9
+ * - Suitable for scenarios requiring declarative validation integrated with
10
+ * browser-native APIs.
11
+ *
12
+ * @param form - The target form element to bind.
13
+ * @param atom - A writable atom or an array of atoms.
14
+ * Logic: Polymorphic Input
15
+ * If an array is provided, it is merged via `mergeLenses`.
16
+ * Note: When merging, later atoms in the array override
17
+ * properties with the same path from earlier atoms.
18
+ * @param options - Configuration for transformations and reactive validation.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const user = $.atom({ profile: { name: 'Alice' }, items: [] });
23
+ *
24
+ * $.bindForm($('form')[0], user, {
25
+ * validation: {
26
+ * 'profile.name': (v) => v ? true : 'Name is required'
27
+ * },
28
+ * onChange: (path, val) => console.log(`${path} changed to ${val}`)
29
+ * });
30
+ * ```
31
+ */
32
+ export declare function bindForm<T extends object>(form: HTMLFormElement, atom: WritableAtom<T> | WritableAtom<unknown>[], options?: FormOptions<unknown>): void;
33
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../src/bindings/form.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAmZ3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,IAAI,EAAE,eAAe,EACrB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EAAE,EAC/C,OAAO,GAAE,WAAW,CAAC,OAAO,CAAM,GACjC,IAAI,CAIN"}
@@ -0,0 +1,31 @@
1
+ import { EffectObject, ValOptions, WritableAtom } from '../types';
2
+ /**
3
+ * Applies a two-way reactive binding to a form input element.
4
+ *
5
+ * This function handles text inputs, textareas, and select menus, ensuring
6
+ * stability during IME composition and maintaining cursor positions during
7
+ * background state updates.
8
+ *
9
+ * When to use:
10
+ * - To synchronize a form control with a `WritableAtom` state.
11
+ * - To implement debounced or custom-formatted input fields.
12
+ *
13
+ * @param $element - The jQuery collection containing the target form element.
14
+ * @param atom - The writable atom to synchronize with.
15
+ * @param options - Configuration for debouncing, event triggers, and data transformation.
16
+ * @returns A handle containing the reactive effect and a cleanup function.
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const name = atom('John');
21
+ * const { cleanup } = applyInputBinding($('#name-input'), name, {
22
+ * debounce: 200,
23
+ * format: (v) => v.toUpperCase()
24
+ * });
25
+ * ```
26
+ */
27
+ export declare function applyInputBinding<T>($element: JQuery, atom: WritableAtom<T>, options: ValOptions<T>): {
28
+ reactiveEffect: EffectObject;
29
+ cleanup: () => void;
30
+ };
31
+ //# sourceMappingURL=input-binding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input-binding.d.ts","sourceRoot":"","sources":["../../src/bindings/input-binding.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AA+QtE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,GACrB;IAAE,cAAc,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAMvD"}
@@ -0,0 +1,82 @@
1
+ import { EffectObject, ListKey } from '../../types';
2
+ /**
3
+ * Represents the state of a single list item at a point in time.
4
+ * Used by the reconciler to calculate moves, updates, and removals.
5
+ */
6
+ export interface ListSnapshot<T> {
7
+ key: ListKey;
8
+ item: T;
9
+ /** The actual DOM element or JQuery wrapper currently representing this item. */
10
+ node?: Element | JQuery | undefined;
11
+ }
12
+ /**
13
+ * Persistent state for the `$.fn.atomList` binding.
14
+ *
15
+ * WHY:
16
+ * Reactive lists require a stable reference to track historical DOM nodes across
17
+ * multiple rendering cycles. Using a POJO (Plain Old JavaScript Object) ensures
18
+ * state is decoupled from logic, following a functional "Relation Function" pattern.
19
+ *
20
+ * @internal
21
+ */
22
+ export interface ListContext<T> {
23
+ /** Sequential snapshot of the previous render state. */
24
+ snapshots: ListSnapshot<T>[];
25
+ /** Keys currently undergoing asynchronous exit animations. */
26
+ readonly removingKeys: Set<ListKey>;
27
+ /** Cached reference to the placeholder element shown when the list is empty. */
28
+ $emptyEl: JQuery | null;
29
+ /** Inverse lookup for O(1) index retrieval from a key. */
30
+ keyToIndex: Map<ListKey, number>;
31
+ /** The reactive effect controlling this list. Needed to check disposal state during async tasks. */
32
+ fx?: EffectObject;
33
+ /** Target container element. */
34
+ readonly $container: JQuery;
35
+ /** Selector for the container. */
36
+ readonly containerSelector: string;
37
+ /** Optional removal lifecycle hook. */
38
+ readonly onRemove: (($el: JQuery) => Promise<void> | void) | undefined;
39
+ }
40
+ /**
41
+ * Factory to initialize a new ListContext.
42
+ */
43
+ export declare function createListContext<T>($container: JQuery, containerSelector: string, onRemove: (($el: JQuery) => Promise<void> | void) | undefined): ListContext<T>;
44
+ /**
45
+ * Retrieves the index of a key, handling string-to-number normalization.
46
+ *
47
+ * WHY: DOM `data-atom-key` attributes are always strings. If the original
48
+ * atom keys were numbers, a direct Map lookup will fail.
49
+ *
50
+ * @internal
51
+ */
52
+ export declare function getListIndex<T>(ctx: ListContext<T>, key: ListKey | string): number | undefined;
53
+ /**
54
+ * Marks a key as "in transit" and starts the removal lifecycle.
55
+ * @internal
56
+ */
57
+ export declare function removeListItem<T>(ctx: ListContext<T>, k: ListKey, $el: JQuery): void;
58
+ /**
59
+ * Initiates the physical removal of an element.
60
+ *
61
+ * PERFORMANCE: Allocation-free path for synchronous removals.
62
+ * Closures are only created if `onRemove` returns a Promise.
63
+ * @internal
64
+ */
65
+ export declare function scheduleListItemRemoval<T>(ctx: ListContext<T>, k: ListKey, $el: JQuery): void;
66
+ /**
67
+ * Finalizes DOM removal and state cleanup.
68
+ *
69
+ * GUARD: If an element is "resurrected" (reused for a new key) during the
70
+ * asynchronous removal delay, this method aborts to prevent accidental destruction.
71
+ * @internal
72
+ */
73
+ export declare function commitListItemRemoval<T>(ctx: ListContext<T>, k: ListKey, $el: JQuery): void;
74
+ /**
75
+ * Full cleanup of state and DOM references.
76
+ *
77
+ * GC: Reuses the `snapshots` array instance (length = 0) to reduce
78
+ * memory fragmentation on high-frequency list swaps.
79
+ * @internal
80
+ */
81
+ export declare function disposeListContext<T>(ctx: ListContext<T>): void;
82
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/bindings/list/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAGrD;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC;IAC7B,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,CAAC,CAAC;IACR,iFAAiF;IACjF,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACrC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,wDAAwD;IACxD,SAAS,EAAE,YAAY,CAAC,C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,GAAG,EAAE,MAAM,GAAG,IAAI,CAS7F;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAY3F;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAM/D"}
@@ -0,0 +1,24 @@
1
+ import { ListKeyFn, ListOptions } from '../../types';
2
+ import { ListContext } from './context';
3
+ import { PreparedDiff } from './types';
4
+ /**
5
+ * Generates a reconciliation plan between the previous and next state of a list.
6
+ *
7
+ * When to use:
8
+ * - Internal orchestration of DOM mutations for the `atomList` binding.
9
+ *
10
+ * Performance:
11
+ * - O(N) time complexity.
12
+ * - Best case: O(1) for pure appends/prepends via head/tail fast-forwarding.
13
+ *
14
+ * @param ctx - Persistent state containing historical DOM and keys.
15
+ * @param items - The new data array from the source atom.
16
+ *
17
+ * @example
18
+ * const diff = buildIndices(ctx, nextItems, nextItems.length, getKey, update, isEqual);
19
+ * // diff.slots now contains the mapping instructions for each index.
20
+ *
21
+ * @internal
22
+ */
23
+ export declare function buildIndices<T>(ctx: ListContext<T>, items: T[], itemCount: number, getKey: ListKeyFn<T>, update: ListOptions<T>['update'], isEqual: ListOptions<T>['isEqual']): PreparedDiff<T>;
24
+ //# sourceMappingURL=diff.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.ts","sourceRoot":"","sources":["../../../src/bindings/list/diff.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAW,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAA4B,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAEtE;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,EACpB,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAChC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GACjC,YAAY,CAAC,CAAC,CAAC,CAyHjB"}
@@ -0,0 +1,50 @@
1
+ import { ListOptions } from '../../types';
2
+ import { ListContext } from './context';
3
+ import { PlaceCallbacks, PreparedDiff } from './types';
4
+ /**
5
+ * Inserts elements before a reference node with zero-allocation for jQuery collections.
6
+ *
7
+ * Why:
8
+ * - Directly iterates over JQuery objects to avoid `.get()` or `Array.from()` array allocations.
9
+ * - Handles polymorphic inputs (Element | JQuery) to keep the caller's logic simple.
10
+ */
11
+ export declare function insertOrAppend(elOrJq: Element | JQuery | undefined, nextNode: Node | null, container: Element): void;
12
+ /**
13
+ * Resets the container or renders an empty placeholder.
14
+ *
15
+ * Why:
16
+ * - Decouples destructive cleanup (`.empty()`) from animated cleanup (`removeItem`).
17
+ * - Ensures the historical context is cleared only after the DOM reflects the empty state.
18
+ */
19
+ export declare function handleEmpty<T>(ctx: ListContext<T>, itemCount: number, $container: JQuery, empty: ListOptions<T>['empty']): void;
20
+ /**
21
+ * Transforms items into DOM nodes or sanitized HTML strings.
22
+ *
23
+ * Performance:
24
+ * - Provides a "Cold Start" optimization: returns raw HTML strings for initial render
25
+ * to allow direct `innerHTML` injection, bypassing jQuery construction overhead.
26
+ *
27
+ * Why:
28
+ * - String parsing is batched (`batchSanitize`) to reduce sanitization engine overhead.
29
+ */
30
+ export declare function renderItems<T>(diff: PreparedDiff<T>, options: ListOptions<T>, isInitial: boolean): string[] | null;
31
+ /**
32
+ * Triggers removal lifecycle for items missing in the new data set.
33
+ *
34
+ * When to use:
35
+ * - Called during the diffing phase before new items are placed.
36
+ */
37
+ export declare function cleanupRemoved<T>(ctx: ListContext<T>): void;
38
+ /**
39
+ * Positions items in the DOM and executes lifecycle callbacks.
40
+ *
41
+ * Logic:
42
+ * 1. Initial Render: Replaces entire innerHTML or appends via DocumentFragment.
43
+ * 2. Reconciliation: Moves existing nodes or inserts new ones based on the diff plan.
44
+ *
45
+ * Performance:
46
+ * - Uses a reverse loop for reconciliation to maintain DOM order with minimal moves.
47
+ * - Uses `switch` instead of a handler Map to avoid object allocation in the hot loop.
48
+ */
49
+ export declare function placeItems<T>(ctx: ListContext<T>, diff: PreparedDiff<T>, container: Element, callbacks: PlaceCallbacks<T>, htmlFragments: string[] | null): void;
50
+ //# sourceMappingURL=dom.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../../src/bindings/list/dom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAG3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C,OAAO,EAAa,KAAK,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5E;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,EACpC,QAAQ,EAAE,IAAI,GAAG,IAAI,EACrB,SAAS,EAAE,OAAO,GACjB,IAAI,CAYN;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAC7B,IAAI,CA8BN;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,EACvB,SAAS,EAAE,OAAO,GACjB,MAAM,EAAE,GAAG,IAAI,CAuEjB;AAcD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAQ3D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAC1B,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC,EAC5B,aAAa,EAAE,MAAM,EAAE,GAAG,IAAI,GAC7B,IAAI,CA0GN"}
@@ -0,0 +1,19 @@
1
+ import { EffectObject, ListOptions, ReadonlyAtom } from '../../types';
2
+ import { ListContext } from './context';
3
+ /**
4
+ * Internal engine for list reconciliation.
5
+ *
6
+ * When to use:
7
+ * - Coordinates the full lifecycle: Empty state -> Diffing -> Rendering -> DOM placement.
8
+ *
9
+ * Boundary:
10
+ * - Uses `untracked` to ensure DOM mutations don't accidentally trigger parent effects.
11
+ * - Relies on `ListContext` for state persistence across render cycles.
12
+ *
13
+ * @internal
14
+ */
15
+ export declare function applyListBinding<T>(element: HTMLElement, source: ReadonlyAtom<T[]>, options: ListOptions<T>): {
16
+ fx: EffectObject;
17
+ ctx: ListContext<T>;
18
+ };
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/bindings/list/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAsB,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE3F,OAAO,EAAuD,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAalG;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,EACzB,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC,GACtB;IAAE,EAAE,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAA;CAAE,CAiD3C"}
@@ -0,0 +1,100 @@
1
+ import { ListKey, ListKeyFn, ListOptions } from '../../types';
2
+ export type { ListKey, ListKeyFn };
3
+ /**
4
+ * Enumeration of lifecycle flags representing the reconciliation status of a list item.
5
+ *
6
+ * These flags are used by the internal DOM synchronizer to determine the minimum
7
+ * required action (skipping, patching, or re-rendering) for each element.
8
+ *
9
+ * When to use:
10
+ * - Internal orchestration of DOM updates within the `atomList` binding engine.
11
+ *
12
+ * @internal
13
+ */
14
+ export declare const ItemState: {
15
+ /**
16
+ * Logic: The item's key and data are identical to the previous state.
17
+ * Optimization: No DOM manipulation is required; this is the fastest execution path.
18
+ */
19
+ readonly Unchanged: 0;
20
+ /**
21
+ * Logic: The key has been identified in the previous state, but its position
22
+ * or data may require a patch or an update callback execution.
23
+ */
24
+ readonly Existing: number;
25
+ /**
26
+ * Logic: The item's key was not found in the previous state.
27
+ * Action: A fresh DOM node must be created and inserted.
28
+ */
29
+ readonly New: number;
30
+ /**
31
+ * Logic: The key matched, but the item's data has changed and no custom
32
+ * `update` callback was provided by the user.
33
+ * Action: Requires a full destruction of the existing node followed by a
34
+ * re-creation to ensure the DOM accurately reflects the new data.
35
+ */
36
+ readonly ForceReplace: number;
37
+ };
38
+ export type ItemState = (typeof ItemState)[keyof typeof ItemState];
39
+ /**
40
+ * Represents a single item's reconciliation state and metadata.
41
+ *
42
+ * @internal
43
+ */
44
+ export interface DiffSlot<T> {
45
+ /** The unique key for the item. */
46
+ key: ListKey;
47
+ /** The current data item. */
48
+ item: T;
49
+ /** The assigned reconciliation state. */
50
+ state: ItemState;
51
+ /** The index in the previous state, or -1 if new. */
52
+ oldIndex: number;
53
+ /** The index in the new state. */
54
+ targetIndex: number;
55
+ /** The current DOM handle. */
56
+ node: Element | JQuery | undefined;
57
+ }
58
+ /**
59
+ * A reconciliation plan generated by the diffing algorithm.
60
+ *
61
+ * Logic: This interface provides a unified table of item slots and metadata
62
+ * required by the DOM synchronizer to perform atomic mutations.
63
+ *
64
+ * @internal
65
+ */
66
+ export interface PreparedDiff<T> {
67
+ /** The unified collection of item slots. */
68
+ slots: DiffSlot<T>[];
69
+ /**
70
+ * A collection of slots that require new DOM construction or HTML parsing.
71
+ */
72
+ toRender: DiffSlot<T>[];
73
+ }
74
+ /**
75
+ * A collection of user-provided lifecycle hooks and event configurations.
76
+ *
77
+ * @internal
78
+ */
79
+ export interface PlaceCallbacks<T> {
80
+ /** Invoked once when an element is first bound to a reactive item. */
81
+ bind?: (($el: JQuery, item: T, index: number) => void) | undefined;
82
+ /** Invoked on subsequent updates when item data changes. */
83
+ update?: (($el: JQuery, item: T, index: number) => void) | undefined;
84
+ /** Invoked when a new item is physically added to the DOM. */
85
+ onAdd?: (($el: JQuery) => void) | undefined;
86
+ /** Invoked to manage the removal of an item, supporting asynchronous transitions. */
87
+ onRemove?: ListOptions<T>['onRemove'] | undefined;
88
+ /** Delegated event listeners for the list container. */
89
+ events?: ListOptions<T>['events'] | undefined;
90
+ }
91
+ /**
92
+ * Normalization table for delegated event listeners.
93
+ * @internal
94
+ */
95
+ export interface EventBinding {
96
+ type: string;
97
+ selector: string;
98
+ callback: Function;
99
+ }
100
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/bindings/list/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE/D,YAAY,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS;IACpB;;;OAGG;;IAG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,UAAU,CAAC,GAAG,SAAS,CAAC;IAClD,wDAAwD;IACxD,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;CAC/C;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;CACpB"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Normalizes a raw DOM element or a jQuery collection into a standard jQuery object.
3
+ *
4
+ * Logic: Polymorphic Input
5
+ * Supports both raw Element for single operations and JQuery collections for bulk
6
+ * processing, ensuring consistent API behavior.
7
+ *
8
+ * @internal
9
+ */
10
+ export declare function wrap($el: Element | JQuery<Element>): JQuery;
11
+ /**
12
+ * Assigns or removes a stable reactive identifier on a DOM node or collection.
13
+ *
14
+ * @param node - The target DOM element or collection.
15
+ * @param key - Unique string key for identification, or null to remove.
16
+ * @internal
17
+ */
18
+ export declare function setAtomKey(node: Element | Node | JQuery, key: string | null): void;
19
+ /**
20
+ * Performs a deep recursive cleanup of reactive resources associated with a DOM tree.
21
+ *
22
+ * Constraint: Teardown Order
23
+ * Must be executed before an element is permanently detached or replaced.
24
+ *
25
+ * Caution: Memory Leak
26
+ * Failure to call this results in "zombie" reactive effects remaining in the
27
+ * global registry, leading to significant memory growth over time.
28
+ *
29
+ * @param node - The root element or collection to purge from the registry.
30
+ * @internal
31
+ */
32
+ export declare function cleanupNodes(node: Element | JQuery): void;
33
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/bindings/list/utils.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAG3D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAgClF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAczD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../../src/bindings/mount.ts"],"names":[],"mappings":""}
@@ -0,0 +1,135 @@
1
+ import { AsyncReactiveValue, BindingOptions, CssValue, PrimitiveValue, ValOptions, WritableAtom } from '../types';
2
+ /**
3
+ * Binds the text content of an element to a reactive source.
4
+ *
5
+ * When to use:
6
+ * - To synchronize labels or counts with an atom without the risk of XSS.
7
+ *
8
+ * @param element - The target HTMLElement.
9
+ * @param value - The reactive source atom or computed.
10
+ * @param formatter - An optional function to format the value before display.
11
+ * @internal
12
+ */
13
+ export declare function bindText<T = unknown>(element: HTMLElement, value: AsyncReactiveValue<T>, formatter?: (value: T) => string): void;
14
+ /**
15
+ * Binds the HTML content of an element to a reactive source.
16
+ *
17
+ * Logic: To prevent memory leaks from detached nodes, all reactive bindings
18
+ * within the element's descendants are automatically cleaned up via the
19
+ * registry before the `innerHTML` is overwritten.
20
+ *
21
+ * Caution: Even with sanitization, rendering user-provided HTML remains a
22
+ * security risk. Prefer `bindText` whenever possible.
23
+ *
24
+ * When to use:
25
+ * - To render trusted templates or rich text containing formatting tags.
26
+ *
27
+ * @param element - The target HTMLElement.
28
+ * @param value - The reactive source containing the HTML string.
29
+ * @internal
30
+ */
31
+ export declare function bindHtml(element: HTMLElement, value: AsyncReactiveValue<string>): void;
32
+ /**
33
+ * Binds a set of CSS classes to reactive conditions.
34
+ *
35
+ * Logic: Token Management
36
+ * - Supports space-separated class names within keys.
37
+ * - Active tokens are tracked in a `Set` to ensure classes are only removed
38
+ * if no other active definition within the map requires them.
39
+ *
40
+ * @param element - The target HTMLElement.
41
+ * @param classMap - A record mapping class names to reactive boolean conditions.
42
+ * @internal
43
+ */
44
+ export declare function bindClass(element: HTMLElement, classMap: Record<string, AsyncReactiveValue<boolean>>): void;
45
+ /**
46
+ * Binds inline CSS styles to reactive sources.
47
+ *
48
+ * Security: Dangerous CSS values (e.g., `url()` containing javascript: protocols)
49
+ * are blocked to prevent XSS and style-based injection attacks.
50
+ *
51
+ * @param element - The target HTMLElement.
52
+ * @param cssMap - A record mapping style properties to reactive values.
53
+ * @internal
54
+ */
55
+ export declare function bindCss(element: HTMLElement, cssMap: Record<string, CssValue>): void;
56
+ /**
57
+ * Binds HTML attributes to reactive sources.
58
+ *
59
+ * Logic: Attribute Transformation Pipeline
60
+ * Implements a unified transformation flow for different attribute categories:
61
+ * - Boolean Attributes: Automatically removed when the condition is `false`.
62
+ * - ARIA Attributes: Boolean values are mapped to 'true'/'false' strings.
63
+ * - Standard Attributes: Values are coerced to strings.
64
+ *
65
+ * Security: Protocol Validation
66
+ * Validates 'href' and 'src' attributes against dangerous URL protocols to
67
+ * mitigate potential XSS vectors.
68
+ *
69
+ * @param element - The target HTMLElement.
70
+ * @param attrMap - A record mapping attribute names to reactive values.
71
+ * @internal
72
+ */
73
+ export declare function bindAttr(element: HTMLElement, attrMap: Record<string, AsyncReactiveValue<PrimitiveValue>>): void;
74
+ /**
75
+ * Binds DOM properties directly to reactive sources.
76
+ *
77
+ * Security: Blocks sensitive properties (e.g., `innerHTML`, event handlers)
78
+ * and validates URL-based properties to prevent prototype pollution or XSS.
79
+ *
80
+ * @param element - The target HTMLElement.
81
+ * @param propMap - A record mapping property names to reactive values.
82
+ * @internal
83
+ */
84
+ export declare function bindProp(element: HTMLElement, propMap: Record<string, AsyncReactiveValue<unknown>>): void;
85
+ /**
86
+ * Manages element visibility based on a reactive condition.
87
+ *
88
+ * Logic: Layout Preservation
89
+ * Transitions between 'visible' and 'hidden' states while preserving the
90
+ * element's original 'display' mode (e.g., flex, grid) when restored.
91
+ *
92
+ * @param element - The target HTMLElement.
93
+ * @param condition - The reactive boolean condition governing visibility.
94
+ * @param invert - If true, hides the element when the condition is met.
95
+ * @internal
96
+ */
97
+ export declare function bindVisibility(element: HTMLElement, condition: AsyncReactiveValue<boolean>, invert: boolean): void;
98
+ /**
99
+ * Binds a form control's value to a writable atom.
100
+ *
101
+ * When to use:
102
+ * - To implement two-way synchronization for inputs, selects, and textareas.
103
+ *
104
+ * @param element - The form control element.
105
+ * @param atom - The writable atom to synchronize with.
106
+ * @param options - Configuration for debouncing and transformation.
107
+ * @internal
108
+ */
109
+ export declare function bindVal(element: HTMLElement, atom: WritableAtom<unknown>, options?: ValOptions<unknown>): void;
110
+ /**
111
+ * Binds a checkbox or radio button's checked state to a writable atom.
112
+ *
113
+ * @param element - The target input element.
114
+ * @param atom - The writable atom to synchronize with the checked state.
115
+ * @internal
116
+ */
117
+ export declare function bindChecked(element: HTMLElement, atom: WritableAtom<boolean>): void;
118
+ /**
119
+ * Binds a mapping of event listeners to an element.
120
+ *
121
+ * @param element - The target HTMLElement.
122
+ * @param eventMap - A record mapping event names to handler functions.
123
+ * @internal
124
+ */
125
+ export declare function bindEvents(element: HTMLElement, eventMap: NonNullable<BindingOptions['on']>): void;
126
+ /**
127
+ * Binds a single event listener to an element.
128
+ *
129
+ * @param element - The target HTMLElement.
130
+ * @param event - The name of the event.
131
+ * @param handler - The handler function to execute.
132
+ * @internal
133
+ */
134
+ export declare function bindOn(element: HTMLElement, event: string, handler: (event: JQuery.TriggeredEvent) => void): void;
135
+ //# sourceMappingURL=unified.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/bindings/unified.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,cAAc,EAEd,UAAU,EACV,YAAY,EACb,MAAM,SAAS,CAAC;AAqCjB;;;;;;;;;;GAUG;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