aril 1.2.17 → 2.0.1-dev.0

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 (126) hide show
  1. package/boot/bridge/src/mfe-bridge.d.ts +42 -2
  2. package/boot/config/apps/index.d.ts +7 -1
  3. package/boot/config/apps/src/custom-reuse-outlet.component.d.ts +37 -0
  4. package/boot/config/apps/src/custom-route-reuse-strategy.class.d.ts +156 -0
  5. package/boot/config/apps/src/nav-link-context-menu.service.d.ts +33 -0
  6. package/boot/config/apps/src/nav-link.directive.d.ts +29 -0
  7. package/boot/config/apps/src/nav.service.d.ts +198 -0
  8. package/boot/config/apps/src/route-close.service.d.ts +9 -0
  9. package/boot/config/apps/src/safe-navigate.d.ts +17 -0
  10. package/boot/config/apps/src/tab-aware-url-serializer.d.ts +22 -0
  11. package/boot/config/plugins/src/getNgZone.d.ts +9 -1
  12. package/boot/mfe/src/app.component.d.ts +15 -4
  13. package/boot/mfe/src/isolated-location-strategy.d.ts +57 -0
  14. package/esm2022/boot/bridge/src/mfe-bridge.mjs +36 -5
  15. package/esm2022/boot/config/api/src/api.service.mjs +12 -3
  16. package/esm2022/boot/config/apps/index.mjs +8 -2
  17. package/esm2022/boot/config/apps/src/apps.service.mjs +14 -6
  18. package/esm2022/boot/config/apps/src/custom-reuse-outlet.component.mjs +207 -0
  19. package/esm2022/boot/config/apps/src/custom-route-reuse-strategy.class.mjs +540 -0
  20. package/esm2022/boot/config/apps/src/nav-link-context-menu.service.mjs +105 -0
  21. package/esm2022/boot/config/apps/src/nav-link.directive.mjs +45 -0
  22. package/esm2022/boot/config/apps/src/nav.service.mjs +675 -0
  23. package/esm2022/boot/config/apps/src/route-close.service.mjs +19 -0
  24. package/esm2022/boot/config/apps/src/safe-navigate.mjs +50 -0
  25. package/esm2022/boot/config/apps/src/tab-aware-url-serializer.mjs +50 -0
  26. package/esm2022/boot/config/plugins/src/getNgZone.mjs +13 -5
  27. package/esm2022/boot/host/src/app.component.mjs +1 -2
  28. package/esm2022/boot/host/src/bootstrap.mjs +22 -7
  29. package/esm2022/boot/mfe/src/app.component.mjs +143 -39
  30. package/esm2022/boot/mfe/src/bootstrap.mjs +197 -20
  31. package/esm2022/boot/mfe/src/isolated-location-strategy.mjs +142 -0
  32. package/esm2022/keycloak/src/auth.interceptor.mjs +17 -2
  33. package/esm2022/provider/src/prodiveHost.mjs +3 -5
  34. package/esm2022/provider/src/prodiveHostRouter.mjs +88 -9
  35. package/esm2022/theme/layout/app/expandableMenu/expandable-menu.component.mjs +81 -19
  36. package/esm2022/theme/layout/app/favorite-pages/favorite-pages-sidebar.component.mjs +6 -4
  37. package/esm2022/theme/layout/app/general-search/general-search.component.mjs +4 -4
  38. package/esm2022/theme/layout/app/history/history-sidebar.component.mjs +6 -4
  39. package/esm2022/theme/layout/app/layout/app.layout.component.mjs +422 -20
  40. package/esm2022/theme/layout/app/layout/mfe.layout.component.mjs +24 -35
  41. package/esm2022/theme/layout/app/site-map/site-map-sidebar.component.mjs +6 -4
  42. package/esm2022/theme/layout/app/static-sidebar/static-sidebar.component.mjs +85 -27
  43. package/esm2022/theme/layout/app/topbar/app.topbar.component.mjs +3 -3
  44. package/esm2022/theme/layout/service/breadcrumb-publisher.service.mjs +86 -0
  45. package/esm2022/theme/layout/service/tab-session.service.mjs +126 -0
  46. package/esm2022/ui/table/src/table.component.mjs +10 -10
  47. package/esm2022/ui-business/ref-value/src/ref-value.component.mjs +15 -7
  48. package/esm2022/util/sync-active-tab-route/src/sync-active-tab-route.directive.mjs +29 -9
  49. package/fesm2022/aril-app.component-s14ruALV.mjs +183 -0
  50. package/fesm2022/aril-app.component-s14ruALV.mjs.map +1 -0
  51. package/fesm2022/aril-boot-bridge.mjs +35 -4
  52. package/fesm2022/aril-boot-bridge.mjs.map +1 -1
  53. package/fesm2022/aril-boot-config-api.mjs +11 -2
  54. package/fesm2022/aril-boot-config-api.mjs.map +1 -1
  55. package/fesm2022/aril-boot-config-apps.mjs +1678 -10
  56. package/fesm2022/aril-boot-config-apps.mjs.map +1 -1
  57. package/fesm2022/aril-boot-config-plugins.mjs +12 -4
  58. package/fesm2022/aril-boot-config-plugins.mjs.map +1 -1
  59. package/fesm2022/aril-boot-host.mjs +21 -7
  60. package/fesm2022/aril-boot-host.mjs.map +1 -1
  61. package/fesm2022/aril-boot-mfe-app.component-a34GeuUv.mjs +183 -0
  62. package/fesm2022/aril-boot-mfe-app.component-a34GeuUv.mjs.map +1 -0
  63. package/fesm2022/aril-boot-mfe-aril-boot-mfe-KFO_X7yR.mjs +631 -0
  64. package/fesm2022/aril-boot-mfe-aril-boot-mfe-KFO_X7yR.mjs.map +1 -0
  65. package/fesm2022/aril-boot-mfe.mjs +5 -3
  66. package/fesm2022/aril-boot-mfe.mjs.map +1 -1
  67. package/fesm2022/aril-keycloak.mjs +16 -1
  68. package/fesm2022/aril-keycloak.mjs.map +1 -1
  69. package/fesm2022/aril-provider.mjs +90 -12
  70. package/fesm2022/aril-provider.mjs.map +1 -1
  71. package/fesm2022/aril-theme-layout.mjs +2630 -2017
  72. package/fesm2022/aril-theme-layout.mjs.map +1 -1
  73. package/fesm2022/aril-ui-business-ref-value.mjs +14 -6
  74. package/fesm2022/aril-ui-business-ref-value.mjs.map +1 -1
  75. package/fesm2022/aril-ui-table.mjs +9 -9
  76. package/fesm2022/aril-ui-table.mjs.map +1 -1
  77. package/fesm2022/aril-util-sync-active-tab-route.mjs +28 -8
  78. package/fesm2022/aril-util-sync-active-tab-route.mjs.map +1 -1
  79. package/fesm2022/aril.mjs +354 -25
  80. package/fesm2022/aril.mjs.map +1 -1
  81. package/keycloak/src/auth.interceptor.d.ts +7 -0
  82. package/package.json +188 -188
  83. package/provider/src/prodiveHost.d.ts +1 -0
  84. package/theme/layout/app/expandableMenu/expandable-menu.component.d.ts +21 -4
  85. package/theme/layout/app/expandableMenu/expandable-menu.component.html +19 -5
  86. package/theme/layout/app/expandableMenu/expandable-menu.component.ts +69 -9
  87. package/theme/layout/app/favorite-pages/favorite-pages-sidebar.component.html +1 -0
  88. package/theme/layout/app/favorite-pages/favorite-pages-sidebar.component.ts +3 -1
  89. package/theme/layout/app/general-search/general-search.component.html +2 -1
  90. package/theme/layout/app/general-search/general-search.component.ts +2 -2
  91. package/theme/layout/app/history/history-sidebar.component.html +3 -1
  92. package/theme/layout/app/history/history-sidebar.component.ts +3 -1
  93. package/theme/layout/app/layout/app.layout.component.d.ts +105 -5
  94. package/theme/layout/app/layout/app.layout.component.html +102 -1
  95. package/theme/layout/app/layout/app.layout.component.scss +372 -0
  96. package/theme/layout/app/layout/app.layout.component.ts +452 -13
  97. package/theme/layout/app/layout/mfe.layout.component.d.ts +7 -5
  98. package/theme/layout/app/layout/mfe.layout.component.ts +13 -39
  99. package/theme/layout/app/site-map/site-map-sidebar.component.html +1 -0
  100. package/theme/layout/app/site-map/site-map-sidebar.component.ts +3 -1
  101. package/theme/layout/app/static-sidebar/static-sidebar.component.d.ts +26 -5
  102. package/theme/layout/app/static-sidebar/static-sidebar.component.html +11 -5
  103. package/theme/layout/app/static-sidebar/static-sidebar.component.ts +68 -13
  104. package/theme/layout/app/topbar/app.topbar.component.html +0 -1
  105. package/theme/layout/app/topbar/app.topbar.component.scss +1 -1
  106. package/theme/layout/service/breadcrumb-publisher.service.d.ts +24 -0
  107. package/theme/layout/service/breadcrumb-publisher.service.ts +95 -0
  108. package/theme/layout/service/tab-session.service.d.ts +52 -0
  109. package/theme/layout/service/tab-session.service.ts +138 -0
  110. package/theme/styles/layout/_breadcrumb.scss +95 -0
  111. package/theme/styles/layout/_content.scss +2 -2
  112. package/ui/table/src/table.component.d.ts +2 -2
  113. package/ui-business/ref-value/src/ref-value.component.d.ts +4 -2
  114. package/util/sync-active-tab-route/src/sync-active-tab-route.directive.d.ts +15 -2
  115. package/boot/config/apps/src/reuse-strategy.d.ts +0 -4
  116. package/esm2022/boot/config/apps/src/reuse-strategy.mjs +0 -9
  117. package/esm2022/theme/layout/app/breadcrumb/app.breadcrumb.component.mjs +0 -107
  118. package/fesm2022/aril-app.component-wxP3y8dg.mjs +0 -81
  119. package/fesm2022/aril-app.component-wxP3y8dg.mjs.map +0 -1
  120. package/fesm2022/aril-boot-mfe-app.component-7IjAmjz0.mjs +0 -80
  121. package/fesm2022/aril-boot-mfe-app.component-7IjAmjz0.mjs.map +0 -1
  122. package/fesm2022/aril-boot-mfe-aril-boot-mfe-KXDpUyv7.mjs +0 -315
  123. package/fesm2022/aril-boot-mfe-aril-boot-mfe-KXDpUyv7.mjs.map +0 -1
  124. package/theme/layout/app/breadcrumb/app.breadcrumb.component.d.ts +0 -25
  125. package/theme/layout/app/breadcrumb/app.breadcrumb.component.html +0 -8
  126. package/theme/layout/app/breadcrumb/app.breadcrumb.component.ts +0 -127
