pulse-js-framework 1.7.32 → 1.7.37
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/cli/index.js +0 -0
- package/cli/release.js +159 -22
- package/compiler/parser.js +96 -10
- package/compiler/transformer/constants.js +1 -1
- package/compiler/transformer/expressions.js +69 -9
- package/loader/README.md +509 -0
- package/loader/esbuild-plugin.js +251 -0
- package/loader/parcel-plugin.js +216 -0
- package/loader/rollup-plugin.js +259 -0
- package/loader/swc-plugin.js +286 -0
- package/loader/vite-plugin.js +1 -1
- package/loader/webpack-loader.js +228 -0
- package/package.json +15 -2
- package/runtime/security.js +21 -0
- package/runtime/ssr.js +17 -2
- package/types/a11y.d.ts +186 -0
- package/types/devtools.d.ts +418 -0
- package/types/dom-adapter.d.ts +643 -0
- package/types/dom.d.ts +63 -0
- package/types/errors.d.ts +618 -0
- package/types/http.d.ts +426 -0
- package/types/logger.d.ts +12 -0
- package/types/native.d.ts +282 -0
- package/types/pulse.d.ts +70 -1
- package/types/security.d.ts +286 -0
- package/types/ssr.d.ts +263 -0
- package/types/utils.d.ts +85 -0
|
@@ -0,0 +1,643 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pulse Framework - DOM Adapter Type Definitions
|
|
3
|
+
* @module pulse-js-framework/runtime/dom-adapter
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// DOMAdapter Interface
|
|
8
|
+
// ============================================================================
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Abstract DOM adapter interface.
|
|
12
|
+
* Both BrowserDOMAdapter and MockDOMAdapter implement this interface,
|
|
13
|
+
* enabling SSR, testing without a browser, and custom rendering targets.
|
|
14
|
+
*/
|
|
15
|
+
export interface DOMAdapter {
|
|
16
|
+
/** Create an element with the specified tag name */
|
|
17
|
+
createElement(tagName: string): any;
|
|
18
|
+
|
|
19
|
+
/** Create a text node with the specified content */
|
|
20
|
+
createTextNode(text: string): any;
|
|
21
|
+
|
|
22
|
+
/** Create a comment node with the specified content */
|
|
23
|
+
createComment(data: string): any;
|
|
24
|
+
|
|
25
|
+
/** Create a document fragment for batched DOM operations */
|
|
26
|
+
createDocumentFragment(): any;
|
|
27
|
+
|
|
28
|
+
/** Query the document for an element matching the selector */
|
|
29
|
+
querySelector(selector: string): any | null;
|
|
30
|
+
|
|
31
|
+
/** Set an attribute on an element */
|
|
32
|
+
setAttribute(element: any, name: string, value: string): void;
|
|
33
|
+
|
|
34
|
+
/** Remove an attribute from an element */
|
|
35
|
+
removeAttribute(element: any, name: string): void;
|
|
36
|
+
|
|
37
|
+
/** Get an attribute value from an element */
|
|
38
|
+
getAttribute(element: any, name: string): string | null;
|
|
39
|
+
|
|
40
|
+
/** Append a child node to a parent */
|
|
41
|
+
appendChild(parent: any, child: any): void;
|
|
42
|
+
|
|
43
|
+
/** Insert a node before a reference node */
|
|
44
|
+
insertBefore(parent: any, newNode: any, refNode: any): void;
|
|
45
|
+
|
|
46
|
+
/** Remove a node from its parent */
|
|
47
|
+
removeNode(node: any): void;
|
|
48
|
+
|
|
49
|
+
/** Get the parent node of a node */
|
|
50
|
+
getParentNode(node: any): any | null;
|
|
51
|
+
|
|
52
|
+
/** Get the next sibling of a node */
|
|
53
|
+
getNextSibling(node: any): any | null;
|
|
54
|
+
|
|
55
|
+
/** Get the first child of a node */
|
|
56
|
+
getFirstChild(node: any): any | null;
|
|
57
|
+
|
|
58
|
+
/** Add a CSS class to an element */
|
|
59
|
+
addClass(element: any, className: string): void;
|
|
60
|
+
|
|
61
|
+
/** Remove a CSS class from an element */
|
|
62
|
+
removeClass(element: any, className: string): void;
|
|
63
|
+
|
|
64
|
+
/** Set a style property on an element */
|
|
65
|
+
setStyle(element: any, prop: string, value: any): void;
|
|
66
|
+
|
|
67
|
+
/** Get a style property from an element */
|
|
68
|
+
getStyle(element: any, prop: string): any;
|
|
69
|
+
|
|
70
|
+
/** Set a DOM property on an element */
|
|
71
|
+
setProperty(element: any, prop: string, value: any): void;
|
|
72
|
+
|
|
73
|
+
/** Get a DOM property from an element */
|
|
74
|
+
getProperty(element: any, prop: string): any;
|
|
75
|
+
|
|
76
|
+
/** Add an event listener to an element */
|
|
77
|
+
addEventListener(element: any, event: string, handler: Function, options?: any): void;
|
|
78
|
+
|
|
79
|
+
/** Remove an event listener from an element */
|
|
80
|
+
removeEventListener(element: any, event: string, handler: Function, options?: any): void;
|
|
81
|
+
|
|
82
|
+
/** Set the text content of a node */
|
|
83
|
+
setTextContent(node: any, text: string): void;
|
|
84
|
+
|
|
85
|
+
/** Get the text content of a node */
|
|
86
|
+
getTextContent(node: any): string;
|
|
87
|
+
|
|
88
|
+
/** Check if a value is a Node */
|
|
89
|
+
isNode(value: any): boolean;
|
|
90
|
+
|
|
91
|
+
/** Check if a value is an Element */
|
|
92
|
+
isElement(value: any): boolean;
|
|
93
|
+
|
|
94
|
+
/** Queue a function to run as a microtask */
|
|
95
|
+
queueMicrotask(fn: () => void): void;
|
|
96
|
+
|
|
97
|
+
/** Set a timeout */
|
|
98
|
+
setTimeout(fn: () => void, ms: number): number;
|
|
99
|
+
|
|
100
|
+
/** Clear a timeout */
|
|
101
|
+
clearTimeout(id: number): void;
|
|
102
|
+
|
|
103
|
+
/** Get the tag name of an element (lowercase) */
|
|
104
|
+
getTagName(element: any): string;
|
|
105
|
+
|
|
106
|
+
/** Get the type attribute of an input element */
|
|
107
|
+
getInputType(element: any): string | undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ============================================================================
|
|
111
|
+
// Mock Node Classes
|
|
112
|
+
// ============================================================================
|
|
113
|
+
|
|
114
|
+
/** Mock classList interface for MockElement */
|
|
115
|
+
export interface MockClassList {
|
|
116
|
+
/** Add a CSS class */
|
|
117
|
+
add(className: string): void;
|
|
118
|
+
|
|
119
|
+
/** Remove a CSS class */
|
|
120
|
+
remove(className: string): void;
|
|
121
|
+
|
|
122
|
+
/** Check if a class exists */
|
|
123
|
+
contains(className: string): boolean;
|
|
124
|
+
|
|
125
|
+
/** Toggle a CSS class, returns the resulting state */
|
|
126
|
+
toggle(className: string, force?: boolean): boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Simple mock node for testing without a browser environment.
|
|
131
|
+
* Provides minimal DOM-like interface for unit tests.
|
|
132
|
+
*/
|
|
133
|
+
export declare class MockNode {
|
|
134
|
+
constructor(type: number, data?: string);
|
|
135
|
+
|
|
136
|
+
/** Node type constant (1 = Element, 3 = Text, 8 = Comment, 11 = Fragment) */
|
|
137
|
+
nodeType: number;
|
|
138
|
+
|
|
139
|
+
/** Node name */
|
|
140
|
+
nodeName: string;
|
|
141
|
+
|
|
142
|
+
/** Text content of the node */
|
|
143
|
+
textContent: string;
|
|
144
|
+
|
|
145
|
+
/** Parent node reference */
|
|
146
|
+
parentNode: MockNode | null;
|
|
147
|
+
|
|
148
|
+
/** Array of child nodes */
|
|
149
|
+
childNodes: MockNode[];
|
|
150
|
+
|
|
151
|
+
/** Next sibling reference */
|
|
152
|
+
nextSibling: MockNode | null;
|
|
153
|
+
|
|
154
|
+
/** Previous sibling reference */
|
|
155
|
+
previousSibling: MockNode | null;
|
|
156
|
+
|
|
157
|
+
/** Get the first child node */
|
|
158
|
+
readonly firstChild: MockNode | null;
|
|
159
|
+
|
|
160
|
+
/** Append a child node */
|
|
161
|
+
appendChild(child: MockNode): MockNode;
|
|
162
|
+
|
|
163
|
+
/** Insert a node before a reference node */
|
|
164
|
+
insertBefore(newNode: MockNode, refNode: MockNode | null): MockNode;
|
|
165
|
+
|
|
166
|
+
/** Remove a child node */
|
|
167
|
+
removeChild(child: MockNode): MockNode;
|
|
168
|
+
|
|
169
|
+
/** Remove this node from its parent */
|
|
170
|
+
remove(): void;
|
|
171
|
+
|
|
172
|
+
/** Add an event listener */
|
|
173
|
+
addEventListener(event: string, handler: Function, options?: any): void;
|
|
174
|
+
|
|
175
|
+
/** Remove an event listener */
|
|
176
|
+
removeEventListener(event: string, handler: Function, options?: any): void;
|
|
177
|
+
|
|
178
|
+
/** Dispatch an event to listeners */
|
|
179
|
+
dispatchEvent(event: { type: string; [key: string]: any }): void;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Mock Element extending MockNode with element-specific features.
|
|
184
|
+
*/
|
|
185
|
+
export declare class MockElement extends MockNode {
|
|
186
|
+
constructor(tagName: string);
|
|
187
|
+
|
|
188
|
+
/** Tag name (uppercase) */
|
|
189
|
+
tagName: string;
|
|
190
|
+
|
|
191
|
+
/** Element ID */
|
|
192
|
+
id: string;
|
|
193
|
+
|
|
194
|
+
/** Class name string */
|
|
195
|
+
className: string;
|
|
196
|
+
|
|
197
|
+
/** Element type attribute */
|
|
198
|
+
type: string | undefined;
|
|
199
|
+
|
|
200
|
+
/** Element value (for form elements) */
|
|
201
|
+
value: string;
|
|
202
|
+
|
|
203
|
+
/** Checked state (for checkboxes/radios) */
|
|
204
|
+
checked: boolean;
|
|
205
|
+
|
|
206
|
+
/** CSS class list helper */
|
|
207
|
+
readonly classList: MockClassList;
|
|
208
|
+
|
|
209
|
+
/** Inline style object */
|
|
210
|
+
readonly style: Record<string, any>;
|
|
211
|
+
|
|
212
|
+
/** Set an attribute */
|
|
213
|
+
setAttribute(name: string, value: string): void;
|
|
214
|
+
|
|
215
|
+
/** Get an attribute value */
|
|
216
|
+
getAttribute(name: string): string | null;
|
|
217
|
+
|
|
218
|
+
/** Remove an attribute */
|
|
219
|
+
removeAttribute(name: string): void;
|
|
220
|
+
|
|
221
|
+
/** Check if an attribute exists */
|
|
222
|
+
hasAttribute(name: string): boolean;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Mock Text node for testing.
|
|
227
|
+
*/
|
|
228
|
+
export declare class MockTextNode extends MockNode {
|
|
229
|
+
constructor(text: string);
|
|
230
|
+
|
|
231
|
+
/** Text data */
|
|
232
|
+
data: string;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Mock Comment node for testing.
|
|
237
|
+
*/
|
|
238
|
+
export declare class MockCommentNode extends MockNode {
|
|
239
|
+
constructor(data: string);
|
|
240
|
+
|
|
241
|
+
/** Comment data */
|
|
242
|
+
data: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Mock DocumentFragment for testing.
|
|
247
|
+
*/
|
|
248
|
+
export declare class MockDocumentFragment extends MockNode {
|
|
249
|
+
constructor();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// ============================================================================
|
|
253
|
+
// Adapter Classes
|
|
254
|
+
// ============================================================================
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Browser DOM adapter - default implementation using native browser APIs.
|
|
258
|
+
* This is the production adapter for client-side rendering.
|
|
259
|
+
*/
|
|
260
|
+
export declare class BrowserDOMAdapter implements DOMAdapter {
|
|
261
|
+
createElement(tagName: string): Element;
|
|
262
|
+
createTextNode(text: string): Text;
|
|
263
|
+
createComment(data: string): Comment;
|
|
264
|
+
createDocumentFragment(): DocumentFragment;
|
|
265
|
+
querySelector(selector: string): Element | null;
|
|
266
|
+
setAttribute(element: Element, name: string, value: string): void;
|
|
267
|
+
removeAttribute(element: Element, name: string): void;
|
|
268
|
+
getAttribute(element: Element, name: string): string | null;
|
|
269
|
+
appendChild(parent: Node, child: Node): void;
|
|
270
|
+
insertBefore(parent: Node, newNode: Node, refNode: Node): void;
|
|
271
|
+
removeNode(node: Node): void;
|
|
272
|
+
getParentNode(node: Node): Node | null;
|
|
273
|
+
getNextSibling(node: Node): Node | null;
|
|
274
|
+
getFirstChild(node: Node): Node | null;
|
|
275
|
+
addClass(element: Element, className: string): void;
|
|
276
|
+
removeClass(element: Element, className: string): void;
|
|
277
|
+
setStyle(element: HTMLElement, prop: string, value: any): void;
|
|
278
|
+
getStyle(element: HTMLElement, prop: string): any;
|
|
279
|
+
setProperty(element: Element, prop: string, value: any): void;
|
|
280
|
+
getProperty(element: Element, prop: string): any;
|
|
281
|
+
addEventListener(element: Element, event: string, handler: Function, options?: any): void;
|
|
282
|
+
removeEventListener(element: Element, event: string, handler: Function, options?: any): void;
|
|
283
|
+
setTextContent(node: Node, text: string): void;
|
|
284
|
+
getTextContent(node: Node): string;
|
|
285
|
+
isNode(value: any): boolean;
|
|
286
|
+
isElement(value: any): boolean;
|
|
287
|
+
queueMicrotask(fn: () => void): void;
|
|
288
|
+
setTimeout(fn: () => void, ms: number): number;
|
|
289
|
+
clearTimeout(id: number): void;
|
|
290
|
+
getTagName(element: Element): string;
|
|
291
|
+
getInputType(element: Element): string | undefined;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Mock DOM adapter for testing without browser environment.
|
|
296
|
+
* Provides a lightweight, synchronous DOM simulation.
|
|
297
|
+
*/
|
|
298
|
+
export declare class MockDOMAdapter implements DOMAdapter {
|
|
299
|
+
createElement(tagName: string): MockElement;
|
|
300
|
+
createTextNode(text: string): MockTextNode;
|
|
301
|
+
createComment(data: string): MockCommentNode;
|
|
302
|
+
createDocumentFragment(): MockDocumentFragment;
|
|
303
|
+
querySelector(selector: string): MockElement | null;
|
|
304
|
+
setAttribute(element: MockElement, name: string, value: string): void;
|
|
305
|
+
removeAttribute(element: MockElement, name: string): void;
|
|
306
|
+
getAttribute(element: MockElement, name: string): string | null;
|
|
307
|
+
appendChild(parent: MockNode, child: MockNode): void;
|
|
308
|
+
insertBefore(parent: MockNode, newNode: MockNode, refNode: MockNode): void;
|
|
309
|
+
removeNode(node: MockNode): void;
|
|
310
|
+
getParentNode(node: MockNode): MockNode | null;
|
|
311
|
+
getNextSibling(node: MockNode): MockNode | null;
|
|
312
|
+
getFirstChild(node: MockNode): MockNode | null;
|
|
313
|
+
addClass(element: MockElement, className: string): void;
|
|
314
|
+
removeClass(element: MockElement, className: string): void;
|
|
315
|
+
setStyle(element: MockElement, prop: string, value: any): void;
|
|
316
|
+
getStyle(element: MockElement, prop: string): any;
|
|
317
|
+
setProperty(element: MockElement, prop: string, value: any): void;
|
|
318
|
+
getProperty(element: MockElement, prop: string): any;
|
|
319
|
+
addEventListener(element: MockNode, event: string, handler: Function, options?: any): void;
|
|
320
|
+
removeEventListener(element: MockNode, event: string, handler: Function, options?: any): void;
|
|
321
|
+
setTextContent(node: MockNode, text: string): void;
|
|
322
|
+
getTextContent(node: MockNode): string;
|
|
323
|
+
isNode(value: any): boolean;
|
|
324
|
+
isElement(value: any): boolean;
|
|
325
|
+
queueMicrotask(fn: () => void): void;
|
|
326
|
+
setTimeout(fn: () => void, ms: number): number;
|
|
327
|
+
clearTimeout(id: number): void;
|
|
328
|
+
getTagName(element: MockElement): string;
|
|
329
|
+
getInputType(element: MockElement): string | undefined;
|
|
330
|
+
|
|
331
|
+
/** Get the mock document body for inspection */
|
|
332
|
+
getBody(): MockElement;
|
|
333
|
+
|
|
334
|
+
/** Reset the mock DOM state */
|
|
335
|
+
reset(): void;
|
|
336
|
+
|
|
337
|
+
/** Flush all pending microtasks (synchronously for testing) */
|
|
338
|
+
flushMicrotasks(): void;
|
|
339
|
+
|
|
340
|
+
/** Run all pending timeouts (synchronously for testing) */
|
|
341
|
+
runAllTimers(): void;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ============================================================================
|
|
345
|
+
// Enhanced Mock Classes
|
|
346
|
+
// ============================================================================
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Mock Canvas 2D rendering context for color parsing in a11y tests.
|
|
350
|
+
*/
|
|
351
|
+
export declare class MockCanvasContext {
|
|
352
|
+
fillStyle: string;
|
|
353
|
+
|
|
354
|
+
fillRect(x: number, y: number, width: number, height: number): void;
|
|
355
|
+
getImageData(x: number, y: number, width: number, height: number): { data: Uint8ClampedArray };
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Mock MediaQueryList for matchMedia() testing.
|
|
360
|
+
*/
|
|
361
|
+
export declare class MockMediaQueryList {
|
|
362
|
+
constructor(query: string, matches?: boolean);
|
|
363
|
+
|
|
364
|
+
/** The media query string */
|
|
365
|
+
media: string;
|
|
366
|
+
|
|
367
|
+
/** Whether the query currently matches */
|
|
368
|
+
matches: boolean;
|
|
369
|
+
|
|
370
|
+
addEventListener(event: string, listener: Function): void;
|
|
371
|
+
removeEventListener(event: string, listener: Function): void;
|
|
372
|
+
|
|
373
|
+
/** @deprecated Use addEventListener instead */
|
|
374
|
+
addListener(listener: Function): void;
|
|
375
|
+
|
|
376
|
+
/** @deprecated Use removeEventListener instead */
|
|
377
|
+
removeListener(listener: Function): void;
|
|
378
|
+
|
|
379
|
+
/** Simulate a media query change (for testing) */
|
|
380
|
+
_setMatches(matches: boolean): void;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Mock MutationObserver for DOM change tracking.
|
|
385
|
+
*/
|
|
386
|
+
export declare class MockMutationObserver {
|
|
387
|
+
constructor(callback: (mutations: any[], observer: MockMutationObserver) => void);
|
|
388
|
+
|
|
389
|
+
observe(target: any, options?: any): void;
|
|
390
|
+
disconnect(): void;
|
|
391
|
+
takeRecords(): any[];
|
|
392
|
+
|
|
393
|
+
/** Simulate a mutation (for testing) */
|
|
394
|
+
_trigger(mutations: any[]): void;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Mock Performance API.
|
|
399
|
+
*/
|
|
400
|
+
export declare class MockPerformance {
|
|
401
|
+
now(): number;
|
|
402
|
+
mark(name: string): void;
|
|
403
|
+
measure(name: string, startMark: string, endMark?: string): void;
|
|
404
|
+
getEntriesByName(name: string): Array<{ name: string; duration: number; startTime: number }>;
|
|
405
|
+
clearMarks(name?: string): void;
|
|
406
|
+
clearMeasures(name?: string): void;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Mock computed style object.
|
|
411
|
+
*/
|
|
412
|
+
export declare class MockCSSStyleDeclaration {
|
|
413
|
+
constructor(styles?: Record<string, string>);
|
|
414
|
+
|
|
415
|
+
display: string;
|
|
416
|
+
visibility: string;
|
|
417
|
+
color: string;
|
|
418
|
+
backgroundColor: string;
|
|
419
|
+
fontSize: string;
|
|
420
|
+
fontWeight: string;
|
|
421
|
+
position: string;
|
|
422
|
+
width: string;
|
|
423
|
+
height: string;
|
|
424
|
+
[property: string]: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** MockWindow constructor options */
|
|
428
|
+
export interface MockWindowOptions {
|
|
429
|
+
mediaQueryResults?: Record<string, boolean>;
|
|
430
|
+
innerWidth?: number;
|
|
431
|
+
innerHeight?: number;
|
|
432
|
+
locationHref?: string;
|
|
433
|
+
locationPathname?: string;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Mock Window object for global browser APIs.
|
|
438
|
+
*/
|
|
439
|
+
export declare class MockWindow {
|
|
440
|
+
constructor(options?: MockWindowOptions);
|
|
441
|
+
|
|
442
|
+
innerWidth: number;
|
|
443
|
+
innerHeight: number;
|
|
444
|
+
location: {
|
|
445
|
+
href: string;
|
|
446
|
+
pathname: string;
|
|
447
|
+
search: string;
|
|
448
|
+
hash: string;
|
|
449
|
+
};
|
|
450
|
+
performance: MockPerformance;
|
|
451
|
+
|
|
452
|
+
matchMedia(query: string): MockMediaQueryList;
|
|
453
|
+
|
|
454
|
+
/** Set media query result (for testing) */
|
|
455
|
+
setMediaQueryResult(query: string, matches: boolean): void;
|
|
456
|
+
|
|
457
|
+
requestAnimationFrame(callback: (time: number) => void): number;
|
|
458
|
+
cancelAnimationFrame(id: number): void;
|
|
459
|
+
|
|
460
|
+
/** Run all pending animation frame callbacks (for testing) */
|
|
461
|
+
flushAnimationFrames(): void;
|
|
462
|
+
|
|
463
|
+
addEventListener(event: string, handler: Function, options?: any): void;
|
|
464
|
+
removeEventListener(event: string, handler: Function, options?: any): void;
|
|
465
|
+
dispatchEvent(event: { type: string; [key: string]: any }): void;
|
|
466
|
+
|
|
467
|
+
getComputedStyle(element: any): MockCSSStyleDeclaration;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Enhanced MockElement with additional browser APIs.
|
|
472
|
+
*/
|
|
473
|
+
export declare class EnhancedMockElement extends MockElement {
|
|
474
|
+
constructor(tagName: string);
|
|
475
|
+
|
|
476
|
+
hidden: boolean;
|
|
477
|
+
inert: boolean;
|
|
478
|
+
labels: any[];
|
|
479
|
+
offsetParent: any;
|
|
480
|
+
|
|
481
|
+
getBoundingClientRect(): {
|
|
482
|
+
top: number;
|
|
483
|
+
left: number;
|
|
484
|
+
width: number;
|
|
485
|
+
height: number;
|
|
486
|
+
right: number;
|
|
487
|
+
bottom: number;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
/** Set bounding rect (for testing) */
|
|
491
|
+
setBoundingRect(rect: Partial<{
|
|
492
|
+
top: number;
|
|
493
|
+
left: number;
|
|
494
|
+
width: number;
|
|
495
|
+
height: number;
|
|
496
|
+
right: number;
|
|
497
|
+
bottom: number;
|
|
498
|
+
}>): void;
|
|
499
|
+
|
|
500
|
+
/** Set computed style (for testing) */
|
|
501
|
+
setComputedStyle(styles: Record<string, string>): void;
|
|
502
|
+
|
|
503
|
+
getContext(contextType: '2d'): MockCanvasContext | null;
|
|
504
|
+
getContext(contextType: string): any | null;
|
|
505
|
+
|
|
506
|
+
focus(): void;
|
|
507
|
+
blur(): void;
|
|
508
|
+
contains(other: any): boolean;
|
|
509
|
+
closest(selector: string): EnhancedMockElement | null;
|
|
510
|
+
querySelectorAll(selector: string): EnhancedMockElement[];
|
|
511
|
+
querySelector(selector: string): EnhancedMockElement | null;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Enhanced Mock DOM Adapter with full browser API simulation.
|
|
516
|
+
* Provides comprehensive testing support for a11y, devtools, and other
|
|
517
|
+
* browser-dependent modules.
|
|
518
|
+
*/
|
|
519
|
+
export declare class EnhancedMockAdapter extends MockDOMAdapter {
|
|
520
|
+
constructor(options?: MockWindowOptions);
|
|
521
|
+
|
|
522
|
+
/** MutationObserver constructor */
|
|
523
|
+
MutationObserver: typeof MockMutationObserver;
|
|
524
|
+
|
|
525
|
+
createElement(tagName: string): EnhancedMockElement;
|
|
526
|
+
|
|
527
|
+
/** Get computed style for an element */
|
|
528
|
+
getComputedStyle(element: any): MockCSSStyleDeclaration;
|
|
529
|
+
|
|
530
|
+
/** Get the mock window object */
|
|
531
|
+
getWindow(): MockWindow;
|
|
532
|
+
|
|
533
|
+
/** Request animation frame */
|
|
534
|
+
requestAnimationFrame(callback: (time: number) => void): number;
|
|
535
|
+
|
|
536
|
+
/** Cancel animation frame */
|
|
537
|
+
cancelAnimationFrame(id: number): void;
|
|
538
|
+
|
|
539
|
+
/** Get performance API */
|
|
540
|
+
getPerformance(): MockPerformance;
|
|
541
|
+
|
|
542
|
+
/** Match media query */
|
|
543
|
+
matchMedia(query: string): MockMediaQueryList;
|
|
544
|
+
|
|
545
|
+
/** Create a MutationObserver */
|
|
546
|
+
createMutationObserver(callback: (mutations: any[], observer: MockMutationObserver) => void): MockMutationObserver;
|
|
547
|
+
|
|
548
|
+
/** Get document element (html) */
|
|
549
|
+
getDocumentElement(): MockElement;
|
|
550
|
+
|
|
551
|
+
/** Get active element */
|
|
552
|
+
getActiveElement(): MockElement | null;
|
|
553
|
+
|
|
554
|
+
/** Set active element (for testing) */
|
|
555
|
+
setActiveElement(element: MockElement | null): void;
|
|
556
|
+
|
|
557
|
+
/** Get element by ID */
|
|
558
|
+
getElementById(id: string): MockElement | null;
|
|
559
|
+
|
|
560
|
+
/** Set media query result (for testing user preferences) */
|
|
561
|
+
setMediaQueryResult(query: string, matches: boolean): void;
|
|
562
|
+
|
|
563
|
+
/** Run all pending animation frames (for testing) */
|
|
564
|
+
flushAnimationFrames(): void;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Install global mocks for browser testing.
|
|
568
|
+
* Installs mocks on globalThis for modules that directly access browser APIs.
|
|
569
|
+
* @returns Cleanup function to restore original globals
|
|
570
|
+
*/
|
|
571
|
+
installGlobalMocks(): () => void;
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// ============================================================================
|
|
575
|
+
// Global Adapter Management
|
|
576
|
+
// ============================================================================
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Get the currently active DOM adapter.
|
|
580
|
+
* Lazily initializes BrowserDOMAdapter if in browser environment.
|
|
581
|
+
*
|
|
582
|
+
* @throws {Error} If no adapter is set and not in browser environment
|
|
583
|
+
*/
|
|
584
|
+
export declare function getAdapter(): DOMAdapter;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Set the active DOM adapter.
|
|
588
|
+
* Use this to configure SSR, testing, or custom rendering targets.
|
|
589
|
+
*
|
|
590
|
+
* @example
|
|
591
|
+
* ```typescript
|
|
592
|
+
* import { setAdapter, MockDOMAdapter } from 'pulse-js-framework/runtime/dom-adapter';
|
|
593
|
+
* setAdapter(new MockDOMAdapter());
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
596
|
+
export declare function setAdapter(adapter: DOMAdapter): void;
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Reset the adapter to browser default (or null in non-browser).
|
|
600
|
+
* Useful for cleanup after tests.
|
|
601
|
+
*/
|
|
602
|
+
export declare function resetAdapter(): void;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Run a function with a temporary DOM adapter.
|
|
606
|
+
* The previous adapter is restored after the function completes.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* const result = withAdapter(new MockDOMAdapter(), () => {
|
|
611
|
+
* return el('div.test', 'Hello');
|
|
612
|
+
* });
|
|
613
|
+
* ```
|
|
614
|
+
*/
|
|
615
|
+
export declare function withAdapter<T>(adapter: DOMAdapter, fn: () => T): T;
|
|
616
|
+
|
|
617
|
+
// ============================================================================
|
|
618
|
+
// Default Export
|
|
619
|
+
// ============================================================================
|
|
620
|
+
|
|
621
|
+
declare const _default: {
|
|
622
|
+
BrowserDOMAdapter: typeof BrowserDOMAdapter;
|
|
623
|
+
MockDOMAdapter: typeof MockDOMAdapter;
|
|
624
|
+
EnhancedMockAdapter: typeof EnhancedMockAdapter;
|
|
625
|
+
MockNode: typeof MockNode;
|
|
626
|
+
MockElement: typeof MockElement;
|
|
627
|
+
EnhancedMockElement: typeof EnhancedMockElement;
|
|
628
|
+
MockTextNode: typeof MockTextNode;
|
|
629
|
+
MockCommentNode: typeof MockCommentNode;
|
|
630
|
+
MockDocumentFragment: typeof MockDocumentFragment;
|
|
631
|
+
MockCanvasContext: typeof MockCanvasContext;
|
|
632
|
+
MockMediaQueryList: typeof MockMediaQueryList;
|
|
633
|
+
MockMutationObserver: typeof MockMutationObserver;
|
|
634
|
+
MockPerformance: typeof MockPerformance;
|
|
635
|
+
MockCSSStyleDeclaration: typeof MockCSSStyleDeclaration;
|
|
636
|
+
MockWindow: typeof MockWindow;
|
|
637
|
+
getAdapter: typeof getAdapter;
|
|
638
|
+
setAdapter: typeof setAdapter;
|
|
639
|
+
resetAdapter: typeof resetAdapter;
|
|
640
|
+
withAdapter: typeof withAdapter;
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
export default _default;
|
package/types/dom.d.ts
CHANGED
|
@@ -286,3 +286,66 @@ export declare function whenTransition(
|
|
|
286
286
|
elseTemplate?: ConditionTemplate,
|
|
287
287
|
options?: WhenTransitionOptions
|
|
288
288
|
): DocumentFragment;
|
|
289
|
+
|
|
290
|
+
// =============================================================================
|
|
291
|
+
// DOM Configuration
|
|
292
|
+
// =============================================================================
|
|
293
|
+
|
|
294
|
+
/** DOM configuration options */
|
|
295
|
+
export interface DomConfig {
|
|
296
|
+
selectorCacheCapacity?: number;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Configure DOM options (selector cache capacity, etc.)
|
|
301
|
+
*/
|
|
302
|
+
export declare function configureDom(config: DomConfig): void;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Get current DOM configuration
|
|
306
|
+
*/
|
|
307
|
+
export declare function getDomConfig(): DomConfig;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Clear the selector cache
|
|
311
|
+
*/
|
|
312
|
+
export declare function clearSelectorCache(): void;
|
|
313
|
+
|
|
314
|
+
/** Cache metrics */
|
|
315
|
+
export interface CacheMetrics {
|
|
316
|
+
hitRate: number;
|
|
317
|
+
size: number;
|
|
318
|
+
capacity: number;
|
|
319
|
+
hits?: number;
|
|
320
|
+
misses?: number;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Get selector cache performance metrics
|
|
325
|
+
*/
|
|
326
|
+
export declare function getCacheMetrics(): CacheMetrics;
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Reset cache metrics counters
|
|
330
|
+
*/
|
|
331
|
+
export declare function resetCacheMetrics(): void;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Resolve a CSS selector to element configuration
|
|
335
|
+
*/
|
|
336
|
+
export declare function resolveSelector(selector: string): ParsedSelector;
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Configure auto-ARIA behavior
|
|
340
|
+
*/
|
|
341
|
+
export declare function configureA11y(options: {
|
|
342
|
+
enabled?: boolean;
|
|
343
|
+
autoAria?: boolean;
|
|
344
|
+
warnMissingAlt?: boolean;
|
|
345
|
+
warnMissingLabel?: boolean;
|
|
346
|
+
}): void;
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Compute the Longest Increasing Subsequence (used internally by list())
|
|
350
|
+
*/
|
|
351
|
+
export declare function computeLIS(arr: number[]): number[];
|