@rendiv/player 0.1.2 → 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/Player.d.ts +2 -0
- package/dist/Player.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +79 -78
- package/package.json +3 -3
package/dist/Player.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export interface PlayerProps {
|
|
|
9
9
|
fps: number;
|
|
10
10
|
compositionWidth: number;
|
|
11
11
|
compositionHeight: number;
|
|
12
|
+
/** Composition id exposed via CompositionContext. Defaults to 'player'. */
|
|
13
|
+
compositionId?: string;
|
|
12
14
|
style?: CSSProperties;
|
|
13
15
|
controls?: boolean;
|
|
14
16
|
loop?: boolean;
|
package/dist/Player.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAQZ,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,OAAO,CAAC;AAQf,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIrE,UAAU,kBAAkB;IAC1B,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAClD,gBAAgB,EAAE,MAAM,CAAC;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC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,EAAE,CAAC,CAAC,SAAS,MAAM,cAAc,EAC/C,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAClC,IAAI,CAAC;IACV,mBAAmB,EAAE,CAAC,CAAC,SAAS,MAAM,cAAc,EAClD,KAAK,EAAE,CAAC,EACR,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,KAClC,IAAI,CAAC;CACX;AAED,eAAO,MAAM,MAAM,+EA4KjB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var V=Object.defineProperty;var W=(o,r,e)=>r in o?V(o,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[r]=e;var j=(o,r,e)=>W(o,typeof r!="symbol"?r+"":r,e);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),n=require("react"),E=require("@rendiv/core");function $(o){const{fps:r,durationInFrames:e,loop:s,playbackRate:i,autoPlay:c}=o,[h,k]=n.useState(0),[x,y]=n.useState(c),m=n.useRef(null),v=n.useRef(0),p=n.useRef(0),w=n.useCallback(()=>y(!0),[]),P=n.useCallback(()=>y(!1),[]),C=n.useCallback(()=>y(f=>!f),[]),u=n.useCallback(f=>{const g=Math.max(0,Math.min(f,e-1));p.current=g,k(g)},[e]);return n.useEffect(()=>{if(!x){m.current=null,v.current=0;return}let f;const g=1e3/(r*i),t=b=>{m.current===null&&(m.current=b);const S=b-m.current;m.current=b,v.current+=S;let d=p.current,R=!1;for(;v.current>=g;)if(v.current-=g,d+=1,R=!0,d>=e)if(s)d=0;else{d=e-1,y(!1);break}R&&(p.current=d,k(d)),f=requestAnimationFrame(t)};return f=requestAnimationFrame(t),()=>cancelAnimationFrame(f)},[x,r,i,s,e]),{frame:h,playing:x,play:w,pause:P,toggle:C,seekTo:u}}class O{constructor(){j(this,"listeners",new Map)}addEventListener(r,e){this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(e)}removeEventListener(r,e){var s;(s=this.listeners.get(r))==null||s.delete(e)}emit(r,...e){const s=this.listeners.get(r);if(!s)return;const i=e[0];for(const c of s)c(i)}}const K={position:"absolute",bottom:0,left:0,right:0,display:"flex",alignItems:"center",gap:8,padding:"8px 12px",backgroundColor:"rgba(0, 0, 0, 0.7)",color:"#fff",fontFamily:"system-ui, -apple-system, sans-serif",fontSize:13,userSelect:"none"},B={background:"none",border:"none",color:"#fff",cursor:"pointer",fontSize:16,padding:"2px 6px",lineHeight:1},G={flex:1,height:4,cursor:"pointer",accentColor:"#fff"};function T(o,r){const e=o/r,s=Math.floor(e/60),i=Math.floor(e%60),c=Math.floor(e%1*100);return`${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")}.${String(c).padStart(2,"0")}`}const D=({player:o,durationInFrames:r,fps:e})=>{const s=n.useCallback(i=>{o.seekTo(Number(i.target.value))},[o]);return a.jsxs("div",{style:K,children:[a.jsx("button",{type:"button",style:B,onClick:o.toggle,"aria-label":o.playing?"Pause":"Play",children:o.playing?"⏸":"▶"}),a.jsx("input",{type:"range",min:0,max:r-1,value:o.frame,onChange:s,style:G}),a.jsxs("span",{style:{minWidth:100,textAlign:"right",fontVariantNumeric:"tabular-nums"},children:[T(o.frame,e)," / ",T(r-1,e)]})]})};D.displayName="PlayerControls";class J extends n.Component{constructor(){super(...arguments);j(this,"state",{error:null})}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,s){console.error("Rendiv Player error:",e,s)}render(){if(this.state.error){const e=this.props.fallback;return e?a.jsx(e,{error:this.state.error}):a.jsx("div",{style:{padding:20,color:"#ff4444",backgroundColor:"#1a1a1a",fontFamily:"monospace",fontSize:14,whiteSpace:"pre-wrap",overflow:"auto",width:"100%",height:"100%"},children:this.state.error.message})}return this.props.children}}const L=n.forwardRef((o,r)=>{const{component:e,durationInFrames:s,fps:i,compositionWidth:c,compositionHeight:h,compositionId:k="player",controls:x=!1,loop:y=!1,autoPlay:m=!1,playbackRate:v=1,inputProps:p={},style:w,errorFallback:P}=o,C=n.useRef(null),u=n.useMemo(()=>new O,[]),[f,g]=n.useState(c),t=$({fps:i,durationInFrames:s,loop:y,playbackRate:v,autoPlay:m});n.useEffect(()=>{const l=C.current;if(!l)return;const M=new ResizeObserver(z=>{for(const H of z)g(H.contentRect.width)});return M.observe(l),()=>M.disconnect()},[]),n.useEffect(()=>{u.emit("frameupdate",{frame:t.frame})},[t.frame,u]),n.useEffect(()=>{t.playing?u.emit("play"):u.emit("pause")},[t.playing,u]);const b=n.useRef(t.frame);b.current=t.frame;const S=n.useRef(t.playing);S.current=t.playing,n.useImperativeHandle(r,()=>({play:t.play,pause:t.pause,toggle:t.toggle,seekTo:t.seekTo,getCurrentFrame:()=>b.current,isPlaying:()=>S.current,getContainerNode:()=>C.current,mute:()=>{},unmute:()=>{},setVolume:()=>{},addEventListener:u.addEventListener.bind(u),removeEventListener:u.removeEventListener.bind(u)}));const d=n.useMemo(()=>({id:k,width:c,height:h,fps:i,durationInFrames:s,defaultProps:p}),[k,c,h,i,s,p]),R=n.useMemo(()=>({frame:t.frame,playing:t.playing,playingRef:{current:t.playing}}),[t.frame,t.playing]),A=n.useMemo(()=>({environment:"player"}),[]),F=f/c,I=h*F,q=n.useCallback(l=>{l.key===" "||l.key==="k"?(l.preventDefault(),t.toggle()):l.key==="ArrowLeft"?(l.preventDefault(),t.seekTo(t.frame-1)):l.key==="ArrowRight"?(l.preventDefault(),t.seekTo(t.frame+1)):l.key==="0"&&(l.preventDefault(),t.seekTo(0))},[t]),N=a.jsx(J,{fallback:P,children:a.jsx(e,{...p})});return a.jsxs("div",{ref:C,style:{position:"relative",overflow:"hidden",width:"100%",height:I,backgroundColor:"#000",...w},tabIndex:0,onKeyDown:q,children:[a.jsx("div",{style:{width:c,height:h,transform:`scale(${F})`,transformOrigin:"top left",overflow:"hidden"},children:a.jsx(E.RendivEnvironmentContext.Provider,{value:A,children:a.jsx(E.CompositionContext.Provider,{value:d,children:a.jsx(E.TimelineContext.Provider,{value:R,children:N})})})}),x&&a.jsx(D,{player:t,durationInFrames:s,fps:i})]})});L.displayName="Player";exports.Player=L;
|
package/dist/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var D = (n, r, e) =>
|
|
1
|
+
var K = Object.defineProperty;
|
|
2
|
+
var O = (n, r, e) => r in n ? K(n, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[r] = e;
|
|
3
|
+
var D = (n, r, e) => O(n, typeof r != "symbol" ? r + "" : r, e);
|
|
4
4
|
import { jsxs as L, jsx as c } from "react/jsx-runtime";
|
|
5
|
-
import { useState as M, useRef as
|
|
6
|
-
import { RendivEnvironmentContext as
|
|
7
|
-
function
|
|
8
|
-
const { fps: r, durationInFrames: e, loop: o, playbackRate: a, autoPlay: i } = n, [
|
|
5
|
+
import { useState as M, useRef as k, useCallback as b, useEffect as F, Component as B, forwardRef as G, useMemo as R, useImperativeHandle as J } from "react";
|
|
6
|
+
import { RendivEnvironmentContext as Q, CompositionContext as U, TimelineContext as X } from "@rendiv/core";
|
|
7
|
+
function Y(n) {
|
|
8
|
+
const { fps: r, durationInFrames: e, loop: o, playbackRate: a, autoPlay: i } = n, [g, w] = M(0), [C, h] = M(i), d = k(null), y = k(0), m = k(0), E = b(() => h(!0), []), T = b(() => h(!1), []), P = b(() => h((f) => !f), []), l = b(
|
|
9
9
|
(f) => {
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const p = Math.max(0, Math.min(f, e - 1));
|
|
11
|
+
m.current = p, w(p);
|
|
12
12
|
},
|
|
13
13
|
[e]
|
|
14
14
|
);
|
|
15
|
-
return
|
|
16
|
-
if (!
|
|
17
|
-
|
|
15
|
+
return F(() => {
|
|
16
|
+
if (!C) {
|
|
17
|
+
d.current = null, y.current = 0;
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
let f;
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
let
|
|
26
|
-
for (;
|
|
27
|
-
if (
|
|
21
|
+
const p = 1e3 / (r * a), t = (v) => {
|
|
22
|
+
d.current === null && (d.current = v);
|
|
23
|
+
const S = v - d.current;
|
|
24
|
+
d.current = v, y.current += S;
|
|
25
|
+
let u = m.current, x = !1;
|
|
26
|
+
for (; y.current >= p; )
|
|
27
|
+
if (y.current -= p, u += 1, x = !0, u >= e)
|
|
28
28
|
if (o)
|
|
29
|
-
|
|
29
|
+
u = 0;
|
|
30
30
|
else {
|
|
31
|
-
|
|
31
|
+
u = e - 1, h(!1);
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
x && (m.current = u, w(u)), f = requestAnimationFrame(t);
|
|
35
35
|
};
|
|
36
|
-
return f = requestAnimationFrame(
|
|
37
|
-
}, [
|
|
36
|
+
return f = requestAnimationFrame(t), () => cancelAnimationFrame(f);
|
|
37
|
+
}, [C, r, a, o, e]), { frame: g, playing: C, play: E, pause: T, toggle: P, seekTo: l };
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class Z {
|
|
40
40
|
constructor() {
|
|
41
41
|
D(this, "listeners", /* @__PURE__ */ new Map());
|
|
42
42
|
}
|
|
@@ -55,7 +55,7 @@ class Y {
|
|
|
55
55
|
i(a);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const _ = {
|
|
59
59
|
position: "absolute",
|
|
60
60
|
bottom: 0,
|
|
61
61
|
left: 0,
|
|
@@ -69,7 +69,7 @@ const Z = {
|
|
|
69
69
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
70
70
|
fontSize: 13,
|
|
71
71
|
userSelect: "none"
|
|
72
|
-
},
|
|
72
|
+
}, ee = {
|
|
73
73
|
background: "none",
|
|
74
74
|
border: "none",
|
|
75
75
|
color: "#fff",
|
|
@@ -77,7 +77,7 @@ const Z = {
|
|
|
77
77
|
fontSize: 16,
|
|
78
78
|
padding: "2px 6px",
|
|
79
79
|
lineHeight: 1
|
|
80
|
-
},
|
|
80
|
+
}, te = {
|
|
81
81
|
flex: 1,
|
|
82
82
|
height: 4,
|
|
83
83
|
cursor: "pointer",
|
|
@@ -92,18 +92,18 @@ const z = ({
|
|
|
92
92
|
durationInFrames: r,
|
|
93
93
|
fps: e
|
|
94
94
|
}) => {
|
|
95
|
-
const o =
|
|
95
|
+
const o = b(
|
|
96
96
|
(a) => {
|
|
97
97
|
n.seekTo(Number(a.target.value));
|
|
98
98
|
},
|
|
99
99
|
[n]
|
|
100
100
|
);
|
|
101
|
-
return /* @__PURE__ */ L("div", { style:
|
|
101
|
+
return /* @__PURE__ */ L("div", { style: _, children: [
|
|
102
102
|
/* @__PURE__ */ c(
|
|
103
103
|
"button",
|
|
104
104
|
{
|
|
105
105
|
type: "button",
|
|
106
|
-
style:
|
|
106
|
+
style: ee,
|
|
107
107
|
onClick: n.toggle,
|
|
108
108
|
"aria-label": n.playing ? "Pause" : "Play",
|
|
109
109
|
children: n.playing ? "⏸" : "▶"
|
|
@@ -117,7 +117,7 @@ const z = ({
|
|
|
117
117
|
max: r - 1,
|
|
118
118
|
value: n.frame,
|
|
119
119
|
onChange: o,
|
|
120
|
-
style:
|
|
120
|
+
style: te
|
|
121
121
|
}
|
|
122
122
|
),
|
|
123
123
|
/* @__PURE__ */ L("span", { style: { minWidth: 100, textAlign: "right", fontVariantNumeric: "tabular-nums" }, children: [
|
|
@@ -128,7 +128,7 @@ const z = ({
|
|
|
128
128
|
] });
|
|
129
129
|
};
|
|
130
130
|
z.displayName = "PlayerControls";
|
|
131
|
-
class
|
|
131
|
+
class re extends B {
|
|
132
132
|
constructor() {
|
|
133
133
|
super(...arguments);
|
|
134
134
|
D(this, "state", { error: null });
|
|
@@ -163,51 +163,52 @@ class te extends O {
|
|
|
163
163
|
return this.props.children;
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
-
const
|
|
166
|
+
const ne = G((n, r) => {
|
|
167
167
|
const {
|
|
168
168
|
component: e,
|
|
169
169
|
durationInFrames: o,
|
|
170
170
|
fps: a,
|
|
171
171
|
compositionWidth: i,
|
|
172
|
-
compositionHeight:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
172
|
+
compositionHeight: g,
|
|
173
|
+
compositionId: w = "player",
|
|
174
|
+
controls: C = !1,
|
|
175
|
+
loop: h = !1,
|
|
176
|
+
autoPlay: d = !1,
|
|
177
|
+
playbackRate: y = 1,
|
|
178
|
+
inputProps: m = {},
|
|
179
|
+
style: E,
|
|
180
|
+
errorFallback: T
|
|
181
|
+
} = n, P = k(null), l = R(() => new Z(), []), [f, p] = M(i), t = Y({
|
|
181
182
|
fps: a,
|
|
182
183
|
durationInFrames: o,
|
|
183
|
-
loop:
|
|
184
|
-
playbackRate:
|
|
185
|
-
autoPlay:
|
|
184
|
+
loop: h,
|
|
185
|
+
playbackRate: y,
|
|
186
|
+
autoPlay: d
|
|
186
187
|
});
|
|
187
|
-
|
|
188
|
-
const s =
|
|
188
|
+
F(() => {
|
|
189
|
+
const s = P.current;
|
|
189
190
|
if (!s) return;
|
|
190
|
-
const I = new ResizeObserver((
|
|
191
|
-
for (const
|
|
192
|
-
|
|
191
|
+
const I = new ResizeObserver((j) => {
|
|
192
|
+
for (const q of j)
|
|
193
|
+
p(q.contentRect.width);
|
|
193
194
|
});
|
|
194
195
|
return I.observe(s), () => I.disconnect();
|
|
195
|
-
}, []),
|
|
196
|
+
}, []), F(() => {
|
|
196
197
|
l.emit("frameupdate", { frame: t.frame });
|
|
197
|
-
}, [t.frame, l]),
|
|
198
|
+
}, [t.frame, l]), F(() => {
|
|
198
199
|
t.playing ? l.emit("play") : l.emit("pause");
|
|
199
200
|
}, [t.playing, l]);
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
const
|
|
203
|
-
|
|
201
|
+
const v = k(t.frame);
|
|
202
|
+
v.current = t.frame;
|
|
203
|
+
const S = k(t.playing);
|
|
204
|
+
S.current = t.playing, J(r, () => ({
|
|
204
205
|
play: t.play,
|
|
205
206
|
pause: t.pause,
|
|
206
207
|
toggle: t.toggle,
|
|
207
208
|
seekTo: t.seekTo,
|
|
208
|
-
getCurrentFrame: () =>
|
|
209
|
-
isPlaying: () =>
|
|
210
|
-
getContainerNode: () =>
|
|
209
|
+
getCurrentFrame: () => v.current,
|
|
210
|
+
isPlaying: () => S.current,
|
|
211
|
+
getContainerNode: () => P.current,
|
|
211
212
|
mute: () => {
|
|
212
213
|
},
|
|
213
214
|
unmute: () => {
|
|
@@ -217,61 +218,61 @@ const re = B((n, r) => {
|
|
|
217
218
|
addEventListener: l.addEventListener.bind(l),
|
|
218
219
|
removeEventListener: l.removeEventListener.bind(l)
|
|
219
220
|
}));
|
|
220
|
-
const
|
|
221
|
+
const u = R(
|
|
221
222
|
() => ({
|
|
222
|
-
id:
|
|
223
|
+
id: w,
|
|
223
224
|
width: i,
|
|
224
|
-
height:
|
|
225
|
+
height: g,
|
|
225
226
|
fps: a,
|
|
226
227
|
durationInFrames: o,
|
|
227
|
-
defaultProps:
|
|
228
|
+
defaultProps: m
|
|
228
229
|
}),
|
|
229
|
-
[i,
|
|
230
|
-
),
|
|
230
|
+
[w, i, g, a, o, m]
|
|
231
|
+
), x = R(
|
|
231
232
|
() => ({
|
|
232
233
|
frame: t.frame,
|
|
233
234
|
playing: t.playing,
|
|
234
235
|
playingRef: { current: t.playing }
|
|
235
236
|
}),
|
|
236
237
|
[t.frame, t.playing]
|
|
237
|
-
),
|
|
238
|
+
), H = R(
|
|
238
239
|
() => ({ environment: "player" }),
|
|
239
240
|
[]
|
|
240
|
-
), A =
|
|
241
|
+
), A = f / i, V = g * A, W = b(
|
|
241
242
|
(s) => {
|
|
242
243
|
s.key === " " || s.key === "k" ? (s.preventDefault(), t.toggle()) : s.key === "ArrowLeft" ? (s.preventDefault(), t.seekTo(t.frame - 1)) : s.key === "ArrowRight" ? (s.preventDefault(), t.seekTo(t.frame + 1)) : s.key === "0" && (s.preventDefault(), t.seekTo(0));
|
|
243
244
|
},
|
|
244
245
|
[t]
|
|
245
|
-
),
|
|
246
|
+
), $ = /* @__PURE__ */ c(re, { fallback: T, children: /* @__PURE__ */ c(e, { ...m }) });
|
|
246
247
|
return /* @__PURE__ */ L(
|
|
247
248
|
"div",
|
|
248
249
|
{
|
|
249
|
-
ref:
|
|
250
|
+
ref: P,
|
|
250
251
|
style: {
|
|
251
252
|
position: "relative",
|
|
252
253
|
overflow: "hidden",
|
|
253
254
|
width: "100%",
|
|
254
|
-
height:
|
|
255
|
+
height: V,
|
|
255
256
|
backgroundColor: "#000",
|
|
256
|
-
...
|
|
257
|
+
...E
|
|
257
258
|
},
|
|
258
259
|
tabIndex: 0,
|
|
259
|
-
onKeyDown:
|
|
260
|
+
onKeyDown: W,
|
|
260
261
|
children: [
|
|
261
262
|
/* @__PURE__ */ c(
|
|
262
263
|
"div",
|
|
263
264
|
{
|
|
264
265
|
style: {
|
|
265
266
|
width: i,
|
|
266
|
-
height:
|
|
267
|
+
height: g,
|
|
267
268
|
transform: `scale(${A})`,
|
|
268
269
|
transformOrigin: "top left",
|
|
269
270
|
overflow: "hidden"
|
|
270
271
|
},
|
|
271
|
-
children: /* @__PURE__ */ c(
|
|
272
|
+
children: /* @__PURE__ */ c(Q.Provider, { value: H, children: /* @__PURE__ */ c(U.Provider, { value: u, children: /* @__PURE__ */ c(X.Provider, { value: x, children: $ }) }) })
|
|
272
273
|
}
|
|
273
274
|
),
|
|
274
|
-
|
|
275
|
+
C && /* @__PURE__ */ c(
|
|
275
276
|
z,
|
|
276
277
|
{
|
|
277
278
|
player: t,
|
|
@@ -283,7 +284,7 @@ const re = B((n, r) => {
|
|
|
283
284
|
}
|
|
284
285
|
);
|
|
285
286
|
});
|
|
286
|
-
|
|
287
|
+
ne.displayName = "Player";
|
|
287
288
|
export {
|
|
288
|
-
|
|
289
|
+
ne as Player
|
|
289
290
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rendiv/player",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"react": "^18.0.0 || ^19.0.0",
|
|
21
21
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
22
|
-
"@rendiv/core": "0.1.
|
|
22
|
+
"@rendiv/core": "0.1.3"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/react": "^19.0.0",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"vite-plugin-dts": "^4.3.0",
|
|
31
31
|
"typescript": "^5.7.0",
|
|
32
32
|
"@rendiv/tsconfig": "0.0.0",
|
|
33
|
-
"@rendiv/core": "0.1.
|
|
33
|
+
"@rendiv/core": "0.1.3"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"build": "vite build",
|