@mohamedatia/fly-design-system 2.14.0 → 2.15.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.
@@ -113,6 +113,17 @@ const FLYOS_LAUNCH_EVENT = 'flyos:launch';
113
113
  * Subsequent re-launches into the already-mounted remote arrive via the event.
114
114
  */
115
115
  const FlyosPendingLaunchesGlobalKey = '__FLYOS_PENDING_LAUNCHES__';
116
+ /** Name of the window CustomEvent a remote dispatches when its route changes. */
117
+ const FLYOS_REMOTE_ROUTE_EVENT = 'flyos:remote-route';
118
+ /**
119
+ * `globalThis` flag set by the shell when it owns the address bar + history for
120
+ * ALL windows (os-core AND remotes) via `ShellHistoryService`. When set, a
121
+ * remote's `FlyRemoteRouter` defers history to the shell (dispatching
122
+ * {@link FLYOS_REMOTE_ROUTE_EVENT} instead of calling `history.pushState`) and
123
+ * stops handling its own `popstate` (the shell replays routes via
124
+ * {@link FLYOS_LAUNCH_EVENT}). Absent ⇒ legacy self-managed behaviour.
125
+ */
126
+ const FlyosShellOwnsHistoryGlobalKey = '__FLYOS_SHELL_OWNS_HISTORY__';
116
127
  /**
117
128
  * Per-window injection token carrying the active <see cref="WindowHelpHint"/>
118
129
  * as a writable signal. The shell creates one writable signal per window
@@ -798,6 +809,17 @@ class FlyRemoteRouter {
798
809
  isEmbedded = this.windowData != null
799
810
  || (typeof globalThis !== 'undefined'
800
811
  && globalThis.__FLYOS_SHELL__ === true);
812
+ /**
813
+ * True when a new shell owns the browser address bar + history for every
814
+ * window (it set {@link FlyosShellOwnsHistoryGlobalKey}). In that mode this
815
+ * router defers history to the shell: it dispatches {@link FLYOS_REMOTE_ROUTE_EVENT}
816
+ * instead of `pushState`, and does not handle its own `popstate` (the shell
817
+ * replays routes via `FLYOS_LAUNCH_EVENT`). Absent ⇒ legacy self-managed mode.
818
+ */
819
+ get shellOwnsHistory() {
820
+ return (typeof globalThis !== 'undefined' &&
821
+ globalThis[FlyosShellOwnsHistoryGlobalKey] === true);
822
+ }
801
823
  _url = signal('/', ...(ngDevMode ? [{ debugName: "_url" }] : /* istanbul ignore next */ []));
802
824
  /**
803
825
  * Current logical URL of the remote — `/signals/abc` etc.
@@ -868,20 +890,26 @@ class FlyRemoteRouter {
868
890
  const rawPath = window.location.pathname || '/';
869
891
  const initialUrl = this._resolveEmbeddedInitialUrl(rawPath);
870
892
  this._url.set(initialUrl);
871
- // Listen for browser back/forward so segments() stays in sync with
872
- // history entries pushed by navigate() / navigateByUrl().
873
- const onPopState = (event) => {
874
- const state = event.state;
875
- // Prefer the URL we stashed in the history state; fall back to pathname.
876
- const url = state?.flyRemoteUrl ?? window.location.pathname ?? '/';
877
- this._url.set(url.startsWith('/') ? url : '/' + url);
878
- };
879
- window.addEventListener('popstate', onPopState);
880
- // Defensive cleanup the service is providedIn: 'root' so this fires
881
- // only when the whole Angular app is destroyed, but it keeps things tidy.
882
- this.destroyRef.onDestroy(() => {
883
- window.removeEventListener('popstate', onPopState);
884
- });
893
+ // When the shell owns history it replays our route on Back/Forward via
894
+ // FLYOS_LAUNCH_EVENT (the remote root re-applies it), so we must NOT also
895
+ // handle popstate the shell's entries carry no `flyRemoteUrl` and we'd
896
+ // clobber `_url` with the shell path. Only self-manage under a legacy shell.
897
+ if (!this.shellOwnsHistory) {
898
+ // Listen for browser back/forward so segments() stays in sync with
899
+ // history entries pushed by navigate() / navigateByUrl().
900
+ const onPopState = (event) => {
901
+ const state = event.state;
902
+ // Prefer the URL we stashed in the history state; fall back to pathname.
903
+ const url = state?.flyRemoteUrl ?? window.location.pathname ?? '/';
904
+ this._url.set(url.startsWith('/') ? url : '/' + url);
905
+ };
906
+ window.addEventListener('popstate', onPopState);
907
+ // Defensive cleanup — the service is providedIn: 'root' so this fires
908
+ // only when the whole Angular app is destroyed, but it keeps things tidy.
909
+ this.destroyRef.onDestroy(() => {
910
+ window.removeEventListener('popstate', onPopState);
911
+ });
912
+ }
885
913
  }
886
914
  }
887
915
  }
@@ -972,10 +1000,28 @@ class FlyRemoteRouter {
972
1000
  * the query string.
973
1001
  */
