@3dsource/metabox-front-api 0.0.10 → 0.0.12

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,25 +1,30 @@
1
1
  {
2
2
  "name": "@3dsource/metabox-front-api",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "API for MetaBox BASIC configurator",
5
- "main": "dist/index.js",
6
- "unpkg": "dist/index.js",
7
- "jsdelivr": "dist/index.js",
5
+ "main": "dist/index.umd.js",
6
+ "module": "dist/index.esm.js",
7
+ "unpkg": "dist/index.esm.js",
8
+ "jsdelivr": "dist/index.esm.js",
8
9
  "type": "module",
9
10
  "scripts": {
10
- "build": "tsc",
11
+ "build": "rollup -c",
11
12
  "clean": "rimraf dist",
12
13
  "packAll": "npm run clean && npm run build && npm pack",
13
14
  "publishApi": "npm run packAll && npm publish --access public",
14
15
  "apiDoc": "typedoc --entryPointStrategy Expand src/index.ts --tsconfig ./../../../tsconfig.typedoc.json --out ./../../../dist/browser/apiDocBasic"
15
16
  },
16
17
  "files": [
17
- "dist"
18
+ "dist/**/*"
18
19
  ],
19
20
  "repository": {
20
21
  "type": "git",
21
22
  "url": "git@bitbucket.org:dreamsoft/ams_vps-frontend.git"
22
23
  },
24
+ "exports": {
25
+ ".": "./dist/index.esm.js"
26
+ },
27
+ "types": "dist/index.d.ts",
23
28
  "keywords": [
24
29
  "metabox",
25
30
  "api",
@@ -28,7 +33,9 @@
28
33
  "author": "3dsource.com",
29
34
  "license": "MIT",
30
35
  "devDependencies": {
31
- "typescript": "~5.7.3",
32
- "rimraf": "^3.0.2"
36
+ "rimraf": "^3.0.2",
37
+ "rollup": "^4.39.0",
38
+ "rollup-plugin-typescript2": "^0.36.0",
39
+ "typescript": "~5.7.3"
33
40
  }
34
41
  }
@@ -1,14 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- /**
7
- * Base class for all API actions.
8
- * @hidden
9
- */
10
- export class ApiAction {
11
- constructor() {
12
- this.api = window.env3DSource.api;
13
- }
14
- }
@@ -1,61 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents a fast render action.
10
- * @remarks
11
- * This class sends a message to the MetaBox API to obtain a fast render based on the provided format and optional size.
12
- *
13
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
14
- * ```javascript
15
- * data.eventType === 'viewportReady' && data.payload === true.
16
- * ```
17
- * Only then request be processed.
18
- *
19
- * @example
20
- * import { integrateMetaBox, GetFastRender, saveImage } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
21
- *
22
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
23
- * integrateMetaBox(
24
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
25
- * 'embed3DSource'
26
- * );
27
- *
28
- * // Set up the global API environment
29
- * window.env3DSource = window.env3DSource || {};
30
- * window.env3DSource.apiReady = (api) => {
31
- * // Listen for events from the MetaBox API
32
- * api.addEventListener('metaboxData', (data) => {
33
- * // Ensure the viewport is ready before sending render requests
34
- * if (data.eventType === 'viewportReady' && data.payload === true) {
35
- * // Request a fast render (PNG image with 1024x1024 dimensions)
36
- * new GetFastRender('image/png', { x: 1024, y: 1024 });
37
- * }
38
- * // Process the fast render response
39
- * if (data.eventType === 'fastRender') {
40
- * saveImage(data.payload, 'Render.png');
41
- * }
42
- * });
43
- * };
44
- */
45
- export class GetFastRender extends ApiAction {
46
- /**
47
- * Constructs an instance of GetFastRender.
48
- * @param mimeType - The output format.
49
- * @param size - Optional size in pixels.
50
- */
51
- constructor(mimeType, size) {
52
- super();
53
- this.api.sendMessageToMetaBox({
54
- payload: {
55
- format: mimeType,
56
- size,
57
- },
58
- action: ToMetaBoxApiAction.getFastRender,
59
- });
60
- }
61
- }
@@ -1,51 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents an action to get a PDF from Metabox.
10
- * @remarks
11
- * This class sends a message to the MetaBox API to generate a PDF based on the current configuration.
12
- * This action does not require any parameters.
13
- *
14
- * **Important:** Before invoking this action, ensure that the MetaBox viewport is fully loaded. This is indicated by the event:
15
- *```javascript
16
- * data.eventType === 'viewportReady' && data.payload === true.
17
- * ```
18
- * Only then request be processed.
19
- *
20
- * @example
21
- * import { integrateMetaBox, GetPdf } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
22
- *
23
- * integrateMetaBox(
24
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
25
- * 'embed3DSource'
26
- * );
27
- *
28
- * window.env3DSource = window.env3DSource || {};
29
- * window.env3DSource.apiReady = (api) => {
30
- * api.addEventListener('metaboxData', (data) => {
31
- * if (data.eventType === 'viewportReady' && data.payload === true) {
32
- * // Request a PDF of the current configuration
33
- * new GetPdf();
34
- * }
35
- * });
36
- * };
37
- */
38
- export class GetPdf extends ApiAction {
39
- /**
40
- * Creates an instance of GetPdf.
41
- *
42
- * @remarks
43
- * This constructor does not require any parameters.
44
- */
45
- constructor() {
46
- super();
47
- this.api.sendMessageToMetaBox({
48
- action: ToMetaBoxApiAction.getPdf,
49
- });
50
- }
51
- }
@@ -1,45 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents an action to set the environment by its ID.
10
- * @remarks
11
- * This action sends a message to the MetaBox API to load the environment level using the specified environment ID.
12
- * It requires the MetaBox API to be properly initialized and an event listener to be registered.
13
- *
14
- * @example
15
- * import { integrateMetaBox, SetEnvironment } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
16
- *
17
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
18
- * integrateMetaBox(
19
- * 'https://metabox.3dsource.com/metabox-configurator/basic/12345678-1234-1234-1234-01234567890?introImage=https://example.com/intro.webp&sidebar=false',
20
- * 'embed3DSource'
21
- * );
22
- *
23
- * // Setup API ready callback
24
- * window.env3DSource = window.env3DSource || {};
25
- * window.env3DSource.apiReady = (api) => {
26
- * // Change the environment to '55555555-1234-1234-1234-01234567890'
27
- * new SetEnvironment('55555555-1234-1234-1234-01234567890');
28
- * };
29
- */
30
- export class SetEnvironment extends ApiAction {
31
- /**
32
- * Creates an instance of SetEnvironment.
33
- *
34
- * @param environmentId - The environment ID.
35
- */
36
- constructor(environmentId) {
37
- super();
38
- this.api.sendMessageToMetaBox({
39
- payload: {
40
- id: environmentId,
41
- },
42
- action: ToMetaBoxApiAction.loadLevel,
43
- });
44
- }
45
- }
@@ -1,65 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents an action to set a material by its ID.
10
- *
11
- * @remarks
12
- * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
13
-
14
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
15
- * as minimum one eventType:"basicConfiguratorDataWithState":
16
- * ```javascript
17
- * data.eventType === 'basicConfiguratorDataWithState'.
18
- * ```
19
- * Only then request be processed.
20
- *
21
- * @example
22
- * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
23
- *
24
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
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
- * // Set up the global API environment
31
- * window.env3DSource = window.env3DSource || {};
32
- * window.env3DSource.apiReady = (api) => {
33
- * // Listen for events from the MetaBox API
34
- * api.addEventListener('metaboxData', (data) => {
35
- * // Process SetMaterial
36
- * if (data.eventType === 'basicConfiguratorDataWithState') {
37
- * new SetEnvironmentMaterial(
38
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
39
- * 'carpaint',
40
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
41
- * );
42
- * }
43
- * });
44
- * };
45
- */
46
- export class SetEnvironmentMaterial extends ApiAction {
47
- /**
48
- * Creates an instance of SetMaterial.
49
- *
50
- * @param productId - The product ID.
51
- * @param slotId - The slot ID.
52
- * @param materialId - The material ID.
53
- */
54
- constructor(productId, slotId, materialId) {
55
- super();
56
- this.api.sendMessageToMetaBox({
57
- payload: {
58
- productId,
59
- slotId,
60
- materialId,
61
- },
62
- action: ToMetaBoxApiAction.setEnvironmentMaterialById,
63
- });
64
- }
65
- }
@@ -1,65 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents an action to set a material by its ID.
10
- *
11
- * @remarks
12
- * This action sends a message to the MetaBox API to update the material on a specific product slot using the provided identifiers.
13
-
14
- * **Important:** Before invoking this action, ensure that the MetaBox already dispatched
15
- * as minimum one eventType:"basicConfiguratorDataWithState":
16
- * ```javascript
17
- * data.eventType === 'basicConfiguratorDataWithState'.
18
- * ```
19
- * Only then request be processed.
20
- *
21
- * @example
22
- * import { SetMaterial } from 'https://unpkg.com/@3dsource/metabox-front-api@latest/dist/index.js';
23
- *
24
- * // Integrate the MetaBox configurator into an HTML element with the ID 'embed3DSource'
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
- * // Set up the global API environment
31
- * window.env3DSource = window.env3DSource || {};
32
- * window.env3DSource.apiReady = (api) => {
33
- * // Listen for events from the MetaBox API
34
- * api.addEventListener('metaboxData', (data) => {
35
- * // Process SetMaterial
36
- * if (data.eventType === 'basicConfiguratorDataWithState') {
37
- * new SetMaterial(
38
- * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
39
- * 'carpaint',
40
- * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
41
- * );
42
- * }
43
- * });
44
- * };
45
- */
46
- export class SetMaterial extends ApiAction {
47
- /**
48
- * Creates an instance of SetMaterial.
49
- *
50
- * @param productId - The product ID.
51
- * @param slotId - The slot ID.
52
- * @param materialId - The material ID.
53
- */
54
- constructor(productId, slotId, materialId) {
55
- super();
56
- this.api.sendMessageToMetaBox({
57
- payload: {
58
- productId,
59
- slotId,
60
- materialId,
61
- },
62
- action: ToMetaBoxApiAction.setMaterialById,
63
- });
64
- }
65
- }
@@ -1,29 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents an action to set a product by its ID.
10
- *
11
- * @remarks
12
- * This action sends a message to the MetaBox API to set a product using the provided product ID.
13
- */
14
- export class SetProduct extends ApiAction {
15
- /**
16
- * Creates an instance of SetProduct.
17
- *
18
- * @param productId - The product ID.
19
- */
20
- constructor(productId) {
21
- super();
22
- this.api.sendMessageToMetaBox({
23
- payload: {
24
- productId,
25
- },
26
- action: ToMetaBoxApiAction.setProduct,
27
- });
28
- }
29
- }
@@ -1,29 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * Represents an action to toggle the Embedded Menu in MetaBox.
10
- *
11
- * @remarks
12
- * This action sends a message to the MetaBox API to toggle the visibility of the embedded menu.
13
- */
14
- export class ShowEmbeddedMenu extends ApiAction {
15
- /**
16
- * Creates an instance of ShowEmbeddedMenu.
17
- *
18
- * @param visible - A flag indicating whether the embedded menu should be visible.
19
- */
20
- constructor(visible) {
21
- super();
22
- this.api.sendMessageToMetaBox({
23
- action: ToMetaBoxApiAction.showEmbeddedMenu,
24
- payload: {
25
- visible,
26
- },
27
- });
28
- }
29
- }
@@ -1,27 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- import { ApiAction } from './ApiAction';
7
- import { ToMetaBoxApiAction } from '../interfaces/ToMetaboxMessagePayloads';
8
- /**
9
- * @experimental
10
- * @remarks
11
- * Represents an action to watch Unreal callbacks from Unreal engine.
12
- * Can be useful for custom solutions.
13
- */
14
- export class WatchCallbacks extends ApiAction {
15
- /**
16
- * Creates an instance of WatchCallbacks.
17
- *
18
- * @remarks
19
- * This constructor does not require any parameters.
20
- */
21
- constructor() {
22
- super();
23
- this.api.sendMessageToMetaBox({
24
- action: ToMetaBoxApiAction.watchCallbacks,
25
- });
26
- }
27
- }
package/dist/index.js DELETED
@@ -1,23 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- export { ShowEmbeddedMenu } from './actions/ShowEmbeddedMenu';
7
- export { SetEnvironment } from './actions/SetEnvironment';
8
- export { SetProduct } from './actions/SetProduct';
9
- export { GetPdf } from './actions/GetPdf';
10
- export { SetMaterial } from './actions/SetMaterial';
11
- export { SetEnvironmentMaterial } from './actions/SetEnvironmentMaterial';
12
- export { GetFastRender } from './actions/GetFastRender';
13
- export { WatchCallbacks } from './actions/WatchCallbacks';
14
- export { ApiAction } from './actions/ApiAction';
15
- export * from './lib/integrateMetaBox';
16
- export * from './lib/initializeCommunicator';
17
- export * from './lib/saveImage';
18
- export * from './lib/sleep';
19
- export * from './lib/UrlUtils';
20
- export * from './interfaces/UniversalConfigurator';
21
- export * from './interfaces/ToMetaboxMessagePayloads';
22
- export * from './interfaces/FromMetaboxMessagePayloads';
23
- export * from './interfaces/application-device-types';
@@ -1,60 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- export const FromMetaboxApiAction = {
7
- bridge: 'bridge',
8
- appLoaded: 'appLoaded',
9
- /**
10
- * @hidden
11
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealFeature"
12
- */
13
- unrealFeatureBridge: 'unrealFeatureBridge',
14
- /**
15
- * @hidden
16
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "unrealCallback"
17
- */
18
- unrealCallback: 'unrealCallback',
19
- /**
20
- * @hidden
21
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
22
- */
23
- configuratorDataWithStateBridge: 'configuratorDataWithStateBridge',
24
- /**
25
- * @hidden
26
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
27
- */
28
- configuratorDataBridge: 'configuratorDataBridge',
29
- /**
30
- * @hidden
31
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
32
- */
33
- menuDataBridge: 'menuDataBridge',
34
- /**
35
- * @hidden
36
- * @deprecated, use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
37
- */
38
- flatMenuDataBridge: 'flatMenuDataBridge',
39
- /**
40
- * @hidden
41
- * @deprecated, use Bridge with isFullscreen
42
- */
43
- fullScreenBridge: 'fullScreenBridge',
44
- /**
45
- * @hidden
46
- * @deprecated, use Bridge with streamResolution
47
- */
48
- videoSize: 'videoSize',
49
- /**
50
- * @hidden
51
- * Used in platform, must be removed in future
52
- * @deprecated
53
- */
54
- unrealResponse: 'unrealResponse',
55
- /**
56
- * @hidden
57
- * @deprecated\
58
- */
59
- getFastRender: 'getFastRender',
60
- };
@@ -1,22 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- export const ToMetaBoxApiAction = {
7
- getPdf: 'getPdf',
8
- loadLevel: 'loadLevel',
9
- setProduct: 'setProduct',
10
- /**
11
- * @deprecated, use 'watchCallbacks'"
12
- * use MetaBoxApiAction.Bridge with eventType: "configuratorDataWithState"
13
- * @hidden
14
- */
15
- addResponse: 'addResponse',
16
- getFastRender: 'getFastRender',
17
- watchCallbacks: 'watchCallbacks',
18
- setMaterialById: 'setMaterialById',
19
- showEmbeddedMenu: 'showEmbeddedMenu',
20
- forceSetDeviceType: 'forceSetDeviceType',
21
- setEnvironmentMaterialById: 'setEnvironmentMaterialById',
22
- };
@@ -1,6 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- export {};
@@ -1,10 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- export const APPLICATION_DEVICE_TYPES = {
7
- deviceTypeAuto: 'deviceTypeAuto',
8
- deviceTypeMobile: 'deviceTypeMobile',
9
- deviceTypeDesktop: 'deviceTypeDesktop',
10
- };
@@ -1,37 +0,0 @@
1
- /*
2
- * Copyright (c) 2025.
3
- * 3DSource.com, Sergii Karanda steve@3dsource.com
4
- * All Rights Reserved
5
- */
6
- /**
7
- * Sets the URL parameters based on the provided state.
8
- *
9
- * @remarks
10
- * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
11
- *
12
- * @param state - An object containing key-value pairs to set as URL parameters.
13
- */
14
- export function setUrlParams(state) {
15
- const url = new URL(window.location.href);
16
- url.search = '';
17
- Object.entries(state).forEach(([key, value]) => {
18
- url.searchParams.set(key, value);
19
- });
20
- history.replaceState(null, '', url.toString());
21
- }
22
- /**
23
- * Retrieves the URL parameters as an object.
24
- *
25
- * @remarks
26
- * This function parses the current URL's search parameters and returns them as a key-value object.
27
- *
28
- * @returns An object containing the URL parameters.
29
- */
30
- export function getUrlParams() {
31
- const urlParams = new URLSearchParams(window.location.search);
32
- const selections = {};
33
- urlParams.forEach((value, key) => {
34
- selections[key] = value;
35
- });
36
- return selections;
37
- }