cradova 3.3.9 → 3.3.11

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
@@ -124,7 +124,7 @@ var makeElement = (element, ElementChildrenAndPropertyList) => {
124
124
  if (!href.includes("://")) {
125
125
  element.addEventListener("click", (e) => {
126
126
  e.preventDefault();
127
- Router.navigate(element.pathname);
127
+ Router.navigate(element.href);
128
128
  if (href.includes("#")) {
129
129
  const l = href.split("#").at(-1);
130
130
  document.getElementById("#" + l)?.scrollIntoView();
@@ -555,7 +555,7 @@ class Page {
555
555
  this._deCallBack = cb;
556
556
  }
557
557
  async _deActivate() {
558
- this._deCallBack && await this._deCallBack(localTree.globalTree["doc"]);
558
+ this._deCallBack && await this._deCallBack();
559
559
  }
560
560
  drop(state) {
561
561
  if (typeof state === "boolean") {
@@ -587,7 +587,7 @@ class Page {
587
587
  left: 0,
588
588
  behavior: "instant"
589
589
  });
590
- this._callBack && await this._callBack(localTree.globalTree["doc"]);
590
+ this._callBack && await this._callBack();
591
591
  }
592
592
  }
593
593
 
@@ -621,7 +621,7 @@ class RouterBoxClass {
621
621
  return;
622
622
  }
623
623
  async router(_e, _force) {
624
- let url = window.location.pathname, route, params;
624
+ let url = window.location.href, route, params;
625
625
  if (this.paused) {
626
626
  window.location.hash = "paused";
627
627
  return;
@@ -682,17 +682,16 @@ class RouterBoxClass {
682
682
  if (this.routes[url]) {
683
683
  return [this.routes[url], { path: url }];
684
684
  }
685
- if (this.routes[url + "/"]) {
686
- return [this.routes[url + "/"], { path: url }];
687
- }
688
- if (url.includes("/?")) {
689
- const sraw = [...new URLSearchParams(url).entries()];
690
- const search = {};
691
- for (const idx in sraw) {
692
- search[sraw[idx][0].includes("?") ? sraw[idx][0].split("?")[1] : sraw[idx][0]] = sraw[idx][1];
685
+ if (url.includes("?")) {
686
+ let search;
687
+ const params = {};
688
+ [url, search] = url.split("?");
689
+ new URLSearchParams(search).forEach((val, key) => {
690
+ params[key] = val;
691
+ });
692
+ if (this.routes[url]) {
693
+ return [this.routes[url], { data: params, path: url }];
693
694
  }
694
- const path = url.slice(0, url.indexOf("/?") + 2);
695
- return [this.routes[path], { path, search }];
696
695
  }
697
696
  for (const path in this.routes) {
698
697
  if (path.includes(":")) {
@@ -774,7 +773,7 @@ class Router {
774
773
  if (href.includes(".")) {
775
774
  window.location.href = href;
776
775
  } else {
777
- if (href === window.location.pathname) {
776
+ if (href === window.location.href) {
778
777
  return;
779
778
  }
780
779
  [route, params] = RouterBox.checker(href);
@@ -1,4 +1,4 @@
1
- import { type CradovaPageType } from "./types";
1
+ import { type CradovaPageType, type promisedPage } from "./types";
2
2
  /**
3
3
  * Cradova event
4
4
  */
@@ -240,7 +240,7 @@ export declare class Router {
240
240
  *
241
241
  * accepts an object containing pat and page
242
242
  */
243
- static BrowserRoutes(obj: Record<string, any>): void;
243
+ static BrowserRoutes(obj: Record<string, Page | promisedPage>): void;
244
244
  /**
245
245
  Go back in Navigation history
246
246
  */
@@ -30,7 +30,7 @@ type Attributes = {
30
30
  recall?: (P: any) => void;
31
31
  onmount?: (this: HTMLElement & Attributes) => void;
32
32
  };
33
- export type VJS_params_TYPE<E = HTMLElement> = (Comp | Comp[] | string | undefined | HTMLElement | HTMLElement[] | DocumentFragment | Attributes | (() => HTMLElement) | Partial<Attributes> | Partial<E> | Record<string, (this: E) => void> | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number>)[];
33
+ export type VJS_params_TYPE<E = HTMLElement> = (Comp | Comp[] | string | undefined | HTMLElement | HTMLElement[] | DocumentFragment | DocumentFragment[] | Attributes | (() => HTMLElement) | Partial<Attributes> | Partial<E> | Record<string, (this: E) => void> | Partial<DataAttributes> | Partial<AriaAttributes> | CSS.Properties<string | number>)[];
34
34
  export interface RouterRouteObject {
35
35
  _html: ((this: Page, data?: unknown) => HTMLElement | DocumentFragment) | HTMLElement | DocumentFragment;
36
36
  _delegatedRoutes: number | boolean;
@@ -67,4 +67,5 @@ export type CradovaPageType = {
67
67
  */
68
68
  template: (this: Page) => HTMLElement;
69
69
  };
70
+ export type promisedPage = (() => Promise<Page>);
70
71
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cradova",
3
- "version": "3.3.9",
3
+ "version": "3.3.11",
4
4
  "description": "Build Powerful ⚡ Web Apps with Ease",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",