@but212/atom-effect-jquery 0.30.1 → 0.32.0

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 -10
  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 +29 -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 +61 -0
  11. package/dist/bindings/list/context.d.ts.map +1 -0
  12. package/dist/bindings/list/diff.d.ts +32 -0
  13. package/dist/bindings/list/diff.d.ts.map +1 -0
  14. package/dist/bindings/list/dom.d.ts +63 -0
  15. package/dist/bindings/list/dom.d.ts.map +1 -0
  16. package/dist/bindings/list/index.d.ts +2 -0
  17. package/dist/bindings/list/index.d.ts.map +1 -0
  18. package/dist/bindings/list/types.d.ts +93 -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 -10
  65. package/dist/index.cjs.map +1 -1
  66. package/dist/index.d.ts +30 -232
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.mjs +3129 -2726
  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 +51 -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 +11 -7
package/dist/index.d.ts CHANGED
@@ -1,232 +1,30 @@
1
- import { ComputedAtom } from '@but212/atom-effect';
2
- import { default as default_2 } from 'jquery';
3
- import { EffectObject } from '@but212/atom-effect';
4
- import { ReadonlyAtom } from '@but212/atom-effect';
5
- import { WritableAtom } from '@but212/atom-effect';
6
-
7
- /**
8
- * An extension of ReactiveValue that also supports Promises and async functions.
9
- * The binding system automatically handles the promise lifecycle, showing the
10
- * latest resolved value and ignoring stale ones (race condition protection).
11
- */
12
- declare type AsyncReactiveValue<T> = T | ReadonlyAtom<T | Promise<T>> | Promise<T> | (() => T | Promise<T>);
13
-
14
- export declare interface BindingOptions<T = unknown> {
15
- text?: AsyncReactiveValue<unknown> | [source: AsyncReactiveValue<unknown>, formatter: (v: unknown) => string];
16
- html?: AsyncReactiveValue<string>;
17
- class?: Record<string, AsyncReactiveValue<boolean>>;
18
- css?: CssBindings;
19
- attr?: Record<string, AsyncReactiveValue<PrimitiveValue>>;
20
- prop?: Record<string, AsyncReactiveValue<unknown>>;
21
- show?: AsyncReactiveValue<boolean>;
22
- hide?: AsyncReactiveValue<boolean>;
23
- val?: WritableAtom<T> | [atom: WritableAtom<T>, options: ValOptions<T>];
24
- checked?: WritableAtom<boolean>;
25
- form?: WritableAtom<T extends object ? T : unknown> | [
26
- atom: WritableAtom<T extends object ? T : unknown>,
27
- options: FormOptions<T extends object ? T : unknown>
28
- ];
29
- on?: Record<string, (e: JQuery.Event) => void>;
30
- }
31
-
32
- /**
33
- * Central registry mapping DOM elements to their reactive binding records.
34
- *
35
- * Design goals:
36
- * - Zero memory leaks: all collections use WeakMap/WeakSet keyed by Element.
37
- * - Minimal allocations in the hot tracking path.
38
- * - O(bound-descendants) cleanup via a single querySelectorAll pass.
39
- */
40
- declare class BindingRegistry {
41
- private records;
42
- private preservedNodes;
43
- private ignoredNodes;
44
- keep(node: Node): void;
45
- isKept(node: Node): boolean;
46
- markIgnored(node: Node): void;
47
- isIgnored(node: Node): boolean;
48
- private getOrCreateRecord;
49
- /**
50
- * Registers a reactive effect with an element's record.
51
- * Effects are automatically disposed when the element is removed from the DOM.
52
- *
53
- * @param el - The DOM element to bind the effect to.
54
- * @param fx - The reactive effect instance.
55
- */
56
- trackEffect(el: Element, fx: EffectObject): void;
57
- /**
58
- * Registers an arbitrary cleanup function with an element's record.
59
- * Cleanups are executed when the element is removed from the DOM.
60
- *
61
- * @param el - The DOM element to bind the cleanup to.
62
- * @param fn - The cleanup function (e.g., event unbinding, timer clear).
63
- */
64
- trackCleanup(el: Element, fn: () => void): void;
65
- /**
66
- * Assigns a component-level cleanup function (e.g., from atomMount).
67
- * Unlike generic cleanups, there can only be one component cleanup per element.
68
- */
69
- setComponentCleanup(el: Element, fn: (() => void) | undefined): void;
70
- hasBind(el: Element): boolean;
71
- cleanup(el: Node): void;
72
- cleanupDescendants(el: Element | DocumentFragment | ShadowRoot): void;
73
- cleanupTree(el: Node): void;
74
- }
75
-
76
- export declare type ComponentFn<P = Record<string, unknown>> = ($el: JQuery, props: P) => EffectResult;
77
-
78
- export { ComputedAtom }
79
-
80
- export declare type CssBindings = Record<string, CssValue>;
81
-
82
- export declare type CssValue = AsyncReactiveValue<string | number> | [source: AsyncReactiveValue<number>, unit: string];
83
-
84
- export default default_2;
85
-
86
- /**
87
- * Stops all MutationObservers started by `enableAutoCleanup`.
88
- */
89
- export declare function disableAutoCleanup(): void;
90
-
91
- /**
92
- * Restores all jQuery methods patched by `enablejQueryOverrides()`.
93
- * Primarily useful in test environments to reset state between suites.
94
- */
95
- export declare function disablejQueryOverrides(): void;
96
-
97
- export declare type EffectCleanup = () => void;
98
-
99
- export declare type EffectResult = undefined | EffectCleanup;
100
-
101
- /**
102
- * Starts observing `root` for removed elements and automatically disposes
103
- * their reactive bindings when they leave the DOM.
104
- *
105
- * Supports Element, ShadowRoot, and DocumentFragment roots.
106
- * Multiple roots can be observed concurrently (e.g. for Micro-Frontends).
107
- */
108
- export declare function enableAutoCleanup(root: Element | ShadowRoot | DocumentFragment): void;
109
-
110
- export declare function enablejQueryOverrides(): void;
111
-
112
- export declare type EqualFn<T> = (a: T, b: T) => boolean;
113
-
114
- export declare interface FetchOptions<T> {
115
- defaultValue: T;
116
- method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | (string & {});
117
- headers?: Record<string, string>;
118
- transform?: (raw: unknown) => T;
119
- ajaxOptions?: JQuery.AjaxSettings | (() => JQuery.AjaxSettings);
120
- onError?: (err: unknown) => void;
121
- eager?: boolean;
122
- }
123
-
124
- /**
125
- * Options for `atomForm` binding.
126
- */
127
- declare interface FormOptions<T> extends ValOptions<T> {
128
- /** Custom function to transform field value based on path before atomic sync. */
129
- transform?: (path: string, value: unknown) => unknown;
130
- /** Callback triggered when a field value changes. */
131
- onChange?: (path: string, value: unknown) => void;
132
- }
133
-
134
- /** Checks if a given value is a reactive node (Atom or Computed). */
135
- export declare const isReactive: (v: unknown) => v is ReadonlyAtom<unknown>;
136
-
137
- declare type KeysOfType<T, V> = {
138
- [K in keyof T]: T[K] extends V ? K : never;
139
- }[keyof T];
140
-
141
- declare type ListKey = string | number;
142
-
143
- declare type ListKeyFn<T> = (item: T, index: number) => ListKey;
144
-
145
- export declare interface ListOptions<T> {
146
- key: KeysOfType<T, ListKey> | ListKeyFn<T>;
147
- render: (item: T, index: number) => ListRenderResult;
148
- bind?: ($el: JQuery, item: T, index: number) => void;
149
- update?: ($el: JQuery, item: T, index: number) => void;
150
- onAdd?: ($el: JQuery) => void;
151
- onRemove?: ($el: JQuery) => Promise<void> | void;
152
- empty?: ListRenderResult;
153
- events?: Record<string, (item: T, index: number, e: JQuery.TriggeredEvent) => void>;
154
- isEqual?: (a: T, b: T) => boolean;
155
- }
156
-
157
- declare type ListRenderResult = string | Element | DocumentFragment | JQuery;
158
-
159
- /** Resolves after microtask effects flush. Fast Promise-based scheduling. */
160
- export declare const nextTick: () => Promise<void>;
161
-
162
- export declare type PrimitiveValue = string | number | boolean | null | undefined;
163
-
164
- /**
165
- * Represents a value that can be tracked by the reactive system.
166
- * - T: Static value (one-time bind)
167
- * - ReadonlyAtom<T>: Reactive value (updates DOM when atom changes)
168
- * - () => T: Reactive function (updates DOM when any atom read inside changes)
169
- */
170
- export declare type ReactiveValue<T> = T | ReadonlyAtom<T> | (() => T);
171
-
172
- export { ReadonlyAtom }
173
-
174
- export declare const registry: BindingRegistry;
175
-
176
- export declare interface RenderRoute extends RouteLifecycle {
177
- render: (container: HTMLElement, route: string, params: Record<string, string>, onUnmount: (cleanupFn: () => void) => void, router: Router) => void;
178
- template?: never;
179
- }
180
-
181
- export declare interface RouteConfig {
182
- target: string;
183
- default: string;
184
- routes: Record<string, RouteDefinition>;
185
- mode?: 'hash' | 'history';
186
- basePath?: string;
187
- notFound?: string;
188
- autoBindLinks?: boolean;
189
- activeClass?: string;
190
- beforeTransition?: (from: string, to: string) => void;
191
- afterTransition?: (from: string, to: string) => void;
192
- }
193
-
194
- export declare type RouteDefinition = TemplateRoute | RenderRoute;
195
-
196
- export declare interface RouteLifecycle {
197
- onEnter?: (params: Record<string, string>, router: Router) => Record<string, string> | undefined;
198
- onLeave?: (router: Router) => boolean | undefined;
199
- }
200
-
201
- export declare interface Router {
202
- currentRoute: ReadonlyAtom<string>;
203
- queryParams: ReadonlyAtom<Record<string, string>>;
204
- navigate: (route: string) => void;
205
- destroy: () => void;
206
- }
207
-
208
- export declare interface TemplateRoute extends RouteLifecycle {
209
- template: string;
210
- render?: never;
211
- onMount?: ($content: JQuery, onUnmount: (cleanupFn: () => void) => void, router: Router) => void;
212
- }
213
-
214
- /**
215
- * Options for `atomVal`, `atomChecked`, and `atomForm` bindings.
216
- */
217
- export declare interface ValOptions<T> {
218
- /** Debounce duration in milliseconds for DOM -> Atom sync. Defaults to 0. */
219
- debounce?: number;
220
- /** jQuery event name(s) to listen to. Defaults to "input". */
221
- event?: string;
222
- /** Custom function to parse DOM string to atom type T. */
223
- parse?: (v: string) => T;
224
- /** Custom function to format atom type T to DOM string. */
225
- format?: (v: T) => string;
226
- /** Custom equality check to prevent redundant atom updates. */
227
- equal?: EqualFn<T>;
228
- }
229
-
230
- export { WritableAtom }
231
-
232
- export { }
1
+ import { default as $ } from 'jquery';
2
+ import { AEJConfig } from './types';
3
+ /**
4
+ * Initializes Atom-Effect jQuery with the specified configuration.
5
+ *
6
+ * This function resets the library's state according to the provided config.
7
+ * It is safe to call multiple times to reconfigure features at runtime.
8
+ *
9
+ * @param config - Configuration options.
10
+ *
11
+ * @warning If both `patch` and `autoCleanup` are set to `false`, you are
12
+ * responsible for calling `cleanup(element)` manually when
13
+ * elements are removed to prevent memory leaks.
14
+ */
15
+ export declare function initAEJ(config?: AEJConfig): void;
16
+ export { disablejQueryOverrides, enablejQueryOverrides } from './core/jquery-patch';
17
+ export { disableAutoCleanup, enableAutoCleanup } from './core/registry';
18
+ /**
19
+ * Performs a deep recursive cleanup on a node and its entire Shadow DOM subtrees.
20
+ *
21
+ * When to use:
22
+ * - Manually cleaning up an element that was removed from the DOM if autoCleanup is disabled.
23
+ * - Forcing a cleanup cycle on a specific container.
24
+ *
25
+ * @param element - The element to clean up.
26
+ */
27
+ export declare function cleanup(element: HTMLElement | JQuery): void;
28
+ export type { AtomComponentController, AtomNav, AtomNavOptions, BindingOptions, ComponentFn, ComputedAtom, CssBindings, CssValue, EffectCleanup, EffectResult, EqualFn, FetchError, FetchOptions, JQueryScopedSelector, ListOptions, PrimitiveValue, ReactiveValue, ReadonlyAtom, RouteConfig, RouteDefinition, RouteLifecycle, Router, ValOptions, WritableAtom, } from './types';
29
+ export default $;
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAEvB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,sBAAsB,CAAC;AAC9B,OAAO,iBAAiB,CAAC;AACzB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,kBAAkB,CAAC;AAC1B,OAAO,gBAAgB,CAAC;AACxB,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAQzC;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,MAAM,GAAE,SAAc,GAAG,IAAI,CAsBpD;AASD,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAM3D;AAID,YAAY,EACV,uBAAuB,EACvB,OAAO,EACP,cAAc,EACd,cAAc,EACd,WAAW,EACX,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,OAAO,EACP,UAAU,EACV,YAAY,EACZ,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,aAAa,EACb,YAAY,EACZ,WAAW,EACX,eAAe,EACf,cAAc,EACd,MAAM,EACN,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AAEjB,eAAe,CAAC,CAAC"}