@aegis-framework/pandora 0.1.8 → 0.3.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/LICENSE +1 -1
- package/README.md +746 -27
- package/dist/pandora.browser.js +10 -0
- package/dist/pandora.browser.js.map +14 -0
- package/dist/pandora.js +9 -1
- package/dist/pandora.js.map +13 -1
- package/dist/types/Component.d.ts +266 -0
- package/dist/types/Component.d.ts.map +1 -0
- package/dist/types/Registry.d.ts +276 -0
- package/dist/types/Registry.d.ts.map +1 -0
- package/dist/types/ShadowComponent.d.ts +35 -0
- package/dist/types/ShadowComponent.d.ts.map +1 -0
- package/dist/types/Types.d.ts +9 -0
- package/dist/types/Types.d.ts.map +1 -0
- package/dist/types/Util.d.ts +16 -0
- package/dist/types/Util.d.ts.map +1 -0
- package/dist/types/browser.d.ts +7 -0
- package/dist/types/browser.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +38 -50
- package/dist/pandora.min.js +0 -2
- package/dist/pandora.min.js.map +0 -1
- package/dist/pandora.node.js +0 -2
- package/dist/pandora.node.js.map +0 -1
- package/index.js +0 -3
- package/src/Component.js +0 -502
- package/src/Registry.js +0 -74
- package/src/ShadowComponent.js +0 -68
- package/src/Util.js +0 -66
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { Properties, Style, ReadyCallback } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* A component represents a custom HTML element, and has all of its functionality
|
|
4
|
+
* as well as its general structure and representation self contained on it.
|
|
5
|
+
*
|
|
6
|
+
* @template P - The type of the component's props (defaults to Properties)
|
|
7
|
+
* @template S - The type of the component's state (defaults to Properties)
|
|
8
|
+
*/
|
|
9
|
+
declare class Component<P extends Properties = Properties, S extends Properties = Properties> extends HTMLElement {
|
|
10
|
+
protected _children: string;
|
|
11
|
+
protected _state: S;
|
|
12
|
+
protected _props: P;
|
|
13
|
+
protected _ready: ReadyCallback[];
|
|
14
|
+
protected _connected: boolean;
|
|
15
|
+
protected _isReady: boolean;
|
|
16
|
+
protected _style: Style;
|
|
17
|
+
protected _styleElement: HTMLStyleElement | null;
|
|
18
|
+
static _tag?: string;
|
|
19
|
+
static _template?: string | ((context: any) => string);
|
|
20
|
+
static _observedAttributes: string[];
|
|
21
|
+
static _onMount?: (component: Component, tag: string) => void;
|
|
22
|
+
static _onUnmount?: (component: Component, tag: string) => void;
|
|
23
|
+
static _onError?: (error: Error, component: Component, tag: string, lifecycle: string) => void;
|
|
24
|
+
static _applyMiddleware?: (type: string, component: Component, value: any) => any;
|
|
25
|
+
static _hasMiddleware?: (type: string) => boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Returns the list of attributes to observe for changes.
|
|
28
|
+
* Override this in subclasses to specify which attributes should trigger attributeChangedCallback.
|
|
29
|
+
*
|
|
30
|
+
* @returns {string[]} - Array of attribute names to observe
|
|
31
|
+
*/
|
|
32
|
+
static get observedAttributes(): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Sets the list of attributes to observe for changes.
|
|
35
|
+
*
|
|
36
|
+
* @param value - The new list of attributes to observe
|
|
37
|
+
*/
|
|
38
|
+
static set observedAttributes(value: string[]);
|
|
39
|
+
static get tag(): string;
|
|
40
|
+
static set tag(value: string);
|
|
41
|
+
static template(html?: string | ((context: any) => string) | null, context?: any): string | undefined | void;
|
|
42
|
+
constructor();
|
|
43
|
+
get width(): number;
|
|
44
|
+
set width(value: number | string);
|
|
45
|
+
get height(): number;
|
|
46
|
+
set height(value: number | string);
|
|
47
|
+
get static(): typeof Component;
|
|
48
|
+
set static(value: typeof Component);
|
|
49
|
+
get props(): P;
|
|
50
|
+
set props(value: P);
|
|
51
|
+
get state(): S;
|
|
52
|
+
set state(value: S);
|
|
53
|
+
get dom(): HTMLElement;
|
|
54
|
+
set dom(value: HTMLElement);
|
|
55
|
+
/**
|
|
56
|
+
* Returns whether the component is currently connected to the DOM.
|
|
57
|
+
*/
|
|
58
|
+
get isConnected(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Returns whether the component has completed its initial mount cycle.
|
|
61
|
+
*/
|
|
62
|
+
get isReady(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* register - Register the component as a custom HTML element
|
|
65
|
+
* using the component's tag as the actual element tag.
|
|
66
|
+
*
|
|
67
|
+
* This action cannot be reverted nor the controller class for
|
|
68
|
+
* the element can be changed.
|
|
69
|
+
*/
|
|
70
|
+
static register(): void;
|
|
71
|
+
/**
|
|
72
|
+
* template - A simple function providing access to the basic HTML
|
|
73
|
+
* structure of the component.
|
|
74
|
+
*
|
|
75
|
+
* @param {function|string} html - A string or function that renders the
|
|
76
|
+
* component into a valid HTML structure.
|
|
77
|
+
*
|
|
78
|
+
* @returns {void|string} - Void or the HTML structure in a string
|
|
79
|
+
*/
|
|
80
|
+
template(html?: string | ((context: any) => string) | null): string | undefined | void;
|
|
81
|
+
protected _createStyleElement(): void;
|
|
82
|
+
setStyle(style: Style | string, reset?: boolean): Style;
|
|
83
|
+
setState(state: Partial<S>): void;
|
|
84
|
+
setProps(props: Partial<P>): void;
|
|
85
|
+
protected _setPropAttributes(update?: boolean): void;
|
|
86
|
+
/**
|
|
87
|
+
* Adds an event listener to the component.
|
|
88
|
+
*
|
|
89
|
+
* @param event - The event type to listen for
|
|
90
|
+
* @param callback - The callback function to execute when the event occurs
|
|
91
|
+
* @param options - Optional event listener options
|
|
92
|
+
* @returns The component instance for chaining
|
|
93
|
+
*/
|
|
94
|
+
on<K extends keyof HTMLElementEventMap>(event: K, callback: (this: this, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): this;
|
|
95
|
+
on(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
|
|
96
|
+
/**
|
|
97
|
+
* Removes an event listener from the component.
|
|
98
|
+
*
|
|
99
|
+
* @param event - The event type to remove the listener for
|
|
100
|
+
* @param callback - The callback function to remove
|
|
101
|
+
* @param options - Optional event listener options
|
|
102
|
+
* @returns The component instance for chaining
|
|
103
|
+
*/
|
|
104
|
+
off<K extends keyof HTMLElementEventMap>(event: K, callback: (this: this, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): this;
|
|
105
|
+
off(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): this;
|
|
106
|
+
/**
|
|
107
|
+
* Adds a one-time event listener that removes itself after the first trigger.
|
|
108
|
+
*
|
|
109
|
+
* @param event - The event type to listen for
|
|
110
|
+
* @param callback - The callback function to execute when the event occurs
|
|
111
|
+
* @param options - Optional event listener options
|
|
112
|
+
* @returns The component instance for chaining
|
|
113
|
+
*/
|
|
114
|
+
once<K extends keyof HTMLElementEventMap>(event: K, callback: (this: this, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): this;
|
|
115
|
+
once(event: string, callback: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
|
|
116
|
+
/**
|
|
117
|
+
* Emits a custom event from the component.
|
|
118
|
+
*
|
|
119
|
+
* @param event - The event name to emit
|
|
120
|
+
* @param detail - Optional data to include with the event
|
|
121
|
+
* @param options - Optional CustomEvent init options (bubbles, cancelable, composed)
|
|
122
|
+
* @returns Whether the event was not cancelled
|
|
123
|
+
*/
|
|
124
|
+
emit<T = unknown>(event: string, detail?: T, options?: Omit<CustomEventInit<T>, 'detail'>): boolean;
|
|
125
|
+
/**
|
|
126
|
+
* Queries for a single element within the component's DOM.
|
|
127
|
+
*
|
|
128
|
+
* @param selector - CSS selector to query for
|
|
129
|
+
* @returns The first matching element or null
|
|
130
|
+
*/
|
|
131
|
+
query<E extends Element = Element>(selector: string): E | null;
|
|
132
|
+
/**
|
|
133
|
+
* Queries for all matching elements within the component's DOM.
|
|
134
|
+
*
|
|
135
|
+
* @param selector - CSS selector to query for
|
|
136
|
+
* @returns A NodeList of all matching elements
|
|
137
|
+
*/
|
|
138
|
+
queryAll<E extends Element = Element>(selector: string): NodeListOf<E>;
|
|
139
|
+
/**
|
|
140
|
+
* Called before the component updates due to state or props changes.
|
|
141
|
+
* Override this method to perform actions before an update occurs.
|
|
142
|
+
*
|
|
143
|
+
* @param origin - Whether the update was triggered by 'state' or 'props'
|
|
144
|
+
* @param property - The name of the property that changed
|
|
145
|
+
* @param oldValue - The previous value of the property
|
|
146
|
+
* @param newValue - The new value of the property
|
|
147
|
+
* @param oldObject - The previous state/props object
|
|
148
|
+
* @param newObject - The new state/props object
|
|
149
|
+
* @returns A promise that resolves when the pre-update logic completes
|
|
150
|
+
*/
|
|
151
|
+
protected willUpdate(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Called when the component updates due to state or props changes.
|
|
154
|
+
* Override this method to perform actions during an update.
|
|
155
|
+
*
|
|
156
|
+
* @param origin - Whether the update was triggered by 'state' or 'props'
|
|
157
|
+
* @param property - The name of the property that changed
|
|
158
|
+
* @param oldValue - The previous value of the property
|
|
159
|
+
* @param newValue - The new value of the property
|
|
160
|
+
* @param oldObject - The previous state/props object
|
|
161
|
+
* @param newObject - The new state/props object
|
|
162
|
+
* @returns A promise that resolves when the update logic completes
|
|
163
|
+
*/
|
|
164
|
+
protected update(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Called after the component updates due to state or props changes.
|
|
167
|
+
* Override this method to perform actions after an update completes.
|
|
168
|
+
*
|
|
169
|
+
* @param origin - Whether the update was triggered by 'state' or 'props'
|
|
170
|
+
* @param property - The name of the property that changed
|
|
171
|
+
* @param oldValue - The previous value of the property
|
|
172
|
+
* @param newValue - The new value of the property
|
|
173
|
+
* @param oldObject - The previous state/props object
|
|
174
|
+
* @param newObject - The new state/props object
|
|
175
|
+
* @returns A promise that resolves when the post-update logic completes
|
|
176
|
+
*/
|
|
177
|
+
protected didUpdate(origin: string, property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Called when the component's state updates.
|
|
180
|
+
* Override this method to react specifically to state changes.
|
|
181
|
+
*
|
|
182
|
+
* @param property - The name of the state property that changed
|
|
183
|
+
* @param oldValue - The previous value of the property
|
|
184
|
+
* @param newValue - The new value of the property
|
|
185
|
+
* @param oldObject - The previous state object
|
|
186
|
+
* @param newObject - The new state object
|
|
187
|
+
* @returns A promise that resolves when the state update logic completes
|
|
188
|
+
*/
|
|
189
|
+
protected onStateUpdate(property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
190
|
+
/**
|
|
191
|
+
* Called when the component's props update.
|
|
192
|
+
* Override this method to react specifically to props changes.
|
|
193
|
+
*
|
|
194
|
+
* @param property - The name of the prop that changed
|
|
195
|
+
* @param oldValue - The previous value of the property
|
|
196
|
+
* @param newValue - The new value of the property
|
|
197
|
+
* @param oldObject - The previous props object
|
|
198
|
+
* @param newObject - The new props object
|
|
199
|
+
* @returns A promise that resolves when the props update logic completes
|
|
200
|
+
*/
|
|
201
|
+
protected onPropsUpdate(property: string, oldValue: unknown, newValue: unknown, oldObject: unknown, newObject: unknown): Promise<void>;
|
|
202
|
+
/**
|
|
203
|
+
* Called before the component is mounted to the DOM.
|
|
204
|
+
* Override this method to perform setup before rendering.
|
|
205
|
+
*
|
|
206
|
+
* @returns A promise that resolves when the pre-mount logic completes
|
|
207
|
+
*/
|
|
208
|
+
protected willMount(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Called after the component is mounted to the DOM.
|
|
211
|
+
* Override this method to perform actions after the component is rendered.
|
|
212
|
+
*
|
|
213
|
+
* @returns A promise that resolves when the post-mount logic completes
|
|
214
|
+
*/
|
|
215
|
+
protected didMount(): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Called before the component is removed from the DOM.
|
|
218
|
+
* Override this method to perform cleanup before unmounting.
|
|
219
|
+
*
|
|
220
|
+
* @returns A promise that resolves when the pre-unmount logic completes
|
|
221
|
+
*/
|
|
222
|
+
protected willUnmount(): Promise<void>;
|
|
223
|
+
/**
|
|
224
|
+
* Called when the component is being removed from the DOM.
|
|
225
|
+
* Override this method to perform cleanup during unmounting.
|
|
226
|
+
*
|
|
227
|
+
* @returns A promise that resolves when the unmount logic completes
|
|
228
|
+
*/
|
|
229
|
+
protected unmount(): Promise<void>;
|
|
230
|
+
/**
|
|
231
|
+
* Called after the component is removed from the DOM.
|
|
232
|
+
* Override this method to perform final cleanup after unmounting.
|
|
233
|
+
*
|
|
234
|
+
* @returns A promise that resolves when the post-unmount logic completes
|
|
235
|
+
*/
|
|
236
|
+
protected didUnmount(): Promise<void>;
|
|
237
|
+
/**
|
|
238
|
+
* Forces the component to be rendered again.
|
|
239
|
+
*
|
|
240
|
+
* @returns A promise that resolves with the rendered HTML string
|
|
241
|
+
*/
|
|
242
|
+
forceRender(): string | Promise<string>;
|
|
243
|
+
/**
|
|
244
|
+
* Returns the HTML content for the component.
|
|
245
|
+
* Override this method to define the component's template.
|
|
246
|
+
*
|
|
247
|
+
* @returns The HTML string to render
|
|
248
|
+
*/
|
|
249
|
+
render(): string;
|
|
250
|
+
protected _render(): Promise<string>;
|
|
251
|
+
connectedCallback(): Promise<void>;
|
|
252
|
+
ready(callback: ReadyCallback): void;
|
|
253
|
+
disconnectedCallback(): Promise<void>;
|
|
254
|
+
protected updateCallback(property: string, oldValue: unknown, newValue: unknown, origin?: 'props' | 'state' | 'attribute', oldObject?: P | S, newObject?: P | S): Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Called when an observed attribute changes.
|
|
257
|
+
* This is a Web Components lifecycle callback.
|
|
258
|
+
*
|
|
259
|
+
* @param property - The name of the attribute that changed
|
|
260
|
+
* @param oldValue - The previous value of the attribute
|
|
261
|
+
* @param newValue - The new value of the attribute
|
|
262
|
+
*/
|
|
263
|
+
attributeChangedCallback(property: string, oldValue: string | null, newValue: string | null): void;
|
|
264
|
+
}
|
|
265
|
+
export default Component;
|
|
266
|
+
//# sourceMappingURL=Component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/Component.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3D;;;;;;GAMG;AACH,cAAM,SAAS,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,WAAW;IACvG,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACpB,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IACpB,SAAS,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC;IAClC,SAAS,CAAC,UAAU,EAAE,OAAO,CAAC;IAC9B,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC;IACxB,SAAS,CAAC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAGjD,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAErB,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,MAAM,CAAC,CAAC;IAIvD,MAAM,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAM;IAG1C,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9D,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,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,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IAmCpC,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IA2DxC,KAAK,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAQ9B,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;cA0B3B,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,QAAQ,EAAE,OAAO,EACjB,MAAM,GAAE,OAAO,GAAG,OAAO,GAAG,WAAqB,EACjD,SAAS,GAAE,CAAC,GAAG,CAAe,EAC9B,SAAS,GAAE,CAAC,GAAG,CAAe,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;;;;OAOG;IACH,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;CAKnG;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import Component from './Component';
|
|
2
|
+
type ComponentClass = typeof Component & {
|
|
3
|
+
tag: string;
|
|
4
|
+
_registered?: boolean;
|
|
5
|
+
};
|
|
6
|
+
type StateSubscriber<T = unknown> = (newValue: T, oldValue: T | undefined) => void;
|
|
7
|
+
type LifecycleCallback = (component: Component, tag: string) => void;
|
|
8
|
+
type ErrorCallback = (error: Error, component: Component, tag: string, lifecycle: string) => void;
|
|
9
|
+
type MiddlewareType = 'props' | 'state' | 'render';
|
|
10
|
+
type Middleware = (component: Component, value: any) => any;
|
|
11
|
+
type ComponentLoader = () => Promise<ComponentClass | {
|
|
12
|
+
default: ComponentClass;
|
|
13
|
+
}>;
|
|
14
|
+
interface ComponentStats {
|
|
15
|
+
tag: string;
|
|
16
|
+
instanceCount: number;
|
|
17
|
+
isRegistered: boolean;
|
|
18
|
+
isLazy: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Registry for managing web components and global state
|
|
22
|
+
*/
|
|
23
|
+
declare class Registry {
|
|
24
|
+
private static _debug;
|
|
25
|
+
private static components;
|
|
26
|
+
private static implementations;
|
|
27
|
+
private static state;
|
|
28
|
+
private static subscribers;
|
|
29
|
+
private static mountCallbacks;
|
|
30
|
+
private static unmountCallbacks;
|
|
31
|
+
private static errorCallbacks;
|
|
32
|
+
private static aliases;
|
|
33
|
+
private static lazyLoaders;
|
|
34
|
+
private static middleware;
|
|
35
|
+
private static _initialized;
|
|
36
|
+
/**
|
|
37
|
+
* Initialize Registry hooks on the Component class. Called automatically on first use
|
|
38
|
+
*/
|
|
39
|
+
private static _init;
|
|
40
|
+
/**
|
|
41
|
+
* Register a new component with a specific tag name
|
|
42
|
+
*
|
|
43
|
+
* @param tag - The tag name for the component
|
|
44
|
+
* @param component - The component constructor
|
|
45
|
+
*/
|
|
46
|
+
static register(tag: string, component: ComponentClass): void;
|
|
47
|
+
/**
|
|
48
|
+
* Get the current implementation for a tag
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
static getImplementation(tag: string): ComponentClass | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* Update an existing component with a new implementation
|
|
55
|
+
*
|
|
56
|
+
* @param tag - The tag name of the component to update
|
|
57
|
+
* @param component - The new component constructor
|
|
58
|
+
* @param rerender - Whether to re-render all existing instances (default: false)
|
|
59
|
+
*/
|
|
60
|
+
static evolve(tag: string, component: ComponentClass, rerender?: boolean): void;
|
|
61
|
+
/**
|
|
62
|
+
* Get all instances of a component or execute a callback on them
|
|
63
|
+
*
|
|
64
|
+
* @param tag - The tag name of the component
|
|
65
|
+
* @param callback - Optional callback to execute on each instance
|
|
66
|
+
*/
|
|
67
|
+
static instances(tag: string, callback?: (instance: Element) => void): NodeListOf<Element> | void;
|
|
68
|
+
/**
|
|
69
|
+
* Create a new instance of a component
|
|
70
|
+
*
|
|
71
|
+
* @param tag - The tag name of the component
|
|
72
|
+
* @param props - Properties to set on the component
|
|
73
|
+
* @returns The created component instance
|
|
74
|
+
*/
|
|
75
|
+
static instantiate(tag: string, props: Record<string, any>): Component;
|
|
76
|
+
/**
|
|
77
|
+
* Check if a component is registered with the given tag
|
|
78
|
+
*
|
|
79
|
+
* @param tag - The tag name to check
|
|
80
|
+
* @returns True if a component is registered with the tag
|
|
81
|
+
*/
|
|
82
|
+
static has(tag: string): boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Get the component class registered with the given tag
|
|
85
|
+
*
|
|
86
|
+
* @param tag - The tag name of the component
|
|
87
|
+
* @returns The component class or undefined if not registered
|
|
88
|
+
*/
|
|
89
|
+
static get(tag: string): ComponentClass | undefined;
|
|
90
|
+
/**
|
|
91
|
+
* Set a global state value
|
|
92
|
+
*
|
|
93
|
+
* @param key - The state key
|
|
94
|
+
* @param value - The value to set
|
|
95
|
+
*/
|
|
96
|
+
static setState<T>(key: string, value: T): void;
|
|
97
|
+
/**
|
|
98
|
+
* Get a global state value
|
|
99
|
+
*
|
|
100
|
+
* @param key - The state key
|
|
101
|
+
* @returns The state value or undefined if not set
|
|
102
|
+
*/
|
|
103
|
+
static getState<T>(key: string): T | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Check if a global state key exists
|
|
106
|
+
*
|
|
107
|
+
* @param key - The state key to check
|
|
108
|
+
* @returns True if the state key exists
|
|
109
|
+
*/
|
|
110
|
+
static hasState(key: string): boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Delete a global state value
|
|
113
|
+
*
|
|
114
|
+
* @param key - The state key to delete
|
|
115
|
+
* @returns True if the key existed and was deleted
|
|
116
|
+
*/
|
|
117
|
+
static deleteState(key: string): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Subscribe to changes on a global state key
|
|
120
|
+
*
|
|
121
|
+
* @param key - The state key to subscribe to
|
|
122
|
+
* @param callback - Function called when the state changes
|
|
123
|
+
* @returns An unsubscribe function
|
|
124
|
+
*/
|
|
125
|
+
static subscribe<T>(key: string, callback: StateSubscriber<T>): () => void;
|
|
126
|
+
/**
|
|
127
|
+
* Unsubscribe from changes on a global state key
|
|
128
|
+
*
|
|
129
|
+
* @param key - The state key to unsubscribe from
|
|
130
|
+
* @param callback - The callback function to remove
|
|
131
|
+
*/
|
|
132
|
+
static unsubscribe<T>(key: string, callback: StateSubscriber<T>): void;
|
|
133
|
+
/**
|
|
134
|
+
* Get all global state as an object
|
|
135
|
+
*
|
|
136
|
+
* @returns A copy of the global state object
|
|
137
|
+
*/
|
|
138
|
+
static getAllState(): Record<string, unknown>;
|
|
139
|
+
/**
|
|
140
|
+
* Clear all global state and notify subscribers
|
|
141
|
+
*/
|
|
142
|
+
static clearState(): void;
|
|
143
|
+
/**
|
|
144
|
+
* Enable or disable debug mode.
|
|
145
|
+
* When enabled, lifecycle events are logged to the console.
|
|
146
|
+
*/
|
|
147
|
+
static get debug(): boolean;
|
|
148
|
+
static set debug(value: boolean);
|
|
149
|
+
/**
|
|
150
|
+
* Log a debug message if debug mode is enabled
|
|
151
|
+
*
|
|
152
|
+
* @param message - The message to log
|
|
153
|
+
* @param data - Optional data to include
|
|
154
|
+
*/
|
|
155
|
+
static log(message: string, data?: unknown): void;
|
|
156
|
+
/**
|
|
157
|
+
* List all registered component tags
|
|
158
|
+
*
|
|
159
|
+
* @returns Array of registered component tag names
|
|
160
|
+
*/
|
|
161
|
+
static list(): string[];
|
|
162
|
+
/**
|
|
163
|
+
* Get statistics for a specific component or all components
|
|
164
|
+
*
|
|
165
|
+
* @param tag - Optional tag to get stats for a specific component
|
|
166
|
+
* @returns Component stats or array of all component stats
|
|
167
|
+
*/
|
|
168
|
+
static stats(tag?: string): ComponentStats | ComponentStats[];
|
|
169
|
+
/**
|
|
170
|
+
* Register a callback to be called when any component mounts
|
|
171
|
+
*
|
|
172
|
+
* @param callback - Function called with (component, tag) when a component mounts
|
|
173
|
+
* @returns Unsubscribe function
|
|
174
|
+
*/
|
|
175
|
+
static onMount(callback: LifecycleCallback): () => void;
|
|
176
|
+
/**
|
|
177
|
+
* Register a callback to be called when any component unmounts
|
|
178
|
+
*
|
|
179
|
+
* @param callback - Function called with (component, tag) when a component unmounts
|
|
180
|
+
* @returns Unsubscribe function
|
|
181
|
+
*/
|
|
182
|
+
static onUnmount(callback: LifecycleCallback): () => void;
|
|
183
|
+
/**
|
|
184
|
+
* Notify Registry that a component has mounted
|
|
185
|
+
* @internal
|
|
186
|
+
*/
|
|
187
|
+
static _notifyMount(component: Component, tag: string): void;
|
|
188
|
+
/**
|
|
189
|
+
* Notify Registry that a component has unmounted
|
|
190
|
+
*
|
|
191
|
+
* @internal
|
|
192
|
+
*/
|
|
193
|
+
static _notifyUnmount(component: Component, tag: string): void;
|
|
194
|
+
/**
|
|
195
|
+
* Register a global error handler for component errors
|
|
196
|
+
*
|
|
197
|
+
* @param callback - Function called with (error, component, tag, lifecycle) when an error occurs
|
|
198
|
+
* @returns Unsubscribe function
|
|
199
|
+
*/
|
|
200
|
+
static onError(callback: ErrorCallback): () => void;
|
|
201
|
+
/**
|
|
202
|
+
* Notify Registry that an error occurred in a component
|
|
203
|
+
*
|
|
204
|
+
* @internal
|
|
205
|
+
*/
|
|
206
|
+
static _notifyError(error: Error, component: Component, tag: string, lifecycle: string): void;
|
|
207
|
+
/**
|
|
208
|
+
* Create an alias for an existing component tag
|
|
209
|
+
*
|
|
210
|
+
* @param aliasTag - The new tag name to use as an alias
|
|
211
|
+
* @param originalTag - The original component tag name
|
|
212
|
+
*/
|
|
213
|
+
static alias(aliasTag: string, originalTag: string): void;
|
|
214
|
+
/**
|
|
215
|
+
* Get the original tag for an alias
|
|
216
|
+
*
|
|
217
|
+
* @param aliasTag - The alias tag name
|
|
218
|
+
* @returns The original tag name or undefined if not an alias
|
|
219
|
+
*/
|
|
220
|
+
static getOriginalTag(aliasTag: string): string | undefined;
|
|
221
|
+
/**
|
|
222
|
+
* Check if a tag is an alias
|
|
223
|
+
*
|
|
224
|
+
* @param tag - The tag name to check
|
|
225
|
+
* @returns True if the tag is an alias
|
|
226
|
+
*/
|
|
227
|
+
static isAlias(tag: string): boolean;
|
|
228
|
+
/**
|
|
229
|
+
* Register a component to be lazily loaded on first use
|
|
230
|
+
*
|
|
231
|
+
* @param tag - The tag name for the component
|
|
232
|
+
* @param loader - Async function that returns the component class
|
|
233
|
+
*/
|
|
234
|
+
static lazy(tag: string, loader: ComponentLoader): void;
|
|
235
|
+
/**
|
|
236
|
+
* Load a lazy component
|
|
237
|
+
*
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
static _loadLazyComponent(tag: string): Promise<void>;
|
|
241
|
+
/**
|
|
242
|
+
* Check if a component is lazy (not yet loaded)
|
|
243
|
+
*
|
|
244
|
+
* @param tag - The tag name to check
|
|
245
|
+
* @returns True if the component is registered as lazy and not yet loaded
|
|
246
|
+
*/
|
|
247
|
+
static isLazy(tag: string): boolean;
|
|
248
|
+
/**
|
|
249
|
+
* Preload a lazy component without mounting it
|
|
250
|
+
*
|
|
251
|
+
* @param tag - The tag name of the lazy component to preload
|
|
252
|
+
*/
|
|
253
|
+
static preload(tag: string): Promise<void>;
|
|
254
|
+
/**
|
|
255
|
+
* Register middleware to intercept props, state, or render operations
|
|
256
|
+
*
|
|
257
|
+
* @param type - The type of middleware: 'props', 'state', or 'render'
|
|
258
|
+
* @param middleware - Function that receives (component, value) and returns the modified value
|
|
259
|
+
* @returns Unsubscribe function
|
|
260
|
+
*/
|
|
261
|
+
static use(type: MiddlewareType, middleware: Middleware): () => void;
|
|
262
|
+
/**
|
|
263
|
+
* Apply middleware to a value
|
|
264
|
+
*
|
|
265
|
+
* @internal
|
|
266
|
+
*/
|
|
267
|
+
static _applyMiddleware(type: MiddlewareType, component: Component, value: any): any;
|
|
268
|
+
/**
|
|
269
|
+
* Check if there are any middleware registered for a type
|
|
270
|
+
*
|
|
271
|
+
* @internal
|
|
272
|
+
*/
|
|
273
|
+
static _hasMiddleware(type: MiddlewareType): boolean;
|
|
274
|
+
}
|
|
275
|
+
export default Registry;
|
|
276
|
+
//# s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OpE;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG;IAcpF;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO;CAGrD;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import Component from './Component';
|
|
2
|
+
import { Properties, Style } from './Types';
|
|
3
|
+
/**
|
|
4
|
+
* A component that uses Shadow DOM for encapsulation
|
|
5
|
+
*
|
|
6
|
+
* @template P - The type of the component's props (defaults to Properties)
|
|
7
|
+
* @template S - The type of the component's state (defaults to Properties)
|
|
8
|
+
*/
|
|
9
|
+
declare class ShadowComponent<P extends Properties = Properties, S extends Properties = Properties> extends Component<P, S> {
|
|
10
|
+
protected _shadowDOM: ShadowRoot;
|
|
11
|
+
constructor();
|
|
12
|
+
setStyle(style: Style | string, reset?: boolean): Style;
|
|
13
|
+
protected _createStyleElement(): void;
|
|
14
|
+
protected _render(): Promise<string>;
|
|
15
|
+
get dom(): HTMLElement;
|
|
16
|
+
set dom(value: HTMLElement);
|
|
17
|
+
get shadowRoot(): ShadowRoot;
|
|
18
|
+
set shadowRoot(value: ShadowRoot);
|
|
19
|
+
/**
|
|
20
|
+
* Queries for a single element within the shadow DOM.
|
|
21
|
+
*
|
|
22
|
+
* @param selector - CSS selector to query for
|
|
23
|
+
* @returns The first matching element or null
|
|
24
|
+
*/
|
|
25
|
+
query<E extends Element = Element>(selector: string): E | null;
|
|
26
|
+
/**
|
|
27
|
+
* Queries for all matching elements within the shadow DOM.
|
|
28
|
+
*
|
|
29
|
+
* @param selector - CSS selector to query for
|
|
30
|
+
* @returns A NodeList of all matching elements
|
|
31
|
+
*/
|
|
32
|
+
queryAll<E extends Element = Element>(selector: string): NodeListOf<E>;
|
|
33
|
+
}
|
|
34
|
+
export default ShadowComponent;
|
|
35
|
+
//# sourceMappingURL=ShadowComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShadowComponent.d.ts","sourceRoot":"","sources":["../../src/ShadowComponent.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;;GAKG;AACH,cAAM,eAAe,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,EAAE,CAAC,SAAS,UAAU,GAAG,UAAU,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC;IACjH,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;;IASjC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,KAAK;IAsB9D,SAAS,CAAC,mBAAmB,IAAI,IAAI;cASrB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;IA+B1C,IAAI,GAAG,IAAI,WAAW,CAErB;IAED,IAAI,GAAG,CAAC,KAAK,EAAE,WAAW,EAEzB;IAED,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED,IAAI,UAAU,CAAC,KAAK,EAAE,UAAU,EAE/B;IAED;;;;;OAKG;IACM,KAAK,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,GAAG,IAAI;IAIvE;;;;;OAKG;IACM,QAAQ,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC;CAGhF;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type Properties = Record<string, unknown>;
|
|
2
|
+
export type CSSValue = string | number;
|
|
3
|
+
export type CSSProperties = Record<string, CSSValue>;
|
|
4
|
+
export interface CSSObject {
|
|
5
|
+
[key: string]: CSSValue | CSSProperties | CSSObject;
|
|
6
|
+
}
|
|
7
|
+
export type Style = CSSObject;
|
|
8
|
+
export type ReadyCallback = () => void;
|
|
9
|
+
//# sourceMappingURL=Types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Types.d.ts","sourceRoot":"","sources":["../../src/Types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AACvC,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAErD,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,CAAC;CACrD;AAED,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC;AAE9B,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSObject } from './Types';
|
|
2
|
+
/**
|
|
3
|
+
* Calls a function asynchronously and returns a Promise with its result
|
|
4
|
+
* @param callable - The function to call
|
|
5
|
+
* @param context - The context (this) to use when calling the function
|
|
6
|
+
* @param args - Additional arguments to pass to the function
|
|
7
|
+
*/
|
|
8
|
+
export declare function callAsync<T>(callable: (...args: any[]) => T, context: any, ...args: any[]): Promise<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Converts a CSS object to a CSS string
|
|
11
|
+
* @param object - The CSS object to convert
|
|
12
|
+
* @param encapsulation - Optional selector to encapsulate the CSS
|
|
13
|
+
* @param level - Current nesting level for indentation
|
|
14
|
+
*/
|
|
15
|
+
export declare function deserializeCSS(object: CSSObject, encapsulation?: string, level?: number): string;
|
|
16
|
+
//# sourceMappingURL=Util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Util.d.ts","sourceRoot":"","sources":["../../src/Util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAOtG;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,GAAE,MAAW,EAAE,KAAK,GAAE,MAAU,GAAG,MAAM,CAuCvG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,OAAO,EAAE,OAAO,OAAO,CAAC;KACzB;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Component } from './Component';
|
|
2
|
+
export { default as ShadowComponent } from './ShadowComponent';
|
|
3
|
+
export { default as Registry } from './Registry';
|
|
4
|
+
export * as Util from './Util';
|
|
5
|
+
export * as Types from './Types';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|