cabloy 5.1.166 → 5.1.167

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.
Files changed (48) hide show
  1. package/.cabloy-version +1 -1
  2. package/.claude/scheduled_tasks.lock +1 -1
  3. package/.claude/skills/cabloy-frontend-scaffold/SKILL.md +1 -0
  4. package/CHANGELOG.md +13 -0
  5. package/package.json +1 -1
  6. package/repo-docs/frontend/page-params-guide.md +1 -1
  7. package/repo-docs/frontend/page-query-guide.md +6 -0
  8. package/repo-docs/frontend/zod-guide.md +9 -7
  9. package/repo-e2e/specs/routed-dialog.spec.ts +368 -0
  10. package/vona/pnpm-lock.yaml +6 -0
  11. package/zova/package.original.json +1 -1
  12. package/zova/packages-cli/cli/package.json +2 -2
  13. package/zova/packages-cli/cli-set-front/package.json +1 -1
  14. package/zova/packages-cli/cli-set-front/src/lib/bean/toolsMetadata/generateBeanGenerals.ts +1 -1
  15. package/zova/packages-cli/cli-set-front/src/lib/bean/toolsMetadata/generateScopeResources.ts +1 -1
  16. package/zova/packages-zova/zova/package.json +2 -2
  17. package/zova/pnpm-lock.yaml +2014 -2053
  18. package/zova/pnpm-workspace.yaml +1 -1
  19. package/zova/src/suite/a-demo/modules/demo-basic/src/.metadata/index.ts +66 -18
  20. package/zova/src/suite/a-demo/modules/demo-basic/src/.metadata/page/routedDialog.ts +9 -0
  21. package/zova/src/suite/a-demo/modules/demo-basic/src/.metadata/page/routedDialogDetail.ts +23 -0
  22. package/zova/src/suite/a-demo/modules/demo-basic/src/.metadata/page/routedDialogEntry.ts +23 -0
  23. package/zova/src/suite/a-demo/modules/demo-basic/src/page/routedDialog/controller.tsx +301 -0
  24. package/zova/src/suite/a-demo/modules/demo-basic/src/page/routedDialogDetail/controller.tsx +135 -0
  25. package/zova/src/suite/a-demo/modules/demo-basic/src/page/routedDialogEntry/controller.tsx +108 -0
  26. package/zova/src/suite/a-demo/modules/demo-basic/src/routes.ts +19 -0
  27. package/zova/src/suite/cabloy-basic/modules/basic-app/src/.metadata/component/routedDialog.ts +63 -0
  28. package/zova/src/suite/cabloy-basic/modules/basic-app/src/.metadata/index.ts +44 -2
  29. package/zova/src/suite/cabloy-basic/modules/basic-app/src/bean/behavior.appModal.tsx +306 -18
  30. package/zova/src/suite/cabloy-basic/modules/basic-app/src/component/routedDialog/controller.tsx +51 -0
  31. package/zova/src/suite/cabloy-basic/modules/basic-app/src/config/config.ts +19 -0
  32. package/zova/src/suite/cabloy-basic/modules/basic-app/src/config/locale/en-us.ts +1 -0
  33. package/zova/src/suite/cabloy-basic/modules/basic-app/src/config/locale/zh-cn.ts +1 -0
  34. package/zova/src/suite/cabloy-basic/modules/basic-app/src/lib/routedDialogHistory.ts +76 -0
  35. package/zova/src/suite/cabloy-basic/modules/basic-app/src/service/appModal.ts +156 -1
  36. package/zova/src/suite/cabloy-basic/modules/basic-app/src/types/appModal.ts +92 -13
  37. package/zova/src/suite/cabloy-basic/modules/basic-app/test/lib/routedDialogHistory.test.ts +92 -0
  38. package/zova/src/suite/cabloy-basic/modules/basic-app/test/lib/routedDialogRouter.test.ts +35 -0
  39. package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/package.json +1 -1
  40. package/zova/src/suite-vendor/a-cabloy/modules/rest-resource/src/model/resource.ts +1 -1
  41. package/zova/src/suite-vendor/a-cabloy/package.json +2 -2
  42. package/zova/src/suite-vendor/a-zova/modules/a-router/package.json +1 -1
  43. package/zova/src/suite-vendor/a-zova/modules/a-router/src/.metadata/index.ts +6 -6
  44. package/zova/src/suite-vendor/a-zova/modules/a-router/src/bean/bean.router.ts +60 -3
  45. package/zova/src/suite-vendor/a-zova/modules/a-router/src/bean/sys.router.ts +12 -0
  46. package/zova/src/suite-vendor/a-zova/modules/a-router/src/component/routerViewEmpty/controller.tsx +4 -1
  47. package/zova/src/suite-vendor/a-zova/modules/a-router/src/lib/routerViewBase.tsx +5 -1
  48. package/zova/src/suite-vendor/a-zova/package.json +2 -2
