cradova 3.3.35 → 3.3.54
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.js +70 -73
- package/dist/primitives/classes.d.ts +27 -25
- package/dist/primitives/functions.d.ts +1 -1
- package/dist/primitives/types.d.ts +3 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
// src/primitives/classes.ts
|
|
2
2
|
class cradovaEvent {
|
|
3
|
+
static refid = 0;
|
|
3
4
|
afterMount = [];
|
|
4
5
|
beforeMountActive = [];
|
|
5
|
-
|
|
6
|
-
this.afterMount.push(callback);
|
|
7
|
-
}
|
|
8
|
-
async addBeforeMountActive(callback) {
|
|
9
|
-
this.beforeMountActive.push(callback);
|
|
10
|
-
}
|
|
6
|
+
afterDeactivate = [];
|
|
11
7
|
dispatchEvent(eventName) {
|
|
12
8
|
const eventListeners = this[eventName];
|
|
13
9
|
if (eventName.includes("Active")) {
|
|
@@ -24,6 +20,7 @@ class cradovaEvent {
|
|
|
24
20
|
var CradovaEvent = new cradovaEvent;
|
|
25
21
|
|
|
26
22
|
class Comp {
|
|
23
|
+
id;
|
|
27
24
|
component;
|
|
28
25
|
effects = [];
|
|
29
26
|
effectuate = null;
|
|
@@ -37,6 +34,8 @@ class Comp {
|
|
|
37
34
|
test;
|
|
38
35
|
constructor(component) {
|
|
39
36
|
this.component = component.bind(this);
|
|
37
|
+
cradovaEvent.refid += 1;
|
|
38
|
+
this.id = cradovaEvent.refid;
|
|
40
39
|
}
|
|
41
40
|
preRender() {
|
|
42
41
|
this.preRendered = this.render();
|
|
@@ -62,6 +61,9 @@ class Comp {
|
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
_setExtra(Extra) {
|
|
64
|
+
if (this.Signal) {
|
|
65
|
+
Extra.value = this.Signal.value;
|
|
66
|
+
}
|
|
65
67
|
this.Signal = Extra;
|
|
66
68
|
}
|
|
67
69
|
_effect(fn) {
|
|
@@ -71,7 +73,10 @@ class Comp {
|
|
|
71
73
|
}
|
|
72
74
|
async effector() {
|
|
73
75
|
for (let i = 0;i < this.effects.length; i++) {
|
|
74
|
-
await this.effects[i].apply(this);
|
|
76
|
+
const fn = await this.effects[i].apply(this);
|
|
77
|
+
if (typeof fn === "function") {
|
|
78
|
+
CradovaEvent.afterDeactivate.push(fn);
|
|
79
|
+
}
|
|
75
80
|
}
|
|
76
81
|
this.effects = [];
|
|
77
82
|
if (this.effectuate) {
|
|
@@ -88,7 +93,9 @@ class Comp {
|
|
|
88
93
|
};
|
|
89
94
|
} else {
|
|
90
95
|
if (this.published) {
|
|
91
|
-
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
this.activate();
|
|
98
|
+
});
|
|
92
99
|
}
|
|
93
100
|
}
|
|
94
101
|
}
|
|
@@ -98,23 +105,21 @@ class Comp {
|
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
107
|
this._state_index = 0;
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
108
|
+
const node = this.reference;
|
|
109
|
+
if (document.contains(node)) {
|
|
110
|
+
const html = this.component();
|
|
111
|
+
if (html instanceof HTMLElement) {
|
|
105
112
|
node.insertAdjacentElement("beforebegin", html);
|
|
106
113
|
node.remove();
|
|
114
|
+
this.published = true;
|
|
115
|
+
this.reference = html;
|
|
116
|
+
CradovaEvent.dispatchEvent("afterMount");
|
|
117
|
+
} else {
|
|
118
|
+
console.error(" \u2718 Cradova err : Invalid html, got - " + html);
|
|
107
119
|
}
|
|
108
|
-
this.published = true;
|
|
109
|
-
this.reference = html;
|
|
110
|
-
CradovaEvent.dispatchEvent("afterMount");
|
|
111
|
-
(async () => {
|
|
112
|
-
if (!document.contains(html)) {
|
|
113
|
-
this.rendered = false;
|
|
114
|
-
}
|
|
115
|
-
})();
|
|
116
120
|
} else {
|
|
117
|
-
|
|
121
|
+
this.reference = null;
|
|
122
|
+
this.rendered = false;
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
}
|
|
@@ -139,7 +144,7 @@ class lazy {
|
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
|
|
142
|
-
class
|
|
147
|
+
class Signal {
|
|
143
148
|
callback;
|
|
144
149
|
persistName = "";
|
|
145
150
|
actions = {};
|
|
@@ -162,34 +167,34 @@ class createSignal {
|
|
|
162
167
|
}
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
|
-
set(value,
|
|
170
|
+
set(value, shouldCompRender) {
|
|
166
171
|
if (typeof value === "function") {
|
|
167
172
|
this.value = value(this.value);
|
|
168
173
|
} else {
|
|
169
174
|
this.value = value;
|
|
170
175
|
}
|
|
171
|
-
if (this.
|
|
172
|
-
localStorage.setItem(this.persistName, JSON.stringify(this.value));
|
|
173
|
-
}
|
|
174
|
-
if (this.comp.length && shouldRefRender !== false) {
|
|
176
|
+
if (this.comp.length && shouldCompRender !== false) {
|
|
175
177
|
this.updateState();
|
|
176
178
|
}
|
|
177
179
|
if (this.callback) {
|
|
178
180
|
this.callback(this.value);
|
|
179
181
|
}
|
|
182
|
+
if (this.persistName) {
|
|
183
|
+
localStorage.setItem(this.persistName, JSON.stringify(this.value));
|
|
184
|
+
}
|
|
180
185
|
}
|
|
181
|
-
setKey(key, value,
|
|
182
|
-
if (typeof this.value === "object"
|
|
186
|
+
setKey(key, value, shouldCompRender) {
|
|
187
|
+
if (typeof this.value === "object") {
|
|
183
188
|
this.value[key] = value;
|
|
184
|
-
if (this.
|
|
185
|
-
localStorage.setItem(this.persistName, JSON.stringify(this.value));
|
|
186
|
-
}
|
|
187
|
-
if (this.comp.length && shouldRefRender !== false) {
|
|
189
|
+
if (this.comp.length && shouldCompRender !== false) {
|
|
188
190
|
this.updateState();
|
|
189
191
|
}
|
|
190
192
|
if (this.callback) {
|
|
191
193
|
this.callback(this.value);
|
|
192
194
|
}
|
|
195
|
+
if (this.persistName) {
|
|
196
|
+
localStorage.setItem(this.persistName, JSON.stringify(this.value));
|
|
197
|
+
}
|
|
193
198
|
} else {
|
|
194
199
|
throw new Error(`\u2718 Cradova err : can't set key ${String(key)} store.value is not an object`);
|
|
195
200
|
}
|
|
@@ -238,16 +243,18 @@ class createSignal {
|
|
|
238
243
|
ent.comp.recall();
|
|
239
244
|
}
|
|
240
245
|
}
|
|
241
|
-
|
|
246
|
+
bindComp(comp, binding) {
|
|
242
247
|
if (comp instanceof Comp) {
|
|
248
|
+
if (this.comp.find((cmp) => cmp.comp?.id === comp.id))
|
|
249
|
+
return;
|
|
243
250
|
comp.render = comp.render.bind(comp);
|
|
244
251
|
comp._setExtra(this);
|
|
245
252
|
}
|
|
246
253
|
this.comp.push({
|
|
247
254
|
comp,
|
|
248
|
-
_signalProperty: binding
|
|
249
|
-
_element_property: binding
|
|
250
|
-
_event: binding
|
|
255
|
+
_signalProperty: binding?.signalProperty,
|
|
256
|
+
_element_property: binding?._element_property,
|
|
257
|
+
_event: binding?.event
|
|
251
258
|
});
|
|
252
259
|
}
|
|
253
260
|
listen(callback) {
|
|
@@ -267,16 +274,12 @@ class Page {
|
|
|
267
274
|
_callBack;
|
|
268
275
|
_deCallBack;
|
|
269
276
|
_dropped = false;
|
|
270
|
-
_errorHandler = null;
|
|
271
277
|
constructor(cradova_page_initials) {
|
|
272
278
|
const { template, name } = cradova_page_initials;
|
|
273
279
|
this._html = template;
|
|
274
280
|
this._name = name || "Document";
|
|
275
281
|
this._template.setAttribute("id", "page");
|
|
276
282
|
}
|
|
277
|
-
set errorHandler(errorHandler) {
|
|
278
|
-
this._errorHandler = errorHandler;
|
|
279
|
-
}
|
|
280
283
|
onActivate(cb) {
|
|
281
284
|
this._callBack = cb;
|
|
282
285
|
}
|
|
@@ -316,6 +319,7 @@ class Page {
|
|
|
316
319
|
behavior: "instant"
|
|
317
320
|
});
|
|
318
321
|
this._callBack && await this._callBack();
|
|
322
|
+
CradovaEvent.dispatchEvent("afterDeactivate");
|
|
319
323
|
}
|
|
320
324
|
}
|
|
321
325
|
|
|
@@ -328,7 +332,7 @@ class RouterBoxClass {
|
|
|
328
332
|
pageHide = null;
|
|
329
333
|
errorHandler;
|
|
330
334
|
loadingPage = null;
|
|
331
|
-
|
|
335
|
+
pageData = { params: {} };
|
|
332
336
|
routes = {};
|
|
333
337
|
pageevents = [];
|
|
334
338
|
paused = false;
|
|
@@ -340,16 +344,14 @@ class RouterBoxClass {
|
|
|
340
344
|
}, 50);
|
|
341
345
|
}
|
|
342
346
|
route(path, page) {
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
console.error(" \u2718 Cradova err: not a valid page ", page);
|
|
346
|
-
}
|
|
347
|
-
return this.routes[path] = page;
|
|
347
|
+
if (!page) {
|
|
348
|
+
console.error(" \u2718 Cradova err: not a valid page ", page);
|
|
348
349
|
}
|
|
349
|
-
return;
|
|
350
|
+
return this.routes[path] = page;
|
|
350
351
|
}
|
|
351
352
|
async router(_e, _force) {
|
|
352
|
-
|
|
353
|
+
const url = window.location.href;
|
|
354
|
+
let route, params;
|
|
353
355
|
if (this.paused) {
|
|
354
356
|
window.location.hash = "paused";
|
|
355
357
|
return;
|
|
@@ -375,7 +377,7 @@ class RouterBoxClass {
|
|
|
375
377
|
}
|
|
376
378
|
}
|
|
377
379
|
if (params) {
|
|
378
|
-
this.
|
|
380
|
+
this.pageData.params = params;
|
|
379
381
|
}
|
|
380
382
|
await route._activate();
|
|
381
383
|
this.start_pageevents(url);
|
|
@@ -383,15 +385,10 @@ class RouterBoxClass {
|
|
|
383
385
|
this.lastNavigatedRoute = url;
|
|
384
386
|
this.lastNavigatedRouteController = route;
|
|
385
387
|
} catch (error) {
|
|
386
|
-
if (
|
|
387
|
-
|
|
388
|
+
if (typeof this.errorHandler === "function") {
|
|
389
|
+
this.errorHandler(error, url);
|
|
388
390
|
} else {
|
|
389
|
-
|
|
390
|
-
this.errorHandler(error);
|
|
391
|
-
} else {
|
|
392
|
-
console.error(error);
|
|
393
|
-
throw new Error(" \u2718 Cradova err: consider adding error boundary to the specific page ");
|
|
394
|
-
}
|
|
391
|
+
console.error(error);
|
|
395
392
|
}
|
|
396
393
|
}
|
|
397
394
|
} else {
|
|
@@ -415,7 +412,7 @@ class RouterBoxClass {
|
|
|
415
412
|
params[key] = val;
|
|
416
413
|
});
|
|
417
414
|
if (this.routes[url]) {
|
|
418
|
-
return [this.routes[url],
|
|
415
|
+
return [this.routes[url], params];
|
|
419
416
|
}
|
|
420
417
|
}
|
|
421
418
|
for (const path in this.routes) {
|
|
@@ -444,7 +441,7 @@ class RouterBoxClass {
|
|
|
444
441
|
routesParams[pathFixtures[i].split(":")[1]] = urlFixtures[i];
|
|
445
442
|
}
|
|
446
443
|
}
|
|
447
|
-
return [this.routes[path],
|
|
444
|
+
return [this.routes[path], routesParams];
|
|
448
445
|
}
|
|
449
446
|
}
|
|
450
447
|
}
|
|
@@ -463,11 +460,11 @@ var RouterBox = new RouterBoxClass;
|
|
|
463
460
|
class Router {
|
|
464
461
|
static BrowserRoutes(obj) {
|
|
465
462
|
for (const path in obj) {
|
|
466
|
-
|
|
463
|
+
const page = obj[path];
|
|
467
464
|
if (typeof page === "object" && typeof page.then === "function" || typeof page === "function") {
|
|
468
465
|
RouterBox.routes[path] = async () => {
|
|
469
|
-
|
|
470
|
-
return RouterBox.route(path,
|
|
466
|
+
const pagepp = typeof page === "function" ? await page() : await page;
|
|
467
|
+
return RouterBox.route(path, pagepp?.default || pagepp);
|
|
471
468
|
};
|
|
472
469
|
} else {
|
|
473
470
|
RouterBox.route(path, page);
|
|
@@ -490,7 +487,7 @@ class Router {
|
|
|
490
487
|
window.location.replace(window.location.pathname + window.location.search);
|
|
491
488
|
history.go(-1);
|
|
492
489
|
}
|
|
493
|
-
static navigate(href, data
|
|
490
|
+
static navigate(href, data) {
|
|
494
491
|
if (typeof href !== "string") {
|
|
495
492
|
console.error(" \u2718 Cradova err: href must be a defined path but got " + href + " instead");
|
|
496
493
|
}
|
|
@@ -503,8 +500,8 @@ class Router {
|
|
|
503
500
|
RouterBox.nextRouteController = route;
|
|
504
501
|
window.history.pushState({}, "", href);
|
|
505
502
|
}
|
|
506
|
-
RouterBox.
|
|
507
|
-
RouterBox.
|
|
503
|
+
RouterBox.pageData.params = params;
|
|
504
|
+
RouterBox.pageData.data = data;
|
|
508
505
|
RouterBox.router(null);
|
|
509
506
|
}
|
|
510
507
|
}
|
|
@@ -519,11 +516,11 @@ class Router {
|
|
|
519
516
|
if (typeof callback === "function") {
|
|
520
517
|
RouterBox["pageevents"].push(callback);
|
|
521
518
|
} else {
|
|
522
|
-
throw new Error(" \u2718 Cradova err: callback for
|
|
519
|
+
throw new Error(" \u2718 Cradova err: callback for page events event is not a function");
|
|
523
520
|
}
|
|
524
521
|
}
|
|
525
|
-
static get
|
|
526
|
-
return RouterBox.
|
|
522
|
+
static get PageData() {
|
|
523
|
+
return RouterBox.pageData;
|
|
527
524
|
}
|
|
528
525
|
static addErrorHandler(callback) {
|
|
529
526
|
if (typeof callback === "function") {
|
|
@@ -702,8 +699,8 @@ var makeElement = (element, ElementChildrenAndPropertyList) => {
|
|
|
702
699
|
value[0]._append(value[1], element);
|
|
703
700
|
continue;
|
|
704
701
|
}
|
|
705
|
-
if (value[0] instanceof
|
|
706
|
-
value[0].
|
|
702
|
+
if (value[0] instanceof Signal) {
|
|
703
|
+
value[0].bindComp(element, {
|
|
707
704
|
_element_property: prop,
|
|
708
705
|
signalProperty: value[1]
|
|
709
706
|
});
|
|
@@ -711,7 +708,7 @@ var makeElement = (element, ElementChildrenAndPropertyList) => {
|
|
|
711
708
|
}
|
|
712
709
|
}
|
|
713
710
|
if (prop === "onmount") {
|
|
714
|
-
CradovaEvent.
|
|
711
|
+
CradovaEvent.afterMount.push(() => {
|
|
715
712
|
typeof props["onmount"] === "function" && props["onmount"].apply(element);
|
|
716
713
|
});
|
|
717
714
|
continue;
|
|
@@ -875,7 +872,6 @@ export {
|
|
|
875
872
|
dialog,
|
|
876
873
|
details,
|
|
877
874
|
datalist,
|
|
878
|
-
createSignal,
|
|
879
875
|
cra,
|
|
880
876
|
caption,
|
|
881
877
|
canvas,
|
|
@@ -883,6 +879,7 @@ export {
|
|
|
883
879
|
br,
|
|
884
880
|
audio,
|
|
885
881
|
a,
|
|
882
|
+
Signal,
|
|
886
883
|
Router,
|
|
887
884
|
Rhoda,
|
|
888
885
|
Page,
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
import { type CradovaPageType, type
|
|
1
|
+
import { type CradovaPageType, type browserPageType } from "./types";
|
|
2
2
|
/**
|
|
3
3
|
* Cradova event
|
|
4
4
|
*/
|
|
5
5
|
declare class cradovaEvent {
|
|
6
|
-
|
|
7
|
-
beforeMountActive: Function[];
|
|
6
|
+
static refid: number;
|
|
8
7
|
/**
|
|
9
|
-
* add an event to an exhaustible list of events
|
|
10
8
|
* the events runs only once and removed.
|
|
11
9
|
* these event are call and removed once when when a comp is rendered to the dom
|
|
12
10
|
* @param callback
|
|
13
11
|
*/
|
|
14
|
-
|
|
12
|
+
afterMount: Function[];
|
|
15
13
|
/**
|
|
16
|
-
* add an event to a list of events
|
|
17
14
|
* the events runs many times.
|
|
18
15
|
* these event are called before a comp is rendered to the dom
|
|
19
16
|
* @param callback
|
|
20
17
|
*/
|
|
21
|
-
|
|
18
|
+
beforeMountActive: Function[];
|
|
19
|
+
/**
|
|
20
|
+
* the events runs once after comps unmounts.
|
|
21
|
+
* these event are called before a comp is rendered to the dom
|
|
22
|
+
* @param callback
|
|
23
|
+
*/
|
|
24
|
+
afterDeactivate: Function[];
|
|
22
25
|
/**
|
|
23
26
|
* Dispatch any event
|
|
24
27
|
* @param eventName
|
|
25
28
|
*/
|
|
26
|
-
dispatchEvent(eventName: "beforeMountActive" | "afterMount"): void;
|
|
29
|
+
dispatchEvent(eventName: "beforeMountActive" | "afterMount" | "afterDeactivate"): void;
|
|
27
30
|
}
|
|
28
31
|
export declare const CradovaEvent: cradovaEvent;
|
|
29
32
|
/**
|
|
@@ -33,6 +36,7 @@ export declare const CradovaEvent: cradovaEvent;
|
|
|
33
36
|
*
|
|
34
37
|
*/
|
|
35
38
|
export declare class Comp<Prop extends Record<string, any> = any> {
|
|
39
|
+
id: number;
|
|
36
40
|
private component;
|
|
37
41
|
private effects;
|
|
38
42
|
private effectuate;
|
|
@@ -40,7 +44,7 @@ export declare class Comp<Prop extends Record<string, any> = any> {
|
|
|
40
44
|
private published;
|
|
41
45
|
private preRendered;
|
|
42
46
|
private reference;
|
|
43
|
-
Signal:
|
|
47
|
+
Signal: Signal<Prop> | undefined;
|
|
44
48
|
_state: Prop[];
|
|
45
49
|
_state_index: number;
|
|
46
50
|
test?: string;
|
|
@@ -54,7 +58,7 @@ export declare class Comp<Prop extends Record<string, any> = any> {
|
|
|
54
58
|
* @returns () => HTMLElement
|
|
55
59
|
*/
|
|
56
60
|
render(): any;
|
|
57
|
-
_setExtra(Extra:
|
|
61
|
+
_setExtra(Extra: Signal<any>): void;
|
|
58
62
|
_effect(fn: () => Promise<void> | void): void;
|
|
59
63
|
private effector;
|
|
60
64
|
/**
|
|
@@ -92,7 +96,7 @@ export declare class lazy<Type> {
|
|
|
92
96
|
* - update a cradova Comp automatically
|
|
93
97
|
* @constructor initial: unknown, props: {useHistory, persist}
|
|
94
98
|
*/
|
|
95
|
-
export declare class
|
|
99
|
+
export declare class Signal<Type extends Record<string, any>> {
|
|
96
100
|
private callback;
|
|
97
101
|
private persistName;
|
|
98
102
|
private actions;
|
|
@@ -108,7 +112,7 @@ export declare class createSignal<Type extends Record<string, any>> {
|
|
|
108
112
|
* @param value - signal value
|
|
109
113
|
* @returns void
|
|
110
114
|
*/
|
|
111
|
-
set(value: Type | ((value: Type) => Type),
|
|
115
|
+
set(value: Type | ((value: Type) => Type), shouldCompRender?: boolean): void;
|
|
112
116
|
/**
|
|
113
117
|
* Cradova Signal
|
|
114
118
|
* ----
|
|
@@ -117,7 +121,7 @@ export declare class createSignal<Type extends Record<string, any>> {
|
|
|
117
121
|
* @param value - value of the key
|
|
118
122
|
* @returns void
|
|
119
123
|
*/
|
|
120
|
-
setKey<k extends keyof Type>(key: k, value: unknown,
|
|
124
|
+
setKey<k extends keyof Type>(key: k, value: unknown, shouldCompRender?: boolean): void;
|
|
121
125
|
/**
|
|
122
126
|
* Cradova Signal
|
|
123
127
|
* ----
|
|
@@ -159,10 +163,10 @@ export declare class createSignal<Type extends Record<string, any>> {
|
|
|
159
163
|
*
|
|
160
164
|
* @param Comp component to bind to.
|
|
161
165
|
*/
|
|
162
|
-
|
|
166
|
+
bindComp(comp: Comp, binding?: {
|
|
163
167
|
event?: string;
|
|
164
|
-
signalProperty
|
|
165
|
-
_element_property
|
|
168
|
+
signalProperty?: string;
|
|
169
|
+
_element_property?: string;
|
|
166
170
|
}): void;
|
|
167
171
|
/**
|
|
168
172
|
* Cradova Signal
|
|
@@ -199,12 +203,7 @@ export declare class Page {
|
|
|
199
203
|
private _callBack;
|
|
200
204
|
private _deCallBack;
|
|
201
205
|
private _dropped;
|
|
202
|
-
/**
|
|
203
|
-
* error handler for the page
|
|
204
|
-
*/
|
|
205
|
-
_errorHandler: ((err: unknown) => void) | null;
|
|
206
206
|
constructor(cradova_page_initials: CradovaPageType);
|
|
207
|
-
set errorHandler(errorHandler: (err: unknown) => void);
|
|
208
207
|
onActivate(cb: () => Promise<void> | void): void;
|
|
209
208
|
onDeactivate(cb: () => Promise<void> | void): void;
|
|
210
209
|
_deActivate(): Promise<void>;
|
|
@@ -226,7 +225,7 @@ export declare class Router {
|
|
|
226
225
|
*
|
|
227
226
|
* accepts an object containing pat and page
|
|
228
227
|
*/
|
|
229
|
-
static BrowserRoutes(obj: Record<string, Page |
|
|
228
|
+
static BrowserRoutes(obj: Record<string, browserPageType<Page | unknown>>): void;
|
|
230
229
|
/**
|
|
231
230
|
Go back in Navigation history
|
|
232
231
|
*/
|
|
@@ -253,7 +252,7 @@ export declare class Router {
|
|
|
253
252
|
* @param data object
|
|
254
253
|
* @param force boolean
|
|
255
254
|
*/
|
|
256
|
-
static navigate(href: string, data?: Record<string,
|
|
255
|
+
static navigate(href: string, data?: Record<string, any>): void;
|
|
257
256
|
/**
|
|
258
257
|
* Cradova
|
|
259
258
|
* ---
|
|
@@ -279,7 +278,10 @@ export declare class Router {
|
|
|
279
278
|
*
|
|
280
279
|
* .
|
|
281
280
|
*/
|
|
282
|
-
static get
|
|
281
|
+
static get PageData(): {
|
|
282
|
+
params: Record<string, string>;
|
|
283
|
+
data?: Record<string, any> | undefined;
|
|
284
|
+
};
|
|
283
285
|
/**
|
|
284
286
|
* Cradova
|
|
285
287
|
* ---
|
|
@@ -288,7 +290,7 @@ export declare class Router {
|
|
|
288
290
|
* @param callback
|
|
289
291
|
* @param path? page path
|
|
290
292
|
*/
|
|
291
|
-
static addErrorHandler(callback: (err
|
|
293
|
+
static addErrorHandler(callback: (err?: unknown, pagePath?: string) => void): void;
|
|
292
294
|
static _mount(): void;
|
|
293
295
|
}
|
|
294
296
|
export {};
|
|
@@ -52,7 +52,7 @@ export declare const frag: (children: VJS_params_TYPE<HTMLElement>) => DocumentF
|
|
|
52
52
|
* @param Comp
|
|
53
53
|
* @returns [state, setState]
|
|
54
54
|
*/
|
|
55
|
-
export declare function useState<S = unknown>(newState: S, Comp: Comp): [S, (newState: S | ((preS: S) => S)) => void];
|
|
55
|
+
export declare function useState<S = unknown>(newState: S, Comp: Comp<any>): [S, (newState: S | ((preS: S) => S)) => void];
|
|
56
56
|
/**
|
|
57
57
|
* Cradova
|
|
58
58
|
* ---
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as CSS from "csstype";
|
|
2
|
-
import { Comp, Page
|
|
2
|
+
import { Comp, Page } from "./classes";
|
|
3
3
|
type DataAttributes = {
|
|
4
4
|
[key: `data-${string}`]: string;
|
|
5
5
|
};
|
|
@@ -24,7 +24,7 @@ type Attributes = {
|
|
|
24
24
|
required?: string;
|
|
25
25
|
frameBorder?: string;
|
|
26
26
|
placeholder?: string;
|
|
27
|
-
reference?:
|
|
27
|
+
reference?: [any, string];
|
|
28
28
|
autocomplete?: string;
|
|
29
29
|
style?: CSS.Properties;
|
|
30
30
|
recall?: (P: any) => void;
|
|
@@ -67,5 +67,5 @@ export type CradovaPageType = {
|
|
|
67
67
|
*/
|
|
68
68
|
template: (this: Page) => HTMLElement;
|
|
69
69
|
};
|
|
70
|
-
export type
|
|
70
|
+
export type browserPageType<importType = Page> = importType | Promise<importType> | (() => Promise<importType>);
|
|
71
71
|
export {};
|