@3dsource/metabox-modular-configurator-api 3.0.37 → 3.0.39
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/CHANGELOG.md +40 -0
- package/README.md +85 -39
- package/fesm2022/3dsource-metabox-modular-configurator-api.mjs +30 -10
- package/fesm2022/3dsource-metabox-modular-configurator-api.mjs.map +1 -1
- package/llms.txt +2 -0
- package/package.json +2 -2
- package/types/3dsource-metabox-modular-configurator-api.d.ts +95 -82
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Changelog — @3dsource/metabox-modular-configurator-api
|
|
2
|
+
|
|
3
|
+
Write free-form context in the **Unreleased** section before releasing. `release:package`
|
|
4
|
+
closes it into the version it publishes, and the package ships this file; the release note
|
|
5
|
+
in ClickUp opens with the text of every version that went live, followed by a structural
|
|
6
|
+
diff of the public `.d.ts`. Leaving it empty is fine: the diff still makes a complete note.
|
|
7
|
+
See `PUBLISH.md`.
|
|
8
|
+
|
|
9
|
+
## Unreleased
|
|
10
|
+
|
|
11
|
+
## 3.0.39 — 23 November 2026
|
|
12
|
+
|
|
13
|
+
`config.domain` written with a scheme now works: `https://staging.example.com` is used as is, where it used to become the host `https` and load nothing. An `http://` domain is rejected with the HTTPS error. The configurator id is URL-encoded, a `state` that is not URI-encoded no longer throws, and container ids such as React's `:r1:` get their size styles.
|
|
14
|
+
|
|
15
|
+
A listener or `apiReadyCallback` that throws no longer breaks the API: the other listeners still run and the handshake is not repeated. The error is still reported to `window.onerror`.
|
|
16
|
+
|
|
17
|
+
New `ModularRouteUrl` constant; `BasicRouteUrl`, which held the modular route, is deprecated and kept as an alias. The examples in the type declarations use `integrateMetabox()` instead of the old `window.env3DSource.apiReady`, and the README now covers `pdfStatusChanged`, `ctaStatusChanged`, the cancel function returned by `integrateMetabox()` and cleanup. `llms.txt` links the Markdown API reference.
|
|
18
|
+
|
|
19
|
+
## 3.0.38 — 10 November 2026
|
|
20
|
+
|
|
21
|
+
Every command now carries `userActivated`: true when it is sent within a few seconds of a real click or key press on the host page. Metabox records configurator analytics for embed API commands only when it is true, so commands a site sends on load are no longer counted as a shopper's choice. Nothing changes for the host code.
|
|
22
|
+
|
|
23
|
+
## 3.0.37 — 7 October 2026
|
|
24
|
+
|
|
25
|
+
`integrateMetabox` adds the `tools` permission to the iframe in browsers that support WebMCP, so an in-browser AI agent on the host page can reach the configurator's agent tools. Other browsers keep the previous `allow` list.
|
|
26
|
+
|
|
27
|
+
New `configuratorNotFound` event: Metabox deployments with the updated contract send it when the configurator id does not exist, so a host that shows its own loading UI can stop waiting. Commands and methods are unchanged; older deployments do not send it.
|
|
28
|
+
|
|
29
|
+
The package now ships `llms.txt`, a short index for AI coding agents that points at the README sections and the type declarations (also served by jsDelivr next to the package).
|
|
30
|
+
|
|
31
|
+
## 3.0.36 — 31 August 2026
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- `CtaStatus` (type) — Lifecycle of the workflow.
|
|
36
|
+
- `FromMetaboxMessagePayloads.ctaStatusChanged` — Dispatches as a GetCallToActionInformation() workflow starts, completes or fails. MetaBox handles the redirect itself; this only reports progress.
|
|
37
|
+
- `FromMetaboxMessagePayloads.pdfStatusChanged` — Dispatches as a GetPdf() render starts, finishes or fails. The document is delivered by the browser download either way; this only reports progress.
|
|
38
|
+
- `PdfStatus` (type) — Lifecycle of a render.
|
|
39
|
+
|
|
40
|
+
---
|
package/README.md
CHANGED
|
@@ -93,7 +93,7 @@ npm install @3dsource/metabox-modular-configurator-api@latest --save
|
|
|
93
93
|
**Import:**
|
|
94
94
|
|
|
95
95
|
```typescript
|
|
96
|
-
import { integrateMetabox, Communicator, ModularConfiguratorEnvelope, SetComponent, SetComponentMaterial, SetEnvironment, GetScreenshot, saveImage } from '@3dsource/metabox-modular-configurator-api';
|
|
96
|
+
import { integrateMetabox, Communicator, type ModularConfiguratorEnvelope, SetComponent, SetComponentMaterial, SetEnvironment, GetScreenshot, saveImage } from '@3dsource/metabox-modular-configurator-api';
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### CDN Installation (Quick Prototyping)
|
|
@@ -179,7 +179,7 @@ Create a container element where the configurator will be embedded:
|
|
|
179
179
|
#### TypeScript/Angular/React
|
|
180
180
|
|
|
181
181
|
```typescript
|
|
182
|
-
import { integrateMetabox, Communicator, ModularConfiguratorEnvelope, SetEnvironment, ShowOverlayInterface, GetScreenshot, saveImage, SetComponent, SetComponentMaterial, type MimeType, ShowEmbeddedMenu } from '@3dsource/metabox-modular-configurator-api';
|
|
182
|
+
import { integrateMetabox, Communicator, type ModularConfiguratorEnvelope, SetEnvironment, ShowOverlayInterface, GetScreenshot, saveImage, SetComponent, SetComponentMaterial, type MimeType, ShowEmbeddedMenu } from '@3dsource/metabox-modular-configurator-api';
|
|
183
183
|
|
|
184
184
|
class ConfiguratorIntegration {
|
|
185
185
|
private api: Communicator | null = null;
|
|
@@ -342,9 +342,11 @@ Embeds the Metabox Modular Configurator iframe and establishes communication cha
|
|
|
342
342
|
**Signature:**
|
|
343
343
|
|
|
344
344
|
```typescript
|
|
345
|
-
function integrateMetabox(configuratorId: string, containerId: string, apiReadyCallback: (api: Communicator) => void, config?: IntegrateMetaboxConfig): void;
|
|
345
|
+
function integrateMetabox(configuratorId: string, containerId: string, apiReadyCallback: (api: Communicator) => void, config?: IntegrateMetaboxConfig): () => void;
|
|
346
346
|
```
|
|
347
347
|
|
|
348
|
+
**Returns:** a function that stops waiting for the configurator to load. Calling it is optional — a later `integrateMetabox()` call cancels a pending one on its own — but call it on teardown (component destroy, route change) so the handshake listener does not outlive the page. See [Cleanup](#cleanup).
|
|
349
|
+
|
|
348
350
|
**Parameters:**
|
|
349
351
|
|
|
350
352
|
| Parameter | Type | Required | Default | Description |
|
|
@@ -352,7 +354,7 @@ function integrateMetabox(configuratorId: string, containerId: string, apiReadyC
|
|
|
352
354
|
| `configuratorId` | `string` | ✅ | - | Modular configurator UUID (not full URL) |
|
|
353
355
|
| `containerId` | `string` | ✅ | - | DOM container element ID |
|
|
354
356
|
| `apiReadyCallback` | `function` | ✅ | - | Callback invoked when API is ready |
|
|
355
|
-
| `config` | `IntegrateMetaboxConfig` | ❌ |
|
|
357
|
+
| `config` | `IntegrateMetaboxConfig` | ❌ | - | Additional configuration options |
|
|
356
358
|
|
|
357
359
|
**Config Options (`IntegrateMetaboxConfig`):**
|
|
358
360
|
|
|
@@ -669,7 +671,7 @@ Commands control configurator behavior. Send via `api.sendCommandToMetabox(new C
|
|
|
669
671
|
|
|
670
672
|
| Command | Parameters | Description |
|
|
671
673
|
| ------------------------ | --------------------------------------------------------- | ------------------------------------------------------------------------- |
|
|
672
|
-
| `SetComponent` | `
|
|
674
|
+
| `SetComponent` | `id: string, typeId: string` | Add/select component in assembly |
|
|
673
675
|
| `SetComponentMaterial` | `componentId: string, slotId: string, materialId: string` | Apply material to component slot |
|
|
674
676
|
| `SetEnvironment` | `environmentId: string` | Change environment/scene |
|
|
675
677
|
| `SetEnvironmentMaterial` | `slotId: string, materialId: string` | Apply material to environment slot |
|
|
@@ -837,15 +839,15 @@ api.sendCommandToMetabox(new ResetUserInactivityTimer());
|
|
|
837
839
|
|
|
838
840
|
#### Export & Media
|
|
839
841
|
|
|
840
|
-
| Command | Parameters | Description | Event Triggered
|
|
841
|
-
| ---------------------------- | --------------------------------------------------- | -------------------- |
|
|
842
|
-
| `GetScreenshot` | `mimeType: MimeType, size?: {x: number, y: number}` | Render screenshot | `screenshotReady`
|
|
843
|
-
| `GetPdf` | None | Generate PDF export |
|
|
844
|
-
| `GetCallToActionInformation` | None | Trigger CTA workflow |
|
|
842
|
+
| Command | Parameters | Description | Event Triggered |
|
|
843
|
+
| ---------------------------- | --------------------------------------------------- | -------------------- | ------------------ |
|
|
844
|
+
| `GetScreenshot` | `mimeType: MimeType, size?: {x: number, y: number}` | Render screenshot | `screenshotReady` |
|
|
845
|
+
| `GetPdf` | None | Generate PDF export | `pdfStatusChanged` |
|
|
846
|
+
| `GetCallToActionInformation` | None | Trigger CTA workflow | `ctaStatusChanged` |
|
|
845
847
|
|
|
846
848
|
##### `saveImage()`
|
|
847
849
|
|
|
848
|
-
Helper function: triggers a browser download of
|
|
850
|
+
Helper function: triggers a browser download of a screenshot from a base64 data URL (`image/png`, `image/jpeg` or `image/webp`).
|
|
849
851
|
|
|
850
852
|
**Signature:**
|
|
851
853
|
|
|
@@ -855,7 +857,7 @@ function saveImage(imageUrl: string, filename: string): void;
|
|
|
855
857
|
|
|
856
858
|
| Parameter | Type | Description |
|
|
857
859
|
| ---------- | -------- | ----------------------------------- |
|
|
858
|
-
| `imageUrl` | `string` | Base64 data URL
|
|
860
|
+
| `imageUrl` | `string` | Base64 data URL to save |
|
|
859
861
|
| `filename` | `string` | Suggested filename for the download |
|
|
860
862
|
|
|
861
863
|
**Screenshot Example:**
|
|
@@ -864,7 +866,9 @@ function saveImage(imageUrl: string, filename: string): void;
|
|
|
864
866
|
api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 2048, y: 2048 }));
|
|
865
867
|
|
|
866
868
|
api.addEventListener('screenshotReady', (imageData) => {
|
|
867
|
-
|
|
869
|
+
if (imageData) {
|
|
870
|
+
saveImage(imageData, 'assembly.png');
|
|
871
|
+
}
|
|
868
872
|
});
|
|
869
873
|
```
|
|
870
874
|
|
|
@@ -888,6 +892,8 @@ Event-driven architecture for reactive state management. Register listeners via
|
|
|
888
892
|
| `loadingStatusChanged` | `{ percents: number; loaderVisible: boolean }` | Loading progress or overlay changed | Show custom loading progress bar |
|
|
889
893
|
| `userInactivityDetected` | `{ remainingSecondsToDisconnect: number; countdownVisible: boolean }` | AFK countdown started or updated | Show "Stay connected?" prompt |
|
|
890
894
|
| `configuratorNotFound` | `true` | The configurator id does not exist | Show an error instead of waiting |
|
|
895
|
+
| `pdfStatusChanged` | `PdfStatus` (`'started' \| 'ready' \| 'failed'`) | GetPdf render progress | Disable export button, show failure |
|
|
896
|
+
| `ctaStatusChanged` | `CtaStatus` (`'started' \| 'ready' \| 'failed'`) | CTA workflow progress | Disable CTA button, show failure |
|
|
891
897
|
|
|
892
898
|
#### Event Examples
|
|
893
899
|
|
|
@@ -967,21 +973,43 @@ api.addEventListener('loadingStatusChanged', ({ percents, loaderVisible }) => {
|
|
|
967
973
|
**AFK Inactivity Countdown:**
|
|
968
974
|
|
|
969
975
|
```typescript
|
|
970
|
-
import { ResetUserInactivityTimer } from '@3dsource/metabox-modular-configurator-api';
|
|
976
|
+
import { integrateMetabox, ResetUserInactivityTimer } from '@3dsource/metabox-modular-configurator-api';
|
|
977
|
+
|
|
978
|
+
integrateMetabox('configurator-id', 'embed3DSource', (api) => {
|
|
979
|
+
api.addEventListener('userInactivityDetected', ({ remainingSecondsToDisconnect, countdownVisible }) => {
|
|
980
|
+
const dialog = document.getElementById('afk-dialog');
|
|
981
|
+
const countdown = document.getElementById('afk-countdown');
|
|
971
982
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
983
|
+
if (dialog) dialog.style.display = countdownVisible ? 'flex' : 'none';
|
|
984
|
+
if (countdown) countdown.textContent = String(remainingSecondsToDisconnect);
|
|
985
|
+
});
|
|
975
986
|
|
|
976
|
-
|
|
977
|
-
|
|
987
|
+
document.getElementById('stay-connected-btn')?.addEventListener('click', () => {
|
|
988
|
+
api.sendCommandToMetabox(new ResetUserInactivityTimer());
|
|
989
|
+
});
|
|
978
990
|
});
|
|
991
|
+
```
|
|
992
|
+
|
|
993
|
+
#### Cleanup
|
|
994
|
+
|
|
995
|
+
There is no single `destroy()` for application code. On teardown:
|
|
979
996
|
|
|
980
|
-
|
|
981
|
-
|
|
997
|
+
```typescript
|
|
998
|
+
const cancel = integrateMetabox(configuratorId, containerId, (api) => {
|
|
999
|
+
api.addEventListener('configuratorDataUpdated', onData);
|
|
1000
|
+
apiRef = api;
|
|
982
1001
|
});
|
|
1002
|
+
|
|
1003
|
+
// later, on component destroy / route change
|
|
1004
|
+
cancel(); // stops waiting if the configurator has not loaded yet
|
|
1005
|
+
apiRef?.removeEventListener('configuratorDataUpdated', onData); // same function reference
|
|
983
1006
|
```
|
|
984
1007
|
|
|
1008
|
+
- `removeEventListener(event, handler)` needs the same function reference you passed to `addEventListener`.
|
|
1009
|
+
- With `fromCommunicatorEvent`, unsubscribe the RxJS subscription (`takeUntil`, `takeUntilDestroyed`).
|
|
1010
|
+
- `Communicator.clearAll()` removes every listener of every instance on the page — use it only when the page owns the only configurator.
|
|
1011
|
+
- Calling `integrateMetabox()` again replaces the iframe (`#embeddedContent`). Keep the `api` from the latest call; an old handle warns in the console.
|
|
1012
|
+
|
|
985
1013
|
### Utility Functions
|
|
986
1014
|
|
|
987
1015
|
#### `saveImage(imageUrl: string, filename: string): void`
|
|
@@ -1014,23 +1042,23 @@ Creates a temporary anchor element with `download` attribute to trigger browser
|
|
|
1014
1042
|
warning instead of being downloaded, since this function is fed event payloads
|
|
1015
1043
|
straight off the postMessage channel.
|
|
1016
1044
|
|
|
1017
|
-
#### `fromCommunicatorEvent(target: Communicator, eventName:
|
|
1045
|
+
#### `fromCommunicatorEvent(target: Communicator, eventName: FromMetaBoxApiEvents): Observable<FromMetaboxMessagePayloads[eventName]>`
|
|
1018
1046
|
|
|
1019
1047
|
RxJS wrapper for Communicator events. Works like RxJS `fromEvent` — creates a typed Observable that emits each time the specified event fires. Alternative to `api.addEventListener()`.
|
|
1020
1048
|
|
|
1021
1049
|
**Parameters:**
|
|
1022
1050
|
|
|
1023
|
-
| Parameter | Type
|
|
1024
|
-
| ----------- |
|
|
1025
|
-
| `target` | `Communicator`
|
|
1026
|
-
| `eventName` | `
|
|
1051
|
+
| Parameter | Type | Description |
|
|
1052
|
+
| ----------- | ---------------------- | ---------------------------------------------------------------------- |
|
|
1053
|
+
| `target` | `Communicator` | The Communicator instance to listen on |
|
|
1054
|
+
| `eventName` | `FromMetaBoxApiEvents` | One of the event names listed in [Available Events](#available-events) |
|
|
1027
1055
|
|
|
1028
1056
|
**Returns:** `Observable<T>` — typed Observable matching the event payload.
|
|
1029
1057
|
|
|
1030
1058
|
**Example:**
|
|
1031
1059
|
|
|
1032
1060
|
```typescript
|
|
1033
|
-
import { fromCommunicatorEvent } from '@3dsource/metabox-modular-configurator-api';
|
|
1061
|
+
import { fromCommunicatorEvent, integrateMetabox, saveImage } from '@3dsource/metabox-modular-configurator-api';
|
|
1034
1062
|
|
|
1035
1063
|
integrateMetabox('configurator-id', 'embed3DSource', (api) => {
|
|
1036
1064
|
fromCommunicatorEvent(api, 'configuratorDataUpdated').subscribe((data) => {
|
|
@@ -1116,7 +1144,7 @@ To create a custom modular configurator interface, use [standalone mode](#standa
|
|
|
1116
1144
|
**Core Pattern:**
|
|
1117
1145
|
|
|
1118
1146
|
```typescript
|
|
1119
|
-
import { integrateMetabox, Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
|
|
1147
|
+
import { integrateMetabox, Communicator, type ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
|
|
1120
1148
|
|
|
1121
1149
|
integrateMetabox(
|
|
1122
1150
|
'configurator-uuid',
|
|
@@ -1166,14 +1194,32 @@ This produces a single ordered list interleaved as: **Type1 selector → Type1 m
|
|
|
1166
1194
|
|
|
1167
1195
|
```typescript
|
|
1168
1196
|
import { computed, signal } from '@angular/core';
|
|
1169
|
-
import type { Communicator, ModularConfiguratorEnvelope
|
|
1197
|
+
import type { Communicator, ModularConfiguratorEnvelope } from '@3dsource/metabox-modular-configurator-api';
|
|
1170
1198
|
import { fromCommunicatorEvent, SetComponent, SetComponentMaterial } from '@3dsource/metabox-modular-configurator-api';
|
|
1171
1199
|
|
|
1200
|
+
interface MenuOption {
|
|
1201
|
+
label: string;
|
|
1202
|
+
id: string;
|
|
1203
|
+
image?: string;
|
|
1204
|
+
action: () => void;
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
interface MenuEntry {
|
|
1208
|
+
id: string;
|
|
1209
|
+
category: string;
|
|
1210
|
+
options: MenuOption[];
|
|
1211
|
+
selectedId?: string;
|
|
1212
|
+
selectedLabel?: string;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1172
1215
|
// Store envelope data as a signal (updated on each configuratorDataUpdated event)
|
|
1173
1216
|
const envelope = signal<ModularConfiguratorEnvelope | null>(null);
|
|
1217
|
+
// The API handle, kept so menu actions can send commands
|
|
1218
|
+
const apiHandle = signal<Communicator | null>(null);
|
|
1174
1219
|
|
|
1175
1220
|
// Subscribe to API events
|
|
1176
1221
|
function listenApi(api: Communicator) {
|
|
1222
|
+
apiHandle.set(api);
|
|
1177
1223
|
fromCommunicatorEvent(api, 'configuratorDataUpdated').subscribe((data) => {
|
|
1178
1224
|
envelope.set(data);
|
|
1179
1225
|
});
|
|
@@ -1203,7 +1249,7 @@ const menuTree = computed(() => {
|
|
|
1203
1249
|
label: item.name,
|
|
1204
1250
|
id: item.id,
|
|
1205
1251
|
image: item.product.thumbnailList[0]?.urlPath,
|
|
1206
|
-
action: () =>
|
|
1252
|
+
action: () => apiHandle()?.sendCommandToMetabox(new SetComponent(item.id, ct.id)),
|
|
1207
1253
|
})),
|
|
1208
1254
|
selectedId: activeComponentId,
|
|
1209
1255
|
selectedLabel: activeComponent?.name,
|
|
@@ -1222,7 +1268,7 @@ const menuTree = computed(() => {
|
|
|
1222
1268
|
label: mat.title,
|
|
1223
1269
|
id: mat.id,
|
|
1224
1270
|
image: mat.thumbnailList[0]?.urlPath,
|
|
1225
|
-
action: () =>
|
|
1271
|
+
action: () => apiHandle()?.sendCommandToMetabox(new SetComponentMaterial(activeComponent.id, slot.id, mat.id)),
|
|
1226
1272
|
})),
|
|
1227
1273
|
selectedId: selectedMaterialId,
|
|
1228
1274
|
selectedLabel: slot.enabledMaterials.find((m) => m.id === selectedMaterialId)?.title,
|
|
@@ -1267,13 +1313,13 @@ api.sendCommandToMetabox(new GetCallToActionInformation());
|
|
|
1267
1313
|
|
|
1268
1314
|
**Root Causes & Solutions:**
|
|
1269
1315
|
|
|
1270
|
-
| Issue | Diagnostic
|
|
1271
|
-
| --------------------------- |
|
|
1272
|
-
| Invalid configurator ID | Browser console shows 404 errors
|
|
1273
|
-
| Container not found | `Error: Container element not found` | Ensure element exists before calling `integrateMetabox()` |
|
|
1274
|
-
| HTTP instead of HTTPS | Mixed content warnings
|
|
1275
|
-
| Container has no dimensions | Invisible iframe (0x0)
|
|
1276
|
-
| CORS/iframe blocking | X-Frame-Options errors
|
|
1316
|
+
| Issue | Diagnostic | Solution |
|
|
1317
|
+
| --------------------------- | ------------------------------------------------- | --------------------------------------------------------- |
|
|
1318
|
+
| Invalid configurator ID | Browser console shows 404 errors | Verify modular configurator ID in Metabox admin |
|
|
1319
|
+
| Container not found | `Error: Container element with id <id> not found` | Ensure element exists before calling `integrateMetabox()` |
|
|
1320
|
+
| HTTP instead of HTTPS | Mixed content warnings | Use HTTPS or test on localhost |
|
|
1321
|
+
| Container has no dimensions | Invisible iframe (0x0) | Set explicit width/height on container element |
|
|
1322
|
+
| CORS/iframe blocking | X-Frame-Options errors | Check domain allowlist in Metabox settings |
|
|
1277
1323
|
|
|
1278
1324
|
**Diagnostic Code:**
|
|
1279
1325
|
|
|
@@ -1346,7 +1392,7 @@ If you're still experiencing issues:
|
|
|
1346
1392
|
- **Debounce rapid commands.** Avoid sending too many commands in quick succession — debounce material or component changes (e.g., 300 ms). When several materials change together, send them as one `SetMaterials` batch instead of debouncing individual commands.
|
|
1347
1393
|
- **Responsive container.** Set the configurator container to responsive dimensions (`width: 100%; height: 100%;`) and adjust with media queries for mobile.
|
|
1348
1394
|
- **Events work in all modes.** `configuratorDataUpdated`, `screenshotReady`, and other events fire in both default and standalone mode — use them to keep your UI synchronized.
|
|
1349
|
-
- **Wait for API ready.** Only send commands inside the `apiReadyCallback
|
|
1395
|
+
- **Wait for API ready.** Only send commands inside the `apiReadyCallback` — the `api` handle does not exist before it fires.
|
|
1350
1396
|
- **Validate IDs from events.** Use the `configuratorDataUpdated` event payload to discover valid component, material, and slot IDs rather than hardcoding them.
|
|
1351
1397
|
- **HTTPS is required.** The iframe URL enforces HTTPS. HTTP URLs will be rejected. Use `localhost` for local development.
|
|
1352
1398
|
- **Pin CDN versions in production.** Replace `@latest` with a specific version to avoid unexpected breaking changes.
|
|
@@ -245,6 +245,10 @@ var ResetUserInactivityTimer = class extends CommandBase {
|
|
|
245
245
|
this.data = { action: MetaboxModularConfiguratorActions.resetUserInactivityTimer };
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
|
+
function reportListenerError(error) {
|
|
249
|
+
if (typeof globalThis.reportError === "function") globalThis.reportError(error);
|
|
250
|
+
else console.error(error);
|
|
251
|
+
}
|
|
248
252
|
var EventDispatcher = class {
|
|
249
253
|
constructor() {
|
|
250
254
|
this.listeners = [];
|
|
@@ -264,7 +268,11 @@ var EventDispatcher = class {
|
|
|
264
268
|
const len = listeners.length;
|
|
265
269
|
for (let i = 0; i < len; i++) {
|
|
266
270
|
const listener = listeners[i];
|
|
267
|
-
if (listener.messageType === messageType)
|
|
271
|
+
if (listener.messageType === messageType) try {
|
|
272
|
+
listener.callback(data);
|
|
273
|
+
} catch (error) {
|
|
274
|
+
reportListenerError(error);
|
|
275
|
+
}
|
|
268
276
|
}
|
|
269
277
|
return this;
|
|
270
278
|
}
|
|
@@ -276,12 +284,13 @@ var EventDispatcher = class {
|
|
|
276
284
|
const Metabox = "metabox";
|
|
277
285
|
const MetaboxHost = "metaboxHost";
|
|
278
286
|
const AppLoaded = "appLoaded";
|
|
287
|
+
const MetaboxDomain = "metabox.3dsource.com";
|
|
279
288
|
const Metabox_V3 = "metabox_v3";
|
|
280
289
|
const MetaboxHost_V3 = "metaboxHost_v3";
|
|
281
290
|
const AppLoaded_V3 = "appLoaded_v3";
|
|
282
|
-
const
|
|
283
|
-
const BasicRouteUrl =
|
|
284
|
-
const VERSION = "3.0.
|
|
291
|
+
const ModularRouteUrl = "metabox-configurator/modular";
|
|
292
|
+
const BasicRouteUrl = ModularRouteUrl;
|
|
293
|
+
const VERSION = "3.0.39";
|
|
285
294
|
const EmbeddedContentId = "embeddedContent";
|
|
286
295
|
function isTargetableOrigin(origin) {
|
|
287
296
|
if (!origin || origin === "*" || origin === "null") return false;
|
|
@@ -344,11 +353,11 @@ var Communicator = class Communicator extends EventDispatcher {
|
|
|
344
353
|
}
|
|
345
354
|
return;
|
|
346
355
|
}
|
|
356
|
+
window.removeEventListener("message", startHandler);
|
|
347
357
|
apiReadyCallback(new Communicator(message.envelope.payload, environment, config, {
|
|
348
358
|
iframe,
|
|
349
359
|
origin: Communicator.resolveHandshakeOrigin(event, connection)
|
|
350
360
|
}));
|
|
351
|
-
window.removeEventListener("message", startHandler);
|
|
352
361
|
};
|
|
353
362
|
window.addEventListener("message", startHandler);
|
|
354
363
|
return () => window.removeEventListener("message", startHandler);
|
|
@@ -383,7 +392,8 @@ var Communicator = class Communicator extends EventDispatcher {
|
|
|
383
392
|
envelope: { ...data },
|
|
384
393
|
payload: { ...data },
|
|
385
394
|
target: iframe?.contentWindow ? "child" : "metabox",
|
|
386
|
-
apiVersion: VERSION
|
|
395
|
+
apiVersion: VERSION,
|
|
396
|
+
userActivated: navigator.userActivation?.isActive ?? false
|
|
387
397
|
};
|
|
388
398
|
if (!iframe?.contentWindow) {
|
|
389
399
|
console.warn("Metabox IFrame not found or not ready. Message sends to the same window");
|
|
@@ -428,12 +438,12 @@ var Communicator = class Communicator extends EventDispatcher {
|
|
|
428
438
|
}
|
|
429
439
|
};
|
|
430
440
|
const prepareIframeSrc = (configuratorId, config) => {
|
|
431
|
-
const base =
|
|
441
|
+
const base = `${toOrigin(config?.domain || "metabox.3dsource.com")}/${ModularRouteUrl}/${encodeURIComponent(configuratorId)}`;
|
|
432
442
|
const params = new URLSearchParams();
|
|
433
443
|
if (config?.introImage) params.set("introImage", config.introImage);
|
|
434
444
|
if (config?.introVideo) params.set("introVideo", config.introVideo);
|
|
435
445
|
if (config?.loadingImage) params.set("loadingImage", config.loadingImage);
|
|
436
|
-
if (config?.state) params.set("state",
|
|
446
|
+
if (config?.state) params.set("state", decodeOnce(config.state));
|
|
437
447
|
if (config?.showLoadingProgress !== void 0) params.set("showLoadingProgress", String(config.showLoadingProgress));
|
|
438
448
|
if (config?.showResumeStreamPopup !== void 0) params.set("showResumeStreamPopup", String(config.showResumeStreamPopup));
|
|
439
449
|
if (config?.showUserInactivityTimer !== void 0) params.set("showUserInactivityTimer", String(config.showUserInactivityTimer));
|
|
@@ -442,6 +452,16 @@ const prepareIframeSrc = (configuratorId, config) => {
|
|
|
442
452
|
const query = params.toString();
|
|
443
453
|
return query ? `${base}?${query}` : base;
|
|
444
454
|
};
|
|
455
|
+
function toOrigin(domain) {
|
|
456
|
+
return /^[a-z][a-z\d+.-]*:\/\//i.test(domain) ? domain.replace(/\/+$/, "") : `https://${domain}`;
|
|
457
|
+
}
|
|
458
|
+
function decodeOnce(state) {
|
|
459
|
+
try {
|
|
460
|
+
return decodeURIComponent(state);
|
|
461
|
+
} catch {
|
|
462
|
+
return state;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
445
465
|
let cancelPendingHandshake = null;
|
|
446
466
|
const BASE_PERMISSIONS = "autoplay; fullscreen; encrypted-media";
|
|
447
467
|
const iframePermissions = () => "modelContext" in document || "modelContext" in navigator ? `${BASE_PERMISSIONS}; tools` : BASE_PERMISSIONS;
|
|
@@ -472,7 +492,7 @@ function integrateMetabox(configuratorId, containerId, apiReadyCallback, config)
|
|
|
472
492
|
const style = document.createElement("style");
|
|
473
493
|
style.id = styleId;
|
|
474
494
|
style.innerHTML = `
|
|
475
|
-
#${containerId} {
|
|
495
|
+
#${CSS.escape(containerId)} {
|
|
476
496
|
width: 100%;
|
|
477
497
|
height: 100%;
|
|
478
498
|
overflow: hidden;
|
|
@@ -507,6 +527,6 @@ function saveImage(imageUrl, filename) {
|
|
|
507
527
|
function isScreenshotDataUrl(value) {
|
|
508
528
|
return /^data:image\/(?:png|jpeg|webp);base64,[A-Za-z0-9+/]+={0,2}$/i.test(value);
|
|
509
529
|
}
|
|
510
|
-
export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, MetaboxModularConfiguratorActions, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, ResetConfiguration, ResetUserInactivityTimer, ResumeStream, SetCamera, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, SetMaterials, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, StopStream, UnrealCommand, VERSION, fromCommunicatorEvent, integrateMetabox, prepareIframeSrc, saveImage };
|
|
530
|
+
export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, MetaboxModularConfiguratorActions, Metabox_V3, ModularRouteUrl, PauseShowcase, PlayShowcase, ResetCamera, ResetConfiguration, ResetUserInactivityTimer, ResumeStream, SetCamera, SetComponent, SetComponentMaterial, SetEnvironment, SetEnvironmentMaterial, SetMaterials, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, StopStream, UnrealCommand, VERSION, fromCommunicatorEvent, integrateMetabox, prepareIframeSrc, saveImage };
|
|
511
531
|
|
|
512
532
|
//# sourceMappingURL=3dsource-metabox-modular-configurator-api.mjs.map
|