zova-module-a-routerstack 5.1.26 → 5.1.28

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.
@@ -2,6 +2,7 @@ import { RouteLocationNormalizedLoadedGeneric } from '@cabloy/vue-router';
2
2
  import { BeanRouterViewBase, IRouterViewPropsBase, IRouteViewRouteMeta } from 'zova-module-a-router';
3
3
  import type { ModelStack } from '../../model/stack.js';
4
4
  export interface ControllerRouterViewStackProps extends IRouterViewPropsBase {
5
+ pageHostProviders?: Record<string, unknown>;
5
6
  }
6
7
  export declare class ControllerRouterViewStack extends BeanRouterViewBase {
7
8
  static $propsDefault: {};
@@ -10,5 +11,6 @@ export declare class ControllerRouterViewStack extends BeanRouterViewBase {
10
11
  forwardRoute(route: RouteLocationNormalizedLoadedGeneric): boolean;
11
12
  protected prepareRouteMeta(route: RouteLocationNormalizedLoadedGeneric): IRouteViewRouteMeta;
12
13
  protected getKeepAliveInclude(): string[] | undefined;
14
+ protected getPageHostProviders(): Record<string, unknown> | undefined;
13
15
  }
14
16
  //# sourceMappingURL=controller.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/routerViewStack/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAG1E,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,8BAA+B,SAAQ,oBAAoB;CAAG;AAE/E,qBACa,yBAA0B,SAAQ,kBAAkB;IAC/D,MAAM,CAAC,aAAa,KAAM;IAG1B,YAAY,EAAE,UAAU,CAAC;IAElB,SAAS,CAAC,KAAK,EAAE,oCAAoC;IAKrD,YAAY,CAAC,KAAK,EAAE,oCAAoC;IAK/D,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,oCAAoC,GAAG,mBAAmB;IAI5F,SAAS,CAAC,mBAAmB,IAAI,MAAM,EAAE,GAAG,SAAS;CAGtD"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/component/routerViewStack/controller.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAG1E,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,WAAW,8BAA+B,SAAQ,oBAAoB;IAC1E,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC7C;AAED,qBACa,yBAA0B,SAAQ,kBAAkB;IAC/D,MAAM,CAAC,aAAa,KAAM;IAG1B,YAAY,EAAE,UAAU,CAAC;IAElB,SAAS,CAAC,KAAK,EAAE,oCAAoC;IAKrD,YAAY,CAAC,KAAK,EAAE,oCAAoC;IAK/D,SAAS,CAAC,gBAAgB,CAAC,KAAK,EAAE,oCAAoC,GAAG,mBAAmB;IAI5F,SAAS,CAAC,mBAAmB,IAAI,MAAM,EAAE,GAAG,SAAS;IAIrD,SAAS,CAAC,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;CAGtE"}
package/dist/index.js CHANGED
@@ -5,7 +5,9 @@ import { Controller, Scope } from "zova-module-a-bean";
5
5
  import { BeanRouterViewBase } from "zova-module-a-router";
6
6
  import { defineComponent } from "vue";
7
7
  //#region src/model/stack.ts
8
- var _dec$2, _dec2$2, _class$2;
8
+ var _dec$2;
9
+ var _dec2$2;
10
+ var _class$2;
9
11
  var ModelStack$1 = (_dec$2 = Model({
10
12
  enableSelector: true,
11
13
  max: -1
@@ -119,7 +121,14 @@ var ModelStack$1 = (_dec$2 = Model({
119
121
  }) || _class$2) || _class$2);
120
122
  //#endregion
121
123
  //#region src/component/routerViewStack/controller.tsx
122
- var _dec$1, _dec2$1, _dec3, _dec4, _class$1, _class2, _descriptor, _ControllerRouterViewStack;
124
+ var _dec$1;
125
+ var _dec2$1;
126
+ var _dec3;
127
+ var _dec4;
128
+ var _class$1;
129
+ var _class2;
130
+ var _descriptor;
131
+ var _ControllerRouterViewStack;
123
132
  function _initializerDefineProperty(e, i, r, l) {
124
133
  r && Object.defineProperty(e, i, {
125
134
  enumerable: r.enumerable,
@@ -155,6 +164,9 @@ var ControllerRouterViewStack = (_dec$1 = Controller(), _dec2$1 = BeanInfo({ mod
155
164
  getKeepAliveInclude() {
156
165
  return this.$$modelStack.keepAliveInclude;
157
166
  }
167
+ getPageHostProviders() {
168
+ return this.$props.pageHostProviders;
169
+ }
158
170
  }, _ControllerRouterViewStack.$propsDefault = {}, _ControllerRouterViewStack), _descriptor = _applyDecoratedDescriptor(_class2.prototype, "$$modelStack", [_dec3, _dec4], {
159
171
  configurable: true,
160
172
  enumerable: true,
@@ -171,7 +183,9 @@ var ZRouterViewStack = defineComponent((_props) => {
171
183
  //#region src/.metadata/index.ts
172
184
  /** components: end */
173
185
  /** scope: begin */
174
- var _dec, _dec2, _class;
186
+ var _dec;
187
+ var _dec2;
188
+ var _class;
175
189
  var components = { "routerViewStack": ZRouterViewStack };
176
190
  var ScopeModuleARouterstack = (_dec = Scope(), _dec2 = BeanInfo({ module: "a-routerstack" }), _dec(_class = _dec2(_class = class ScopeModuleARouterstack extends BeanScopeBase {}) || _class) || _class);
177
191
  /** scope: end */
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Use","Controller","BeanRouterViewBase","ControllerRouterViewStack","_dec","_dec2","__z_BeanInfo","module","_dec3","injectionScope","_dec4","Reflect","metadata","ModelStack","Object","_class","_class2","_ControllerRouterViewStack","constructor","args","_initializerDefineProperty","_descriptor","backRoute","route","$$modelStack","forwardRoute","prepareRouteMeta","getKeepAliveInclude","keepAliveInclude","$propsDefault","_applyDecoratedDescriptor","prototype","configurable","enumerable","writable","initializer"],"sources":["../src/model/stack.ts","../src/component/routerViewStack/controller.tsx","../src/.metadata/component/routerViewStack.ts","../src/.metadata/index.ts"],"sourcesContent":["var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { mutate } from 'mutate-on-copy';\nimport { deepExtend } from 'zova';\nimport { BeanModelBase, Model } from 'zova-module-a-model';\nexport let ModelStack = (_dec = Model({\n enableSelector: true,\n max: -1\n}), _dec2 = __z_BeanInfo({\n module: \"a-routerstack\"\n}), _dec(_class = _dec2(_class = class ModelStack extends BeanModelBase {\n constructor(...args) {\n super(...args);\n this.stackOptions = void 0;\n this.tabs = void 0;\n this.keepAliveInclude = void 0;\n }\n async __init__(scene, options) {\n await super.__init__(scene);\n this.bean._setBean('$$modelStack', this);\n // options\n this.stackOptions = deepExtend({}, this.$onionOptions, options);\n // tabs: always []\n this.tabs = [];\n // computed\n this.keepAliveInclude = this.$computed(() => {\n return this._getKeepAliveInclude();\n });\n // first route\n if (this.$currentRoute) {\n this.forwardRoute(this.$currentRoute);\n }\n }\n addTab(tab) {\n return this._addTab(tab);\n }\n _addTab(tab) {\n const tabKey = tab.tabKey;\n if (!tabKey) return false;\n // tab\n const [index, tabOld] = this.findTab(tabKey);\n // tabs\n if (index === -1) {\n // new\n const tabNew = {\n tabKey,\n updatedAt: Date.now()\n };\n this.tabs = mutate(this.tabs, copyState => {\n copyState.push(tabNew);\n });\n this.pruneTabs();\n } else {\n // update\n if (!this._checkIfTabNeedUpdate(tabOld, tab)) {\n return false;\n }\n this.updateTab(tab);\n }\n return true;\n }\n findTab(tabKey) {\n if (!tabKey) return [-1, undefined];\n const index = this.tabs.findIndex(item => item.tabKey === tabKey);\n if (index === -1) return [index, undefined];\n return [index, this.tabs[index]];\n }\n deleteTab(tabKey) {\n if (!tabKey) return false;\n // tabs\n const [index] = this.findTab(tabKey);\n if (index === -1) return false;\n // tabs\n this.tabs = mutate(this.tabs, copyState => {\n copyState.splice(index, 1);\n });\n return true;\n }\n updateTab(tab) {\n const tabKey = tab.tabKey;\n const [index, tabOld] = this.findTab(tabKey);\n if (index === -1 || !tabOld) return;\n const tabNew = {\n ...tabOld,\n tabKey,\n updatedAt: Date.now()\n };\n this.tabs = mutate(this.tabs, copyState => {\n copyState.splice(index, 1, tabNew);\n });\n }\n async pruneTabs() {\n let max = this.stackOptions.max;\n if (max === undefined || max === -1) return;\n if (max < 1) max = 1;\n while (true) {\n if (this.tabs.length <= max) break;\n let tabKey;\n let updatedAt = Date.now();\n for (const tab of this.tabs) {\n if (tab.updatedAt < updatedAt) {\n tabKey = tab.tabKey;\n updatedAt = tab.updatedAt;\n }\n }\n if (!tabKey) break;\n this.deleteTab(tabKey);\n }\n }\n\n // special for _addTab\n _checkIfTabNeedUpdate(tabOld, _tabNew) {\n const recentTabIndex = this.tabs.findIndex(item => item.tabKey !== tabOld.tabKey && (item.updatedAt ?? 0) >= (tabOld.updatedAt ?? 0));\n if (recentTabIndex > -1) return true;\n return false;\n }\n _getKeepAliveInclude() {\n const include = [];\n for (const tab of this.tabs) {\n if (!include.includes(tab.tabKey)) {\n include.push(tab.tabKey);\n }\n }\n return include;\n }\n backRoute(route) {\n this.deleteTab(route.fullPath);\n }\n forwardRoute(route) {\n const componentMeta = this.prepareRouteMeta(route);\n this.addTab(componentMeta);\n }\n prepareRouteMeta(route) {\n // fullPath\n const fullPath = route.fullPath;\n // tab\n return {\n tabKey: fullPath,\n componentKey: fullPath,\n fullPath\n };\n }\n}) || _class) || _class);","import { RouteLocationNormalizedLoadedGeneric } from '@cabloy/vue-router';\nimport { Use } from 'zova';\nimport { Controller } from 'zova-module-a-bean';\nimport {\n BeanRouterViewBase,\n IRouterViewPropsBase,\n IRouteViewRouteMeta,\n} from 'zova-module-a-router';\n\nimport type { ModelStack } from '../../model/stack.js';\n\nexport interface ControllerRouterViewStackProps extends IRouterViewPropsBase {}\n\n@Controller()\nexport class ControllerRouterViewStack extends BeanRouterViewBase {\n static $propsDefault = {};\n\n @Use({ injectionScope: 'skipSelf' })\n $$modelStack: ModelStack;\n\n public backRoute(route: RouteLocationNormalizedLoadedGeneric) {\n this.$$modelStack.backRoute(route);\n return true;\n }\n\n public forwardRoute(route: RouteLocationNormalizedLoadedGeneric) {\n this.$$modelStack.forwardRoute(route);\n return true;\n }\n\n protected prepareRouteMeta(route: RouteLocationNormalizedLoadedGeneric): IRouteViewRouteMeta {\n return this.$$modelStack.prepareRouteMeta(route);\n }\n\n protected getKeepAliveInclude(): string[] | undefined {\n return this.$$modelStack.keepAliveInclude;\n }\n}\n","import { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\nimport { ControllerRouterViewStack } from '../../component/routerViewStack/controller.jsx';\nexport const ZRouterViewStack = defineComponent(_props => {\n useController(ControllerRouterViewStack, undefined, undefined);\n return () => {};\n}, prepareComponentOptions());","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** model: begin */\nexport * from '../model/stack.js';\nimport 'zova-module-a-model';\n/** model: end */\n/** model: begin */\nimport { ModelStack } from '../model/stack.js';\nimport 'zova';\n/** model: end */\n/** controller: begin */\nexport * from '../component/routerViewStack/controller.jsx';\nimport 'zova';\n/** controller: end */\n/** controller: begin */\nimport { ControllerRouterViewStack } from '../component/routerViewStack/controller.jsx';\nimport 'zova';\n/** controller: end */\n\n/** components: begin */\nexport * from './component/routerViewStack.js';\nimport { ZRouterViewStack } from './component/routerViewStack.js';\nexport const components = {\n 'routerViewStack': ZRouterViewStack\n};\nimport 'zova';\n/** components: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleARouterstack = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-routerstack\"\n}), _dec(_class = _dec2(_class = class ScopeModuleARouterstack extends BeanScopeBase {}) || _class) || _class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AAAnB,QAAA,KAAAD,QAAA,KAAAA;;;ACZ3B,IAAa,mBAAmB,iBAAgB,WAAU;CACxD,cAAc,2BAA2B,KAAA,GAAW,KAAA,CAAS;CAC7D,aAAa,CAAC;AAChB,GAAG,wBAAwB,CAAC;;;;;ACN5B,IAAI,MAAM,OAAO;AAuBjB,IAAa,aAAa,EACxB,mBAAmB,iBACrB;AAMA,IAAW,2BAA2B,OAAO,MAAM,GAAG,QAAQ,SAAa,EACzE,QAAQ,gBACV,CAAC,GAAG,KAAK,SAAS,MAAM,SAAS,MAAM,gCAAgC,cAAc,CAAC,CAAC,KAAK,MAAM,KAAK"}
1
+ {"version":3,"file":"index.js","names":["Use","Controller","BeanRouterViewBase","ControllerRouterViewStack","_dec","_dec2","__z_BeanInfo","module","_dec3","injectionScope","_dec4","Reflect","metadata","ModelStack","Object","_class","_class2","_ControllerRouterViewStack","constructor","args","_initializerDefineProperty","_descriptor","backRoute","route","$$modelStack","forwardRoute","prepareRouteMeta","getKeepAliveInclude","keepAliveInclude","getPageHostProviders","$props","pageHostProviders","$propsDefault","_applyDecoratedDescriptor","prototype","configurable","enumerable","writable","initializer"],"sources":["../src/model/stack.ts","../src/component/routerViewStack/controller.tsx","../src/.metadata/component/routerViewStack.ts","../src/.metadata/index.ts"],"sourcesContent":["var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\nimport { mutate } from 'mutate-on-copy';\nimport { deepExtend } from 'zova';\nimport { BeanModelBase, Model } from 'zova-module-a-model';\nexport let ModelStack = (_dec = Model({\n enableSelector: true,\n max: -1\n}), _dec2 = __z_BeanInfo({\n module: \"a-routerstack\"\n}), _dec(_class = _dec2(_class = class ModelStack extends BeanModelBase {\n constructor(...args) {\n super(...args);\n this.stackOptions = void 0;\n this.tabs = void 0;\n this.keepAliveInclude = void 0;\n }\n async __init__(scene, options) {\n await super.__init__(scene);\n this.bean._setBean('$$modelStack', this);\n // options\n this.stackOptions = deepExtend({}, this.$onionOptions, options);\n // tabs: always []\n this.tabs = [];\n // computed\n this.keepAliveInclude = this.$computed(() => {\n return this._getKeepAliveInclude();\n });\n // first route\n if (this.$currentRoute) {\n this.forwardRoute(this.$currentRoute);\n }\n }\n addTab(tab) {\n return this._addTab(tab);\n }\n _addTab(tab) {\n const tabKey = tab.tabKey;\n if (!tabKey) return false;\n // tab\n const [index, tabOld] = this.findTab(tabKey);\n // tabs\n if (index === -1) {\n // new\n const tabNew = {\n tabKey,\n updatedAt: Date.now()\n };\n this.tabs = mutate(this.tabs, copyState => {\n copyState.push(tabNew);\n });\n this.pruneTabs();\n } else {\n // update\n if (!this._checkIfTabNeedUpdate(tabOld, tab)) {\n return false;\n }\n this.updateTab(tab);\n }\n return true;\n }\n findTab(tabKey) {\n if (!tabKey) return [-1, undefined];\n const index = this.tabs.findIndex(item => item.tabKey === tabKey);\n if (index === -1) return [index, undefined];\n return [index, this.tabs[index]];\n }\n deleteTab(tabKey) {\n if (!tabKey) return false;\n // tabs\n const [index] = this.findTab(tabKey);\n if (index === -1) return false;\n // tabs\n this.tabs = mutate(this.tabs, copyState => {\n copyState.splice(index, 1);\n });\n return true;\n }\n updateTab(tab) {\n const tabKey = tab.tabKey;\n const [index, tabOld] = this.findTab(tabKey);\n if (index === -1 || !tabOld) return;\n const tabNew = {\n ...tabOld,\n tabKey,\n updatedAt: Date.now()\n };\n this.tabs = mutate(this.tabs, copyState => {\n copyState.splice(index, 1, tabNew);\n });\n }\n async pruneTabs() {\n let max = this.stackOptions.max;\n if (max === undefined || max === -1) return;\n if (max < 1) max = 1;\n while (true) {\n if (this.tabs.length <= max) break;\n let tabKey;\n let updatedAt = Date.now();\n for (const tab of this.tabs) {\n if (tab.updatedAt < updatedAt) {\n tabKey = tab.tabKey;\n updatedAt = tab.updatedAt;\n }\n }\n if (!tabKey) break;\n this.deleteTab(tabKey);\n }\n }\n\n // special for _addTab\n _checkIfTabNeedUpdate(tabOld, _tabNew) {\n const recentTabIndex = this.tabs.findIndex(item => item.tabKey !== tabOld.tabKey && (item.updatedAt ?? 0) >= (tabOld.updatedAt ?? 0));\n if (recentTabIndex > -1) return true;\n return false;\n }\n _getKeepAliveInclude() {\n const include = [];\n for (const tab of this.tabs) {\n if (!include.includes(tab.tabKey)) {\n include.push(tab.tabKey);\n }\n }\n return include;\n }\n backRoute(route) {\n this.deleteTab(route.fullPath);\n }\n forwardRoute(route) {\n const componentMeta = this.prepareRouteMeta(route);\n this.addTab(componentMeta);\n }\n prepareRouteMeta(route) {\n // fullPath\n const fullPath = route.fullPath;\n // tab\n return {\n tabKey: fullPath,\n componentKey: fullPath,\n fullPath\n };\n }\n}) || _class) || _class);","import { RouteLocationNormalizedLoadedGeneric } from '@cabloy/vue-router';\nimport { Use } from 'zova';\nimport { Controller } from 'zova-module-a-bean';\nimport {\n BeanRouterViewBase,\n IRouterViewPropsBase,\n IRouteViewRouteMeta,\n} from 'zova-module-a-router';\n\nimport type { ModelStack } from '../../model/stack.js';\n\nexport interface ControllerRouterViewStackProps extends IRouterViewPropsBase {\n pageHostProviders?: Record<string, unknown>;\n}\n\n@Controller()\nexport class ControllerRouterViewStack extends BeanRouterViewBase {\n static $propsDefault = {};\n\n @Use({ injectionScope: 'skipSelf' })\n $$modelStack: ModelStack;\n\n public backRoute(route: RouteLocationNormalizedLoadedGeneric) {\n this.$$modelStack.backRoute(route);\n return true;\n }\n\n public forwardRoute(route: RouteLocationNormalizedLoadedGeneric) {\n this.$$modelStack.forwardRoute(route);\n return true;\n }\n\n protected prepareRouteMeta(route: RouteLocationNormalizedLoadedGeneric): IRouteViewRouteMeta {\n return this.$$modelStack.prepareRouteMeta(route);\n }\n\n protected getKeepAliveInclude(): string[] | undefined {\n return this.$$modelStack.keepAliveInclude;\n }\n\n protected getPageHostProviders(): Record<string, unknown> | undefined {\n return this.$props.pageHostProviders;\n }\n}\n","import { defineComponent } from 'vue';\nimport { prepareComponentOptions, useController } from 'zova';\nimport { ControllerRouterViewStack } from '../../component/routerViewStack/controller.jsx';\nexport const ZRouterViewStack = defineComponent(_props => {\n useController(ControllerRouterViewStack, undefined, undefined);\n return () => {};\n}, prepareComponentOptions());","var _dec, _dec2, _class;\nimport { \"BeanInfo\" as __z_BeanInfo } from \"zova\";\n// eslint-disable\n/** model: begin */\nexport * from '../model/stack.js';\nimport 'zova-module-a-model';\n/** model: end */\n/** model: begin */\nimport { ModelStack } from '../model/stack.js';\nimport 'zova';\n/** model: end */\n/** controller: begin */\nexport * from '../component/routerViewStack/controller.jsx';\nimport 'zova';\n/** controller: end */\n/** controller: begin */\nimport { ControllerRouterViewStack } from '../component/routerViewStack/controller.jsx';\nimport 'zova';\n/** controller: end */\n\n/** components: begin */\nexport * from './component/routerViewStack.js';\nimport { ZRouterViewStack } from './component/routerViewStack.js';\nexport const components = {\n 'routerViewStack': ZRouterViewStack\n};\nimport 'zova';\n/** components: end */\n/** scope: begin */\nimport { BeanScopeBase } from 'zova';\nimport { Scope } from 'zova-module-a-bean';\nexport let ScopeModuleARouterstack = (_dec = Scope(), _dec2 = __z_BeanInfo({\n module: \"a-routerstack\"\n}), _dec(_class = _dec2(_class = class ScopeModuleARouterstack extends BeanScopeBase {}) || _class) || _class);\nimport 'zova';\n\n/** scope: end */"],"mappings":";;;;;;;AAAA,IAAI;AAAM,IAAA;AAAO,IAAA;AAKjB,IAAW,gBAAc,SAAO,MAAM;CACpC,gBAAgB;CAChB,KAAK;AACP,CAAC,GAAG,UAAQ,SAAa,EACvB,QAAQ,gBACV,CAAC,GAAG,OAAK,WAAS,QAAM,WAAS,MAAM,mBAAmB,cAAc;CACtE,YAAY,GAAG,MAAM;EACnB,MAAM,GAAG,IAAI;EACb,KAAK,eAAe,KAAK;EACzB,KAAK,OAAO,KAAK;EACjB,KAAK,mBAAmB,KAAK;CAC/B;CACA,MAAM,SAAS,OAAO,SAAS;EAC7B,MAAM,MAAM,SAAS,KAAK;EAC1B,KAAK,KAAK,SAAS,gBAAgB,IAAI;EAEvC,KAAK,eAAe,WAAW,CAAC,GAAG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
1
1
  {
2
2
  "name": "zova-module-a-routerstack",
3
- "version": "5.1.26",
4
- "gitHead": "1a39e8008e1b48001cfeff475ddd53a2a0d867c4",
3
+ "version": "5.1.28",
4
+ "gitHead": "bd7ffc467ab9d5e7e420e38d1c36a1162991f9fc",
5
5
  "description": "",
6
6
  "keywords": [
7
7
  "Zova Module"
@@ -4,15 +4,15 @@ export * from '../model/stack.js';
4
4
  import { IModelOptionsStack } from '../model/stack.js';
5
5
  import 'zova-module-a-model';
6
6
  declare module 'zova-module-a-model' {
7
-
7
+
8
8
  export interface IModelRecord {
9
9
  'a-routerstack:stack': IModelOptionsStack;
10
10
  }
11
11
 
12
-
12
+
13
13
  }
14
14
  declare module 'zova-module-a-routerstack' {
15
-
15
+
16
16
  export interface ModelStack {
17
17
  /** @internal */
18
18
  get scope(): ScopeModuleARouterstack;
@@ -22,7 +22,7 @@ declare module 'zova-module-a-routerstack' {
22
22
  get $beanFullName(): 'a-routerstack.model.stack';
23
23
  get $onionName(): 'a-routerstack:stack';
24
24
  get $onionOptions(): IModelOptionsStack;
25
- }
25
+ }
26
26
  }
27
27
  /** model: end */
28
28
  /** model: begin */
@@ -39,15 +39,15 @@ export * from '../component/routerViewStack/controller.jsx';
39
39
 
40
40
  import 'zova';
41
41
  declare module 'zova' {
42
-
43
-
42
+
43
+
44
44
  }
45
45
  declare module 'zova-module-a-routerstack' {
46
-
46
+
47
47
  export interface ControllerRouterViewStack {
48
48
  /** @internal */
49
49
  get scope(): ScopeModuleARouterstack;
50
- }
50
+ }
51
51
  }
52
52
  /** controller: end */
53
53
  /** controller: begin */
@@ -92,12 +92,12 @@ declare module 'zova' {
92
92
  export interface IBeanScopeRecord {
93
93
  'a-routerstack': ScopeModuleARouterstack;
94
94
  }
95
-
96
-
97
95
 
98
-
99
96
 
100
-
97
+
98
+
99
+
100
+
101
101
  }
102
-
102
+
103
103
  /** scope: end */
@@ -9,7 +9,9 @@ import {
9
9
 
10
10
  import type { ModelStack } from '../../model/stack.js';
11
11
 
12
- export interface ControllerRouterViewStackProps extends IRouterViewPropsBase {}
12
+ export interface ControllerRouterViewStackProps extends IRouterViewPropsBase {
13
+ pageHostProviders?: Record<string, unknown>;
14
+ }
13
15
 
14
16
  @Controller()
15
17
  export class ControllerRouterViewStack extends BeanRouterViewBase {
@@ -35,4 +37,8 @@ export class ControllerRouterViewStack extends BeanRouterViewBase {
35
37
  protected getKeepAliveInclude(): string[] | undefined {
36
38
  return this.$$modelStack.keepAliveInclude;
37
39
  }
40
+
41
+ protected getPageHostProviders(): Record<string, unknown> | undefined {
42
+ return this.$props.pageHostProviders;
43
+ }
38
44
  }