@parafin/core 1.0.8 → 1.0.9
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/index.ts +25 -35
- package/out/index.js +25 -34
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -14,51 +14,41 @@ const openParafinDashboard = (
|
|
|
14
14
|
document.removeChild(existingParafinDashboard)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
17
|
+
const frame = document.createElement('iframe')
|
|
18
|
+
frame.id = 'parafin-dashboard'
|
|
19
|
+
frame.style.position = 'fixed'
|
|
20
|
+
frame.style.top = '0'
|
|
21
|
+
frame.style.left = '0'
|
|
22
|
+
frame.style.width = '100%'
|
|
23
|
+
frame.style.height = '100%'
|
|
24
|
+
frame.style.border = 'none'
|
|
25
|
+
frame.style.zIndex = '2147483647'
|
|
26
|
+
frame.style.backgroundColor = '#fff'
|
|
27
|
+
frame.style.opacity = '0'
|
|
28
|
+
frame.style.transition = 'opacity 0.2s'
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
switch (props.environment) {
|
|
32
|
-
case 'local':
|
|
33
|
-
return 'http://localhost:9000'
|
|
34
|
-
case 'development':
|
|
35
|
-
return props.dashboardUrlOverride ?? 'https://app.dev.parafin.com'
|
|
36
|
-
default:
|
|
37
|
-
return 'https://app.parafin.com'
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const baseUrl = getBaseUrl()
|
|
30
|
+
const url = new URL(props.dashboardUrlOverride ?? 'https://app.parafin.com')
|
|
42
31
|
const route = props.route ?? '/'
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
32
|
+
const query = {
|
|
33
|
+
token: props.token,
|
|
34
|
+
product: props.product,
|
|
35
|
+
externalBusinessId: props.externalBusinessId ?? '',
|
|
36
|
+
...Object.fromEntries(url.searchParams),
|
|
37
|
+
}
|
|
48
38
|
|
|
49
39
|
const closeParafinDashboard = ({ data, origin }: MessageEvent) => {
|
|
50
|
-
if (origin ===
|
|
40
|
+
if (origin === url.origin && data?.message === 'close-dashboard') {
|
|
51
41
|
props.onExit?.()
|
|
52
42
|
window.removeEventListener('message', closeParafinDashboard)
|
|
53
|
-
|
|
54
|
-
setTimeout(() => document.body.removeChild(
|
|
43
|
+
frame.style.opacity = '0'
|
|
44
|
+
setTimeout(() => document.body.removeChild(frame), 200)
|
|
55
45
|
}
|
|
56
46
|
}
|
|
57
47
|
|
|
58
|
-
|
|
48
|
+
frame.src = `${url.origin}${route}?${new URLSearchParams(query).toString()}`
|
|
59
49
|
window.addEventListener('message', closeParafinDashboard)
|
|
60
|
-
document.body.appendChild(
|
|
61
|
-
setTimeout(() => (
|
|
50
|
+
document.body.appendChild(frame)
|
|
51
|
+
setTimeout(() => (frame.style.opacity = '1'), 1)
|
|
62
52
|
} catch (error) {
|
|
63
53
|
console.error('Error loading Parafin dashboard', error)
|
|
64
54
|
}
|
package/out/index.js
CHANGED
|
@@ -4,47 +4,38 @@ const openParafinDashboard = (props) => {
|
|
|
4
4
|
if (existingParafinDashboard) {
|
|
5
5
|
document.removeChild(existingParafinDashboard);
|
|
6
6
|
}
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
switch (props.environment) {
|
|
21
|
-
case 'local':
|
|
22
|
-
return 'http://localhost:9000';
|
|
23
|
-
case 'development':
|
|
24
|
-
return props.dashboardUrlOverride ?? 'https://app.dev.parafin.com';
|
|
25
|
-
default:
|
|
26
|
-
return 'https://app.parafin.com';
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const baseUrl = getBaseUrl();
|
|
7
|
+
const frame = document.createElement('iframe');
|
|
8
|
+
frame.id = 'parafin-dashboard';
|
|
9
|
+
frame.style.position = 'fixed';
|
|
10
|
+
frame.style.top = '0';
|
|
11
|
+
frame.style.left = '0';
|
|
12
|
+
frame.style.width = '100%';
|
|
13
|
+
frame.style.height = '100%';
|
|
14
|
+
frame.style.border = 'none';
|
|
15
|
+
frame.style.zIndex = '2147483647';
|
|
16
|
+
frame.style.backgroundColor = '#fff';
|
|
17
|
+
frame.style.opacity = '0';
|
|
18
|
+
frame.style.transition = 'opacity 0.2s';
|
|
19
|
+
const url = new URL(props.dashboardUrlOverride ?? 'https://app.parafin.com');
|
|
30
20
|
const route = props.route ?? '/';
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
const query = {
|
|
22
|
+
token: props.token,
|
|
23
|
+
product: props.product,
|
|
24
|
+
externalBusinessId: props.externalBusinessId ?? '',
|
|
25
|
+
...Object.fromEntries(url.searchParams),
|
|
26
|
+
};
|
|
36
27
|
const closeParafinDashboard = ({ data, origin }) => {
|
|
37
|
-
if (origin ===
|
|
28
|
+
if (origin === url.origin && data?.message === 'close-dashboard') {
|
|
38
29
|
props.onExit?.();
|
|
39
30
|
window.removeEventListener('message', closeParafinDashboard);
|
|
40
|
-
|
|
41
|
-
setTimeout(() => document.body.removeChild(
|
|
31
|
+
frame.style.opacity = '0';
|
|
32
|
+
setTimeout(() => document.body.removeChild(frame), 200);
|
|
42
33
|
}
|
|
43
34
|
};
|
|
44
|
-
|
|
35
|
+
frame.src = `${url.origin}${route}?${new URLSearchParams(query).toString()}`;
|
|
45
36
|
window.addEventListener('message', closeParafinDashboard);
|
|
46
|
-
document.body.appendChild(
|
|
47
|
-
setTimeout(() => (
|
|
37
|
+
document.body.appendChild(frame);
|
|
38
|
+
setTimeout(() => (frame.style.opacity = '1'), 1);
|
|
48
39
|
}
|
|
49
40
|
catch (error) {
|
|
50
41
|
console.error('Error loading Parafin dashboard', error);
|