@dinoreic/fez 0.4.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +723 -198
- package/bin/fez +16 -6
- package/bin/fez-compile +347 -0
- package/bin/fez-debug +25 -0
- package/bin/fez-index +16 -4
- package/bin/refactor +699 -0
- package/dist/fez.js +142 -33
- package/dist/fez.js.map +4 -4
- package/fez.d.ts +533 -0
- package/package.json +25 -15
- package/src/fez/compile.js +396 -164
- package/src/fez/connect.js +250 -143
- package/src/fez/defaults.js +275 -84
- package/src/fez/instance.js +673 -514
- package/src/fez/lib/await-helper.js +64 -0
- package/src/fez/lib/global-state.js +22 -4
- package/src/fez/lib/index.js +140 -0
- package/src/fez/lib/localstorage.js +44 -0
- package/src/fez/lib/n.js +38 -23
- package/src/fez/lib/pubsub.js +208 -0
- package/src/fez/lib/svelte-template-lib.js +339 -0
- package/src/fez/lib/svelte-template.js +472 -0
- package/src/fez/lib/template.js +114 -119
- package/src/fez/morph.js +384 -0
- package/src/fez/root.js +284 -164
- package/src/fez/utility.js +319 -149
- package/src/fez/utils/dump.js +114 -84
- package/src/fez/utils/highlight_all.js +1 -1
- package/src/fez.js +65 -43
- package/src/rollup.js +1 -1
- package/src/svelte-cde-adapter.coffee +21 -12
- package/src/fez/vendor/idiomorph.js +0 -860
package/fez.d.ts
ADDED
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fez - TypeScript Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* This file provides type information for the Fez framework.
|
|
5
|
+
* Import: `import { Fez, FezBase } from '@dinoreic/fez'`
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// UTILITY TYPES
|
|
10
|
+
// =============================================================================
|
|
11
|
+
|
|
12
|
+
/** Reactive state proxy that triggers re-renders on property changes */
|
|
13
|
+
type ReactiveState<T = Record<string, any>> = T;
|
|
14
|
+
|
|
15
|
+
/** Global state proxy for cross-component communication */
|
|
16
|
+
type GlobalState = Record<string, any>;
|
|
17
|
+
|
|
18
|
+
/** Component props (always strings from HTML attributes) */
|
|
19
|
+
type ComponentProps = Record<string, string>;
|
|
20
|
+
|
|
21
|
+
/** Evaluated props (when using :prop syntax) */
|
|
22
|
+
type EvaluatedProps = Record<string, any>;
|
|
23
|
+
|
|
24
|
+
// =============================================================================
|
|
25
|
+
// LIFECYCLE HOOK TYPES
|
|
26
|
+
// =============================================================================
|
|
27
|
+
|
|
28
|
+
/** Called when fez element is connected to DOM, before first render */
|
|
29
|
+
type InitHook = (props: ComponentProps & EvaluatedProps) => void;
|
|
30
|
+
|
|
31
|
+
/** Execute after init and first render */
|
|
32
|
+
type OnMountHook = (props: ComponentProps & EvaluatedProps) => void;
|
|
33
|
+
|
|
34
|
+
/** Execute before every render - use for reactive computed state */
|
|
35
|
+
type BeforeRenderHook = () => void;
|
|
36
|
+
|
|
37
|
+
/** Execute after every render */
|
|
38
|
+
type AfterRenderHook = () => void;
|
|
39
|
+
|
|
40
|
+
/** Monitor new or changed node attributes */
|
|
41
|
+
type OnPropsChangeHook = (attrName: string, attrValue: string) => void;
|
|
42
|
+
|
|
43
|
+
/** Called when local component state changes */
|
|
44
|
+
type OnStateChangeHook = (key: string, value: any, oldValue: any) => void;
|
|
45
|
+
|
|
46
|
+
/** Called when global state changes */
|
|
47
|
+
type OnGlobalStateChangeHook = (key: string, value: any) => void;
|
|
48
|
+
|
|
49
|
+
/** Called when component is destroyed */
|
|
50
|
+
type OnDestroyHook = () => void;
|
|
51
|
+
|
|
52
|
+
// =============================================================================
|
|
53
|
+
// COMPONENT CONFIGURATION
|
|
54
|
+
// =============================================================================
|
|
55
|
+
|
|
56
|
+
interface FezComponentConfig {
|
|
57
|
+
/** Set element node name (defaults to 'div') */
|
|
58
|
+
NAME?: string | ((node: HTMLElement) => string);
|
|
59
|
+
|
|
60
|
+
/** Static alternative - use static nodeName = 'span' */
|
|
61
|
+
static?: {
|
|
62
|
+
nodeName?: string;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** Component CSS styles (SCSS syntax) */
|
|
66
|
+
CSS?: string | (() => string);
|
|
67
|
+
|
|
68
|
+
/** Component HTML template */
|
|
69
|
+
HTML?: string | (() => string);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Control rendering timing to prevent flicker
|
|
73
|
+
* - true: renders immediately in main loop (no flicker)
|
|
74
|
+
* - false/undefined: renders in next animation frame (may flicker)
|
|
75
|
+
*/
|
|
76
|
+
FAST?: boolean | ((node: HTMLElement) => boolean);
|
|
77
|
+
|
|
78
|
+
/** Make component globally accessible as window[name] */
|
|
79
|
+
GLOBAL?: string | boolean;
|
|
80
|
+
|
|
81
|
+
/** Component metadata */
|
|
82
|
+
META?: Record<string, any>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// =============================================================================
|
|
86
|
+
// FezBase CLASS
|
|
87
|
+
// =============================================================================
|
|
88
|
+
|
|
89
|
+
/** Base class for all Fez components */
|
|
90
|
+
declare abstract class FezBase {
|
|
91
|
+
// ===================================================================
|
|
92
|
+
// LIFECYCLE HOOKS (override as needed)
|
|
93
|
+
// ===================================================================
|
|
94
|
+
|
|
95
|
+
/** Called when fez element is connected to DOM, before first render */
|
|
96
|
+
init?(props: ComponentProps & EvaluatedProps): void;
|
|
97
|
+
|
|
98
|
+
/** Execute after init and first render */
|
|
99
|
+
onMount?(props: ComponentProps & EvaluatedProps): void;
|
|
100
|
+
|
|
101
|
+
/** Execute before every render - use for reactive computed state */
|
|
102
|
+
beforeRender?(): void;
|
|
103
|
+
|
|
104
|
+
/** Execute after every render */
|
|
105
|
+
afterRender?(): void;
|
|
106
|
+
|
|
107
|
+
/** Monitor new or changed node attributes */
|
|
108
|
+
onPropsChange?(attrName: string, attrValue: string): void;
|
|
109
|
+
|
|
110
|
+
/** Called when local component state changes */
|
|
111
|
+
onStateChange?(key: string, value: any, oldValue: any): void;
|
|
112
|
+
|
|
113
|
+
/** Called when global state changes */
|
|
114
|
+
onGlobalStateChange?(key: string, value: any): void;
|
|
115
|
+
|
|
116
|
+
/** Called when component is destroyed */
|
|
117
|
+
onDestroy?(): void;
|
|
118
|
+
|
|
119
|
+
// ===================================================================
|
|
120
|
+
// COMPONENT STATE
|
|
121
|
+
// ===================================================================
|
|
122
|
+
|
|
123
|
+
/** Reactive local state - changes trigger re-renders */
|
|
124
|
+
state: ReactiveState;
|
|
125
|
+
|
|
126
|
+
/** Global state proxy - shared across components */
|
|
127
|
+
globalState: GlobalState;
|
|
128
|
+
|
|
129
|
+
/** Component props from HTML attributes */
|
|
130
|
+
props: ComponentProps & EvaluatedProps;
|
|
131
|
+
|
|
132
|
+
/** Unique component instance ID */
|
|
133
|
+
UID: number;
|
|
134
|
+
|
|
135
|
+
/** Component tag name (e.g., 'ui-button') */
|
|
136
|
+
fezName: string;
|
|
137
|
+
|
|
138
|
+
/** Root DOM element */
|
|
139
|
+
root: HTMLElement;
|
|
140
|
+
|
|
141
|
+
// ===================================================================
|
|
142
|
+
// DOM HELPERS
|
|
143
|
+
// ===================================================================
|
|
144
|
+
|
|
145
|
+
/** Find element by selector within component */
|
|
146
|
+
find<T extends HTMLElement = HTMLElement>(selector: string): T | null;
|
|
147
|
+
|
|
148
|
+
/** Get or set root element attribute */
|
|
149
|
+
attr(name: string): string | null;
|
|
150
|
+
attr(name: string, value: string): void;
|
|
151
|
+
|
|
152
|
+
/** Get or set node value (input/textarea/select or innerHTML) */
|
|
153
|
+
val(selector: string | HTMLElement): any;
|
|
154
|
+
val(selector: string | HTMLElement, value: any): void;
|
|
155
|
+
|
|
156
|
+
/** Add classes to root or given node */
|
|
157
|
+
addClass(names: string, node?: HTMLElement): void;
|
|
158
|
+
|
|
159
|
+
/** Toggle a class on root or given node */
|
|
160
|
+
toggleClass(name: string, force?: boolean, node?: HTMLElement): void;
|
|
161
|
+
|
|
162
|
+
/** Set CSS properties on root */
|
|
163
|
+
setStyle(key: string | Record<string, string>, value?: string): void;
|
|
164
|
+
|
|
165
|
+
/** Copy props as attributes to root */
|
|
166
|
+
copy(...names: string[]): void;
|
|
167
|
+
|
|
168
|
+
/** Get or set root ID */
|
|
169
|
+
rootId(): string;
|
|
170
|
+
|
|
171
|
+
/** Get root element children as array */
|
|
172
|
+
childNodes(): HTMLElement[];
|
|
173
|
+
childNodes<T>(func: (node: HTMLElement) => T): T[];
|
|
174
|
+
childNodes(asObject: true): Array<{
|
|
175
|
+
html: string;
|
|
176
|
+
ROOT: HTMLElement;
|
|
177
|
+
[attr: string]: any;
|
|
178
|
+
}>;
|
|
179
|
+
|
|
180
|
+
/** Dissolve component into parent */
|
|
181
|
+
dissolve(inNode?: HTMLElement): HTMLElement[];
|
|
182
|
+
|
|
183
|
+
/** Get form data from closest/child form */
|
|
184
|
+
formData(node?: HTMLElement): Record<string, string>;
|
|
185
|
+
|
|
186
|
+
/** Check if component is attached to DOM */
|
|
187
|
+
readonly isConnected: boolean;
|
|
188
|
+
|
|
189
|
+
/** Get single node property */
|
|
190
|
+
prop<T = any>(name: string): T;
|
|
191
|
+
|
|
192
|
+
// ===================================================================
|
|
193
|
+
// RENDERING
|
|
194
|
+
// ===================================================================
|
|
195
|
+
|
|
196
|
+
/** Force a re-render on next frame */
|
|
197
|
+
fezRefresh(): void;
|
|
198
|
+
|
|
199
|
+
/** Alias for fezRefresh */
|
|
200
|
+
refresh(): void;
|
|
201
|
+
|
|
202
|
+
/** Render the component template to DOM */
|
|
203
|
+
fezRender(template?: string | Function | Node[]): void;
|
|
204
|
+
|
|
205
|
+
/** Parse HTML and replace fez. references */
|
|
206
|
+
fezParseHtml(text: string): string;
|
|
207
|
+
|
|
208
|
+
/** Schedule work on next animation frame (debounced by name) */
|
|
209
|
+
fezNextTick(func: () => void, name?: string): void;
|
|
210
|
+
|
|
211
|
+
// ===================================================================
|
|
212
|
+
// EVENT HANDLERS
|
|
213
|
+
// ===================================================================
|
|
214
|
+
|
|
215
|
+
/** Add window event listener with auto-cleanup */
|
|
216
|
+
on(eventName: string, func: () => void, delay?: number): void;
|
|
217
|
+
|
|
218
|
+
/** Window resize handler with auto-cleanup */
|
|
219
|
+
onWindowResize(func: () => void, delay?: number): void;
|
|
220
|
+
|
|
221
|
+
/** Window scroll handler with auto-cleanup */
|
|
222
|
+
onWindowScroll(func: () => void, delay?: number): void;
|
|
223
|
+
|
|
224
|
+
/** Element resize handler using ResizeObserver */
|
|
225
|
+
onElementResize(el: HTMLElement, func: () => void, delay?: number): void;
|
|
226
|
+
|
|
227
|
+
/** Timeout with auto-cleanup */
|
|
228
|
+
setTimeout(func: () => void, delay: number): number;
|
|
229
|
+
|
|
230
|
+
/** Interval with auto-cleanup */
|
|
231
|
+
setInterval(func: () => void, tick: number, name?: string): number;
|
|
232
|
+
|
|
233
|
+
// ===================================================================
|
|
234
|
+
// PUB/SUB
|
|
235
|
+
// ===================================================================
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Publish to parent components (bubbles up through DOM)
|
|
239
|
+
* @returns True if a parent handled the event
|
|
240
|
+
*/
|
|
241
|
+
publish(channel: string, ...args: any[]): boolean;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Subscribe to a channel (auto-cleanup on destroy)
|
|
245
|
+
* @returns Unsubscribe function
|
|
246
|
+
*/
|
|
247
|
+
subscribe(channel: string, func: (...args: any[]) => void): () => void;
|
|
248
|
+
|
|
249
|
+
// ===================================================================
|
|
250
|
+
// SLOTS
|
|
251
|
+
// ===================================================================
|
|
252
|
+
|
|
253
|
+
/** Copy child nodes natively to preserve bound events */
|
|
254
|
+
fezSlot(source: HTMLElement, target?: HTMLElement): HTMLElement;
|
|
255
|
+
|
|
256
|
+
// ===================================================================
|
|
257
|
+
// INTERNAL PROPERTIES
|
|
258
|
+
// ===================================================================
|
|
259
|
+
|
|
260
|
+
/** Store for passing values to child components (e.g., loop vars) */
|
|
261
|
+
fezGlobals: {
|
|
262
|
+
set(value: any): number;
|
|
263
|
+
delete(key: number): any;
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
/** Block template functions */
|
|
267
|
+
fezBlocks: Record<string, Function>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// =============================================================================
|
|
271
|
+
// Fez STATIC API
|
|
272
|
+
// =============================================================================
|
|
273
|
+
|
|
274
|
+
/** Main Fez function - register or find components */
|
|
275
|
+
interface FezStatic {
|
|
276
|
+
// ===================================================================
|
|
277
|
+
// COMPONENT REGISTRATION & LOOKUP
|
|
278
|
+
// ===================================================================
|
|
279
|
+
|
|
280
|
+
/** Register a component */
|
|
281
|
+
(name: string, klass: typeof FezBase | Function): void;
|
|
282
|
+
|
|
283
|
+
/** Find component by UID */
|
|
284
|
+
(uid: number): FezBase | undefined;
|
|
285
|
+
|
|
286
|
+
/** Find component by DOM node or selector */
|
|
287
|
+
(name: string | Node): FezBase | undefined;
|
|
288
|
+
|
|
289
|
+
/** Find all components of name and execute callback */
|
|
290
|
+
(name: string, callback: (fez: FezBase) => void): FezBase[];
|
|
291
|
+
|
|
292
|
+
/** Find with selector context */
|
|
293
|
+
(name: string, selector: string | Node): FezBase | undefined;
|
|
294
|
+
|
|
295
|
+
// ===================================================================
|
|
296
|
+
// COMPONENT INDEX
|
|
297
|
+
// ===================================================================
|
|
298
|
+
|
|
299
|
+
/** Unified component index */
|
|
300
|
+
index: {
|
|
301
|
+
/** Get component by name */
|
|
302
|
+
[name: string]: {
|
|
303
|
+
class?: typeof FezBase;
|
|
304
|
+
meta?: Record<string, any>;
|
|
305
|
+
demo?: string | HTMLElement;
|
|
306
|
+
info?: string | HTMLElement;
|
|
307
|
+
source?: string;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/** Get component data object */
|
|
311
|
+
get(name: string): {
|
|
312
|
+
class?: typeof FezBase;
|
|
313
|
+
meta?: Record<string, any>;
|
|
314
|
+
demo?: HTMLElement;
|
|
315
|
+
info?: HTMLElement;
|
|
316
|
+
source?: string;
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
/** Render demo into element and execute scripts */
|
|
320
|
+
apply(name: string, el: HTMLElement): void;
|
|
321
|
+
|
|
322
|
+
/** Get all component names */
|
|
323
|
+
names(): string[];
|
|
324
|
+
|
|
325
|
+
/** Get component names that have demos */
|
|
326
|
+
withDemo(): string[];
|
|
327
|
+
|
|
328
|
+
/** Get all components */
|
|
329
|
+
all(): Record<string, any>;
|
|
330
|
+
|
|
331
|
+
/** Log all component names to console */
|
|
332
|
+
info(): void;
|
|
333
|
+
|
|
334
|
+
/** Ensure entry exists for component */
|
|
335
|
+
ensure(name: string): Record<string, any>;
|
|
336
|
+
};
|
|
337
|
+
|
|
338
|
+
// ===================================================================
|
|
339
|
+
// COMPONENT INSTANCES
|
|
340
|
+
// ===================================================================
|
|
341
|
+
|
|
342
|
+
/** Counter for unique instance IDs */
|
|
343
|
+
instanceCount: number;
|
|
344
|
+
|
|
345
|
+
/** Active component instances by UID */
|
|
346
|
+
instances: Map<number, FezBase>;
|
|
347
|
+
|
|
348
|
+
/** Find a component instance from a DOM node */
|
|
349
|
+
find(onode: Node | string, name?: string): FezBase | undefined;
|
|
350
|
+
|
|
351
|
+
// ===================================================================
|
|
352
|
+
// CSS UTILITIES
|
|
353
|
+
// ===================================================================
|
|
354
|
+
|
|
355
|
+
/** Generate unique CSS class from CSS text */
|
|
356
|
+
cssClass(text: string): string;
|
|
357
|
+
|
|
358
|
+
/** Register global CSS styles */
|
|
359
|
+
globalCss(cssClass: string | Function, opts?: { name?: string; wrap?: boolean }): string;
|
|
360
|
+
|
|
361
|
+
/** Define custom CSS shortcuts */
|
|
362
|
+
cssMixin(name: string, value: string): void;
|
|
363
|
+
|
|
364
|
+
/** Add global SCSS styles */
|
|
365
|
+
globalCss(scss: string): void;
|
|
366
|
+
|
|
367
|
+
// ===================================================================
|
|
368
|
+
// DOM UTILITIES
|
|
369
|
+
// ===================================================================
|
|
370
|
+
|
|
371
|
+
/** Get DOM node containing passed HTML */
|
|
372
|
+
domRoot(htmlData: string | HTMLElement): HTMLElement;
|
|
373
|
+
|
|
374
|
+
/** Activate node by adding class and removing from siblings */
|
|
375
|
+
activateNode(node: HTMLElement, className?: string): void;
|
|
376
|
+
|
|
377
|
+
/** Morph DOM node to new state */
|
|
378
|
+
morphdom(target: Element, newNode: Element, opts?: {
|
|
379
|
+
skipNode?: (oldNode: Element) => boolean;
|
|
380
|
+
beforeRemove?: (node: Element) => void;
|
|
381
|
+
}): void;
|
|
382
|
+
|
|
383
|
+
/** Create template render function */
|
|
384
|
+
createTemplate(text: string, opts?: { name: string }): Function;
|
|
385
|
+
|
|
386
|
+
// ===================================================================
|
|
387
|
+
// FETCH & DATA
|
|
388
|
+
// ===================================================================
|
|
389
|
+
|
|
390
|
+
/** Built-in fetch with caching */
|
|
391
|
+
fetch(url: string, callback?: (data: any) => void): Promise<any>;
|
|
392
|
+
|
|
393
|
+
/** Local storage with JSON serialization */
|
|
394
|
+
localStorage: {
|
|
395
|
+
set(key: string, value: any): void;
|
|
396
|
+
get<T = any>(key: string, defaultValue?: T): T;
|
|
397
|
+
remove(key: string): void;
|
|
398
|
+
clear(): void;
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// ===================================================================
|
|
402
|
+
// PUB/SUB
|
|
403
|
+
// ===================================================================
|
|
404
|
+
|
|
405
|
+
/** Subscribe globally to a channel */
|
|
406
|
+
subscribe(channel: string, callback: (...args: any[]) => void): () => void;
|
|
407
|
+
subscribe(nodeOrSelector: Node | string, channel: string, callback: (...args: any[]) => void): () => void;
|
|
408
|
+
|
|
409
|
+
/** Publish globally to a channel */
|
|
410
|
+
publish(channel: string, ...args: any[]): void;
|
|
411
|
+
|
|
412
|
+
// ===================================================================
|
|
413
|
+
// GLOBAL STATE
|
|
414
|
+
// ===================================================================
|
|
415
|
+
|
|
416
|
+
/** Global reactive state management */
|
|
417
|
+
state: {
|
|
418
|
+
/** Get global state value */
|
|
419
|
+
get(key: string): any;
|
|
420
|
+
|
|
421
|
+
/** Set global state value */
|
|
422
|
+
set(key: string, value: any): void;
|
|
423
|
+
|
|
424
|
+
/** Subscribe to specific key changes */
|
|
425
|
+
subscribe(key: string, callback: (value: any, oldValue: any) => void): () => void;
|
|
426
|
+
|
|
427
|
+
/** Subscribe to ALL state changes */
|
|
428
|
+
subscribe(callback: (key: string, value: any, oldValue: any) => void): () => void;
|
|
429
|
+
|
|
430
|
+
/** Iterate over components using a specific state key */
|
|
431
|
+
forEach(key: string, callback: (fez: FezBase) => void): void;
|
|
432
|
+
|
|
433
|
+
/** Create state proxy for component */
|
|
434
|
+
createProxy(component: FezBase): GlobalState;
|
|
435
|
+
};
|
|
436
|
+
|
|
437
|
+
// ===================================================================
|
|
438
|
+
// UTILITIES
|
|
439
|
+
// ===================================================================
|
|
440
|
+
|
|
441
|
+
/** Get unique ID for a string */
|
|
442
|
+
fnv1(str: string): string;
|
|
443
|
+
|
|
444
|
+
/** Resolve a function from string or function reference */
|
|
445
|
+
getFunction(value: string | Function, context?: any): Function;
|
|
446
|
+
|
|
447
|
+
/** Check if value is truthy (from props) */
|
|
448
|
+
isTrue(value: any): boolean;
|
|
449
|
+
|
|
450
|
+
/** Get type short identifier */
|
|
451
|
+
typeof(value: any): 'o' | 'f' | 's' | 'a' | 'i' | 'n' | 'u';
|
|
452
|
+
|
|
453
|
+
/** Convert collection to pairs */
|
|
454
|
+
toPairs(obj: any[]): Array<[any, number]>;
|
|
455
|
+
toPairs(obj: Record<string, any>): Array<[string, any]>;
|
|
456
|
+
toPairs(obj: null | undefined): [];
|
|
457
|
+
|
|
458
|
+
/** Throttle function execution */
|
|
459
|
+
throttle(func: Function, delay: number): Function;
|
|
460
|
+
|
|
461
|
+
/** Execute callback when DOM is ready */
|
|
462
|
+
onReady(callback: Function): void;
|
|
463
|
+
|
|
464
|
+
/** Add utilities to Fez object */
|
|
465
|
+
addUtilities(obj: Record<string, Function>): void;
|
|
466
|
+
|
|
467
|
+
// ===================================================================
|
|
468
|
+
// COMPONENT COMPILATION
|
|
469
|
+
// ===================================================================
|
|
470
|
+
|
|
471
|
+
/** Compile Fez component from template/xmp/script */
|
|
472
|
+
compile(tagName?: string | Node, html?: string): void;
|
|
473
|
+
|
|
474
|
+
// ===================================================================
|
|
475
|
+
// LOGGING & ERROR HANDLING
|
|
476
|
+
// ===================================================================
|
|
477
|
+
|
|
478
|
+
/** Enable framework logging */
|
|
479
|
+
LOG?: boolean;
|
|
480
|
+
|
|
481
|
+
/** Enable development mode */
|
|
482
|
+
DEV?: boolean;
|
|
483
|
+
|
|
484
|
+
/** Log message (only if LOG enabled) */
|
|
485
|
+
consoleLog(text: string): void;
|
|
486
|
+
|
|
487
|
+
/** Error message */
|
|
488
|
+
consoleError(text: string, show?: boolean): string;
|
|
489
|
+
|
|
490
|
+
/** Error handler - can be overridden */
|
|
491
|
+
onError(kind: string, message: string | Error, context?: Record<string, any>): string;
|
|
492
|
+
|
|
493
|
+
/** Log component information */
|
|
494
|
+
info(): void;
|
|
495
|
+
|
|
496
|
+
/** Highlight all fez components */
|
|
497
|
+
highlightAll(): void;
|
|
498
|
+
|
|
499
|
+
// ===================================================================
|
|
500
|
+
// ASYNC HELPERS
|
|
501
|
+
// ===================================================================
|
|
502
|
+
|
|
503
|
+
/** Async/await helper for promises in templates */
|
|
504
|
+
fezAwait(promise: Promise<any>, handlers: {
|
|
505
|
+
pending?: Function;
|
|
506
|
+
then?: Function;
|
|
507
|
+
catch?: Function;
|
|
508
|
+
}): any;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// =============================================================================
|
|
512
|
+
// GLOBAL DECLARATIONS
|
|
513
|
+
// =============================================================================
|
|
514
|
+
|
|
515
|
+
declare global {
|
|
516
|
+
/** Global Fez object */
|
|
517
|
+
const Fez: FezStatic;
|
|
518
|
+
|
|
519
|
+
/** FezBase class */
|
|
520
|
+
const FezBase: typeof FezBase;
|
|
521
|
+
|
|
522
|
+
interface HTMLElement {
|
|
523
|
+
/** Fez instance attached to element */
|
|
524
|
+
fez?: FezBase;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// =============================================================================
|
|
529
|
+
// EXPORTS
|
|
530
|
+
// =============================================================================
|
|
531
|
+
|
|
532
|
+
export { FezBase };
|
|
533
|
+
export default FezStatic;
|
package/package.json
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dinoreic/fez",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Runtime custom DOM elements lib",
|
|
5
5
|
"main": "dist/fez.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"types": "fez.d.ts",
|
|
7
8
|
"exports": {
|
|
8
9
|
".": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
},
|
|
12
|
-
"./rollup": {
|
|
13
|
-
"import": "./src/rollup.js",
|
|
14
|
-
"require": "./src/rollup.js"
|
|
15
|
-
},
|
|
16
|
-
"./log": {
|
|
17
|
-
"import": "./src/log.js",
|
|
18
|
-
"require": "./src/log.js"
|
|
10
|
+
"types": "./fez.d.ts",
|
|
11
|
+
"import": "./dist/fez.js"
|
|
19
12
|
},
|
|
13
|
+
"./rollup": "./src/rollup.js",
|
|
14
|
+
"./log": "./src/log.js",
|
|
15
|
+
"./svelte": "./src/svelte-cde-adapter.coffee",
|
|
20
16
|
"./package.json": "./package.json"
|
|
21
17
|
},
|
|
22
18
|
"bin": {
|
|
23
|
-
"fez": "bin/fez"
|
|
19
|
+
"fez": "bin/fez",
|
|
20
|
+
"fez-compile": "bin/fez-compile",
|
|
21
|
+
"fez-index": "bin/fez-index"
|
|
24
22
|
},
|
|
25
23
|
"files": [
|
|
26
24
|
"bin",
|
|
27
25
|
"dist",
|
|
28
26
|
"src",
|
|
27
|
+
"fez.d.ts",
|
|
29
28
|
"README.md",
|
|
30
29
|
"LICENSE"
|
|
31
30
|
],
|
|
@@ -51,10 +50,12 @@
|
|
|
51
50
|
"concurrently": "^9.1.2",
|
|
52
51
|
"esbuild": "0.23.0",
|
|
53
52
|
"esbuild-coffeescript": "^2.2.0",
|
|
53
|
+
"eslint": "^8.57.0",
|
|
54
54
|
"glob-cli": "^1.0.0",
|
|
55
55
|
"happy-dom": "^18.0.1",
|
|
56
56
|
"jsdom": "^26.1.0",
|
|
57
|
-
"mime": "^4.0.7"
|
|
57
|
+
"mime": "^4.0.7",
|
|
58
|
+
"playwright": "^1.57.0"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
61
|
"build": "bun build.js b",
|
|
@@ -62,9 +63,18 @@
|
|
|
62
63
|
"watch": "bun build.js w",
|
|
63
64
|
"server": "bun run lib/server.js",
|
|
64
65
|
"dev": "bunx concurrently --kill-others \"bun run server\" \"find src demo lib | entr -cn sh -c 'bun run index && bun run b'\"",
|
|
65
|
-
"
|
|
66
|
+
"lint": "eslint src/**/*.js",
|
|
67
|
+
"lint:fix": "eslint src/**/*.js --fix",
|
|
68
|
+
"format": "prettier --write \"src/**/*.js\"",
|
|
69
|
+
"format:check": "prettier --check \"src/**/*.js\"",
|
|
70
|
+
"test": "bun test test/*.test.js && bun test test/browser/*.test.js",
|
|
71
|
+
"test:coverage": "bun test --coverage",
|
|
66
72
|
"prepublishOnly": "bun run build && bun run test",
|
|
67
73
|
"publish": "npm publish --access public",
|
|
68
|
-
"index": "
|
|
74
|
+
"index": "ls demo/fez/*.fez | xargs -n1 basename | sed 's/\\.fez$//' | sort | sed 's/^/fez\\//' > demo/fez.txt"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"glob": "^13.0.0",
|
|
78
|
+
"prettier": "^3.8.1"
|
|
69
79
|
}
|
|
70
80
|
}
|