cradova 3.7.10 → 3.7.12

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/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export * from "./primitives/functions.js";
3
3
  export * from "./primitives/dom-objects.js";
4
4
  export type { Func } from "./primitives/types.js";
5
5
  declare global {
6
- interface Function {
7
- cloneFunc(): () => HTMLElement;
8
- }
6
+ interface Function {
7
+ cloneFunc(): () => HTMLElement;
8
+ }
9
9
  }
package/dist/index.js CHANGED
@@ -411,11 +411,13 @@ class Signal {
411
411
  });
412
412
  return;
413
413
  }
414
- if (!isArrowFunc(comp) && comp.signals) {
415
- comp = toFuncNoRender(comp);
416
- } else {
417
- console.error(` ✘ Cradova err: ${String(comp)} is not a valid component or function`);
418
- return;
414
+ if (!comp.signals) {
415
+ if (!isArrowFunc(comp)) {
416
+ comp = toFuncNoRender(comp);
417
+ } else {
418
+ console.error(` ✘ Cradova err: ${String(comp)} is not a valid component or function`);
419
+ return;
420
+ }
419
421
  }
420
422
  if (comp.signals.get(eventName))
421
423
  return;
@@ -3,23 +3,25 @@ import type { browserPageType, CradovaPageType } from "./types.js";
3
3
  * Cradova event
4
4
  */
5
5
  export declare class cradovaEvent {
6
- /**
7
- * the events runs only once and removed to avoid duplication when added on the next rendering
8
- * these event are call and removed once when when a Function is rendered to the dom
9
- * @param callback
10
- */
11
- after_comp_is_mounted: Function[];
12
- /**
13
- * the events runs once after comps unmounts.
14
- * these event are called before a Function is rendered to the dom
15
- * @param callback
16
- */
17
- after_page_is_killed: Function[];
18
- /**
19
- * Dispatch any event
20
- * @param eventName
21
- */
22
- dispatchEvent(eventName: "after_comp_is_mounted" | "after_page_is_killed"): Promise<void>;
6
+ /**
7
+ * the events runs only once and removed to avoid duplication when added on the next rendering
8
+ * these event are call and removed once when when a Function is rendered to the dom
9
+ * @param callback
10
+ */
11
+ after_comp_is_mounted: Function[];
12
+ /**
13
+ * the events runs once after comps unmounts.
14
+ * these event are called before a Function is rendered to the dom
15
+ * @param callback
16
+ */
17
+ after_page_is_killed: Function[];
18
+ /**
19
+ * Dispatch any event
20
+ * @param eventName
21
+ */
22
+ dispatchEvent(
23
+ eventName: "after_comp_is_mounted" | "after_page_is_killed",
24
+ ): Promise<void>;
23
25
  }
24
26
  /**
25
27
  * Cradova Signal
@@ -32,51 +34,54 @@ export declare class cradovaEvent {
32
34
  * @constructor initial: Record<string, any>, props: {persist}
33
35
  */
34
36
  export declare class Signal<Type extends Record<string, any>> {
35
- private pn?;
36
- private subs;
37
- private listening_subs;
38
- pipe: Type;
39
- constructor(initial: Type, props?: {
40
- persistName?: string | undefined;
41
- });
42
- /**
43
- * Cradova Signal
44
- * ----
45
- * fires an action if available
46
- * @param key - string key of the action
47
- * @param data - data for the action
48
- */
49
- publish<T extends keyof Type>(eventName: T, data: Type[T]): void;
50
- /**
51
- * Cradova Signal
52
- * ----
53
- * fires actions if any available
54
- */
55
- batchPublish(events: Partial<Type>): void;
56
- /**
57
- * Cradova Signal
58
- * ----
59
- * subscribe to an event
60
- *
61
- * @param name of event.
62
- * @param Func component to bind to.
63
- */
64
- subscribe<T extends keyof Type>(eventName: T | T[], comp: any): void;
65
- /**
66
- * Cradova Signal
67
- * ----
68
- * subscribe an element to an event
69
- *
70
- * @param name(s) of event.
71
- * @param Func to bind to.
72
- */
73
- subscriber<T extends keyof Type>(eventName: T | T[], fn: (this: HTMLElement, data: Partial<Type>) => void): Signal<any>;
74
- /**
75
- * Cradova Signal
76
- * ----
77
- * clear the history on local storage
78
- */
79
- clearPersist(): void;
37
+ private pn?;
38
+ private subs;
39
+ private listening_subs;
40
+ pipe: Type;
41
+ constructor(initial: Type, props?: {
42
+ persistName?: string | undefined;
43
+ });
44
+ /**
45
+ * Cradova Signal
46
+ * ----
47
+ * fires an action if available
48
+ * @param key - string key of the action
49
+ * @param data - data for the action
50
+ */
51
+ publish<T extends keyof Type>(eventName: T, data: Type[T]): void;
52
+ /**
53
+ * Cradova Signal
54
+ * ----
55
+ * fires actions if any available
56
+ */
57
+ batchPublish(events: Partial<Type>): void;
58
+ /**
59
+ * Cradova Signal
60
+ * ----
61
+ * subscribe to an event
62
+ *
63
+ * @param name of event.
64
+ * @param Func component to bind to.
65
+ */
66
+ subscribe<T extends keyof Type>(eventName: T | T[], comp: any): void;
67
+ /**
68
+ * Cradova Signal
69
+ * ----
70
+ * subscribe an element to an event
71
+ *
72
+ * @param name(s) of event.
73
+ * @param Func to bind to.
74
+ */
75
+ subscriber<T extends keyof Type>(
76
+ eventName: T | T[],
77
+ fn: (this: HTMLElement, data: Partial<Type>) => void,
78
+ ): Signal<any>;
79
+ /**
80
+ * Cradova Signal
81
+ * ----
82
+ * clear the history on local storage
83
+ */
84
+ clearPersist(): void;
80
85
  }
81
86
  /**
82
87
  * Cradova Page
@@ -86,9 +91,9 @@ export declare class Signal<Type extends Record<string, any>> {
86
91
  * @param template
87
92
  */
88
93
  export declare class Page {
89
- constructor(pageParams: CradovaPageType);
90
- private _takeSnapShot;
91
- set onDeactivate(cb: () => Promise<void> | void);
94
+ constructor(pageParams: CradovaPageType);
95
+ private _takeSnapShot;
96
+ set onDeactivate(cb: () => Promise<void> | void);
92
97
  }
93
98
  /** cradova router
94
99
  * ---
@@ -98,63 +103,67 @@ export declare class Page {
98
103
  * @param page the cradova document tree for the route.
99
104
  */
100
105
  export declare class Router {
101
- /**
102
- * cradova router
103
- * ---
104
- * Registers a route.
105
- *
106
- * accepts an object containing pat and page
107
- */
108
- static BrowserRoutes(obj: Record<string, browserPageType<Page | unknown>>): void;
109
- /**
106
+ /**
107
+ * cradova router
108
+ * ---
109
+ * Registers a route.
110
+ *
111
+ * accepts an object containing pat and page
112
+ */
113
+ static BrowserRoutes(
114
+ obj: Record<string, browserPageType<Page | unknown>>,
115
+ ): void;
116
+ /**
110
117
  Pause navigation
111
118
  */
112
- static pauseNavigation(): void;
113
- /**
119
+ static pauseNavigation(): void;
120
+ /**
114
121
  resume navigation
115
122
  */
116
- static resumeNavigation(): void;
117
- /**
118
- * Cradova Router
119
- * ------
120
- *
121
- * Navigates to a designated page in your app
122
- *
123
- * @param href string
124
- * @param data object
125
- * @param force boolean
126
- */
127
- static navigate(href: string, data?: Record<string, any>): void;
128
- /**
129
- * Cradova
130
- * ---
131
- * Loading page for your app
132
- *
133
- * lazy loaded loading use
134
- *
135
- * @param page
136
- */
137
- static setLoadingPage(page: Page): void;
138
- /**
139
- * Cradova Router
140
- * ------
141
- *
142
- * return last set router params
143
- *
144
- * .
145
- */
146
- static get PageData(): {
147
- params: Record<string, string>;
148
- data?: Record<string, any>;
149
- };
150
- /**
151
- * Cradova
152
- * ---
153
- * Error Handler for your app
154
- *
155
- * @param callback
156
- * @param path? page path
157
- */
158
- static addErrorHandler(callback: (err?: unknown, pagePath?: string) => void): void;
159
- static _mount(): void;
123
+ static resumeNavigation(): void;
124
+ /**
125
+ * Cradova Router
126
+ * ------
127
+ *
128
+ * Navigates to a designated page in your app
129
+ *
130
+ * @param href string
131
+ * @param data object
132
+ * @param force boolean
133
+ */
134
+ static navigate(href: string, data?: Record<string, any>): void;
135
+ /**
136
+ * Cradova
137
+ * ---
138
+ * Loading page for your app
139
+ *
140
+ * lazy loaded loading use
141
+ *
142
+ * @param page
143
+ */
144
+ static setLoadingPage(page: Page): void;
145
+ /**
146
+ * Cradova Router
147
+ * ------
148
+ *
149
+ * return last set router params
150
+ *
151
+ * .
152
+ */
153
+ static get PageData(): {
154
+ params: Record<string, string>;
155
+ data?: Record<string, any>;
156
+ };
157
+ /**
158
+ * Cradova
159
+ * ---
160
+ * Error Handler for your app
161
+ *
162
+ * @param callback
163
+ * @param path? page path
164
+ */
165
+ static addErrorHandler(
166
+ callback: (err?: unknown, pagePath?: string) => void,
167
+ ): void;
168
+ static _mount(): void;
160
169
  }
@@ -1,38 +1,113 @@
1
1
  import { type VJS_params_TYPE } from "./types.js";
2
- export declare const a: (...Children_and_Properties: VJS_params_TYPE<HTMLAnchorElement>) => HTMLAnchorElement;
3
- export declare const audio: (...Children_and_Properties: VJS_params_TYPE<HTMLAudioElement>) => HTMLAudioElement;
4
- export declare const button: (...Children_and_Properties: VJS_params_TYPE<HTMLButtonElement>) => HTMLButtonElement;
5
- export declare const canvas: (...Children_and_Properties: VJS_params_TYPE<HTMLCanvasElement>) => HTMLCanvasElement;
6
- export declare const div: (...Children_and_Properties: VJS_params_TYPE<HTMLDivElement>) => HTMLDivElement;
7
- export declare const footer: (...Children_and_Properties: VJS_params_TYPE<HTMLElement>) => HTMLElement;
8
- export declare const form: (...Children_and_Properties: VJS_params_TYPE<HTMLFormElement>) => HTMLFormElement;
9
- export declare const h1: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>) => HTMLHeadingElement;
10
- export declare const h2: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>) => HTMLHeadingElement;
11
- export declare const h3: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>) => HTMLHeadingElement;
12
- export declare const h4: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>) => HTMLHeadingElement;
13
- export declare const h5: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>) => HTMLHeadingElement;
14
- export declare const h6: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>) => HTMLHeadingElement;
15
- export declare const header: (...Children_and_Properties: VJS_params_TYPE<HTMLHeadElement>) => HTMLHeadElement;
16
- export declare const i: (...Children_and_Properties: VJS_params_TYPE<HTMLLIElement>) => HTMLLIElement;
17
- export declare const iframe: (...Children_and_Properties: VJS_params_TYPE<HTMLIFrameElement>) => HTMLIFrameElement;
18
- export declare const img: (...Children_and_Properties: VJS_params_TYPE<HTMLImageElement>) => HTMLImageElement;
19
- export declare const input: (...Children_and_Properties: VJS_params_TYPE<HTMLInputElement>) => HTMLInputElement;
20
- export declare const label: (...Children_and_Properties: VJS_params_TYPE<HTMLLabelElement>) => HTMLLabelElement;
21
- export declare const li: (...Children_and_Properties: VJS_params_TYPE<HTMLLIElement>) => HTMLLIElement;
22
- export declare const main: (...Children_and_Properties: VJS_params_TYPE<HTMLElement>) => HTMLElement;
23
- export declare const nav: (...Children_and_Properties: VJS_params_TYPE<HTMLElement>) => HTMLElement;
24
- export declare const ol: (...Children_and_Properties: VJS_params_TYPE<HTMLOListElement>) => HTMLOListElement;
25
- export declare const option: (...Children_and_Properties: VJS_params_TYPE<HTMLOptionElement>) => HTMLOptionElement;
26
- export declare const p: (...Children_and_Properties: VJS_params_TYPE<HTMLParagraphElement>) => HTMLParagraphElement;
27
- export declare const section: (...Children_and_Properties: VJS_params_TYPE<HTMLElement>) => HTMLElement;
28
- export declare const select: (...Children_and_Properties: VJS_params_TYPE<HTMLSelectElement>) => HTMLSelectElement;
29
- export declare const span: (...Children_and_Properties: VJS_params_TYPE<HTMLSpanElement>) => HTMLSpanElement;
30
- export declare const textarea: (...Children_and_Properties: VJS_params_TYPE<HTMLTextAreaElement>) => HTMLTextAreaElement;
31
- export declare const ul: (...Children_and_Properties: VJS_params_TYPE<HTMLUListElement>) => HTMLUListElement;
32
- export declare const video: (...Children_and_Properties: VJS_params_TYPE<HTMLVideoElement>) => HTMLVideoElement;
33
- export declare const tbody: (...Children_and_Properties: VJS_params_TYPE<HTMLTableElement>) => HTMLTableElement;
34
- export declare const table: (...Children_and_Properties: VJS_params_TYPE<HTMLTableSectionElement>) => HTMLTableSectionElement;
35
- export declare const td: (...Children_and_Properties: VJS_params_TYPE<HTMLTableCellElement>) => HTMLTableCellElement;
36
- export declare const tr: (...Children_and_Properties: VJS_params_TYPE<HTMLTableColElement>) => HTMLTableColElement;
37
- export declare const svg: (svg: string, properties?: VJS_params_TYPE<HTMLSpanElement>) => HTMLSpanElement;
38
- export declare const raw: (html: string | TemplateStringsArray) => DocumentFragment;
2
+ export declare const a: (
3
+ ...Children_and_Properties: VJS_params_TYPE<HTMLAnchorElement>
4
+ ) => HTMLAnchorElement;
5
+ export declare const audio: (
6
+ ...Children_and_Properties: VJS_params_TYPE<HTMLAudioElement>
7
+ ) => HTMLAudioElement;
8
+ export declare const button: (
9
+ ...Children_and_Properties: VJS_params_TYPE<HTMLButtonElement>
10
+ ) => HTMLButtonElement;
11
+ export declare const canvas: (
12
+ ...Children_and_Properties: VJS_params_TYPE<HTMLCanvasElement>
13
+ ) => HTMLCanvasElement;
14
+ export declare const div: (
15
+ ...Children_and_Properties: VJS_params_TYPE<HTMLDivElement>
16
+ ) => HTMLDivElement;
17
+ export declare const footer: (
18
+ ...Children_and_Properties: VJS_params_TYPE<HTMLElement>
19
+ ) => HTMLElement;
20
+ export declare const form: (
21
+ ...Children_and_Properties: VJS_params_TYPE<HTMLFormElement>
22
+ ) => HTMLFormElement;
23
+ export declare const h1: (
24
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>
25
+ ) => HTMLHeadingElement;
26
+ export declare const h2: (
27
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>
28
+ ) => HTMLHeadingElement;
29
+ export declare const h3: (
30
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>
31
+ ) => HTMLHeadingElement;
32
+ export declare const h4: (
33
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>
34
+ ) => HTMLHeadingElement;
35
+ export declare const h5: (
36
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>
37
+ ) => HTMLHeadingElement;
38
+ export declare const h6: (
39
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadingElement>
40
+ ) => HTMLHeadingElement;
41
+ export declare const header: (
42
+ ...Children_and_Properties: VJS_params_TYPE<HTMLHeadElement>
43
+ ) => HTMLHeadElement;
44
+ export declare const i: (
45
+ ...Children_and_Properties: VJS_params_TYPE<HTMLLIElement>
46
+ ) => HTMLLIElement;
47
+ export declare const iframe: (
48
+ ...Children_and_Properties: VJS_params_TYPE<HTMLIFrameElement>
49
+ ) => HTMLIFrameElement;
50
+ export declare const img: (
51
+ ...Children_and_Properties: VJS_params_TYPE<HTMLImageElement>
52
+ ) => HTMLImageElement;
53
+ export declare const input: (
54
+ ...Children_and_Properties: VJS_params_TYPE<HTMLInputElement>
55
+ ) => HTMLInputElement;
56
+ export declare const label: (
57
+ ...Children_and_Properties: VJS_params_TYPE<HTMLLabelElement>
58
+ ) => HTMLLabelElement;
59
+ export declare const li: (
60
+ ...Children_and_Properties: VJS_params_TYPE<HTMLLIElement>
61
+ ) => HTMLLIElement;
62
+ export declare const main: (
63
+ ...Children_and_Properties: VJS_params_TYPE<HTMLElement>
64
+ ) => HTMLElement;
65
+ export declare const nav: (
66
+ ...Children_and_Properties: VJS_params_TYPE<HTMLElement>
67
+ ) => HTMLElement;
68
+ export declare const ol: (
69
+ ...Children_and_Properties: VJS_params_TYPE<HTMLOListElement>
70
+ ) => HTMLOListElement;
71
+ export declare const option: (
72
+ ...Children_and_Properties: VJS_params_TYPE<HTMLOptionElement>
73
+ ) => HTMLOptionElement;
74
+ export declare const p: (
75
+ ...Children_and_Properties: VJS_params_TYPE<HTMLParagraphElement>
76
+ ) => HTMLParagraphElement;
77
+ export declare const section: (
78
+ ...Children_and_Properties: VJS_params_TYPE<HTMLElement>
79
+ ) => HTMLElement;
80
+ export declare const select: (
81
+ ...Children_and_Properties: VJS_params_TYPE<HTMLSelectElement>
82
+ ) => HTMLSelectElement;
83
+ export declare const span: (
84
+ ...Children_and_Properties: VJS_params_TYPE<HTMLSpanElement>
85
+ ) => HTMLSpanElement;
86
+ export declare const textarea: (
87
+ ...Children_and_Properties: VJS_params_TYPE<HTMLTextAreaElement>
88
+ ) => HTMLTextAreaElement;
89
+ export declare const ul: (
90
+ ...Children_and_Properties: VJS_params_TYPE<HTMLUListElement>
91
+ ) => HTMLUListElement;
92
+ export declare const video: (
93
+ ...Children_and_Properties: VJS_params_TYPE<HTMLVideoElement>
94
+ ) => HTMLVideoElement;
95
+ export declare const tbody: (
96
+ ...Children_and_Properties: VJS_params_TYPE<HTMLTableElement>
97
+ ) => HTMLTableElement;
98
+ export declare const table: (
99
+ ...Children_and_Properties: VJS_params_TYPE<HTMLTableSectionElement>
100
+ ) => HTMLTableSectionElement;
101
+ export declare const td: (
102
+ ...Children_and_Properties: VJS_params_TYPE<HTMLTableCellElement>
103
+ ) => HTMLTableCellElement;
104
+ export declare const tr: (
105
+ ...Children_and_Properties: VJS_params_TYPE<HTMLTableColElement>
106
+ ) => HTMLTableColElement;
107
+ export declare const svg: (
108
+ svg: string,
109
+ properties?: VJS_params_TYPE<HTMLSpanElement>,
110
+ ) => HTMLSpanElement;
111
+ export declare const raw: (
112
+ html: string | TemplateStringsArray,
113
+ ) => DocumentFragment;
@@ -1,22 +1,55 @@
1
1
  import type { Func, VJS_params_TYPE } from "./types.js";
