cradova 3.6.5 → 3.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Friday Candour
3
+ Copyright (c) 2021 Friday Candour
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
package/dist/index.js CHANGED
@@ -163,10 +163,10 @@ function useEffect(effect, self) {
163
163
  function useRef() {
164
164
  return new __raw_ref;
165
165
  }
166
- var getSignal = (func, name) => {
166
+ var getSignal = (name, func) => {
167
167
  return func.pipes.get(name);
168
168
  };
169
- var sendSignal = (func, name, data) => {
169
+ var sendSignal = (name, data, func) => {
170
170
  const signal = func.signals.get(name);
171
171
  if (signal) {
172
172
  signal.publish(name, data);
@@ -181,28 +181,21 @@ var DEFAULT_STATE = {
181
181
  preRendered: null,
182
182
  reference: null,
183
183
  effectuate: null,
184
- _state_index: 0
184
+ _state_index: 0,
185
+ effects: [],
186
+ _state: []
185
187
  };
186
188
  var toFunc = (func) => {
187
- if (func.id)
189
+ if (typeof func._state_index === "number")
188
190
  return funcManager.render(func);
189
- cradovaEvent.compId += 1;
190
- func.id = cradovaEvent.compId;
191
191
  Object.assign(func, DEFAULT_STATE);
192
192
  func.signals = new Map;
193
193
  func.pipes = new Map;
194
- func.effects = [];
195
- func._state = [];
196
194
  return funcManager.render(func);
197
195
  };
198
196
  var funcManager = {
199
197
  render(func) {
200
- cradovaEvent.compId += 1;
201
- func.id = cradovaEvent.compId;
202
- func.effects = [];
203
- func.rendered = false;
204
- func._state_index = 0;
205
- func._state = [];
198
+ Object.assign(func, DEFAULT_STATE);
206
199
  const html = func.apply(func);
207
200
  if (html instanceof HTMLElement) {
208
201
  func.reference = html;
@@ -329,7 +322,6 @@ var raw = (html) => {
329
322
 
330
323
  // src/primitives/classes.ts
331
324
  class cradovaEvent {
332
- static compId = 0;
333
325
  after_comp_is_mounted = [];
334
326
  after_page_is_killed = [];
335
327
  dispatchEvent(eventName) {
@@ -381,19 +373,19 @@ class Signal {
381
373
  localStorage.setItem(this.pn, JSON.stringify(this.pipe));
382
374
  }
383
375
  }
384
- publishObject(events) {
385
- const s = new Map;
376
+ batchPublish(events) {
377
+ const s = new Set;
386
378
  for (const [eventName, data] of Object.entries(events)) {
387
379
  this.pipe[eventName] = data;
388
380
  const subs = this.subs[eventName] || [];
389
381
  for (let i2 = 0;i2 < subs.length; i2++) {
390
382
  const c = subs[i2];
391
383
  c.pipes.set(eventName, this.pipe[eventName]);
392
- s.set(c.id, c);
384
+ s.add(c);
393
385
  }
394
386
  }
395
- for (const [_, c] of s) {
396
- c.recall();
387
+ for (const c of s.values()) {
388
+ funcManager.recall(c);
397
389
  }
398
390
  if (this.pn) {
399
391
  localStorage.setItem(this.pn, JSON.stringify(this.pipe));
@@ -413,9 +405,8 @@ class Signal {
413
405
  } else {
414
406
  console.error(` ✘ Cradova err: ${String(eventName)} is not a valid event for this Signal`);
415
407
  }
416
- if (this.subs[eventName]?.find((cmp) => cmp.id === comp.id)) {
408
+ if (comp.signals.get(eventName))
417
409
  return;
418
- }
419
410
  if (!this.subs[eventName]) {
420
411
  this.subs[eventName] = [comp];
421
412
  } else {
@@ -439,7 +430,7 @@ class Page {
439
430
  _dropped = false;
440
431
  _snapshot;
441
432
  _snapshot_html;
442
- _deCB;
433
+ _de_active_CB;
443
434
  constructor(pageParams) {
444
435
  const { template, name } = pageParams;
445
436
  if (typeof template !== "function") {
@@ -483,7 +474,7 @@ class Page {
483
474
  this._snapshot_html = undefined;
484
475
  }
485
476
  set onDeactivate(cb) {
486
- this._deCB = cb;
477
+ this._de_active_CB = cb;
487
478
  }
488
479
  drop(state) {
489
480
  if (typeof state === "boolean") {
@@ -567,7 +558,7 @@ class RouterBoxClass {
567
558
  this.pageData.params = params;
568
559
  }
569
560
  await route._activate();
570
- this.lastNavigatedRouteController && this.lastNavigatedRouteController._deCB?.();
561
+ this.lastNavigatedRouteController && this.lastNavigatedRouteController._de_active_CB?.();
571
562
  this.lastNavigatedRoute = url;
572
563
  this.lastNavigatedRouteController = route;
573
564
  } catch (error) {
@@ -3,24 +3,25 @@ import type { browserPageType, CradovaPageType } from "./types.js";
3
3
  * Cradova event
4
4
  */
5
5
  export declare class cradovaEvent {
6
- static compId: number;
7
- /**
8
- * the events runs only once and removed to avoid duplication when added on the next rendering
9
- * these event are call and removed once when when a Function is rendered to the dom
10
- * @param callback
11
- */
12
- after_comp_is_mounted: Function[];
13
- /**
14
- * the events runs once after comps unmounts.
15
- * these event are called before a Function is rendered to the dom
16
- * @param callback
17
- */
18
- after_page_is_killed: Function[];
19
- /**
20
- * Dispatch any event
21
- * @param eventName
22
- */
23
- dispatchEvent(eventName: "after_comp_is_mounted" | "after_page_is_killed"): 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
+ ): void;
24
25
  }
25
26
  export declare const CradovaEvent: cradovaEvent;
26
27
  /**
@@ -34,43 +35,41 @@ export declare const CradovaEvent: cradovaEvent;
34
35
  * @constructor initial: Record<string, any>, props: {persist}
35
36
  */
36
37
  export declare class Signal<Type extends Record<string, any>> {
37
- private pn?;
38
- private subs?;
39
- pipe: Type;
40
- constructor(initial: Type, props?: {
41
- persistName?: string | undefined;
42
- });
43
- /**
44
- * Cradova Signal
45
- * ----
46
- * fires an action if available
47
- * @param key - string key of the action
48
- * @param data - data for the action
49
- */
50
- publish<T extends keyof Type>(eventName: T, data: Type[T]): void;
51
- /**
52
- * Cradova Signal
53
- * ----
54
- * fires an action if available
55
- * @param key - string key of the action
56
- * @param data - data for the action
57
- */
58
- publishObject<T extends keyof Type>(events: Record<T, Type[T]>): void;
59
- /**
60
- * Cradova Signal
61
- * ----
62
- * subscribe to an event
63
- *
64
- * @param name of event.
65
- * @param Func component to bind to.
66
- */
67
- subscribe<T extends keyof Type>(eventName: T | T[], comp: any): void;
68
- /**
69
- * Cradova Signal
70
- * ----
71
- * clear the history on local storage
72
- */
73
- clearPersist(): void;
38
+ private pn?;
39
+ private 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<T extends keyof Type>(events: Record<T, Type[T]>): 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
+ * clear the history on local storage
71
+ */
72
+ clearPersist(): void;
74
73
  }
75
74
  /**
76
75
  * Cradova Page
@@ -80,24 +79,22 @@ export declare class Signal<Type extends Record<string, any>> {
80
79
  * @param template
81
80
  */
82
81
  export declare class Page {
83
- /**
84
- * used internally
85
- */
86
- private _name;
87
- /**
88
- * this should be a cradova page component
89
- */
90
- _html: (this: Page) => HTMLElement;
91
- _template?: HTMLElement;
92
- private _dropped;
93
- private _snapshot;
94
- private _snapshot_html?;
95
- _deCB?: () => Promise<void> | void;
96
- constructor(pageParams: CradovaPageType);
97
- private _takeSnapShot;
98
- set onDeactivate(cb: () => Promise<void> | void);
99
- drop(state?: boolean): boolean | undefined;
100
- _activate(): Promise<void>;
82
+ /**
83
+ * used internally
84
+ */
85
+ private _name;
86
+ _html: (this: Page) => HTMLElement;
87
+ _template?: HTMLElement;
88
+ private _dropped;
89
+ private _snapshot;
90
+ private _snapshot_html?;
91
+ _de_active_CB?: () => Promise<void> | void;
92
+ constructor(pageParams: CradovaPageType);
93
+ private _takeSnapShot;
94
+ set onDeactivate(cb: () => Promise<void> | void);
95
+ drop(state?: boolean): boolean | undefined;
96
+ /** @internal */
97
+ _activate(): Promise<void>;
101
98
  }
102
99
  /** cradova router
103
100
  * ---
@@ -107,65 +104,69 @@ export declare class Page {
107
104
  * @param page the cradova document tree for the route.
108
105
  */
109
106
  export declare class Router {
110
- /**
111
- * cradova router
112
- * ---
113
- * Registers a route.
114
- *
115
- * accepts an object containing pat and page
116
- */
117
- static BrowserRoutes(obj: Record<string, browserPageType<Page | unknown>>): void;
118
- /**
107
+ /**
108
+ * cradova router
109
+ * ---
110
+ * Registers a route.
111
+ *
112
+ * accepts an object containing pat and page
113
+ */
114
+ static BrowserRoutes(
115
+ obj: Record<string, browserPageType<Page | unknown>>,
116
+ ): void;
117
+ /**
119
118
  Pause navigation
120
119
  */
121
- static pauseNavigation(): void;
122
- /**
120
+ static pauseNavigation(): void;
121
+ /**
123
122
  resume navigation
124
123
  */
125
- static resumeNavigation(): void;
126
- /**
127
- * Cradova Router
128
- * ------
129
- *
130
- * Navigates to a designated page in your app
131
- *
132
- * @param href string
133
- * @param data object
134
- * @param force boolean
135
- */
136
- static navigate(href: string, data?: Record<string, any>): void;
137
- /**
138
- * Cradova
139
- * ---
140
- * Loading page for your app
141
- *
142
- * lazy loaded loading use
143
- *
144
- * @param page
145
- */
146
- static setLoadingPage(page: Page): void;
147
- /**
148
- * Cradova Router
149
- * ------
150
- *
151
- * return last set router params
152
- *
153
- * .
154
- */
155
- static get PageData(): {
156
- params: Record<string, string>;
157
- data?: Record<string, any>;
158
- };
159
- /**
160
- * Cradova
161
- * ---
162
- * Error Handler for your app
163
- *
164
- * @param callback
165
- * @param path? page path
166
- */
167
- static addErrorHandler(callback: (err?: unknown, pagePath?: string) => void): void;
168
- static _mount(): void;
124
+ static resumeNavigation(): void;
125
+ /**
126
+ * Cradova Router
127
+ * ------
128
+ *
129
+ * Navigates to a designated page in your app
130
+ *
131
+ * @param href string
132
+ * @param data object
133
+ * @param force boolean
134
+ */
135
+ static navigate(href: string, data?: Record<string, any>): void;
136
+ /**
137
+ * Cradova
138
+ * ---
139
+ * Loading page for your app
140
+ *
141
+ * lazy loaded loading use
142
+ *
143
+ * @param page
144
+ */
145
+ static setLoadingPage(page: Page): void;
146
+ /**
147
+ * Cradova Router
148
+ * ------
149
+ *
150
+ * return last set router params
151
+ *
152
+ * .
153
+ */
154
+ static get PageData(): {
155
+ params: Record<string, string>;
156
+ data?: Record<string, any>;
157
+ };
158
+ /**
159
+ * Cradova
160
+ * ---
161
+ * Error Handler for your app
162
+ *
163
+ * @param callback
164
+ * @param path? page path
165
+ */
166
+ static addErrorHandler(
167
+ callback: (err?: unknown, pagePath?: string) => void,
168
+ ): void;
169
+ static _mount(): void;
169
170
  }
170
171
  /**
171
172
  * Cradova
@@ -173,21 +174,23 @@ export declare class Router {
173
174
  * make reference to dom elements
174
175
  */
175
176
  export declare class __raw_ref {
176
- tree: Record<string, any>;
177
- /**
178
- * Bind a DOM element to a reference name.
179
- * @param name - The name to reference the DOM element by.
180
- */
181
- bindAs(name: string): __raw_ref;
182
- /**
183
- * Retrieve a referenced DOM element.
184
- * @param name - The name of the referenced DOM element.
185
- */
186
- elem<ElementType extends HTMLElement = HTMLElement>(name: string): ElementType | undefined;
187
- /**
188
- * Append a DOM element to the reference, overwriting any existing reference.
189
- * @param name - The name to reference the DOM element by.
190
- * @param element - The DOM element to reference.
191
- */
192
- _append(name: string, Element: HTMLElement): void;
177
+ tree: Record<string, any>;
178
+ /**
179
+ * Bind a DOM element to a reference name.
180
+ * @param name - The name to reference the DOM element by.
181
+ */
182
+ bindAs(name: string): __raw_ref;
183
+ /**
184
+ * Retrieve a referenced DOM element.
185
+ * @param name - The name of the referenced DOM element.
186
+ */
187
+ elem<ElementType extends HTMLElement = HTMLElement>(
188
+ name: string,
189
+ ): ElementType | undefined;
190
+ /**
191
+ * Append a DOM element to the reference, overwriting any existing reference.
192
+ * @param name - The name to reference the DOM element by.
193
+ * @param element - The DOM element to reference.
194
+ */
195
+ _append(name: string, Element: HTMLElement): void;
193
196
  }
@@ -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,23 +1,50 @@
1
- import type { VJS_params_TYPE, CradovaFunc } from "./types.js";
1
+ import type { Func, VJS_params_TYPE } from "./types.js";
2
2
  import { __raw_ref } from "./classes.js";
3
- export declare const makeElement: <E extends HTMLElement>(element: E & HTMLElement, ElementChildrenAndPropertyList: VJS_params_TYPE<E>) => E;
4
- export declare const cra: <E extends HTMLElement>(tag: string) => (...Children_and_Properties: VJS_params_TYPE<E>) => E;
3
+ export declare const makeElement: <E extends HTMLElement>(
4
+ element: E & HTMLElement,
5
+ ElementChildrenAndPropertyList: VJS_params_TYPE<E>,
6
+ ) => E;
7
+ export declare const cra: <E extends HTMLElement>(
8
+ tag: string,
9
+ ) => (...Children_and_Properties: VJS_params_TYPE<E>) => E;
5
10
  /**
6
11
  * @param {expression} condition
7
12
  * @param {function} elements[]
8
13
  */
9
- export declare function $if<E extends HTMLElement>(condition: any, ...elements: VJS_params_TYPE<E>): any;
10
- export declare function $ifelse(condition: any, ifTrue: any, ifFalse?: any): any;
11
- export declare function $case<E extends HTMLElement = HTMLElement>(value: any, ...elements: VJS_params_TYPE<E>): (key: any) => VJS_params_TYPE<E> | undefined;
12
- export declare function $switch(key: unknown, ...cases: ((key: any) => any)[]): any;
14
+ export declare function $if<E extends HTMLElement>(
15
+ condition: any,
16
+ ...elements: VJS_params_TYPE<E>
17
+ ): any;
18
+ export declare function $ifelse(
19
+ condition: any,
20
+ ifTrue: any,
21
+ ifFalse?: any,
22
+ ): any;
23
+ export declare function $case<E extends HTMLElement = HTMLElement>(
24
+ value: any,
25
+ ...elements: VJS_params_TYPE<E>
26
+ ): (key: any) => VJS_params_TYPE<E> | undefined;
27
+ export declare function $switch(
28
+ key: unknown,
29
+ ...cases: ((key: any) => any)[]
30
+ ): any;
13
31
  type LoopData<Type> = Type[];
14
- export declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
32
+ export declare function loop<Type>(
33
+ datalist: LoopData<Type>,
34
+ component: (
35
+ value: Type,
36
+ index?: number,
37
+ array?: LoopData<Type>,
38
+ ) => HTMLElement | DocumentFragment | undefined,
39
+ ): HTMLElement[] | undefined;
15
40
  /**
16
41
  * Document fragment
17
42
  * @param children
18
43
  * @returns
19
44
  */
20
- export declare const frag: (children: VJS_params_TYPE<HTMLElement>) => DocumentFragment;
45
+ export declare const frag: (
46
+ children: VJS_params_TYPE<HTMLElement>,
47
+ ) => DocumentFragment;
21
48
  /**
22
49
  * Cradova
23
50
  * ---
@@ -26,7 +53,10 @@ export declare const frag: (children: VJS_params_TYPE<HTMLElement>) => DocumentF
26
53
  * @param Func
27
54
  * @returns [state, setState]
28
55
  */
29
- export declare function useState<S = unknown>(newState: S, self: any): [S, (newState: S | ((preS: S) => S)) => void];
56
+ export declare function useState<S = unknown>(
57
+ newState: S,
58
+ self: any,
59
+ ): [S, (newState: S | ((preS: S) => S)) => void];
30
60
  /**
31
61
  * Cradova
32
62
  * ---
@@ -42,13 +72,13 @@ Returns a mutable reference object of dom elements.
42
72
  * @returns reference
43
73
  */
44
74
  export declare function useRef(): __raw_ref;
45
- export declare const getSignal: (func: CradovaFunc, name: string) => any;
46
- export declare const sendSignal: (func: CradovaFunc, name: string, data: any) => void;
75
+ export declare const getSignal: (name: string, func: Func) => any;
76
+ export declare const sendSignal: (name: string, data: any, func: Func) => void;
47
77
  export declare const funcManager: {
48
- render(func: CradovaFunc): HTMLElement;
49
- _effect(func: CradovaFunc, fn: () => Promise<void> | void): void;
50
- effector(func: CradovaFunc): Promise<void>;
51
- recall(func: CradovaFunc): void;
52
- activate(func: CradovaFunc): Promise<void>;
78
+ render(func: Func): HTMLElement;
79
+ _effect(func: Func, fn: () => Promise<void> | void): void;
80
+ effector(func: Func): Promise<void>;
81
+ recall(func: Func): void;
82
+ activate(func: Func): Promise<void>;
53
83
  };
54
84
  export {};
@@ -1,94 +1,119 @@
1
1
  import * as CSS from "csstype";
2
2
  import { __raw_ref, Page, Signal } from "./classes.js";
3
- type DataAttributes = {
4
- [key: `data-${string}`]: string;
3
+ type Attributes<E> = {
4
+ src?: string;
5
+ alt?: string;
6
+ for?: string;
7
+ rel?: string;
8
+ href?: string;
9
+ type?: string;
10
+ name?: string;
11
+ rows?: string;
12
+ value?: string;
13
+ accept: string;
14
+ action?: string;
15
+ target?: string;
16
+ method?: string;
17
+ checked?: boolean;
18
+ required?: string;
19
+ frameBorder?: string;
20
+ placeholder?: string;
21
+ ref?: __raw_ref;
22
+ autocomplete?: string;
23
+ style?: CSS.Properties;
24
+ recall?: (P: any) => void;
25
+ [key: `data-${string}` | `data-${string}`]: string | undefined;
26
+ [key: `on${string}`]: (this: E) => void;
27
+ /**
28
+ * Cradova calls this function when this element is rendered on the DOM.
29
+ */
30
+ onmount: (this: E) => void;
5
31
  };
6
- type AriaAttributes = {
7
- [key: `aria-${string}`]: string;
8
- };
9
- type Attributes = {
10
- src?: string;
11
- alt?: string;
12
- for?: string;
13
- rel?: string;
14
- href?: string;
15
- type?: string;
16
- name?: string;
17
- rows?: string;
18
- value?: string;
19
- accept: string;
20
- action?: string;
21
- target?: string;
22
- method?: string;
23
- checked?: boolean;
24
- required?: string;
25
- frameBorder?: string;
26
- placeholder?: string;
27
- ref?: __raw_ref;
28
- autocomplete?: string;
29
- style?: CSS.Properties;
30
- recall?: (P: any) => void;
31
- onmount?: (this: HTMLElement & Attributes) => void;
32
- };
33
- export type VJS_params_TYPE<E extends HTMLElement> = (string | undefined | HTMLElement | HTMLElement[] | DocumentFragment | DocumentFragment[] | Attributes | Partial<Attributes> | (() => HTMLElement) | Partial<E> | Record<string, (this: E) => void> | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number>)[];
32
+ export type VJS_params_TYPE<E extends HTMLElement> = (
33
+ | undefined
34
+ | string
35
+ | HTMLElement
36
+ | HTMLElement[]
37
+ | DocumentFragment
38
+ | DocumentFragment[]
39
+ | (() => HTMLElement)
40
+ | Partial<Attributes<E>>
41
+ | Partial<E>
42
+ | {
43
+ style: CSS.Properties;
44
+ }
45
+ )[];
34
46
  export interface RouterRouteObject {
35
- _html: ((this: Page, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
36
- _delegatedRoutes: number | boolean;
37
- _Activate: (force: boolean) => Promise<void>;
38
- _deActivate: (params: object) => void;
39
- _package: (params: unknown) => void;
40
- _errorHandler: ((err: unknown) => void) | null;
41
- _derive(): {
42
- _name: string;
43
- _callBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
44
- _deCallBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
45
- };
46
- _apply_derivation(data: {
47
- _name: string;
48
- _callBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
49
- _deCallBack: ((cradovaPageSet: HTMLElement) => void | Promise<void>) | undefined;
50
- }): unknown;
47
+ _html:
48
+ | ((this: Page, data?: unknown) => HTMLElement | DocumentFragment)
49
+ | HTMLElement
50
+ | DocumentFragment;
51
+ _delegatedRoutes: number | boolean;
52
+ _Activate: (force: boolean) => Promise<void>;
53
+ _deActivate: (params: object) => void;
54
+ _package: (params: unknown) => void;
55
+ _errorHandler: ((err: unknown) => void) | null;
56
+ _derive(): {
57
+ _name: string;
58
+ _callBack:
59
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
60
+ | undefined;
61
+ _deCallBack:
62
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
63
+ | undefined;
64
+ };
65
+ _apply_derivation(data: {
66
+ _name: string;
67
+ _callBack:
68
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
69
+ | undefined;
70
+ _deCallBack:
71
+ | ((cradovaPageSet: HTMLElement) => void | Promise<void>)
72
+ | undefined;
73
+ }): unknown;
51
74
  }
52
75
  export type CradovaPageType = {
53
- /**
54
- * Cradova page
55
- * ---
56
- * title of the page
57
- * .
58
- */
59
- name?: string;
60
- /**
61
- * Cradova page
62
- * ---
63
- * The component for the page
64
- * @param data
65
- * @returns void
66
- * .
67
- */
68
- template: (this: Page) => HTMLElement;
69
- /**
70
- * Cradova page
71
- * ---
72
- * a snapshot is the initial render of a page.
73
- * snapshot isolation allows for good SEO guarantee with the flexibility of client based rendering
74
- * the origin server should accept post requesting to save a snapshot of this page for future use.
75
- * the origin server should respond with the snapshot for future request to the page url
76
- * the origin server should implement suitable mechanisms to invalidate it's caches
77
- */
78
- snapshotIsolation?: boolean;
76
+ /**
77
+ * Cradova page
78
+ * ---
79
+ * title of the page
80
+ * .
81
+ */
82
+ name?: string;
83
+ /**
84
+ * Cradova page
85
+ * ---
86
+ * The component for the page
87
+ * @param data
88
+ * @returns void
89
+ * .
90
+ */
91
+ template: (this: Page) => HTMLElement;
92
+ /**
93
+ * Cradova page
94
+ * ---
95
+ * a snapshot is the initial render of a page.
96
+ * snapshot isolation allows for good SEO guarantee with the flexibility of client based rendering
97
+ * the origin server should accept post requesting to save a snapshot of this page for future use.
98
+ * the origin server should respond with the snapshot for future request to the page url
99
+ * the origin server should implement suitable mechanisms to invalidate it's caches
100
+ */
101
+ snapshotIsolation?: boolean;
79
102
  };
80
- export type browserPageType<importType = Page> = importType | Promise<importType> | (() => Promise<importType>);
81
- export type CradovaFunc = {
82
- (): HTMLElement;
83
- id?: number;
84
- rendered: boolean;
85
- published: boolean;
86
- reference: HTMLElement | null;
87
- signals: Map<string, Signal<any>>;
88
- pipes: Map<string, any>;
89
- _state: unknown[];
90
- _state_index: number;
91
- effects: (() => Promise<void> | void)[];
92
- effectuate: ((this: any) => void) | null;
103
+ export type browserPageType<importType = Page> =
104
+ | importType
105
+ | Promise<importType>
106
+ | (() => Promise<importType>);
107
+ export type Func = {
108
+ (): HTMLElement;
109
+ rendered?: boolean;
110
+ published?: boolean;
111
+ reference?: HTMLElement | null;
112
+ signals?: Map<string, Signal<any>>;
113
+ pipes?: Map<string, any>;
114
+ effects?: (() => Promise<void> | void)[];
115
+ effectuate?: ((this: any) => void) | null;
116
+ _state?: unknown[];
117
+ _state_index?: number;
93
118
  };
94
119
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.6.5",
3
+ "version": "3.6.6",
4
4
  "description": "Build Powerful ⚡ Web Apps with Ease",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -18,6 +18,7 @@
18
18
  "lint": "eslint . --fix"
19
19
  },
20
20
  "keywords": [
21
+ "frontend library",
21
22
  "PWA",
22
23
  "webapp",
23
24
  "SPA",