@upscopeio/react 1.0.3 → 1.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/index.js +8 -8
- package/index.tsx +15 -25
- package/package.json +2 -5
package/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import UpscopeSDK from
|
|
3
|
-
import { useEffect
|
|
2
|
+
import UpscopeSDK from "@upscopeio/sdk";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
4
|
const Upscope = function ({ children, ...props }) {
|
|
5
|
-
const [initiated, setInitiated] = useState(false);
|
|
6
5
|
const keys = Object.keys(props).sort((a, b) => a.localeCompare(b));
|
|
7
6
|
const values = keys.map((key) => props[key]);
|
|
8
7
|
useEffect(() => {
|
|
8
|
+
const initiated = sessionStorage.getItem("upscope__initiated") === "true";
|
|
9
9
|
if (initiated) {
|
|
10
|
-
UpscopeSDK(
|
|
10
|
+
UpscopeSDK("updateConnection", props);
|
|
11
11
|
}
|
|
12
12
|
else {
|
|
13
|
-
UpscopeSDK(
|
|
14
|
-
|
|
13
|
+
UpscopeSDK("init", props);
|
|
14
|
+
sessionStorage.setItem("upscope__initiated", "true");
|
|
15
15
|
}
|
|
16
16
|
}, values);
|
|
17
17
|
return children;
|
|
@@ -27,7 +27,7 @@ export function Masked({ children }) {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}, [children]);
|
|
30
|
-
return
|
|
30
|
+
return _jsx(_Fragment, { children: children });
|
|
31
31
|
}
|
|
32
32
|
export function NoRemoteControl({ children }) {
|
|
33
33
|
useEffect(() => {
|
|
@@ -39,5 +39,5 @@ export function NoRemoteControl({ children }) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}, [children]);
|
|
42
|
-
return
|
|
42
|
+
return _jsx(_Fragment, { children: children });
|
|
43
43
|
}
|
package/index.tsx
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import type {CobrowsingSdkConfiguration, Upscope} from
|
|
2
|
-
import type {ReactNode} from
|
|
3
|
-
import UpscopeSDK from
|
|
4
|
-
import React, {useEffect
|
|
1
|
+
import type { CobrowsingSdkConfiguration, Upscope } from "@upscopeio/sdk";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import UpscopeSDK from "@upscopeio/sdk";
|
|
4
|
+
import React, { useEffect } from "react";
|
|
5
5
|
|
|
6
6
|
type Child = ReactNode & {
|
|
7
7
|
__upscopeMasked?: boolean;
|
|
8
8
|
__upscopeNoRemoteControl?: boolean;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
type Children = {children: Child};
|
|
11
|
+
type Children = { children: Child };
|
|
12
12
|
|
|
13
13
|
type Props = Children & Partial<CobrowsingSdkConfiguration>;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
const Upscope: React.FC<Props> = function({children, ...props}: Props) {
|
|
17
|
-
const [initiated, setInitiated] = useState(false);
|
|
15
|
+
const Upscope: React.FC<Props> = function ({ children, ...props }: Props) {
|
|
18
16
|
const keys = Object.keys(props).sort((a, b) => a.localeCompare(b)) as (keyof CobrowsingSdkConfiguration)[];
|
|
19
17
|
const values: unknown[] = keys.map((key: keyof CobrowsingSdkConfiguration) => props[key] as unknown);
|
|
20
18
|
|
|
21
19
|
useEffect(() => {
|
|
20
|
+
const initiated = sessionStorage.getItem("upscope__initiated") === "true";
|
|
21
|
+
|
|
22
22
|
if (initiated) {
|
|
23
|
-
(UpscopeSDK as Upscope)(
|
|
23
|
+
(UpscopeSDK as Upscope)("updateConnection", props);
|
|
24
24
|
} else {
|
|
25
|
-
(UpscopeSDK as Upscope)(
|
|
26
|
-
|
|
25
|
+
(UpscopeSDK as Upscope)("init", props);
|
|
26
|
+
sessionStorage.setItem("upscope__initiated", "true");
|
|
27
27
|
}
|
|
28
28
|
}, values);
|
|
29
29
|
|
|
@@ -31,8 +31,7 @@ const Upscope: React.FC<Props> = function({children, ...props}: Props) {
|
|
|
31
31
|
};
|
|
32
32
|
export default Upscope;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
export function Masked({children}: Children): ReactNode {
|
|
34
|
+
export function Masked({ children }: Children): ReactNode {
|
|
36
35
|
useEffect(() => {
|
|
37
36
|
if (children) {
|
|
38
37
|
children.__upscopeMasked = true;
|
|
@@ -42,15 +41,10 @@ export function Masked({children}: Children): ReactNode {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
}, [children]);
|
|
45
|
-
return
|
|
46
|
-
<>
|
|
47
|
-
{children}
|
|
48
|
-
</>
|
|
49
|
-
);
|
|
44
|
+
return <>{children}</>;
|
|
50
45
|
}
|
|
51
46
|
|
|
52
|
-
|
|
53
|
-
export function NoRemoteControl({children}: Children): ReactNode {
|
|
47
|
+
export function NoRemoteControl({ children }: Children): ReactNode {
|
|
54
48
|
useEffect(() => {
|
|
55
49
|
if (children) {
|
|
56
50
|
children.__upscopeNoRemoteControl = true;
|
|
@@ -60,9 +54,5 @@ export function NoRemoteControl({children}: Children): ReactNode {
|
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
}, [children]);
|
|
63
|
-
return
|
|
64
|
-
<>
|
|
65
|
-
{children}
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
57
|
+
return <>{children}</>;
|
|
68
58
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upscopeio/react",
|
|
3
3
|
"main": "index.js",
|
|
4
|
-
"type": "module",
|
|
5
4
|
"dependencies": {
|
|
6
|
-
"@upscopeio/sdk": "1.0.
|
|
7
|
-
},
|
|
8
|
-
"peerDependencies": {
|
|
5
|
+
"@upscopeio/sdk": "1.0.5",
|
|
9
6
|
"react": "^18.2.0"
|
|
10
7
|
},
|
|
11
8
|
"devDependencies": {
|
|
12
9
|
"@types/react": "^18.2.14",
|
|
13
10
|
"typescript": "^5.1.6"
|
|
14
11
|
},
|
|
15
|
-
"version": "1.0.
|
|
12
|
+
"version": "1.0.5"
|
|
16
13
|
}
|