974
1002
  _pushEmbedded(url) {
1003
+ this._url.set(url);
1004
+ if (this.shellOwnsHistory && typeof window !== 'undefined') {
1005
+ // Single-writer mode: hand the route to the shell, which owns the address
1006
+ // bar + browser history for every window. The shell mirrors it to the
1007
+ // canonical `…/desktop?app=&route=` form and pushes one history entry.
1008
+ const appId = this.windowData?.appId;
1009
+ if (appId) {
1010
+ const detail = {
1011
+ appId,
1012
+ windowId: this.windowData?.id ?? null,
1013
+ url,
1014
+ };
1015
+ window.dispatchEvent(new CustomEvent(FLYOS_REMOTE_ROUTE_EVENT, { detail }));
1016
+ return;
1017
+ }
1018
+ // No appId reachable (WINDOW_DATA split across bundles) — fall through to
1019
+ // the legacy local history entry so Back/Forward still update segments().
1020
+ }
1021
+ // Legacy / fallback: self-managed history entry (older shell, or no appId).
975
1022
  if (typeof history !== 'undefined') {
976
1023
  history.pushState({ flyRemoteUrl: url }, '', this._buildEmbeddedHistoryUrl(url));
977
1024
  }
978
- this._url.set(url);
979
1025
  }
980
1026
  /**
981
1027
  * Build the browser-address-bar URL for an embedded navigation: the shell's
@@ -6498,5 +6544,5 @@ const AUDIENCE_ERROR_CODES = {
6498
6544
  * Generated bundle index. Do not edit.
6499
6545
  */
6500
6546
 
