ezfw-core 1.0.80 → 1.0.82

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.
@@ -1094,6 +1094,11 @@ export class EzBaseComponent {
1094
1094
  }
1095
1095
 
1096
1096
  destroy(): void {
1097
+ // Call controller onDestroy if exists
1098
+ if (this.controller && typeof (this.controller as EzController & { onDestroy?: () => void }).onDestroy === 'function') {
1099
+ (this.controller as EzController & { onDestroy?: () => void }).onDestroy!();
1100
+ }
1101
+
1097
1102
  // Destroy children first
1098
1103
  if (this._children) {
1099
1104
  for (const child of this._children) {
package/core/renderer.ts CHANGED
@@ -421,30 +421,35 @@ export class EzRenderer {
421
421
  }
422
422
  }
423
423
 
424
- async executeOnInit(config: ComponentConfig, controllerName: string | null): Promise<void> {
425
- let controller = this.ez._controllers[controllerName || ''];
424
+ async executeOnInit(instance: EzBaseComponent | null, config: ComponentConfig): Promise<void> {
425
+ // Prefer instance's config and controller when available
426
+ const effectiveConfig = (instance?.config || config) as ComponentConfig;
426
427
 
427
- if (!controller && config.controller) {
428
- const ctrlName = typeof config.controller === 'string'
429
- ? config.controller
428
+ let controller: ControllerInstance | null = null;
429
+
430
+ if (instance?.controller) {
431
+ controller = instance.controller as unknown as ControllerInstance;
432
+ } else if (effectiveConfig.controller) {
433
+ const ctrlName = typeof effectiveConfig.controller === 'string'
434
+ ? effectiveConfig.controller
430
435
  : null;
431
436
  if (ctrlName) {
432
- controller = this.ez._controllers[ctrlName]
433
- || this.ez._controllers[`${ctrlName}Controller`];
434
- } else if (typeof config.controller === 'object') {
435
- controller = config.controller as ControllerInstance;
437
+ controller = this.ez._controllers[ctrlName] ||
438
+ this.ez._controllers[`${ctrlName}Controller`];
439
+ } else if (typeof effectiveConfig.controller === 'object') {
440
+ controller = effectiveConfig.controller as ControllerInstance;
436
441
  }
437
442
  }
438
443
 
439
444
  if (!controller) return;
440
445
 
441
- let fn: unknown = config.init;
446
+ let fn: unknown = effectiveConfig.init;
442
447
  if (typeof fn === 'string') {
443
448
  fn = controller[fn];
444
449
  }
445
450
 
446
451
  if (typeof fn === 'function') {
447
- await fn.call(controller, config);
452
+ await fn.call(controller, instance);
448
453
  }
449
454
  }
450
455
 
@@ -1051,7 +1056,7 @@ export class EzRenderer {
1051
1056
 
1052
1057
  if (config.init && config.skipInit !== true) {
1053
1058
  queueMicrotask(() => {
1054
- this.executeOnInit(config, controllerName)
1059
+ this.executeOnInit(instance || null, config)
1055
1060
  .catch(err => this.ez.handleFrameworkError(err));
1056
1061
  });
1057
1062
  }
@@ -78,12 +78,10 @@ export class StaticHtmlRenderer {
78
78
  // If we're inside an island or template-based component, render children as static
79
79
  // (they will be re-rendered when the parent hydrates or when SPA takes over)
80
80
  if (ctx.insideIsland || ctx.insideTemplate) {
81
- console.log(`[SSR] ${name} rendered as static (inside ${ctx.insideIsland ? 'island' : 'template'})`);
82
81
  return this.renderStaticComponent(name, definition, props, ctx);
83
82
  }
84
83
  // Analyze the component
85
84
  const analysis = this.analyzer.analyze(name, definition);
86
- console.log(`[SSR] ${name} analyzed as: ${analysis.type}`);
87
85
  if (analysis.type === 'island') {
88
86
  // Render as island placeholder
89
87
  return this.renderIslandPlaceholder(name, definition, props, ctx);
@@ -104,9 +102,6 @@ export class StaticHtmlRenderer {
104
102
  // Template-based components are re-rendered by SPA, so their children don't need island markers
105
103
  const hasTemplate = !!definition.template;
106
104
  const childCtx = hasTemplate ? { ...ctx, insideTemplate: true } : ctx;
107
- if (hasTemplate) {
108
- console.log(`[SSR] ${name} has template, setting insideTemplate=true for children`);
109
- }
110
105
  // Get component config from template or items
111
106
  if (definition.template) {
112
107
  // Get controller state for SSR
@@ -159,13 +159,11 @@ export class StaticHtmlRenderer {
159
159
  // If we're inside an island or template-based component, render children as static
160
160
  // (they will be re-rendered when the parent hydrates or when SPA takes over)
161
161
  if (ctx.insideIsland || ctx.insideTemplate) {
162
- console.log(`[SSR] ${name} rendered as static (inside ${ctx.insideIsland ? 'island' : 'template'})`);
163
162
  return this.renderStaticComponent(name, definition, props, ctx);
164
163
  }
165
164
 
166
165
  // Analyze the component
167
166
  const analysis = this.analyzer.analyze(name, definition);
168
- console.log(`[SSR] ${name} analyzed as: ${analysis.type}`);
169
167
 
170
168
  if (analysis.type === 'island') {
171
169
  // Render as island placeholder
@@ -196,9 +194,6 @@ export class StaticHtmlRenderer {
196
194
  // Template-based components are re-rendered by SPA, so their children don't need island markers
197
195
  const hasTemplate = !!definition.template;
198
196
  const childCtx = hasTemplate ? { ...ctx, insideTemplate: true } : ctx;
199
- if (hasTemplate) {
200
- console.log(`[SSR] ${name} has template, setting insideTemplate=true for children`);
201
- }
202
197
 
203
198
  // Get component config from template or items
204
199
  if (definition.template) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ezfw-core",
3
- "version": "1.0.80",
3
+ "version": "1.0.82",
4
4
  "description": "Ez Framework - A declarative component framework for building modern web applications",
5
5
  "type": "module",
6
6
  "main": "./core/ez.ts",