2
- export declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE<E>) => E;
3
- export declare const cra: <E extends HTMLElement>(tag: string) => (...Children_and_Properties: VJS_params_TYPE<E>) => E;
2
+ export declare const makeElement: <E extends HTMLElement>(
3
+ element: E & HTMLElement,
4
+ ElementChildrenAndPropertyList: VJS_params_TYPE<E>,
5
+ ) => E;
6
+ export declare const cra: <E extends HTMLElement>(
7
+ tag: string,
8
+ ) => (...Children_and_Properties: VJS_params_TYPE<E>) => E;
4
9
  /**
5
10
  * @param {expression} condition
6
11
  * @param {function} elements[]
7
12
  */
8
- export declare function $if<E extends HTMLElement>(condition: any, ...elements: VJS_params_TYPE<E>): any;
9
- export declare function $ifelse(condition: any, ifTrue: any, ifFalse?: any): any;
10
- export declare function $case<E extends HTMLElement = HTMLElement>(value: any, ...elements: VJS_params_TYPE<E>): (key: any) => VJS_params_TYPE<E> | undefined;
11
- export declare function $switch(key: unknown, ...cases: ((key: any) => any)[]): any;
13
+ export declare function $if<E extends HTMLElement>(
14
+ condition: any,
15
+ ...elements: VJS_params_TYPE<E>
16
+ ): any;
17
+ export declare function $ifelse(
18
+ condition: any,
19
+ ifTrue: any,
20
+ ifFalse?: any,
21
+ ): any;
22
+ export declare function $case<E extends HTMLElement = HTMLElement>(
23
+ value: any,
24
+ ...elements: VJS_params_TYPE<E>
25
+ ): (key: any) => VJS_params_TYPE<E> | undefined;
26
+ export declare function $switch(
27
+ key: unknown,
28
+ ...cases: ((key: any) => any)[]
29
+ ): any;
12
30
  type LoopData<Type> = Type[];
