@salesforce/experimental-mfe-lwc-shell 2.2.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.
- package/README.md +27 -0
- package/dist/InternalHostLwcShell.d.ts +98 -0
- package/dist/graphqlHandler.d.ts +5 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +702 -0
- package/dist/index.iife.js +710 -0
- package/dist/index.iife.prod.js +5 -0
- package/dist/lwc/dirtyStateModal/dirtyStateModal.html +33 -0
- package/dist/lwc/dirtyStateModal/dirtyStateModal.js +82 -0
- package/dist/lwc/dirtyStateModal/dirtyStateModal.js-meta.xml +5 -0
- package/dist/utils/dirtyStateModal.d.ts +23 -0
- package/dist/utils/dirtyStateModal.d.ts.map +1 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/symbols.d.ts +18 -0
- package/dist/utils/symbols.d.ts.map +1 -0
- package/index.d.ts +97 -0
- package/package.json +42 -0
- package/scripts/templates/vendor-banner.js +2 -0
- package/scripts/templates/vendor-meta.xml +5 -0
- package/scripts/vendor-build.mjs +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @salesforce/experimental-mfe-lwc-shell
|
|
2
|
+
|
|
3
|
+
A **custom web component** (`<lwc-shell>`) that renders a sandboxed `<iframe>` to embed Micro-Frontend (MFE) applications inside Salesforce Lightning pages, Experience sites, and other LWC-enabled surfaces.
|
|
4
|
+
|
|
5
|
+
## Key Capabilities
|
|
6
|
+
|
|
7
|
+
- Sandboxed `<iframe>` rendering inside a closed Shadow DOM
|
|
8
|
+
- Cross-origin communication with embedded MFE apps via `postMessage` bridge
|
|
9
|
+
- Configurable sandbox tokens, fullscreen mode, automatic resize, and theme forwarding
|
|
10
|
+
- Dirty-state tracking via `trackdirtystate` event
|
|
11
|
+
- Framework-agnostic — extends `HTMLElement` directly
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
| Document | Description |
|
|
16
|
+
|---|---|
|
|
17
|
+
| [Web Component API](./docs/LWC_SHELL_WEB_COMPONENT_API.md) | Full specification of the `<lwc-shell>` web component — attributes, properties, methods, events, and sandbox security. |
|
|
18
|
+
| [LWC Wrapper Guide](./docs/LWC_SHELL_WRAPPER_GUIDE.md) | Step-by-step guide to writing an LWC wrapper, from setup and vendor build through to deployment, with a complete code recipe. |
|
|
19
|
+
| [Dirty State Flow](./docs/DIRTY_STATE_FLOW.md) | How MFE widgets track unsaved changes via `trackdirtystate` and how the shell relays it to the host platform. |
|
|
20
|
+
| [PostMessage Security](./docs/POSTMESSAGE_SECURITY.md) | Security model for `postMessage` communication between the shell and the embedded iframe. |
|
|
21
|
+
|
|
22
|
+
## Package Contents
|
|
23
|
+
|
|
24
|
+
| Path | Purpose |
|
|
25
|
+
|---|---|
|
|
26
|
+
| `src/InternalHostLwcShell.ts` | Core web component implementation (`<lwc-shell>` custom element). |
|
|
27
|
+
| `scripts/vendor-build.mjs` | CLI tool (`lwc-shell-vendor-build`) that copies the built ESM bundle as a vendor-prefixed LWC component. |
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InternalHostLwcShell
|
|
3
|
+
*
|
|
4
|
+
* A standard Web Component (custom element) that embeds an iframe-based widget
|
|
5
|
+
* with bridge communication, sandbox management, and fullscreen support.
|
|
6
|
+
*
|
|
7
|
+
* Registered as `<lwc-shell>`.
|
|
8
|
+
*
|
|
9
|
+
* Dirty-state tracking is handled via a simple `trackdirtystate`
|
|
10
|
+
* custom-event flow: the embedded widget dispatches `trackdirtystate`
|
|
11
|
+
* with `{ isDirty, instanceId, label }`, and this shell re-dispatches
|
|
12
|
+
* the event for the host LWC to observe.
|
|
13
|
+
*
|
|
14
|
+
* **How customers use this:**
|
|
15
|
+
* 1. The build produces `dist/index.esm.js` which bundles this class.
|
|
16
|
+
* 2. Customers copy that file into their SFDX project as an LWC entity
|
|
17
|
+
* (e.g. `c/lwcShell`) and deploy it to their Salesforce org.
|
|
18
|
+
* 3. A wrapper LWC imports `'c/lwcShell'` and creates `<lwc-shell>`
|
|
19
|
+
* imperatively via `document.createElement('lwc-shell')`.
|
|
20
|
+
*
|
|
21
|
+
* See the README and the `productRegistration` demo for a full recipe.
|
|
22
|
+
*/
|
|
23
|
+
export declare class InternalHostLwcShell extends HTMLElement {
|
|
24
|
+
private _shadow;
|
|
25
|
+
private _iframe;
|
|
26
|
+
private _container;
|
|
27
|
+
private _currentState;
|
|
28
|
+
private _readinessTimeout;
|
|
29
|
+
private _isFullscreen;
|
|
30
|
+
private _preFullscreenHeight;
|
|
31
|
+
private _lastThemeData;
|
|
32
|
+
private _lastPayloadData;
|
|
33
|
+
private _bridgeReady;
|
|
34
|
+
private _shellInstanceId;
|
|
35
|
+
private _hasSentTheme;
|
|
36
|
+
private _hasSentData;
|
|
37
|
+
private _src;
|
|
38
|
+
private _srcdoc;
|
|
39
|
+
private _sandbox;
|
|
40
|
+
private _title;
|
|
41
|
+
private _view;
|
|
42
|
+
private _debugEnabled;
|
|
43
|
+
private _pendingGraphQLCount;
|
|
44
|
+
private static readonly MAX_CONCURRENT_GRAPHQL;
|
|
45
|
+
static get observedAttributes(): string[];
|
|
46
|
+
constructor();
|
|
47
|
+
connectedCallback(): void;
|
|
48
|
+
disconnectedCallback(): void;
|
|
49
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
50
|
+
get src(): string | null;
|
|
51
|
+
set src(v: string | null);
|
|
52
|
+
get srcdoc(): string | null;
|
|
53
|
+
set srcdoc(v: string | null);
|
|
54
|
+
get sandbox(): string | null;
|
|
55
|
+
set sandbox(v: string | null);
|
|
56
|
+
get title(): string;
|
|
57
|
+
set title(v: string | null);
|
|
58
|
+
get view(): string | null;
|
|
59
|
+
set view(v: string | null);
|
|
60
|
+
/**
|
|
61
|
+
* Controls debug logging. Toggle via:
|
|
62
|
+
* - HTML attribute: `<lwc-shell debug>`
|
|
63
|
+
* - Programmatically: `shell.debug = true`
|
|
64
|
+
*/
|
|
65
|
+
get debug(): boolean;
|
|
66
|
+
set debug(v: boolean);
|
|
67
|
+
updateData(newData: Record<string, unknown>): void;
|
|
68
|
+
refreshTheme(): void;
|
|
69
|
+
private get _isFullView();
|
|
70
|
+
private get _frameClass();
|
|
71
|
+
private _log;
|
|
72
|
+
private _renderInitial;
|
|
73
|
+
private _updateContainerState;
|
|
74
|
+
private _updateTitle;
|
|
75
|
+
private _updateViewDOM;
|
|
76
|
+
private _setState;
|
|
77
|
+
private _setupMessageListener;
|
|
78
|
+
private _handleMessage;
|
|
79
|
+
private _handleResize;
|
|
80
|
+
private _handleWidgetReady;
|
|
81
|
+
private _handleFullscreenRequest;
|
|
82
|
+
private _enterFullscreen;
|
|
83
|
+
private _exitFullscreen;
|
|
84
|
+
private _handleBridgeReady;
|
|
85
|
+
private _handleBridgeError;
|
|
86
|
+
private _handleGraphQLRequest;
|
|
87
|
+
private _handleContainerClick;
|
|
88
|
+
private _applySandbox;
|
|
89
|
+
private _computeSandboxTokens;
|
|
90
|
+
private _updateIframeSrc;
|
|
91
|
+
private _handleIframeLoad;
|
|
92
|
+
private _handleIframeError;
|
|
93
|
+
private _postToIframe;
|
|
94
|
+
private _collectDataAttributes;
|
|
95
|
+
private _sendInitialTheme;
|
|
96
|
+
private _sendInitialData;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=InternalHostLwcShell.d.ts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @salesforce/experimental-mfe-lwc-shell — Public entry point.
|
|
3
|
+
*
|
|
4
|
+
* Importing this module auto-registers the `<lwc-shell>` custom element
|
|
5
|
+
* via `customElements.define`. The bundled output (`dist/index.esm.js`) is
|
|
6
|
+
* what customers copy into their SFDX project as an LWC entity so the custom
|
|
7
|
+
* element is available at runtime on the Salesforce org.
|
|
8
|
+
*
|
|
9
|
+
* See the package README for the full integration guide.
|
|
10
|
+
*/
|
|
11
|
+
export { InternalHostLwcShell } from "./InternalHostLwcShell";
|
|
12
|
+
export { InternalHostLwcShell as default } from "./InternalHostLwcShell";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|