@nice2dev/ui-video 1.0.22 → 1.0.23

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.
Files changed (2) hide show
  1. package/dist/index.mjs +50 -50
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as r, Fragment as ie } from "react/jsx-runtime";
2
2
  import { useContext as ye, createContext as $, memo as Se, useState as v, useEffect as ne, useRef as F, useCallback as me } from "react";
3
- const He = (l, m) => m, Ie = $(He);
4
- function Te() {
5
- return { t: ye(Ie) };
3
+ const He = (l, m) => m, Te = $(He);
4
+ function Ie() {
5
+ return { t: ye(Te) };
6
6
  }
7
7
  $({
8
8
  dir: "ltr",
@@ -64,8 +64,8 @@ function ae(l) {
64
64
  return l < 1 ? `${(l * 1e3).toFixed(0)}μs` : l < 1e3 ? `${l.toFixed(2)}ms` : `${(l / 1e3).toFixed(2)}s`;
65
65
  }
66
66
  function $e() {
67
- const l = Array.from(pe.values()), m = _e(), f = l.reduce((T, p) => T + p.renderCount, 0), C = l.length > 0 ? l.reduce((T, p) => T + p.avgRenderTime, 0) / l.length : 0, I = Array.from(ve.values());
68
- return { stats: l, slowRenders: m, totalRenders: f, avgRenderTime: C, marks: I };
67
+ const l = Array.from(pe.values()), m = _e(), f = l.reduce((I, p) => I + p.renderCount, 0), C = l.length > 0 ? l.reduce((I, p) => I + p.avgRenderTime, 0) / l.length : 0, T = Array.from(ve.values());
68
+ return { stats: l, slowRenders: m, totalRenders: f, avgRenderTime: C, marks: T };
69
69
  }
70
70
  function Ae() {
71
71
  const l = $e();
@@ -97,11 +97,11 @@ function Ae() {
97
97
  }
98
98
  const Ee = Se(
99
99
  ({ position: l = "bottom-right", defaultCollapsed: m = !0 }) => {
100
- const [f, C] = v(m), [I, T] = v([]), [p, i] = v({ used: 0, total: 0 });
100
+ const [f, C] = v(m), [T, I] = v([]), [p, i] = v({ used: 0, total: 0 });
101
101
  if (ne(() => {
102
102
  const b = () => {
103
103
  const y = Array.from(pe.values());
104
- T(y.sort((S, z) => z.totalRenderTime - S.totalRenderTime).slice(0, 10));
104
+ I(y.sort((S, z) => z.totalRenderTime - S.totalRenderTime).slice(0, 10));
105
105
  const k = window.performance;
106
106
  k.memory && i({
107
107
  used: k.memory.usedJSHeapSize / 1024 / 1024,
@@ -171,7 +171,7 @@ const Ee = Se(
171
171
  children: /* @__PURE__ */ e("strong", { children: "Top Components" })
172
172
  }
173
173
  ),
174
- I.map((b) => /* @__PURE__ */ r("div", { style: { marginBottom: 4, display: "flex", gap: 8 }, children: [
174
+ T.map((b) => /* @__PURE__ */ r("div", { style: { marginBottom: 4, display: "flex", gap: 8 }, children: [
175
175
  /* @__PURE__ */ e("span", { style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis" }, children: b.componentName }),
176
176
  /* @__PURE__ */ e(
177
177
  "span",
@@ -274,11 +274,11 @@ const Le = ({
274
274
  autoStart: m,
275
275
  label: f,
276
276
  size: C = "md",
277
- className: I,
278
- style: T,
277
+ className: T,
278
+ style: I,
279
279
  "data-testid": p
280
280
  }) => {
281
- const { enabled: i, run: D } = Pe(), { t: b } = Te();
281
+ const { enabled: i, run: D } = Pe(), { t: b } = Ie();
282
282
  if (!i || !l || l.length === 0)
283
283
  return null;
284
284
  const E = f ?? b("tutorial.startAria", "Start tutorial");
@@ -286,8 +286,8 @@ const Le = ({
286
286
  "button",
287
287
  {
288
288
  type: "button",
289
- className: `nice-tutorial-button nice-tutorial-button--${C}` + (I ? ` ${I}` : ""),
290
- style: T,
289
+ className: `nice-tutorial-button nice-tutorial-button--${C}` + (T ? ` ${T}` : ""),
290
+ style: I,
291
291
  "data-testid": p,
292
292
  "aria-label": E,
293
293
  title: E,
@@ -367,7 +367,7 @@ const ge = {
367
367
  lg: "0 10px 15px -3px rgba(0,0,0,0.4)",
368
368
  xl: "0 20px 25px -5px rgba(0,0,0,0.4)"
369
369
  };
370
- function d(l, m, f, C, I) {
370
+ function d(l, m, f, C, T) {
371
371
  return {
372
372
  name: l,
373
373
  darkMode: "light",
@@ -383,14 +383,14 @@ function d(l, m, f, C, I) {
383
383
  canvas: f.canvas ?? f.primary
384
384
  },
385
385
  text: { ...C, inverse: C.inverse ?? "#ffffff" },
386
- borders: ke(I),
386
+ borders: ke(T),
387
387
  shadows: Ve,
388
388
  spacing: ge,
389
389
  typography: we,
390
390
  transitions: Ne
391
391
  };
392
392
  }
393
- function x(l, m, f, C, I) {
393
+ function x(l, m, f, C, T) {
394
394
  return {
395
395
  name: l,
396
396
  darkMode: "dark",
@@ -406,7 +406,7 @@ function x(l, m, f, C, I) {
406
406
  canvas: f.canvas ?? f.primary
407
407
  },
408
408
  text: { ...C, inverse: C.inverse ?? "#0f172a" },
409
- borders: ke(I),
409
+ borders: ke(T),
410
410
  shadows: Oe,
411
411
  spacing: ge,
412
412
  typography: we,
@@ -1821,12 +1821,12 @@ const Be = {
1821
1821
  onProjectChange: m,
1822
1822
  onExport: f,
1823
1823
  onAssetUpload: C,
1824
- className: I = "",
1825
- tutorial: T
1824
+ className: T = "",
1825
+ tutorial: I
1826
1826
  }) => {
1827
1827
  const [p, i] = v(l || Be), [D, b] = v(
1828
1828
  "timeline"
1829
- ), [E, y] = v(null), [k, S] = v(null), [z, R] = v(0), [q, W] = v(!1), [M, J] = v(1), [K, P] = v(!0), [U, O] = v(null), oe = F(null), se = F(null), A = F(null);
1829
+ ), [E, y] = v(null), [k, S] = v(null), [z, R] = v(0), [Z, W] = v(!1), [M, J] = v(1), [K, P] = v(!0), [U, O] = v(null), oe = F(null), se = F(null), A = F(null);
1830
1830
  ne(() => {
1831
1831
  l && i(l);
1832
1832
  }, [l]), ne(() => () => {
@@ -1957,7 +1957,7 @@ const Be = {
1957
1957
  return {};
1958
1958
  }
1959
1959
  }, de = () => {
1960
- q ? (A.current && clearInterval(A.current), W(!1)) : (A.current = setInterval(() => {
1960
+ Z ? (A.current && clearInterval(A.current), W(!1)) : (A.current = setInterval(() => {
1961
1961
  R((n) => {
1962
1962
  const o = Math.max(
1963
1963
  ...p.tracks.flatMap((a) => a.items.map((t) => t.startTime + t.duration)),
@@ -1983,7 +1983,7 @@ const Be = {
1983
1983
  }, te = (n) => {
1984
1984
  const o = Math.floor(n / 60), a = Math.floor(n % 60), t = Math.floor(n % 1 * p.frameRate);
1985
1985
  return `${o.toString().padStart(2, "0")}:${a.toString().padStart(2, "0")}:${t.toString().padStart(2, "0")}`;
1986
- }, Z = () => {
1986
+ }, q = () => {
1987
1987
  for (const n of p.tracks) {
1988
1988
  const o = n.items.find((a) => a.id === k);
1989
1989
  if (o)
@@ -1991,8 +1991,8 @@ const Be = {
1991
1991
  }
1992
1992
  return null;
1993
1993
  };
1994
- return /* @__PURE__ */ r("div", { className: `nice-video-editor ${I}`, style: { position: "relative" }, children: [
1995
- /* @__PURE__ */ e("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ e(Le, { steps: Ue(T, Ge) }) }),
1994
+ return /* @__PURE__ */ r("div", { className: `nice-video-editor ${T}`, style: { position: "relative" }, children: [
1995
+ /* @__PURE__ */ e("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 30 }, children: /* @__PURE__ */ e(Le, { steps: Ue(I, Ge) }) }),
1996
1996
  /* @__PURE__ */ r("header", { className: "video-editor__header", children: [
1997
1997
  /* @__PURE__ */ r("div", { className: "header__project-info", children: [
1998
1998
  /* @__PURE__ */ e(
@@ -2095,13 +2095,13 @@ const Be = {
2095
2095
  /* @__PURE__ */ r("div", { className: "playback-controls", children: [
2096
2096
  /* @__PURE__ */ e("button", { onClick: () => Q(0), children: "⏮️" }),
2097
2097
  /* @__PURE__ */ e("button", { onClick: () => Q(z - 1 / p.frameRate), children: "⏪" }),
2098
- /* @__PURE__ */ e("button", { onClick: de, className: "play-button", children: q ? "⏸️" : "▶️" }),
2098
+ /* @__PURE__ */ e("button", { onClick: de, className: "play-button", children: Z ? "⏸️" : "▶️" }),
2099
2099
  /* @__PURE__ */ e("button", { onClick: () => Q(z + 1 / p.frameRate), children: "⏩" }),
2100
2100
  /* @__PURE__ */ e("span", { className: "time-display", children: te(z) })
2101
2101
  ] })
2102
2102
  ] }),
2103
2103
  k && D !== "export" && /* @__PURE__ */ e("div", { className: "item-inspector", children: (() => {
2104
- const n = Z();
2104
+ const n = q();
2105
2105
  if (!n)
2106
2106
  return null;
2107
2107
  const { track: o, item: a } = n;
@@ -2299,7 +2299,7 @@ const Be = {
2299
2299
  className: "effect-preset",
2300
2300
  disabled: !k,
2301
2301
  onClick: () => {
2302
- const o = Z();
2302
+ const o = q();
2303
2303
  o && Y(o.track.id, o.item.id, n.type);
2304
2304
  },
2305
2305
  children: [
@@ -2321,7 +2321,7 @@ const Be = {
2321
2321
  {
2322
2322
  disabled: !k,
2323
2323
  onClick: () => {
2324
- const o = Z();
2324
+ const o = q();
2325
2325
  o && L(
2326
2326
  o.track.id,
2327
2327
  o.item.id,
@@ -2337,7 +2337,7 @@ const Be = {
2337
2337
  {
2338
2338
  disabled: !k,
2339
2339
  onClick: () => {
2340
- const o = Z();
2340
+ const o = q();
2341
2341
  o && L(o.track.id, o.item.id, n.type, "end");
2342
2342
  },
2343
2343
  children: "Out"
@@ -2465,15 +2465,15 @@ const Be = {
2465
2465
  onRecordingStart: m,
2466
2466
  onRecordingStop: f,
2467
2467
  onRecordingPause: C,
2468
- onRecordingResume: I,
2469
- onError: T,
2468
+ onRecordingResume: T,
2469
+ onError: I,
2470
2470
  className: p = ""
2471
2471
  }) => {
2472
2472
  var u, h;
2473
2473
  const [i, D] = v({
2474
2474
  ...je,
2475
2475
  ...l
2476
- }), [b, E] = v(null), [y, k] = v("idle"), [S, z] = v([]), [R, q] = v(null), [W, M] = v(null), [J, K] = v(!1), [P, U] = v(!1), [O, oe] = v(
2476
+ }), [b, E] = v(null), [y, k] = v("idle"), [S, z] = v([]), [R, Z] = v(null), [W, M] = v(null), [J, K] = v(!1), [P, U] = v(!1), [O, oe] = v(
2477
2477
  "pen"
2478
2478
  ), [se, A] = v("var(--nice-danger, #ff0000)"), w = F(null), g = F([]), B = F(null), X = F(null), G = F(null), re = F(0);
2479
2479
  ne(() => () => {
@@ -2508,9 +2508,9 @@ const Be = {
2508
2508
  } catch (H) {
2509
2509
  console.warn("Could not access microphone:", H);
2510
2510
  }
2511
- q(N), B.current && (B.current.srcObject = N, B.current.play()), k("idle");
2511
+ Z(N), B.current && (B.current.srcObject = N, B.current.play()), k("idle");
2512
2512
  } catch (s) {
2513
- k("error"), T == null || T(s instanceof Error ? s : new Error("Failed to start preview"));
2513
+ k("error"), I == null || I(s instanceof Error ? s : new Error("Failed to start preview"));
2514
2514
  }
2515
2515
  }, L = async () => {
2516
2516
  R || await Y();
@@ -2550,14 +2550,14 @@ const Be = {
2550
2550
  );
2551
2551
  }, 100);
2552
2552
  } catch (s) {
2553
- k("error"), T == null || T(s instanceof Error ? s : new Error("Failed to start recording"));
2553
+ k("error"), I == null || I(s instanceof Error ? s : new Error("Failed to start recording"));
2554
2554
  }
2555
2555
  }, ce = async () => (await Y(), R), de = () => {
2556
2556
  w.current && y === "recording" && (w.current.pause(), k("paused"), C == null || C());
2557
2557
  }, Q = () => {
2558
- w.current && y === "paused" && (w.current.resume(), k("recording"), I == null || I());
2558
+ w.current && y === "paused" && (w.current.resume(), k("recording"), T == null || T());
2559
2559
  }, ee = () => {
2560
- G.current && clearInterval(G.current), w.current && (y === "recording" || y === "paused") && (w.current.stop(), k("stopped")), R && (R.getTracks().forEach((s) => s.stop()), q(null));
2560
+ G.current && clearInterval(G.current), w.current && (y === "recording" || y === "paused") && (w.current.stop(), k("stopped")), R && (R.getTracks().forEach((s) => s.stop()), Z(null));
2561
2561
  }, te = me(
2562
2562
  (s) => {
2563
2563
  if (y !== "recording")
@@ -2571,7 +2571,7 @@ const Be = {
2571
2571
  z((H) => [...H, N]);
2572
2572
  },
2573
2573
  [y, b == null ? void 0 : b.duration, S.length]
2574
- ), Z = (s) => {
2574
+ ), q = (s) => {
2575
2575
  z((N) => N.filter((H) => H.id !== s));
2576
2576
  }, n = (s) => {
2577
2577
  switch (s) {
@@ -2768,7 +2768,7 @@ const Be = {
2768
2768
  className: "marker-label"
2769
2769
  }
2770
2770
  ),
2771
- /* @__PURE__ */ e("button", { className: "marker-remove", onClick: () => Z(s.id), children: "×" })
2771
+ /* @__PURE__ */ e("button", { className: "marker-remove", onClick: () => q(s.id), children: "×" })
2772
2772
  ]
2773
2773
  },
2774
2774
  s.id
@@ -2962,7 +2962,7 @@ const Be = {
2962
2962
  ] })
2963
2963
  ] })
2964
2964
  ] });
2965
- }, qe = {
2965
+ }, Ze = {
2966
2966
  id: crypto.randomUUID(),
2967
2967
  name: "My Stream",
2968
2968
  protocol: "rtmp",
@@ -3019,11 +3019,11 @@ const Be = {
3019
3019
  onConfigChange: m,
3020
3020
  onStreamStart: f,
3021
3021
  onStreamStop: C,
3022
- onStatsUpdate: I,
3023
- onError: T,
3022
+ onStatsUpdate: T,
3023
+ onError: I,
3024
3024
  className: p = ""
3025
3025
  }) => {
3026
- const [i, D] = v(l || qe), [b, E] = v(
3026
+ const [i, D] = v(l || Ze), [b, E] = v(
3027
3027
  "sources"
3028
3028
  ), [y, k] = v(!1), [S, z] = v({
3029
3029
  duration: 0,
@@ -3034,7 +3034,7 @@ const Be = {
3034
3034
  droppedFrames: 0,
3035
3035
  cpuUsage: 0,
3036
3036
  memoryUsage: 0
3037
- }), [R, q] = v(null), [W, M] = v(!1), [J, K] = v(!1), [P, U] = v([i.layout]), [O, oe] = v(0), se = F(null), A = F(null), w = F(0);
3037
+ }), [R, Z] = v(null), [W, M] = v(!1), [J, K] = v(!1), [P, U] = v([i.layout]), [O, oe] = v(0), se = F(null), A = F(null), w = F(0);
3038
3038
  ne(() => {
3039
3039
  l && D(l);
3040
3040
  }, [l]), ne(() => () => {
@@ -3164,17 +3164,17 @@ const Be = {
3164
3164
  cpuUsage: 15 + Math.random() * 30,
3165
3165
  memoryUsage: 40 + Math.random() * 20
3166
3166
  };
3167
- z(a), I == null || I(a);
3167
+ z(a), T == null || T(a);
3168
3168
  }, 1e3);
3169
3169
  } catch (a) {
3170
- T == null || T(a instanceof Error ? a : new Error("Failed to start stream")), g({
3170
+ I == null || I(a instanceof Error ? a : new Error("Failed to start stream")), g({
3171
3171
  destinations: i.destinations.map((t) => ({
3172
3172
  ...t,
3173
3173
  status: "error"
3174
3174
  }))
3175
3175
  });
3176
3176
  }
3177
- }, Z = () => {
3177
+ }, q = () => {
3178
3178
  A.current && clearInterval(A.current), g({
3179
3179
  destinations: i.destinations.map((a) => ({ ...a, status: "idle" }))
3180
3180
  }), k(!1), C == null || C();
@@ -3230,7 +3230,7 @@ const Be = {
3230
3230
  " fps"
3231
3231
  ] })
3232
3232
  ] }) }),
3233
- /* @__PURE__ */ e("div", { className: "header__actions", children: y ? /* @__PURE__ */ e("button", { className: "action-button action-button--stop", onClick: Z, children: "End Stream" }) : /* @__PURE__ */ e(
3233
+ /* @__PURE__ */ e("div", { className: "header__actions", children: y ? /* @__PURE__ */ e("button", { className: "action-button action-button--stop", onClick: q, children: "End Stream" }) : /* @__PURE__ */ e(
3234
3234
  "button",
3235
3235
  {
3236
3236
  className: "action-button action-button--go-live",
@@ -3278,7 +3278,7 @@ const Be = {
3278
3278
  opacity: a.opacity,
3279
3279
  zIndex: a.zIndex
3280
3280
  },
3281
- onClick: () => q(a.id),
3281
+ onClick: () => Z(a.id),
3282
3282
  children: /* @__PURE__ */ r("div", { className: "layer-content", children: [
3283
3283
  /* @__PURE__ */ e("span", { className: "layer-icon", children: ((c = le.find((u) => u.type === t.type)) == null ? void 0 : c.icon) || "📦" }),
3284
3284
  /* @__PURE__ */ e("span", { className: "layer-name", children: t.name })
@@ -3321,7 +3321,7 @@ const Be = {
3321
3321
  "div",
3322
3322
  {
3323
3323
  className: `source-item ${R === (t == null ? void 0 : t.id) ? "source-item--selected" : ""}`,
3324
- onClick: () => t && q(t.id),
3324
+ onClick: () => t && Z(t.id),
3325
3325
  children: [
3326
3326
  /* @__PURE__ */ e("span", { className: "source-icon", children: (c = le.find((u) => u.type === a.type)) == null ? void 0 : c.icon }),
3327
3327
  /* @__PURE__ */ e("span", { className: "source-name", children: a.name }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/ui-video",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "Nice2Dev Video Components - Video editor, screen recorder, and live streaming",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -31,12 +31,12 @@
31
31
  },
32
32
  "dependencies": {},
33
33
  "peerDependencies": {
34
- "@nice2dev/ui-core": "^1.0.22",
34
+ "@nice2dev/ui-core": "^1.0.23",
35
35
  "react": ">=17.0.0",
36
36
  "react-dom": ">=17.0.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@nice2dev/ui-core": "^1.0.22",
39
+ "@nice2dev/ui-core": "^1.0.23",
40
40
  "@testing-library/react": "^14.1.0",
41
41
  "@types/react": "^18.2.0",
42
42
  "@types/react-dom": "^18.2.0",