13
- export declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | HTMLElement[] | DocumentFragment | DocumentFragment[] | undefined | undefined[]): HTMLElement[] | undefined;
31
+ export declare function loop<Type>(
32
+ datalist: LoopData<Type>,
33
+ component: (
34
+ value: Type,
35
+ index?: number,
36
+ array?: LoopData<Type>,
37
+ ) =>
38
+ | HTMLElement
39
+ | HTMLElement[]
40
+ | DocumentFragment
41
+ | DocumentFragment[]
42
+ | undefined
43
+ | undefined[],
44
+ ): HTMLElement[] | undefined;
14
45
  /**
15
46
  * Document fragment
16
47
  * @param children
17
48
  * @returns
18
49
  */
19
- export declare const frag: (children: VJS_params_TYPE<HTMLElement>) => DocumentFragment;
50
+ export declare const frag: (
51
+ children: VJS_params_TYPE<HTMLElement>,
52
+ ) => DocumentFragment;
20
53
  /**
21
54
  * Cradova
22
55
  * ---
@@ -25,7 +58,10 @@ export declare const frag: (children: VJS_params_TYPE<HTMLElement>) => DocumentF
25
58
  * @param Func
26
59
  * @returns [state, setState]
27
60
  */
28
- export declare function useState<S = unknown>(newState: S, self: any): [S, (newState: S | ((preS: S) => S)) => void];
61
+ export declare function useState<S = unknown>(
62
+ newState: S,
63
+ self: any,
64
+ ): [S, (newState: S | ((preS: S) => S)) => void];
29
65
  /**
30
66
  * Cradova
31
67
  * ---
@@ -40,17 +76,19 @@ export declare function useEffect(effect: () => void, self: Func): void;
40
76
  * make reference to dom elements
41
77
  */
