chesai-ui 0.16.2 → 0.16.4
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/chesai-ui.css +1 -1
- package/dist/components/charts/bar-chart.d.ts +3 -1
- package/dist/components/charts/bar-chart.mjs +87 -74
- package/dist/components/charts/chart-utils.d.ts +7 -0
- package/dist/components/charts/chart-utils.mjs +24 -7
- package/dist/components/charts/heatmap-chart.d.ts +25 -0
- package/dist/components/playlist-studio/elements.d.ts +10 -2
- package/dist/components/playlist-studio/elements.mjs +289 -120
- package/dist/components/playlist-studio/index.d.ts +1 -0
- package/dist/components/playlist-studio/item-renderer.d.ts +2 -1
- package/dist/components/playlist-studio/item-renderer.mjs +66 -55
- package/dist/components/playlist-studio/player.d.ts +3 -1
- package/dist/components/playlist-studio/player.mjs +438 -71
- package/dist/components/playlist-studio/preload-context.d.ts +8 -0
- package/dist/components/playlist-studio/preload-context.mjs +6 -0
- package/dist/components/playlist-studio/types.d.ts +3 -0
- package/dist/components/textarea/textarea-styles.mjs +4 -4
- package/dist/components/textarea/use-textarea.d.ts +2 -2
- package/dist/components/textarea/use-textarea.mjs +72 -69
- package/dist/context/ChesaiProvider.d.ts +5 -1
- package/dist/context/ChesaiProvider.mjs +28 -24
- package/dist/context/ThemeProvider.d.ts +5 -1
- package/dist/context/ThemeProvider.mjs +130 -112
- package/dist/context/heatmap-chart.d.ts +25 -0
- package/dist/index.mjs +67 -63
- package/dist/utils/theme-generator.d.ts +1 -1
- package/dist/utils/theme-generator.mjs +39 -39
- package/package.json +1 -1
|
@@ -1,163 +1,332 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { clsx as
|
|
4
|
-
import
|
|
5
|
-
import { useMotionValueEvent as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { jsxs as V, jsx as k } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as E, useState as D, useEffect as f } from "react";
|
|
3
|
+
import { clsx as A } from "clsx";
|
|
4
|
+
import _ from "hls.js";
|
|
5
|
+
import { useMotionValueEvent as O } from "framer-motion";
|
|
6
|
+
import { LoadingIndicator as J } from "../loadingIndicator/index.mjs";
|
|
7
|
+
import { usePreload as M } from "./preload-context.mjs";
|
|
8
|
+
const q = /* @__PURE__ */ new Set([
|
|
9
|
+
"div",
|
|
10
|
+
"span",
|
|
11
|
+
"p",
|
|
12
|
+
"h1",
|
|
13
|
+
"h2",
|
|
14
|
+
"h3",
|
|
15
|
+
"h4",
|
|
16
|
+
"h5",
|
|
17
|
+
"h6",
|
|
18
|
+
"section",
|
|
19
|
+
"article",
|
|
20
|
+
"aside",
|
|
21
|
+
"header",
|
|
22
|
+
"footer",
|
|
23
|
+
"main",
|
|
24
|
+
"ul",
|
|
25
|
+
"ol",
|
|
26
|
+
"li",
|
|
27
|
+
"a",
|
|
28
|
+
"table",
|
|
29
|
+
"thead",
|
|
30
|
+
"tbody",
|
|
31
|
+
"tr",
|
|
32
|
+
"th",
|
|
33
|
+
"td",
|
|
34
|
+
"pre",
|
|
35
|
+
"code",
|
|
36
|
+
"blockquote",
|
|
37
|
+
"mark",
|
|
38
|
+
"strong",
|
|
39
|
+
"em",
|
|
40
|
+
"i",
|
|
41
|
+
"b"
|
|
42
|
+
]), B = ({
|
|
43
|
+
id: r,
|
|
44
|
+
data: N,
|
|
45
|
+
isActive: s,
|
|
46
|
+
isTimelinePlaying: u,
|
|
47
|
+
playhead: L,
|
|
48
|
+
startTime: g
|
|
12
49
|
}) => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
50
|
+
const l = E(null), a = E(null), d = E(null), [c, v] = D(null), { src: m, muted: R = !0, objectFit: S = "cover", volume: t = 1 } = N, i = E(!1), [h, b] = D(!1), p = E(null), P = E(null), y = M();
|
|
51
|
+
f(() => (y && r && y.registerAsset(r, "Video"), () => {
|
|
52
|
+
y && r && y.unregisterAsset(r);
|
|
53
|
+
}), [r, y]), f(() => {
|
|
54
|
+
y && r && y.setAssetReady(r, h, s);
|
|
55
|
+
}, [r, y, h, s]), f(() => {
|
|
56
|
+
c && y && r && y.setAssetReady(r, !0, s);
|
|
57
|
+
}, [c, y, r, s]), f(() => {
|
|
58
|
+
const e = l.current;
|
|
59
|
+
if (!e || !m) return;
|
|
60
|
+
if (v(null), i.current = !1, b(!1), a.current && (a.current.destroy(), a.current = null), m.includes(".m3u8") || m.includes("application/x-mpegURL"))
|
|
61
|
+
if (e.canPlayType("application/vnd.apple.mpegurl"))
|
|
62
|
+
e.src = m;
|
|
63
|
+
else if (_.isSupported()) {
|
|
64
|
+
const o = new _({
|
|
22
65
|
enableWorker: !0,
|
|
23
66
|
lowLatencyMode: !0
|
|
24
67
|
});
|
|
25
|
-
|
|
26
|
-
|
|
68
|
+
o.loadSource(m), o.attachMedia(e), a.current = o, o.on(_.Events.ERROR, (T, w) => {
|
|
69
|
+
w.fatal && (console.warn(
|
|
27
70
|
"[PlaylistVideo] Fatal HLS error encountered:",
|
|
28
|
-
|
|
29
|
-
),
|
|
71
|
+
w.type
|
|
72
|
+
), v(`HLS stream error: ${w.details}`));
|
|
30
73
|
});
|
|
31
74
|
} else
|
|
32
|
-
|
|
75
|
+
v("HLS playback is not supported in this environment");
|
|
33
76
|
else
|
|
34
|
-
|
|
77
|
+
e.src = m;
|
|
35
78
|
return () => {
|
|
36
|
-
|
|
79
|
+
e && (e.pause(), e.src = "", e.load()), a.current && (a.current.destroy(), a.current = null);
|
|
37
80
|
};
|
|
38
|
-
}, [
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
}, [m]), f(() => {
|
|
82
|
+
const e = l.current;
|
|
83
|
+
if (!e) return;
|
|
84
|
+
const n = () => {
|
|
85
|
+
if (p.current && (clearTimeout(p.current), p.current = null), P.current !== null) {
|
|
86
|
+
const T = P.current;
|
|
87
|
+
P.current = null;
|
|
88
|
+
try {
|
|
89
|
+
e.currentTime = T;
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
e.readyState >= 3 && b(!0);
|
|
95
|
+
}, o = () => {
|
|
96
|
+
p.current || (p.current = setTimeout(() => {
|
|
97
|
+
b(!1), p.current = null;
|
|
98
|
+
}, 300));
|
|
99
|
+
};
|
|
100
|
+
return e.addEventListener("canplay", n), e.addEventListener("canplaythrough", n), e.addEventListener("playing", n), e.addEventListener("progress", n), e.addEventListener("seeked", n), e.addEventListener("waiting", o), e.addEventListener("stalled", o), e.addEventListener("seeking", o), e.addEventListener("loadstart", o), e.addEventListener("emptied", o), n(), () => {
|
|
101
|
+
p.current && clearTimeout(p.current), e.removeEventListener("canplay", n), e.removeEventListener("canplaythrough", n), e.removeEventListener("playing", n), e.removeEventListener("progress", n), e.removeEventListener("seeked", n), e.removeEventListener("waiting", o), e.removeEventListener("stalled", o), e.removeEventListener("seeking", o), e.removeEventListener("loadstart", o), e.removeEventListener("emptied", o);
|
|
102
|
+
};
|
|
103
|
+
}, [m]), f(() => {
|
|
104
|
+
const e = l.current;
|
|
105
|
+
if (!e || c) return;
|
|
106
|
+
if (s && u && h)
|
|
107
|
+
e.muted = R, e.volume = t, d.current = e.play(), d.current.catch((o) => {
|
|
108
|
+
console.warn("[PlaylistVideo] Play request prevented:", o);
|
|
44
109
|
});
|
|
45
110
|
else {
|
|
46
|
-
const
|
|
47
|
-
|
|
111
|
+
const o = () => {
|
|
112
|
+
e.pause(), s || (e.currentTime = 0);
|
|
48
113
|
};
|
|
49
|
-
|
|
114
|
+
d.current ? d.current.then(o).catch(o) : o();
|
|
50
115
|
}
|
|
51
|
-
}, [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
116
|
+
}, [s, u, h, R, t, c]);
|
|
117
|
+
const x = E(0);
|
|
118
|
+
return O(L, "change", (e) => {
|
|
119
|
+
const n = l.current;
|
|
120
|
+
if (!n || !s || n.readyState < 1) {
|
|
121
|
+
x.current = e;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const o = Math.max(0, (e - g) / 1e3), T = Math.abs(e - x.current);
|
|
125
|
+
let w = o;
|
|
126
|
+
n.duration && !isNaN(n.duration) && n.duration > 0 && (w = o % n.duration);
|
|
127
|
+
const H = Math.abs(n.currentTime - w), j = (I) => {
|
|
128
|
+
if (n.seeking)
|
|
129
|
+
P.current = I;
|
|
130
|
+
else {
|
|
131
|
+
P.current = null;
|
|
132
|
+
try {
|
|
133
|
+
n.currentTime = I;
|
|
134
|
+
} catch {
|
|
135
|
+
}
|
|
59
136
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
137
|
+
};
|
|
138
|
+
u ? (T > 1e3 || e < x.current || H > 0.25) && j(w) : H > 0.1 && j(w), x.current = e;
|
|
139
|
+
}), /* @__PURE__ */ V("div", { className: "relative w-full h-full bg-surface-container-low flex items-center justify-center overflow-hidden", children: [
|
|
140
|
+
c && /* @__PURE__ */ V("div", { className: "absolute inset-0 z-20 flex flex-col items-center justify-center p-4 bg-error-container/20 text-center", children: [
|
|
141
|
+
/* @__PURE__ */ k("span", { className: "text-xs font-semibold text-error mb-1", children: "Playback Error" }),
|
|
142
|
+
/* @__PURE__ */ k("span", { className: "text-[10px] text-on-error-container opacity-80 max-w-[80%] leading-normal", children: c })
|
|
64
143
|
] }),
|
|
65
|
-
/* @__PURE__ */
|
|
144
|
+
s && u && !h && !c && /* @__PURE__ */ k("div", { className: "absolute inset-0 z-10 flex items-center justify-center bg-black/15", children: /* @__PURE__ */ k(
|
|
145
|
+
J,
|
|
146
|
+
{
|
|
147
|
+
variant: "material-morph",
|
|
148
|
+
className: "!w-20vw !h-20vh text-primary"
|
|
149
|
+
}
|
|
150
|
+
) }),
|
|
151
|
+
/* @__PURE__ */ k(
|
|
66
152
|
"video",
|
|
67
153
|
{
|
|
68
|
-
ref:
|
|
69
|
-
onError: (
|
|
70
|
-
const
|
|
71
|
-
let
|
|
72
|
-
if (
|
|
73
|
-
switch (
|
|
74
|
-
case
|
|
75
|
-
|
|
154
|
+
ref: l,
|
|
155
|
+
onError: (e) => {
|
|
156
|
+
const n = e.target.error;
|
|
157
|
+
let o = "An unknown media error occurred.";
|
|
158
|
+
if (n)
|
|
159
|
+
switch (n.code) {
|
|
160
|
+
case n.MEDIA_ERR_ABORTED:
|
|
161
|
+
o = "Video loading aborted.";
|
|
76
162
|
break;
|
|
77
|
-
case
|
|
78
|
-
|
|
163
|
+
case n.MEDIA_ERR_NETWORK:
|
|
164
|
+
o = "Network error prevented video download.";
|
|
79
165
|
break;
|
|
80
|
-
case
|
|
81
|
-
|
|
166
|
+
case n.MEDIA_ERR_DECODE:
|
|
167
|
+
o = "Video corrupted or decoding failed.";
|
|
82
168
|
break;
|
|
83
|
-
case
|
|
84
|
-
|
|
169
|
+
case n.MEDIA_ERR_SRC_NOT_SUPPORTED:
|
|
170
|
+
o = "Failed to load: Video format or source url is not supported.";
|
|
85
171
|
break;
|
|
86
172
|
}
|
|
87
|
-
|
|
173
|
+
v(o);
|
|
88
174
|
},
|
|
89
|
-
className:
|
|
175
|
+
className: A(
|
|
90
176
|
"w-full h-full border-0 outline-none transition-opacity duration-300",
|
|
91
|
-
|
|
92
|
-
|
|
177
|
+
c ? "opacity-0" : "opacity-100",
|
|
178
|
+
S === "contain" ? "object-contain" : "object-cover"
|
|
93
179
|
),
|
|
94
180
|
preload: "auto",
|
|
95
|
-
muted:
|
|
181
|
+
muted: R,
|
|
96
182
|
playsInline: !0
|
|
97
183
|
}
|
|
98
184
|
)
|
|
99
185
|
] });
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
186
|
+
}, C = ({
|
|
187
|
+
id: r,
|
|
188
|
+
data: N,
|
|
189
|
+
isActive: s,
|
|
190
|
+
isTimelinePlaying: u,
|
|
191
|
+
playhead: L,
|
|
192
|
+
startTime: g,
|
|
193
|
+
isSeeking: l = !1
|
|
106
194
|
}) => {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
195
|
+
const a = E(null), d = E(null), { src: c, muted: v = !1, volume: m = 1 } = N, R = M();
|
|
196
|
+
f(() => {
|
|
197
|
+
const t = new Audio();
|
|
198
|
+
return t.preload = "auto", a.current = t, () => {
|
|
199
|
+
a.current && (a.current.pause(), a.current.src = ""), a.current = null;
|
|
200
|
+
};
|
|
201
|
+
}, []), f(() => (R && r && (R.registerAsset(r, "Audio"), R.setAssetReady(r, !0, s)), () => {
|
|
202
|
+
R && r && R.unregisterAsset(r);
|
|
203
|
+
}), [r, R, s]), f(() => {
|
|
204
|
+
const t = a.current;
|
|
205
|
+
!t || !c || (t.src = c, t.load());
|
|
206
|
+
}, [c]), f(() => {
|
|
207
|
+
const t = a.current;
|
|
208
|
+
if (!t) return;
|
|
209
|
+
s && u && !l ? (t.muted = v, t.volume = m, t.play().then(() => {
|
|
210
|
+
console.log("[PlaylistAudio] Playback started successfully!");
|
|
211
|
+
}).catch((h) => {
|
|
212
|
+
console.warn("[PlaylistAudio] Playback blocked:", h);
|
|
213
|
+
})) : (t.pause(), s || (t.currentTime = 0));
|
|
214
|
+
}, [s, u, v, m, l]), f(() => {
|
|
215
|
+
const t = a.current;
|
|
216
|
+
if (!t) return;
|
|
217
|
+
const i = () => {
|
|
218
|
+
if (d.current !== null) {
|
|
219
|
+
const h = d.current;
|
|
220
|
+
d.current = null;
|
|
221
|
+
try {
|
|
222
|
+
t.currentTime = h;
|
|
223
|
+
} catch (b) {
|
|
224
|
+
console.log(b);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return t.addEventListener("seeked", i), () => {
|
|
229
|
+
t.removeEventListener("seeked", i);
|
|
230
|
+
};
|
|
231
|
+
}, [c]), f(() => {
|
|
232
|
+
const t = a.current;
|
|
233
|
+
if (!t || l) return;
|
|
234
|
+
const i = L.get(), h = Math.max(0, (i - g) / 1e3);
|
|
235
|
+
let b = h;
|
|
236
|
+
t.duration && !isNaN(t.duration) && t.duration > 0 && (b = h % t.duration);
|
|
237
|
+
try {
|
|
238
|
+
t.currentTime = b;
|
|
239
|
+
} catch {
|
|
240
|
+
}
|
|
241
|
+
}, [l, s, g, L]);
|
|
242
|
+
const S = E(0);
|
|
243
|
+
return O(L, "change", (t) => {
|
|
244
|
+
const i = a.current;
|
|
245
|
+
if (!i || !s || i.readyState < 1 || l) {
|
|
246
|
+
S.current = t;
|
|
247
|
+
return;
|
|
123
248
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
249
|
+
const h = Math.max(0, (t - g) / 1e3), b = Math.abs(t - S.current);
|
|
250
|
+
let p = h;
|
|
251
|
+
i.duration && !isNaN(i.duration) && i.duration > 0 && (p = h % i.duration);
|
|
252
|
+
const P = Math.abs(i.currentTime - p), y = (x) => {
|
|
253
|
+
if (i.seeking)
|
|
254
|
+
d.current = x;
|
|
255
|
+
else {
|
|
256
|
+
d.current = null;
|
|
257
|
+
try {
|
|
258
|
+
i.currentTime = x;
|
|
259
|
+
} catch {
|
|
260
|
+
}
|
|
132
261
|
}
|
|
133
|
-
|
|
134
|
-
|
|
262
|
+
};
|
|
263
|
+
u ? (b > 1e3 || t < S.current || P > 0.25) && y(p) : P > 0.1 && y(p), S.current = t;
|
|
264
|
+
}), null;
|
|
265
|
+
}, W = ({
|
|
266
|
+
id: r,
|
|
267
|
+
data: N,
|
|
268
|
+
isActive: s
|
|
269
|
+
}) => {
|
|
270
|
+
const { src: u, alt: L, objectFit: g = "cover" } = N, l = M(), a = E(null), [d, c] = D(!1);
|
|
271
|
+
return f(() => (l && r && l.registerAsset(r, "Image"), () => {
|
|
272
|
+
l && r && l.unregisterAsset(r);
|
|
273
|
+
}), [r, l]), f(() => {
|
|
274
|
+
l && r && l.setAssetReady(r, d, s);
|
|
275
|
+
}, [r, l, d, s]), f(() => {
|
|
276
|
+
a.current?.complete ? c(!0) : c(!1);
|
|
277
|
+
}, [u]), /* @__PURE__ */ k(
|
|
278
|
+
"img",
|
|
135
279
|
{
|
|
136
|
-
ref:
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
280
|
+
ref: a,
|
|
281
|
+
src: u,
|
|
282
|
+
alt: L || "Playlist Image",
|
|
283
|
+
onLoad: () => {
|
|
284
|
+
c(!0);
|
|
285
|
+
},
|
|
286
|
+
onError: () => {
|
|
287
|
+
c(!0);
|
|
288
|
+
},
|
|
289
|
+
className: "w-full h-full border-0 block select-none pointer-events-none",
|
|
290
|
+
style: { objectFit: g }
|
|
140
291
|
}
|
|
141
292
|
);
|
|
142
|
-
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
293
|
+
}, z = ({
|
|
294
|
+
id: r,
|
|
295
|
+
data: N,
|
|
296
|
+
isActive: s
|
|
297
|
+
}) => {
|
|
298
|
+
const u = M(), { tag: L = "div", html: g, children: l, className: a, style: d, ...c } = N;
|
|
299
|
+
f(() => (u && r && (u.registerAsset(r, "Html"), u.setAssetReady(r, !0, s)), () => {
|
|
300
|
+
u && r && u.unregisterAsset(r);
|
|
301
|
+
}), [r, u, s]);
|
|
302
|
+
const v = typeof L == "string" ? L.toLowerCase() : "div", m = q.has(v) ? v : "div";
|
|
303
|
+
return g && typeof g == "string" ? /* @__PURE__ */ k(
|
|
304
|
+
m,
|
|
146
305
|
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
306
|
+
className: A("w-full h-full overflow-hidden", a),
|
|
307
|
+
style: d,
|
|
308
|
+
dangerouslySetInnerHTML: { __html: g },
|
|
309
|
+
...c
|
|
310
|
+
}
|
|
311
|
+
) : /* @__PURE__ */ k(
|
|
312
|
+
m,
|
|
313
|
+
{
|
|
314
|
+
className: A("w-full h-full overflow-hidden", a),
|
|
315
|
+
style: d,
|
|
316
|
+
...c,
|
|
317
|
+
children: l
|
|
151
318
|
}
|
|
152
319
|
);
|
|
153
|
-
},
|
|
154
|
-
Video:
|
|
155
|
-
Audio:
|
|
156
|
-
Image:
|
|
320
|
+
}, re = {
|
|
321
|
+
Video: B,
|
|
322
|
+
Audio: C,
|
|
323
|
+
Image: W,
|
|
324
|
+
Html: z
|
|
157
325
|
};
|
|
158
326
|
export {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
327
|
+
C as PlaylistAudio,
|
|
328
|
+
z as PlaylistHtml,
|
|
329
|
+
W as PlaylistImage,
|
|
330
|
+
B as PlaylistVideo,
|
|
331
|
+
re as defaultPlaylistRegistry
|
|
163
332
|
};
|
|
@@ -5,6 +5,7 @@ interface ItemRendererProps {
|
|
|
5
5
|
playhead: any;
|
|
6
6
|
components: PlaylistComponentRegistry;
|
|
7
7
|
isTimelinePlaying: boolean;
|
|
8
|
+
isSeeking?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare const ItemRenderer: React.MemoExoticComponent<({ item, playhead, components, isTimelinePlaying }: ItemRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
10
|
+
export declare const ItemRenderer: React.MemoExoticComponent<({ item, playhead, components, isTimelinePlaying, isSeeking, }: ItemRendererProps) => import("react/jsx-runtime").JSX.Element | null>;
|
|
10
11
|
export {};
|