@bluealba/pae-ui-react-core 4.6.0-integration-css.408 → 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.
- package/dist/index.cjs.js +43 -43
- package/dist/index.esm.js +2059 -2037
- package/dist/index.systemjs.js +45 -45
- package/dist/index.umd.js +46 -46
- package/dist/src/styles/moduleStyleLifecycle.d.ts +17 -8
- package/dist/src/utils/initializeMicroFrontend.d.ts +30 -2
- package/package.json +1 -1
|
@@ -14,6 +14,11 @@
|
|
|
14
14
|
* document while keeping them in memory — and restoreModuleStyles on mount,
|
|
15
15
|
* so re-entering the app is instant (no re-parse, CSSOM preserved).
|
|
16
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
|
+
*
|
|
17
22
|
* NOTE: this only covers CSS that goes through style-loader. Runtime
|
|
18
23
|
* CSS-in-JS (e.g. Emotion/MUI) injects its own tags and is not affected.
|
|
19
24
|
*
|
|
@@ -21,14 +26,18 @@
|
|
|
21
26
|
* so this module-scoped store is global across all micro-frontends.
|
|
22
27
|
*/
|
|
23
28
|
/**
|
|
24
|
-
* Detach the module's style elements from the document
|
|
25
|
-
*
|
|
26
|
-
* has no tagged
|
|
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).
|
|
27
33
|
*/
|
|
28
|
-
export declare const suspendModuleStyles: (moduleName: string) => void;
|
|
34
|
+
export declare const suspendModuleStyles: (moduleName: string, extraRoot?: ParentNode) => void;
|
|
29
35
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
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).
|
|
33
42
|
*/
|
|
34
|
-
export declare const restoreModuleStyles: (moduleName: string) => void;
|
|
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.
|
|
@@ -16,7 +42,9 @@ export interface MicroFrontendOptions<T extends RootComponentProps> extends Sing
|
|
|
16
42
|
* On top of the single-spa lifecycles, the module's global styles (tagged
|
|
17
43
|
* with data-pae-module by the UI SDK) are suspended on unmount and restored
|
|
18
44
|
* on mount, so CSS frameworks imported by one module don't leak into other
|
|
19
|
-
* modules across navigation (see styles/moduleStyleLifecycle).
|
|
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.
|
|
20
48
|
*/
|
|
21
|
-
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>;
|
|
22
50
|
export default initializeMicroFrontend;
|