@but212/atom-effect-jquery 0.31.0 → 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.
- package/README.md +32 -28
- package/dist/atom-effect-jquery.min.js +9 -5
- package/dist/atom-effect-jquery.min.js.map +1 -1
- package/dist/bindings/chainable.d.ts +2 -0
- package/dist/bindings/chainable.d.ts.map +1 -0
- package/dist/bindings/form.d.ts +29 -0
- package/dist/bindings/form.d.ts.map +1 -0
- package/dist/bindings/input-binding.d.ts +31 -0
- package/dist/bindings/input-binding.d.ts.map +1 -0
- package/dist/bindings/list/context.d.ts +61 -0
- package/dist/bindings/list/context.d.ts.map +1 -0
- package/dist/bindings/list/diff.d.ts +32 -0
- package/dist/bindings/list/diff.d.ts.map +1 -0
- package/dist/bindings/list/dom.d.ts +63 -0
- package/dist/bindings/list/dom.d.ts.map +1 -0
- package/dist/bindings/list/index.d.ts +2 -0
- package/dist/bindings/list/index.d.ts.map +1 -0
- package/dist/bindings/list/types.d.ts +93 -0
- package/dist/bindings/list/types.d.ts.map +1 -0
- package/dist/bindings/list/utils.d.ts +33 -0
- package/dist/bindings/list/utils.d.ts.map +1 -0
- package/dist/bindings/mount.d.ts +2 -0
- package/dist/bindings/mount.d.ts.map +1 -0
- package/dist/bindings/unified.d.ts +135 -0
- package/dist/bindings/unified.d.ts.map +1 -0
- package/dist/constants.d.ts +108 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/core/dom.d.ts +26 -0
- package/dist/core/dom.d.ts.map +1 -0
- package/dist/core/effect-factory.d.ts +34 -0
- package/dist/core/effect-factory.d.ts.map +1 -0
- package/dist/core/jquery-patch.d.ts +12 -0
- package/dist/core/jquery-patch.d.ts.map +1 -0
- package/dist/core/namespace.d.ts +11 -0
- package/dist/core/namespace.d.ts.map +1 -0
- package/dist/core/navigation.d.ts +172 -0
- package/dist/core/navigation.d.ts.map +1 -0
- package/dist/core/registry.d.ts +189 -0
- package/dist/core/registry.d.ts.map +1 -0
- package/dist/core/symbols.d.ts +33 -0
- package/dist/core/symbols.d.ts.map +1 -0
- package/dist/features/fetch.d.ts +2 -0
- package/dist/features/fetch.d.ts.map +1 -0
- package/dist/features/nav.d.ts +23 -0
- package/dist/features/nav.d.ts.map +1 -0
- package/dist/features/route/core.d.ts +83 -0
- package/dist/features/route/core.d.ts.map +1 -0
- package/dist/features/route/index.d.ts +43 -0
- package/dist/features/route/index.d.ts.map +1 -0
- package/dist/features/route/router.d.ts +74 -0
- package/dist/features/route/router.d.ts.map +1 -0
- package/dist/features/route/types.d.ts +60 -0
- package/dist/features/route/types.d.ts.map +1 -0
- package/dist/features/route/view.d.ts +116 -0
- package/dist/features/route/view.d.ts.map +1 -0
- package/dist/features/web-component/index.d.ts +33 -0
- package/dist/features/web-component/index.d.ts.map +1 -0
- package/dist/features/web-component/setup.d.ts +77 -0
- package/dist/features/web-component/setup.d.ts.map +1 -0
- package/dist/features/web-component/state.d.ts +47 -0
- package/dist/features/web-component/state.d.ts.map +1 -0
- package/dist/features/web-component/utils.d.ts +13 -0
- package/dist/features/web-component/utils.d.ts.map +1 -0
- package/dist/index.cjs +9 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +30 -230
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +3127 -2967
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.ts +476 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/debug.d.ts +40 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/index.d.ts +51 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/sanitize.d.ts +52 -0
- package/dist/utils/sanitize.d.ts.map +1 -0
- package/package.json +10 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,230 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
text?: AsyncReactiveValue<unknown> | [source: AsyncReactiveValue<unknown>, formatter: (v: unknown) => string];
|
|
32
|
-
html?: AsyncReactiveValue<string>;
|
|
33
|
-
class?: Record<string, AsyncReactiveValue<boolean>>;
|
|
34
|
-
css?: CssBindings;
|
|
35
|
-
attr?: Record<string, AsyncReactiveValue<PrimitiveValue>>;
|
|
36
|
-
prop?: Record<string, AsyncReactiveValue<unknown>>;
|
|
37
|
-
show?: AsyncReactiveValue<boolean>;
|
|
38
|
-
hide?: AsyncReactiveValue<boolean>;
|
|
39
|
-
val?: WritableAtom<T> | [atom: WritableAtom<T>, options: ValOptions<T>];
|
|
40
|
-
checked?: WritableAtom<boolean>;
|
|
41
|
-
form?: WritableAtom<T extends object ? T : unknown> | [
|
|
42
|
-
atom: WritableAtom<T extends object ? T : unknown>,
|
|
43
|
-
options: FormOptions<T extends object ? T : unknown>
|
|
44
|
-
];
|
|
45
|
-
on?: Record<string, (e: JQuery.Event) => void>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Manages the lifecycle of reactive bindings and component effects.
|
|
50
|
-
*
|
|
51
|
-
* Safety Rationale:
|
|
52
|
-
* - Uses WeakMap for records to avoid holding strong references that prevent GC.
|
|
53
|
-
* - Uses WeakSet for node flags (kept/ignored) to ensure the registry doesn't leak
|
|
54
|
-
* memory even for nodes that were "lost" without a cleanup call.
|
|
55
|
-
*/
|
|
56
|
-
declare class BindingRegistry {
|
|
57
|
-
private records;
|
|
58
|
-
private preservedNodes;
|
|
59
|
-
private ignoredNodes;
|
|
60
|
-
/** Mark a node to preserve its effects even if detached from the DOM (e.g., jQuery .detach()). */
|
|
61
|
-
keep(node: Node): void;
|
|
62
|
-
isKept(node: Node): boolean;
|
|
63
|
-
/** Temporary flag to block redundant cleanup cycles for the same node. */
|
|
64
|
-
markIgnored(node: Node): void;
|
|
65
|
-
isIgnored(node: Node): boolean;
|
|
66
|
-
private getOrCreateRecord;
|
|
67
|
-
private addCleanup;
|
|
68
|
-
/** Registers a reactive effect instance to be disposed when the element is removed. */
|
|
69
|
-
trackEffect(element: Element, reactiveEffect: EffectObject): void;
|
|
70
|
-
/** Registers a generic cleanup closure to be executed when the element is removed. */
|
|
71
|
-
trackCleanup(element: Element, cleanupFunction: () => void): void;
|
|
72
|
-
/** Sets the optional teardown function returned by a mounted component. */
|
|
73
|
-
setComponentCleanup(element: Element, teardownFunction: (() => void) | undefined): void;
|
|
74
|
-
hasBind(element: Element): boolean;
|
|
75
|
-
/**
|
|
76
|
-
* Performs the actual destruction of all resources bound to the node.
|
|
77
|
-
* This clears the record, removes the tracking CSS class, and executes all callbacks.
|
|
78
|
-
*/
|
|
79
|
-
cleanup(node: Node): void;
|
|
80
|
-
cleanupDescendants(root: Element | DocumentFragment | ShadowRoot): void;
|
|
81
|
-
/** Destroys the reactive state of the element and its entire sub-tree. */
|
|
82
|
-
cleanupTree(node: Node): void;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Definition for a mountable component that manages its own lifecycle. */
|
|
86
|
-
export declare type ComponentFn<P = Record<string, unknown>> = ($el: JQuery, props: P) => EffectResult;
|
|
87
|
-
|
|
88
|
-
declare interface ComponentLifecycle {
|
|
89
|
-
unmount: EffectCleanup;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { ComputedAtom }
|
|
93
|
-
|
|
94
|
-
export declare type CssBindings = Record<string, CssValue>;
|
|
95
|
-
|
|
96
|
-
export declare type CssValue = AsyncReactiveValue<string | number> | [source: AsyncReactiveValue<number>, unit: string];
|
|
97
|
-
|
|
98
|
-
export default default_2;
|
|
99
|
-
|
|
100
|
-
export declare function disableAutoCleanup(): void;
|
|
101
|
-
|
|
102
|
-
/** Restores original jQuery prototype methods to their clean state. */
|
|
103
|
-
export declare function disablejQueryOverrides(): void;
|
|
104
|
-
|
|
105
|
-
export declare type EffectCleanup = () => void;
|
|
106
|
-
|
|
107
|
-
export declare type EffectResult = undefined | EffectCleanup | ComponentLifecycle;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Requirement: Native browser operations (like el.innerHTML = '') bypass jQuery hooks.
|
|
111
|
-
* This observer serves as a safety net, detecting removed nodes that missed the
|
|
112
|
-
* patched jQuery .remove() or .empty() calls.
|
|
113
|
-
*/
|
|
114
|
-
export declare function enableAutoCleanup(root: Element | ShadowRoot | DocumentFragment): void;
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Globally overrides specific jQuery prototype methods to automate library behavior.
|
|
118
|
-
*
|
|
119
|
-
* Responsibilities:
|
|
120
|
-
* 1. Auto-Batching: Wraps all event handlers in 'batch()' to prevent UI jitter.
|
|
121
|
-
* 2. Lifecycle Sync: Hooking .remove()/.empty() to stop reactive effects on deleted elements.
|
|
122
|
-
* 3. Persistence: Hooking .detach() to preserve effects when nodes are moved temporarily.
|
|
123
|
-
* 4. Identity Management: Uses a WeakMap so .off(originalFn) still works correctly.
|
|
124
|
-
*/
|
|
125
|
-
export declare function enablejQueryOverrides(): void;
|
|
126
|
-
|
|
127
|
-
export declare type EqualFn<T> = (a: T, b: T) => boolean;
|
|
128
|
-
|
|
129
|
-
export declare interface FetchOptions<T> {
|
|
130
|
-
defaultValue: T;
|
|
131
|
-
name?: string;
|
|
132
|
-
method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS' | (string & {});
|
|
133
|
-
headers?: Record<string, string>;
|
|
134
|
-
transform?: (raw: unknown, xhr: JQuery.jqXHR) => T;
|
|
135
|
-
ajaxOptions?: JQuery.AjaxSettings | (() => JQuery.AjaxSettings);
|
|
136
|
-
onError?: (err: unknown) => void;
|
|
137
|
-
eager?: boolean;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
declare interface FormOptions<T> extends ValOptions<T> {
|
|
141
|
-
/** Custom function to transform field value based on path before atomic sync. */
|
|
142
|
-
transform?: (path: string, value: unknown) => unknown;
|
|
143
|
-
/** Callback triggered when a field value changes. */
|
|
144
|
-
onChange?: (path: string, value: unknown) => void;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
declare type ListKey = string | number;
|
|
148
|
-
|
|
149
|
-
declare type ListKeyFn<T> = (item: T, index: number) => ListKey;
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Configuration for high-performance list reconciliation.
|
|
153
|
-
* Uses 'key' for identity tracking to minimize DOM churn.
|
|
154
|
-
*/
|
|
155
|
-
export declare interface ListOptions<T> {
|
|
156
|
-
key: keyof T | ListKeyFn<T>;
|
|
157
|
-
render: (item: T, index: number) => ListRenderResult;
|
|
158
|
-
bind?: ($el: JQuery, item: T, index: number) => void;
|
|
159
|
-
update?: ($el: JQuery, item: T, index: number) => void;
|
|
160
|
-
onAdd?: ($el: JQuery) => void;
|
|
161
|
-
onRemove?: ($el: JQuery) => Promise<void> | void;
|
|
162
|
-
empty?: ListRenderResult;
|
|
163
|
-
events?: Record<string, (item: T, index: number, e: JQuery.TriggeredEvent) => void>;
|
|
164
|
-
isEqual?: (a: T, b: T) => boolean;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
declare type ListRenderResult = string | Element | DocumentFragment | JQuery;
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Returns a promise that resolves after the next reactive tick.
|
|
171
|
-
* Useful for waiting until all pending effects have updated the DOM.
|
|
172
|
-
*/
|
|
173
|
-
export declare const nextTick: () => Promise<void>;
|
|
174
|
-
|
|
175
|
-
export declare type PrimitiveValue = string | number | boolean | null | undefined;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Flexible value container.
|
|
179
|
-
* Supports raw T, reactive Atoms, or functional getters for deferred execution.
|
|
180
|
-
*/
|
|
181
|
-
export declare type ReactiveValue<T> = T | ReadonlyAtom<T> | (() => T);
|
|
182
|
-
|
|
183
|
-
export { ReadonlyAtom }
|
|
184
|
-
|
|
185
|
-
export declare const registry: BindingRegistry;
|
|
186
|
-
|
|
187
|
-
export declare interface RouteConfig {
|
|
188
|
-
target: string | JQuery<HTMLElement> | HTMLElement;
|
|
189
|
-
default?: string;
|
|
190
|
-
routes?: Record<string, RouteDefinition>;
|
|
191
|
-
mode?: 'hash' | 'history';
|
|
192
|
-
basePath?: string;
|
|
193
|
-
notFound?: string;
|
|
194
|
-
autoBindLinks?: boolean;
|
|
195
|
-
activeClass?: string;
|
|
196
|
-
beforeTransition?: (from: string, to: string) => void;
|
|
197
|
-
afterTransition?: (from: string, to: string) => void;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export declare interface RouteDefinition extends RouteLifecycle {
|
|
201
|
-
template?: string;
|
|
202
|
-
render?: (container: HTMLElement, route: string, params: Record<string, string>, onUnmount: (cleanupFn: () => void) => void, router: Router) => void;
|
|
203
|
-
onMount?: ($content: JQuery, onUnmount: (cleanupFn: () => void) => void, router: Router) => void;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export declare interface RouteLifecycle {
|
|
207
|
-
onEnter?: (params: Record<string, string>, router: Router) => Record<string, string> | undefined | false;
|
|
208
|
-
onLeave?: (router: Router) => boolean | undefined;
|
|
209
|
-
title?: string;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export declare interface Router {
|
|
213
|
-
currentRoute: ReadonlyAtom<string>;
|
|
214
|
-
queryParams: ReadonlyAtom<Record<string, string>>;
|
|
215
|
-
params: ReadonlyAtom<Record<string, string>>;
|
|
216
|
-
navigate: (route: string) => void;
|
|
217
|
-
destroy: () => void;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
export declare interface ValOptions<T> {
|
|
221
|
-
debounce?: number;
|
|
222
|
-
event?: string;
|
|
223
|
-
parse?: (v: string) => T;
|
|
224
|
-
format?: (v: T) => string;
|
|
225
|
-
equal?: EqualFn<T>;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
export { WritableAtom }
|
|
229
|
-
|
|
230
|
-
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"}
|