@bluealba/pae-ui-react-core 4.7.0-develop-423 → 4.7.0-develop-428
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 +51 -51
- package/dist/index.css +1 -1
- package/dist/index.esm.js +4822 -4798
- package/dist/index.systemjs.js +52 -52
- package/dist/index.umd.js +52 -52
- package/dist/src/components/ThemeToggle/useTheme.d.ts +1 -1
- package/dist/src/utils/initializeMicroFrontend.d.ts +19 -11
- package/dist/src/utils/moduleStyleRegistry.d.ts +38 -0
- package/package.json +1 -1
|
@@ -5,8 +5,9 @@ import { RootComponentProps } from '../MicrofrontendProps';
|
|
|
5
5
|
export interface MicroFrontendOptions<T extends RootComponentProps> extends SingleSpaReactOpts<T> {
|
|
6
6
|
rootComponent: FC<T>;
|
|
7
7
|
/**
|
|
8
|
-
* Mount this module inside its own shadow root (attached to
|
|
9
|
-
* element the platform resolves from ui.mountAtSelector
|
|
8
|
+
* Mount this module inside its own shadow root (attached to a dedicated child
|
|
9
|
+
* of the host element the platform resolves from ui.mountAtSelector, so the
|
|
10
|
+
* shared host stays usable by other modules mounted there later).
|
|
10
11
|
*
|
|
11
12
|
* Why: global CSS from OTHER modules mounted at the same time (a framework
|
|
12
13
|
* reset, unlayered utilities, ...) cannot reach this module's DOM, and this
|
|
@@ -18,10 +19,10 @@ export interface MicroFrontendOptions<T extends RootComponentProps> extends Sing
|
|
|
18
19
|
* they keep working.
|
|
19
20
|
* - Selectors like `:root`, `html` or `body` do NOT match inside a shadow
|
|
20
21
|
* root; use `:host` instead.
|
|
21
|
-
* - CSS built with the SDK (`pae-ui-sdk`) is automatically encapsulated
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* No extra setup needed for webpack-imported stylesheets.
|
|
22
|
+
* - CSS built with the SDK (`pae-ui-sdk`) is automatically encapsulated. The
|
|
23
|
+
* module's `<style data-pae-module>` nodes are kept out of the light-DOM
|
|
24
|
+
* `document.head` and live inside the shadow root, including lazy chunks and
|
|
25
|
+
* HMR updates. No extra setup needed for webpack-imported stylesheets.
|
|
25
26
|
* - If you inject styles by other means (e.g. dynamic `<style>` creation,
|
|
26
27
|
* third-party runtime CSS-in-JS), access the shadow root via:
|
|
27
28
|
* `usePortalContainer()?.getRootNode() as ShadowRoot | undefined`
|
|
@@ -33,6 +34,15 @@ export interface MicroFrontendOptions<T extends RootComponentProps> extends Sing
|
|
|
33
34
|
*/
|
|
34
35
|
shadowDom?: boolean;
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Marker set on a shadow module's exported `mount` so other core code can detect,
|
|
39
|
+
* after a bare `System.import` (e.g. reading a module's `menu`/`icon` without
|
|
40
|
+
* mounting it), that the module is shadow-isolated and its styles must be evacuated
|
|
41
|
+
* from `document.head`. See {@link hasShadowDomMarker} and useApplicationJSModule.
|
|
42
|
+
*/
|
|
43
|
+
export declare const SHADOW_DOM_MARKER = "__paeShadowDom";
|
|
44
|
+
/** True if `mount` is a shadow module's lifecycle (carries {@link SHADOW_DOM_MARKER}). */
|
|
45
|
+
export declare const hasShadowDomMarker: (mount: unknown) => boolean;
|
|
36
46
|
/**
|
|
37
47
|
* Main function to create a PAE micro-frontend module.
|
|
38
48
|
* Internally we use single-spa so currently our API is pretty similar.
|
|
@@ -41,11 +51,9 @@ export interface MicroFrontendOptions<T extends RootComponentProps> extends Sing
|
|
|
41
51
|
* All PAE micro-frontends are wrapped in PAE components that provides react context later used
|
|
42
52
|
* by the provided hooks.
|
|
43
53
|
*
|
|
44
|
-
* When `shadowDom: true` is passed the module is mounted inside its own open
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* the shadow root is exposed via `usePortalContainer()` so that overlay components
|
|
48
|
-
* (modals, dropdowns, tooltips) can render inside the shadow root as well.
|
|
54
|
+
* When `shadowDom: true` is passed the module is mounted inside its own open shadow
|
|
55
|
+
* root (see {@link withShadowDom}), isolating it from global CSS in the light DOM and
|
|
56
|
+
* keeping its own CSS out of `document.head`.
|
|
49
57
|
*/
|
|
50
58
|
declare const initializeMicroFrontend: <T extends RootComponentProps>({ rootComponent, shadowDom, ...opts }: MicroFrontendOptions<T>) => ReactAppOrParcel<T>;
|
|
51
59
|
export default initializeMicroFrontend;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-module style routing registry, shared process-wide via `window`.
|
|
3
|
+
*
|
|
4
|
+
* The CSS of an isolated (`shadowDom`) micro-frontend must never leak into the
|
|
5
|
+
* light-DOM `document.head`. style-loader injects `<style data-pae-module=name>`
|
|
6
|
+
* nodes into the head at bundle-load (e.g. when the shell imports a module just to
|
|
7
|
+
* read its `menu`/`icon`, long before — or without ever — mounting it). This
|
|
8
|
+
* registry holds, per module, a DETACHED holder element that owns those nodes
|
|
9
|
+
* while the module is not mounted (a detached node is not rendered, so its CSS does
|
|
10
|
+
* not apply ⇒ no leak), plus the current `target` where new nodes should go.
|
|
11
|
+
*
|
|
12
|
+
* `initializeMicroFrontend` flips `target` across the lifecycle (holder ⇄ shadow
|
|
13
|
+
* root) and `useApplicationJSModule` evacuates a shadow module's head styles into
|
|
14
|
+
* the holder right after importing it for its exports.
|
|
15
|
+
*/
|
|
16
|
+
export interface StyleEntry {
|
|
17
|
+
/** The module name (equals the `data-pae-module` attribute of its style nodes). */
|
|
18
|
+
name: string;
|
|
19
|
+
/** Where newly injected `<style data-pae-module=name>` nodes should be placed now. */
|
|
20
|
+
target: Node;
|
|
21
|
+
/** Detached `<div>` that owns the module's style nodes while it is not mounted. */
|
|
22
|
+
holder: HTMLElement;
|
|
23
|
+
mode: 'detached' | 'shadow';
|
|
24
|
+
}
|
|
25
|
+
/** Get or lazily create the registry entry (with a detached holder) for a module. */
|
|
26
|
+
export declare const getStyleEntry: (moduleName: string) => StyleEntry;
|
|
27
|
+
/**
|
|
28
|
+
* Move every `<style|link data-pae-module=name>` node currently under `from` into
|
|
29
|
+
* `to`. Used to evacuate a module's styles out of `document.head` (into its holder
|
|
30
|
+
* or shadow root) and back into the holder on unmount.
|
|
31
|
+
*/
|
|
32
|
+
export declare const moveModuleStyles: (from: ParentNode, to: Node, name: string) => void;
|
|
33
|
+
/**
|
|
34
|
+
* Evacuate a shadow module's styles out of the light-DOM `document.head` into its
|
|
35
|
+
* detached holder, and route future styles there too — unless the module is
|
|
36
|
+
* currently mounted (its target is the live shadow root). Returns the entry.
|
|
37
|
+
*/
|
|
38
|
+
export declare const evacuateToHolder: (moduleName: string) => StyleEntry;
|