@3dsource/metabox-front-api 0.0.3 → 0.0.5
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 +1 -1
- package/dist/actions/ApiAction.d.ts +4 -0
- package/dist/actions/ApiAction.js +10 -0
- package/dist/actions/GetFastRender.d.ts +55 -0
- package/dist/actions/GetFastRender.js +61 -0
- package/dist/actions/GetPdf.d.ts +40 -0
- package/dist/actions/GetPdf.js +51 -0
- package/dist/actions/SetEnvironment.d.ts +31 -0
- package/dist/actions/SetEnvironment.js +45 -0
- package/dist/actions/SetMaterial.d.ts +49 -0
- package/dist/actions/SetMaterial.js +65 -0
- package/dist/actions/SetProduct.d.ts +15 -0
- package/dist/actions/SetProduct.js +29 -0
- package/dist/actions/ShowEmbeddedMenu.d.ts +15 -0
- package/dist/actions/ShowEmbeddedMenu.js +29 -0
- package/dist/actions/WatchCallbacks.d.ts +16 -0
- package/dist/actions/WatchCallbacks.js +27 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +20 -0
- package/dist/interfaces/FromMetaboxMessagePayloads.d.ts +130 -0
- package/dist/interfaces/FromMetaboxMessagePayloads.js +46 -0
- package/dist/interfaces/ToMetaboxMessagePayloads.d.ts +53 -0
- package/dist/interfaces/ToMetaboxMessagePayloads.js +17 -0
- package/dist/interfaces/UniversalConfigurator.d.ts +152 -0
- package/dist/interfaces/UniversalConfigurator.js +6 -0
- package/dist/lib/UrlUtils.d.ts +18 -0
- package/dist/lib/UrlUtils.js +37 -0
- package/dist/lib/initializeCommunicator.d.ts +87 -0
- package/dist/lib/initializeCommunicator.js +133 -0
- package/dist/lib/integrateMetaBox.d.ts +24 -0
- package/dist/lib/integrateMetaBox.js +55 -0
- package/dist/lib/saveImage.d.ts +11 -0
- package/dist/lib/saveImage.js +23 -0
- package/dist/lib/sleep.d.ts +10 -0
- package/dist/lib/sleep.js +17 -0
- package/package.json +4 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integrates the MetaBox into the provided layout.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This function injects an iframe into a specified container element in the DOM and initializes
|
|
6
|
+
* the communicator for interacting with the MetaBox embedded content.
|
|
7
|
+
*
|
|
8
|
+
* @param iframeSrc - The source URL of the MetaBox iframe.
|
|
9
|
+
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
10
|
+
*
|
|
11
|
+
* @throws Error if the container element with the specified ID is not found.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
*
|
|
15
|
+
* import {
|
|
16
|
+
* integrateMetaBox,
|
|
17
|
+
* } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
18
|
+
*
|
|
19
|
+
* integrateMetaBox(
|
|
20
|
+
* 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
|
|
21
|
+
* 'embed3DSource'
|
|
22
|
+
* );
|
|
23
|
+
*/
|
|
24
|
+
export declare function integrateMetaBox(iframeSrc: string, containerId?: string): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025.
|
|
3
|
+
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*/
|
|
6
|
+
import { Communicator } from './initializeCommunicator';
|
|
7
|
+
/**
|
|
8
|
+
* Integrates the MetaBox into the provided layout.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* This function injects an iframe into a specified container element in the DOM and initializes
|
|
12
|
+
* the communicator for interacting with the MetaBox embedded content.
|
|
13
|
+
*
|
|
14
|
+
* @param iframeSrc - The source URL of the MetaBox iframe.
|
|
15
|
+
* @param containerId - The ID of the layout element. Defaults to 'embed3DSource'.
|
|
16
|
+
*
|
|
17
|
+
* @throws Error if the container element with the specified ID is not found.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* import {
|
|
22
|
+
* integrateMetaBox,
|
|
23
|
+
* } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
|
|
24
|
+
*
|
|
25
|
+
* integrateMetaBox(
|
|
26
|
+
* 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
|
|
27
|
+
* 'embed3DSource'
|
|
28
|
+
* );
|
|
29
|
+
*/
|
|
30
|
+
export function integrateMetaBox(iframeSrc, containerId = 'embed3DSource') {
|
|
31
|
+
const container = document.getElementById(containerId);
|
|
32
|
+
if (!container) {
|
|
33
|
+
throw new Error(`Container element with id ${containerId} not found`);
|
|
34
|
+
}
|
|
35
|
+
Communicator.createInstance();
|
|
36
|
+
const style = document.createElement('style');
|
|
37
|
+
style.innerHTML = `
|
|
38
|
+
#${containerId} {
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
overflow: hidden;
|
|
42
|
+
position: relative;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
document.head.appendChild(style);
|
|
46
|
+
const iframe = document.createElement('iframe');
|
|
47
|
+
iframe.setAttribute('referrerPolicy', 'no-referrer-when-downgrade');
|
|
48
|
+
iframe.setAttribute('id', 'embeddedContent');
|
|
49
|
+
iframe.style.border = '0';
|
|
50
|
+
iframe.style.width = '100%';
|
|
51
|
+
iframe.style.height = '100%';
|
|
52
|
+
iframe.style.overflow = 'hidden';
|
|
53
|
+
iframe.src = iframeSrc;
|
|
54
|
+
container.appendChild(iframe);
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Saves an image by triggering a download.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This function creates an anchor element, sets its `href` attribute to the provided image URL,
|
|
6
|
+
* and triggers a click event to initiate a download with the specified filename.
|
|
7
|
+
*
|
|
8
|
+
* @param image - The URL of the image to save.
|
|
9
|
+
* @param filename - The name of the file to save.
|
|
10
|
+
*/
|
|
11
|
+
export declare function saveImage(image: string, filename: string): void;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025.
|
|
3
|
+
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Saves an image by triggering a download.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This function creates an anchor element, sets its `href` attribute to the provided image URL,
|
|
11
|
+
* and triggers a click event to initiate a download with the specified filename.
|
|
12
|
+
*
|
|
13
|
+
* @param image - The URL of the image to save.
|
|
14
|
+
* @param filename - The name of the file to save.
|
|
15
|
+
*/
|
|
16
|
+
export function saveImage(image, filename) {
|
|
17
|
+
const a = document.createElement('a');
|
|
18
|
+
a.href = image;
|
|
19
|
+
a.download = filename;
|
|
20
|
+
document.body.appendChild(a);
|
|
21
|
+
a.click();
|
|
22
|
+
document.body.removeChild(a);
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pauses execution for a specified duration.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This function returns a promise that resolves after the given number of milliseconds.
|
|
6
|
+
*
|
|
7
|
+
* @param time - The time to sleep in milliseconds.
|
|
8
|
+
* @returns A promise that resolves after the specified duration.
|
|
9
|
+
*/
|
|
10
|
+
export declare function sleep(time: number): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025.
|
|
3
|
+
* 3DSource.com, Sergii Karanda steve@3dsource.com
|
|
4
|
+
* All Rights Reserved
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Pauses execution for a specified duration.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This function returns a promise that resolves after the given number of milliseconds.
|
|
11
|
+
*
|
|
12
|
+
* @param time - The time to sleep in milliseconds.
|
|
13
|
+
* @returns A promise that resolves after the specified duration.
|
|
14
|
+
*/
|
|
15
|
+
export function sleep(time) {
|
|
16
|
+
return new Promise((resolve) => setTimeout(resolve, time));
|
|
17
|
+
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3dsource/metabox-front-api",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "API for MetaBox configurator",
|
|
5
|
-
"main": "dist/index.
|
|
5
|
+
"main": "dist/index.ts",
|
|
6
6
|
"unpkg": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "tsc",
|
|
10
10
|
"clean": "rimraf dist",
|
|
11
|
-
"
|
|
11
|
+
"packAll": "npm run clean && npm run build && npm pack",
|
|
12
|
+
"publishApi": "npm run packAll && npm publish --access public",
|
|
12
13
|
"apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../tsconfig.typedoc.json --out ./../../dist/browser/apiDoc"
|
|
13
14
|
},
|
|
14
15
|
"files": [
|