zova-module-a-router 5.0.56 → 5.0.60

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-module-a-router",
3
- "version": "5.0.56",
3
+ "version": "5.0.60",
4
4
  "title": "a-router",
5
5
  "zovaModule": {
6
6
  "capabilities": {
@@ -35,10 +35,10 @@
35
35
  "scripts": {
36
36
  "clean": "tsc -b --clean",
37
37
  "tsc:publish": "npm run clean && tsc -b",
38
- "prepublishOnly": "npm run tsc:publish"
38
+ "_prepublishOnly": "npm run tsc:publish"
39
39
  },
40
40
  "dependencies": {
41
41
  "vue-router": "^4.3.2"
42
42
  },
43
- "gitHead": "ff62e324389a802952e49a39e07a84aa9c057084"
43
+ "gitHead": "b87bdd8540395b181993a617d33cad57b3c4d446"
44
44
  }
@@ -0,0 +1,36 @@
1
+ /** beans: begin */
2
+ export * from '../bean/bean.router.js';
3
+ export * from '../bean/bean.routerBase.js';
4
+ import { BeanRouter } from '../bean/bean.router.js';
5
+ import { BeanRouterBase } from '../bean/bean.routerBase.js';
6
+ import 'zova';
7
+ declare module 'zova' {
8
+ export interface IBeanRecord {
9
+ 'a-router.bean.router': BeanRouter;
10
+ 'a-router.bean.routerBase': BeanRouterBase;
11
+ }
12
+ }
13
+ /** beans: end */
14
+ /** config: begin */
15
+ export * from '../config/config.js';
16
+ import { config } from '../config/config.js';
17
+ /** config: end */
18
+ /** scope: begin */
19
+ import { BeanScopeBase, Scope, TypeModuleResource } from 'zova';
20
+
21
+ @Scope()
22
+ export class ScopeModuleARouter extends BeanScopeBase {}
23
+
24
+ export interface ScopeModuleARouter extends TypeModuleResource<any, typeof config, any, any, any, any> {}
25
+
26
+ import 'zova';
27
+ declare module 'zova' {
28
+ export interface IBeanScopeRecord {
29
+ 'a-router': ScopeModuleARouter;
30
+ }
31
+
32
+ export interface IBeanScopeConfig {
33
+ 'a-router': ReturnType<typeof config>;
34
+ }
35
+ }
36
+ /** scope: end */
@@ -0,0 +1,2 @@
1
+ export const __ThisModule__ = 'a-router';
2
+ export { ScopeModuleARouter as ScopeModule } from './index.js';
@@ -33,7 +33,7 @@ export class BeanRouter extends BeanBase {
33
33
  }
34
34
 
35
35
  private _createRouter() {
36
- const createHistory = this.app.config.env.appServer
36
+ const createHistory = process.env.SERVER
37
37
  ? createMemoryHistory
38
38
  : this.app.config.env.appRouterMode === 'history'
39
39
  ? createWebHistory
@@ -68,7 +68,7 @@ export class BeanRouter extends BeanBase {
68
68
  }
69
69
 
70
70
  public checkPathValid(to?: { name?: string; path?: string } | string): boolean {
71
- const _path = to && typeof to === 'object' ? to.name ?? to.path : to;
71
+ const _path = to && typeof to === 'object' ? (to.name ?? to.path) : to;
72
72
  if (!_path) return true;
73
73
  const moduleName = ModuleInfo.parseName(_path);
74
74
  if (!moduleName) return true;
@@ -113,11 +113,13 @@ export class BeanRouter extends BeanBase {
113
113
  private _registerRoute(module: IModule, route: IModuleRoute) {
114
114
  // path
115
115
  let path: string | undefined;
116
- if (route.path) {
116
+ if (route.path !== undefined) {
117
117
  if (route.meta?.absolute === true) {
118
118
  path = route.path;
119
119
  } else {
120
- path = `/${module.info.pid}/${module.info.name}/${route.path}`;
120
+ path = route.path
121
+ ? `/${module.info.pid}/${module.info.name}/${route.path}`
122
+ : `/${module.info.pid}/${module.info.name}`;
121
123
  }
122
124
  }
123
125
  // name
@@ -1,7 +1,7 @@
1
1
  import { Local, Use } from 'zova';
2
2
  import * as ModuleInfo from '@cabloy/module-info';
3
- import { ScopeModule } from '../resource/this.js';
4
- import { BeanRouterBase } from './virtual.router.js';
3
+ import { ScopeModule } from '../.metadata/this.js';
4
+ import { BeanRouterBase } from './bean.routerBase.js';
5
5
  import { BeanRouter } from './bean.router.js';
6
6
 
7
7
  @Local()
package/src/index.ts CHANGED
@@ -1,8 +1,3 @@
1
- export * from './config/index.js';
2
- export * from './resource/index.js';
3
- export * from './api/index.js';
4
- export * from './routes.js';
1
+ export * from './.metadata/index.js';
5
2
  export * from './types.js';
6
3
  export * from './monkey.js';
7
-
8
- import './typings.js';
package/src/monkey.ts CHANGED
@@ -14,7 +14,7 @@ import {
14
14
  import * as ModuleInfo from '@cabloy/module-info';
15
15
  import { useRoute } from 'vue-router';
16
16
  import { BeanRouter } from './bean/bean.router.js';
17
- import { ScopeModule, __ThisModule__ } from './resource/this.js';
17
+ import { ScopeModule, __ThisModule__ } from './.metadata/this.js';
18
18
  import { markRaw } from 'vue';
19
19
  import { getRealRouteName } from './utils.js';
20
20
  import { LocalRouter } from './bean/local.router.js';
@@ -52,6 +52,15 @@ export class Monkey extends BeanSimple implements IMonkeySystem, IMonkeyModule,
52
52
  async appReady(_bean: BeanContainer) {
53
53
  // use router
54
54
  this.app.vue.use(this._beanRouter);
55
+ // ssr
56
+ if (process.env.SERVER) {
57
+ // push
58
+ const url = this.ctx.meta.ssr.context.req.url;
59
+ this._beanRouter.push(url);
60
+ await this._beanRouter.isReady();
61
+ } else if (process.env.CLIENT && this.ctx.meta.ssr.isRuntimeSsrPreHydration) {
62
+ await this._beanRouter.isReady();
63
+ }
55
64
  }
56
65
  async beanInit(bean: BeanContainer, beanInstance: BeanBase) {
57
66
  const self = this;
package/src/types.ts CHANGED
@@ -42,4 +42,12 @@ declare module 'zova' {
42
42
  path: Record<keyof IPagePathRecord, IModuleRoute>;
43
43
  name: Record<keyof IPageNameRecord, IModuleRoute>;
44
44
  }
45
+
46
+ export interface IEventRecord {
47
+ 'a-router:routerGuards': BeanRouter;
48
+ }
49
+
50
+ export interface IEventResultRecord {
51
+ 'a-router:routerGuards': void;
52
+ }
45
53
  }
package/src/api/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './interface/index.js';
2
- export * from './service/index.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export const services = {};
File without changes
@@ -1 +0,0 @@
1
- export const constants = null;
@@ -1 +0,0 @@
1
- export enum Errors {}
@@ -1,4 +0,0 @@
1
- export * from './locales.js';
2
- export * from './errors.js';
3
- export * from './config.js';
4
- export * from './constants.js';
@@ -1 +0,0 @@
1
- export default {};
@@ -1 +0,0 @@
1
- export default {};
@@ -1,7 +0,0 @@
1
- import en_us from './locale/en-us.js';
2
- import zh_cn from './locale/zh-cn.js';
3
-
4
- export const locales = {
5
- 'en-us': en_us,
6
- 'zh-cn': zh_cn,
7
- };
package/src/page/.gitkeep DELETED
File without changes
@@ -1,9 +0,0 @@
1
- export * from '../bean/bean.router.js';
2
- export * from '../bean/virtual.router.js';
3
- import { BeanRouter } from '../bean/bean.router.js';
4
- import 'zova';
5
- declare module 'zova' {
6
- export interface IBeanRecord {
7
- 'a-router.bean.router': BeanRouter;
8
- }
9
- }
@@ -1 +0,0 @@
1
- export const components = {};
@@ -1,12 +0,0 @@
1
- import { BeanRouter } from './beans.js';
2
-
3
- import 'zova';
4
- declare module 'zova' {
5
- export interface IEventRecord {
6
- 'a-router:routerGuards': BeanRouter;
7
- }
8
-
9
- export interface IEventResultRecord {
10
- 'a-router:routerGuards': void;
11
- }
12
- }
@@ -1,4 +0,0 @@
1
- export * from './scope.js';
2
- export * from './beans.js';
3
- export * from './components.js';
4
- export * from './events.js';
@@ -1,32 +0,0 @@
1
- import { BeanScopeBase, Scope, TypeLocaleBase, TypeModuleResource } from 'zova';
2
- import { config, Errors, locales, constants } from '../config/index.js';
3
- import { components } from './components.js';
4
- import { services } from '../api/service/index.js';
5
-
6
- @Scope()
7
- export class ScopeModuleARouter extends BeanScopeBase {}
8
-
9
- export interface ScopeModuleARouter
10
- extends TypeModuleResource<
11
- typeof components,
12
- typeof config,
13
- typeof Errors,
14
- (typeof locales)[TypeLocaleBase],
15
- typeof constants,
16
- typeof services
17
- > {}
18
-
19
- import 'zova';
20
- declare module 'zova' {
21
- export interface IBeanScopeRecord {
22
- 'a-router': ScopeModuleARouter;
23
- }
24
-
25
- export interface IBeanScopeConfig {
26
- 'a-router': ReturnType<typeof config>;
27
- }
28
-
29
- export interface IBeanScopeLocale {
30
- 'a-router': (typeof locales)[TypeLocaleBase];
31
- }
32
- }
@@ -1,4 +0,0 @@
1
- export const __ThisModule__ = 'a-router';
2
- export type __ThisModuleType__ = typeof __ThisModule__;
3
-
4
- export { ScopeModuleARouter as ScopeModule } from './scope.js';
package/src/routes.ts DELETED
@@ -1,3 +0,0 @@
1
- import { IModuleRoute } from 'zova-module-a-router';
2
-
3
- export const routes: IModuleRoute[] = [];
package/src/typings.ts DELETED
@@ -1 +0,0 @@
1
- export {};