package/fesm2022/aril.mjs CHANGED
@@ -1,20 +1,23 @@
1
+ import { Location, LocationStrategy } from '@angular/common';
1
2
  import { HttpClient } from '@angular/common/http';
2
3
  import * as i0 from '@angular/core';
3
- import { inject, NgZone, Component, APP_INITIALIZER, importProvidersFrom } from '@angular/core';
4
+ import { inject, NgZone, Component, APP_INITIALIZER, Injectable, importProvidersFrom, ɵINJECTOR_SCOPE as _INJECTOR_SCOPE, ApplicationRef, createEnvironmentInjector, isDevMode, createComponent } from '@angular/core';
4
5
  import { bootstrapApplication, createApplication } from '@angular/platform-browser';
5
- import { provideRouter, withComponentInputBinding, withHashLocation, withViewTransitions, withRouterConfig, RouteReuseStrategy, Router } from '@angular/router';
6
+ import { provideRouter, withComponentInputBinding, withHashLocation, withRouterConfig, RouteReuseStrategy, UrlSerializer, Router } from '@angular/router';
6
7
  import { KeycloakService } from 'keycloak-angular';
7
8
  import { createBaseAppConfig, HOST_I18N_FOLDER } from 'aril/boot/base';
8
9
  import * as i3 from 'aril/boot/bridge';
