@dynamic-labs/iframe-setup 4.9.1-preview.0 → 4.9.2-preview.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/CHANGELOG.md +13 -2
- package/README.md +12 -10
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +2 -5
- package/src/index.cjs +0 -2
- package/src/index.d.ts +0 -1
- package/src/index.js +0 -1
- package/src/lib/setupIframe/setupIframe.cjs +2 -2
- package/src/lib/setupIframe/setupIframe.d.ts +2 -14
- package/src/lib/setupIframe/setupIframe.js +2 -2
- package/_virtual/_tslib.cjs +0 -36
- package/_virtual/_tslib.js +0 -32
- package/src/lib/setupInsideIframe/index.d.ts +0 -1
- package/src/lib/setupInsideIframe/setupInsideIframe.cjs +0 -18
- package/src/lib/setupInsideIframe/setupInsideIframe.d.ts +0 -1
- package/src/lib/setupInsideIframe/setupInsideIframe.js +0 -14
- package/src/lib/setupInsideIframe/utils/createMessageHandler/createMessageHandler.cjs +0 -30
- package/src/lib/setupInsideIframe/utils/createMessageHandler/createMessageHandler.d.ts +0 -2
- package/src/lib/setupInsideIframe/utils/createMessageHandler/createMessageHandler.js +0 -26
- package/src/lib/setupInsideIframe/utils/createMessageHandler/index.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/createMessageSender/createMessageSender.cjs +0 -8
- package/src/lib/setupInsideIframe/utils/createMessageSender/createMessageSender.d.ts +0 -2
- package/src/lib/setupInsideIframe/utils/createMessageSender/createMessageSender.js +0 -4
- package/src/lib/setupInsideIframe/utils/createMessageSender/index.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/getInitialParentURL/getInitialParentURL.cjs +0 -14
- package/src/lib/setupInsideIframe/utils/getInitialParentURL/getInitialParentURL.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/getInitialParentURL/getInitialParentURL.js +0 -10
- package/src/lib/setupInsideIframe/utils/getInitialParentURL/index.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/logger.cjs +0 -10
- package/src/lib/setupInsideIframe/utils/logger.d.ts +0 -2
- package/src/lib/setupInsideIframe/utils/logger.js +0 -6
- package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/index.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/setupPlatformEventsService.cjs +0 -23
- package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/setupPlatformEventsService.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/setupPlatformEventsService.js +0 -15
- package/src/lib/setupInsideIframe/utils/setupPlatformService/index.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/setupPlatformService/setupPlatformService.cjs +0 -36
- package/src/lib/setupInsideIframe/utils/setupPlatformService/setupPlatformService.d.ts +0 -1
- package/src/lib/setupInsideIframe/utils/setupPlatformService/setupPlatformService.js +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
|
|
2
|
-
### [4.9.
|
|
2
|
+
### [4.9.2-preview.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.1...v4.9.2-preview.0) (2025-03-11)
|
|
3
|
+
|
|
4
|
+
### [4.9.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.9.0...v4.9.1) (2025-03-11)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* waas svm connector ([#8191](https://github.com/dynamic-labs/dynamic-auth/issues/8191)) ([049a360](https://github.com/dynamic-labs/dynamic-auth/commit/049a360642d6aa2122676c7a29d36a7baef9e49b))
|
|
3
10
|
|
|
4
11
|
|
|
5
12
|
### Bug Fixes
|
|
6
13
|
|
|
7
14
|
* 7702 on sepolia ([#8242](https://github.com/dynamic-labs/dynamic-auth/issues/8242)) ([8e1c63f](https://github.com/dynamic-labs/dynamic-auth/commit/8e1c63f240024f419e12787636dd2ebaacf8da94))
|
|
8
|
-
*
|
|
15
|
+
* close auth flow when promptExport enabled but createWallet is false ([#8239](https://github.com/dynamic-labs/dynamic-auth/issues/8239)) ([f82429f](https://github.com/dynamic-labs/dynamic-auth/commit/f82429f85e729a76c2516f0db112033fdd2a36d5))
|
|
16
|
+
* fix solana genesis hashes bug that was causing a breaking change ([#8250](https://github.com/dynamic-labs/dynamic-auth/issues/8250)) ([731c93b](https://github.com/dynamic-labs/dynamic-auth/commit/731c93bea4b8b95caa8cc665f2ecb53f9948ef8e))
|
|
17
|
+
* move setup-inside-iframe utility method to the utils package ([#8256](https://github.com/dynamic-labs/dynamic-auth/issues/8256)) ([d34eb6d](https://github.com/dynamic-labs/dynamic-auth/commit/d34eb6d211baecb496b84fefaee8179a5fb1b52a))
|
|
18
|
+
* **QNTM-2952:** support headless social sign in ([#8226](https://github.com/dynamic-labs/dynamic-auth/issues/8226)) ([0c3082d](https://github.com/dynamic-labs/dynamic-auth/commit/0c3082d593c633519c9eed20be15186f18f65c09))
|
|
19
|
+
* sign message with trust wallet on solana ([#8249](https://github.com/dynamic-labs/dynamic-auth/issues/8249)) ([99a7917](https://github.com/dynamic-labs/dynamic-auth/commit/99a791796f7d2c83b9f18e45367aa9689c67869d))
|
|
9
20
|
|
|
10
21
|
## [4.9.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.8.6...v4.9.0) (2025-03-07)
|
|
11
22
|
|
package/README.md
CHANGED
|
@@ -10,10 +10,7 @@ npm install @dynamic-labs/iframe-setup
|
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
This package provides
|
|
14
|
-
|
|
15
|
-
1. `setupIframe`: Configures an iframe element with the necessary event listeners to support the SDK
|
|
16
|
-
2. `setupInsideIframe`: Prepares the sdk-react-core services to operate within an iframe
|
|
13
|
+
This package provides the setupIframe method thats used to setup the iframe environment.
|
|
17
14
|
|
|
18
15
|
## Implementation Guide
|
|
19
16
|
|
|
@@ -49,7 +46,7 @@ Inside your iframe application, initialize the SDK:
|
|
|
49
46
|
|
|
50
47
|
```tsx
|
|
51
48
|
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core';
|
|
52
|
-
import { setupInsideIframe } from '@dynamic-labs/
|
|
49
|
+
import { setupInsideIframe } from '@dynamic-labs/utils';
|
|
53
50
|
|
|
54
51
|
// Initialize as early as possible in your iframe application
|
|
55
52
|
setupInsideIframe();
|
|
@@ -73,20 +70,25 @@ If you're unable to install the package in the parent application, you can direc
|
|
|
73
70
|
|
|
74
71
|
```ts
|
|
75
72
|
/**
|
|
76
|
-
* Setup an iframe to
|
|
73
|
+
* Setup an iframe to communicate with the Dynamic SDK
|
|
77
74
|
* running inside the iframe
|
|
78
75
|
*
|
|
79
|
-
* This file is self contained and should not import or
|
|
76
|
+
* This file is self contained and should not import or depend on any
|
|
80
77
|
* other file or package.
|
|
81
78
|
*
|
|
82
79
|
* @see https://www.npmjs.com/package/@dynamic-labs/iframe-setup
|
|
83
80
|
*/
|
|
84
81
|
/* eslint no-restricted-syntax: ["error", "ImportDeclaration"] */
|
|
85
82
|
|
|
83
|
+
/**
|
|
84
|
+
* The same implementation was added to the utils package
|
|
85
|
+
* and they should be kept in sync
|
|
86
|
+
* The type is duplicated here to avoid a dependency on the utils package
|
|
87
|
+
* @see packages/utils/src/setupInsideIframe/types.ts
|
|
88
|
+
*/
|
|
86
89
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
export type IFRAME_EVENTS = {
|
|
90
|
+
type MESSAGE_HANDLER = (...params: any[]) => Promise<any> | void;
|
|
91
|
+
type IFRAME_EVENTS = {
|
|
90
92
|
OPEN_URL: (args: {
|
|
91
93
|
url: string;
|
|
92
94
|
target?: 'self' | 'blank';
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/iframe-setup",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.2-preview.0",
|
|
4
4
|
"description": "Collection of utilities to use the Dynamic SDK in an iframe",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,10 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.9.
|
|
22
|
-
"@dynamic-labs/logger": "4.9.1-preview.0",
|
|
23
|
-
"@dynamic-labs/utils": "4.9.1-preview.0",
|
|
24
|
-
"eventemitter3": "5.0.1"
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.9.2-preview.0"
|
|
25
22
|
},
|
|
26
23
|
"peerDependencies": {}
|
|
27
24
|
}
|
package/src/index.cjs
CHANGED
|
@@ -6,9 +6,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
7
|
var _package = require('../package.cjs');
|
|
8
8
|
var setupIframe = require('./lib/setupIframe/setupIframe.cjs');
|
|
9
|
-
var setupInsideIframe = require('./lib/setupInsideIframe/setupInsideIframe.cjs');
|
|
10
9
|
|
|
11
10
|
assertPackageVersion.assertPackageVersion('@dynamic-labs/iframe-setup', _package.version);
|
|
12
11
|
|
|
13
12
|
exports.setupIframe = setupIframe.setupIframe;
|
|
14
|
-
exports.setupInsideIframe = setupInsideIframe.setupInsideIframe;
|
package/src/index.d.ts
CHANGED
package/src/index.js
CHANGED
|
@@ -2,6 +2,5 @@
|
|
|
2
2
|
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
3
|
import { version } from '../package.js';
|
|
4
4
|
export { setupIframe } from './lib/setupIframe/setupIframe.js';
|
|
5
|
-
export { setupInsideIframe } from './lib/setupInsideIframe/setupInsideIframe.js';
|
|
6
5
|
|
|
7
6
|
assertPackageVersion('@dynamic-labs/iframe-setup', version);
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Setup an iframe to
|
|
7
|
+
* Setup an iframe to communicate with the Dynamic SDK
|
|
8
8
|
* running inside the iframe
|
|
9
9
|
*
|
|
10
|
-
* This file is self contained and should not import or
|
|
10
|
+
* This file is self contained and should not import or depend on any
|
|
11
11
|
* other file or package.
|
|
12
12
|
*
|
|
13
13
|
* @see https://www.npmjs.com/package/@dynamic-labs/iframe-setup
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Setup an iframe to
|
|
2
|
+
* Setup an iframe to communicate with the Dynamic SDK
|
|
3
3
|
* running inside the iframe
|
|
4
4
|
*
|
|
5
|
-
* This file is self contained and should not import or
|
|
5
|
+
* This file is self contained and should not import or depend on any
|
|
6
6
|
* other file or package.
|
|
7
7
|
*
|
|
8
8
|
* @see https://www.npmjs.com/package/@dynamic-labs/iframe-setup
|
|
9
9
|
*/
|
|
10
|
-
export type MESSAGE_HANDLER = (...params: any[]) => Promise<any> | void;
|
|
11
|
-
export type IFRAME_EVENTS = {
|
|
12
|
-
OPEN_URL: (args: {
|
|
13
|
-
url: string;
|
|
14
|
-
target?: 'self' | 'blank';
|
|
15
|
-
features?: string;
|
|
16
|
-
}) => void;
|
|
17
|
-
UPDATE_PARENT_URL: (args: {
|
|
18
|
-
url: string;
|
|
19
|
-
}) => void;
|
|
20
|
-
APP_FOCUS: () => void;
|
|
21
|
-
};
|
|
22
10
|
/**
|
|
23
11
|
* Setup an iframe to comunicate with the Dynamic SDK
|
|
24
12
|
* running inside the iframe
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
/**
|
|
3
|
-
* Setup an iframe to
|
|
3
|
+
* Setup an iframe to communicate with the Dynamic SDK
|
|
4
4
|
* running inside the iframe
|
|
5
5
|
*
|
|
6
|
-
* This file is self contained and should not import or
|
|
6
|
+
* This file is self contained and should not import or depend on any
|
|
7
7
|
* other file or package.
|
|
8
8
|
*
|
|
9
9
|
* @see https://www.npmjs.com/package/@dynamic-labs/iframe-setup
|
package/_virtual/_tslib.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Copyright (c) Microsoft Corporation.
|
|
8
|
-
|
|
9
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
10
|
-
purpose with or without fee is hereby granted.
|
|
11
|
-
|
|
12
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
13
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
14
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
15
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
16
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
17
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
18
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
19
|
-
***************************************************************************** */
|
|
20
|
-
|
|
21
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
32
|
-
var e = new Error(message);
|
|
33
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.__awaiter = __awaiter;
|
package/_virtual/_tslib.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
/******************************************************************************
|
|
3
|
-
Copyright (c) Microsoft Corporation.
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
9
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
10
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
11
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
12
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */
|
|
16
|
-
|
|
17
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
28
|
-
var e = new Error(message);
|
|
29
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { __awaiter };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { setupInsideIframe } from './setupInsideIframe';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var setupPlatformService = require('./utils/setupPlatformService/setupPlatformService.cjs');
|
|
7
|
-
var getInitialParentURL = require('./utils/getInitialParentURL/getInitialParentURL.cjs');
|
|
8
|
-
var setupPlatformEventsService = require('./utils/setupPlatformEventsService/setupPlatformEventsService.cjs');
|
|
9
|
-
|
|
10
|
-
const setupInsideIframe = () => {
|
|
11
|
-
// Get the initial parent URL
|
|
12
|
-
const initialParentURL = getInitialParentURL.getInitialParentURL();
|
|
13
|
-
// Setup services
|
|
14
|
-
setupPlatformService.setupPlatformService(initialParentURL);
|
|
15
|
-
setupPlatformEventsService.setupPlatformEventsService(initialParentURL);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.setupInsideIframe = setupInsideIframe;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const setupInsideIframe: () => void;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { setupPlatformService } from './utils/setupPlatformService/setupPlatformService.js';
|
|
3
|
-
import { getInitialParentURL } from './utils/getInitialParentURL/getInitialParentURL.js';
|
|
4
|
-
import { setupPlatformEventsService } from './utils/setupPlatformEventsService/setupPlatformEventsService.js';
|
|
5
|
-
|
|
6
|
-
const setupInsideIframe = () => {
|
|
7
|
-
// Get the initial parent URL
|
|
8
|
-
const initialParentURL = getInitialParentURL();
|
|
9
|
-
// Setup services
|
|
10
|
-
setupPlatformService(initialParentURL);
|
|
11
|
-
setupPlatformEventsService(initialParentURL);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { setupInsideIframe };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var logger = require('../logger.cjs');
|
|
7
|
-
|
|
8
|
-
const createMessageHandler = (parentOrigin) => (eventName, handler) => {
|
|
9
|
-
window.addEventListener('message', (event) => {
|
|
10
|
-
if (event.origin !== parentOrigin) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
if (!Object.prototype.hasOwnProperty.call(event.data, 'eventName') ||
|
|
15
|
-
!Object.prototype.hasOwnProperty.call(event.data, 'args') ||
|
|
16
|
-
!Array.isArray(event.data.args)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const { eventName: incomingEventName, args } = event.data;
|
|
20
|
-
if (incomingEventName === eventName) {
|
|
21
|
-
handler(...args);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
logger.logger.error('Failed to parse message', error);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
exports.createMessageHandler = createMessageHandler;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { logger } from '../logger.js';
|
|
3
|
-
|
|
4
|
-
const createMessageHandler = (parentOrigin) => (eventName, handler) => {
|
|
5
|
-
window.addEventListener('message', (event) => {
|
|
6
|
-
if (event.origin !== parentOrigin) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
try {
|
|
10
|
-
if (!Object.prototype.hasOwnProperty.call(event.data, 'eventName') ||
|
|
11
|
-
!Object.prototype.hasOwnProperty.call(event.data, 'args') ||
|
|
12
|
-
!Array.isArray(event.data.args)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
const { eventName: incomingEventName, args } = event.data;
|
|
16
|
-
if (incomingEventName === eventName) {
|
|
17
|
-
handler(...args);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
logger.error('Failed to parse message', error);
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export { createMessageHandler };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createMessageHandler } from './createMessageHandler';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const createMessageSender = (parentOrigin) => (eventName, ...args) => window.parent.postMessage({ args, eventName }, parentOrigin);
|
|
7
|
-
|
|
8
|
-
exports.createMessageSender = createMessageSender;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { MESSAGE_HANDLER } from '../../../setupIframe/setupIframe';
|
|
2
|
-
export declare const createMessageSender: <T extends Record<string, MESSAGE_HANDLER>>(parentOrigin: string) => <EVENT_NAME extends Extract<keyof T, string>>(eventName: EVENT_NAME, ...args: Parameters<T[EVENT_NAME]>) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createMessageSender } from './createMessageSender';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const getInitialParentURL = () => {
|
|
7
|
-
const initialParentURL = new URLSearchParams(window.location.search).get('initial-parent-url');
|
|
8
|
-
if (!initialParentURL) {
|
|
9
|
-
throw new Error('Parent URL is required');
|
|
10
|
-
}
|
|
11
|
-
return new URL(decodeURIComponent(initialParentURL));
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
exports.getInitialParentURL = getInitialParentURL;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getInitialParentURL: () => URL;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
const getInitialParentURL = () => {
|
|
3
|
-
const initialParentURL = new URLSearchParams(window.location.search).get('initial-parent-url');
|
|
4
|
-
if (!initialParentURL) {
|
|
5
|
-
throw new Error('Parent URL is required');
|
|
6
|
-
}
|
|
7
|
-
return new URL(decodeURIComponent(initialParentURL));
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { getInitialParentURL };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { getInitialParentURL } from './getInitialParentURL';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { setupPlatformEventsService } from './setupPlatformEventsService';
|
package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/setupPlatformEventsService.cjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var EventEmitter = require('eventemitter3');
|
|
7
|
-
var utils = require('@dynamic-labs/utils');
|
|
8
|
-
var createMessageHandler = require('../createMessageHandler/createMessageHandler.cjs');
|
|
9
|
-
|
|
10
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
-
|
|
12
|
-
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
13
|
-
|
|
14
|
-
const setupPlatformEventsService = (initialParentURL) => {
|
|
15
|
-
const emitter = new EventEmitter__default["default"]();
|
|
16
|
-
const messageHandler = createMessageHandler.createMessageHandler(initialParentURL.origin);
|
|
17
|
-
utils.PlatformEventsService.implementation = emitter;
|
|
18
|
-
messageHandler('APP_FOCUS', () => {
|
|
19
|
-
emitter.emit('appFocused');
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
exports.setupPlatformEventsService = setupPlatformEventsService;
|
package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/setupPlatformEventsService.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const setupPlatformEventsService: (initialParentURL: URL) => void;
|
package/src/lib/setupInsideIframe/utils/setupPlatformEventsService/setupPlatformEventsService.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import { PlatformEventsService } from '@dynamic-labs/utils';
|
|
4
|
-
import { createMessageHandler } from '../createMessageHandler/createMessageHandler.js';
|
|
5
|
-
|
|
6
|
-
const setupPlatformEventsService = (initialParentURL) => {
|
|
7
|
-
const emitter = new EventEmitter();
|
|
8
|
-
const messageHandler = createMessageHandler(initialParentURL.origin);
|
|
9
|
-
PlatformEventsService.implementation = emitter;
|
|
10
|
-
messageHandler('APP_FOCUS', () => {
|
|
11
|
-
emitter.emit('appFocused');
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { setupPlatformEventsService };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { setupPlatformService } from './setupPlatformService';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
-
var utils = require('@dynamic-labs/utils');
|
|
8
|
-
var createMessageSender = require('../createMessageSender/createMessageSender.cjs');
|
|
9
|
-
var createMessageHandler = require('../createMessageHandler/createMessageHandler.cjs');
|
|
10
|
-
|
|
11
|
-
const setupPlatformService = (initialParentURL) => {
|
|
12
|
-
let parentURL = new URL(initialParentURL);
|
|
13
|
-
const messageHandler = createMessageHandler.createMessageHandler(initialParentURL.origin);
|
|
14
|
-
const messageSender = createMessageSender.createMessageSender(initialParentURL.origin);
|
|
15
|
-
utils.PlatformService.implementation = {
|
|
16
|
-
getDisplayOrigin: () => parentURL.origin,
|
|
17
|
-
getHost: () => parentURL.host,
|
|
18
|
-
getHostname: () => parentURL.hostname,
|
|
19
|
-
getOrigin: () => parentURL.origin,
|
|
20
|
-
getTLD: () => parentURL.hostname,
|
|
21
|
-
getUrl: () => parentURL,
|
|
22
|
-
isNativeMobile: false,
|
|
23
|
-
openURL: (url_1, ...args_1) => _tslib.__awaiter(void 0, [url_1, ...args_1], void 0, function* (url, target = 'self', features = '') {
|
|
24
|
-
return messageSender('OPEN_URL', {
|
|
25
|
-
features,
|
|
26
|
-
target,
|
|
27
|
-
url,
|
|
28
|
-
});
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
messageHandler('UPDATE_PARENT_URL', ({ url }) => {
|
|
32
|
-
parentURL = new URL(url);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
exports.setupPlatformService = setupPlatformService;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const setupPlatformService: (initialParentURL: URL) => void;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { PlatformService } from '@dynamic-labs/utils';
|
|
4
|
-
import { createMessageSender } from '../createMessageSender/createMessageSender.js';
|
|
5
|
-
import { createMessageHandler } from '../createMessageHandler/createMessageHandler.js';
|
|
6
|
-
|
|
7
|
-
const setupPlatformService = (initialParentURL) => {
|
|
8
|
-
let parentURL = new URL(initialParentURL);
|
|
9
|
-
const messageHandler = createMessageHandler(initialParentURL.origin);
|
|
10
|
-
const messageSender = createMessageSender(initialParentURL.origin);
|
|
11
|
-
PlatformService.implementation = {
|
|
12
|
-
getDisplayOrigin: () => parentURL.origin,
|
|
13
|
-
getHost: () => parentURL.host,
|
|
14
|
-
getHostname: () => parentURL.hostname,
|
|
15
|
-
getOrigin: () => parentURL.origin,
|
|
16
|
-
getTLD: () => parentURL.hostname,
|
|
17
|
-
getUrl: () => parentURL,
|
|
18
|
-
isNativeMobile: false,
|
|
19
|
-
openURL: (url_1, ...args_1) => __awaiter(void 0, [url_1, ...args_1], void 0, function* (url, target = 'self', features = '') {
|
|
20
|
-
return messageSender('OPEN_URL', {
|
|
21
|
-
features,
|
|
22
|
-
target,
|
|
23
|
-
url,
|
|
24
|
-
});
|
|
25
|
-
}),
|
|
26
|
-
};
|
|
27
|
-
messageHandler('UPDATE_PARENT_URL', ({ url }) => {
|
|
28
|
-
parentURL = new URL(url);
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export { setupPlatformService };
|