42
78
  declare class __raw_ref {
43
- tree: Record<string, any>;
44
- /**
45
- * Bind a DOM element to a reference name.
46
- * @param name - The name to reference the DOM element by.
47
- */
48
- bindAs(name: string): __raw_ref;
49
- /**
50
- * Retrieve a referenced DOM element.
51
- * @param name - The name of the referenced DOM element.
52
- */
53
- elem<ElementType extends HTMLElement = HTMLElement>(name: string): ElementType | undefined;
79
+ tree: Record<string, any>;
80
+ /**
81
+ * Bind a DOM element to a reference name.
82
+ * @param name - The name to reference the DOM element by.
83
+ */
84
+ bindAs(name: string): __raw_ref;
85
+ /**
86
+ * Retrieve a referenced DOM element.
87
+ * @param name - The name of the referenced DOM element.
88
+ */
89
+ elem<ElementType extends HTMLElement = HTMLElement>(
90
+ name: string,
91
+ ): ElementType | undefined;
54
92
  }
55
93
  /**
56
94
  * Cradova
@@ -63,8 +101,8 @@ export declare const getSignal: (name: string, func: Func) => any;
63
101
  export declare const isArrowFunc: (fn: Function) => boolean;
64
102
  export declare const toFuncNoRender: (func: any) => any;
65
103
  export declare const funcManager: {
66
- render(func: Func): HTMLElement;
67
- recall(func: Func): void;
68
- activate(func: Func): Promise<void>;
104
+ render(func: Func): HTMLElement;
105
+ recall(func: Func): void;
106
+ activate(func: Func): Promise<void>;
69
107
  };
70
108
  export {};
@@ -1,6 +1,7 @@
1
1
  import * as CSS from "csstype";
2
2
  import { __raw_ref, Page, Signal } from "./classes.js";
3
- type Attributes<E extends HTMLElement> = {
3
+ type Attributes<E extends HTMLElement> =
4
+ & {
4
5
  ref?: __raw_ref;
5
6
  value?: any;
6
7
  subscription?: Signal<any>;
@@ -9,70 +10,106 @@ type Attributes<E extends HTMLElement> = {
9
10
  [key: `data-${string}`]: string | undefined;
10
11
  [key: `aria-${string}`]: string | undefined;
11
12
  [key: `on${string}`]: (this: E, event: Event) => void;
12
- } & {
13
+ }
14
+ & {
13
15
  /**
14
16
  * Cradova calls this function when this element is rendered on the DOM.
15
17
  */
