@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
@@ -0,0 +1,43 @@
1
+ import { RouteConfig, Router } from '../../types';
2
+ /**
3
+ * Initializes a reactive router for synchronizing URL state with DOM views.
4
+ *
5
+ * When to use:
6
+ * - Invoke during application bootstrap to define your routing manifest
7
+ * and bind a target container for dynamic content rendering.
8
+ *
9
+ * Logic: Reactive Routing
10
+ * This manager orchestrates URL synchronization, path matching, and dynamic
11
+ * view rendering. It exposes reactive atoms (`currentRoute`, `params`)
12
+ * allowing the rest of your UI to respond automatically to navigation changes.
13
+ *
14
+ * Capabilities:
15
+ * - Multi-mode support: Modern 'history' (clean URLs) or 'hash' for legacy/static hosting.
16
+ * - Dynamic matching: High-performance parameter extraction for named segments.
17
+ * - Lifecycle guards: Navigation control via `onEnter` and `onLeave` hooks.
18
+ * - Accessibility: Built-in focus management for Screen Readers on route transitions.
19
+ *
20
+ * @param config - Configuration for routes, target containers, and lifecycle hooks.
21
+ * @returns A router interface for programmatic control and state monitoring.
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * const router = $.route({
26
+ * target: '#app-root',
27
+ * routes: {
28
+ * '/': { template: '#home-tmpl' },
29
+ * '/user/:id': {
30
+ * onEnter: (params) => console.log('Entering user:', params.id),
31
+ * render: (el, name, params) => {
32
+ * $(el).text(`User Profile: ${params.id}`);
33
+ * }
34
+ * }
35
+ * }
36
+ * });
37
+ *
38
+ * // Programmatic navigation
39
+ * router.navigate('/user/42');
40
+ * ```
41
+ */
42
+ export declare function route(config: RouteConfig): Router;
43
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/route/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAEjD"}
@@ -0,0 +1,74 @@
1
+ import { ReadonlyAtom } from '@but212/atom-effect';
2
+ import { RouteConfig, RouteLocation, Router } from '../../types';
3
+ /**
4
+ * Concrete implementation of the Router interface.
5
+ * Coordinates the transition from URL intent to rendered view.
6
+ */
7
+ export declare class RouterImpl implements Router {
8
+ readonly location: ReadonlyAtom<RouteLocation>;
9
+ readonly currentRoute: ReadonlyAtom<string>;
10
+ readonly queryParams: ReadonlyAtom<Record<string, string>>;
11
+ readonly params: ReadonlyAtom<Record<string, string>>;
12
+ private readonly matcher;
13
+ private readonly config;
14
+ private readonly urlAdapter;
15
+ private readonly $target;
16
+ private readonly scanner;
17
+ private readonly renderer;
18
+ private readonly currentRouteAtom;
19
+ private readonly queryParamsAtom;
20
+ private readonly paramsAtom;
21
+ /**
22
+ * Logic: Internal State Management
23
+ * Tracks transient flags and metadata that are hidden from the public API
24
+ * to ensure stable transitions and prevent feedback loops.
25
+ */
26
+ private readonly stateAtom;
27
+ private readonly cleanups;
28
+ /**
29
+ * The public context object passed to route guards and lifecycle hooks.
30
+ * Defined as a separate object to maintain interface compatibility.
31
+ */
32
+ private readonly context;
33
+ constructor(config: RouteConfig);
34
+ /**
35
+ * Logic: Lifecycle Orchestration
36
+ * Establishes the reactive bridge between the URL adapter and the renderer.
37
+ */
38
+ private setupLifecycle;
39
+ private updateState;
40
+ /**
41
+ * Programmatically transitions the application to a new location.
42
+ *
43
+ * When to use:
44
+ * - Triggered by user clicks or script-driven navigation logic.
45
+ *
46
+ * Caution:
47
+ * - Navigation will be aborted if the current route's `onLeave` guard returns `false`.
48
+ *
49
+ * @example
50
+ * router.navigate('/user/123', { debug: 'true' });
51
+ */
52
+ navigate(to: string | Partial<RouteLocation>, query?: Record<string, string>): Promise<void>;
53
+ /**
54
+ * Logic: Browser State Synchronization
55
+ * Handles external URL changes (e.g., Back/Forward button) and ensures
56
+ * they are validated against route guards before adoption.
57
+ */
58
+ private handleBrowserSync;
59
+ /**
60
+ * Logic: Internal Rendering Dispatch
61
+ * Resolves the route definition and delegates DOM manipulation to the renderer.
62
+ */
63
+ private render;
64
+ /**
65
+ * Executes the unmount guard for the current route.
66
+ */
67
+ private canLeave;
68
+ /**
69
+ * Cleanup: Resource Disposal
70
+ * Terminates all reactive effects, unbinds global listeners, and releases DOM references.
71
+ */
72
+ destroy(): void;
73
+ }
74
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/features/route/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,YAAY,EAElB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,WAAW,EAAmB,aAAa,EAAE,MAAM,EAAgB,MAAM,SAAS,CAAC;AAqBjG;;;GAGG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,SAAgB,QAAQ,EAAE,YAAY,CAAC,aAAa,CAAC,CAAC;IACtD,SAAgB,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IACnD,SAAgB,WAAW,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAClE,SAAgB,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAE7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsE;IAC7F,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmC;IAC9D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAE9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;IAEzC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAuB;IACxD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuC;IACvE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAuC;IAElE;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,SAAS,CAKvB;IAEH,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgC;IAEzD;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAWtB;gBAEU,MAAM,EAAE,WAAW;IA6E/B;;;OAGG;IACH,OAAO,CAAC,cAAc;IAiCtB,OAAO,CAAC,WAAW;IAanB;;;;;;;;;;;OAWG;IACU,QAAQ,CACnB,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,EACnC,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACjC,OAAO,CAAC,IAAI,CAAC;IA+ChB;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;IA0CzB;;;OAGG;IACH,OAAO,CAAC,MAAM;IAqBd;;OAEG;IACH,OAAO,CAAC,QAAQ;IAMhB;;;OAGG;IACI,OAAO,IAAI,IAAI;CAQvB"}
@@ -0,0 +1,60 @@
1
+ import { Option } from '@but212/atom-effect-utils';
2
+ import { RouteDefinition } from '../../types';
3
+ /**
4
+ * Represents the current parsed state of a URL.
5
+ *
6
+ * Logic: Data Contract
7
+ * Provides an immutable snapshot used to bridge the gap between browser-specific
8
+ * URL states and the router's internal reactive state.
9
+ */
10
+ export type URLState = {
11
+ readonly path: string;
12
+ readonly query: Record<string, string>;
13
+ readonly url: string;
14
+ };
15
+ /**
16
+ * Interface for browser URL interaction.
17
+ *
18
+ * Logic: State Adaptation
19
+ * Abstracting History and Hash behavior behind this interface allows the router
20
+ * to remain agnostic of the underlying URL strategy.
21
+ */
22
+ export interface UrlAdapter {
23
+ /** Retrieves the current path and query from the browser. */
24
+ readonly get: (base: string) => URLState;
25
+ /** Updates the browser URL and returns the new state. */
26
+ readonly commit: (fullPath: string, base: string) => URLState;
27
+ /** Rolls back the browser URL to a previous state (used when navigation is rejected). */
28
+ readonly revert: (previousUrl: string) => void;
29
+ /** Resolves an anchor element's destination relative to the base path. */
30
+ readonly resolveAnchor: (el: Element, base: string) => string;
31
+ /** Sets up a listener for browser navigation events (popstate or hashchange). */
32
+ readonly setupListener: (handler: () => void) => () => void;
33
+ }
34
+ /**
35
+ * Internal metadata for a compiled route pattern.
36
+ */
37
+ export interface CompiledRoute {
38
+ readonly pattern: string;
39
+ readonly def: RouteDefinition;
40
+ }
41
+ /**
42
+ * Outcome of a route matching operation.
43
+ *
44
+ * Logic: Polymorphic Result
45
+ * Uses the `Option` type to represent a successful match with params or a miss.
46
+ */
47
+ export type MatchResult = Option<{
48
+ readonly route: CompiledRoute;
49
+ readonly params: Record<string, string>;
50
+ }>;
51
+ /**
52
+ * A single entry in the route matcher containing both metadata and matching logic.
53
+ */
54
+ export interface MatchEntry {
55
+ readonly pattern: string;
56
+ readonly def: RouteDefinition;
57
+ /** Executes the matching logic against a given path. */
58
+ readonly match: (path: string) => MatchResult;
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/features/route/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACvC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;IAEzC,yDAAyD;IACzD,QAAQ,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,QAAQ,CAAC;IAE9D,yFAAyF;IACzF,QAAQ,CAAC,MAAM,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAE/C,0EAA0E;IAC1E,QAAQ,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;IAE9D,iFAAiF;IACjF,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;CAC7D;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;CAC/B;AAED;;;;;GAKG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC;IAE9B,wDAAwD;IACxD,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,WAAW,CAAC;CAC/C"}
@@ -0,0 +1,116 @@
1
+ import { ReadonlyAtom } from '@but212/atom-effect';
2
+ import { SlotBuffer } from '@but212/atom-effect-utils';
3
+ import { RouteConfig, RouteDefinition, Router } from '../../types';
4
+ import { createAdapter, RouteMatcher } from './core';
5
+ /**
6
+ * State container for a specific routing target.
7
+ */
8
+ export interface RouteRenderer {
9
+ $target: JQuery<HTMLElement>;
10
+ config: Required<RouteConfig> & {
11
+ routes: Record<string, RouteDefinition>;
12
+ };
13
+ urlAdapter: ReturnType<typeof createAdapter>;
14
+ cleanups: SlotBuffer<() => void>;
15
+ previousPath: string;
16
+ }
17
+ /**
18
+ * Initializes a renderer state for a target element.
19
+ */
20
+ export declare function createRouteRenderer($target: JQuery<HTMLElement>, config: Required<RouteConfig> & {
21
+ routes: Record<string, RouteDefinition>;
22
+ }, urlAdapter: ReturnType<typeof createAdapter>): RouteRenderer;
23
+ /**
24
+ * Orchestrates the transition between views within a target container.
25
+ *
26
+ * When to use:
27
+ * - Invoked by the router whenever a route match is confirmed.
28
+ *
29
+ * Logic: View Update Pipeline
30
+ * 1. Synchronizes document metadata (Title/Meta).
31
+ * 2. Clears the container and triggers previous view cleanups.
32
+ * 3. Renders the new content using the defined strategy.
33
+ * 4. Manages focus and scroll for Accessibility compliance.
34
+ *
35
+ * @example
36
+ * renderRoute(renderer, homeDef, '/home', {}, routerInstance);
37
+ */
38
+ export declare function renderRoute(renderer: RouteRenderer, def: RouteDefinition, routeName: string, params: Record<string, string>, router: Router): void;
39
+ /**
40
+ * Disposes of all resources and effects bound to the current route view.
41
+ */
42
+ export declare function runRendererCleanups(renderer: RouteRenderer): void;
43
+ /**
44
+ * State container for the navigation link tracker.
45
+ */
46
+ export interface RouteScanner {
47
+ config: Required<RouteConfig> & {
48
+ routes: Record<string, RouteDefinition>;
49
+ };
50
+ matcher: RouteMatcher;
51
+ urlAdapter: ReturnType<typeof createAdapter>;
52
+ activeClass: string;
53
+ trackedLinks: Set<Element>;
54
+ pathCache: WeakMap<Element, string>;
55
+ activeStateCache: WeakMap<Element, boolean>;
56
+ linkObserver?: MutationObserver;
57
+ }
58
+ /**
59
+ * Creates a scanner that tracks elements to apply "active" CSS classes.
60
+ */
61
+ export declare function createRouteScanner(config: Required<RouteConfig> & {
62
+ routes: Record<string, RouteDefinition>;
63
+ }, matcher: RouteMatcher, urlAdapter: ReturnType<typeof createAdapter>, activeClass: string): RouteScanner;
64
+ /**
65
+ * Initializes reactive tracking for navigation links across the entire document.
66
+ *
67
+ * When to use:
68
+ * - Call once during application bootstrap to enable automatic "active" link styling.
69
+ *
70
+ * Logic: Link Lifecycle Management
71
+ * 1. Uses MutationObserver to detect links injected via AJAX or templates.
72
+ * 2. Binds reactive effects to each link to toggle classes based on the current atom state.
73
+ * 3. Automatically cleans up effects when elements are removed from the DOM.
74
+ *
75
+ * @param scanner - The scanner state.
76
+ * @param currentRouteAtom - The reactive atom containing the current path.
77
+ *
78
+ * @example
79
+ * setupRouteScanner(scanner, router.current);
80
+ */
81
+ export declare function setupRouteScanner(scanner: RouteScanner, currentRouteAtom: ReadonlyAtom<string>): {
82
+ scan: () => void;
83
+ resolvePath: (el: Element, stripQuery?: boolean) => string;
84
+ };
85
+ /**
86
+ * Scans the initial DOM for declarative route definitions.
87
+ *
88
+ * Logic: Declarative Route Manifest Discovery
89
+ * Extracts route definitions from `<template data-path="...">` tags.
90
+ * This allows defining the application structure directly in HTML.
91
+ *
92
+ * @returns A partial route manifest and the identified default path.
93
+ *
94
+ * @example
95
+ * // HTML: <template data-path="/home" data-default>...</template>
96
+ * const { routes, default: def } = discoverRoutes();
97
+ */
98
+ export declare function discoverRoutes(): {
99
+ routes: Record<string, RouteDefinition>;
100
+ default: string | undefined;
101
+ };
102
+ /**
103
+ * Intercepts document-level clicks to implement "hijack" navigation.
104
+ *
105
+ * Logic: Global Click Interception
106
+ * Decides whether a click should be handled by the router based on:
107
+ * 1. Is it a valid navigation click (e.g., Left click without modifiers)?
108
+ * 2. Does the target match a known route or the 'notFound' handler?
109
+ * 3. Does the target represent a file download? (Heuristic: ignore dots in paths unless matched).
110
+ *
111
+ * @returns A cleanup function to unbind the global listener.
112
+ */
113
+ export declare function setupRouteInterceptor(config: Required<RouteConfig> & {
114
+ routes: Record<string, RouteDefinition>;
115
+ }, matcher: RouteMatcher, resolvePath: (el: Element) => string, navigate: (path: string) => Promise<void>): () => void;
116
+ //# sourceMappingURL=view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view.d.ts","sourceRoot":"","sources":["../../../src/features/route/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,K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,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GACxC,MAAM,IAAI,CAwBZ"}
@@ -0,0 +1,33 @@
1
+ import { AtomComponentController, WritableAtom } from '../../types';
2
+ /**
3
+ * Orchestrates AEJ features for a specific DOM element.
4
+ *
5
+ * Usage:
6
+ * ```ts
7
+ * const ctrl = useAtomComponent(el);
8
+ * ctrl.setup({
9
+ * bind: { '.title': { text: titleAtom } }
10
+ * });
11
+ * ```
12
+ */
13
+ export declare function useAtomComponent(element: HTMLElement): AtomComponentController;
14
+ /**
15
+ * Registers a value or atom to be provided to all descendant elements.
16
+ *
17
+ * Side-effect: Synchronizes the value to a CSS variable `--aej-[key]`
18
+ * on the host element for hybrid styling (CSS-in-JS lite).
19
+ *
20
+ * @example
21
+ * provideAtom(el, 'theme', $.atom('dark'));
22
+ */
23
+ export declare function provideAtom(element: HTMLElement | JQuery | string, key: string | symbol, val: unknown): void;
24
+ /**
25
+ * Injects a provided value or atom from an ancestor.
26
+ * Returns a proxy atom that tracks the provider's location in the DOM.
27
+ *
28
+ * @example
29
+ * const theme = injectAtom(el, 'theme');
30
+ * $.effect(() => console.log(theme.value));
31
+ */
32
+ export declare function injectAtom<T = unknown>(element: HTMLElement | JQuery | string, key: string | symbol): WritableAtom<T> | null;
33
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/features/web-component/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,uBAAuB,EAKvB,YAAY,EACb,MAAM,SAAS,CAAC;AAsRjB;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,uBAAuB,CAuM9E;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,EACtC,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,GAAG,EAAE,OAAO,GACX,IAAI,CA2CN;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,EACpC,OAAO,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,EACtC,GAAG,EAAE,MAAM,GAAG,MAAM,GACnB,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAyBxB"}
@@ -0,0 +1,77 @@
1
+ import { SlotBuffer } from '@but212/atom-effect-utils';
2
+ import { EffectObject, ReactiveValue, ReadonlyAtom } from '../../types';
3
+ /**
4
+ * Collection of decomposed activation logic for setup components.
5
+ * Separates concerns for different reactive integrations to maintain maintainability.
6
+ * @internal
7
+ */
8
+ export declare const SetupFeatures: {
9
+ /**
10
+ * Synchronizes atom values to custom events dispatched from the host.
11
+ *
12
+ * Logic:
13
+ * - If the source is a function returning an object, it is used as the event `detail`.
14
+ * - Otherwise, the value is wrapped in `{ value: val }` for a predictable API.
15
+ */
16
+ dispatch(el: HTMLElement, mappings: Record<string, ReactiveValue<unknown>>, effects: SlotBuffer<EffectObject>): void;
17
+ /**
18
+ * Applies constructable stylesheets to a ShadowRoot or Document.
19
+ * Note: This appends to existing sheets rather than replacing them.
20
+ */
21
+ styles(root: ShadowRoot | Document, sheets: CSSStyleSheet[]): CSSStyleSheet[];
22
+ /**
23
+ * Synchronizes atoms to AriaMixin properties via ElementInternals.
24
+ * Useful for high-level accessibility state (e.g. `aria-pressed`, `aria-valuenow`).
25
+ */
26
+ aria(internals: ElementInternals, aria: Record<string, ReadonlyAtom<unknown>>, effects: SlotBuffer<EffectObject>): void;
27
+ /**
28
+ * Performs declarative hydration of text content based on data-aej-bind attributes.
29
+ *
30
+ * Constraint: Uses `HYDRATION_MARKER` to ensure a node is only bound once,
31
+ * even if multiple hydration passes occur.
32
+ */
33
+ hydrate(root: ParentNode, bindings: Record<string, ReadonlyAtom<unknown>>, effects: SlotBuffer<EffectObject>, hydratedNodes: Set<Element>): void;
34
+ /**
35
+ * Synchronizes atoms to CSS Parts (`part` attribute) based on data-aej-part.
36
+ *
37
+ * Input Support:
38
+ * - String: "part1 part2"
39
+ * - Array: ["part1", "part2"]
40
+ * - Object: { part1: true, part2: false }
41
+ */
42
+ parts(root: ParentNode, parts: Record<string, ReadonlyAtom<unknown>>, effects: SlotBuffer<EffectObject>): void;
43
+ /**
44
+ * Shared DOM observer for detecting dynamically added elements matching a selector.
45
+ * This is the engine behind "late-binding" hydration for dynamically inserted nodes.
46
+ */
47
+ observe(root: ParentNode, selector: string, apply: (n: Element) => void, effects: SlotBuffer<EffectObject>): void;
48
+ /**
49
+ * Integrates reactive state with Form-Associated Custom Element (FACE) internals.
50
+ *
51
+ * This handles both the value state (via `setFormValue`) and the validity state
52
+ * (via `setValidity`), making the component behave like a native input.
53
+ */
54
+ form(el: HTMLElement, internals: ElementInternals, value: ReadonlyAtom<unknown> | {
55
+ val: ReadonlyAtom<unknown>;
56
+ state?: ReadonlyAtom<unknown>;
57
+ } | undefined, validation: ReadonlyAtom<ValidityStateFlags | string> | ((val: unknown) => ValidityStateFlags | string) | undefined, effects: SlotBuffer<EffectObject>): void;
58
+ /**
59
+ * Initializes attribute tracking.
60
+ *
61
+ * Optimisation: If `observedAttributes` is defined on the class,
62
+ * we only watch those specific attributes to reduce MutationObserver overhead.
63
+ */
64
+ attributes(host: HTMLElement): {
65
+ atom: ReadonlyAtom<Record<string, string | null>>;
66
+ observer: MutationObserver;
67
+ };
68
+ /**
69
+ * Initializes reactive slot tracking.
70
+ * Tracks `assignedNodes` for every slot in the ShadowRoot.
71
+ */
72
+ slots(root: ShadowRoot | null): {
73
+ atom: ReadonlyAtom<Record<string, Node[]>>;
74
+ listener: (e: Event) => void;
75
+ };
76
+ };
77
+ //# sourceMappingURL=setup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../../src/features/web-component/setup.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAI5D,OAAO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AC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;QAClD,QAAQ,EAAE,gBAAgB,CAAC;KAC5B;IAuCD;;;OAGG;gBACS,UAAU,GAAG,IAAI,GAAG;QAC9B,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC3C,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;KAC9B;CA6BF,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { Option, SlotBuffer } from '@but212/atom-effect-utils';
2
+ import { CLEANUP_MARKER } from '../../core/symbols';
3
+ import { EffectObject, WritableAtom } from '../../types';
4
+ /**
5
+ * Centralizes all component-specific reactive state and resource tracking.
6
+ * Consolidates lifecycle resources into a single class instance to simplify teardown.
7
+ * @internal
8
+ */
9
+ export declare class ComponentState {
10
+ host: HTMLElement;
11
+ /** The root node (host or shadowRoot) where bindings and styles are applied. */
12
+ root: Option<Node & {
13
+ [CLEANUP_MARKER]?: boolean;
14
+ }>;
15
+ /** Guards against double-initialization of the same host element. */
16
+ isInitialized: boolean;
17
+ /**
18
+ * A buffer for all reactive effects created during setup.
19
+ * Disposed as a single unit in `dispose()`.
20
+ */
21
+ effects: SlotBuffer<EffectObject>;
22
+ /** Set of nodes that have been processed by the hydration engine. */
23
+ hydratedNodes: Set<Element>;
24
+ /** The root atom containing the full snapshot of attributes. */
25
+ attributeAtom: WritableAtom<Record<string, string | null>> | null;
26
+ /** The observer that keeps `attributeAtom` in sync with the DOM. */
27
+ attributeObserver: MutationObserver | null;
28
+ /** Memoized lenses into `attributeAtom` to avoid redundant atom creation. */
29
+ attributeLenses: Map<string, WritableAtom<string | null>>;
30
+ /** The root atom containing the current mapping of assigned nodes per slot. */
31
+ slotsAtom: WritableAtom<Record<string, Node[]>> | null;
32
+ /** Memoized lenses into `slotsAtom`. */
33
+ slotLenses: Map<string, WritableAtom<Node[]>>;
34
+ /** Tracks listeners to allow precise removal during teardown. */
35
+ slotListeners: Map<string, (e: Event) => void>;
36
+ /** References to constructable stylesheets that must be removed from the root. */
37
+ appliedStyles: CSSStyleSheet[];
38
+ constructor(host: HTMLElement);
39
+ /**
40
+ * Deterministically releases all reactive resources and observers.
41
+ *
42
+ * Warning: Failure to call this on unmount will lead to memory leaks
43
+ * as the MutationObservers and effects will remain active.
44
+ */
45
+ dispose(): void;
46
+ }
47
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/features/web-component/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAE,cAAc,EAAoB,MAAM,gBAAgB,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG1D;;;;GAIG;AACH,qBAAa,cAAc;IAiCN,IAAI,EAAE,WAAW;IAhCpC,gFAAgF;IAChF,IAAI,EAAE,MAAM,CAAC,IAAI,GAAG;QAAE,CAAC,cAAc,CAAC,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAe;IAElE,qEAAqE;IACrE,aAAa,UAAS;IAEtB;;;OAGG;IACH,OAAO,2BAAkC;IAEzC,qEAAqE;IACrE,aAAa,eAAsB;IAEnC,gEAAgE;IAChE,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,IAAI,CAAQ;IACzE,oEAAoE;IACpE,iBAAiB,EAAE,gBAAgB,GAAG,IAAI,CAAQ;IAClD,6EAA6E;IAC7E,eAAe,2CAAkD;IAEjE,+EAA+E;IAC/E,SAAS,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAQ;IAC9D,wCAAwC;IACxC,UAAU,oCAA2C;IACrD,iEAAiE;IACjE,aAAa,kBAAuB,KAAK,KAAK,IAAI,EAAI;IAEtD,kFAAkF;IAClF,aAAa,EAAE,aAAa,EAAE,CAAM;gBAEjB,IAAI,EAAE,WAAW;IAEpC;;;;;OAKG;IACH,OAAO;CAqDR"}
@@ -0,0 +1,13 @@
1
+ import { ReactiveValue } from '../../types';
2
+ /**
3
+ * Resolves the active ShadowRoot for component-local operations.
4
+ * @internal
5
+ */
6
+ export declare const resolveShadowRoot: (element: HTMLElement, root: Node | ShadowRoot | null | undefined) => ShadowRoot | null;
7
+ /**
8
+ * Resolves a reactive source into its current value.
9
+ * Supports static values, atoms, and getter functions.
10
+ * @internal
11
+ */
12
+ export declare const resolveValue: <T>(source: ReactiveValue<T>) => T;
13
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/features/web-component/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,WAAW,EACpB,MAAM,IAAI,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,KACzC,UAAU,GAAG,IAKJ,CAAC;AAEb;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,QAAQ,aAAa,CAAC,CAAC,CAAC,KAAG,CAI1D,CAAC"}