@lightning-out/lwc-shell 2.2.0-rc.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 +137 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.esm.js +791 -0
- package/dist/index.iife.js +801 -0
- package/dist/index.iife.prod.js +3 -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 +151 -0
- package/package.json +45 -0
- package/scripts/templates/vendor-banner.js +2 -0
- package/scripts/templates/vendor-meta.xml +5 -0
- package/scripts/vendor-build.mjs +76 -0
package/README.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# @lightning-out/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 with unsaved-changes confirmation modal
|
|
11
|
+
- Framework-agnostic — extends `HTMLElement` directly
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
| Document | Description |
|
|
16
|
+
|---|---|
|
|
17
|
+
| [LWC_SHELL_WEB_COMPONENT_API.md](./LWC_SHELL_WEB_COMPONENT_API.md) | Full specification of the `<lwc-shell>` web component — attributes, properties, methods, events, and sandbox security. |
|
|
18
|
+
| [LWC_SHELL_WRAPPER_GUIDE.md](./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
|
+
|
|
20
|
+
## Package Contents
|
|
21
|
+
|
|
22
|
+
| Path | Purpose |
|
|
23
|
+
|---|---|
|
|
24
|
+
| `src/InternalHostLwcShell.ts` | Core web component implementation (`<lwc-shell>` custom element). |
|
|
25
|
+
| `src/utils/` | Shared utilities — symbol keys, dirty-state contract, GUID generator. |
|
|
26
|
+
| `src/lwc/` | Source LWC components (e.g. `dirtyStateModal`) that are vendored into consumer projects. |
|
|
27
|
+
| `scripts/vendor-build.js` | CLI tool (`lwc-shell-vendor-build`) that copies built artifacts as vendor-prefixed LWC components. |
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* InternalHostLwcShell
|
|
3
|
+
*
|
|
4
|
+
* A standard Web Component (custom element) that embeds an iframe-based widget
|
|
5
|
+
* with bridge communication, sandbox management, fullscreen support, and
|
|
6
|
+
* dirty-state tracking.
|
|
7
|
+
*
|
|
8
|
+
* Registered as `<lwc-shell>`.
|
|
9
|
+
*
|
|
10
|
+
* Ported from the LWC `widgetContainerLo` component (formerly known as
|
|
11
|
+
* WidgetContainer) — all Lightning Web Component framework dependencies have
|
|
12
|
+
* been removed so this can run as a plain custom element inside any LWC host.
|
|
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 `productRegistrationWidgetLo` demo for a full recipe.
|
|
22
|
+
*/
|
|
23
|
+
import { DoCloseConfirmation, Guid } from "./utils";
|
|
24
|
+
interface DirtyStateModalButton {
|
|
25
|
+
buttonKey: string;
|
|
26
|
+
buttonLabel: string;
|
|
27
|
+
buttonVariant?: string;
|
|
28
|
+
}
|
|
29
|
+
interface DirtyStateModalFields {
|
|
30
|
+
label?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
buttons?: DirtyStateModalButton[];
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Represents a LightningModal-style class with a static `.open()` method.
|
|
36
|
+
*/
|
|
37
|
+
interface DirtyStateModalClass {
|
|
38
|
+
open(config: {
|
|
39
|
+
modalFields?: DirtyStateModalFields;
|
|
40
|
+
size?: string;
|
|
41
|
+
}): Promise<string | undefined>;
|
|
42
|
+
}
|
|
43
|
+
export declare class InternalHostLwcShell extends HTMLElement {
|
|
44
|
+
private _shadow;
|
|
45
|
+
private _iframe;
|
|
46
|
+
private _container;
|
|
47
|
+
private _currentState;
|
|
48
|
+
private _hasExplicitResize;
|
|
49
|
+
private _readinessTimeout;
|
|
50
|
+
private _isFullscreen;
|
|
51
|
+
private _lastThemeData;
|
|
52
|
+
private _lastPayloadData;
|
|
53
|
+
private _bridgeReady;
|
|
54
|
+
private _hasSentTheme;
|
|
55
|
+
private _hasSentData;
|
|
56
|
+
private _src;
|
|
57
|
+
private _srcdoc;
|
|
58
|
+
private _sandbox;
|
|
59
|
+
private _title;
|
|
60
|
+
private _view;
|
|
61
|
+
private _dirtyComponentGuid;
|
|
62
|
+
private _beforeUnloadHandler;
|
|
63
|
+
private _dirtyStateModal;
|
|
64
|
+
private _pendingDirtyActions;
|
|
65
|
+
private _debugEnabled;
|
|
66
|
+
static get observedAttributes(): string[];
|
|
67
|
+
constructor();
|
|
68
|
+
connectedCallback(): void;
|
|
69
|
+
disconnectedCallback(): void;
|
|
70
|
+
attributeChangedCallback(name: string, oldVal: string | null, newVal: string | null): void;
|
|
71
|
+
get src(): string | null;
|
|
72
|
+
set src(v: string | null);
|
|
73
|
+
get srcdoc(): string | null;
|
|
74
|
+
set srcdoc(v: string | null);
|
|
75
|
+
get sandbox(): string | null;
|
|
76
|
+
set sandbox(v: string | null);
|
|
77
|
+
get title(): string;
|
|
78
|
+
set title(v: string | null);
|
|
79
|
+
get view(): string | null;
|
|
80
|
+
set view(v: string | null);
|
|
81
|
+
/**
|
|
82
|
+
* Controls debug logging. Toggle via:
|
|
83
|
+
* - HTML attribute: `<lwc-shell debug>`
|
|
84
|
+
* - Programmatically: `shell.debug = true`
|
|
85
|
+
*/
|
|
86
|
+
get debug(): boolean;
|
|
87
|
+
set debug(v: boolean);
|
|
88
|
+
get _SelfManagedDirtyComponent(): Readonly<{
|
|
89
|
+
DoCloseConfirmation: typeof DoCloseConfirmation;
|
|
90
|
+
Guid: typeof Guid;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* The LightningModal class used to show the unsaved-changes confirmation.
|
|
94
|
+
* Wrapper LWC sets this via: `shell.dirtyStateModal = DirtyStateModal;`
|
|
95
|
+
* where `DirtyStateModal` is the class imported from `'c/dirtyStateModal'`.
|
|
96
|
+
*/
|
|
97
|
+
get dirtyStateModal(): DirtyStateModalClass | null;
|
|
98
|
+
set dirtyStateModal(v: DirtyStateModalClass | null);
|
|
99
|
+
updateData(newData: Record<string, unknown>): void;
|
|
100
|
+
refreshTheme(): void;
|
|
101
|
+
private get _isFullView();
|
|
102
|
+
private get _frameClass();
|
|
103
|
+
private _log;
|
|
104
|
+
private _renderInitial;
|
|
105
|
+
private _updateContainerState;
|
|
106
|
+
private _updateTitle;
|
|
107
|
+
private _updateViewDOM;
|
|
108
|
+
private _setState;
|
|
109
|
+
private _setupMessageListener;
|
|
110
|
+
private _handleMessage;
|
|
111
|
+
private _dispatchSelfManagedDirtyEvent;
|
|
112
|
+
private _toggleBeforeUnload;
|
|
113
|
+
private _handleDirtyStateDetected;
|
|
114
|
+
private _handleDirtyStateReset;
|
|
115
|
+
private _handleDirtyStateModalStatus;
|
|
116
|
+
private _handleResize;
|
|
117
|
+
private _handleWidgetReady;
|
|
118
|
+
private _handleFullscreenRequest;
|
|
119
|
+
private _enterFullscreen;
|
|
120
|
+
private _exitFullscreen;
|
|
121
|
+
private _handleBridgeReady;
|
|
122
|
+
private _handleBridgeError;
|
|
123
|
+
private _handleContainerClick;
|
|
124
|
+
private _applySandbox;
|
|
125
|
+
private _computeSandboxTokens;
|
|
126
|
+
private _updateIframeSrc;
|
|
127
|
+
private _handleIframeLoad;
|
|
128
|
+
private _handleIframeError;
|
|
129
|
+
private _postToIframe;
|
|
130
|
+
private _collectDataAttributes;
|
|
131
|
+
private _sendInitialTheme;
|
|
132
|
+
private _sendInitialData;
|
|
133
|
+
[Guid]: string;
|
|
134
|
+
[DoCloseConfirmation](): Promise<"SUCCESS" | "CANCEL" | "ERROR">;
|
|
135
|
+
}
|
|
136
|
+
export {};
|
|
137
|
+
//# sourceMappingURL=InternalHostLwcShell.d.ts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @lightning-out/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
|