@bluealba/pae-ui-react-core 4.6.0-integration-css.403 → 4.6.0-integration-css.409

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.
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Suspend/restore a micro-frontend module's global styles across single-spa
3
+ * mount/unmount.
4
+ *
5
+ * style-loader injects a module's CSS into document.head when the bundle is
6
+ * LOADED, and single-spa unmount never removes it (SystemJS keeps the module
7
+ * cached). A module that imports a global stylesheet (a CSS framework reset,
8
+ * preflight, etc.) therefore permanently contaminates every app visited
9
+ * afterwards in the same session.
10
+ *
11
+ * The UI SDK tags every <style> it emits with data-pae-module="<name>"
12
+ * (see pae-ui-react-sdk getBaseConfig). initializeMicroFrontend calls
13
+ * suspendModuleStyles on unmount — detaching those elements from the
14
+ * document while keeping them in memory — and restoreModuleStyles on mount,
15
+ * so re-entering the app is instant (no re-parse, CSSOM preserved).
16
+ *
17
+ * For modules that opt into per-module shadow DOM, restoreModuleStyles
18
+ * accepts the module's shadow root as target: the tagged styles are moved
19
+ * INTO the shadow root (scoping them to the module) instead of back into
20
+ * document.head, and suspendModuleStyles also sweeps that root on unmount.
21
+ *
22
+ * NOTE: this only covers CSS that goes through style-loader. Runtime
23
+ * CSS-in-JS (e.g. Emotion/MUI) injects its own tags and is not affected.
24
+ *
25
+ * pae-ui-react-core is a shared singleton (one instance via the import map),
26
+ * so this module-scoped store is global across all micro-frontends.
27
+ */
28
+ /**
29
+ * Detach the module's style elements from the document (and from the given
30
+ * extra root, e.g. the module's shadow root), keeping them in memory for a
31
+ * later restoreModuleStyles call. Safe to call when the module has no tagged
32
+ * styles (no-op).
33
+ */
34
+ export declare const suspendModuleStyles: (moduleName: string, extraRoot?: ParentNode) => void;
35
+ /**
36
+ * Attach the module's style elements to the target (document.head by
37
+ * default, or the module's shadow root in per-module shadow DOM mode).
38
+ * Sources, in order: previously suspended elements, plus any still sitting
39
+ * in document.head when a non-document target is given (first mount of a
40
+ * shadow module — style-loader injected them at bundle load time).
41
+ * Safe to call when there is nothing to attach (no-op).
42
+ */
43
+ export declare const restoreModuleStyles: (moduleName: string, target?: ShadowRoot) => void;
@@ -4,6 +4,32 @@ import { RootComponentProps } from '../MicrofrontendProps';
4
4
 
5
5
  export interface MicroFrontendOptions<T extends RootComponentProps> extends SingleSpaReactOpts<T> {
6
6
  rootComponent: FC<T>;
7
+ /**
8
+ * Mount this module inside its own shadow root (attached to the host
9
+ * element the platform resolves from ui.mountAtSelector).
10
+ *
11
+ * Why: global CSS from OTHER modules mounted at the same time (a framework
12
+ * reset, unlayered utilities, ...) cannot reach this module's DOM, and this
13
+ * module's own style-loader CSS is moved into the shadow root so it cannot
14
+ * leak out. This is the only isolation that works for SIMULTANEOUSLY
15
+ * mounted modules (e.g. fragments side by side) — the suspend/restore
16
+ * lifecycle alone only helps across navigation.
17
+ *
18
+ * What module authors must know:
19
+ * - Design tokens (CSS custom properties) inherit into the shadow root —
20
+ * they keep working.
21
+ * - Selectors like `:root`, `html` or `body` do NOT match inside a shadow
22
+ * root; use `:host` (Tailwind v4 already emits `:root, :host`).
23
+ * - @keyframes and @layer order statements are scoped per tree — keep them
24
+ * in the module's own CSS (style-loader output is moved wholesale, so
25
+ * this is automatic for bundled CSS).
26
+ * - Platform core components (Dialog, Tooltip) portal into the shadow root
27
+ * automatically. Third-party overlay libraries default to document.body:
28
+ * pass them the container from usePortalContainer(), and point runtime
29
+ * CSS-in-JS (e.g. Emotion: createCache({ container })) at the shadow
30
+ * root, or their floating content will render unstyled outside it.
31
+ */
32
+ shadowDom?: boolean;
7
33
  }
8
34
  /**
9
35
  * Main function to create a PAE micro-frontend module.
@@ -12,6 +38,13 @@ export interface MicroFrontendOptions<T extends RootComponentProps> extends Sing
12
38
  *
13
39
  * All PAE micro-frontends are wrapped in PAE components that provides react context later used
14
40
  * by the provided hooks.
41
+ *
42
+ * On top of the single-spa lifecycles, the module's global styles (tagged
43
+ * with data-pae-module by the UI SDK) are suspended on unmount and restored
44
+ * on mount, so CSS frameworks imported by one module don't leak into other
45
+ * modules across navigation (see styles/moduleStyleLifecycle). With
46
+ * `shadowDom: true` the module is additionally mounted inside its own shadow
47
+ * root, isolating it from modules mounted at the same time.
15
48
  */
16
- declare const initializeMicroFrontend: <T extends RootComponentProps>({ rootComponent, ...opts }: MicroFrontendOptions<T>) => ReactAppOrParcel<T>;
49
+ declare const initializeMicroFrontend: <T extends RootComponentProps>({ rootComponent, shadowDom, ...opts }: MicroFrontendOptions<T>) => ReactAppOrParcel<T>;
17
50
  export default initializeMicroFrontend;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluealba/pae-ui-react-core",
3
- "version": "4.6.0-integration-css.403",
3
+ "version": "4.6.0-integration-css.409",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",