zova-core 5.1.47 → 5.1.49

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.
@@ -1 +1 @@
1
- {"version":3,"file":"beanControllerPageBase.d.ts","sourceRoot":"","sources":["../../src/bean/beanControllerPageBase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,qBAAa,sBAAuB,SAAQ,QAAQ;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CAmBxB"}
1
+ {"version":3,"file":"beanControllerPageBase.d.ts","sourceRoot":"","sources":["../../src/bean/beanControllerPageBase.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,qBAAa,sBAAuB,SAAQ,QAAQ;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CAoBxB"}
@@ -5,6 +5,7 @@ export declare class AppModule extends BeanSimple {
5
5
  private modules;
6
6
  private mainInstances;
7
7
  private monkeyInstances;
8
+ private _ensureModulesMeta;
8
9
  get<K extends TypeBeanScopeRecordKeys>(moduleName: K, forceLoad?: boolean): IModule | undefined;
9
10
  get(moduleName: string, forceLoad?: boolean): IModule | undefined;
10
11
  get(moduleName: IModuleInfo, forceLoad?: boolean): IModule | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/core/component/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAUlE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,qBAAa,SAAU,SAAQ,UAAU;IACvC,OAAO,CAAC,OAAO,CAAmD;IAClE,OAAO,CAAC,aAAa,CA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kBAAkB;IAe1B,GAAG,CAAC,CAAC,SAAS,uBAAuB,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAC/F,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IACjE,GAAG,CAAC,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS;IAuBhE,GAAG,CAAC,CAAC,SAAS,uBAAuB,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IACvE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IACzC,GAAG,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAqBpD,MAAM,CAAC,CAAC,SAAS,uBAAuB,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO;IACjE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IACnC,MAAM,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO;YAK1B,oBAAoB;YAepB,QAAQ;YA8BR,aAAa;YAsBb,kBAAkB;IAIhC,OAAO,CAAC,mBAAmB;CA8G5B"}
@@ -1,6 +1,9 @@
1
1
  import { BeanSimple } from '../../bean/beanSimple.ts';
2
2
  export declare class CtxComponent extends BeanSimple {
3
3
  private _bean_render_original;
4
+ private _instance_ssrRender_original;
5
+ private _renderPatched;
6
+ private _ssrRenderReset;
4
7
  activate(): void;
5
8
  private _getRender;
6
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/core/context/component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAItD,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAO,CAAC,qBAAqB,CAAM;IAEnC,QAAQ;IAsCR,OAAO,CAAC,UAAU;CAOnB"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/core/context/component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAOtD,qBAAa,YAAa,SAAQ,UAAU;IAC1C,OAAO,CAAC,qBAAqB,CAAM;IACnC,OAAO,CAAC,4BAA4B,CAAM;IAC1C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,eAAe,CAAS;IAEhC,QAAQ;IAgER,OAAO,CAAC,UAAU;CAOnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/core/context/util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,qBAAa,OAAQ,SAAQ,UAAU;IACrC,aAAa,CAAC,EAAE,KAAA,EAAE,QAAQ,CAAC,EAAE,OAAO;CAiBrC"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../../src/core/context/util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAGtD,qBAAa,OAAQ,SAAQ,UAAU;IACrC,aAAa,CAAC,EAAE,KAAA,EAAE,QAAQ,CAAC,EAAE,OAAO;CAqBrC"}
@@ -3,10 +3,12 @@ import type { TypeBeanScopeRecordKeys } from '../../bean/type.ts';
3
3
  import type { PluginZovaModulesMeta } from '../../types/index.ts';
4
4
  import { BeanSimple } from '../../bean/beanSimple.ts';
5
5
  export declare class SysModule extends BeanSimple {
6
- modulesMeta: PluginZovaModulesMeta;
6
+ modulesMeta: PluginZovaModulesMeta | undefined;
7
7
  private modules;
8
8
  private mainInstances;
9
9
  private monkeyInstances;
10
+ getModulesMeta(): PluginZovaModulesMeta | undefined;
11
+ private _ensureModulesMeta;
10
12
  get<K extends TypeBeanScopeRecordKeys>(moduleName: K): IModule | undefined;
11
13
  get(moduleName: string): IModule | undefined;
12
14
  get(moduleName: IModuleInfo): IModule | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/core/sys/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMhE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAKV,qBAAqB,EAEtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAKtD,qBAAa,SAAU,SAAQ,UAAU;IAChC,WAAW,EAAE,qBAAqB,CAAC;IAC1C,OAAO,CAAC,OAAO,CAAgD;IAC/D,OAAO,CAAC,aAAa,CAAsC;IAC3D,OAAO,CAAC,eAAe,CAAqD;IAmB5E,GAAG,CAAC,CAAC,SAAS,uBAAuB,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,GAAG,SAAS;IAC1E,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAC5C,GAAG,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,GAAG,SAAS;IAkB3C,GAAG,CAAC,CAAC,SAAS,uBAAuB,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IACvE,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IACzC,GAAG,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAoBpD,MAAM,CAAC,CAAC,SAAS,uBAAuB,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO;IACjE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IACnC,MAAM,CAAC,UAAU,EAAE,WAAW,GAAG,OAAO;YAW1B,kCAAkC;IAoBnC,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE;YAwBhC,oBAAoB;YAgBpB,iB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AO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,kBAAkB;CAM3B;AAcD,eAAO,MAAM,GAAG,SAAgB,CAAC"}
1
+ {"version":3,"file":"sys.d.ts","sourceRoot":"","sources":["../../../src/core/sys/sys.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAK5D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EAAc,OAAO,EAAE,MAAM,WAAW,CAAC;AAEhD,QAAA,MAAM,0BAA0B,eAAuC,CAAC;AACxE,QAAA,MAAM,cAAc,eAA2B,CAAC;AAEhD,qBAAa,OAAO;IAClB,OAAO,CAAC,CAAC,0BAA0B,CAAC,CAA4B;IAChE,OAAO,CAAC,CAAC,cAAc,CAAC,CAAU;IAClC,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,GAAG,EAAE,aAAa,CAAC;IACnB,QAAQ,EAAE,YAAY,CAAC;;YAsBT,gBAAgB;IAqC9B,OAAO,CAAC,UAAU;IAkBX,KAAK;YAeE,cAAc;IAS5B,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,mBAAmB;IAQ3B,OAAO,CAAC,kBAAkB;CAM3B;AAcD,eAAO,MAAM,GAAG,SAAgB,CAAC"}
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ import '@vue/runtime-dom';
17
17
  import { Logger, format, NpmConfigSetLevels, print, colorize } from '@cabloy/logger';
18
18
  import * as localeutil from '@cabloy/localeutil';
19
19
  import * as ModuleInfo from '@cabloy/module-info';
20
- import { setCurrentInstance } from '@cabloy/vue-runtime-core';
20
+ import { withCurrentInstanceScopeSSR, withCurrentInstanceScope } from '@cabloy/vue-runtime-core';
21
21
 
22
22
  function cast(source) {
23
23
  return source;
@@ -1183,7 +1183,7 @@ class BeanContainer {
1183
1183
  } else {
1184
1184
  this.app.meta.module._monkeyModuleSync(false, 'beanDispose', undefined, this, beanInstance);
1185
1185
  this.runWithInstanceScopeOrAppContext(() => {
1186
- beanInstance.__dispose__();
1186
+ return beanInstance.__dispose__();
1187
1187
  });
1188
1188
  this.app.meta.module._monkeyModuleSync(false, 'beanDisposed', undefined, this, beanInstance);
1189
1189
  }
@@ -1518,8 +1518,8 @@ class BeanContainer {
1518
1518
  await this.app?.meta.module._monkeyModule(true, 'beanInit', undefined, this, beanInstance);
1519
1519
  }
1520
1520
  if (!(beanInstance instanceof BeanAopBase) && beanInstance.__init__) {
1521
- await this.runWithInstanceScopeOrAppContext(async () => {
1522
- await beanInstance.__init__(...args);
1521
+ await this.runWithInstanceScopeOrAppContext(() => {
1522
+ return beanInstance.__init__(...args);
1523
1523
  });
1524
1524
  }
1525
1525
  if (this.containerType === 'sys') {
@@ -2284,6 +2284,7 @@ class BeanControllerPageBase extends BeanBase {
2284
2284
 
2285
2285
  /** @internal */
2286
2286
  __updateControllerData() {
2287
+ if (!this.app) return;
2287
2288
  this.app.meta.module._monkeyModuleSync(true, 'controllerDataUpdate', undefined, this);
2288
2289
  }
2289
2290
  }
@@ -2919,7 +2920,18 @@ class SysModule extends BeanSimple {
2919
2920
  dispose() {
2920
2921
  this.modulesMeta = undefined;
2921
2922
  }
2923
+ getModulesMeta() {
2924
+ return this.modulesMeta;
2925
+ }
2926
+ _ensureModulesMeta() {
2927
+ const modulesMeta = this.modulesMeta;
2928
+ if (!modulesMeta) {
2929
+ throw new Error('module registry has been disposed');
2930
+ }
2931
+ return modulesMeta;
2932
+ }
2922
2933
  get(moduleName) {
2934
+ if (!this.modulesMeta) return undefined;
2923
2935
  // module info
2924
2936
  if (!moduleName) return undefined;
2925
2937
  const moduleInfo = typeof moduleName === 'string' ? ModuleInfo.parseInfo(moduleName) : moduleName;
@@ -2943,8 +2955,9 @@ class SysModule extends BeanSimple {
2943
2955
  // should not try check get directly
2944
2956
  // const module = this.getOnly(relativeName);
2945
2957
  // if (module) return module;
2958
+ const modulesMeta = this._ensureModulesMeta();
2946
2959
  // module
2947
- const moduleRepo = this.modulesMeta.modules[relativeName];
2960
+ const moduleRepo = modulesMeta.modules[relativeName];
2948
2961
  if (!moduleRepo) throw new Error(`module not exists: ${relativeName}`);
2949
2962
  // install
2950
2963
  await this._install(relativeName, moduleRepo);
@@ -2952,17 +2965,20 @@ class SysModule extends BeanSimple {
2952
2965
  return moduleRepo;
2953
2966
  }
2954
2967
  exists(moduleName) {
2968
+ const modulesMeta = this.modulesMeta;
2969
+ if (!modulesMeta) return false;
2955
2970
  // module info
2956
2971
  if (!moduleName) return false;
2957
2972
  const moduleInfo = typeof moduleName === 'string' ? ModuleInfo.parseInfo(moduleName) : moduleName;
2958
2973
  if (!moduleInfo) throw new Error(`invalid module name: ${moduleName}`);
2959
- const moduleRepo = this.modulesMeta.modules[moduleInfo.relativeName];
2974
+ const moduleRepo = modulesMeta.modules[moduleInfo.relativeName];
2960
2975
  return !!moduleRepo;
2961
2976
  }
2962
2977
  async _loadAllMonkeysAndSyncsAndPreloads() {
2978
+ const modulesMeta = this._ensureModulesMeta();
2963
2979
  const moduleNames = [];
2964
- for (const moduleName of this.modulesMeta.moduleNames) {
2965
- const module = this.modulesMeta.modules[moduleName];
2980
+ for (const moduleName of modulesMeta.moduleNames) {
2981
+ const module = modulesMeta.modules[moduleName];
2966
2982
  const info = module.info;
2967
2983
  const shouldLoad = process.env.SERVER || info.capabilities?.monkey || info.capabilities?.sync || info.capabilities?.preload;
2968
2984
  if (shouldLoad) {
@@ -2976,10 +2992,11 @@ class SysModule extends BeanSimple {
2976
2992
  }
2977
2993
  async loadModules(moduleNames) {
2978
2994
  if (moduleNames.length === 0) return;
2995
+ const modulesMeta = this._ensureModulesMeta();
2979
2996
  const promises = [];
2980
2997
  const moduleNamesLoading = [];
2981
2998
  for (const moduleName of moduleNames) {
2982
- const module = this.modulesMeta.modules[moduleName];
2999
+ const module = modulesMeta.modules[moduleName];
2983
3000
  if (!module) throw new Error(`module not found: ${moduleName}`);
2984
3001
  const moduleResource = module.resource;
2985
3002
  if (typeof moduleResource === 'function') {
@@ -2994,25 +3011,27 @@ class SysModule extends BeanSimple {
2994
3011
  const modulesResource = await Promise.all(promises);
2995
3012
  for (let i = 0; i < modulesResource.length; i++) {
2996
3013
  const moduleName = moduleNamesLoading[i];
2997
- this.modulesMeta.modules[moduleName].resource = modulesResource[i];
3014
+ modulesMeta.modules[moduleName].resource = modulesResource[i];
2998
3015
  }
2999
3016
  }
3000
3017
  async _requireAllSpecifics(capabilityName) {
3001
- const moduleNames = this.modulesMeta.moduleNames.filter(moduleName => {
3002
- const module = this.modulesMeta.modules[moduleName];
3018
+ const modulesMeta = this._ensureModulesMeta();
3019
+ const moduleNames = modulesMeta.moduleNames.filter(moduleName => {
3020
+ const module = modulesMeta.modules[moduleName];
3003
3021
  return module.info.capabilities?.[capabilityName];
3004
3022
  });
3005
3023
  if (moduleNames.length > 0) {
3006
3024
  this.sys.meta.logger.child('module', 'default').debug(`modules ${capabilityName}: ${moduleNames.join(',')}`);
3007
3025
  }
3008
3026
  for (const moduleName of moduleNames) {
3009
- const module = this.modulesMeta.modules[moduleName];
3027
+ const module = modulesMeta.modules[moduleName];
3010
3028
  await this._install(moduleName, module);
3011
3029
  }
3012
3030
  }
3013
3031
  async _requireAllOthers() {
3014
- for (const moduleName of this.modulesMeta.moduleNames) {
3015
- const module = this.modulesMeta.modules[moduleName];
3032
+ const modulesMeta = this._ensureModulesMeta();
3033
+ for (const moduleName of modulesMeta.moduleNames) {
3034
+ const module = modulesMeta.modules[moduleName];
3016
3035
  const info = module.info;
3017
3036
  const shouldInstall = !info.capabilities?.monkey && !info.capabilities?.sync && !info.capabilities?.preload;
3018
3037
  if (shouldInstall) {
@@ -3098,6 +3117,8 @@ class SysModule extends BeanSimple {
3098
3117
 
3099
3118
  /** @internal */
3100
3119
  async _monkeyModule(order, monkeyName, moduleTarget, ...monkeyData) {
3120
+ const modulesMeta = this.modulesMeta;
3121
+ if (!modulesMeta) return;
3101
3122
  // self: main
3102
3123
  if (moduleTarget) {
3103
3124
  const mainInstance = this.mainInstances[moduleTarget.info.relativeName];
@@ -3106,8 +3127,8 @@ class SysModule extends BeanSimple {
3106
3127
  }
3107
3128
  }
3108
3129
  // module monkey
3109
- await forEach(this.modulesMeta.moduleNames, order, async key => {
3110
- const moduleMonkey = this.modulesMeta.modules[key];
3130
+ await forEach(modulesMeta.moduleNames, order, async key => {
3131
+ const moduleMonkey = modulesMeta.modules[key];
3111
3132
  if (moduleMonkey.info.capabilities?.monkey) {
3112
3133
  const monkeyInstance = this.monkeyInstances[key];
3113
3134
  if (monkeyInstance && monkeyInstance[monkeyName]) {
@@ -3136,6 +3157,8 @@ class SysModule extends BeanSimple {
3136
3157
 
3137
3158
  /** @internal */
3138
3159
  _monkeyModuleSync(order, monkeyName, moduleTarget, ...monkeyData) {
3160
+ const modulesMeta = this.modulesMeta;
3161
+ if (!modulesMeta) return;
3139
3162
  // self: main
3140
3163
  if (moduleTarget) {
3141
3164
  const mainInstance = this.mainInstances[moduleTarget.info.relativeName];
@@ -3144,8 +3167,8 @@ class SysModule extends BeanSimple {
3144
3167
  }
3145
3168
  }
3146
3169
  // module monkey
3147
- forEachSync(this.modulesMeta.moduleNames, order, key => {
3148
- const moduleMonkey = this.modulesMeta.modules[key];
3170
+ forEachSync(modulesMeta.moduleNames, order, key => {
3171
+ const moduleMonkey = modulesMeta.modules[key];
3149
3172
  if (moduleMonkey.info.capabilities?.monkey) {
3150
3173
  const monkeyInstance = this.monkeyInstances[key];
3151
3174
  if (monkeyInstance && monkeyInstance[monkeyName]) {
@@ -3312,11 +3335,12 @@ class ZovaSys {
3312
3335
  viteHot.on('vite:beforeFullReload', hook);
3313
3336
  }
3314
3337
  if (process.env.CLIENT && typeof window !== 'undefined') {
3315
- const hook = () => {
3338
+ const hook = event => {
3339
+ if (event.persisted) return;
3316
3340
  this.close();
3317
- window.removeEventListener('beforeunload', hook);
3341
+ window.removeEventListener('pagehide', hook);
3318
3342
  };
3319
- window.addEventListener('beforeunload', hook);
3343
+ window.addEventListener('pagehide', hook);
3320
3344
  }
3321
3345
  }
3322
3346
  close() {
@@ -3420,17 +3444,22 @@ const ClientOnly = defineComponent({
3420
3444
  }
3421
3445
  });
3422
3446
 
3447
+ const SymbolTypeSSRRenderOriginal = Symbol('SymbolTypeSSRRenderOriginal');
3448
+ const SymbolTypeSSRRenderResetCount = Symbol('SymbolTypeSSRRenderResetCount');
3423
3449
  class CtxComponent extends BeanSimple {
3424
3450
  constructor(...args) {
3425
3451
  super(...args);
3426
3452
  this._bean_render_original = void 0;
3453
+ this._instance_ssrRender_original = void 0;
3454
+ this._renderPatched = false;
3455
+ this._ssrRenderReset = false;
3427
3456
  }
3428
3457
  activate() {
3429
3458
  if (this.ctx.disposed) return;
3430
3459
  const renderMethod = 'render';
3431
- const self = this;
3432
3460
  const instance = cast(this.ctx.instance);
3433
3461
  this._bean_render_original = instance[renderMethod];
3462
+ const self = this;
3434
3463
  instance[renderMethod] = function (...args) {
3435
3464
  if (instance.isUnmounted) return;
3436
3465
  if (!self.ctx.meta.state.inited.state) {
@@ -3451,16 +3480,42 @@ class CtxComponent extends BeanSimple {
3451
3480
  // return render.render();
3452
3481
  // }
3453
3482
  };
3454
- instance.type.ssrRender = null;
3483
+ this._renderPatched = true;
3484
+ const componentType = cast(instance.type);
3485
+ const ssrRenderResetCount = componentType[SymbolTypeSSRRenderResetCount] ?? 0;
3486
+ if (ssrRenderResetCount === 0) {
3487
+ componentType[SymbolTypeSSRRenderOriginal] = componentType.ssrRender;
3488
+ componentType.ssrRender = null;
3489
+ }
3490
+ componentType[SymbolTypeSSRRenderResetCount] = ssrRenderResetCount + 1;
3491
+ this._instance_ssrRender_original = instance.ssrRender;
3455
3492
  instance.ssrRender = null;
3493
+ this._ssrRenderReset = true;
3456
3494
  }
3457
3495
 
3458
3496
  /** @internal */
3459
3497
  dispose() {
3460
3498
  const renderMethod = 'render';
3461
3499
  const instance = cast(this.ctx.instance);
3462
- instance[renderMethod] = this._bean_render_original;
3500
+ if (this._renderPatched) {
3501
+ instance[renderMethod] = this._bean_render_original;
3502
+ }
3503
+ if (this._ssrRenderReset) {
3504
+ instance.ssrRender = this._instance_ssrRender_original;
3505
+ const componentType = cast(instance.type);
3506
+ const ssrRenderResetCount = componentType[SymbolTypeSSRRenderResetCount] ?? 0;
3507
+ if (ssrRenderResetCount <= 1) {
3508
+ componentType.ssrRender = componentType[SymbolTypeSSRRenderOriginal];
3509
+ componentType[SymbolTypeSSRRenderOriginal] = undefined;
3510
+ componentType[SymbolTypeSSRRenderResetCount] = 0;
3511
+ } else {
3512
+ componentType[SymbolTypeSSRRenderResetCount] = ssrRenderResetCount - 1;
3513
+ }
3514
+ }
3463
3515
  this._bean_render_original = null;
3516
+ this._instance_ssrRender_original = null;
3517
+ this._renderPatched = false;
3518
+ this._ssrRenderReset = false;
3464
3519
  }
3465
3520
  _getRender() {
3466
3521
  const render = this.bean._getBeanSyncOnly(BeanControllerIdentifier);
@@ -3561,18 +3616,22 @@ class CtxUtil extends BeanSimple {
3561
3616
  if (this.ctx.disposed) {
3562
3617
  throwErrorComponentUnmounted();
3563
3618
  }
3564
- const reset = setCurrentInstance(this.ctx.instance);
3565
- if (!tracking) {
3566
- pauseTracking();
3567
- }
3568
- try {
3569
- return fn();
3570
- } finally {
3619
+ const instance = this.ctx.instance;
3620
+ const runner = process.env.SERVER ? withCurrentInstanceScopeSSR : withCurrentInstanceScope;
3621
+ const result = runner(instance, () => {
3571
3622
  if (!tracking) {
3572
- resetTracking();
3623
+ pauseTracking();
3573
3624
  }
3574
- reset();
3575
- }
3625
+ try {
3626
+ const result = fn();
3627
+ return result;
3628
+ } finally {
3629
+ if (!tracking) {
3630
+ resetTracking();
3631
+ }
3632
+ }
3633
+ });
3634
+ return result;
3576
3635
  }
3577
3636
  }
3578
3637
 
@@ -3867,6 +3926,14 @@ class AppModule extends BeanSimple {
3867
3926
  this.mainInstances = {};
3868
3927
  this.monkeyInstances = {};
3869
3928
  }
3929
+ _ensureModulesMeta() {
3930
+ const modulesMeta = this.sys.meta.module.getModulesMeta();
3931
+ if (!modulesMeta) {
3932
+ throw new Error('module registry has been disposed');
3933
+ }
3934
+ return modulesMeta;
3935
+ }
3936
+
3870
3937
  /** @internal */
3871
3938
  async initialize() {
3872
3939
  await this._requireAllSpecifics('preload');
@@ -3874,6 +3941,7 @@ class AppModule extends BeanSimple {
3874
3941
  await this._requireAllSpecifics('sync');
3875
3942
  }
3876
3943
  get(moduleName, forceLoad) {
3944
+ if (!this.sys.meta.module.getModulesMeta()) return undefined;
3877
3945
  // module info
3878
3946
  if (!moduleName) return undefined;
3879
3947
  const moduleInfo = typeof moduleName === 'string' ? ModuleInfo.parseInfo(moduleName) : moduleName;
@@ -3901,8 +3969,9 @@ class AppModule extends BeanSimple {
3901
3969
  // should not try check get directly
3902
3970
  // const module = this.getOnly(relativeName);
3903
3971
  // if (module) return module;
3972
+ const modulesMeta = this._ensureModulesMeta();
3904
3973
  // module
3905
- const moduleRepo = this.sys.meta.module.modulesMeta.modules[relativeName];
3974
+ const moduleRepo = modulesMeta.modules[relativeName];
3906
3975
  if (!moduleRepo) throw new Error(`module not exists: ${relativeName}`);
3907
3976
  // install
3908
3977
  await this._install(relativeName, moduleRepo);
@@ -3913,15 +3982,16 @@ class AppModule extends BeanSimple {
3913
3982
  return this.sys.meta.module.exists(moduleName);
3914
3983
  }
3915
3984
  async _requireAllSpecifics(capabilityName) {
3916
- const moduleNames = this.sys.meta.module.modulesMeta.moduleNames.filter(moduleName => {
3917
- const module = this.sys.meta.module.modulesMeta.modules[moduleName];
3985
+ const modulesMeta = this._ensureModulesMeta();
3986
+ const moduleNames = modulesMeta.moduleNames.filter(moduleName => {
3987
+ const module = modulesMeta.modules[moduleName];
3918
3988
  return module.info.capabilities?.[capabilityName];
3919
3989
  });
3920
3990
  // if (moduleNames.length > 0) {
3921
3991
  // this.sys.meta.logger.child('module', 'default').debug(`app modules: ${capabilityName}: ${moduleNames.join(',')}`);
3922
3992
  // }
3923
3993
  for (const moduleName of moduleNames) {
3924
- const module = this.sys.meta.module.modulesMeta.modules[moduleName];
3994
+ const module = modulesMeta.modules[moduleName];
3925
3995
  await this._install(moduleName, module);
3926
3996
  }
3927
3997
  }
@@ -3976,29 +4046,31 @@ class AppModule extends BeanSimple {
3976
4046
 
3977
4047
  /** @internal */
3978
4048
  async _monkeyModule(order, monkeyName, moduleTarget, ...monkeyData) {
4049
+ const modulesMeta = this.sys.meta.module.getModulesMeta();
4050
+ if (!modulesMeta) return;
3979
4051
  // self: main
3980
4052
  if (moduleTarget) {
3981
4053
  const mainInstance = this.mainInstances[moduleTarget.info.relativeName];
3982
4054
  if (mainInstance && mainInstance[monkeyName]) {
3983
4055
  // @ts-ignore ignore
3984
- await this.app.vue.runWithContext(async () => {
3985
- await mainInstance[monkeyName](...monkeyData);
4056
+ await this.app.vue.runWithContext(() => {
4057
+ return mainInstance[monkeyName](...monkeyData);
3986
4058
  });
3987
4059
  }
3988
4060
  }
3989
4061
  // module monkey
3990
- await forEach(this.sys.meta.module.modulesMeta.moduleNames, order, async key => {
3991
- const moduleMonkey = this.sys.meta.module.modulesMeta.modules[key];
4062
+ await forEach(modulesMeta.moduleNames, order, async key => {
4063
+ const moduleMonkey = modulesMeta.modules[key];
3992
4064
  if (moduleMonkey.info.capabilities?.monkey) {
3993
4065
  const monkeyInstance = this.monkeyInstances[key];
3994
4066
  if (monkeyInstance && monkeyInstance[monkeyName]) {
3995
- await this.app.vue.runWithContext(async () => {
4067
+ await this.app.vue.runWithContext(() => {
3996
4068
  if (moduleTarget === undefined) {
3997
4069
  // @ts-ignore ignore
3998
- await monkeyInstance[monkeyName](...monkeyData);
4070
+ return monkeyInstance[monkeyName](...monkeyData);
3999
4071
  } else {
4000
4072
  // @ts-ignore ignore
4001
- await monkeyInstance[monkeyName](moduleTarget, ...monkeyData);
4073
+ return monkeyInstance[monkeyName](moduleTarget, ...monkeyData);
4002
4074
  }
4003
4075
  });
4004
4076
  }
@@ -4007,13 +4079,13 @@ class AppModule extends BeanSimple {
4007
4079
  // app monkey
4008
4080
  const appMonkey = this.app.meta.appMonkey;
4009
4081
  if (appMonkey && appMonkey[monkeyName]) {
4010
- await this.app.vue.runWithContext(async () => {
4082
+ await this.app.vue.runWithContext(() => {
4011
4083
  if (moduleTarget === undefined) {
4012
4084
  // @ts-ignore ignore
4013
- await appMonkey[monkeyName](...monkeyData);
4085
+ return appMonkey[monkeyName](...monkeyData);
4014
4086
  } else {
4015
4087
  // @ts-ignore ignore
4016
- await appMonkey[monkeyName](moduleTarget, ...monkeyData);
4088
+ return appMonkey[monkeyName](moduleTarget, ...monkeyData);
4017
4089
  }
4018
4090
  });
4019
4091
  }
@@ -4021,29 +4093,31 @@ class AppModule extends BeanSimple {
4021
4093
 
4022
4094
  /** @internal */
4023
4095
  _monkeyModuleSync(order, monkeyName, moduleTarget, ...monkeyData) {
4096
+ const modulesMeta = this.sys.meta.module.getModulesMeta();
4097
+ if (!modulesMeta) return;
4024
4098
  // self: main
4025
4099
  if (moduleTarget) {
4026
4100
  const mainInstance = this.mainInstances[moduleTarget.info.relativeName];
4027
4101
  if (mainInstance && mainInstance[monkeyName]) {
4028
4102
  // @ts-ignore ignore
4029
- this.app.vue.runWithContext(async () => {
4030
- mainInstance[monkeyName](...monkeyData);
4103
+ this.app.vue.runWithContext(() => {
4104
+ return mainInstance[monkeyName](...monkeyData);
4031
4105
  });
4032
4106
  }
4033
4107
  }
4034
4108
  // module monkey
4035
- forEachSync(this.sys.meta.module.modulesMeta.moduleNames, order, key => {
4036
- const moduleMonkey = this.sys.meta.module.modulesMeta.modules[key];
4109
+ forEachSync(modulesMeta.moduleNames, order, key => {
4110
+ const moduleMonkey = modulesMeta.modules[key];
4037
4111
  if (moduleMonkey.info.capabilities?.monkey) {
4038
4112
  const monkeyInstance = this.monkeyInstances[key];
4039
4113
  if (monkeyInstance && monkeyInstance[monkeyName]) {
4040
- this.app.vue.runWithContext(async () => {
4114
+ this.app.vue.runWithContext(() => {
4041
4115
  if (moduleTarget === undefined) {
4042
4116
  // @ts-ignore ignore
4043
- monkeyInstance[monkeyName](...monkeyData);
4117
+ return monkeyInstance[monkeyName](...monkeyData);
4044
4118
  } else {
4045
4119
  // @ts-ignore ignore
4046
- monkeyInstance[monkeyName](moduleTarget, ...monkeyData);
4120
+ return monkeyInstance[monkeyName](moduleTarget, ...monkeyData);
4047
4121
  }
4048
4122
  });
4049
4123
  }
@@ -4052,13 +4126,13 @@ class AppModule extends BeanSimple {
4052
4126
  // app monkey
4053
4127
  const appMonkey = this.app.meta.appMonkey;
4054
4128
  if (appMonkey && appMonkey[monkeyName]) {
4055
- this.app.vue.runWithContext(async () => {
4129
+ this.app.vue.runWithContext(() => {
4056
4130
  if (moduleTarget === undefined) {
4057
4131
  // @ts-ignore ignore
4058
- appMonkey[monkeyName](...monkeyData);
4132
+ return appMonkey[monkeyName](...monkeyData);
4059
4133
  } else {
4060
4134
  // @ts-ignore ignore
4061
- appMonkey[monkeyName](moduleTarget, ...monkeyData);
4135
+ return appMonkey[monkeyName](moduleTarget, ...monkeyData);
4062
4136
  }
4063
4137
  });
4064
4138
  }