@gooddata/sdk-ui-pluggable-host 11.62.0-alpha.2 → 11.62.0-alpha.3

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.
@@ -9,6 +9,18 @@
9
9
  }
10
10
 
11
11
  &__error {
12
+ min-height: 100vh;
13
+ box-sizing: border-box;
14
+ display: flex;
15
+ flex-direction: column;
16
+ align-items: center;
17
+ justify-content: center;
12
18
  padding: 2rem;
19
+ text-align: center;
13
20
  }
14
21
  }
22
+
23
+ // The app slot sits below the host header, so a viewport-high fallback would overflow it.
24
+ .gd-host-chrome__app-container > .gd-host-root__error {
25
+ min-height: 100%;
26
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"useRedirectTarget.d.ts","sourceRoot":"","sources":["../../src/components/useRedirectTarget.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAOlF,MAAM,MAAM,mBAAmB,GACzB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,QAAQ,CAAA;CAAE,GACnB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,gCAAgC,EAAE,EACxC,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GAChB,mBAAmB,CA6DrB"}
1
+ {"version":3,"file":"useRedirectTarget.d.ts","sourceRoot":"","sources":["../../src/components/useRedirectTarget.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAQlF,MAAM,MAAM,mBAAmB,GACzB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,QAAQ,CAAA;CAAE,GACnB;IAAE,KAAK,EAAE,UAAU,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAClC;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,gCAAgC,EAAE,EACxC,GAAG,EAAE,gBAAgB,EACrB,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,GAChB,mBAAmB,CAsErB"}
@@ -1,8 +1,10 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { useEffect, useState } from "react";
3
+ import { isNotAuthenticated } from "@gooddata/sdk-backend-spi";
3
4
  import { debugLog } from "../debug.js";
4
5
  import { AppNotFoundError, resolveRedirectTarget } from "../loader/redirectLogic.js";
5
6
  import { getBackend } from "../platformContext/backend.js";
7
+ import { afterNotAuthenticatedGrace } from "../platformContext/notAuthenticatedGrace.js";
6
8
  import { getWorkspaceAccess } from "../platformContext/workspaceAccess.js";
7
9
  /**
8
10
  * Resolves the redirect target for the current URL and permission context.
@@ -11,6 +13,7 @@ export function useRedirectTarget(apps, ctx, pathname, search) {
11
13
  const [redirectState, setRedirectState] = useState({ state: "loading" });
12
14
  useEffect(() => {
13
15
  let cancelled = false;
16
+ let cancelGrace;
14
17
  // Preserve "render" state during re-resolution so that HostUiContainer stays mounted
15
18
  // while the async redirect check runs. Other states (loading, error, not-found) reset to loading.
16
19
  setRedirectState((prev) => (prev.state === "render" ? prev : { state: "loading" }));
@@ -54,11 +57,17 @@ export function useRedirectTarget(apps, ctx, pathname, search) {
54
57
  else {
55
58
  const error = e instanceof Error ? e.message : "Unknown redirect error.";
56
59
  debugLog(`[host-app/redirect] useRedirectTarget: unexpected error → ${error}`);
60
+ // Stay "loading" while the backend redirects to login on a 401.
61
+ if (isNotAuthenticated(e)) {
62
+ cancelGrace = afterNotAuthenticatedGrace(() => setRedirectState({ state: "error", error }));
63
+ return;
64
+ }
57
65
  setRedirectState({ state: "error", error });
58
66
  }
59
67
  });
60
68
  return () => {
61
69
  cancelled = true;
70
+ cancelGrace?.();
62
71
  };
63
72
  }, [apps, pathname, search, ctx]);
64
73
  return redirectState;
@@ -23,6 +23,15 @@ export declare function registerAppStylesheetScope(appId: string, remoteEntryUrl
23
23
  * is resolved before an app renders inside it.
24
24
  */
25
25
  export declare function reserveHostStylesheetScope(remoteEntryUrl: string): void;
26
+ /**
27
+ * Declares that the remote at `remoteEntryUrl` serves its assets from `assetBaseUrl`, so
28
+ * stylesheet links under that base belong to whichever app owns the remote entry URL.
29
+ *
30
+ * Call order relative to `registerAppStylesheetScope` does not matter. Refused with a warning
31
+ * when the base is an origin root or covers the host UI module's scope, because it would then
32
+ * claim host stylesheets.
33
+ */
34
+ export declare function registerRemoteAssetBase(remoteEntryUrl: string, assetBaseUrl: string): void;
26
35
  /**
27
36
  * Re-enables all stylesheets attributed to the app. Safe to call before any of the
28
37
  * app's CSS exists and repeatedly.
@@ -1 +1 @@
1
- {"version":3,"file":"stylesheetRegistry.d.ts","sourceRoot":"","sources":["../../src/lib/stylesheetRegistry.ts"],"names":[],"mappings":"AAkJA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAiCtF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAQvE;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAQ9C"}
1
+ {"version":3,"file":"stylesheetRegistry.d.ts","sourceRoot":"","sources":["../../src/lib/stylesheetRegistry.ts"],"names":[],"mappings":"AA4JA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAiCtF;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAQvE;AAED;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,cAAc,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAkB1F;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM1D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAM5D;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAS9C"}
@@ -1,10 +1,14 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  const scopePrefixes = new Map();
3
3
  const reservedHostPrefixes = new Set();
4
+ const assetBaseAliases = new Map();
4
5
  const deactivatedApps = new Set();
5
6
  let linkLoadStates = new WeakMap();
6
7
  let retiredLinks = new WeakSet();
7
8
  let observer;
9
+ function withAliases(prefix) {
10
+ return [prefix, ...(assetBaseAliases.get(prefix) ?? [])];
11
+ }
8
12
  function deriveScopePrefix(remoteEntryUrl) {
9
13
  try {
10
14
  const url = new URL(remoteEntryUrl, document.baseURI);
@@ -21,9 +25,11 @@ function findOwnerOfHref(href) {
21
25
  let longestPrefixLength = -1;
22
26
  for (const [appId, prefixes] of scopePrefixes) {
23
27
  for (const prefix of prefixes) {
24
- if (href.startsWith(prefix) && prefix.length > longestPrefixLength) {
25
- owner = appId;
26
- longestPrefixLength = prefix.length;
28
+ for (const candidate of withAliases(prefix)) {
29
+ if (href.startsWith(candidate) && candidate.length > longestPrefixLength) {
30
+ owner = appId;
31
+ longestPrefixLength = candidate.length;
32
+ }
27
33
  }
28
34
  }
29
35
  }
@@ -32,7 +38,7 @@ function findOwnerOfHref(href) {
32
38
  // An app prefix above a reserved host prefix would claim the host's own links.
33
39
  function coversReservedHostScope(prefix) {
34
40
  for (const reserved of reservedHostPrefixes) {
35
- if (reserved.startsWith(prefix)) {
41
+ if (withAliases(reserved).some((candidate) => candidate.startsWith(prefix))) {
36
42
  return true;
37
43
  }
38
44
  }
@@ -171,6 +177,31 @@ export function reserveHostStylesheetScope(remoteEntryUrl) {
171
177
  reservedHostPrefixes.add(prefix);
172
178
  }
173
179
  }
180
+ /**
181
+ * Declares that the remote at `remoteEntryUrl` serves its assets from `assetBaseUrl`, so
182
+ * stylesheet links under that base belong to whichever app owns the remote entry URL.
183
+ *
184
+ * Call order relative to `registerAppStylesheetScope` does not matter. Refused with a warning
185
+ * when the base is an origin root or covers the host UI module's scope, because it would then
186
+ * claim host stylesheets.
187
+ */
188
+ export function registerRemoteAssetBase(remoteEntryUrl, assetBaseUrl) {
189
+ if (typeof document === "undefined") {
190
+ return;
191
+ }
192
+ const prefix = deriveScopePrefix(remoteEntryUrl);
193
+ const alias = deriveScopePrefix(assetBaseUrl.endsWith("/") ? assetBaseUrl : `${assetBaseUrl}/`);
194
+ if (!prefix || !alias || alias === prefix) {
195
+ return;
196
+ }
197
+ if (new URL(alias).pathname === "/" || coversReservedHostScope(alias)) {
198
+ console.warn(`[host-runtime/stylesheet-registry] Not tracking stylesheets under asset base "${assetBaseUrl}" of remote "${remoteEntryUrl}": the base would also cover host stylesheets.`);
199
+ return;
200
+ }
201
+ const aliases = assetBaseAliases.get(prefix) ?? new Set();
202
+ aliases.add(alias);
203
+ assetBaseAliases.set(prefix, aliases);
204
+ }
174
205
  /**
175
206
  * Re-enables all stylesheets attributed to the app. Safe to call before any of the
176
207
  * app's CSS exists and repeatedly.
@@ -199,6 +230,7 @@ export function deactivateAppStylesheets(appId) {
199
230
  export function resetStylesheetRegistry() {
200
231
  scopePrefixes.clear();
201
232
  reservedHostPrefixes.clear();
233
+ assetBaseAliases.clear();
202
234
  deactivatedApps.clear();
203
235
  linkLoadStates = new WeakMap();
204
236
  retiredLinks = new WeakSet();
@@ -42,7 +42,7 @@ export declare function evictRemoteEntryLoadCache(remoteInfo: {
42
42
  }): void;
43
43
  /**
44
44
  * Host-side Module Federation runtime plugin. Registered on the federation instance created
45
- * by the remote loader; both hooks work around behaviour of the MF runtime we cannot
45
+ * by the remote loader; its hooks work around behaviour of the MF runtime we cannot
46
46
  * configure any other way.
47
47
  */
48
48
  export declare function createHostFederationPlugin(): ModuleFederationRuntimePlugin;
@@ -1 +1 @@
1
- {"version":3,"file":"federationRuntimePlugin.d.ts","sourceRoot":"","sources":["../../src/loader/federationRuntimePlugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,oCAAoC,CAAC;AAK7E;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAU3F;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,6BAA6B,CAgB1E"}
1
+ {"version":3,"file":"federationRuntimePlugin.d.ts","sourceRoot":"","sources":["../../src/loader/federationRuntimePlugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAIhF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,uBAAuB,QAAS,CAAC;AAE9C;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,oCAAoC,CAAC;AAK7E;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAU3F;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,IAAI,6BAA6B,CA0B1E"}
@@ -1,4 +1,5 @@
1
1
  // (C) 2026 GoodData Corporation
2
+ import { registerRemoteAssetBase } from "../lib/stylesheetRegistry.js";
2
3
  /**
3
4
  * Timeout applied to every `<link rel="preload">` Module Federation creates.
4
5
  *
@@ -46,7 +47,7 @@ export function evictRemoteEntryLoadCache(remoteInfo) {
46
47
  }
47
48
  /**
48
49
  * Host-side Module Federation runtime plugin. Registered on the federation instance created
49
- * by the remote loader; both hooks work around behaviour of the MF runtime we cannot
50
+ * by the remote loader; its hooks work around behaviour of the MF runtime we cannot
50
51
  * configure any other way.
51
52
  */
52
53
  export function createHostFederationPlugin() {
@@ -62,5 +63,14 @@ export function createHostFederationPlugin() {
62
63
  evictRemoteEntryLoadCache(remoteInfo);
63
64
  }
64
65
  },
66
+ // A manifest publicPath (e.g. the CDN base) moves the remote's CSS off its entry URL.
67
+ // The stylesheet registry must know that base to attribute those links to the app.
68
+ loadRemoteSnapshot: async (args) => {
69
+ const { moduleInfo, remoteSnapshot } = args;
70
+ if ("entry" in moduleInfo && "publicPath" in remoteSnapshot && remoteSnapshot.publicPath) {
71
+ registerRemoteAssetBase(moduleInfo.entry, remoteSnapshot.publicPath);
72
+ }
73
+ return args;
74
+ },
65
75
  };
66
76
  }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * How long a 401 is treated as "login redirect in progress" before it is shown as an error.
3
+ *
4
+ * @remarks
5
+ * The backend's not-authenticated handler navigates to the login page on every 401, so the error
6
+ * is normally never seen. The error surfaces only when no navigation happens, e.g. the 401 carries
7
+ * no authentication flow or an embedding host installed a handler that does not redirect.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare const NOT_AUTHENTICATED_GRACE_MS = 10000;
12
+ /**
13
+ * Calls `onExpired` once the grace period passes. Returns a function that cancels the call.
14
+ *
15
+ * @internal
16
+ */
17
+ export declare function afterNotAuthenticatedGrace(onExpired: () => void): () => void;
18
+ /**
19
+ * Resolves once the grace period passes, or immediately when `signal` aborts.
20
+ *
21
+ * @internal
22
+ */
23
+ export declare function waitForNotAuthenticatedGrace(signal: AbortSignal): Promise<void>;
24
+ //# sourceMappingURL=notAuthenticatedGrace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notAuthenticatedGrace.d.ts","sourceRoot":"","sources":["../../src/platformContext/notAuthenticatedGrace.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,QAAS,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG5E;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAgB/E"}
@@ -0,0 +1,39 @@
1
+ // (C) 2026 GoodData Corporation
2
+ /**
3
+ * How long a 401 is treated as "login redirect in progress" before it is shown as an error.
4
+ *
5
+ * @remarks
6
+ * The backend's not-authenticated handler navigates to the login page on every 401, so the error
7
+ * is normally never seen. The error surfaces only when no navigation happens, e.g. the 401 carries
8
+ * no authentication flow or an embedding host installed a handler that does not redirect.
9
+ *
10
+ * @internal
11
+ */
12
+ export const NOT_AUTHENTICATED_GRACE_MS = 10_000;
13
+ /**
14
+ * Calls `onExpired` once the grace period passes. Returns a function that cancels the call.
15
+ *
16
+ * @internal
17
+ */
18
+ export function afterNotAuthenticatedGrace(onExpired) {
19
+ const timer = setTimeout(onExpired, NOT_AUTHENTICATED_GRACE_MS);
20
+ return () => clearTimeout(timer);
21
+ }
22
+ /**
23
+ * Resolves once the grace period passes, or immediately when `signal` aborts.
24
+ *
25
+ * @internal
26
+ */
27
+ export function waitForNotAuthenticatedGrace(signal) {
28
+ return new Promise((resolve) => {
29
+ if (signal.aborted) {
30
+ resolve();
31
+ return;
32
+ }
33
+ const cancel = afterNotAuthenticatedGrace(resolve);
34
+ signal.addEventListener("abort", () => {
35
+ cancel();
36
+ resolve();
37
+ }, { once: true });
38
+ });
39
+ }
@@ -1,4 +1,5 @@
1
1
  import { type IAuthenticationContext, type NotAuthenticated } from "@gooddata/sdk-backend-spi";
2
+ import { type RedirectToTigerAuthenticationHandler } from "@gooddata/sdk-backend-tiger";
2
3
  /** Not authenticated handler will be called every time 401 is returned from Tiger backend. */
3
- export declare function createNotAuthenticatedHandler(externalProviderId?: string): (ctx: IAuthenticationContext, err: NotAuthenticated) => void;
4
+ export declare function createNotAuthenticatedHandler(externalProviderId?: string, redirectHandler?: RedirectToTigerAuthenticationHandler): (ctx: IAuthenticationContext, err: NotAuthenticated) => void;
4
5
  //# sourceMappingURL=tigerNotAuthenticatedHandler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tigerNotAuthenticatedHandler.d.ts","sourceRoot":"","sources":["../../src/platformContext/tigerNotAuthenticatedHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAM/F,8FAA8F;AAE9F,wBAAgB,6BAA6B,CACzC,kBAAkB,CAAC,EAAE,MAAM,GAC5B,CAAC,GAAG,EAAE,sBAAsB,EAAE,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAY9D"}
1
+ {"version":3,"file":"tigerNotAuthenticatedHandler.d.ts","sourceRoot":"","sources":["../../src/platformContext/tigerNotAuthenticatedHandler.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,sBAAsB,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EACH,KAAK,oCAAoC,EAG5C,MAAM,6BAA6B,CAAC;AAErC,8FAA8F;AAE9F,wBAAgB,6BAA6B,CACzC,kBAAkB,CAAC,EAAE,MAAM,EAC3B,eAAe,GAAE,oCAEkB,GACpC,CAAC,GAAG,EAAE,sBAAsB,EAAE,GAAG,EAAE,gBAAgB,KAAK,IAAI,CAU9D"}
@@ -2,15 +2,15 @@
2
2
  import { throttle } from "lodash-es";
3
3
  import { createRedirectToTigerAuthenticationWithParams, redirectToTigerAuthentication, } from "@gooddata/sdk-backend-tiger";
4
4
  /** Not authenticated handler will be called every time 401 is returned from Tiger backend. */
5
- export function createNotAuthenticatedHandler(externalProviderId) {
6
- const redirectHandler = externalProviderId
7
- ? createRedirectToTigerAuthenticationWithParams({ externalProviderId })
8
- : redirectToTigerAuthentication;
9
- const debouncedRedirectHandler = throttle(redirectHandler, 500, {
10
- leading: false,
11
- trailing: true,
5
+ export function createNotAuthenticatedHandler(externalProviderId, redirectHandler = externalProviderId
6
+ ? createRedirectToTigerAuthenticationWithParams({ externalProviderId })
7
+ : redirectToTigerAuthentication) {
8
+ // Boot fires several requests in parallel. Redirect on the first 401 and ignore the rest.
9
+ const throttledRedirectHandler = throttle(redirectHandler, 500, {
10
+ leading: true,
11
+ trailing: false,
12
12
  });
13
13
  return (ctx, err) => {
14
- debouncedRedirectHandler(ctx, err);
14
+ throttledRedirectHandler(ctx, err);
15
15
  };
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadPlatformContext.d.ts","sourceRoot":"","sources":["../../src/platformContext/useLoadPlatformContext.ts"],"names":[],"mappings":"AAOA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAO3G,OAAO,EACH,KAAK,6BAA6B,EAGrC,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACH,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAElC,MAAM,YAAY,CAAC;AAYpB;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,IAAI,0BAA0B,CAAC,gBAAgB,CAAC,CA6JrF;AAED;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC5C,YAAY,CAAC,SAAS,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC7D,SAAS,EAAE,MAAM,QAAQ,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAC/E,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AAmED;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,+BACA,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,6BAA6B,GAAG,IAAI,CAE/F"}
1
+ {"version":3,"file":"useLoadPlatformContext.d.ts","sourceRoot":"","sources":["../../src/platformContext/useLoadPlatformContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAO3G,OAAO,EACH,KAAK,6BAA6B,EAGrC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACH,KAAK,uBAAuB,EAC5B,KAAK,0BAA0B,EAElC,MAAM,YAAY,CAAC;AAYpB;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,IAAI,0BAA0B,CAAC,gBAAgB,CAAC,CA6JrF;AAED;;;;GAIG;AACH,MAAM,WAAW,+BAA+B;IAC5C,YAAY,CAAC,SAAS,EAAE,6BAA6B,GAAG,IAAI,CAAC;IAC7D,SAAS,EAAE,MAAM,QAAQ,CAAC,0BAA0B,CAAC,uBAAuB,CAAC,CAAC,CAAC;IAC/E,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAChD,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B;AA4ED;;GAEG;AACH,eAAO,MAAM,8BAA8B,EAAE,+BACA,CAAC;AAE9C;;;;;;GAMG;AACH,wBAAgB,gCAAgC,CAAC,SAAS,EAAE,6BAA6B,GAAG,IAAI,CAE/F"}
@@ -1,12 +1,14 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { useEffect, useMemo, useState, useSyncExternalStore } from "react";
3
3
  import { useLocation } from "react-router";
4
+ import { isNotAuthenticated } from "@gooddata/sdk-backend-spi";
4
5
  import { isLocale } from "@gooddata/sdk-model";
5
6
  import { isProduction } from "../lib/isProduction.js";
6
7
  import { getApplicationScopeFromPath, getWorkspaceIdFromPath } from "../loader/routing.js";
7
8
  import { resolveAvailableWorkspaceApplications } from "../registry/pluggableApplicationsRegistry.js";
8
9
  import { getBackend } from "./backend.js";
9
10
  import { HostApplicationDisabledError, loadPlatformContext, } from "./loadPlatformContext.js";
11
+ import { waitForNotAuthenticatedGrace } from "./notAuthenticatedGrace.js";
10
12
  import { useWorkspaceColorPalette } from "./useWorkspaceColorPalette.js";
11
13
  import { useWorkspacePermissions } from "./useWorkspacePermissions.js";
12
14
  import { useWorkspaceSettings } from "./useWorkspaceSettings.js";
@@ -171,12 +173,13 @@ class BackendPlatformContextProviderClass {
171
173
  this._setResult(this._loadingStateMemo);
172
174
  }
173
175
  this._abortController = new AbortController();
176
+ const signal = this._abortController.signal;
174
177
  try {
175
178
  if (shouldWaitForInjectedApiToken()) {
176
- await waitForInjectedApiToken(this._abortController.signal);
179
+ await waitForInjectedApiToken(signal);
177
180
  }
178
181
  const ctx = await loadPlatformContext({
179
- signal: this._abortController.signal,
182
+ signal,
180
183
  callbacks: this._callbacks,
181
184
  });
182
185
  if (!this._abortController.signal.aborted) {
@@ -191,6 +194,14 @@ class BackendPlatformContextProviderClass {
191
194
  if (e instanceof DOMException && e.name === "AbortError") {
192
195
  return;
193
196
  }
197
+ // The backend redirects to login on a 401. Keep the loader up so the error does not
198
+ // flash before the browser leaves the page.
199
+ if (isNotAuthenticated(e)) {
200
+ await waitForNotAuthenticatedGrace(signal);
201
+ if (signal.aborted) {
202
+ return;
203
+ }
204
+ }
194
205
  console.error("[host-runtime/platform-context] Failed to load platform context.", e);
195
206
  const message = e instanceof Error ? e.message : "Unknown platform context error.";
196
207
  if (!this._abortController.signal.aborted) {
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspacePermissions.d.ts","sourceRoot":"","sources":["../../src/platformContext/useWorkspacePermissions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAIjE,KAAK,yBAAyB,GACxB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,qBAAqB,CAAA;CAAE,GACtD;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAYxC;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,WAAW,EAAE,MAAM,GAAG,SAAS,GAChC,yBAAyB,CA6D3B"}
1
+ {"version":3,"file":"useWorkspacePermissions.d.ts","sourceRoot":"","sources":["../../src/platformContext/useWorkspacePermissions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,kBAAkB,EAAsB,MAAM,2BAA2B,CAAC;AACxF,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAKjE,KAAK,yBAAyB,GACxB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,qBAAqB,CAAA;CAAE,GACtD;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAYxC;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,WAAW,EAAE,MAAM,GAAG,SAAS,GAChC,yBAAyB,CAuE3B"}
@@ -1,5 +1,7 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { useEffect, useState } from "react";
3
+ import { isNotAuthenticated } from "@gooddata/sdk-backend-spi";
4
+ import { afterNotAuthenticatedGrace } from "./notAuthenticatedGrace.js";
3
5
  import { classifyWorkspaceAccessError } from "./workspaceAccess.js";
4
6
  const IDLE = { state: "idle" };
5
7
  const LOADING = { state: "loading" };
@@ -26,6 +28,7 @@ export function useWorkspacePermissions(backend, workspaceId) {
26
28
  return;
27
29
  }
28
30
  let cancelled = false;
31
+ let cancelGrace;
29
32
  setSnapshot({ backend, workspaceId, state: LOADING });
30
33
  const update = (state) => {
31
34
  if (!cancelled) {
@@ -49,10 +52,19 @@ export function useWorkspacePermissions(backend, workspaceId) {
49
52
  return;
50
53
  }
51
54
  const error = e instanceof Error ? e.message : "Unknown error loading workspace permissions.";
55
+ // Stay "loading" while the backend redirects to login on a 401.
56
+ if (isNotAuthenticated(e)) {
57
+ if (cancelled) {
58
+ return;
59
+ }
60
+ cancelGrace = afterNotAuthenticatedGrace(() => update({ state: "error", error }));
61
+ return;
62
+ }
52
63
  update({ state: "error", error });
53
64
  });
54
65
  return () => {
55
66
  cancelled = true;
67
+ cancelGrace?.();
56
68
  };
57
69
  }, [backend, workspaceId]);
58
70
  if (!backend || !workspaceId) {
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkspaceSettings.d.ts","sourceRoot":"","sources":["../../src/platformContext/useWorkspaceSettings.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC9B,MAAM,2BAA2B,CAAC;AAEnC,KAAK,sBAAsB,GACrB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,sBAAsB,CAAA;CAAE,GACpD;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,WAAW,EAAE,MAAM,GAAG,SAAS,GAChC,sBAAsB,CAqCxB"}
1
+ {"version":3,"file":"useWorkspaceSettings.d.ts","sourceRoot":"","sources":["../../src/platformContext/useWorkspaceSettings.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAE9B,MAAM,2BAA2B,CAAC;AAInC,KAAK,sBAAsB,GACrB;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,GACjB;IAAE,KAAK,EAAE,SAAS,CAAA;CAAE,GACpB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,sBAAsB,CAAA;CAAE,GACpD;IAAE,KAAK,EAAE,WAAW,CAAA;CAAE,GACtB;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,kBAAkB,GAAG,SAAS,EACvC,WAAW,EAAE,MAAM,GAAG,SAAS,GAChC,sBAAsB,CA8CxB"}
@@ -1,6 +1,7 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { useEffect, useState } from "react";
3
- import { UnexpectedResponseError, } from "@gooddata/sdk-backend-spi";
3
+ import { UnexpectedResponseError, isNotAuthenticated, } from "@gooddata/sdk-backend-spi";
4
+ import { afterNotAuthenticatedGrace } from "./notAuthenticatedGrace.js";
4
5
  /**
5
6
  * Loads effective workspace-scoped settings for the current user.
6
7
  *
@@ -18,6 +19,7 @@ export function useWorkspaceSettings(backend, workspaceId) {
18
19
  return;
19
20
  }
20
21
  let cancelled = false;
22
+ let cancelGrace;
21
23
  setSettingsState({ state: "loading" });
22
24
  backend
23
25
  .workspace(workspaceId)
@@ -36,10 +38,16 @@ export function useWorkspaceSettings(backend, workspaceId) {
36
38
  return;
37
39
  }
38
40
  const error = e instanceof Error ? e.message : "Unknown error loading workspace settings.";
41
+ // Stay "loading" while the backend redirects to login on a 401.
42
+ if (isNotAuthenticated(e)) {
43
+ cancelGrace = afterNotAuthenticatedGrace(() => setSettingsState({ state: "error", error }));
44
+ return;
45
+ }
39
46
  setSettingsState({ state: "error", error });
40
47
  });
41
48
  return () => {
42
49
  cancelled = true;
50
+ cancelGrace?.();
43
51
  };
44
52
  }, [backend, workspaceId]);
45
53
  return settingsState;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/sdk-ui-pluggable-host",
3
- "version": "11.62.0-alpha.2",
3
+ "version": "11.62.0-alpha.3",
4
4
  "description": "GoodData SDK runtime for hosting pluggable applications — registry, loader, routing, platform context, default UI chrome",
5
5
  "license": "MIT",
6
6
  "author": "GoodData Corporation",
@@ -29,25 +29,26 @@
29
29
  "dependencies": {
30
30
  "@module-federation/runtime": "2.6.0",
31
31
  "lodash-es": "^4.17.23",
32
- "@gooddata/sdk-backend-base": "11.62.0-alpha.2",
33
- "@gooddata/sdk-backend-spi": "11.62.0-alpha.2",
34
- "@gooddata/sdk-backend-tiger": "11.62.0-alpha.2",
35
- "@gooddata/sdk-embedding": "11.62.0-alpha.2",
36
- "@gooddata/sdk-model": "11.62.0-alpha.2",
37
- "@gooddata/sdk-pluggable-application-model": "11.62.0-alpha.2",
38
- "@gooddata/sdk-ui": "11.62.0-alpha.2",
39
- "@gooddata/sdk-ui-application-header": "11.62.0-alpha.2",
40
- "@gooddata/sdk-ui-ext": "11.62.0-alpha.2",
41
- "@gooddata/sdk-ui-kit": "11.62.0-alpha.2",
42
- "@gooddata/sdk-ui-gen-ai": "11.62.0-alpha.2",
43
- "@gooddata/sdk-ui-theme-provider": "11.62.0-alpha.2",
44
- "@gooddata/sdk-ui-semantic-search": "11.62.0-alpha.2",
45
- "@gooddata/util": "11.62.0-alpha.2"
32
+ "@gooddata/sdk-backend-base": "11.62.0-alpha.3",
33
+ "@gooddata/sdk-embedding": "11.62.0-alpha.3",
34
+ "@gooddata/sdk-backend-spi": "11.62.0-alpha.3",
35
+ "@gooddata/sdk-model": "11.62.0-alpha.3",
36
+ "@gooddata/sdk-backend-tiger": "11.62.0-alpha.3",
37
+ "@gooddata/sdk-pluggable-application-model": "11.62.0-alpha.3",
38
+ "@gooddata/sdk-ui": "11.62.0-alpha.3",
39
+ "@gooddata/sdk-ui-application-header": "11.62.0-alpha.3",
40
+ "@gooddata/sdk-ui-ext": "11.62.0-alpha.3",
41
+ "@gooddata/sdk-ui-gen-ai": "11.62.0-alpha.3",
42
+ "@gooddata/sdk-ui-kit": "11.62.0-alpha.3",
43
+ "@gooddata/sdk-ui-semantic-search": "11.62.0-alpha.3",
44
+ "@gooddata/sdk-ui-theme-provider": "11.62.0-alpha.3",
45
+ "@gooddata/util": "11.62.0-alpha.3"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@microsoft/api-documenter": "7.30.16",
49
49
  "@microsoft/api-extractor": "7.59.2",
50
50
  "@testing-library/dom": "10.4.2",
51
+ "@testing-library/jest-dom": "7.0.1",
51
52
  "@testing-library/react": "16.3.0",
52
53
  "@types/lodash-es": "4.17.12",
53
54
  "@types/node": "24.12.0",
@@ -55,7 +56,7 @@
55
56
  "@types/react-dom": "19.1.7",
56
57
  "@typescript-eslint/eslint-plugin": "8.58.0",
57
58
  "@typescript-eslint/parser": "8.58.0",
58
- "@vitest/coverage-v8": "4.1.11",
59
+ "@vitest/coverage-v8": "5.0.4",
59
60
  "eslint": "^9.39.2",
60
61
  "eslint-plugin-headers": "1.3.3",
61
62
  "eslint-plugin-jsdoc": "62.1.0",
@@ -79,10 +80,9 @@
79
80
  "tslib": "2.8.1",
80
81
  "typescript": "7.0.2",
81
82
  "vite": "8.0.16",
82
- "vitest": "4.1.11",
83
- "vitest-dom": "0.1.1",
84
- "@gooddata/eslint-config": "11.62.0-alpha.2",
85
- "@gooddata/oxlint-config": "11.62.0-alpha.2"
83
+ "vitest": "5.0.4",
84
+ "@gooddata/oxlint-config": "11.62.0-alpha.3",
85
+ "@gooddata/eslint-config": "11.62.0-alpha.3"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "react": ">=18.3.1",