cradova 3.3.17 → 3.3.19
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
CHANGED
|
@@ -45,29 +45,25 @@ function $case(value, ...elements) {
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
function $switch(key, ...cases) {
|
|
48
|
+
let element;
|
|
48
49
|
if (cases.length) {
|
|
49
50
|
for (let i = 0;i < cases.length; i++) {
|
|
50
|
-
const
|
|
51
|
-
const elements = case_N(key);
|
|
51
|
+
const elements = cases[i](key);
|
|
52
52
|
if (elements) {
|
|
53
|
-
|
|
53
|
+
break;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
return;
|
|
57
|
+
return element;
|
|
58
58
|
}
|
|
59
59
|
function loop(datalist, component) {
|
|
60
|
-
if (typeof component !== "function") {
|
|
61
|
-
throw new Error(" \u2718 Cradova err : Invalid component type, must be a function that returns html ");
|
|
62
|
-
}
|
|
63
60
|
return Array.isArray(datalist) ? datalist.map(component) : undefined;
|
|
64
61
|
}
|
|
65
62
|
function useState(newState, Comp2) {
|
|
66
63
|
Comp2._state_index += 1;
|
|
67
64
|
const idx = Comp2._state_index;
|
|
68
|
-
if (
|
|
65
|
+
if (idx >= Comp2._state.length) {
|
|
69
66
|
Comp2._state[idx] = newState;
|
|
70
|
-
Comp2._state_track[idx] = true;
|
|
71
67
|
}
|
|
72
68
|
function setState(newState2) {
|
|
73
69
|
Comp2._state[idx] = newState2;
|
|
@@ -201,7 +197,6 @@ var frag = function(children) {
|
|
|
201
197
|
continue;
|
|
202
198
|
}
|
|
203
199
|
console.error(" \u2718 Cradova err: wrong element type" + html);
|
|
204
|
-
throw new TypeError(" \u2718 Cradova err: invalid element");
|
|
205
200
|
}
|
|
206
201
|
return par;
|
|
207
202
|
};
|
|
@@ -245,13 +240,12 @@ class Comp {
|
|
|
245
240
|
reference = new __raw_ref;
|
|
246
241
|
Signal;
|
|
247
242
|
_state = [];
|
|
248
|
-
_state_track = {};
|
|
249
243
|
_state_index = 0;
|
|
244
|
+
test;
|
|
250
245
|
constructor(component) {
|
|
251
246
|
this.component = component.bind(this);
|
|
252
247
|
CradovaEvent.addBeforeMountActive(() => {
|
|
253
248
|
this._state_index = 0;
|
|
254
|
-
this._state_track = {};
|
|
255
249
|
this._state = [];
|
|
256
250
|
});
|
|
257
251
|
}
|
|
@@ -560,7 +554,6 @@ class Page {
|
|
|
560
554
|
return this._dropped;
|
|
561
555
|
}
|
|
562
556
|
async _activate() {
|
|
563
|
-
console.log("boohoo 1");
|
|
564
557
|
if (this._dropped) {
|
|
565
558
|
history.go(-1);
|
|
566
559
|
return;
|
|
@@ -610,7 +603,6 @@ class RouterBoxClass {
|
|
|
610
603
|
if (typeof page !== "undefined") {
|
|
611
604
|
if (page && !page) {
|
|
612
605
|
console.error(" \u2718 Cradova err: not a valid page ", page);
|
|
613
|
-
throw new Error(" \u2718 Cradova err: Not a valid cradova page component");
|
|
614
606
|
}
|
|
615
607
|
return this.routes[path] = page;
|
|
616
608
|
}
|
|
@@ -622,16 +614,12 @@ class RouterBoxClass {
|
|
|
622
614
|
window.location.hash = "paused";
|
|
623
615
|
return;
|
|
624
616
|
}
|
|
625
|
-
if (url === this.lastNavigatedRoute) {
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
617
|
if (this.nextRouteController) {
|
|
629
618
|
route = this.nextRouteController;
|
|
630
619
|
this.nextRouteController = undefined;
|
|
631
620
|
} else {
|
|
632
621
|
[route, params] = this.checker(url);
|
|
633
622
|
}
|
|
634
|
-
console.log({ url, route });
|
|
635
623
|
if (typeof route !== "undefined") {
|
|
636
624
|
try {
|
|
637
625
|
if (typeof route === "function") {
|
|
@@ -674,11 +662,8 @@ class RouterBoxClass {
|
|
|
674
662
|
}
|
|
675
663
|
checker(url) {
|
|
676
664
|
if (url[0] !== "/") {
|
|
677
|
-
console.log(url, 1);
|
|
678
665
|
url = url.slice(url.indexOf("/", 8));
|
|
679
|
-
console.log(url, 2);
|
|
680
666
|
}
|
|
681
|
-
console.log(url);
|
|
682
667
|
if (this.routes[url]) {
|
|
683
668
|
return [this.routes[url], { path: url }];
|
|
684
669
|
}
|
|
@@ -748,7 +733,6 @@ class Router {
|
|
|
748
733
|
RouterBox.route(path, page);
|
|
749
734
|
}
|
|
750
735
|
}
|
|
751
|
-
console.log(RouterBox.routes);
|
|
752
736
|
Router._mount();
|
|
753
737
|
}
|
|
754
738
|
static back() {
|
|
@@ -768,15 +752,12 @@ class Router {
|
|
|
768
752
|
}
|
|
769
753
|
static navigate(href, data = null) {
|
|
770
754
|
if (typeof href !== "string") {
|
|
771
|
-
|
|
755
|
+
console.error(" \u2718 Cradova err: href must be a defined path but got " + href + " instead");
|
|
772
756
|
}
|
|
773
757
|
let route = null, params;
|
|
774
758
|
if (href.includes(".")) {
|
|
775
759
|
window.location.href = href;
|
|
776
760
|
} else {
|
|
777
|
-
if (href === window.location.href) {
|
|
778
|
-
return;
|
|
779
|
-
}
|
|
780
761
|
[route, params] = RouterBox.checker(href);
|
|
781
762
|
if (route) {
|
|
782
763
|
RouterBox.nextRouteController = route;
|
|
@@ -42,10 +42,8 @@ export declare class Comp<Prop extends Record<string, any> = any> {
|
|
|
42
42
|
private reference;
|
|
43
43
|
Signal: createSignal<any> | undefined;
|
|
44
44
|
_state: Prop[];
|
|
45
|
-
_state_track: {
|
|
46
|
-
[x: number]: boolean;
|
|
47
|
-
};
|
|
48
45
|
_state_index: number;
|
|
46
|
+
test?: string;
|
|
49
47
|
constructor(component: (this: Comp<Prop>) => HTMLElement);
|
|
50
48
|
preRender(): void;
|
|
51
49
|
/**
|
|
@@ -10,8 +10,8 @@ export declare function Rhoda(l: VJS_params_TYPE<HTMLElement>): DocumentFragment
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function $if<E>(condition: any, ...elements: VJS_params_TYPE<E>): any;
|
|
12
12
|
export declare function $ifelse(condition: any, ifTrue: any, ifFalse?: any): any;
|
|
13
|
-
export declare function $case<E>(value: any, ...elements: VJS_params_TYPE<E>): (key: any) => VJS_params_TYPE<E> | undefined;
|
|
14
|
-
export declare function $switch(key: unknown, ...cases: ((key: any) =>
|
|
13
|
+
export declare function $case<E = HTMLElement>(value: any, ...elements: VJS_params_TYPE<E>): (key: any) => VJS_params_TYPE<E> | undefined;
|
|
14
|
+
export declare function $switch(key: unknown, ...cases: ((key: any) => any)[]): undefined;
|
|
15
15
|
type LoopData<Type> = Type[];
|
|
16
16
|
export declare function loop<Type>(datalist: LoopData<Type>, component: (value: Type, index?: number, array?: LoopData<Type>) => HTMLElement | DocumentFragment | undefined): HTMLElement[] | undefined;
|
|
17
17
|
/** Calculate a simple numerical representation of the URL */
|