9
10
  import { bridge } from 'aril/boot/bridge';
10
11
  import { loadApiConfigs, loadInitData, setApiConfigOnMFEMode } from 'aril/boot/config/api';
11
- import { ArilReuseStrategy, MicroAppService } from 'aril/boot/config/apps';
12
+ import { CustomRouteReuseStrategy, TabAwareUrlSerializer, MicroAppService } from 'aril/boot/config/apps';
12
13
  import { loadPlugins, getNgZone } from 'aril/boot/config/plugins';
13
14
  import { i18nFolderName } from 'aril/i18n';
14
15
  import * as i1 from 'aril/theme/layout';
15
16
  import { AppLayoutComponent } from 'aril/theme/layout';
16
17
  import * as i2 from 'aril/util/pub-sub';
17
- import { createCustomElement } from '@angular/elements';
18
+ import { PubSubService } from 'aril/util/pub-sub';
19
+ import { PrimeNGConfig, MessageService, ConfirmationService } from 'primeng/api';
20
+ import { TranslocoService } from '@ngneat/transloco';
18
21
  import { MonacoEditorModule, NGX_MONACO_EDITOR_CONFIG } from 'ngx-monaco-editor-v2';
19
22
  import { provideHost } from 'aril/provider';
20
23
 
@@ -25,7 +28,6 @@ class AppComponent {
25
28
  this.bridgeSvc = bridgeSvc;
26
29
  this.bridgeSvc.mirrorToWindow();
27
30
  this.bridgeSvc.activeHost.set(appName$1);
28
- this.bridgeSvc.isHostMode.set(true);
29
31
  this.bridgeSvc.hostNgZone = inject(NgZone);
30
32
  this.pubSubService.subscribe('menuModeChanged', (data) => {
31
33
  const menuMode = data?.custom;
@@ -67,13 +69,27 @@ const boot$1 = (_appName, routes) => {
67
69
  const appConfig = {
68
70
  providers: [
69
71
  createBaseAppConfig({ i18nFolder: HOST_I18N_FOLDER }),
70
- provideRouter(routes, withComponentInputBinding(), withHashLocation(), withViewTransitions(), withRouterConfig({ onSameUrlNavigation: 'reload' })),
71
- { provide: RouteReuseStrategy, useClass: ArilReuseStrategy },
72
+ provideRouter(routes, withComponentInputBinding(), withHashLocation(), withRouterConfig({ onSameUrlNavigation: 'reload' })),
73
+ // `useExisting`: `CustomRouteReuseStrategy` `providedIn: 'root'` olduğu için root injector'da
74
+ // zaten bir instance var. Router'a aynı instance'ı bağlamak ileride class'a doğrudan
75
+ // erişmek isteyen tüketiciler (örn. test hook'ları, debug paneli) için tek-instance
76
+ // garantisi sağlar.
77
+ {
78
+ provide: RouteReuseStrategy,
79
+ useExisting: CustomRouteReuseStrategy
80
+ },
81
+ // `_tab` query param'ı address bar'dan strip eder; Router internal `queryParams`'ı korur.
82
+ {
83
+ provide: UrlSerializer,
84
+ useExisting: TabAwareUrlSerializer
85
+ },
72
86
  {
73
87
  provide: APP_INITIALIZER,
74
- useFactory: (httpClient, keycloak, router, folderName, microAppService) => {
88
+ useFactory: (httpClient, keycloak, router, folderName, microAppService, location) => {
75
89
  if (router)
76
90
  bridge.hostRouter = router;
91
+ if (location)
92
+ bridge.hostLocation = location;
77
93
  const runLoadApiConfigs = loadApiConfigs(httpClient, keycloak, folderName, microAppService);
78
94
  const runLoadInitData = loadInitData(httpClient);
79
95
  const runLoadPlugins = loadPlugins();
@@ -84,7 +100,7 @@ const boot$1 = (_appName, routes) => {
84
100
  };
85
101
  },
86
102
  multi: true,
87
- deps: [HttpClient, KeycloakService, Router, i18nFolderName, MicroAppService]
103
+ deps: [HttpClient, KeycloakService, Router, i18nFolderName, MicroAppService, Location]
88
104
  }
89
105
  ]
90
106
  };
@@ -92,10 +108,149 @@ const boot$1 = (_appName, routes) => {
92
108
  };
93
109
 
94
110
  const appComponentLoader = async () => {
95
- const { AppComponent } = await import('./aril-app.component-wxP3y8dg.mjs');
111
+ const { AppComponent } = await import('./aril-app.component-s14ruALV.mjs');
96
112
  return AppComponent;
97
113
  };
98
114
 
115
+ /**
116
+ * Host modda her MFE Application'ı için kullanılan custom `LocationStrategy`. Browser
117
+ * URL'ine (`window.location.hash`) HİÇ YAZMAZ; tüm path/state internal alanlarda tutulur.
118
+ *
119
+ * Neden? Host modda host Router yegane URL kontrolcüsüdür. Eğer MFE Router da
120
+ * `HashLocationStrategy` kullansaydı, MFE içindeki bir `routerLink` tıklaması browser hash'ını
121
+ * değiştirir → `HashLocationStrategy` host Router'ı OTOMATİK tetikler → host Router'a
122
+ * tabsız (state'siz) navigation gelir → Strategy yanlış componentRef yaratır, tab
123
+ * izolasyonu bozulur. Bu otomatik sync'i kırmak için MFE Router'ın LocationStrategy'sini
124
+ * isolate ediyoruz: MFE içi navigation MFE Router'ın internal state'inde kalır, browser'a
125
+ * sızmaz, host'a istemsiz event göndermez.
126
+ *
127
+ * ## Tab içi history stack
128
+ * Browser back/forward butonu yerine MFE içinde **tab-içi history stack** çalışır:
129
+ * `pushState` her yeni navigation'da `backStack`'e mevcut konumu iter, `forwardStack`'i
130
+ * temizler; `back()` ve `forward()` stack'ler arasında değiş tokuş yapıp `popstate` event'i
131
+ * emit eder — Angular `Location` service bunu Router'a iletir, Router popstate-driven
132
+ * navigation cycle başlatır. Sonuçta kullanıcı **detay → liste** gibi MFE içi geri dönüşleri
133
+ * browser back butonuyla yapabilir, ama bu navigation **host Router'a yansımaz** → tab
134
+ * izolasyonu korunur, "geri" başka tab'a atlatmaz.
135
+ */
136
+ class IsolatedLocationStrategy extends LocationStrategy {
137
+ /**
138
+ * Stack boyutu üst limiti — browser default'una (50 entry) yakın. Aşırı uzun
139
+ * session'larda memory'i sınırlı tutar; sınır aşıldığında en eski entry düşürülür.
140
+ */
141
+ static { this.MAX_STACK_SIZE = 50; }
142
+ constructor() {
143
+ super();
144
+ this.internalPath = '/';
145
+ this.internalState = null;
146
+ /** Geri gidilebilecek path/state çiftleri (LIFO). */
147
+ this.backStack = [];
148
+ /** İleri gidilebilecek path/state çiftleri (`back()` ile pop edilen entry'ler). */
149
+ this.forwardStack = [];
150
+ this.popStateHandlers = [];
151
+ /**
152
+ * `back/forward` sonrası Router'ın navigation cycle'ı sırasında çağrılabilen
153
+ * `pushState`'i `backStack`'e tekrar itmemek için flag. `replaceState` zaten stack'i
154
+ * değiştirmiyor — bu flag yalnızca pushState yolunu koruyor.
155
+ */
156
+ this.isNavigatingViaHistory = false;
157
+ console.log('[IsolatedLocationStrategy] CONSTRUCTED — host modda MFE Router için aktif');
158
+ }
159
+ path(_includeHash) {
160
+ return this.internalPath;
161
+ }
162
+ prepareExternalUrl(internal) {
163
+ // Host `HashLocationStrategy` (withHashLocation) kullanıyor → MFE routerLink'lerinin
164
+ // ürettiği `<a href>` (hover/kopyalama/orta-tık/yeni sekme) host ile uyumlu `#/...`
165
+ // formatında olmalı. Sol-tık navigation'ı zaten host Router proxy üzerinden gider
166
+ // (href kullanılmaz); bu override yalnız görünen/kopyalanan URL'i düzeltir.
167
+ return internal.length > 0 ? '#' + internal : internal;
168
+ }
169
+ pushState(state, _title, url, queryParams) {
170
+ const fullPath = url + (queryParams ? `?${queryParams}` : '');
171
+ console.log(`[IsolatedLocationStrategy] pushState url="${url}" qs="${queryParams}" viaHistory=${this.isNavigatingViaHistory}`);
172
+ if (!this.isNavigatingViaHistory) {
173
+ // Yeni navigation → mevcut konumu backStack'e it, forwardStack'i temizle
174
+ // (browser semantiği: yeni sayfaya gidince forward history düşer).
175
+ if (this.internalPath !== fullPath) {
176
+ this.backStack.push({ path: this.internalPath, state: this.internalState });
177
+ if (this.backStack.length > IsolatedLocationStrategy.MAX_STACK_SIZE) {
178
+ this.backStack.shift();
179
+ }
180
+ this.forwardStack = [];
181
+ }
182
+ }
183
+ this.internalPath = fullPath;
184
+ this.internalState = state;
185
+ }
186
+ replaceState(state, _title, url, queryParams) {
187
+ console.log(`[IsolatedLocationStrategy] replaceState url="${url}" qs="${queryParams}"`);
188
+ this.internalPath = url + (queryParams ? `?${queryParams}` : '');
189
+ this.internalState = state;
190
+ }
191
+ back() {
192
+ const prev = this.backStack.pop();
193
+ if (!prev)
194
+ return;
195
+ this.forwardStack.push({ path: this.internalPath, state: this.internalState });
196
+ this.internalPath = prev.path;
197
+ this.internalState = prev.state;
198
+ this.emitPopState();
199
+ }
200
+ forward() {
201
+ const next = this.forwardStack.pop();
202
+ if (!next)
203
+ return;
204
+ this.backStack.push({ path: this.internalPath, state: this.internalState });
205
+ this.internalPath = next.path;
206
+ this.internalState = next.state;
207
+ this.emitPopState();
208
+ }
209
+ historyGo(relativePosition) {
210
+ if (relativePosition < 0) {
211
+ const steps = -relativePosition;
212
+ for (let i = 0; i < steps && this.backStack.length; i++)
213
+ this.back();
214
+ }
215
+ else if (relativePosition > 0) {
216
+ for (let i = 0; i < relativePosition && this.forwardStack.length; i++)
217
+ this.forward();
218
+ }
219
+ }
220
+ onPopState(fn) {
221
+ this.popStateHandlers.push(fn);
222
+ }
223
+ emitPopState() {
224
+ this.isNavigatingViaHistory = true;
225
+ try {
226
+ const event = new PopStateEvent('popstate', { state: this.internalState });
227
+ for (const fn of this.popStateHandlers)
228
+ fn(event);
229
+ }
230
+ finally {
231
+ // Router'ın navigation cycle'ı async — popstate handler'ı navigation tetikledikten
232
+ // sonra cycle bittiğinde pushState/replaceState çağrılabilir. Microtask sınırı
233
+ // sync cycle'ı kapsar; daha güvenli istersek `queueMicrotask` yerine `setTimeout(0)`
234
+ // tercih edilebilir ama bu durumda araya gerçek user navigation girebilir. Microtask
235
+ // pratikte yeterli: Router popstate cycle'ında pushState değil replaceState çağırır.
236
+ queueMicrotask(() => {
237
+ this.isNavigatingViaHistory = false;
238
+ });
239
+ }
240
+ }
241
+ getBaseHref() {
242
+ return '/';
243
+ }
244
+ getState() {
245
+ return this.internalState;
246
+ }
247
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: IsolatedLocationStrategy, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
248
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: IsolatedLocationStrategy }); }
249
+ }
250
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: IsolatedLocationStrategy, decorators: [{
251
+ type: Injectable
252
+ }], ctorParameters: () => [] });
253
+
99
254
  const monacoConfig = {
100
255
  baseUrl: 'assets',
101
256
  defaultOptions: { scrollBeyondLastLine: false },
@@ -345,24 +500,35 @@ const monacoConfig = {
345
500
 
346
501
  var appName;
347
502
  var menuItems = [];
503
+ /**
504
+ * `boot` çağrılarının idempotent kalmasını sağlayan sync guard. Aynı remote için
505
+ * birden fazla paralel `boot('wdm', ...)` çağrısı geldiğinde, ilk `customElements.define`
506
+ * tamamlanmadan ikinci çağrı `customElements.get` guard'ını geçiyordu → her ikisi de
507
+ * define etmeye çalışıp `NotSupportedError: the name "app-wdm" has already been used`
508
+ * hatası fırlatılıyordu. Set ile sync mark ederek tek bir define cycle'ı garanti ediyoruz.
509
+ */
510
+ const bootedApps = new Set();
348
511
  const boot = (_appName, _routes, _menuItems) => {
349
- if (customElements.get(`app-${_appName}`))
512
+ if (bootedApps.has(_appName) || customElements.get(`app-${_appName}`))
350
513
  return;
514
+ bootedApps.add(_appName);
351
515
  appName = _appName;
352
516
  menuItems = _menuItems;
353
- const appBootConfig = {
517
+ /**
518
+ * **Paylaşılan base config** — remote başına TEK `createApplication`. Ağır servisler
519
+ * (HttpClient + interceptor chain, Keycloak, i18n/Transloco, Monaco, animations) burada
520
+ * yaşar; `providedIn` taşımayan explicit provider oldukları için tüm tab'ların child
521
+ * injector'larından parent olarak paylaşılır → RAM lineer büyümez. Router/Location/
522
+ * ReuseStrategy/UrlSerializer burada YOK; onlar tab başına izole child injector'da verilir.
523
+ */
524
+ const sharedBaseConfig = {
354
525
  providers: [
355
526
  createBaseAppConfig({ i18nFolder: _appName }),
356
- provideHost(appName),
357
- provideRouter(_routes, withComponentInputBinding(), withHashLocation(), withViewTransitions(), withRouterConfig({ onSameUrlNavigation: 'reload' })),
358
- { provide: RouteReuseStrategy, useClass: ArilReuseStrategy },
527
+ provideHost(_appName),
359
528
  getNgZone(),
360
529
  {
361
530
  provide: APP_INITIALIZER,
362
531
  useFactory: (httpClient, keycloak, folderName) => {
363
- if (!bridge.isHostMode()) {
364
- return () => Promise.resolve();
365
- }
366
532
  const runApiInit = setApiConfigOnMFEMode(httpClient, keycloak, folderName);
367
533
  const runLoadPlugins = loadPlugins();
368
534
  return async () => {
@@ -377,17 +543,180 @@ const boot = (_appName, _routes, _menuItems) => {
377
543
  { provide: NGX_MONACO_EDITOR_CONFIG, useValue: monacoConfig }
378
544
  ]
379
545
  };
380
- createApplication(appBootConfig).then((appRef) => {
381
- appComponentLoader().then((AppComponent) => {
382
- const app = createCustomElement(AppComponent, { injector: appRef.injector });
383
- customElements.define(`app-${appName}`, app);
384
- });
385
- });
546
+ /**
547
+ * Remote başına TEK paylaşılan `ApplicationRef` — closure-scope. İlk `<app-${appName}>`
548
+ * element'i `createApplication(sharedBaseConfig)` çağırır, sonraki tüm element'ler aynı
549
+ * promise'ı bekler (duplicate Application yaratımı imkânsız). Her element kendi child
550
+ * injector + `createComponent` ile kendi `AppComponent` view'ını yaratıp shared app'e
551
+ * `attachView` ile bağlar. Shared app uzun ömürlüdür (tab'lar kapansa da destroy edilmez).
552
+ *
553
+ * `childProviders`'taki `TranslocoService` factory'si bu referansı kullandığı için
554
+ * `childProviders`'tan ÖNCE tanımlanır (forward TDZ'yi önler).
555
+ */
556
+ let sharedAppRef = null;
557
+ let sharedAppPromise = null;
558
+ /**
559
+ * **Tab başına izole Router stack** — her `<app-${appName}>` kendi child
560
+ * `EnvironmentInjector`'ında bunları alır. `ɵINJECTOR_SCOPE: 'root'` child'ı 'root'
561
+ * scope yapar (Angular `R3Injector` ctor: `scopes.add('root')`); böylece `provideRouter`'ın
562
+ * inject ettiği `providedIn:'root'` Router servisleri — `Router`, `ChildrenOutletContexts`,
563
+ * `Location`, `NavigationTransitions` vb. — child-LOCAL üretilir. Sonuç: her tab kendi
564
+ * Router + kendi `RouterOutlet` context'ine sahip olur → **1 Router : 1 outlet**.
565
+ *
566
+ * Neden gerekli: paylaşılan tek Application'da N `<router-outlet>` aynı tek
567
+ * `ChildrenOutletContexts`'e "primary" diye kaydolup birbirini eziyordu (`contexts.set`
568
+ * overwrite) → tab geçişi sonrası aynı tab içi navigasyon (list→detail) yanlış outlet'e
569
+ * render oluyordu. Child-injector izolasyonu bunu kökten çözer.
570
+ *
571
+ * **TranslocoService istisnası**: `'root'` scope onu da child-local yapardı; ama global
572
+ * (scope'suz) çeviriler shared app'in init akışında yüklendiğinden — `createComponent`
573
+ * `APP_INITIALIZER` çalıştırmaz — child-local service'in global cache'i boş kalıp ham key
574
+ * gösteriyordu. Tab başına ayrı dil senaryosu yok; service'i shared app'ten paylaştırıyoruz
575
+ * (global çeviri tek yerde yüklenir, tek translation cache → ek RAM kazancı). Scope çevirileri
576
+ * (`providei18nScope`) component-level sağlandığı için paylaşılan service'le de çalışır.
577
+ *
578
+ * NOT: `ɵINJECTOR_SCOPE` Angular private API'sidir; minor sürüm yükseltmelerinde davranışı
579
+ * doğrulanmalı (aşağıdaki POC izolasyon log'u bunun için bırakıldı).
580
+ */
581
+ const childProviders = [
582
+ { provide: _INJECTOR_SCOPE, useValue: 'root' },
583
+ provideRouter(_routes, withComponentInputBinding(), withRouterConfig({ onSameUrlNavigation: 'reload' })),
584
+ { provide: LocationStrategy, useClass: IsolatedLocationStrategy },
585
+ { provide: Location, useClass: Location },
586
+ { provide: RouteReuseStrategy, useExisting: CustomRouteReuseStrategy },
587
+ { provide: UrlSerializer, useExisting: TabAwareUrlSerializer },
588
+ { provide: TranslocoService, useFactory: () => sharedAppRef.injector.get(TranslocoService) },
589
+ // `ɵINJECTOR_SCOPE:'root'` yan etkisi: `ApplicationRef` de `providedIn:'root'` olduğu için
590
+ // child injector'da child-LOKAL (sahte) bir instance üretilirdi — bu instance NgZone'un
591
+ // tick döngüsüne bağlı DEĞİLDİR. Sonuç: bu appRef'e `attachView` edilen view'lar hiç change
592
+ // detection almaz. AppComponent'i biz açıkça `sharedAppRef.attachView` ile bağladığımız için
593
+ // çalışır; ama `inject(ApplicationRef)` yapan üçüncü taraf kod (PrimeNG `DialogService` →
594
+ // `this.appRef.attachView`) child-local sahte appRef'i alıp dialog'u ona bağlıyordu → dialog
595
+ // yaratılıyor ama `*ngIf="visible"` hiç render edilmiyordu (boş açılıyordu). Gerçek (tek,
596
+ // tick alan) `sharedAppRef`'e sabitliyoruz.
597
+ { provide: ApplicationRef, useFactory: () => sharedAppRef },
598
+ // Tarama (log15) ile saptanan, child-local olunca bozulan ek `providedIn:'root'` servisleri:
599
+ // • PubSubService — MFE'nin `breadcrumbUpdated` event'i host `history.service`'e ulaşmalı;
600
+ // child-local olunca MFE↔host event köprüsü kopuyordu.
601
+ // • PrimeNGConfig — dinamik dialog'lar shared root context'inde yaratıldığı için PrimeNG
602
+ // çevirileri (calendar/paginator vb.) ve `setTranslation` shared instance'tan okunmalı.
603
+ // (BreadcrumbService bilinçli olarak child-local bırakıldı: her tab kendi breadcrumb'ı.)
604
+ { provide: PubSubService, useFactory: () => sharedAppRef.injector.get(PubSubService) },
605
+ { provide: PrimeNGConfig, useFactory: () => sharedAppRef.injector.get(PrimeNGConfig) },
606
+ // Toast/confirm GLOBAL: tek shared MessageService/ConfirmationService. Aksi halde her tab
607
+ // kendi instance'ına sahip olur → host'tan tetiklenen toast MFE tab'ında (ya da tersi)
608
+ // görünmez. Shared instance ile tüm `<p-toast key="toast-root">` container'ları aynı kuyruğu dinler.
609
+ { provide: MessageService, useFactory: () => sharedAppRef.injector.get(MessageService) },
610
+ { provide: ConfirmationService, useFactory: () => sharedAppRef.injector.get(ConfirmationService) }
611
+ ];
612
+ const appComponentPromise = appComponentLoader();
613
+ class MFEAppElement extends HTMLElement {
614
+ constructor() {
615
+ super(...arguments);
616
+ this.childInjector = null;
617
+ this.compRef = null;
618
+ this.isBootstrapping = false;
619
+ this.destroyTimer = null;
620
+ }
621
+ async connectedCallback() {
622
+ // Strategy hidden container ↔ view arası taşımalarda re-bootstrap'ı önle —
623
+ // view zaten yaratıldıysa skip. destroyTimer pending ise iptal et.
624
+ if (this.compRef || this.isBootstrapping) {
625
+ if (this.destroyTimer) {
626
+ clearTimeout(this.destroyTimer);
627
+ this.destroyTimer = null;
628
+ }
629
+ return;
630
+ }
631
+ this.isBootstrapping = true;
632
+ try {
633
+ // Paylaşılan Application — ilk çağıran yaratır, diğerleri aynı promise'ı bekler.
634
+ if (!sharedAppPromise) {
635
+ sharedAppPromise = createApplication(sharedBaseConfig);
636
+ }
637
+ const [appRef, AppComponent] = await Promise.all([sharedAppPromise, appComponentPromise]);
638
+ sharedAppRef = appRef;
639
+ // Bu tab için izole Router stack'i barındıran child injector.
640
+ const tabId = this.getAttribute('aril-tab-id') ?? '';
641
+ this.childInjector = createEnvironmentInjector(childProviders, appRef.injector, `mfe:${_appName}:${tabId || 'pending'}`);
642
+ // [Hibrit izolasyon guard — kalıcı] `ɵINJECTOR_SCOPE:'root'` ile child injector'ın
643
+ // KENDİ Router + ChildrenOutletContexts'i olması, tab izolasyonunun temelidir
644
+ // ("1 Router : 1 outlet"). Bu private API Angular upgrade'inde davranış değiştirirse
645
+ // burada erken yakalanır; aksi halde "1 Router : N outlet" bug'ı sessizce geri döner.
646
+ if (isDevMode() && this.childInjector.get(Router) === appRef.injector.get(Router)) {
647
+ console.error(`[boot:${_appName}] HİBRİT İZOLASYON BOZULDU: child Router shared root ile aynı instance! ` +
648
+ `ɵINJECTOR_SCOPE davranışı değişmiş olabilir (Angular upgrade?) — tab izolasyonu çalışmaz.`);
649
+ }
650
+ // AppComponent'i child injector context'inde yarat → inject(Router)/LocationStrategy
651
+ // child-local; inject(MfeBridge)/HttpClient/Keycloak/TranslocoService vb. parent'tan
652
+ // paylaşımlı. `attachView` shared app'in change detection döngüsüne bağlar. (`bootstrap`
653
+ // değil: APP_BOOTSTRAP_LISTENER çalışmaz, child Router'ın initial navigation'ını
654
+ // AppComponent host-Router sync'i `safeNavigate` ile yapıyor.)
655
+ this.compRef = createComponent(AppComponent, {
656
+ environmentInjector: this.childInjector,
657
+ hostElement: this
658
+ });
659
+ appRef.attachView(this.compRef.hostView);
660
+ // Başarılı boot: guard artık `compRef` üzerinden çalışır → `isBootstrapping`'i bırak.
661
+ // (await sırasında disconnect olup hata oluşmazsa flag takılı kalmasın; aksi halde
662
+ // reconnect'te guard erken return edip tab'ı kalıcı boş bırakır.)
663
+ this.isBootstrapping = false;
664
+ }
665
+ catch (err) {
666
+ console.error(`[boot:${_appName}] application bootstrap hatası:`, err);
667
+ this.isBootstrapping = false;
668
+ // sharedApp henüz set edilmediyse (createApplication başarısız) promise'ı sıfırla ki
669
+ // sonraki tab retry edebilsin — aksi halde rejected promise closure'da kalıcı kalır ve
670
+ // remote sayfa yenilemeden bir daha boot edilemez. (createComponent hatasında
671
+ // sharedAppRef zaten set'tir; o durumda promise korunur, app yeniden yaratılmaz.)
672
+ if (!sharedAppRef)
673
+ sharedAppPromise = null;
674
+ }
675
+ }
676
+ disconnectedCallback() {
677
+ // Strategy hidden container ↔ view arası taşımalarda `removeChild` + `appendChild`
678
+ // ardışık olduğu için disconnectedCallback parent değişimiyle tetiklenir — element
679
+ // gerçekten destroy edilmiyor. `preserveWebComponentElement` öncesinde Strategy
680
+ // `__arilPreserveDuringDetach` flag'i set ediyor; o flag varsa view korunur.
681
+ const preserveFlag = this.__arilPreserveDuringDetach;
682
+ if (preserveFlag) {
683
+ return;
684
+ }
685
+ // Flag yok → gerçek destroy. Async re-connect ihtimaline karşı microtask sınırlı
686
+ // defansif gecikme; bir sonraki tick'te hâlâ disconnected mı diye son kontrol.
687
+ if (this.destroyTimer)
688
+ clearTimeout(this.destroyTimer);
689
+ this.destroyTimer = setTimeout(() => {
690
+ if (!this.isConnected && this.compRef) {
691
+ console.log(`[boot:${_appName}] gerçek destroy → view + child injector destroy`);
692
+ // Shared app'e ASLA dokunma; sadece bu tab'ın view'ını ve child injector'ını yık.
693
+ if (sharedAppRef)
694
+ sharedAppRef.detachView(this.compRef.hostView);
695
+ this.compRef.destroy();
696
+ this.childInjector?.destroy();
697
+ this.compRef = null;
698
+ this.childInjector = null;
699
+ this.isBootstrapping = false;
700
+ }
701
+ this.destroyTimer = null;
702
+ }, 0);
703
+ }
704
+ }
705
+ try {
706
+ customElements.define(`app-${appName}`, MFEAppElement);
707
+ }
708
+ catch (e) {
709
+ if (e instanceof DOMException && e.name === 'NotSupportedError') {
710
+ console.warn(`[boot:${appName}] custom element zaten tanımlı, define atlandı`);
711
+ return;
712
+ }
713
+ throw e;
714
+ }
386
715
  };
387
716
 
388
717
  /**
389
718
  * Generated bundle index. Do not edit.
390
719
  */
391
720
 
392
- export { appName as a, menuItems as m };
721
+ export { appName as a };
393
722
  //# sourceMappingURL=aril.mjs.map