@shiflo/ui 0.1.1 → 0.1.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/dist/components/BottomSheet/BottomSheet.mjs +1 -1
- package/dist/components/Button/Button.mjs +29 -29
- package/dist/components/Dialog/Dialog.mjs +24 -25
- package/dist/components/Overlay/Overlay.mjs +44 -53
- package/dist/components/Snackbar/Snackbar.mjs +50 -53
- package/package.json +1 -1
- package/dist/components/FPSMonitor/FPSMonitor.mjs +0 -201
- package/dist/components/FPSMonitor/FPSMonitor.utils.mjs +0 -116
- package/dist/components/FPSMonitor/index.mjs +0 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as k } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { motion as
|
|
4
|
-
const m = f
|
|
2
|
+
import v from "@emotion/styled";
|
|
3
|
+
import { motion as f } from "motion/react";
|
|
4
|
+
const m = v(f.button)`
|
|
5
5
|
display: inline-flex;
|
|
6
6
|
align-items: center;
|
|
7
7
|
justify-content: center;
|
|
@@ -9,11 +9,11 @@ const m = f(v.button)`
|
|
|
9
9
|
font-weight: 500;
|
|
10
10
|
transition: all 0.2s;
|
|
11
11
|
|
|
12
|
-
${({ theme: t, variant: l, size:
|
|
12
|
+
${({ theme: t, variant: l, size: d, color: c }) => {
|
|
13
13
|
const {
|
|
14
14
|
mode: a,
|
|
15
15
|
palette: { primary: e, secondary: r, neutral: o, gradient: p },
|
|
16
|
-
typography: { body1:
|
|
16
|
+
typography: { body1: s, body2: g, small1: h, small2: u },
|
|
17
17
|
spacing: n,
|
|
18
18
|
radius: b
|
|
19
19
|
} = t, i = {};
|
|
@@ -89,7 +89,7 @@ const m = f(v.button)`
|
|
|
89
89
|
});
|
|
90
90
|
break;
|
|
91
91
|
default:
|
|
92
|
-
if (
|
|
92
|
+
if (c === "secondary") {
|
|
93
93
|
Object.assign(i, {
|
|
94
94
|
backgroundColor: r.main,
|
|
95
95
|
color: a === "dark" ? o[900] : o[700],
|
|
@@ -134,16 +134,16 @@ const m = f(v.button)`
|
|
|
134
134
|
});
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
137
|
-
switch (
|
|
137
|
+
switch (d) {
|
|
138
138
|
case "large":
|
|
139
139
|
Object.assign(i, {
|
|
140
140
|
padding: `${n[300]} ${n[350]}`,
|
|
141
141
|
borderRadius: b[300],
|
|
142
|
-
fontSize:
|
|
143
|
-
lineHeight:
|
|
142
|
+
fontSize: s.fontSize,
|
|
143
|
+
lineHeight: s.lineHeight,
|
|
144
144
|
"& svg": {
|
|
145
|
-
width:
|
|
146
|
-
height:
|
|
145
|
+
width: s.fontSize,
|
|
146
|
+
height: s.fontSize
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
break;
|
|
@@ -190,19 +190,19 @@ const m = f(v.button)`
|
|
|
190
190
|
function C({
|
|
191
191
|
ref: t,
|
|
192
192
|
children: l,
|
|
193
|
-
variant:
|
|
194
|
-
size:
|
|
193
|
+
variant: d = "filled",
|
|
194
|
+
size: c = "medium",
|
|
195
195
|
color: a = "primary",
|
|
196
196
|
startIcon: e,
|
|
197
197
|
endIcon: r,
|
|
198
198
|
...o
|
|
199
199
|
}) {
|
|
200
|
-
return
|
|
200
|
+
return d === "text" ? /* @__PURE__ */ k(
|
|
201
201
|
m,
|
|
202
202
|
{
|
|
203
203
|
ref: t,
|
|
204
204
|
variant: "text",
|
|
205
|
-
size:
|
|
205
|
+
size: c,
|
|
206
206
|
color: "secondary",
|
|
207
207
|
layout: !0,
|
|
208
208
|
whileHover: {
|
|
@@ -211,8 +211,8 @@ function C({
|
|
|
211
211
|
whileTap: { scale: 0.98 },
|
|
212
212
|
transition: {
|
|
213
213
|
type: "spring",
|
|
214
|
-
|
|
215
|
-
|
|
214
|
+
duration: 0.2,
|
|
215
|
+
bounce: 0.2
|
|
216
216
|
},
|
|
217
217
|
...o,
|
|
218
218
|
children: [
|
|
@@ -221,12 +221,12 @@ function C({
|
|
|
221
221
|
r
|
|
222
222
|
]
|
|
223
223
|
}
|
|
224
|
-
) :
|
|
224
|
+
) : d === "ghost" ? /* @__PURE__ */ k(
|
|
225
225
|
m,
|
|
226
226
|
{
|
|
227
227
|
ref: t,
|
|
228
228
|
variant: "ghost",
|
|
229
|
-
size:
|
|
229
|
+
size: c,
|
|
230
230
|
color: "primary",
|
|
231
231
|
layout: !0,
|
|
232
232
|
whileHover: {
|
|
@@ -235,8 +235,8 @@ function C({
|
|
|
235
235
|
whileTap: { scale: 0.98 },
|
|
236
236
|
transition: {
|
|
237
237
|
type: "spring",
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
duration: 0.2,
|
|
239
|
+
bounce: 0.2
|
|
240
240
|
},
|
|
241
241
|
...o,
|
|
242
242
|
children: [
|
|
@@ -245,12 +245,12 @@ function C({
|
|
|
245
245
|
r
|
|
246
246
|
]
|
|
247
247
|
}
|
|
248
|
-
) :
|
|
248
|
+
) : d === "gradient" ? /* @__PURE__ */ k(
|
|
249
249
|
m,
|
|
250
250
|
{
|
|
251
251
|
ref: t,
|
|
252
252
|
variant: "gradient",
|
|
253
|
-
size:
|
|
253
|
+
size: c,
|
|
254
254
|
color: "primary",
|
|
255
255
|
layout: !0,
|
|
256
256
|
whileHover: {
|
|
@@ -259,8 +259,8 @@ function C({
|
|
|
259
259
|
whileTap: { scale: 0.98 },
|
|
260
260
|
transition: {
|
|
261
261
|
type: "spring",
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
duration: 0.2,
|
|
263
|
+
bounce: 0.2
|
|
264
264
|
},
|
|
265
265
|
...o,
|
|
266
266
|
children: [
|
|
@@ -273,8 +273,8 @@ function C({
|
|
|
273
273
|
m,
|
|
274
274
|
{
|
|
275
275
|
ref: t,
|
|
276
|
-
variant:
|
|
277
|
-
size:
|
|
276
|
+
variant: d,
|
|
277
|
+
size: c,
|
|
278
278
|
color: a,
|
|
279
279
|
layout: !0,
|
|
280
280
|
whileHover: {
|
|
@@ -283,8 +283,8 @@ function C({
|
|
|
283
283
|
whileTap: { scale: 0.98 },
|
|
284
284
|
transition: {
|
|
285
285
|
type: "spring",
|
|
286
|
-
|
|
287
|
-
|
|
286
|
+
duration: 0.2,
|
|
287
|
+
bounce: 0.2
|
|
288
288
|
},
|
|
289
289
|
...o,
|
|
290
290
|
children: [
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as m } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
4
|
-
import { motion as
|
|
5
|
-
import
|
|
6
|
-
const
|
|
2
|
+
import { useState as p, useEffect as d } from "react";
|
|
3
|
+
import u from "@emotion/styled";
|
|
4
|
+
import { motion as h } from "motion/react";
|
|
5
|
+
import g from "../Overlay/Overlay.mjs";
|
|
6
|
+
const y = u(h.div)`
|
|
7
7
|
width: calc(100% - ${({ theme: { spacing: e } }) => e[800]});
|
|
8
8
|
max-width: ${({ maxWidth: e = "375px" }) => e};
|
|
9
9
|
max-height: calc(100% - ${({ theme: { spacing: e } }) => e[800]});
|
|
@@ -17,60 +17,59 @@ const x = g(y.div)`
|
|
|
17
17
|
}
|
|
18
18
|
}) => e.background};
|
|
19
19
|
`;
|
|
20
|
-
function
|
|
20
|
+
function O({
|
|
21
21
|
open: e,
|
|
22
|
-
onClose:
|
|
23
|
-
children:
|
|
22
|
+
onClose: c,
|
|
23
|
+
children: l,
|
|
24
24
|
transitionDuration: a = 0.2,
|
|
25
25
|
onClick: o,
|
|
26
|
-
style:
|
|
27
|
-
maxWidth:
|
|
26
|
+
style: $,
|
|
27
|
+
maxWidth: n = "375px",
|
|
28
28
|
...s
|
|
29
29
|
}) {
|
|
30
|
-
const [
|
|
30
|
+
const [i, r] = p(!1), f = (t) => {
|
|
31
31
|
t.stopPropagation(), typeof o == "function" && o(t);
|
|
32
32
|
};
|
|
33
|
-
return
|
|
33
|
+
return d(() => {
|
|
34
34
|
let t;
|
|
35
35
|
return e ? t = requestAnimationFrame(() => {
|
|
36
|
-
|
|
37
|
-
}) :
|
|
36
|
+
r(!0);
|
|
37
|
+
}) : r(!1), () => {
|
|
38
38
|
t && cancelAnimationFrame(t);
|
|
39
39
|
};
|
|
40
40
|
}, [e]), /* @__PURE__ */ m(
|
|
41
|
-
|
|
41
|
+
g,
|
|
42
42
|
{
|
|
43
|
-
ref: f,
|
|
44
43
|
open: e,
|
|
45
|
-
onClose:
|
|
44
|
+
onClose: c,
|
|
46
45
|
transitionDuration: a,
|
|
47
46
|
placement: "center-middle",
|
|
48
47
|
children: /* @__PURE__ */ m(
|
|
49
|
-
|
|
48
|
+
y,
|
|
50
49
|
{
|
|
51
50
|
transitionDuration: a,
|
|
52
|
-
maxWidth:
|
|
53
|
-
onClick:
|
|
51
|
+
maxWidth: n,
|
|
52
|
+
onClick: f,
|
|
54
53
|
initial: {
|
|
55
54
|
scale: 0.9,
|
|
56
55
|
opacity: 0
|
|
57
56
|
},
|
|
58
57
|
animate: {
|
|
59
|
-
scale:
|
|
60
|
-
opacity:
|
|
58
|
+
scale: i ? 1 : 0.9,
|
|
59
|
+
opacity: i ? 1 : 0
|
|
61
60
|
},
|
|
62
61
|
transition: {
|
|
63
62
|
type: "spring",
|
|
64
63
|
duration: a,
|
|
65
|
-
|
|
64
|
+
bounce: 0.2
|
|
66
65
|
},
|
|
67
66
|
...s,
|
|
68
|
-
children:
|
|
67
|
+
children: l
|
|
69
68
|
}
|
|
70
69
|
)
|
|
71
70
|
}
|
|
72
71
|
);
|
|
73
72
|
}
|
|
74
73
|
export {
|
|
75
|
-
|
|
74
|
+
O as default
|
|
76
75
|
};
|
|
@@ -1,35 +1,30 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { useTheme as
|
|
5
|
-
import
|
|
6
|
-
import { motion as
|
|
7
|
-
const
|
|
1
|
+
import { jsxs as k, jsx as m } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState as f, useEffect as j } from "react";
|
|
3
|
+
import { createPortal as v } from "react-dom";
|
|
4
|
+
import { useTheme as x } from "@emotion/react";
|
|
5
|
+
import r from "@emotion/styled";
|
|
6
|
+
import { motion as n } from "motion/react";
|
|
7
|
+
const C = r(n.div)`
|
|
8
8
|
position: fixed;
|
|
9
9
|
top: 0;
|
|
10
10
|
left: 0;
|
|
11
11
|
z-index: 1;
|
|
12
|
-
`,
|
|
12
|
+
`, A = r(n.div)`
|
|
13
13
|
position: fixed;
|
|
14
14
|
top: 0;
|
|
15
15
|
left: 0;
|
|
16
16
|
width: 100%;
|
|
17
17
|
height: 100%;
|
|
18
|
-
|
|
19
|
-
theme: {
|
|
20
|
-
palette: { common: r }
|
|
21
|
-
}
|
|
22
|
-
}) => r.overlay};
|
|
23
|
-
`, S = a(o.div)`
|
|
18
|
+
`, w = r(n.div)`
|
|
24
19
|
position: fixed;
|
|
25
20
|
width: 100%;
|
|
26
21
|
display: flex;
|
|
27
22
|
justify-content: center;
|
|
28
23
|
align-items: center;
|
|
29
24
|
|
|
30
|
-
${({ placement:
|
|
25
|
+
${({ placement: o }) => {
|
|
31
26
|
const t = {};
|
|
32
|
-
switch (
|
|
27
|
+
switch (o) {
|
|
33
28
|
case "top-left":
|
|
34
29
|
Object.assign(t, {
|
|
35
30
|
top: 0,
|
|
@@ -93,60 +88,56 @@ const F = a(o.div)`
|
|
|
93
88
|
return t;
|
|
94
89
|
}}
|
|
95
90
|
`;
|
|
96
|
-
function
|
|
97
|
-
children:
|
|
91
|
+
function P({
|
|
92
|
+
children: o,
|
|
98
93
|
open: t,
|
|
99
|
-
onClose:
|
|
100
|
-
transitionDuration:
|
|
101
|
-
placement:
|
|
102
|
-
ref:
|
|
103
|
-
onClick:
|
|
104
|
-
hideOverlay:
|
|
105
|
-
...
|
|
94
|
+
onClose: p,
|
|
95
|
+
transitionDuration: a = 0.2,
|
|
96
|
+
placement: b,
|
|
97
|
+
ref: I,
|
|
98
|
+
onClick: d,
|
|
99
|
+
hideOverlay: s,
|
|
100
|
+
...g
|
|
106
101
|
}) {
|
|
107
102
|
const {
|
|
108
|
-
palette: { common:
|
|
109
|
-
} =
|
|
110
|
-
|
|
103
|
+
palette: { common: i }
|
|
104
|
+
} = x(), [u, c] = f(!0), [h, l] = f(!1), y = (e) => {
|
|
105
|
+
p?.(), d?.(e);
|
|
106
|
+
}, O = () => {
|
|
107
|
+
t || c(!0);
|
|
111
108
|
};
|
|
112
|
-
return
|
|
109
|
+
return j(() => {
|
|
113
110
|
let e;
|
|
114
|
-
return t ? (
|
|
115
|
-
|
|
116
|
-
})) :
|
|
111
|
+
return t ? (c(!1), e = requestAnimationFrame(() => {
|
|
112
|
+
l(!0);
|
|
113
|
+
})) : l(!1), () => {
|
|
117
114
|
e && cancelAnimationFrame(e);
|
|
118
115
|
};
|
|
119
|
-
}, [t,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return e?.addEventListener("transitionend", l), () => {
|
|
124
|
-
e?.removeEventListener("transitionend", l);
|
|
125
|
-
};
|
|
126
|
-
}, [t]), O ? null : L(
|
|
127
|
-
/* @__PURE__ */ x(F, { children: [
|
|
128
|
-
/* @__PURE__ */ f(
|
|
129
|
-
R,
|
|
116
|
+
}, [t, a]), u ? null : v(
|
|
117
|
+
/* @__PURE__ */ k(C, { children: [
|
|
118
|
+
/* @__PURE__ */ m(
|
|
119
|
+
A,
|
|
130
120
|
{
|
|
131
|
-
|
|
132
|
-
initial: { opacity: 0 },
|
|
121
|
+
initial: { opacity: 0, backgroundColor: s ? "rgba(0, 0, 0, 0)" : i.overlay },
|
|
133
122
|
animate: {
|
|
134
|
-
opacity:
|
|
135
|
-
backgroundColor:
|
|
123
|
+
opacity: h ? 1 : 0,
|
|
124
|
+
backgroundColor: s ? "rgba(0, 0, 0, 0)" : i.overlay
|
|
136
125
|
},
|
|
137
126
|
transition: {
|
|
138
|
-
|
|
139
|
-
|
|
127
|
+
type: "spring",
|
|
128
|
+
duration: a,
|
|
129
|
+
bounce: 0.2
|
|
140
130
|
},
|
|
141
|
-
|
|
142
|
-
|
|
131
|
+
onAnimationComplete: O,
|
|
132
|
+
onClick: y,
|
|
133
|
+
...g
|
|
143
134
|
}
|
|
144
135
|
),
|
|
145
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ m(w, { placement: b, children: o })
|
|
146
137
|
] }),
|
|
147
138
|
document.body
|
|
148
139
|
);
|
|
149
140
|
}
|
|
150
141
|
export {
|
|
151
|
-
|
|
142
|
+
P as default
|
|
152
143
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import
|
|
5
|
-
import { motion as
|
|
6
|
-
const
|
|
1
|
+
import { jsxs as $, jsx as l } from "@emotion/react/jsx-runtime";
|
|
2
|
+
import { useState as h, useRef as v, useEffect as x } from "react";
|
|
3
|
+
import { createPortal as S } from "react-dom";
|
|
4
|
+
import n from "@emotion/styled";
|
|
5
|
+
import { motion as k } from "motion/react";
|
|
6
|
+
const A = n(k.div)`
|
|
7
7
|
position: fixed;
|
|
8
8
|
left: 50%;
|
|
9
9
|
bottom: ${({ theme: { spacing: e } }) => `calc(${e[800]} + var(--safe-area-inset-bottom, 0px))`};
|
|
@@ -21,9 +21,9 @@ const R = i(L.div)`
|
|
|
21
21
|
}) => e[900]};
|
|
22
22
|
border-radius: ${({ theme: { radius: e } }) => e[400]};
|
|
23
23
|
z-index: 1;
|
|
24
|
-
`,
|
|
24
|
+
`, z = n.div`
|
|
25
25
|
white-space: nowrap;
|
|
26
|
-
`, j =
|
|
26
|
+
`, j = n.div`
|
|
27
27
|
flex-grow: 1;
|
|
28
28
|
display: -webkit-box;
|
|
29
29
|
overflow: hidden;
|
|
@@ -40,52 +40,49 @@ const R = i(L.div)`
|
|
|
40
40
|
lineHeight: t.lineHeight,
|
|
41
41
|
color: e.surface
|
|
42
42
|
})}
|
|
43
|
-
`,
|
|
43
|
+
`, C = n.div`
|
|
44
44
|
white-space: nowrap;
|
|
45
45
|
`;
|
|
46
|
-
function
|
|
46
|
+
function E({
|
|
47
47
|
children: e,
|
|
48
48
|
open: t,
|
|
49
|
-
onClose:
|
|
50
|
-
transitionDuration:
|
|
51
|
-
style:
|
|
52
|
-
ref:
|
|
49
|
+
onClose: c,
|
|
50
|
+
transitionDuration: r = 0.2,
|
|
51
|
+
style: F,
|
|
52
|
+
ref: I,
|
|
53
53
|
startIcon: m,
|
|
54
|
-
action:
|
|
55
|
-
maxWidth:
|
|
56
|
-
autoHideDuration:
|
|
54
|
+
action: s,
|
|
55
|
+
maxWidth: b = "375px",
|
|
56
|
+
autoHideDuration: f = 3e3,
|
|
57
57
|
disableAutoHide: p,
|
|
58
|
-
|
|
58
|
+
...w
|
|
59
59
|
}) {
|
|
60
|
-
const [
|
|
61
|
-
|
|
62
|
-
let
|
|
63
|
-
return t ? (
|
|
64
|
-
|
|
65
|
-
})) :
|
|
66
|
-
|
|
60
|
+
const [g, d] = h(!0), [i, u] = h(!1), o = v(null);
|
|
61
|
+
x(() => {
|
|
62
|
+
let a;
|
|
63
|
+
return t ? (d(!1), a = requestAnimationFrame(() => {
|
|
64
|
+
u(!0);
|
|
65
|
+
})) : u(!1), () => {
|
|
66
|
+
a && cancelAnimationFrame(a);
|
|
67
67
|
};
|
|
68
|
-
}, [t,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
l?.();
|
|
79
|
-
}, d), () => {
|
|
80
|
-
s.current && clearTimeout(s.current);
|
|
68
|
+
}, [t, r]);
|
|
69
|
+
const y = () => {
|
|
70
|
+
t || d(!0);
|
|
71
|
+
};
|
|
72
|
+
return x(() => {
|
|
73
|
+
if (!(p || !i))
|
|
74
|
+
return o.current = setTimeout(() => {
|
|
75
|
+
c?.();
|
|
76
|
+
}, f), () => {
|
|
77
|
+
o.current && clearTimeout(o.current);
|
|
81
78
|
};
|
|
82
|
-
}, [p,
|
|
83
|
-
/* @__PURE__ */
|
|
84
|
-
|
|
79
|
+
}, [p, f, i, c]), g ? null : S(
|
|
80
|
+
/* @__PURE__ */ $(
|
|
81
|
+
A,
|
|
85
82
|
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
transitionDuration: r,
|
|
84
|
+
maxWidth: b,
|
|
85
|
+
onAnimationComplete: y,
|
|
89
86
|
initial: {
|
|
90
87
|
x: "-50%",
|
|
91
88
|
scale: 0.97,
|
|
@@ -93,19 +90,19 @@ function B({
|
|
|
93
90
|
},
|
|
94
91
|
animate: {
|
|
95
92
|
x: "-50%",
|
|
96
|
-
scale:
|
|
97
|
-
opacity:
|
|
93
|
+
scale: i ? 1 : 0.97,
|
|
94
|
+
opacity: i ? 1 : 0
|
|
98
95
|
},
|
|
99
96
|
transition: {
|
|
100
97
|
type: "spring",
|
|
101
|
-
duration:
|
|
102
|
-
|
|
98
|
+
duration: r,
|
|
99
|
+
bounce: 0.2
|
|
103
100
|
},
|
|
104
|
-
|
|
101
|
+
...w,
|
|
105
102
|
children: [
|
|
106
|
-
m && /* @__PURE__ */
|
|
107
|
-
/* @__PURE__ */
|
|
108
|
-
|
|
103
|
+
m && /* @__PURE__ */ l(z, { children: m }),
|
|
104
|
+
/* @__PURE__ */ l(j, { children: e }),
|
|
105
|
+
s && /* @__PURE__ */ l(C, { children: s })
|
|
109
106
|
]
|
|
110
107
|
}
|
|
111
108
|
),
|
|
@@ -113,5 +110,5 @@ function B({
|
|
|
113
110
|
);
|
|
114
111
|
}
|
|
115
112
|
export {
|
|
116
|
-
|
|
113
|
+
E as default
|
|
117
114
|
};
|
package/package.json
CHANGED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import { jsxs as t, jsx as r } from "@emotion/react/jsx-runtime";
|
|
2
|
-
import { useState as P, useRef as k, useEffect as A } from "react";
|
|
3
|
-
import { useTheme as E } from "@emotion/react";
|
|
4
|
-
import { motion as u, AnimatePresence as C } from "motion/react";
|
|
5
|
-
import s from "../Box/Box.mjs";
|
|
6
|
-
import { FPSChecker as I } from "./FPSMonitor.utils.mjs";
|
|
7
|
-
import e from "../Typography/Typography.mjs";
|
|
8
|
-
function J({
|
|
9
|
-
trigger: R = !1,
|
|
10
|
-
duration: g = 5e3,
|
|
11
|
-
updateInterval: y = 10,
|
|
12
|
-
threshold: p = 55,
|
|
13
|
-
onComplete: v,
|
|
14
|
-
on60FPSAchieved: b
|
|
15
|
-
}) {
|
|
16
|
-
const {
|
|
17
|
-
palette: { neutral: x, primary: o, feedback: n, common: W, border: w, gradient: T },
|
|
18
|
-
spacing: l,
|
|
19
|
-
radius: d
|
|
20
|
-
} = E(), [i, f] = P(null), [c, F] = P(null), h = k(!1), m = k(null);
|
|
21
|
-
A(() => {
|
|
22
|
-
if (!h.current)
|
|
23
|
-
return h.current = !0, F(null), f(null), m.current = new I(
|
|
24
|
-
{ duration: g, callbackInterval: y },
|
|
25
|
-
{
|
|
26
|
-
onUpdate: (a) => {
|
|
27
|
-
f(a);
|
|
28
|
-
},
|
|
29
|
-
onComplete: (a) => {
|
|
30
|
-
h.current = !1, f(a), v?.(a);
|
|
31
|
-
const S = a.averageFPS >= p;
|
|
32
|
-
F(S), b?.(S);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
), m.current.start(), () => {
|
|
36
|
-
m.current && h.current && m.current.stop();
|
|
37
|
-
};
|
|
38
|
-
}, [R, g, y, p, b, v]);
|
|
39
|
-
const $ = () => i ? i.averageFPS >= 60 ? o.main : i.averageFPS >= 30 ? o.light : n.error.main : x[500], B = () => i ? i.averageFPS >= 60 ? "60프레임 달성!" : i.averageFPS >= 30 ? "30프레임 이상" : "30프레임 미만" : "측정 대기 중", j = (a) => a >= 60 ? o.main : a >= 30 ? o.light : n.error.main, O = (a) => Math.min(a / 60 * 100, 100);
|
|
40
|
-
return /* @__PURE__ */ t(
|
|
41
|
-
u.div,
|
|
42
|
-
{
|
|
43
|
-
initial: { opacity: 0, y: 10 },
|
|
44
|
-
animate: { opacity: 1, y: 0 },
|
|
45
|
-
transition: { duration: 0.3, ease: "easeOut" },
|
|
46
|
-
style: {
|
|
47
|
-
padding: l[600],
|
|
48
|
-
border: `1px solid ${w.light}`,
|
|
49
|
-
borderRadius: d[600],
|
|
50
|
-
backgroundColor: W.surface,
|
|
51
|
-
boxShadow: `0 2px 8px ${x[100]}15`,
|
|
52
|
-
position: "relative",
|
|
53
|
-
overflow: "hidden"
|
|
54
|
-
},
|
|
55
|
-
children: [
|
|
56
|
-
/* @__PURE__ */ r(
|
|
57
|
-
"div",
|
|
58
|
-
{
|
|
59
|
-
style: {
|
|
60
|
-
position: "absolute",
|
|
61
|
-
top: 0,
|
|
62
|
-
left: 0,
|
|
63
|
-
right: 0,
|
|
64
|
-
height: "2px",
|
|
65
|
-
background: T.primaryToAccent,
|
|
66
|
-
opacity: 0.6
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
),
|
|
70
|
-
/* @__PURE__ */ r(s, { mb: "600", children: /* @__PURE__ */ r(e, { variant: "heading3", fontWeight: 700, color: "primary.main", mb: "400", children: "FPS 모니터" }) }),
|
|
71
|
-
/* @__PURE__ */ r(C, { children: i && /* @__PURE__ */ r(
|
|
72
|
-
u.div,
|
|
73
|
-
{
|
|
74
|
-
initial: { opacity: 0 },
|
|
75
|
-
animate: { opacity: 1 },
|
|
76
|
-
exit: { opacity: 0 },
|
|
77
|
-
transition: { duration: 0.2 },
|
|
78
|
-
children: /* @__PURE__ */ t(s, { mb: "600", children: [
|
|
79
|
-
/* @__PURE__ */ t(
|
|
80
|
-
e,
|
|
81
|
-
{
|
|
82
|
-
variant: "body1",
|
|
83
|
-
fontWeight: 700,
|
|
84
|
-
mb: "400",
|
|
85
|
-
style: { color: $() },
|
|
86
|
-
children: [
|
|
87
|
-
"상태: ",
|
|
88
|
-
B()
|
|
89
|
-
]
|
|
90
|
-
}
|
|
91
|
-
),
|
|
92
|
-
/* @__PURE__ */ t(s, { mb: "500", children: [
|
|
93
|
-
/* @__PURE__ */ t(e, { variant: "small1", color: "text.secondary", mb: "300", children: [
|
|
94
|
-
"현재 FPS: ",
|
|
95
|
-
i.fps.toFixed(1)
|
|
96
|
-
] }),
|
|
97
|
-
/* @__PURE__ */ r(
|
|
98
|
-
s,
|
|
99
|
-
{
|
|
100
|
-
style: {
|
|
101
|
-
height: "8px",
|
|
102
|
-
backgroundColor: o.alpha[10],
|
|
103
|
-
borderRadius: d[150],
|
|
104
|
-
overflow: "hidden",
|
|
105
|
-
position: "relative"
|
|
106
|
-
},
|
|
107
|
-
children: /* @__PURE__ */ r(
|
|
108
|
-
u.div,
|
|
109
|
-
{
|
|
110
|
-
style: {
|
|
111
|
-
height: "100%",
|
|
112
|
-
backgroundColor: j(i.fps),
|
|
113
|
-
borderRadius: d[150],
|
|
114
|
-
position: "relative"
|
|
115
|
-
},
|
|
116
|
-
initial: { width: 0 },
|
|
117
|
-
animate: { width: `${O(i.fps)}%` },
|
|
118
|
-
transition: { duration: 0.4, ease: "easeOut" }
|
|
119
|
-
}
|
|
120
|
-
)
|
|
121
|
-
}
|
|
122
|
-
)
|
|
123
|
-
] }),
|
|
124
|
-
/* @__PURE__ */ t(
|
|
125
|
-
s,
|
|
126
|
-
{
|
|
127
|
-
mb: "600",
|
|
128
|
-
style: {
|
|
129
|
-
display: "grid",
|
|
130
|
-
gridTemplateColumns: "1fr 1fr",
|
|
131
|
-
gap: l[300],
|
|
132
|
-
backgroundColor: o.alpha[5],
|
|
133
|
-
padding: l[400],
|
|
134
|
-
borderRadius: d[400],
|
|
135
|
-
border: `1px solid ${o.alpha[20]}`
|
|
136
|
-
},
|
|
137
|
-
children: [
|
|
138
|
-
/* @__PURE__ */ t("div", { children: [
|
|
139
|
-
/* @__PURE__ */ r(e, { variant: "small1", color: "text.secondary", children: "평균 FPS" }),
|
|
140
|
-
/* @__PURE__ */ r(e, { variant: "body1", fontWeight: 700, color: "text.primary", children: i.averageFPS.toFixed(1) })
|
|
141
|
-
] }),
|
|
142
|
-
/* @__PURE__ */ t("div", { children: [
|
|
143
|
-
/* @__PURE__ */ r(e, { variant: "small1", color: "text.secondary", children: "최소 FPS" }),
|
|
144
|
-
/* @__PURE__ */ r(e, { variant: "body1", fontWeight: 700, color: "text.primary", children: i.minFPS.toFixed(1) })
|
|
145
|
-
] }),
|
|
146
|
-
/* @__PURE__ */ t("div", { children: [
|
|
147
|
-
/* @__PURE__ */ r(e, { variant: "small1", color: "text.secondary", children: "최대 FPS" }),
|
|
148
|
-
/* @__PURE__ */ r(e, { variant: "body1", fontWeight: 700, color: "text.primary", children: i.maxFPS.toFixed(1) })
|
|
149
|
-
] }),
|
|
150
|
-
/* @__PURE__ */ t("div", { children: [
|
|
151
|
-
/* @__PURE__ */ r(e, { variant: "small1", color: "text.secondary", children: "프레임 수" }),
|
|
152
|
-
/* @__PURE__ */ r(e, { variant: "body1", fontWeight: 700, color: "text.primary", children: i.frameCount })
|
|
153
|
-
] }),
|
|
154
|
-
/* @__PURE__ */ t("div", { style: { gridColumn: "1 / -1" }, children: [
|
|
155
|
-
/* @__PURE__ */ r(e, { variant: "small1", color: "text.secondary", children: "측정 시간" }),
|
|
156
|
-
/* @__PURE__ */ t(e, { variant: "body1", fontWeight: 700, color: "text.primary", children: [
|
|
157
|
-
(i.duration / 1e3).toFixed(1),
|
|
158
|
-
"초"
|
|
159
|
-
] })
|
|
160
|
-
] })
|
|
161
|
-
]
|
|
162
|
-
}
|
|
163
|
-
)
|
|
164
|
-
] })
|
|
165
|
-
}
|
|
166
|
-
) }),
|
|
167
|
-
/* @__PURE__ */ r(C, { children: c !== null && /* @__PURE__ */ t(
|
|
168
|
-
u.div,
|
|
169
|
-
{
|
|
170
|
-
initial: { opacity: 0 },
|
|
171
|
-
animate: { opacity: 1 },
|
|
172
|
-
exit: { opacity: 0 },
|
|
173
|
-
transition: { duration: 0.2 },
|
|
174
|
-
style: {
|
|
175
|
-
width: "100%",
|
|
176
|
-
marginTop: l[600],
|
|
177
|
-
padding: l[400],
|
|
178
|
-
backgroundColor: c ? o.alpha[10] : n.error.light,
|
|
179
|
-
border: `1px solid ${c ? o.main : n.error.main}`,
|
|
180
|
-
borderRadius: d[400],
|
|
181
|
-
color: c ? o.main : n.error.dark,
|
|
182
|
-
position: "relative",
|
|
183
|
-
overflow: "hidden"
|
|
184
|
-
},
|
|
185
|
-
children: [
|
|
186
|
-
/* @__PURE__ */ r(e, { variant: "body1", fontWeight: 700, children: c ? "60프레임 달성!" : "60프레임 미달성" }),
|
|
187
|
-
/* @__PURE__ */ t(e, { variant: "small1", mt: "200", style: { opacity: 0.8 }, children: [
|
|
188
|
-
"임계값: ",
|
|
189
|
-
p,
|
|
190
|
-
"fps"
|
|
191
|
-
] })
|
|
192
|
-
]
|
|
193
|
-
}
|
|
194
|
-
) })
|
|
195
|
-
]
|
|
196
|
-
}
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
export {
|
|
200
|
-
J as default
|
|
201
|
-
};
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
class u {
|
|
2
|
-
startTime = 0;
|
|
3
|
-
lastTime = 0;
|
|
4
|
-
frameCount = 0;
|
|
5
|
-
fpsHistory = [];
|
|
6
|
-
animationId = null;
|
|
7
|
-
isRunning = !1;
|
|
8
|
-
options;
|
|
9
|
-
onUpdate;
|
|
10
|
-
onComplete;
|
|
11
|
-
constructor(t = {}, e) {
|
|
12
|
-
this.options = {
|
|
13
|
-
duration: t.duration ?? 5e3,
|
|
14
|
-
// 기본 5초
|
|
15
|
-
sampleSize: t.sampleSize ?? 60,
|
|
16
|
-
// 기본 60프레임 샘플
|
|
17
|
-
callbackInterval: t.callbackInterval ?? 10
|
|
18
|
-
// 기본 10프레임마다 콜백
|
|
19
|
-
}, this.onUpdate = e?.onUpdate, this.onComplete = e?.onComplete;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* FPS 측정 시작
|
|
23
|
-
*/
|
|
24
|
-
start() {
|
|
25
|
-
if (this.isRunning) {
|
|
26
|
-
console.warn("FPS 측정이 이미 실행 중입니다.");
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.isRunning = !0, this.startTime = performance.now(), this.lastTime = this.startTime, this.frameCount = 0, this.fpsHistory = [], this.animationId = requestAnimationFrame(this.measure.bind(this));
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* FPS 측정 중지
|
|
33
|
-
*/
|
|
34
|
-
stop() {
|
|
35
|
-
if (!this.isRunning)
|
|
36
|
-
throw new Error("FPS 측정이 실행 중이 아닙니다.");
|
|
37
|
-
return this.isRunning = !1, this.animationId && (cancelAnimationFrame(this.animationId), this.animationId = null), this.getMetrics();
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* 현재 측정 중인지 확인
|
|
41
|
-
*/
|
|
42
|
-
get running() {
|
|
43
|
-
return this.isRunning;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* 현재까지의 측정 결과 반환
|
|
47
|
-
*/
|
|
48
|
-
getMetrics() {
|
|
49
|
-
const e = performance.now() - this.startTime, i = this.frameCount > 0 ? this.frameCount / e * 1e3 : 0, h = this.fpsHistory.length > 0 ? this.fpsHistory.reduce((m, o) => m + o, 0) / this.fpsHistory.length : i, s = this.fpsHistory.length > 0 ? Math.min(...this.fpsHistory) : i, r = this.fpsHistory.length > 0 ? Math.max(...this.fpsHistory) : i;
|
|
50
|
-
return {
|
|
51
|
-
fps: i,
|
|
52
|
-
averageFPS: h,
|
|
53
|
-
minFPS: s,
|
|
54
|
-
maxFPS: r,
|
|
55
|
-
frameCount: this.frameCount,
|
|
56
|
-
duration: e
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
measure(t) {
|
|
60
|
-
if (this.isRunning) {
|
|
61
|
-
if (this.frameCount++, t - this.lastTime >= 1e3) {
|
|
62
|
-
const e = this.frameCount / (t - this.startTime) * 1e3;
|
|
63
|
-
this.fpsHistory.push(e), this.fpsHistory.length > this.options.sampleSize && this.fpsHistory.shift(), this.lastTime = t;
|
|
64
|
-
}
|
|
65
|
-
if (this.frameCount % this.options.callbackInterval === 0 && this.onUpdate?.(this.getMetrics()), t - this.startTime >= this.options.duration) {
|
|
66
|
-
this.stop(), this.onComplete?.(this.getMetrics());
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
this.animationId = requestAnimationFrame(this.measure.bind(this));
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function f(n = 5e3) {
|
|
74
|
-
return new Promise((t) => {
|
|
75
|
-
new u({ duration: n }, { onComplete: t }).start();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
function p(n, t = {}) {
|
|
79
|
-
const e = new u(t, { onUpdate: n });
|
|
80
|
-
return e.start(), e;
|
|
81
|
-
}
|
|
82
|
-
function l() {
|
|
83
|
-
return new Promise((n, t) => {
|
|
84
|
-
if (!("PerformanceObserver" in window)) {
|
|
85
|
-
t(new Error("PerformanceObserver를 지원하지 않는 브라우저입니다."));
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const e = new PerformanceObserver((i) => {
|
|
89
|
-
const s = i.getEntries().filter((r) => r.entryType === "frame");
|
|
90
|
-
if (s.length > 0) {
|
|
91
|
-
const r = s.map((a) => a.duration), o = 1e3 / (r.reduce((a, c) => a + c, 0) / r.length);
|
|
92
|
-
e.disconnect(), n({
|
|
93
|
-
fps: o,
|
|
94
|
-
averageFPS: o,
|
|
95
|
-
minFPS: o,
|
|
96
|
-
maxFPS: o,
|
|
97
|
-
frameCount: s.length,
|
|
98
|
-
duration: s[s.length - 1].startTime - s[0].startTime
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
try {
|
|
103
|
-
e.observe({ entryTypes: ["frame"] }), setTimeout(() => {
|
|
104
|
-
e.disconnect(), t(new Error("측정 시간이 초과되었습니다."));
|
|
105
|
-
}, 3e3);
|
|
106
|
-
} catch (i) {
|
|
107
|
-
t(i);
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
export {
|
|
112
|
-
u as FPSChecker,
|
|
113
|
-
f as measureFPS,
|
|
114
|
-
l as measureFPSWithPerformanceAPI,
|
|
115
|
-
p as monitorFPS
|
|
116
|
-
};
|