@streamlayer/react-ui 0.24.2 → 0.24.3
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/lib/utils/components/developer.js +35 -25
- package/lib/utils/components/envToggle.js +58 -0
- package/lib/utils/components/eventInput.js +17 -51
- package/lib/utils/components/sdkKey.js +23 -0
- package/lib/utils/components/styles.js +43 -0
- package/lib/utils/createDemo.js +27 -33
- package/lib/utils/storage.js +27 -11
- package/package.json +1 -1
|
@@ -1,29 +1,38 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useStore as m } from "@nanostores/react";
|
|
1
|
+
import { jsxs as e, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as c, useState as x } from "react";
|
|
4
3
|
import { styled as n } from "@linaria/react";
|
|
5
|
-
import { EventInput as
|
|
4
|
+
import { EventInput as g } from "./eventInput.js";
|
|
6
5
|
import { BypassLogin as f } from "./bypassLogin.js";
|
|
7
|
-
import {
|
|
6
|
+
import { SdkKey as h } from "./sdkKey.js";
|
|
7
|
+
import { EnvToggle as u } from "./envToggle.js";
|
|
8
|
+
import { DeveloperStorage as b } from "../storage.js";
|
|
9
|
+
import "@streamlayer/sdk-web-core";
|
|
10
|
+
import "@nanostores/react";
|
|
11
|
+
import "./styles.js";
|
|
8
12
|
import "@streamlayer/sdk-web-storage";
|
|
9
|
-
const
|
|
13
|
+
const v = n.div`
|
|
10
14
|
position: fixed;
|
|
11
15
|
bottom: 0;
|
|
12
16
|
right: 0;
|
|
13
|
-
padding: 10px;
|
|
14
|
-
padding-right: 60px;
|
|
15
17
|
max-width: 600px;
|
|
16
|
-
`,
|
|
18
|
+
`, y = n.div`
|
|
17
19
|
flex-direction: column;
|
|
18
|
-
gap:
|
|
19
|
-
|
|
20
|
+
gap: 10px;
|
|
21
|
+
margin-right: 60px;
|
|
22
|
+
display: flex;
|
|
23
|
+
transition: all .3s ease;
|
|
24
|
+
transform-origin: bottom right;
|
|
25
|
+
|
|
26
|
+
&[data-opened='false'] {
|
|
27
|
+
transform: scale(0) translateY(-100%);
|
|
28
|
+
}
|
|
29
|
+
`, w = n.button`
|
|
20
30
|
position: absolute;
|
|
21
31
|
z-index: 10000;
|
|
22
32
|
bottom: 10px;
|
|
23
33
|
right: 10px;
|
|
24
34
|
width: 40px;
|
|
25
35
|
height: 40px;
|
|
26
|
-
|
|
27
36
|
display: flex;
|
|
28
37
|
flex-direction: column;
|
|
29
38
|
justify-content: space-around;
|
|
@@ -43,7 +52,7 @@ const g = n.div`
|
|
|
43
52
|
transform: translateY(4px);
|
|
44
53
|
}
|
|
45
54
|
|
|
46
|
-
&[data-
|
|
55
|
+
&[data-opened='true'] {
|
|
47
56
|
span:nth-child(odd) {
|
|
48
57
|
opacity: 0;
|
|
49
58
|
}
|
|
@@ -56,21 +65,22 @@ const g = n.div`
|
|
|
56
65
|
width: 100%;
|
|
57
66
|
height: 4px;
|
|
58
67
|
}
|
|
59
|
-
`,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
/* @__PURE__ */
|
|
65
|
-
/* @__PURE__ */
|
|
66
|
-
/* @__PURE__ */ e("span", {})
|
|
68
|
+
`, O = ({ sdk: t, sdkKey: s, setSdkKey: i, env: d, setEnv: p }) => {
|
|
69
|
+
const r = c(() => new b(), []), [a, m] = x(!1);
|
|
70
|
+
return /* @__PURE__ */ e(v, { children: [
|
|
71
|
+
/* @__PURE__ */ e(w, { "data-opened": a.toString(), onClick: () => m((l) => !l), children: [
|
|
72
|
+
/* @__PURE__ */ o("span", {}),
|
|
73
|
+
/* @__PURE__ */ o("span", {}),
|
|
74
|
+
/* @__PURE__ */ o("span", {})
|
|
67
75
|
] }),
|
|
68
|
-
/* @__PURE__ */
|
|
69
|
-
/* @__PURE__ */
|
|
70
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ e(y, { "data-opened": a.toString(), children: [
|
|
77
|
+
p && /* @__PURE__ */ o(u, { env: d, setEnv: p, storage: r }),
|
|
78
|
+
i && /* @__PURE__ */ o(h, { sdkKey: s, setSdkKey: i, storage: r }),
|
|
79
|
+
t && /* @__PURE__ */ o(g, { sdk: t, storage: r }),
|
|
80
|
+
t && /* @__PURE__ */ o(f, { sdk: t, storage: r })
|
|
71
81
|
] })
|
|
72
82
|
] });
|
|
73
83
|
};
|
|
74
84
|
export {
|
|
75
|
-
|
|
85
|
+
O as Developer
|
|
76
86
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsxs as t, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { styled as o } from "@linaria/react";
|
|
3
|
+
const d = o.div`
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
padding: 4px 6px;
|
|
7
|
+
font-size: 16px;
|
|
8
|
+
user-select: none;
|
|
9
|
+
|
|
10
|
+
label {
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
}
|
|
13
|
+
`, a = o.div`
|
|
14
|
+
width: 2rem;
|
|
15
|
+
height: 1rem;
|
|
16
|
+
background: #fff;
|
|
17
|
+
border-radius: 1em;
|
|
18
|
+
position: relative;
|
|
19
|
+
margin-left: 5px;
|
|
20
|
+
|
|
21
|
+
input {
|
|
22
|
+
opacity: 0;
|
|
23
|
+
position: relative;
|
|
24
|
+
z-index: 1;
|
|
25
|
+
|
|
26
|
+
&:checked + span {
|
|
27
|
+
transform: translate3d(100%, 0, 0);
|
|
28
|
+
background: green;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
span {
|
|
33
|
+
display: block;
|
|
34
|
+
position: absolute;
|
|
35
|
+
top: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
height: 1rem;
|
|
38
|
+
width: 1rem;
|
|
39
|
+
border-radius: 1em;
|
|
40
|
+
background: gray;
|
|
41
|
+
box-shadow: 0 0.1em 0.3em rgba(0,0,0,0.3);
|
|
42
|
+
transition: all 300ms;
|
|
43
|
+
}
|
|
44
|
+
`, m = ({ env: r, setEnv: i, storage: s }) => /* @__PURE__ */ t(d, { children: [
|
|
45
|
+
/* @__PURE__ */ e("label", { htmlFor: "slEnvCheckbox", children: "Production:" }),
|
|
46
|
+
/* @__PURE__ */ t(a, { children: [
|
|
47
|
+
/* @__PURE__ */ e("input", { id: "slEnvCheckbox", type: "checkbox", checked: r === "production", onChange: () => {
|
|
48
|
+
i((c) => {
|
|
49
|
+
const n = c === "production" ? "development" : "production";
|
|
50
|
+
return s.setEnv(n), n;
|
|
51
|
+
});
|
|
52
|
+
} }),
|
|
53
|
+
/* @__PURE__ */ e("span", {})
|
|
54
|
+
] })
|
|
55
|
+
] });
|
|
56
|
+
export {
|
|
57
|
+
m as EnvToggle
|
|
58
|
+
};
|
|
@@ -1,56 +1,22 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { useState as
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
input {
|
|
12
|
-
display: block;
|
|
13
|
-
width: 100%;
|
|
14
|
-
color: #fff;
|
|
15
|
-
font-size: 24px;
|
|
16
|
-
border: none;
|
|
17
|
-
padding: 2px;
|
|
18
|
-
padding-left: 10px;
|
|
19
|
-
background: linear-gradient(136.45deg, rgba(60, 139, 251, 0.3) 0.57%, rgba(0, 79, 190, 0.3) 100%);
|
|
20
|
-
border: 1px solid transparent;
|
|
21
|
-
outline: none;
|
|
22
|
-
|
|
23
|
-
&:focus {
|
|
24
|
-
border-color: rgb(29, 123, 255);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
label {
|
|
29
|
-
margin-right: 4px;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
button {
|
|
33
|
-
width: 150px;
|
|
34
|
-
color: #fff;
|
|
35
|
-
background: transparent;
|
|
36
|
-
margin: 0;
|
|
37
|
-
padding: 0;
|
|
38
|
-
cursor: pointer;
|
|
39
|
-
border: none;
|
|
40
|
-
text-transform: uppercase;
|
|
41
|
-
}
|
|
42
|
-
`, v = ({ sdk: o, useStreamLayerEventsIds: i, storage: n }) => {
|
|
43
|
-
const [e, d] = l(n.getEvent() || ""), r = () => {
|
|
44
|
-
o.createEventSession(e), n.setEvent(e);
|
|
1
|
+
import { jsx as t, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import "@streamlayer/sdk-web-core";
|
|
3
|
+
import { useState as p, useEffect as d } from "react";
|
|
4
|
+
import { useStore as m } from "@nanostores/react";
|
|
5
|
+
import { InputField as u } from "./styles.js";
|
|
6
|
+
import "@linaria/react";
|
|
7
|
+
const I = ({ sdk: n, storage: s }) => {
|
|
8
|
+
var i;
|
|
9
|
+
const { organizationSettings: r } = m(n.sdkStore), v = !((i = r == null ? void 0 : r.data) != null && i.provider), [e, l] = p(s.getEvent() || ""), o = () => {
|
|
10
|
+
n.createEventSession(e), s.setEvent(e);
|
|
45
11
|
};
|
|
46
|
-
return
|
|
47
|
-
e &&
|
|
48
|
-
}, []), /* @__PURE__ */ t("div", { children: /* @__PURE__ */
|
|
49
|
-
/* @__PURE__ */ t("label", { children:
|
|
50
|
-
/* @__PURE__ */ t("input", { type: "text", value: e, onChange: (a) =>
|
|
51
|
-
/* @__PURE__ */ t("button", { onClick:
|
|
12
|
+
return d(() => {
|
|
13
|
+
e && o();
|
|
14
|
+
}, []), /* @__PURE__ */ t("div", { children: /* @__PURE__ */ c(u, { children: [
|
|
15
|
+
/* @__PURE__ */ t("label", { children: v ? "Use StreamLayer event ids" : "Use your provider event ids" }),
|
|
16
|
+
/* @__PURE__ */ t("input", { type: "text", value: e, onChange: (a) => l(a.target.value) }),
|
|
17
|
+
/* @__PURE__ */ t("button", { onClick: o, children: "set" })
|
|
52
18
|
] }) });
|
|
53
19
|
};
|
|
54
20
|
export {
|
|
55
|
-
|
|
21
|
+
I as EventInput
|
|
56
22
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u } from "react";
|
|
3
|
+
import { InputField as m } from "./styles.js";
|
|
4
|
+
import "@linaria/react";
|
|
5
|
+
const b = ({
|
|
6
|
+
sdkKey: r,
|
|
7
|
+
setSdkKey: i,
|
|
8
|
+
storage: n
|
|
9
|
+
}) => {
|
|
10
|
+
const [e, o] = u(r);
|
|
11
|
+
return /* @__PURE__ */ t("div", { children: /* @__PURE__ */ l(m, { children: [
|
|
12
|
+
/* @__PURE__ */ t("label", { children: "SDK Key" }),
|
|
13
|
+
/* @__PURE__ */ t("input", { type: "text", value: e, onChange: (s) => {
|
|
14
|
+
o(s.target.value);
|
|
15
|
+
} }),
|
|
16
|
+
/* @__PURE__ */ t("button", { onClick: () => {
|
|
17
|
+
n.setSdkKey(e), i(e);
|
|
18
|
+
}, children: "set" })
|
|
19
|
+
] }) });
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
b as SdkKey
|
|
23
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { styled as r } from "@linaria/react";
|
|
2
|
+
const n = r.div`
|
|
3
|
+
display: flex;
|
|
4
|
+
background: rgb(29, 123, 255);
|
|
5
|
+
padding: 4px 6px;
|
|
6
|
+
border-radius: 5px;
|
|
7
|
+
font-size: 16px;
|
|
8
|
+
|
|
9
|
+
input {
|
|
10
|
+
display: block;
|
|
11
|
+
width: 100%;
|
|
12
|
+
color: #fff;
|
|
13
|
+
font-size: 24px;
|
|
14
|
+
border: none;
|
|
15
|
+
padding: 2px;
|
|
16
|
+
padding-left: 10px;
|
|
17
|
+
background: linear-gradient(136.45deg, rgba(60, 139, 251, 0.3) 0.57%, rgba(0, 79, 190, 0.3) 100%);
|
|
18
|
+
border: 1px solid transparent;
|
|
19
|
+
outline: none;
|
|
20
|
+
|
|
21
|
+
&:focus {
|
|
22
|
+
border-color: rgb(29, 123, 255);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
label {
|
|
27
|
+
margin-right: 4px;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
button {
|
|
31
|
+
width: 150px;
|
|
32
|
+
color: #fff;
|
|
33
|
+
background: transparent;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
border: none;
|
|
38
|
+
text-transform: uppercase;
|
|
39
|
+
}
|
|
40
|
+
`;
|
|
41
|
+
export {
|
|
42
|
+
n as InputField
|
|
43
|
+
};
|
package/lib/utils/createDemo.js
CHANGED
|
@@ -1,46 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { anonymous as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { Developer as
|
|
5
|
-
import { useStreamLayerApp as
|
|
6
|
-
import "
|
|
1
|
+
import { jsx as t, jsxs as f, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { anonymous as g } from "@streamlayer/sdk-web-anonymous-auth";
|
|
3
|
+
import { useMemo as p, useState as d } from "react";
|
|
4
|
+
import { Developer as S } from "./components/developer.js";
|
|
5
|
+
import { useStreamLayerApp as v } from "./useStreamLayerApp.js";
|
|
6
|
+
import { DeveloperStorage as y } from "./storage.js";
|
|
7
7
|
import "@linaria/react";
|
|
8
8
|
import "./components/eventInput.js";
|
|
9
|
+
import "@streamlayer/sdk-web-core";
|
|
10
|
+
import "@nanostores/react";
|
|
11
|
+
import "./components/styles.js";
|
|
9
12
|
import "./components/bypassLogin.js";
|
|
10
|
-
import "./
|
|
11
|
-
import "
|
|
13
|
+
import "./components/sdkKey.js";
|
|
14
|
+
import "./components/envToggle.js";
|
|
12
15
|
import "@streamlayer/sdk-web";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
import "@streamlayer/sdk-web-storage";
|
|
17
|
+
function l({
|
|
18
|
+
Component: r,
|
|
19
|
+
Story: o,
|
|
20
|
+
args: D
|
|
17
21
|
}) {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
}, []),
|
|
22
|
-
return
|
|
23
|
-
/* @__PURE__ */ r
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
] })
|
|
22
|
+
const m = p(() => new y(), []), [n, c] = d(m.getEnv()), [s, a] = d(m.getSdkKey() || "set-sdk-key"), u = p(() => {
|
|
23
|
+
const i = /* @__PURE__ */ new Set();
|
|
24
|
+
return i.add(g), i;
|
|
25
|
+
}, []), e = v(s, u, n === "production");
|
|
26
|
+
return /* @__PURE__ */ f(k, { children: [
|
|
27
|
+
e ? /* @__PURE__ */ t(r, { Story: o, sdk: e }) : /* @__PURE__ */ t("div", { children: "wait sdk..." }),
|
|
28
|
+
/* @__PURE__ */ t(S, { sdk: e, sdkKey: s, setSdkKey: a, env: n, setEnv: c })
|
|
29
|
+
] });
|
|
26
30
|
}
|
|
27
|
-
function
|
|
31
|
+
function H(r) {
|
|
28
32
|
return {
|
|
29
|
-
args: {
|
|
30
|
-
SDK_KEY: {}.NX_DEMO_SDK_KEY,
|
|
31
|
-
production: !0
|
|
32
|
-
},
|
|
33
33
|
decorators: [
|
|
34
|
-
(
|
|
35
|
-
const { SDK_KEY: i } = o;
|
|
36
|
-
return i ? /* @__PURE__ */ r(a, { Story: e, args: o, Component: t }) : /* @__PURE__ */ p("div", { children: [
|
|
37
|
-
"Provide ",
|
|
38
|
-
/* @__PURE__ */ r("b", { children: "SDK_KEY" })
|
|
39
|
-
] });
|
|
40
|
-
}
|
|
34
|
+
(o) => /* @__PURE__ */ t(l, { Story: o, Component: r })
|
|
41
35
|
]
|
|
42
36
|
};
|
|
43
37
|
}
|
|
44
38
|
export {
|
|
45
|
-
|
|
39
|
+
H as createDemo
|
|
46
40
|
};
|
package/lib/utils/storage.js
CHANGED
|
@@ -1,36 +1,52 @@
|
|
|
1
1
|
var n = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { Storage as
|
|
5
|
-
class
|
|
2
|
+
var i = (s, r, e) => r in s ? n(s, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[r] = e;
|
|
3
|
+
var t = (s, r, e) => (i(s, typeof r != "symbol" ? r + "" : r, e), e);
|
|
4
|
+
import { Storage as h } from "@streamlayer/sdk-web-storage";
|
|
5
|
+
class d extends h {
|
|
6
6
|
constructor() {
|
|
7
7
|
super("dev");
|
|
8
8
|
// Schema
|
|
9
|
-
|
|
9
|
+
t(this, "setSchema", (e) => {
|
|
10
10
|
this.write("schema", e);
|
|
11
11
|
});
|
|
12
|
-
|
|
12
|
+
t(this, "getSchema", () => this.read(
|
|
13
13
|
"schema"
|
|
14
14
|
/* SCHEMA */
|
|
15
15
|
));
|
|
16
16
|
// Token
|
|
17
|
-
|
|
17
|
+
t(this, "setToken", (e) => {
|
|
18
18
|
this.write("token", e);
|
|
19
19
|
});
|
|
20
|
-
|
|
20
|
+
t(this, "getToken", () => this.read(
|
|
21
21
|
"token"
|
|
22
22
|
/* TOKEN */
|
|
23
23
|
));
|
|
24
24
|
// Event
|
|
25
|
-
|
|
25
|
+
t(this, "setEvent", (e) => {
|
|
26
26
|
this.write("event", e);
|
|
27
27
|
});
|
|
28
|
-
|
|
28
|
+
t(this, "getEvent", () => this.read(
|
|
29
29
|
"event"
|
|
30
30
|
/* EVENT */
|
|
31
31
|
));
|
|
32
|
+
// SDK_KEY
|
|
33
|
+
t(this, "setSdkKey", (e) => {
|
|
34
|
+
this.write("sdkKey", e);
|
|
35
|
+
});
|
|
36
|
+
t(this, "getSdkKey", () => this.read(
|
|
37
|
+
"sdkKey"
|
|
38
|
+
/* SDK_KEY */
|
|
39
|
+
));
|
|
40
|
+
// ENV
|
|
41
|
+
t(this, "setEnv", (e) => {
|
|
42
|
+
this.write("env", e);
|
|
43
|
+
});
|
|
44
|
+
t(this, "getEnv", () => this.read(
|
|
45
|
+
"env"
|
|
46
|
+
/* ENV */
|
|
47
|
+
) || "production");
|
|
32
48
|
}
|
|
33
49
|
}
|
|
34
50
|
export {
|
|
35
|
-
|
|
51
|
+
d as DeveloperStorage
|
|
36
52
|
};
|