@@ -26,7 +26,7 @@ declare module 'zova-module-a-router' {
26
26
  }
27
27
  /** model: end */
28
28
  /** model: begin */
29
- import { ModelPageData } from '../model/pageData.js';
29
+ import type { ModelPageData } from '../model/pageData.js';
30
30
  import 'zova';
31
31
  declare module 'zova' {
32
32
  export interface IBeanRecordGeneral {
@@ -57,7 +57,7 @@ declare module 'zova-module-a-router' {
57
57
  }
58
58
  /** sys: end */
59
59
  /** sys: begin */
60
- import { SysRouter } from '../bean/sys.router.js';
60
+ import type { SysRouter } from '../bean/sys.router.js';
61
61
  import 'zova';
62
62
  declare module 'zova' {
63
63
  export interface IBeanRecordGeneral {
@@ -89,8 +89,8 @@ declare module 'zova-module-a-router' {
89
89
  }
90
90
  /** bean: end */
91
91
  /** bean: begin */
92
- import { BeanRouter } from '../bean/bean.router.js';
93
- import { BeanRouterGuardsBase } from '../bean/bean.routerGuardsBase.js';
92
+ import type { BeanRouter } from '../bean/bean.router.js';
93
+ import type { BeanRouterGuardsBase } from '../bean/bean.routerGuardsBase.js';
94
94
  import 'zova';
95
95
  declare module 'zova' {
96
96
  export interface IBeanRecordGeneral {
@@ -126,7 +126,7 @@ declare module 'zova-module-a-router' {
126
126
  }
127
127
  /** service: end */
128
128
  /** service: begin */
129
- import { ServiceRouterGuards } from '../service/routerGuards.js';
129
+ import type { ServiceRouterGuards } from '../service/routerGuards.js';
130
130
  import 'zova';
131
131
  declare module 'zova' {
132
132
  export interface IBeanRecordGeneral {
@@ -151,7 +151,7 @@ declare module 'zova-module-a-router' {
151
151
  }
152
152
  /** controller: end */
153
153
  /** controller: begin */
154
- import { ControllerRouterViewEmpty } from '../component/routerViewEmpty/controller.jsx';
154
+ import type { ControllerRouterViewEmpty } from '../component/routerViewEmpty/controller.jsx';
155
155
  import 'zova';
156
156
  declare module 'zova' {
157
157
  export interface IBeanRecordLocal {
@@ -3,6 +3,7 @@ import type {
3
3
  NavigationHookAfter,
4
4
  RouteLocationNormalizedLoadedGeneric,
5
5
  Router,
6
+ RouterOptions,
6
7
  } from '@cabloy/vue-router';
7
8
 
8
9
  import { BeanBase, TypeEventOff, Use } from 'zova';
@@ -14,6 +15,13 @@ import { IPageMeta } from '../types/pageMeta.js';
14
15
  import { TypeErrorListener } from '../types/router.js';
15
16
  import { SysRouter } from './sys.router.js';
16
17
 
18
+ export interface BeanRouterInitOptions {
19
+ mainRouter?: boolean;
20
+ routerOptions?: RouterOptions;
21
+ prepareNavigation?: (to: unknown) => Promise<void> | void;
22
+ embeddedView?: 'page';
23
+ }
24
+
17
25
  export interface BeanRouter extends Omit<
18
26
  SysRouter,
19
27
  '$beanFullName' | '$onionName' | '$onionOptions'
@@ -24,6 +32,7 @@ export class BeanRouter extends BeanBase {
24
32
  private _vueRouterApp: Router;
25
33
  private _eventRouterGuards: TypeEventOff[] = [];
26
34
  private _routerViews: BeanRouterViewBase[] = [];
35
+ private _disposed = false;
27
36
 
28
37
  @Use()
29
38
  $$sysRouter: SysRouter;
@@ -35,10 +44,42 @@ export class BeanRouter extends BeanBase {
35
44
  return this._vueRouterApp;
36
45
  }
37
46
 
47
+ get isEmbedded() {
48
+ return this._isEmbedded;
49
+ }
50
+
51
+ private _isEmbedded = false;
52
+ private _embeddedView?: 'page';
53
+ private _prepareNavigation?: (to: unknown) => Promise<void> | void;
54
+
55
+ /**
56
+ * Returns the initial RouterView depth for an embedded page-only host.
57
+ *
58
+ * SysRouter records the synthetic layout parents it creates. The page-only
59
+ * host skips only those exact records; routes registered with
60
+ * `meta.layout: false` still start at depth zero.
61
+ */
62
+ public getEmbeddedRouterViewDepth(route: RouteLocationNormalizedLoadedGeneric): number {
63
+ if (this._embeddedView !== 'page') return 0;
64
+ return this.$$sysRouter.isSyntheticLayoutRouteRecord(route.matched[0]) ? 1 : 0;
65
+ }
66
+
67
+ public dispose() {
68
+ this.__dispose__();
69
+ }
70
+
38
71
  protected __dispose__() {
72
+ if (this._disposed) return;
73
+ this._disposed = true;
39
74
  for (const fn of this._eventRouterGuards) {
40
75
  fn();
41
76
  }
77
+ this._eventRouterGuards = [];
78
+ this._routerViews = [];
79
+ const router = this._vueRouterApp as Router & {
80
+ __prepareNavigation?: (to: unknown) => Promise<void> | void;
81
+ };
82
+ if (router) router.__prepareNavigation = undefined;
42
83
  }
43
84
 
44
85
  protected __get__(prop: string) {
@@ -48,10 +89,21 @@ export class BeanRouter extends BeanBase {
48
89
  return this.$$sysRouter?.[prop];
49
90
  }
50
91
 
51
- protected async __init__(mainRouter?: boolean) {
92
+ protected async __init__(mainRouterOrOptions?: boolean | BeanRouterInitOptions) {
93
+ const options: BeanRouterInitOptions =
94
+ typeof mainRouterOrOptions === 'boolean'
95
+ ? { mainRouter: mainRouterOrOptions }
96
+ : (mainRouterOrOptions ?? {});
97
+ this._isEmbedded = options.mainRouter === false;
98
+ this._embeddedView = options.embeddedView;
99
+ this._prepareNavigation = options.prepareNavigation;
52
100
  // create router
53
- this._vueRouterApp = this.$$sysRouter.createRouter();
54
- if (!mainRouter) {
101
+ this._vueRouterApp = this.$$sysRouter.createRouter(options.routerOptions);
102
+ const router = this._vueRouterApp as Router & {
103
+ __prepareNavigation?: (to: unknown) => Promise<void> | void;
104
+ };
105
+ router.__prepareNavigation = this._prepareNavigation;
106
+ if (!options.mainRouter) {
55
107
  // emit event
56
108
  await this.app.meta.event.emit('a-router:routerGuards', this);
57
109
  }
@@ -59,6 +111,11 @@ export class BeanRouter extends BeanBase {
59
111
 
60
112
  addRouterView(routerView: BeanRouterViewBase) {
61
113
  this._routerViews.push(routerView);
114
+ if (!this._isEmbedded) return;
115
+ const route = this._vueRouterApp.currentRoute.value;
116
+ if (route?.matched.length > 0) {
117
+ routerView.forwardRoute(route);
118
+ }
62
119
  }
63
120
 
64
121
  removeRouterView(routerView: BeanRouterViewBase) {
@@ -33,6 +33,7 @@ export interface SysRouter extends Router {}
33
33
  @Sys()
34
34
  export class SysRouter extends BeanBase {
35
35
  private _vueRouterSys: Router;
36
+ private _syntheticLayoutRouteNames = new Set<string>();
36
37
 
37
38
  get router(): Router {
38
39
  return this._vueRouterSys;
@@ -92,6 +93,14 @@ export class SysRouter extends BeanBase {
92
93
  return this.sys.meta.component.createAsyncComponent(component);
93
94
  }
94
95
 
96
+ public isSyntheticLayoutRouteRecord(record: RouteLocationMatched | undefined) {
97
+ const canonicalRecord = record?.aliasOf ?? record;
98
+ return (
99
+ typeof canonicalRecord?.name === 'string' &&
100
+ this._syntheticLayoutRouteNames.has(canonicalRecord.name)
101
+ );
102
+ }
103
+
95
104
  public getPagePath<K extends keyof IPagePathRecord>(
96
105
  path: K,
97
106
  options?: IPagePathRecord[K],
@@ -392,5 +401,8 @@ export class SysRouter extends BeanBase {
392
401
  }
393
402
  // add
394
403
  this.router.addRoute(routeData);
404
+ if (routeNameParent) {
405
+ this._syntheticLayoutRouteNames.add(routeNameParent);
406
+ }
395
407
  }
396
408
  }
@@ -14,7 +14,10 @@ export class ControllerRouterViewEmpty extends BeanRouterViewBase {
14
14
  const slots = {
15
15
  default: component => {
16
16
  const vnode = h(component.Component);
17
- cast(vnode).zovaHostProviders = { [pageRouteKey]: component.route };
17
+ cast(vnode).zovaHostProviders = {
18
+ [pageRouteKey]: component.route,
19
+ 'a-router.bean.router': this.$router,
20
+ };
18
21
  return vnode;
19
22
  },
20
23
  };
@@ -47,8 +47,12 @@ export class BeanRouterViewBase extends BeanControllerBase implements IRouterVie
47
47
  default: () => {
48
48
  const vnode = h(component.Component as any, {
49
49
  key: routeMeta.componentKey,
50
+ route: component.route,
50
51
  });
51
- cast(vnode).zovaHostProviders = { [pageRouteKey]: component.route };
52
+ cast(vnode).zovaHostProviders = {
53
+ [pageRouteKey]: component.route,
54
+ 'a-router.bean.router': this.$router,
55
+ };
52
56
  return [
53
57
  h(
54
58
  KeepAlive,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-suite-a-zova",
3
- "version": "5.1.157",
3
+ "version": "5.1.158",
4
4
  "gitHead": "2c5c19284bab738e492856189acb6fad74b8a7b7",
5
5
  "description": "zova",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "zova-module-a-meta": "^5.1.22",
24
24
  "zova-module-a-model": "^5.1.36",
25
25
  "zova-module-a-openapi": "^5.1.53",
26
- "zova-module-a-router": "^5.1.34",
26
+ "zova-module-a-router": "^5.1.35",
27
27
  "zova-module-a-routerstack": "^5.1.27",
28
28
  "zova-module-a-routertabs": "^5.1.34",
29
29
  "zova-module-a-ssr": "^5.1.38",