6501
- export { AGENT_DRAG_MIME, AGENT_PAYLOAD_VERSION, APP_LOOKUP, AUDIENCE_ERROR_CODES, AUDIENCE_LIMITS, AUDIENCE_PRESETS, AUDIENCE_TERM_KINDS, AgentActionBus, AgentActionUnsupportedDispatchError, AgentCommandRegistry, AgentDropRegistry, AgentFlightAnimator, AgentLookupRegistry, AgentPayloadOversizeError, AudienceBuilderComponent, AuthService, ContextMenuComponent, DEFAULT_AGENT_PAYLOAD_LIMITS, DEFAULT_FLY_THEME_MODE, DS_BASELINE_LOCALES, DialogResult, ENTITY_LINK_LAUNCHER, EntityLookupComponent, FLYOS_LAUNCH_EVENT, FLY_LOCALE_CATALOG, FLY_REMOTE_BASE_PATH, FLY_REMOTE_CONTEXT_EVENT, FLY_REMOTE_CONTEXT_STORE_KEY, FLY_REMOTE_ROUTES, FLY_THEME_MODE_IDS, FLY_WINDOW_HELP_HINT_EVENT, FlyAgentDraggableDirective, FlyBlockUiComponent, FlyFileUploadComponent, FlyImageUploadComponent, FlyMarkdownEditorComponent, FlyRemoteContextService, FlyRemoteRouter, FlyRemoteRouterOutletComponent, FlySecureSrcDirective, FlyThemeService, FlyWindowHelpService, FlyosPendingLaunchesGlobalKey, I18nService, LAUNCH_CONTEXT, MARKDOWN_TOOLBAR_PRESETS, MessageBoxButtons, MessageBoxComponent, MessageBoxIcon, MessageBoxService, MockAuthService, RTL_LOCALE_SET, SHARE_ORG_CHART_SYSTEM_KEY_APPS, SHARE_ORG_CHART_SYSTEM_KEY_DEFAULT, SHARE_PANEL_DEFAULT_FILE_LEVELS, SUPPORTED_AGENT_PAYLOAD_VERSIONS, SharePanelComponent, SourceAppResolver, StandaloneWindowManagerService, TranslatePipe, WINDOW_DATA, WINDOW_HELP_HINT, WindowManagerService, findLocaleByDialect, findLocaleByPrefix, isRtlLocale, isRtlLocaleEntry, loadRemoteStyles, matchFlyRoutePattern, normalizeFlyTheme, trimAgentPayload, trimAgentString, unloadRemoteStyles, utf8ByteLength, validateAgentPayload };
6547
+ export { AGENT_DRAG_MIME, AGENT_PAYLOAD_VERSION, APP_LOOKUP, AUDIENCE_ERROR_CODES, AUDIENCE_LIMITS, AUDIENCE_PRESETS, AUDIENCE_TERM_KINDS, AgentActionBus, AgentActionUnsupportedDispatchError, AgentCommandRegistry, AgentDropRegistry, AgentFlightAnimator, AgentLookupRegistry, AgentPayloadOversizeError, AudienceBuilderComponent, AuthService, ContextMenuComponent, DEFAULT_AGENT_PAYLOAD_LIMITS, DEFAULT_FLY_THEME_MODE, DS_BASELINE_LOCALES, DialogResult, ENTITY_LINK_LAUNCHER, EntityLookupComponent, FLYOS_LAUNCH_EVENT, FLYOS_REMOTE_ROUTE_EVENT, FLY_LOCALE_CATALOG, FLY_REMOTE_BASE_PATH, FLY_REMOTE_CONTEXT_EVENT, FLY_REMOTE_CONTEXT_STORE_KEY, FLY_REMOTE_ROUTES, FLY_THEME_MODE_IDS, FLY_WINDOW_HELP_HINT_EVENT, FlyAgentDraggableDirective, FlyBlockUiComponent, FlyFileUploadComponent, FlyImageUploadComponent, FlyMarkdownEditorComponent, FlyRemoteContextService, FlyRemoteRouter, FlyRemoteRouterOutletComponent, FlySecureSrcDirective, FlyThemeService, FlyWindowHelpService, FlyosPendingLaunchesGlobalKey, FlyosShellOwnsHistoryGlobalKey, I18nService, LAUNCH_CONTEXT, MARKDOWN_TOOLBAR_PRESETS, MessageBoxButtons, MessageBoxComponent, MessageBoxIcon, MessageBoxService, MockAuthService, RTL_LOCALE_SET, SHARE_ORG_CHART_SYSTEM_KEY_APPS, SHARE_ORG_CHART_SYSTEM_KEY_DEFAULT, SHARE_PANEL_DEFAULT_FILE_LEVELS, SUPPORTED_AGENT_PAYLOAD_VERSIONS, SharePanelComponent, SourceAppResolver, StandaloneWindowManagerService, TranslatePipe, WINDOW_DATA, WINDOW_HELP_HINT, WindowManagerService, findLocaleByDialect, findLocaleByPrefix, isRtlLocale, isRtlLocaleEntry, loadRemoteStyles, matchFlyRoutePattern, normalizeFlyTheme, trimAgentPayload, trimAgentString, unloadRemoteStyles, utf8ByteLength, validateAgentPayload };
6502
6548
  //# sourceMappingURL=mohamedatia-fly-design-system.mjs.map