@domyjs/domy 1.0.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.
@@ -0,0 +1,944 @@
1
+ type AppState = {
2
+ isSetuped: boolean;
3
+ isMounted: boolean;
4
+ isUnmounted: boolean;
5
+ };
6
+ type App = () => Record<string, unknown> | void;
7
+ type State = {
8
+ data: Record<string, unknown>;
9
+ componentInfos?: ComponentInfos;
10
+ refs: Record<string, Element>;
11
+ };
12
+ declare namespace ReactiveUtils {
13
+ /* eslint @typescript-eslint/no-this-alias: "off" */
14
+ type Listener = OnGetListener | OnSetListener;
15
+ type OnGetListener = {
16
+ type: "onGet";
17
+ fn: (props: {
18
+ reactiveVariable: ReactiveVariable;
19
+ path: string;
20
+ }) => void;
21
+ };
22
+ type OnSetListener = {
23
+ type: "onSet";
24
+ fn: (props: {
25
+ reactiveVariable: ReactiveVariable;
26
+ path: string;
27
+ prevValue: any;
28
+ newValue: any;
29
+ }) => void | Promise<void>;
30
+ };
31
+ const isProxySymbol: unique symbol;
32
+ const isSignalSymbol: unique symbol;
33
+ const skipReactivitySymbol: unique symbol;
34
+ /**
35
+ * Allow to create a DeepProxy to listen to any change into an object
36
+ * @author yoannchb-pro
37
+ */
38
+ class ReactiveVariable {
39
+ private target;
40
+ name: string;
41
+ private proxy;
42
+ private onSetListeners;
43
+ private onGetListeners;
44
+ static IS_GLOBAL_LOCK: boolean;
45
+ constructor(target: any);
46
+ getProxy(): any;
47
+ /**
48
+ * Check if the current target is already a proxy
49
+ * @param target
50
+ * @returns
51
+ */
52
+ static isReactive(target: any): boolean;
53
+ /**
54
+ * Check if the current target is a signal instead of a reactive
55
+ * @param target
56
+ * @returns
57
+ */
58
+ static isSignal(target: any): boolean;
59
+ /**
60
+ * Check we should skip the reactivity on the current element
61
+ * @param target
62
+ * @returns
63
+ */
64
+ static shouldBeSkip(target: any): boolean;
65
+ clearListeners(): void;
66
+ attachListener(l: Listener): () => void;
67
+ removeListener(l: Listener): void;
68
+ private canAttachProxy;
69
+ private isCollection;
70
+ private createCollectionHandler;
71
+ private createHandler;
72
+ private createProxy;
73
+ private callOnGetListeners;
74
+ private callOnSetListeners;
75
+ }
76
+ /**
77
+ * Attach a listener to all reactive variables
78
+ * @param listener
79
+ *
80
+ * @author yoannchb-pro
81
+ */
82
+ function globalWatch(listener: Listener, tracking?: boolean): () => void;
83
+ /**
84
+ * Will return true if a obj is a signal/reactive
85
+ * @param obj
86
+ * @returns
87
+ *
88
+ * @author yoannchb-pro
89
+ */
90
+ function isReactive(obj: any): boolean;
91
+ /**
92
+ * Will return true if the obj is a signal
93
+ * @param obj
94
+ * @returns
95
+ *
96
+ * @author yoannchb-pro
97
+ */
98
+ function isSignal(obj: any): boolean;
99
+ type MatchingResult = {
100
+ isMatching: boolean;
101
+ params: Record<string, string>;
102
+ };
103
+ /**
104
+ * Check if a path match a certain rule
105
+ * Example:
106
+ * path: todos.0.isComplete
107
+ * reg: todos.*.isComplete or todos, todos.* or todos.*.*
108
+ * Will give true
109
+ * reg: todos.1.isComplete, todos.*.name, todos.*.*.id
110
+ * Will give false
111
+ * @param reg
112
+ * @param path
113
+ * @returns
114
+ *
115
+ * @author yoannchb-pro
116
+ */
117
+ function matchPath(reg: string, path: string): MatchingResult;
118
+ /**
119
+ * Transform an object into a reactive object to listen to any change
120
+ * @param obj
121
+ * @returns
122
+ *
123
+ * @author yoannchb-pro
124
+ */
125
+ function reactive<T>(obj: T): T;
126
+ /**
127
+ * Register a name for a reactive variable
128
+ * It allow us to have a correct path name
129
+ * Example of use case:
130
+ * cont count = signal(0);
131
+ * watch(({ path }) => console.log(path), [count]);
132
+ * count.value += 1;
133
+ *
134
+ * The path is going to be "value" instead of "count.value" because we don't know the variable name
135
+ * So to fixe that we just need to put registerName("count", count) after the variable declaration
136
+ * @param name
137
+ * @param obj
138
+ * @returns
139
+ *
140
+ * @author yoannchb-pro
141
+ */
142
+ function registerName(name: string, obj: any): void;
143
+ /**
144
+ * Transform a primitive into a reactive object to listen to any change
145
+ * @param obj
146
+ * @returns
147
+ *
148
+ * @author yoannchb-pro
149
+ */
150
+ function signal<T>(obj: T): {
151
+ value: T;
152
+ };
153
+ /**
154
+ * Attach a listener to some reactives variables
155
+ * @param listener
156
+ * @param effect
157
+ *
158
+ * @author yoannchb-pro
159
+ */
160
+ function watch(listener: Listener, effect: () => any): () => void;
161
+ /**
162
+ * Allow us to lock every watcher if we need to do a set/get action on the object without calling the watcher
163
+ *
164
+ * @author yoannchb-pro
165
+ */
166
+ function lockWatchers(): void;
167
+ /**
168
+ * Unlock every watchers
169
+ *
170
+ * @author yoannchb-pro
171
+ */
172
+ function unlockWatchers(): void;
173
+ /**
174
+ * Will delete the reactivity of a data
175
+ * @param obj
176
+ * @returns
177
+ *
178
+ * @author yoannchb-pro
179
+ */
180
+ function unReactive<T = any>(obj: T): T;
181
+ /**
182
+ * Skip the reactivity on an element we don't wanna listen to in a reactivity variable
183
+ * Example:
184
+ * const myElement = reactive({ el: skipReactive({ ... }), name: 'div' })
185
+ * @param obj
186
+ * @returns
187
+ *
188
+ * @author yoannchb-pro
189
+ */
190
+ function skipReactive<T = any>(obj: T): T;
191
+ type Effect = () => any;
192
+ type UnEffect = () => void;
193
+ type WatchEffectOptions = {
194
+ noSelfUpdate?: boolean; // Avoid the effect to launch the function again
195
+ onDepChange?: (uneffect: UnEffect) => void;
196
+ };
197
+ /**
198
+ * Act like a watcher but get his dependencies it self by running one time the instance
199
+ * Example:
200
+ * const todo = reactive({ title: "Yoann", isCompleted: false });
201
+ * const uneffect = watchEffect(() => console.log(todo.title)); // Will display: "Yoann" when initialising
202
+ * todo.isCompleted = true; // Don't call the effect
203
+ * todo.title = "Pierre"; // Will call the effect and display "Pierre"
204
+ * @param effectFn
205
+ *
206
+ * @author yoannchb-pro
207
+ */
208
+ function watchEffect(effect: Effect, opts?: WatchEffectOptions): UnEffect;
209
+ type Dep = {
210
+ type: "reactive_variable_creation";
211
+ reactiveVariable: ReactiveVariable;
212
+ clean: () => void;
213
+ } | {
214
+ type: "watcher" | "effect" | "global_watcher";
215
+ clean: () => void;
216
+ };
217
+ let trackCallback: ((dep: Dep) => void) | null;
218
+ /**
219
+ * Allow us to track inside a function:
220
+ * - reactive variable (signal + reactive)
221
+ * - watcher
222
+ * - effects
223
+ * - global watchers
224
+ * @param fn
225
+ * @returns
226
+ *
227
+ * @author yoannchb-pro
228
+ */
229
+ function trackDeps(fn: () => any): Dep[];
230
+ const isComputedSymbol: unique symbol;
231
+ /**
232
+ * Will return a boolean determining if an object is a computed value or not
233
+ * @param obj
234
+ * @returns
235
+ *
236
+ * @author yoannchb-pro
237
+ */
238
+ function isComputed(obj: any): boolean;
239
+ /**
240
+ * Create a computed variable based on a signal
241
+ * Example:
242
+ * const count = signal(1);
243
+ * const doubleCount = computed(() => count.value * 2);
244
+ * console.log(doubleCount); // 2
245
+ * @param getter
246
+ * @param setter
247
+ * @returns
248
+ *
249
+ * @author yoannchb-pro
250
+ */
251
+ function computed<T extends () => unknown, R extends ReturnType<T>>(getter: () => R, setter?: (newValue: R) => void): {
252
+ [isComputedSymbol]: boolean;
253
+ value: R;
254
+ };
255
+ }
256
+ type Config = {
257
+ avoidDeprecatedWith?: boolean;
258
+ CSP?: boolean;
259
+ };
260
+ type Props = {
261
+ domyHelperId?: number;
262
+ el?: Element | Text;
263
+ state: State;
264
+ scopedNodeData: Record<string, any>[];
265
+ config: Config;
266
+ pluginHelper: PluginHelper;
267
+ };
268
+ /**
269
+ * Return a context with all what domy need to render
270
+ * Like variables, methods, helpers ...
271
+ * @param el
272
+ * @param state
273
+ * @param scopedNodeData
274
+ * @returns
275
+ *
276
+ * @author yoannchb-pro
277
+ */
278
+ declare function getContext(props: Props): {
279
+ [x: `$${string}`]: any;
280
+ };
281
+ type QueueElement = () => any;
282
+ /**
283
+ * Scheduler function to add a job to the queue
284
+ * @param job
285
+ *
286
+ * @author yoannchb-pro
287
+ */
288
+ declare function queueJob(job: QueueElement, id: number): void;
289
+ /**
290
+ * Return an unique queue id
291
+ * @returns
292
+ *
293
+ * @author yoannchb-pro
294
+ */
295
+ declare function getUniqueQueueId(): number;
296
+ /**
297
+ * Call a function with error handling
298
+ * @param fn
299
+ * @returns
300
+ *
301
+ * @author yoannchb-pro
302
+ */
303
+ declare function callWithErrorHandling<T extends (...args: any[]) => any>(fn: T, onError?: (err: any) => void): {
304
+ hasError: true;
305
+ err: any;
306
+ } | {
307
+ hasError: false;
308
+ result: ReturnType<T>;
309
+ };
310
+ /**
311
+ * Fixe an attribute name to avoid setAttribute throwing error
312
+ * @param attrName
313
+ * @returns
314
+ *
315
+ * @author yoannchb-pro
316
+ */
317
+ declare function fixeAttrName(attrName: string): string;
318
+ /**
319
+ * Retrieve some utils informations from a domy attribute
320
+ * @param attr
321
+ * @returns
322
+ *
323
+ * @author yoannchb-pro
324
+ */
325
+ declare function getDomyAttributeInformations(attr: Attr): {
326
+ prefix: string;
327
+ directive: string;
328
+ modifiers: string[];
329
+ attrName: string;
330
+ };
331
+ /**
332
+ * Execute a function after the animation/transition on an element is finish
333
+ * @param el
334
+ * @param action
335
+ * @returns
336
+ *
337
+ * @author yoannchb-pro
338
+ */
339
+ declare function executeActionAfterAnimation(el: Element, action: () => void): () => void;
340
+ /**
341
+ * Get function (like get in lodash)
342
+ * @param object
343
+ * @param path
344
+ * @param defaultValue
345
+ * @returns
346
+ *
347
+ * @author yoannchb-pro
348
+ */
349
+ declare function get<T = any>(object: Array<any> | Record<string, any>, path: string, defaultValue?: any): T | undefined;
350
+ /**
351
+ * Set function (like set in lodash)
352
+ * @param object
353
+ * @param path
354
+ * @param value
355
+ * @returns
356
+ *
357
+ * @author yoannchb-pro
358
+ */
359
+ declare function set<T>(object: T, path: string, value: any): T;
360
+ type Props$0 = {
361
+ shouldBeDisplay: () => boolean;
362
+ domy: DomyDirectiveHelper;
363
+ };
364
+ /**
365
+ * Handle the visibility of an element with the transition
366
+ * @param props
367
+ * @returns
368
+ *
369
+ * @author yoannchb-pro
370
+ */
371
+ declare function getElementVisibilityHandler(props: Props$0): {
372
+ effect: () => void;
373
+ cleanup: () => void;
374
+ };
375
+ /**
376
+ * Return the list of previous conditions elements before an element
377
+ * Useful for d-else and d-else-if directives
378
+ * @param element
379
+ * @param previousAuthorizedAttrs
380
+ * @returns
381
+ *
382
+ * @author yoannchb-pro
383
+ */
384
+ declare function getPreviousConditionsElements(element: HTMLElement, previousAuthorizedAttrs: string[]): Element[];
385
+ /**
386
+ * Return the get and set method for a reactive variable
387
+ * It allow us to keep the proxy and to handle signals
388
+ * @param obj
389
+ * @param key
390
+ * @returns
391
+ *
392
+ * @author yoannchb-pro
393
+ */
394
+ declare function getReactiveHandler(obj: Record<string, any>, key: string): PropertyDescriptor;
395
+ /**
396
+ * Handle class attribute if it's a string or an object like
397
+ * { show: true }
398
+ * or
399
+ * ["show"]
400
+ * @param executedValue
401
+ * @param defaultClass
402
+ *
403
+ * @author yoannchb-pro
404
+ */
405
+ declare function handleClass(executedValue: any, defaultClass?: string): {
406
+ class: string;
407
+ cleanedClass: (newDefaultClass: string) => string;
408
+ };
409
+ /**
410
+ * Handle style attribute if it's an object
411
+ * { backgroundColor: '#fff', color: 'red' .... }
412
+ * @param executedValue
413
+ * @param defaultStyle
414
+ *
415
+ * @author yoannchb-pro
416
+ */
417
+ declare function handleStyle(executedValue: any, defaultStyle?: string): {
418
+ style: string;
419
+ cleanedStyle: (newDefaultStyle: string) => string;
420
+ };
421
+ /**
422
+ * Check if the current attribute is a binding attribute
423
+ * @param attr
424
+ * @returns
425
+ *
426
+ * @author yoannchb-pro
427
+ */
428
+ declare function isBindAttr(attr: string): boolean;
429
+ /**
430
+ * Check if the current attribute is an event attribute
431
+ * @param attr
432
+ * @returns
433
+ *
434
+ * @author yoannchb-pro
435
+ */
436
+ declare function isEventAttr(attr: string): boolean;
437
+ declare function isDNameAttr(attr: string): boolean;
438
+ /**
439
+ * Check if the current attribute is a domy attribute
440
+ * It could be a prefix like d-on:click
441
+ * Or it could be a simple attribute like d-for
442
+ * @param attr
443
+ * @returns
444
+ *
445
+ * @author yoannchb-pro
446
+ */
447
+ declare function isDomyAttr(PLUGINS: Plugins, attr: string): boolean;
448
+ /**
449
+ * Check if the current attribute is a normal attribute
450
+ * @param attr
451
+ * @returns
452
+ *
453
+ * @author yoannchb-pro
454
+ */
455
+ declare function isNormalAttr(PLUGINS: Plugins, attr: string): boolean;
456
+ /**
457
+ * Convert a kebab string into a camelCase string
458
+ * Example: show-error -> showError
459
+ * @param str
460
+ * @returns
461
+ *
462
+ * @author yoannchb-pro
463
+ */
464
+ declare function kebabToCamelCase(str: string): string;
465
+ /**
466
+ * Warn log function for domy
467
+ * @param msg
468
+ *
469
+ * @author yoannchb-pro
470
+ */
471
+ declare function warn(msg: string): void;
472
+ /**
473
+ * Error log function for domy
474
+ * @param err
475
+ *
476
+ * @author yoannchb-pro
477
+ */
478
+ declare function error(...errs: (Error | string)[]): void;
479
+ /**
480
+ * Allow us to merge conditions for d-else and d-else-if
481
+ * @param conditions
482
+ * @returns
483
+ *
484
+ * @author yoannchb-pro
485
+ */
486
+ declare function mergeToNegativeCondition(conditions: string[]): string;
487
+ /**
488
+ * Convert a string to kebab case
489
+ * Example:
490
+ * console.log(toKebabCase('HelloWorld')); // hello-world
491
+ * console.log(toKebabCase('myVariableName')); // my-variable-name
492
+ * console.log(toKebabCase('Hello World Today')); // hello-world-today
493
+ * @param str
494
+ * @returns
495
+ *
496
+ * @author yoannchb-pro
497
+ */
498
+ declare function toKebabCase(str: string): string;
499
+ // A list of utils we can access in helpers
500
+ declare const helpersUtils: {
501
+ handleClass: typeof handleClass;
502
+ handleStyle: typeof handleStyle;
503
+ callWithErrorHandling: typeof callWithErrorHandling;
504
+ toKebabCase: typeof toKebabCase;
505
+ kebabToCamelCase: typeof kebabToCamelCase;
506
+ getElementVisibilityHandler: typeof getElementVisibilityHandler;
507
+ get: typeof get;
508
+ set: typeof set;
509
+ getPreviousConditionsElements: typeof getPreviousConditionsElements;
510
+ executeActionAfterAnimation: typeof executeActionAfterAnimation;
511
+ getReactiveHandler: typeof getReactiveHandler;
512
+ mergeToNegativeCondition: typeof mergeToNegativeCondition;
513
+ fixeAttrName: typeof fixeAttrName;
514
+ getDomyAttributeInformations: typeof getDomyAttributeInformations;
515
+ isDomyAttr: typeof isDomyAttr;
516
+ isNormalAttr: typeof isNormalAttr;
517
+ isEventAttr: typeof isEventAttr;
518
+ isBindAttr: typeof isBindAttr;
519
+ isDNameAttr: typeof isDNameAttr;
520
+ warn: typeof warn;
521
+ error: typeof error;
522
+ };
523
+ type Helpers = Record<`$${string}`, any>;
524
+ type Props$1 = {
525
+ domyHelperId?: number;
526
+ el?: Element | Text;
527
+ state: State;
528
+ config: Config;
529
+ scopedNodeData: Record<string, any>[];
530
+ pluginHelper: PluginHelper;
531
+ };
532
+ /**
533
+ * Return the initialised helpers with everything it need
534
+ * @param el
535
+ * @param state
536
+ * @param scopedNodeData
537
+ * @returns
538
+ *
539
+ * @author yoannchb-pro
540
+ */
541
+ declare function getHelpers(props: Props$1): Helpers;
542
+ type Options = {
543
+ dontQueueOnFirstExecution?: boolean;
544
+ effectId?: number;
545
+ };
546
+ /**
547
+ * Allow to queue an effect
548
+ * @param effect
549
+ * @param opts
550
+ *
551
+ * @author yoannchb-pro
552
+ */
553
+ declare function queuedWatchEffect(effect: () => any, opts?: Options): () => void;
554
+ // A list of utils we can access in directives/prefix
555
+ declare const directivesUtils: {
556
+ getHelpers: typeof getHelpers;
557
+ queuedWatchEffect: typeof queuedWatchEffect;
558
+ handleClass: typeof handleClass;
559
+ handleStyle: typeof handleStyle;
560
+ callWithErrorHandling: typeof callWithErrorHandling;
561
+ toKebabCase: typeof toKebabCase;
562
+ kebabToCamelCase: typeof kebabToCamelCase;
563
+ getElementVisibilityHandler: typeof getElementVisibilityHandler;
564
+ get: typeof get;
565
+ set: typeof set;
566
+ getPreviousConditionsElements: typeof getPreviousConditionsElements;
567
+ executeActionAfterAnimation: typeof executeActionAfterAnimation;
568
+ getReactiveHandler: typeof getReactiveHandler;
569
+ mergeToNegativeCondition: typeof mergeToNegativeCondition;
570
+ fixeAttrName: typeof fixeAttrName;
571
+ getDomyAttributeInformations: typeof getDomyAttributeInformations;
572
+ isDomyAttr: typeof isDomyAttr;
573
+ isNormalAttr: typeof isNormalAttr;
574
+ isEventAttr: typeof isEventAttr;
575
+ isBindAttr: typeof isBindAttr;
576
+ isDNameAttr: typeof isDNameAttr;
577
+ warn: typeof warn;
578
+ error: typeof error;
579
+ };
580
+ type Observer = {
581
+ type: keyof AppState;
582
+ callback: () => void;
583
+ };
584
+ /**
585
+ * Register the current lifecycle state of the current app
586
+ *
587
+ * @author yoannchb-pro
588
+ */
589
+ declare class AppStateObserver {
590
+ private observers;
591
+ private appState;
592
+ get isMounted(): boolean;
593
+ get isSetuped(): boolean;
594
+ get isUnmounted(): boolean;
595
+ set isMounted(newValue: boolean);
596
+ set isSetuped(newValue: boolean);
597
+ set isUnmounted(newValue: boolean);
598
+ private callObservers;
599
+ addObserver(observer: Observer): () => void;
600
+ removeObserver(observer: Observer): void;
601
+ }
602
+ type Transition = {
603
+ enterTransition: string;
604
+ enterTransitionTo: string;
605
+ outTransition: string;
606
+ outTransitionTo: string;
607
+ init: boolean;
608
+ };
609
+ type TransitionType = "enterTransition" | "outTransition";
610
+ /**
611
+ * Utilitary class to handle properly an element
612
+ */
613
+ declare class Block {
614
+ private element;
615
+ name: string | null;
616
+ key: string | null;
617
+ private pluginsData;
618
+ transition: Transition | null;
619
+ private cleanupTransition;
620
+ private cleanups;
621
+ private onElChangeCbList;
622
+ parentBlock: Block | null;
623
+ constructor(element: Element | Block);
624
+ getDataForPluginId(pluginId: string): any;
625
+ setDataForPluginId(pluginId: string, data: any): void;
626
+ cleanTransition(): void;
627
+ private callCbForElementChange;
628
+ createNewElementBlock(): Block;
629
+ attachListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
630
+ onElementChange(cb: (newEl: Element) => void): void;
631
+ setEl(newEl: Element | Block): void;
632
+ getEl(): Element;
633
+ applyTransition(transitionType: TransitionType, action?: () => void): void;
634
+ replaceWith(newEl: Element | Block): void;
635
+ remove(): void;
636
+ isTemplate(): boolean;
637
+ isTextNode(): boolean;
638
+ addCleanup(cleanup: () => void): void;
639
+ unmount(): void;
640
+ }
641
+ type Props$2 = {
642
+ element: Element | Block;
643
+ scopedNodeData: Record<string, any>[];
644
+ byPassAttributes?: string[];
645
+ skipChildRendering?: boolean;
646
+ renderWithoutListeningToChange?: boolean;
647
+ };
648
+ /**
649
+ * Deep render an element (with the childs and textContent)
650
+ * It will keep the config for all the specified target only
651
+ * @param config
652
+ *
653
+ * @author yoannchb-pro
654
+ */
655
+ declare function createDeepRenderFn(appId: number, appState: AppStateObserver, state: State, config: Config, components: Components, pluginHelper: PluginHelper): (props: Props$2) => Block;
656
+ type DomyDirectiveFn = (domy: DomyDirectiveHelper) => DomyDirectiveReturn;
657
+ type DomySpecialFn = (domy: DomySpecialHelper) => any;
658
+ type DomyDirectiveReturn = {
659
+ skipChildsRendering?: boolean;
660
+ skipOtherAttributesRendering?: boolean;
661
+ skipComponentRendering?: boolean;
662
+ } | void;
663
+ type DomySpecialHelper = {
664
+ domyHelperId?: number;
665
+ el?: Element | Text;
666
+ state: State;
667
+ scopedNodeData: Record<string, any>[];
668
+ config: Config;
669
+ utils: typeof helpersUtils;
670
+ } & typeof ReactiveUtils;
671
+ type DomyDirectiveHelper = {
672
+ domyHelperId: number;
673
+ pluginHelper: PluginHelper;
674
+ appState: AppStateObserver;
675
+ block: Block;
676
+ config: Config;
677
+ state: State;
678
+ scopedNodeData: Record<string, any>[];
679
+ prefix: string;
680
+ directive: string;
681
+ modifiers: string[];
682
+ attrName: string;
683
+ attr: {
684
+ name: string;
685
+ value: string;
686
+ };
687
+ utils: typeof directivesUtils;
688
+ onElementMounted(cb: () => void): void;
689
+ onAppMounted(cb: () => void): void;
690
+ getUniqueQueueId: typeof getUniqueQueueId;
691
+ queueJob: typeof queueJob;
692
+ effect(cb: () => void): (() => void) | void;
693
+ cleanup(cb: () => void): void;
694
+ evaluate(code: string, scope?: Record<string, any>): any;
695
+ deepRender: ReturnType<typeof createDeepRenderFn>;
696
+ addScopeToNode(obj: Record<string, any>): void;
697
+ removeScopeToNode(obj: Record<string, any>): void;
698
+ getContext: typeof getContext;
699
+ } & typeof ReactiveUtils;
700
+ type DomyPluginDefinition = {
701
+ prefix(name: string, fn: DomyDirectiveFn): void;
702
+ directive(name: string, fn: DomyDirectiveFn): void;
703
+ helper(name: string, fn: DomySpecialFn): void;
704
+ };
705
+ type DomyPlugin = (domy: DomyPluginDefinition) => void;
706
+ type PluginHelper = ReturnType<typeof createPluginRegistrer>;
707
+ type Plugins = {
708
+ prefixes: Record<string, DomyDirectiveFn>;
709
+ directives: Record<string, DomyDirectiveFn>;
710
+ helpers: Record<string, DomySpecialFn>;
711
+ };
712
+ /**
713
+ * Allow to register plugin for the current instance
714
+ * @returns
715
+ *
716
+ * @author yoannchb-pro
717
+ */
718
+ declare function createPluginRegistrer(): {
719
+ PLUGINS: Plugins;
720
+ plugin: (pluginMaker: DomyPlugin) => void;
721
+ };
722
+ type ComponentInfos = {
723
+ componentData: {
724
+ $props: {
725
+ [key: string]: any;
726
+ };
727
+ $attrs: {
728
+ [key: string]: string;
729
+ };
730
+ };
731
+ childrens: Element[];
732
+ names: {
733
+ [name: string]: Element | undefined;
734
+ };
735
+ parentPluginHelper: PluginHelper;
736
+ };
737
+ type Component = (props: {
738
+ name: string;
739
+ componentElement: HTMLElement;
740
+ domy: DomyDirectiveHelper;
741
+ }) => void | (() => Element);
742
+ type Components = {
743
+ [name: string]: Component;
744
+ };
745
+ type ComponentDefinition = {
746
+ html: string;
747
+ props?: string[];
748
+ app?: App;
749
+ components?: Components;
750
+ };
751
+ /**
752
+ * Get the render function after mounting a DOMY app
753
+ * It allow the user to append html element
754
+ * Example:
755
+ * const p = document.createElement('p');
756
+ * p.textContent = 'Count: {{ count }}';
757
+ * app.render(p);
758
+ * container.appendChild(p);
759
+ * @param deepRender
760
+ * @param state
761
+ * @returns
762
+ *
763
+ * @author yoannchb-pro
764
+ */
765
+ declare function getRender(deepRender: ReturnType<typeof createDeepRenderFn>): (element: Element) => Block;
766
+ /**
767
+ * Same as createAdvancedApp but the user can't inject data or methods
768
+ * @param appDefinition
769
+ * @returns
770
+ *
771
+ * @author yoannchb-pro
772
+ */
773
+ declare function createApp(appDefinition?: App): {
774
+ appId: number;
775
+ mount: (target?: HTMLElement) => {
776
+ render: ReturnType<typeof getRender>;
777
+ unmount: () => void;
778
+ };
779
+ configure: (c: Config) => {
780
+ plugins: (pluginsList: DomyPlugin[]) => {
781
+ components: (c: Components) => {
782
+ mount: (target?: HTMLElement) => {
783
+ render: ReturnType<typeof getRender>;
784
+ unmount: () => void;
785
+ };
786
+ };
787
+ mount: (target?: HTMLElement) => {
788
+ render: ReturnType<typeof getRender>;
789
+ unmount: () => void;
790
+ };
791
+ };
792
+ components: (c: Components) => {
793
+ mount: (target?: HTMLElement) => {
794
+ render: ReturnType<typeof getRender>;
795
+ unmount: () => void;
796
+ };
797
+ };
798
+ mount: (target?: HTMLElement) => {
799
+ render: ReturnType<typeof getRender>;
800
+ unmount: () => void;
801
+ };
802
+ };
803
+ components: (c: Components) => {
804
+ mount: (target?: HTMLElement) => {
805
+ render: ReturnType<typeof getRender>;
806
+ unmount: () => void;
807
+ };
808
+ };
809
+ plugins: (pluginsList: DomyPlugin[]) => {
810
+ components: (c: Components) => {
811
+ mount: (target?: HTMLElement) => {
812
+ render: ReturnType<typeof getRender>;
813
+ unmount: () => void;
814
+ };
815
+ };
816
+ mount: (target?: HTMLElement) => {
817
+ render: ReturnType<typeof getRender>;
818
+ unmount: () => void;
819
+ };
820
+ };
821
+ };
822
+ /**
823
+ * Allow the user to create component
824
+ * This function get the component without the directives which has already been rendered
825
+ * Example:
826
+ * createComponent({
827
+ * props: ['title'],
828
+ * html: `
829
+ * <div>
830
+ * <h1>{{ $props.title }}</h1>
831
+ * <p>Count: {{ count }}</p>
832
+ * <button @click="++count">+</button>
833
+ * <button @click="--count">-</button>
834
+ * </div>
835
+ * `,
836
+ * app(){
837
+ * const count = signal(0);
838
+ * return { count };
839
+ * }
840
+ * })
841
+ * @param componentDefinition
842
+ * @returns
843
+ *
844
+ * @author yoannchb-pro
845
+ */
846
+ declare function createComponent(componentDefinition: ComponentDefinition): Components[keyof Components];
847
+ /* eslint @typescript-eslint/no-this-alias: "off" */
848
+ type Listener = OnGetListener | OnSetListener;
849
+ type OnGetListener = {
850
+ type: "onGet";
851
+ fn: (props: {
852
+ reactiveVariable: ReactiveVariable;
853
+ path: string;
854
+ }) => void;
855
+ };
856
+ type OnSetListener = {
857
+ type: "onSet";
858
+ fn: (props: {
859
+ reactiveVariable: ReactiveVariable;
860
+ path: string;
861
+ prevValue: any;
862
+ newValue: any;
863
+ }) => void | Promise<void>;
864
+ };
865
+ /**
866
+ * Allow to create a DeepProxy to listen to any change into an object
867
+ * @author yoannchb-pro
868
+ */
869
+ declare class ReactiveVariable {
870
+ private target;
871
+ name: string;
872
+ private proxy;
873
+ private onSetListeners;
874
+ private onGetListeners;
875
+ static IS_GLOBAL_LOCK: boolean;
876
+ constructor(target: any);
877
+ getProxy(): any;
878
+ /**
879
+ * Check if the current target is already a proxy
880
+ * @param target
881
+ * @returns
882
+ */
883
+ static isReactive(target: any): boolean;
884
+ /**
885
+ * Check if the current target is a signal instead of a reactive
886
+ * @param target
887
+ * @returns
888
+ */
889
+ static isSignal(target: any): boolean;
890
+ /**
891
+ * Check we should skip the reactivity on the current element
892
+ * @param target
893
+ * @returns
894
+ */
895
+ static shouldBeSkip(target: any): boolean;
896
+ clearListeners(): void;
897
+ attachListener(l: Listener): () => void;
898
+ removeListener(l: Listener): void;
899
+ private canAttachProxy;
900
+ private isCollection;
901
+ private createCollectionHandler;
902
+ private createHandler;
903
+ private createProxy;
904
+ private callOnGetListeners;
905
+ private callOnSetListeners;
906
+ }
907
+ declare const DOMY$0: {
908
+ createApp: typeof createApp;
909
+ createComponent: typeof createComponent;
910
+ onSetuped: (cb: () => void | Promise<void>) => void;
911
+ onMounted: (cb: () => void | Promise<void>) => void;
912
+ onBeforeUnmount: (cb: () => void | Promise<void>) => void;
913
+ onUnmounted: (cb: () => void | Promise<void>) => void;
914
+ useAttrs: () => {
915
+ [key: string]: string;
916
+ } | undefined;
917
+ useProps: () => {
918
+ [key: string]: any;
919
+ } | undefined;
920
+ useChildrens: () => Element[] | undefined;
921
+ useConfig: () => Config;
922
+ useNames: () => {
923
+ [name: string]: Element | undefined;
924
+ } | undefined;
925
+ useRefs: () => {
926
+ [x: string]: Element;
927
+ };
928
+ nextTick: (cb?: () => void | Promise<void>) => Promise<unknown>;
929
+ watch: (listener: OnSetListener["fn"], effect: () => any) => () => void;
930
+ watchEffect: (effect: () => any) => () => void;
931
+ globalWatch: (listener: OnSetListener["fn"]) => () => void;
932
+ matchPath: typeof ReactiveUtils.matchPath;
933
+ signal: typeof ReactiveUtils.signal;
934
+ computed: typeof ReactiveUtils.computed;
935
+ skipReactive: typeof ReactiveUtils.skipReactive;
936
+ helperToHookRegistrer: {
937
+ getHook<T extends (domy: DomySpecialHelper) => any>(helper: T): () => ReturnType<T>;
938
+ provideHookMandatories(domyHelper: DomySpecialHelper): void;
939
+ clear(): void;
940
+ };
941
+ };
942
+
943
+ export { Block, DOMY$0 as DOMY, DOMY$0 as default };
944
+ export type { App, AppState, Component, ComponentDefinition, ComponentInfos, Components, Config, DomyDirectiveFn, DomyDirectiveHelper, DomyDirectiveReturn, DomyPlugin, DomyPluginDefinition, DomySpecialFn, DomySpecialHelper, Helpers, State };