16
18
  onmount?: (this: E) => void;
17
- } & Partial<Omit<E, "style" | `data-${string}` | `aria-${string}` | `on${string}` | "ref" | "recall">>;
18
- export type VJS_params_TYPE<E extends HTMLElement> = (undefined | string | HTMLElement | HTMLElement[] | DocumentFragment | DocumentFragment[] | (() => HTMLElement) | Partial<Attributes<E>> | {
19
+ }
20
+ & Partial<
21
+ Omit<
22
+ E,
23
+ | "style"
24
+ | `data-${string}`
25
+ | `aria-${string}`
26
+ | `on${string}`
27
+ | "ref"
28
+ | "recall"
29
+ >
30
+ >;
31
+ export type VJS_params_TYPE<E extends HTMLElement> = (
32
+ | undefined
33
+ | string
34
+ | HTMLElement
35
+ | HTMLElement[]
36
+ | DocumentFragment
37
+ | DocumentFragment[]
38
+ | (() => HTMLElement)
39
+ | Partial<Attributes<E>>
40
+ | {
19
41
  style: CSS.Properties;
20
- })[];
42
+ }
43
+ )[];
21
44
  export interface RouterRouteObject {
22
- _html: ((this: Page, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
23
- _delegatedRoutes: number | boolean;
24
- _Activate: (force: boolean) => Promise<void>;
25
- _deActivate: (params: object) => void;
26
- _package: (params: unknown) => void;
27
- _errorHandler: ((err: unknown) => void) | null;
28
- _derive(): {
29
- _name: string;
30
- _callBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
31
- _deCallBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
32
- };
33
- _apply_derivation(data: {
34
- _name: string;
35
- _callBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
36
- _deCallBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
37
- }): unknown;
45
+ _html:
46
+ | ((this: Page, data?: unknown) => HTMLElement | DocumentFragment)
47
+ | HTMLElement
48
+ | DocumentFragment;
49
+ _delegatedRoutes: number | boolean;
50
+ _Activate: (force: boolean) => Promise<void>;
51
+ _deActivate: (params: object) => void;
52
+ _package: (params: unknown) => void;
53
+ _errorHandler: ((err: unknown) => void) | null;
54
+ _derive(): {
55
+ _name: string;
56
+ _callBack:
57
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
58
+ | undefined;
59
+ _deCallBack:
60
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
61
+ | undefined;
62
+ };
63
+ _apply_derivation(data: {
64
+ _name: string;
65
+ _callBack:
66
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
67
+ | undefined;
68
+ _deCallBack:
69
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
70
+ | undefined;
71
+ }): unknown;
38
72
  }
39
73
  export type CradovaPageType = {
40
- /**
41
- * Cradova page
42
- * ---
43
- * title of the page
44
- * .
45
- */
46
- name?: string;
47
- /**
48
- * Cradova page
49
- * ---
50
- * The component for the page
51
- * @param data
52
- * @returns void
53
- * .
54
- */
55
- template: (this: any) => HTMLElement;
56
- /**
57
- * Cradova page
58
- * ---
59
- * a snapshot is the initial render of a page.
60
- * snapshot isolation allows for good SEO guarantee with the flexibility of client based rendering
61
- * the origin server should accept post requesting to save a snapshot of this page for future use.
62
- * the origin server should respond with the snapshot for future request to the page url
63
- * the origin server should implement suitable mechanisms to invalidate it's caches
64
- */
65
- snapshotIsolation?: boolean;
74
+ /**
75
+ * Cradova page
76
+ * ---
77
+ * title of the page
78
+ * .
79
+ */
80
+ name?: string;
81
+ /**
82
+ * Cradova page
83
+ * ---
84
+ * The component for the page
85
+ * @param data
86
+ * @returns void
87
+ * .
88
+ */
89
+ template: (this: any) => HTMLElement;
90
+ /**
91
+ * Cradova page
92
+ * ---
93
+ * a snapshot is the initial render of a page.
94
+ * snapshot isolation allows for good SEO guarantee with the flexibility of client based rendering
95
+ * the origin server should accept post requesting to save a snapshot of this page for future use.
96
+ * the origin server should respond with the snapshot for future request to the page url
97
+ * the origin server should implement suitable mechanisms to invalidate it's caches
98
+ */
99
+ snapshotIsolation?: boolean;
66
100
  };
67
- export type browserPageType<importType = Page> = importType | Promise<importType> | (() => Promise<importType>);
101
+ export type browserPageType<importType = Page> =
102
+ | importType
103
+ | Promise<importType>
104
+ | (() => Promise<importType>);
68
105
  export type Func = {
69
- (): HTMLElement;
70
- rendered?: boolean;
71
- published?: boolean;
72
- reference?: HTMLElement | null;
73
- signals?: Map<string, Signal<any>>;
74
- pipes?: Map<string, any>;
75
- _state?: unknown[];
76
- _state_index?: number;
106
+ (): HTMLElement;
107
+ rendered?: boolean;
108
+ published?: boolean;
109
+ reference?: HTMLElement | null;
110
+ signals?: Map<string, Signal<any>>;
111
+ pipes?: Map<string, any>;
112
+ _state?: unknown[];
113
+ _state_index?: number;
77
114
  };
78
115
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.7.10",
3
+ "version": "3.7.12",
4
4
  "description": "Build Powerful ⚡ Web Apps with Ease",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",