reactive-route 0.0.1-alpha.33 → 0.0.1-alpha.35
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/adapters/mobx-preact.cjs +1 -0
- package/adapters/mobx-preact.d.ts.map +1 -1
- package/adapters/mobx-preact.mjs +1 -0
- package/adapters/mobx-react.cjs +1 -0
- package/adapters/mobx-react.d.ts.map +1 -1
- package/adapters/mobx-react.mjs +1 -0
- package/adapters/mobx-solid.cjs +1 -0
- package/adapters/mobx-solid.d.ts.map +1 -1
- package/adapters/mobx-solid.mjs +1 -0
- package/adapters/solid.cjs +1 -0
- package/adapters/solid.d.ts.map +1 -1
- package/adapters/solid.mjs +1 -0
- package/adapters/vue.cjs +1 -0
- package/adapters/vue.d.ts.map +1 -1
- package/adapters/vue.mjs +1 -0
- package/core/createRouter.d.ts.map +1 -1
- package/core/createRoutes.d.ts +6 -8
- package/core/createRoutes.d.ts.map +1 -1
- package/core/types/TypeCurrentRoute.d.ts +1 -0
- package/core/types/TypeCurrentRoute.d.ts.map +1 -1
- package/core/types/TypeRouter.d.ts +8 -4
- package/core/types/TypeRouter.d.ts.map +1 -1
- package/core/utils/constants.d.ts +0 -2
- package/core/utils/constants.d.ts.map +1 -1
- package/core/utils/dynamic.d.ts +1 -1
- package/core/utils/dynamic.d.ts.map +1 -1
- package/core/utils/findRouteByPathname.d.ts.map +1 -1
- package/core/utils/getDynamicValues.d.ts.map +1 -1
- package/core/utils/getQueryValues.d.ts.map +1 -1
- package/core/utils/replaceDynamicValues.d.ts.map +1 -1
- package/core/utils/routerSetLoadedComponent.d.ts.map +1 -1
- package/index.cjs +57 -42
- package/index.mjs +57 -42
- package/package.json +1 -1
- package/preact/Router.d.ts +1 -1
- package/preact/Router.d.ts.map +1 -1
- package/preact/index.cjs +3 -7
- package/preact/index.mjs +3 -7
- package/react/Router.d.ts +1 -3
- package/react/Router.d.ts.map +1 -1
- package/react/index.cjs +4 -7
- package/react/index.mjs +5 -8
- package/solid/Router.d.ts.map +1 -1
- package/solid/index.cjs +1 -1
- package/solid/index.mjs +1 -1
- package/vue/index.cjs +0 -0
- package/vue/index.mjs +0 -0
- package/core/utils/addNames.d.ts +0 -8
- package/core/utils/addNames.d.ts.map +0 -1
package/adapters/mobx-preact.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx-preact.d.ts","sourceRoot":"","sources":["../../packages/adapters/mobx-preact.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"mobx-preact.d.ts","sourceRoot":"","sources":["../../packages/adapters/mobx-preact.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,YAgBtB,CAAC"}
|
package/adapters/mobx-preact.mjs
CHANGED
package/adapters/mobx-react.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx-react.d.ts","sourceRoot":"","sources":["../../packages/adapters/mobx-react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"mobx-react.d.ts","sourceRoot":"","sources":["../../packages/adapters/mobx-react.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,YAgBtB,CAAC"}
|
package/adapters/mobx-react.mjs
CHANGED
package/adapters/mobx-solid.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mobx-solid.d.ts","sourceRoot":"","sources":["../../packages/adapters/mobx-solid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"mobx-solid.d.ts","sourceRoot":"","sources":["../../packages/adapters/mobx-solid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,eAAO,MAAM,QAAQ,EAAE,YAgBtB,CAAC"}
|
package/adapters/mobx-solid.mjs
CHANGED
package/adapters/solid.cjs
CHANGED
package/adapters/solid.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../../packages/adapters/solid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"solid.d.ts","sourceRoot":"","sources":["../../packages/adapters/solid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,eAAO,MAAM,QAAQ,EAAE,YAoBtB,CAAC"}
|
package/adapters/solid.mjs
CHANGED
package/adapters/vue.cjs
CHANGED
package/adapters/vue.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../../packages/adapters/vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"vue.d.ts","sourceRoot":"","sources":["../../packages/adapters/vue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,QAAQ,EAAE,YActB,CAAC"}
|
package/adapters/vue.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../../packages/core/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"createRouter.d.ts","sourceRoot":"","sources":["../../packages/core/createRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAWhD,wBAAgB,YAAY,CAC1B,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,EACxE,MAAM,EAAE;IACR,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;CAC9B,GAAG,UAAU,CAAC,OAAO,CAAC,CAgRtB"}
|
package/core/createRoutes.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { TypeRouteRaw } from './types/TypeRouteRaw';
|
|
2
2
|
export declare function createRoutes<TConfig extends {
|
|
3
3
|
[Key in keyof TConfig | 'notFound' | 'internalError']: TypeRouteRaw;
|
|
4
|
-
}>(config: TConfig): {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
};
|
|
4
|
+
}>(config: TConfig): { [Key in keyof TConfig]: TConfig[Key] & {
|
|
5
|
+
name: Key;
|
|
6
|
+
pageId?: string;
|
|
7
|
+
component?: any;
|
|
8
|
+
otherExports?: Record<string, any>;
|
|
9
|
+
}; };
|
|
12
10
|
//# sourceMappingURL=createRoutes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoutes.d.ts","sourceRoot":"","sources":["../../packages/core/createRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"createRoutes.d.ts","sourceRoot":"","sources":["../../packages/core/createRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,wBAAgB,YAAY,CAC1B,OAAO,SAAS;KAAG,GAAG,IAAI,MAAM,OAAO,GAAG,UAAU,GAAG,eAAe,GAAG,YAAY;CAAE,EACvF,MAAM,EAAE,OAAO,GAKE,GACd,GAAG,IAAI,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,GAAG;IACrC,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,GAAG,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACpC,GACF,CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeCurrentRoute.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeCurrentRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,SAAS,IAAI;IACvD,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,MAAM,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"TypeCurrentRoute.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeCurrentRoute.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,gBAAgB,CAAC,MAAM,SAAS,SAAS,IAAI;IACvD,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACvB,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;IACtD,MAAM,EAAE,MAAM,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;IAC/C,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACnB,CAAC"}
|
|
@@ -5,15 +5,19 @@ import { TypeRoute } from './TypeRoute';
|
|
|
5
5
|
export type TypeRouter<TRoutes extends Record<string | 'notFound' | 'internalError', TypeRoute>> = {
|
|
6
6
|
routes: TRoutes;
|
|
7
7
|
adapters: TypeAdapters;
|
|
8
|
-
currentRoute:
|
|
8
|
+
currentRoute: {
|
|
9
|
+
[TRouteName in keyof TRoutes | 'notFound' | 'internalError']: TypeCurrentRoute<TRoutes[TRouteName]> | undefined;
|
|
10
|
+
};
|
|
9
11
|
isRedirecting: boolean;
|
|
10
|
-
redirect<TRouteName extends keyof TRoutes>(config: TypeRedirectParams<TRoutes, TRouteName>): Promise<
|
|
12
|
+
redirect<TRouteName extends keyof TRoutes>(config: TypeRedirectParams<TRoutes, TRouteName>): Promise<string>;
|
|
11
13
|
restoreFromURL(params: {
|
|
12
14
|
pathname: string;
|
|
13
15
|
replace?: boolean;
|
|
14
|
-
}): Promise<
|
|
16
|
+
}): Promise<string>;
|
|
15
17
|
restoreFromServer(obj: {
|
|
16
|
-
currentRoute:
|
|
18
|
+
currentRoute: {
|
|
19
|
+
[TRouteName in keyof TRoutes]: TypeCurrentRoute<TRoutes[TRouteName]> | undefined;
|
|
20
|
+
};
|
|
17
21
|
}): Promise<void>;
|
|
18
22
|
lifecycleParams?: Array<any>;
|
|
19
23
|
destroy(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,IAAI;IACjG,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE,gBAAgB,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"TypeRouter.d.ts","sourceRoot":"","sources":["../../../packages/core/types/TypeRouter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,MAAM,UAAU,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,UAAU,GAAG,eAAe,EAAE,SAAS,CAAC,IAAI;IACjG,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,YAAY,CAAC;IACvB,YAAY,EAAE;SACX,UAAU,IAAI,MAAM,OAAO,GAAG,UAAU,GAAG,eAAe,GACvD,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GACrC,SAAS;KACd,CAAC;IACF,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,UAAU,SAAS,MAAM,OAAO,EACvC,MAAM,EAAE,kBAAkB,CAAC,OAAO,EAAE,UAAU,CAAC,GAC9C,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,cAAc,CAAC,MAAM,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IACjF,iBAAiB,CAAC,GAAG,EAAE;QACrB,YAAY,EAAE;aACX,UAAU,IAAI,MAAM,OAAO,GAAG,gBAAgB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS;SACjF,CAAC;KACH,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClB,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;CAErB,CAAC"}
|
package/core/utils/dynamic.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { TypeRoute } from '../types/TypeRoute';
|
|
2
2
|
import { TypeValidator } from '../types/TypeValidator';
|
|
3
3
|
export declare function isDynamic(param: string): boolean;
|
|
4
|
-
export declare function clearDynamic(param: string): string;
|
|
5
4
|
export declare function isDynamicRoute<TRoute extends TypeRoute>(route: TRoute): route is TRoute & {
|
|
6
5
|
params: Record<keyof TRoute, TypeValidator>;
|
|
7
6
|
};
|
|
7
|
+
export declare function clearDynamic(param: string): string;
|
|
8
8
|
//# sourceMappingURL=dynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/dynamic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"dynamic.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/dynamic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEhD;AAED,wBAAgB,cAAc,CAAC,MAAM,SAAS,SAAS,EACrD,KAAK,EAAE,MAAM,GACZ,KAAK,IAAI,MAAM,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC,MAAM,MAAM,EAAE,aAAa,CAAC,CAAA;CAAE,CAEnE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findRouteByPathname.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/findRouteByPathname.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"findRouteByPathname.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/findRouteByPathname.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAO/C,wBAAgB,mBAAmB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,EAC7E,QAAQ,EACR,MAAM,GACP,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB,GAAG,OAAO,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,CAkDrC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDynamicValues.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getDynamicValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"getDynamicValues.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getDynamicValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAG/C,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,SAAS,EAAE,MAAM,EAAE;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAqBzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getQueryValues.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getQueryValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,wBAAgB,cAAc,CAAC,MAAM,SAAS,SAAS,EAAE,MAAM,EAAE;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"getQueryValues.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/getQueryValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI/C,wBAAgB,cAAc,CAAC,MAAM,SAAS,SAAS,EAAE,MAAM,EAAE;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAoBjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replaceDynamicValues.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/replaceDynamicValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"replaceDynamicValues.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/replaceDynamicValues.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,wBAAgB,oBAAoB,CAAC,UAAU,SAAS,SAAS,GAAG,gBAAgB,CAAC,SAAS,CAAC,EAAE,EAC/F,KAAK,EACL,MAAkB,GACnB,EAAE;IACD,KAAK,EAAE,UAAU,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,CAAC;CACrD,GAAG,MAAM,CAcT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerSetLoadedComponent.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/routerSetLoadedComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE;IACN,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC,
|
|
1
|
+
{"version":3,"file":"routerSetLoadedComponent.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/routerSetLoadedComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,CAAC,GAAG,CAAC,EAC3B,MAAM,EAAE;IACN,mBAAmB,CAAC,EAAE,GAAG,CAAC;IAC1B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CACnC,QAoCF"}
|
package/index.cjs
CHANGED
|
@@ -31,24 +31,22 @@ module.exports = __toCommonJS(core_exports);
|
|
|
31
31
|
|
|
32
32
|
// packages/core/utils/constants.ts
|
|
33
33
|
var constants = {
|
|
34
|
-
dynamicSeparator: ":",
|
|
35
|
-
pathPartSeparator: "/",
|
|
36
34
|
isClient: typeof window !== "undefined"
|
|
37
35
|
};
|
|
38
36
|
|
|
39
37
|
// packages/core/utils/dynamic.ts
|
|
40
38
|
function isDynamic(param) {
|
|
41
|
-
return param[0] ===
|
|
39
|
+
return param[0] === ":";
|
|
42
40
|
}
|
|
43
41
|
function clearDynamic(param) {
|
|
44
|
-
return param.replace(
|
|
42
|
+
return param.replace(/^:/, "");
|
|
45
43
|
}
|
|
46
44
|
|
|
47
45
|
// packages/core/utils/getDynamicValues.ts
|
|
48
46
|
function getDynamicValues(params) {
|
|
49
47
|
const { route, pathname } = params;
|
|
50
|
-
const pathnameArray = pathname.replace(/\?.+$/, "").split(
|
|
51
|
-
const routePathnameArray = route.path.split(
|
|
48
|
+
const pathnameArray = pathname.replace(/\?.+$/, "").split("/").filter(Boolean).map((str) => decodeURIComponent(str));
|
|
49
|
+
const routePathnameArray = route.path.split("/").filter(Boolean);
|
|
52
50
|
const dynamicParams = {};
|
|
53
51
|
for (let i = 0; i < routePathnameArray.length; i++) {
|
|
54
52
|
const paramName = routePathnameArray[i];
|
|
@@ -59,20 +57,20 @@ function getDynamicValues(params) {
|
|
|
59
57
|
|
|
60
58
|
// packages/core/utils/findRouteByPathname.ts
|
|
61
59
|
function completeStaticMatch(pathname, path) {
|
|
62
|
-
return !path.includes(
|
|
60
|
+
return !path.includes(":") && (pathname === path || pathname === `${path}/`);
|
|
63
61
|
}
|
|
64
62
|
function findRouteByPathname({
|
|
65
63
|
pathname,
|
|
66
64
|
routes
|
|
67
65
|
}) {
|
|
68
66
|
let dynamicRouteMatch;
|
|
69
|
-
const pathnameArray = pathname.replace(/\?.+$/, "").split(
|
|
67
|
+
const pathnameArray = pathname.replace(/\?.+$/, "").split("/").filter(Boolean);
|
|
70
68
|
for (const routeName in routes) {
|
|
71
69
|
if (!Object.hasOwn(routes, routeName)) continue;
|
|
72
70
|
const route = routes[routeName];
|
|
73
71
|
if (completeStaticMatch(pathname, route.path)) return route;
|
|
74
72
|
if (dynamicRouteMatch) continue;
|
|
75
|
-
const routePathnameArray = route.path.split(
|
|
73
|
+
const routePathnameArray = route.path.split("/").filter(Boolean);
|
|
76
74
|
if (routePathnameArray.length !== pathnameArray.length) continue;
|
|
77
75
|
const someParamInvalid = routePathnameArray.some((paramName, i) => {
|
|
78
76
|
const paramFromUrl = pathnameArray[i];
|
|
@@ -113,8 +111,9 @@ var queryString = {
|
|
|
113
111
|
// packages/core/utils/getQueryValues.ts
|
|
114
112
|
function getQueryValues(params) {
|
|
115
113
|
const { route, pathname } = params;
|
|
114
|
+
if (!route.query) return {};
|
|
116
115
|
const qs = queryString.extract(pathname);
|
|
117
|
-
if (!qs
|
|
116
|
+
if (!qs) return {};
|
|
118
117
|
const query = queryString.parse(qs);
|
|
119
118
|
getTypedEntries(query).forEach(([key, value]) => {
|
|
120
119
|
const validator = route.query[key];
|
|
@@ -166,7 +165,7 @@ var RedirectError = class extends Error {
|
|
|
166
165
|
};
|
|
167
166
|
|
|
168
167
|
// packages/core/utils/replaceDynamicValues.ts
|
|
169
|
-
var re = new RegExp(`[
|
|
168
|
+
var re = new RegExp(`[^/]+`, "g");
|
|
170
169
|
function replaceDynamicValues({
|
|
171
170
|
route,
|
|
172
171
|
params = {}
|
|
@@ -206,8 +205,11 @@ function createRouter(config) {
|
|
|
206
205
|
router.adapters.batch(() => {
|
|
207
206
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
208
207
|
});
|
|
208
|
+
const activeRoute = Object.values(
|
|
209
|
+
router.currentRoute
|
|
210
|
+
).find((currentRoute) => currentRoute?.isActive);
|
|
209
211
|
const preloadedRouteName = Object.keys(router.routes).find(
|
|
210
|
-
(routeName) =>
|
|
212
|
+
(routeName) => activeRoute?.name === routeName
|
|
211
213
|
);
|
|
212
214
|
return loadComponentToConfig({ route: router.routes[preloadedRouteName] });
|
|
213
215
|
};
|
|
@@ -221,14 +223,14 @@ function createRouter(config) {
|
|
|
221
223
|
let currentUrl;
|
|
222
224
|
let currentSearch;
|
|
223
225
|
let currentQuery;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
});
|
|
230
|
-
currentQuery =
|
|
231
|
-
currentSearch = queryString.stringify(
|
|
226
|
+
const activeRoute = Object.values(
|
|
227
|
+
router.currentRoute
|
|
228
|
+
).find((currentRoute2) => currentRoute2?.isActive);
|
|
229
|
+
if (activeRoute) {
|
|
230
|
+
currentRoute = router.routes[activeRoute.name];
|
|
231
|
+
currentPathname = replaceDynamicValues({ route: currentRoute, params: activeRoute.params });
|
|
232
|
+
currentQuery = activeRoute.query;
|
|
233
|
+
currentSearch = queryString.stringify(activeRoute.query);
|
|
232
234
|
currentUrl = `${currentPathname}${currentSearch ? `?${currentSearch}` : ""}`;
|
|
233
235
|
}
|
|
234
236
|
const nextRoute = router.routes[routeName];
|
|
@@ -250,12 +252,12 @@ function createRouter(config) {
|
|
|
250
252
|
nextUrl = `${nextPathname}?${nextSearch}`;
|
|
251
253
|
}
|
|
252
254
|
}
|
|
253
|
-
if (currentUrl === nextUrl) return
|
|
255
|
+
if (currentUrl === nextUrl) return nextUrl;
|
|
254
256
|
if (currentPathname === nextPathname) {
|
|
255
257
|
if (currentSearch !== nextSearch) {
|
|
256
258
|
router.adapters.batch(() => {
|
|
257
|
-
router.adapters.replaceObject(router.currentRoute, {
|
|
258
|
-
...router.currentRoute,
|
|
259
|
+
router.adapters.replaceObject(router.currentRoute[routeName], {
|
|
260
|
+
...router.currentRoute[routeName],
|
|
259
261
|
query: nextQuery || {}
|
|
260
262
|
});
|
|
261
263
|
});
|
|
@@ -263,7 +265,7 @@ function createRouter(config) {
|
|
|
263
265
|
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
264
266
|
}
|
|
265
267
|
}
|
|
266
|
-
return
|
|
268
|
+
return nextUrl;
|
|
267
269
|
}
|
|
268
270
|
router.adapters.batch(() => {
|
|
269
271
|
router.isRedirecting = true;
|
|
@@ -309,7 +311,7 @@ function createRouter(config) {
|
|
|
309
311
|
await loadComponentToConfig({ route: router.routes[nextRoute.name] });
|
|
310
312
|
} catch (error) {
|
|
311
313
|
if (error instanceof PreventError) {
|
|
312
|
-
return
|
|
314
|
+
return currentUrl;
|
|
313
315
|
}
|
|
314
316
|
if (error instanceof RedirectError) {
|
|
315
317
|
throw error;
|
|
@@ -317,33 +319,48 @@ function createRouter(config) {
|
|
|
317
319
|
console.error(error);
|
|
318
320
|
await loadComponentToConfig({ route: router.routes.internalError });
|
|
319
321
|
router.adapters.batch(() => {
|
|
320
|
-
|
|
322
|
+
const newObj = {
|
|
321
323
|
name: router.routes.internalError.name,
|
|
322
324
|
path: router.routes.internalError.path,
|
|
323
325
|
props: router.routes[router.routes.internalError.name].props,
|
|
324
326
|
query: router.adapters.makeObservable({}),
|
|
325
327
|
params: router.adapters.makeObservable({}),
|
|
326
|
-
pageId: router.routes[router.routes.internalError.name].pageId
|
|
328
|
+
pageId: router.routes[router.routes.internalError.name].pageId,
|
|
329
|
+
isActive: true
|
|
330
|
+
};
|
|
331
|
+
if (!router.currentRoute.internalError) router.currentRoute.internalError = newObj;
|
|
332
|
+
else router.adapters.replaceObject(router.currentRoute.internalError, newObj);
|
|
333
|
+
Object.values(router.currentRoute).forEach((r) => {
|
|
334
|
+
if (r && r.name !== "internalError") r.isActive = false;
|
|
327
335
|
});
|
|
328
336
|
router.isRedirecting = false;
|
|
329
337
|
});
|
|
330
|
-
return
|
|
338
|
+
return nextUrl;
|
|
331
339
|
}
|
|
332
340
|
router.adapters.batch(() => {
|
|
333
|
-
|
|
341
|
+
const newObj = {
|
|
334
342
|
name: nextRoute.name,
|
|
335
343
|
path: nextRoute.path,
|
|
336
344
|
props: router.routes[nextRoute.name].props,
|
|
337
345
|
query: getQueryValues({ route: nextRoute, pathname: nextUrl }),
|
|
338
346
|
params: getDynamicValues({ route: nextRoute, pathname: nextUrl }),
|
|
339
|
-
pageId: router.routes[nextRoute.name].pageId
|
|
347
|
+
pageId: router.routes[nextRoute.name].pageId,
|
|
348
|
+
isActive: true
|
|
349
|
+
};
|
|
350
|
+
if (!router.currentRoute[routeName]) {
|
|
351
|
+
router.currentRoute[routeName] = newObj;
|
|
352
|
+
} else {
|
|
353
|
+
router.adapters.replaceObject(router.currentRoute[routeName], newObj);
|
|
354
|
+
}
|
|
355
|
+
Object.values(router.currentRoute).forEach((r) => {
|
|
356
|
+
if (r && r.name !== routeName) r.isActive = false;
|
|
340
357
|
});
|
|
341
358
|
if (constants.isClient) {
|
|
342
359
|
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
343
360
|
}
|
|
344
361
|
router.isRedirecting = false;
|
|
345
362
|
});
|
|
346
|
-
return
|
|
363
|
+
return nextUrl;
|
|
347
364
|
};
|
|
348
365
|
function popHandler() {
|
|
349
366
|
const currentUrl = `${location.pathname}${location.search}`;
|
|
@@ -360,23 +377,21 @@ function createRouter(config) {
|
|
|
360
377
|
return router;
|
|
361
378
|
}
|
|
362
379
|
|
|
363
|
-
// packages/core/utils/addNames.ts
|
|
364
|
-
function addNames(obj) {
|
|
365
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
366
|
-
value.name = key;
|
|
367
|
-
});
|
|
368
|
-
return obj;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
380
|
// packages/core/createRoutes.ts
|
|
372
381
|
function createRoutes(config) {
|
|
373
|
-
|
|
382
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
383
|
+
value.name = key;
|
|
384
|
+
});
|
|
385
|
+
return config;
|
|
374
386
|
}
|
|
375
387
|
|
|
376
388
|
// packages/core/utils/routerSetLoadedComponent.ts
|
|
377
389
|
function routerSetLoadedComponent(props, config) {
|
|
378
|
-
const
|
|
379
|
-
|
|
390
|
+
const activeRoute = Object.values(props.router.currentRoute).find(
|
|
391
|
+
(currentRoute) => currentRoute?.isActive
|
|
392
|
+
);
|
|
393
|
+
const currentRouteName = activeRoute?.name;
|
|
394
|
+
const currentRoutePage = activeRoute?.pageId;
|
|
380
395
|
const componentConfig = props.router.routes[currentRouteName];
|
|
381
396
|
let preventRedirect = false;
|
|
382
397
|
if (props.router.isRedirecting) preventRedirect = true;
|
package/index.mjs
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
// packages/core/utils/constants.ts
|
|
2
2
|
var constants = {
|
|
3
|
-
dynamicSeparator: ":",
|
|
4
|
-
pathPartSeparator: "/",
|
|
5
3
|
isClient: typeof window !== "undefined"
|
|
6
4
|
};
|
|
7
5
|
|
|
8
6
|
// packages/core/utils/dynamic.ts
|
|
9
7
|
function isDynamic(param) {
|
|
10
|
-
return param[0] ===
|
|
8
|
+
return param[0] === ":";
|
|
11
9
|
}
|
|
12
10
|
function clearDynamic(param) {
|
|
13
|
-
return param.replace(
|
|
11
|
+
return param.replace(/^:/, "");
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
// packages/core/utils/getDynamicValues.ts
|
|
17
15
|
function getDynamicValues(params) {
|
|
18
16
|
const { route, pathname } = params;
|
|
19
|
-
const pathnameArray = pathname.replace(/\?.+$/, "").split(
|
|
20
|
-
const routePathnameArray = route.path.split(
|
|
17
|
+
const pathnameArray = pathname.replace(/\?.+$/, "").split("/").filter(Boolean).map((str) => decodeURIComponent(str));
|
|
18
|
+
const routePathnameArray = route.path.split("/").filter(Boolean);
|
|
21
19
|
const dynamicParams = {};
|
|
22
20
|
for (let i = 0; i < routePathnameArray.length; i++) {
|
|
23
21
|
const paramName = routePathnameArray[i];
|
|
@@ -28,20 +26,20 @@ function getDynamicValues(params) {
|
|
|
28
26
|
|
|
29
27
|
// packages/core/utils/findRouteByPathname.ts
|
|
30
28
|
function completeStaticMatch(pathname, path) {
|
|
31
|
-
return !path.includes(
|
|
29
|
+
return !path.includes(":") && (pathname === path || pathname === `${path}/`);
|
|
32
30
|
}
|
|
33
31
|
function findRouteByPathname({
|
|
34
32
|
pathname,
|
|
35
33
|
routes
|
|
36
34
|
}) {
|
|
37
35
|
let dynamicRouteMatch;
|
|
38
|
-
const pathnameArray = pathname.replace(/\?.+$/, "").split(
|
|
36
|
+
const pathnameArray = pathname.replace(/\?.+$/, "").split("/").filter(Boolean);
|
|
39
37
|
for (const routeName in routes) {
|
|
40
38
|
if (!Object.hasOwn(routes, routeName)) continue;
|
|
41
39
|
const route = routes[routeName];
|
|
42
40
|
if (completeStaticMatch(pathname, route.path)) return route;
|
|
43
41
|
if (dynamicRouteMatch) continue;
|
|
44
|
-
const routePathnameArray = route.path.split(
|
|
42
|
+
const routePathnameArray = route.path.split("/").filter(Boolean);
|
|
45
43
|
if (routePathnameArray.length !== pathnameArray.length) continue;
|
|
46
44
|
const someParamInvalid = routePathnameArray.some((paramName, i) => {
|
|
47
45
|
const paramFromUrl = pathnameArray[i];
|
|
@@ -82,8 +80,9 @@ var queryString = {
|
|
|
82
80
|
// packages/core/utils/getQueryValues.ts
|
|
83
81
|
function getQueryValues(params) {
|
|
84
82
|
const { route, pathname } = params;
|
|
83
|
+
if (!route.query) return {};
|
|
85
84
|
const qs = queryString.extract(pathname);
|
|
86
|
-
if (!qs
|
|
85
|
+
if (!qs) return {};
|
|
87
86
|
const query = queryString.parse(qs);
|
|
88
87
|
getTypedEntries(query).forEach(([key, value]) => {
|
|
89
88
|
const validator = route.query[key];
|
|
@@ -135,7 +134,7 @@ var RedirectError = class extends Error {
|
|
|
135
134
|
};
|
|
136
135
|
|
|
137
136
|
// packages/core/utils/replaceDynamicValues.ts
|
|
138
|
-
var re = new RegExp(`[
|
|
137
|
+
var re = new RegExp(`[^/]+`, "g");
|
|
139
138
|
function replaceDynamicValues({
|
|
140
139
|
route,
|
|
141
140
|
params = {}
|
|
@@ -175,8 +174,11 @@ function createRouter(config) {
|
|
|
175
174
|
router.adapters.batch(() => {
|
|
176
175
|
Object.assign(router.currentRoute, obj.currentRoute);
|
|
177
176
|
});
|
|
177
|
+
const activeRoute = Object.values(
|
|
178
|
+
router.currentRoute
|
|
179
|
+
).find((currentRoute) => currentRoute?.isActive);
|
|
178
180
|
const preloadedRouteName = Object.keys(router.routes).find(
|
|
179
|
-
(routeName) =>
|
|
181
|
+
(routeName) => activeRoute?.name === routeName
|
|
180
182
|
);
|
|
181
183
|
return loadComponentToConfig({ route: router.routes[preloadedRouteName] });
|
|
182
184
|
};
|
|
@@ -190,14 +192,14 @@ function createRouter(config) {
|
|
|
190
192
|
let currentUrl;
|
|
191
193
|
let currentSearch;
|
|
192
194
|
let currentQuery;
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
});
|
|
199
|
-
currentQuery =
|
|
200
|
-
currentSearch = queryString.stringify(
|
|
195
|
+
const activeRoute = Object.values(
|
|
196
|
+
router.currentRoute
|
|
197
|
+
).find((currentRoute2) => currentRoute2?.isActive);
|
|
198
|
+
if (activeRoute) {
|
|
199
|
+
currentRoute = router.routes[activeRoute.name];
|
|
200
|
+
currentPathname = replaceDynamicValues({ route: currentRoute, params: activeRoute.params });
|
|
201
|
+
currentQuery = activeRoute.query;
|
|
202
|
+
currentSearch = queryString.stringify(activeRoute.query);
|
|
201
203
|
currentUrl = `${currentPathname}${currentSearch ? `?${currentSearch}` : ""}`;
|
|
202
204
|
}
|
|
203
205
|
const nextRoute = router.routes[routeName];
|
|
@@ -219,12 +221,12 @@ function createRouter(config) {
|
|
|
219
221
|
nextUrl = `${nextPathname}?${nextSearch}`;
|
|
220
222
|
}
|
|
221
223
|
}
|
|
222
|
-
if (currentUrl === nextUrl) return
|
|
224
|
+
if (currentUrl === nextUrl) return nextUrl;
|
|
223
225
|
if (currentPathname === nextPathname) {
|
|
224
226
|
if (currentSearch !== nextSearch) {
|
|
225
227
|
router.adapters.batch(() => {
|
|
226
|
-
router.adapters.replaceObject(router.currentRoute, {
|
|
227
|
-
...router.currentRoute,
|
|
228
|
+
router.adapters.replaceObject(router.currentRoute[routeName], {
|
|
229
|
+
...router.currentRoute[routeName],
|
|
228
230
|
query: nextQuery || {}
|
|
229
231
|
});
|
|
230
232
|
});
|
|
@@ -232,7 +234,7 @@ function createRouter(config) {
|
|
|
232
234
|
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
233
235
|
}
|
|
234
236
|
}
|
|
235
|
-
return
|
|
237
|
+
return nextUrl;
|
|
236
238
|
}
|
|
237
239
|
router.adapters.batch(() => {
|
|
238
240
|
router.isRedirecting = true;
|
|
@@ -278,7 +280,7 @@ function createRouter(config) {
|
|
|
278
280
|
await loadComponentToConfig({ route: router.routes[nextRoute.name] });
|
|
279
281
|
} catch (error) {
|
|
280
282
|
if (error instanceof PreventError) {
|
|
281
|
-
return
|
|
283
|
+
return currentUrl;
|
|
282
284
|
}
|
|
283
285
|
if (error instanceof RedirectError) {
|
|
284
286
|
throw error;
|
|
@@ -286,33 +288,48 @@ function createRouter(config) {
|
|
|
286
288
|
console.error(error);
|
|
287
289
|
await loadComponentToConfig({ route: router.routes.internalError });
|
|
288
290
|
router.adapters.batch(() => {
|
|
289
|
-
|
|
291
|
+
const newObj = {
|
|
290
292
|
name: router.routes.internalError.name,
|
|
291
293
|
path: router.routes.internalError.path,
|
|
292
294
|
props: router.routes[router.routes.internalError.name].props,
|
|
293
295
|
query: router.adapters.makeObservable({}),
|
|
294
296
|
params: router.adapters.makeObservable({}),
|
|
295
|
-
pageId: router.routes[router.routes.internalError.name].pageId
|
|
297
|
+
pageId: router.routes[router.routes.internalError.name].pageId,
|
|
298
|
+
isActive: true
|
|
299
|
+
};
|
|
300
|
+
if (!router.currentRoute.internalError) router.currentRoute.internalError = newObj;
|
|
301
|
+
else router.adapters.replaceObject(router.currentRoute.internalError, newObj);
|
|
302
|
+
Object.values(router.currentRoute).forEach((r) => {
|
|
303
|
+
if (r && r.name !== "internalError") r.isActive = false;
|
|
296
304
|
});
|
|
297
305
|
router.isRedirecting = false;
|
|
298
306
|
});
|
|
299
|
-
return
|
|
307
|
+
return nextUrl;
|
|
300
308
|
}
|
|
301
309
|
router.adapters.batch(() => {
|
|
302
|
-
|
|
310
|
+
const newObj = {
|
|
303
311
|
name: nextRoute.name,
|
|
304
312
|
path: nextRoute.path,
|
|
305
313
|
props: router.routes[nextRoute.name].props,
|
|
306
314
|
query: getQueryValues({ route: nextRoute, pathname: nextUrl }),
|
|
307
315
|
params: getDynamicValues({ route: nextRoute, pathname: nextUrl }),
|
|
308
|
-
pageId: router.routes[nextRoute.name].pageId
|
|
316
|
+
pageId: router.routes[nextRoute.name].pageId,
|
|
317
|
+
isActive: true
|
|
318
|
+
};
|
|
319
|
+
if (!router.currentRoute[routeName]) {
|
|
320
|
+
router.currentRoute[routeName] = newObj;
|
|
321
|
+
} else {
|
|
322
|
+
router.adapters.replaceObject(router.currentRoute[routeName], newObj);
|
|
323
|
+
}
|
|
324
|
+
Object.values(router.currentRoute).forEach((r) => {
|
|
325
|
+
if (r && r.name !== routeName) r.isActive = false;
|
|
309
326
|
});
|
|
310
327
|
if (constants.isClient) {
|
|
311
328
|
window.history[replace ? "replaceState" : "pushState"](null, "", nextUrl);
|
|
312
329
|
}
|
|
313
330
|
router.isRedirecting = false;
|
|
314
331
|
});
|
|
315
|
-
return
|
|
332
|
+
return nextUrl;
|
|
316
333
|
};
|
|
317
334
|
function popHandler() {
|
|
318
335
|
const currentUrl = `${location.pathname}${location.search}`;
|
|
@@ -329,23 +346,21 @@ function createRouter(config) {
|
|
|
329
346
|
return router;
|
|
330
347
|
}
|
|
331
348
|
|
|
332
|
-
// packages/core/utils/addNames.ts
|
|
333
|
-
function addNames(obj) {
|
|
334
|
-
Object.entries(obj).forEach(([key, value]) => {
|
|
335
|
-
value.name = key;
|
|
336
|
-
});
|
|
337
|
-
return obj;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
349
|
// packages/core/createRoutes.ts
|
|
341
350
|
function createRoutes(config) {
|
|
342
|
-
|
|
351
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
352
|
+
value.name = key;
|
|
353
|
+
});
|
|
354
|
+
return config;
|
|
343
355
|
}
|
|
344
356
|
|
|
345
357
|
// packages/core/utils/routerSetLoadedComponent.ts
|
|
346
358
|
function routerSetLoadedComponent(props, config) {
|
|
347
|
-
const
|
|
348
|
-
|
|
359
|
+
const activeRoute = Object.values(props.router.currentRoute).find(
|
|
360
|
+
(currentRoute) => currentRoute?.isActive
|
|
361
|
+
);
|
|
362
|
+
const currentRouteName = activeRoute?.name;
|
|
363
|
+
const currentRoutePage = activeRoute?.pageId;
|
|
349
364
|
const componentConfig = props.router.routes[currentRouteName];
|
|
350
365
|
let preventRedirect = false;
|
|
351
366
|
if (props.router.isRedirecting) preventRedirect = true;
|
package/package.json
CHANGED
package/preact/Router.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TypePropsRouter, TypeRoute } from 'reactive-route';
|
|
2
|
-
export declare function Router<TRoutes extends Record<string, TypeRoute>>(props: TypePropsRouter<TRoutes>):
|
|
2
|
+
export declare function Router<TRoutes extends Record<string, TypeRoute>>(props: TypePropsRouter<TRoutes>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
//# sourceMappingURL=Router.d.ts.map
|
package/preact/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/preact/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/preact/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA0CtF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,2CAIhG"}
|
package/preact/index.cjs
CHANGED
|
@@ -52,14 +52,10 @@ function RouterInner(props) {
|
|
|
52
52
|
};
|
|
53
53
|
}, []);
|
|
54
54
|
if (!config.loadedComponentName) return null;
|
|
55
|
-
const LoadedComponent = props.router.routes[config.loadedComponentName]
|
|
56
|
-
|
|
57
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
58
|
-
return null;
|
|
55
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName].component;
|
|
56
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
59
57
|
}
|
|
60
58
|
function Router(props) {
|
|
61
|
-
const [Component] = (0, import_hooks.useState)(
|
|
62
|
-
() => props.router.adapters.observer ? props.router.adapters.observer(RouterInner) : RouterInner
|
|
63
|
-
);
|
|
59
|
+
const [Component] = (0, import_hooks.useState)(() => props.router.adapters.observer(RouterInner));
|
|
64
60
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...props });
|
|
65
61
|
}
|
package/preact/index.mjs
CHANGED
|
@@ -26,15 +26,11 @@ function RouterInner(props) {
|
|
|
26
26
|
};
|
|
27
27
|
}, []);
|
|
28
28
|
if (!config.loadedComponentName) return null;
|
|
29
|
-
const LoadedComponent = props.router.routes[config.loadedComponentName]
|
|
30
|
-
|
|
31
|
-
return /* @__PURE__ */ jsx(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
32
|
-
return null;
|
|
29
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName].component;
|
|
30
|
+
return /* @__PURE__ */ jsx(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
33
31
|
}
|
|
34
32
|
function Router(props) {
|
|
35
|
-
const [Component] = useState(
|
|
36
|
-
() => props.router.adapters.observer ? props.router.adapters.observer(RouterInner) : RouterInner
|
|
37
|
-
);
|
|
33
|
+
const [Component] = useState(() => props.router.adapters.observer(RouterInner));
|
|
38
34
|
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
39
35
|
}
|
|
40
36
|
export {
|
package/react/Router.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { TypePropsRouter, TypeRoute } from 'reactive-route';
|
|
2
|
-
declare function
|
|
3
|
-
export declare const Router: typeof RouterWrapper;
|
|
4
|
-
export {};
|
|
2
|
+
export declare function Router<TRoutes extends Record<string, TypeRoute>>(props: TypePropsRouter<TRoutes>): import("react/jsx-runtime").JSX.Element;
|
|
5
3
|
//# sourceMappingURL=Router.d.ts.map
|
package/react/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/react/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/react/Router.tsx"],"names":[],"mappings":"AACA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AA0CtF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,2CAIhG"}
|
package/react/index.cjs
CHANGED
|
@@ -52,13 +52,10 @@ function RouterInner(props) {
|
|
|
52
52
|
};
|
|
53
53
|
}, []);
|
|
54
54
|
if (!config.loadedComponentName) return null;
|
|
55
|
-
const LoadedComponent = props.router.routes[config.loadedComponentName]
|
|
56
|
-
|
|
57
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
58
|
-
return null;
|
|
55
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName].component;
|
|
56
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
59
57
|
}
|
|
60
|
-
function
|
|
61
|
-
const Component =
|
|
58
|
+
function Router(props) {
|
|
59
|
+
const [Component] = (0, import_react.useState)(() => props.router.adapters.observer(RouterInner));
|
|
62
60
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...props });
|
|
63
61
|
}
|
|
64
|
-
var Router = (0, import_react.memo)(RouterWrapper);
|
package/react/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// packages/react/Router.tsx
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
3
|
import { routerSetLoadedComponent } from "reactive-route";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
function RouterInner(props) {
|
|
@@ -26,16 +26,13 @@ function RouterInner(props) {
|
|
|
26
26
|
};
|
|
27
27
|
}, []);
|
|
28
28
|
if (!config.loadedComponentName) return null;
|
|
29
|
-
const LoadedComponent = props.router.routes[config.loadedComponentName]
|
|
30
|
-
|
|
31
|
-
return /* @__PURE__ */ jsx(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
32
|
-
return null;
|
|
29
|
+
const LoadedComponent = props.router.routes[config.loadedComponentName].component;
|
|
30
|
+
return /* @__PURE__ */ jsx(LoadedComponent, { ...config.currentProps, router: props.router });
|
|
33
31
|
}
|
|
34
|
-
function
|
|
35
|
-
const Component =
|
|
32
|
+
function Router(props) {
|
|
33
|
+
const [Component] = useState(() => props.router.adapters.observer(RouterInner));
|
|
36
34
|
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
37
35
|
}
|
|
38
|
-
var Router = memo(RouterWrapper);
|
|
39
36
|
export {
|
|
40
37
|
Router
|
|
41
38
|
};
|
package/solid/Router.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAItF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../packages/solid/Router.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,eAAe,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAItF,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,kCAoChG"}
|
package/solid/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ function Router(props) {
|
|
|
55
55
|
get children() {
|
|
56
56
|
return (0, import_web.createComponent)(import_web3.Dynamic, (0, import_web2.mergeProps)({
|
|
57
57
|
get component() {
|
|
58
|
-
return props.router.routes[config.loadedComponentName]
|
|
58
|
+
return props.router.routes[config.loadedComponentName].component;
|
|
59
59
|
}
|
|
60
60
|
}, () => config.currentProps, {
|
|
61
61
|
get router() {
|
package/solid/index.mjs
CHANGED
|
@@ -29,7 +29,7 @@ function Router(props) {
|
|
|
29
29
|
get children() {
|
|
30
30
|
return _$createComponent(Dynamic, _$mergeProps({
|
|
31
31
|
get component() {
|
|
32
|
-
return props.router.routes[config.loadedComponentName]
|
|
32
|
+
return props.router.routes[config.loadedComponentName].component;
|
|
33
33
|
}
|
|
34
34
|
}, () => config.currentProps, {
|
|
35
35
|
get router() {
|
package/vue/index.cjs
CHANGED
|
Binary file
|
package/vue/index.mjs
CHANGED
|
Binary file
|
package/core/utils/addNames.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addNames.d.ts","sourceRoot":"","sources":["../../../packages/core/utils/addNames.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG;QAAE,IAAI,EAAE,GAAG,CAAA;KAAE;CAAE,CAAC;AAE3E,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAMtF"}
|