react-hook-videojs 3.0.2 → 4.0.0-beta.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Jimmy Callin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ declare const deepClone: <T>(value: T) => T;
2
+ export default deepClone;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,81 @@
1
- import React, { HTMLProps } from "react";
2
- import { VideoJsPlayer, VideoJsPlayerOptions } from "video.js";
3
- declare type VideoProps = {
4
- children?: React.ReactNode;
5
- } & Partial<HTMLProps<HTMLVideoElement>>;
6
- declare type VideoType = (props: VideoProps) => JSX.Element;
1
+ import type { ComponentPropsWithRef, MutableRefObject, Ref } from "react";
2
+ type VideoJsModule = (typeof import("video.js"))["default"];
3
+ type VideoJsPlayer = ReturnType<VideoJsModule>;
4
+ type VideoJsPlayerOptions = Parameters<VideoJsModule>[1];
5
+ export declare const __private__: {
6
+ setVideoNodeRef: (videoNode: MutableRefObject<HTMLVideoElement | null>, videoRef: Ref<HTMLVideoElement> | undefined, value: HTMLVideoElement | null) => void;
7
+ getVideoClassName: (classNames: string, className?: string) => string;
8
+ restoreDisposedVideoNode: (containerNode: HTMLDivElement, originalVideoNode: HTMLVideoElement | null, videoNode: MutableRefObject<HTMLVideoElement | null>, videoRef?: Ref<HTMLVideoElement>) => void;
9
+ shouldSkipReadyCallback: (disposed: boolean, playerRef: MutableRefObject<VideoJsPlayer | null>, initializedPlayer: VideoJsPlayer) => boolean;
10
+ callOnReadyForCurrentPlayer: (disposed: boolean, playerRef: MutableRefObject<VideoJsPlayer | null>, initializedPlayer: VideoJsPlayer, onReady: (player: VideoJsPlayer) => void) => void;
11
+ getCurrentVideoNode: (containerNode: HTMLDivElement, videoNode: MutableRefObject<HTMLVideoElement | null>) => HTMLVideoElement | null;
12
+ };
13
+ type VideoElementProps = ComponentPropsWithRef<"video">;
14
+ /** All standard `<video>` element attributes and the `ref` prop are accepted. */
15
+ export type VideoProps = VideoElementProps;
16
+ /**
17
+ * The `Video` component returned by {@link useVideoJS}.
18
+ *
19
+ * Renders a Video.js-managed `<video>` element. Accepts any prop that a
20
+ * native `<video>` element accepts (including `ref`, `className`, `muted`,
21
+ * `autoPlay`, etc.) as well as child elements such as `<track>` nodes.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * const { Video } = useVideoJS(options);
26
+ * return (
27
+ * <Video className="my-player" muted>
28
+ * <track kind="captions" src="/captions.vtt" srcLang="en" default />
29
+ * </Video>
30
+ * );
31
+ * ```
32
+ */
33
+ export type VideoComponent = (props: VideoProps) => React.JSX.Element;
34
+ /**
35
+ * Integrates Video.js with React.
36
+ *
37
+ * Initializes a Video.js player when the returned `Video` component mounts,
38
+ * disposes it on unmount or when `videoJsOptions` changes, and reinitializes
39
+ * with the new configuration — all while handling React 19 Strict Mode's
40
+ * double-invoke lifecycle correctly.
41
+ *
42
+ * @param videoJsOptions - Video.js player options. **Must be memoized** (e.g.
43
+ * with `React.useMemo`) so the player only reinitializes when options values
44
+ * actually change, not on every render.
45
+ * @param classNames - Optional CSS class name(s) appended to the `<video>`
46
+ * node in addition to the required `"video-js"` class.
47
+ * @returns An object with three fields:
48
+ * - `Video` — React component to render in JSX. Accepts all `<video>` props
49
+ * and children (e.g. `<track>` elements).
50
+ * - `ready` — `true` once the player has fired its `"ready"` event.
51
+ * - `player` — The `VideoJsPlayer` instance when ready, `null` otherwise.
52
+ * Use this to call Video.js API methods imperatively (e.g. in a
53
+ * `useEffect` that depends on `player`).
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * import React, { useMemo, useEffect } from "react";
58
+ * import "video.js/dist/video-js.css";
59
+ * import { useVideoJS } from "react-hook-videojs";
60
+ *
61
+ * const MyPlayer = ({ src }: { src: string }) => {
62
+ * const options = useMemo(() => ({ sources: [{ src }] }), [src]);
63
+ * const { Video, ready, player } = useVideoJS(options);
64
+ *
65
+ * // Attach event listeners imperatively once the player is ready
66
+ * useEffect(() => {
67
+ * if (!player) return;
68
+ * const onPlay = () => console.log("playing");
69
+ * player.on("play", onPlay);
70
+ * return () => { player.off("play", onPlay); };
71
+ * }, [player]);
72
+ *
73
+ * return <Video />;
74
+ * };
75
+ * ```
76
+ */
7
77
  export declare const useVideoJS: (videoJsOptions: VideoJsPlayerOptions, classNames?: string) => {
8
- Video: VideoType;
78
+ Video: VideoComponent;
9
79
  ready: boolean;
10
80
  player: VideoJsPlayer | null;
11
81
  };
@@ -1,70 +1,545 @@
1
- import React, { forwardRef, useRef, useLayoutEffect, useState, useCallback } from "react";
2
- import videojs from "video.js";
3
- import cloneDeep from "lodash.clonedeep";
4
- import { dequal } from "dequal";
5
- function useDeepCompareMemoize(value) {
6
- const ref = React.useRef(value);
7
- const signalRef = React.useRef(0);
8
- if (!dequal(value, ref.current)) {
9
- ref.current = value;
10
- signalRef.current += 1;
11
- }
12
- return React.useMemo(() => ref.current, [signalRef.current]);
1
+ import require$$0, { useState, useRef, useCallback, useMemo, useEffect } from "react";
2
+ import videojsModule from "video.js";
3
+ var jsxRuntime = { exports: {} };
4
+ var reactJsxRuntime_production = {};
5
+ var hasRequiredReactJsxRuntime_production;
6
+ function requireReactJsxRuntime_production() {
7
+ if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
8
+ hasRequiredReactJsxRuntime_production = 1;
9
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function jsxProd(type, config, maybeKey) {
11
+ var key = null;
12
+ void 0 !== maybeKey && (key = "" + maybeKey);
13
+ void 0 !== config.key && (key = "" + config.key);
14
+ if ("key" in config) {
15
+ maybeKey = {};
16
+ for (var propName in config)
17
+ "key" !== propName && (maybeKey[propName] = config[propName]);
18
+ } else maybeKey = config;
19
+ config = maybeKey.ref;
20
+ return {
21
+ $$typeof: REACT_ELEMENT_TYPE,
22
+ type,
23
+ key,
24
+ ref: void 0 !== config ? config : null,
25
+ props: maybeKey
26
+ };
27
+ }
28
+ reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
29
+ reactJsxRuntime_production.jsx = jsxProd;
30
+ reactJsxRuntime_production.jsxs = jsxProd;
31
+ return reactJsxRuntime_production;
13
32
  }
14
- const VideoJsWrapper = forwardRef(({ children, videoJsOptions, onReady, onDispose, classNames, ...props }, playerRef) => {
15
- const player = playerRef;
16
- const videoJsOptionsCloned = cloneDeep(videoJsOptions);
33
+ var reactJsxRuntime_development = {};
34
+ var hasRequiredReactJsxRuntime_development;
35
+ function requireReactJsxRuntime_development() {
36
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
37
+ hasRequiredReactJsxRuntime_development = 1;
38
+ "production" !== process.env.NODE_ENV && (function() {
39
+ function getComponentNameFromType(type) {
40
+ if (null == type) return null;
41
+ if ("function" === typeof type)
42
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
43
+ if ("string" === typeof type) return type;
44
+ switch (type) {
45
+ case REACT_FRAGMENT_TYPE:
46
+ return "Fragment";
47
+ case REACT_PROFILER_TYPE:
48
+ return "Profiler";
49
+ case REACT_STRICT_MODE_TYPE:
50
+ return "StrictMode";
51
+ case REACT_SUSPENSE_TYPE:
52
+ return "Suspense";
53
+ case REACT_SUSPENSE_LIST_TYPE:
54
+ return "SuspenseList";
55
+ case REACT_ACTIVITY_TYPE:
56
+ return "Activity";
57
+ }
58
+ if ("object" === typeof type)
59
+ switch ("number" === typeof type.tag && console.error(
60
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
61
+ ), type.$$typeof) {
62
+ case REACT_PORTAL_TYPE:
63
+ return "Portal";
64
+ case REACT_CONTEXT_TYPE:
65
+ return type.displayName || "Context";
66
+ case REACT_CONSUMER_TYPE:
67
+ return (type._context.displayName || "Context") + ".Consumer";
68
+ case REACT_FORWARD_REF_TYPE:
69
+ var innerType = type.render;
70
+ type = type.displayName;
71
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
72
+ return type;
73
+ case REACT_MEMO_TYPE:
74
+ return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
75
+ case REACT_LAZY_TYPE:
76
+ innerType = type._payload;
77
+ type = type._init;
78
+ try {
79
+ return getComponentNameFromType(type(innerType));
80
+ } catch (x) {
81
+ }
82
+ }
83
+ return null;
84
+ }
85
+ function testStringCoercion(value) {
86
+ return "" + value;
87
+ }
88
+ function checkKeyStringCoercion(value) {
89
+ try {
90
+ testStringCoercion(value);
91
+ var JSCompiler_inline_result = false;
92
+ } catch (e) {
93
+ JSCompiler_inline_result = true;
94
+ }
95
+ if (JSCompiler_inline_result) {
96
+ JSCompiler_inline_result = console;
97
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
98
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
99
+ JSCompiler_temp_const.call(
100
+ JSCompiler_inline_result,
101
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
102
+ JSCompiler_inline_result$jscomp$0
103
+ );
104
+ return testStringCoercion(value);
105
+ }
106
+ }
107
+ function getTaskName(type) {
108
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
109
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
110
+ return "<...>";
111
+ try {
112
+ var name = getComponentNameFromType(type);
113
+ return name ? "<" + name + ">" : "<...>";
114
+ } catch (x) {
115
+ return "<...>";
116
+ }
117
+ }
118
+ function getOwner() {
119
+ var dispatcher = ReactSharedInternals.A;
120
+ return null === dispatcher ? null : dispatcher.getOwner();
121
+ }
122
+ function UnknownOwner() {
123
+ return Error("react-stack-top-frame");
124
+ }
125
+ function hasValidKey(config) {
126
+ if (hasOwnProperty.call(config, "key")) {
127
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
128
+ if (getter && getter.isReactWarning) return false;
129
+ }
130
+ return void 0 !== config.key;
131
+ }
132
+ function defineKeyPropWarningGetter(props, displayName) {
133
+ function warnAboutAccessingKey() {
134
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
135
+ "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
136
+ displayName
137
+ ));
138
+ }
139
+ warnAboutAccessingKey.isReactWarning = true;
140
+ Object.defineProperty(props, "key", {
141
+ get: warnAboutAccessingKey,
142
+ configurable: true
143
+ });
144
+ }
145
+ function elementRefGetterWithDeprecationWarning() {
146
+ var componentName = getComponentNameFromType(this.type);
147
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
148
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
149
+ ));
150
+ componentName = this.props.ref;
151
+ return void 0 !== componentName ? componentName : null;
152
+ }
153
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
154
+ var refProp = props.ref;
155
+ type = {
156
+ $$typeof: REACT_ELEMENT_TYPE,
157
+ type,
158
+ key,
159
+ props,
160
+ _owner: owner
161
+ };
162
+ null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
163
+ enumerable: false,
164
+ get: elementRefGetterWithDeprecationWarning
165
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
166
+ type._store = {};
167
+ Object.defineProperty(type._store, "validated", {
168
+ configurable: false,
169
+ enumerable: false,
170
+ writable: true,
171
+ value: 0
172
+ });
173
+ Object.defineProperty(type, "_debugInfo", {
174
+ configurable: false,
175
+ enumerable: false,
176
+ writable: true,
177
+ value: null
178
+ });
179
+ Object.defineProperty(type, "_debugStack", {
180
+ configurable: false,
181
+ enumerable: false,
182
+ writable: true,
183
+ value: debugStack
184
+ });
185
+ Object.defineProperty(type, "_debugTask", {
186
+ configurable: false,
187
+ enumerable: false,
188
+ writable: true,
189
+ value: debugTask
190
+ });
191
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
192
+ return type;
193
+ }
194
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
195
+ var children = config.children;
196
+ if (void 0 !== children)
197
+ if (isStaticChildren)
198
+ if (isArrayImpl(children)) {
199
+ for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
200
+ validateChildKeys(children[isStaticChildren]);
201
+ Object.freeze && Object.freeze(children);
202
+ } else
203
+ console.error(
204
+ "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
205
+ );
206
+ else validateChildKeys(children);
207
+ if (hasOwnProperty.call(config, "key")) {
208
+ children = getComponentNameFromType(type);
209
+ var keys = Object.keys(config).filter(function(k) {
210
+ return "key" !== k;
211
+ });
212
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
213
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
214
+ 'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
215
+ isStaticChildren,
216
+ children,
217
+ keys,
218
+ children
219
+ ), didWarnAboutKeySpread[children + isStaticChildren] = true);
220
+ }
221
+ children = null;
222
+ void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
223
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
224
+ if ("key" in config) {
225
+ maybeKey = {};
226
+ for (var propName in config)
227
+ "key" !== propName && (maybeKey[propName] = config[propName]);
228
+ } else maybeKey = config;
229
+ children && defineKeyPropWarningGetter(
230
+ maybeKey,
231
+ "function" === typeof type ? type.displayName || type.name || "Unknown" : type
232
+ );
233
+ return ReactElement(
234
+ type,
235
+ children,
236
+ maybeKey,
237
+ getOwner(),
238
+ debugStack,
239
+ debugTask
240
+ );
241
+ }
242
+ function validateChildKeys(node) {
243
+ isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
244
+ }
245
+ function isValidElement(object) {
246
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
247
+ }
248
+ var React = require$$0, REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
249
+ return null;
250
+ };
251
+ React = {
252
+ react_stack_bottom_frame: function(callStackForError) {
253
+ return callStackForError();
254
+ }
255
+ };
256
+ var specialPropKeyWarningShown;
257
+ var didWarnAboutElementRef = {};
258
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
259
+ React,
260
+ UnknownOwner
261
+ )();
262
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
263
+ var didWarnAboutKeySpread = {};
264
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
265
+ reactJsxRuntime_development.jsx = function(type, config, maybeKey) {
266
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
267
+ return jsxDEVImpl(
268
+ type,
269
+ config,
270
+ maybeKey,
271
+ false,
272
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
273
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
274
+ );
275
+ };
276
+ reactJsxRuntime_development.jsxs = function(type, config, maybeKey) {
277
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
278
+ return jsxDEVImpl(
279
+ type,
280
+ config,
281
+ maybeKey,
282
+ true,
283
+ trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
284
+ trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
285
+ );
286
+ };
287
+ })();
288
+ return reactJsxRuntime_development;
289
+ }
290
+ var hasRequiredJsxRuntime;
291
+ function requireJsxRuntime() {
292
+ if (hasRequiredJsxRuntime) return jsxRuntime.exports;
293
+ hasRequiredJsxRuntime = 1;
294
+ if (process.env.NODE_ENV === "production") {
295
+ jsxRuntime.exports = requireReactJsxRuntime_production();
296
+ } else {
297
+ jsxRuntime.exports = requireReactJsxRuntime_development();
298
+ }
299
+ return jsxRuntime.exports;
300
+ }
301
+ var jsxRuntimeExports = requireJsxRuntime();
302
+ const cloneWithDescriptor = (descriptor, cloneValue) => {
303
+ if (!("value" in descriptor)) {
304
+ return descriptor;
305
+ }
306
+ return {
307
+ ...descriptor,
308
+ value: cloneValue(descriptor.value)
309
+ };
310
+ };
311
+ const deepCloneInternal = (value, seen) => {
312
+ if (value === null || typeof value !== "object") {
313
+ return value;
314
+ }
315
+ if (typeof Node !== "undefined" && value instanceof Node) {
316
+ return value;
317
+ }
318
+ const cached = seen.get(value);
319
+ if (cached) {
320
+ return cached;
321
+ }
322
+ if (value instanceof Date) {
323
+ const clonedDate = new Date(value.getTime());
324
+ seen.set(value, clonedDate);
325
+ return clonedDate;
326
+ }
327
+ if (value instanceof RegExp) {
328
+ const clonedRegExp = new RegExp(value.source, value.flags);
329
+ clonedRegExp.lastIndex = value.lastIndex;
330
+ seen.set(value, clonedRegExp);
331
+ return clonedRegExp;
332
+ }
333
+ if (value instanceof ArrayBuffer) {
334
+ const clonedBuffer = value.slice(0);
335
+ seen.set(value, clonedBuffer);
336
+ return clonedBuffer;
337
+ }
338
+ if (ArrayBuffer.isView(value)) {
339
+ if (value instanceof DataView) {
340
+ const clonedBuffer2 = deepCloneInternal(value.buffer, seen);
341
+ const clonedDataView = new DataView(
342
+ clonedBuffer2,
343
+ value.byteOffset,
344
+ value.byteLength
345
+ );
346
+ seen.set(value, clonedDataView);
347
+ return clonedDataView;
348
+ }
349
+ const TypedArrayConstructor = value.constructor;
350
+ const clonedBuffer = deepCloneInternal(value.buffer, seen);
351
+ const length = value.byteLength / TypedArrayConstructor.BYTES_PER_ELEMENT;
352
+ const clonedTypedArray = new TypedArrayConstructor(
353
+ clonedBuffer,
354
+ value.byteOffset,
355
+ length
356
+ );
357
+ seen.set(value, clonedTypedArray);
358
+ return clonedTypedArray;
359
+ }
360
+ if (value instanceof Map) {
361
+ const clonedMap = /* @__PURE__ */ new Map();
362
+ seen.set(value, clonedMap);
363
+ for (const [key, mapValue] of value.entries()) {
364
+ clonedMap.set(
365
+ deepCloneInternal(key, seen),
366
+ deepCloneInternal(mapValue, seen)
367
+ );
368
+ }
369
+ return clonedMap;
370
+ }
371
+ if (value instanceof Set) {
372
+ const clonedSet = /* @__PURE__ */ new Set();
373
+ seen.set(value, clonedSet);
374
+ for (const setValue of value.values()) {
375
+ clonedSet.add(deepCloneInternal(setValue, seen));
376
+ }
377
+ return clonedSet;
378
+ }
379
+ const clonedObject = Array.isArray(value) ? (() => {
380
+ const clonedArray = [];
381
+ clonedArray.length = value.length;
382
+ return clonedArray;
383
+ })() : Object.create(Object.getPrototypeOf(value));
384
+ seen.set(value, clonedObject);
385
+ for (const key of Reflect.ownKeys(value)) {
386
+ if (Array.isArray(value) && key === "length") {
387
+ continue;
388
+ }
389
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
390
+ if (!descriptor) {
391
+ continue;
392
+ }
393
+ Object.defineProperty(
394
+ clonedObject,
395
+ key,
396
+ cloneWithDescriptor(
397
+ descriptor,
398
+ (input) => deepCloneInternal(input, seen)
399
+ )
400
+ );
401
+ }
402
+ return clonedObject;
403
+ };
404
+ const deepClone = (value) => deepCloneInternal(value, /* @__PURE__ */ new WeakMap());
405
+ const videojs = videojsModule;
406
+ const setVideoNodeRef = (videoNode, videoRef, value) => {
407
+ videoNode.current = value;
408
+ if (!videoRef) {
409
+ return;
410
+ }
411
+ if (typeof videoRef === "function") {
412
+ videoRef(value);
413
+ return;
414
+ }
415
+ videoRef.current = value;
416
+ };
417
+ const getVideoClassName = (classNames, className) => ["video-js", classNames, className].filter(Boolean).join(" ");
418
+ const restoreDisposedVideoNode = (containerNode, originalVideoNode, videoNode, videoRef) => {
419
+ if (originalVideoNode && !containerNode.querySelector("video")) {
420
+ containerNode.appendChild(originalVideoNode);
421
+ setVideoNodeRef(
422
+ videoNode,
423
+ videoRef,
424
+ containerNode.querySelector("video")
425
+ );
426
+ }
427
+ };
428
+ const shouldSkipReadyCallback = (disposed, playerRef, initializedPlayer) => disposed || playerRef.current !== initializedPlayer;
429
+ const getCurrentVideoNode = (containerNode, videoNode) => {
430
+ const connectedVideoNode = containerNode.querySelector(
431
+ "video"
432
+ );
433
+ return videoNode.current?.isConnected === true ? videoNode.current : connectedVideoNode;
434
+ };
435
+ const callOnReadyForCurrentPlayer = (disposed, playerRef, initializedPlayer, onReady) => {
436
+ if (shouldSkipReadyCallback(disposed, playerRef, initializedPlayer)) {
437
+ return;
438
+ }
439
+ onReady(initializedPlayer);
440
+ };
441
+ const __private__ = {
442
+ setVideoNodeRef,
443
+ getVideoClassName,
444
+ restoreDisposedVideoNode,
445
+ shouldSkipReadyCallback,
446
+ callOnReadyForCurrentPlayer,
447
+ getCurrentVideoNode
448
+ };
449
+ const VideoJsWrapper = ({
450
+ children,
451
+ videoJsOptions,
452
+ onReady,
453
+ onDispose,
454
+ classNames,
455
+ playerRef,
456
+ ref: videoRef,
457
+ className,
458
+ ...props
459
+ }) => {
460
+ const videoJsOptionsCloned = useMemo(
461
+ () => deepClone(videoJsOptions),
462
+ [videoJsOptions]
463
+ );
17
464
  const videoNode = useRef(null);
18
465
  const containerRef = useRef(null);
19
- useLayoutEffect(() => {
20
- var _a;
21
- if (!((_a = videoNode.current) == null ? void 0 : _a.parentNode))
22
- return;
23
- const originalVideoNodeParent = videoNode.current.parentNode.cloneNode(true);
24
- if (!player.current) {
25
- player.current = videojs(videoNode.current, videoJsOptionsCloned);
26
- player.current.ready(() => {
27
- onReady();
28
- });
466
+ useEffect(() => {
467
+ const containerNode = containerRef.current;
468
+ const currentVideoNode = getCurrentVideoNode(containerNode, videoNode);
469
+ if (!currentVideoNode || !currentVideoNode.isConnected) return;
470
+ if (videoNode.current !== currentVideoNode) {
471
+ setVideoNodeRef(videoNode, videoRef, currentVideoNode);
29
472
  }
473
+ const originalVideoNode = currentVideoNode.cloneNode(
474
+ true
475
+ );
476
+ let disposed = false;
477
+ const initializedPlayer = videojs(currentVideoNode, videoJsOptionsCloned);
478
+ playerRef.current = initializedPlayer;
479
+ initializedPlayer.ready(() => {
480
+ callOnReadyForCurrentPlayer(
481
+ disposed,
482
+ playerRef,
483
+ initializedPlayer,
484
+ onReady
485
+ );
486
+ });
30
487
  return () => {
31
- var _a2;
32
- if (player.current) {
33
- player.current.dispose();
34
- if (containerRef.current && ((_a2 = videoNode.current) == null ? void 0 : _a2.parentNode) && !containerRef.current.contains(videoNode.current.parentNode)) {
35
- containerRef.current.appendChild(originalVideoNodeParent);
36
- videoNode.current = originalVideoNodeParent.firstChild;
37
- }
38
- player.current = null;
39
- onDispose();
40
- }
488
+ disposed = true;
489
+ initializedPlayer.dispose();
490
+ playerRef.current = null;
491
+ restoreDisposedVideoNode(
492
+ containerNode,
493
+ originalVideoNode,
494
+ videoNode,
495
+ videoRef
496
+ );
497
+ onDispose();
41
498
  };
42
- }, [useDeepCompareMemoize(videoJsOptions)]);
43
- return /* @__PURE__ */ React.createElement("div", {
44
- ref: containerRef
45
- }, /* @__PURE__ */ React.createElement("div", {
46
- "data-vjs-player": true
47
- }, /* @__PURE__ */ React.createElement("video", {
48
- ref: videoNode,
49
- className: `video-js ${classNames}`,
50
- ...props
51
- }, children)));
52
- });
53
- VideoJsWrapper.displayName = "VideoJsWrapper";
499
+ }, [videoJsOptionsCloned, onReady, onDispose, playerRef, videoRef]);
500
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { ref: containerRef, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
501
+ "video",
502
+ {
503
+ ref: (value) => {
504
+ setVideoNodeRef(videoNode, videoRef, value);
505
+ },
506
+ className: getVideoClassName(classNames, className),
507
+ ...props,
508
+ children
509
+ }
510
+ ) });
511
+ };
54
512
  const useVideoJS = (videoJsOptions, classNames = "") => {
55
513
  const [ready, setReady] = useState(false);
56
- const player = useRef(null);
57
- const Video = useCallback(({ children, ...props }) => /* @__PURE__ */ React.createElement(VideoJsWrapper, {
58
- videoJsOptions,
59
- classNames,
60
- onReady: () => setReady(true),
61
- onDispose: () => setReady(false),
62
- ...props,
63
- ref: player
64
- }, children), [useDeepCompareMemoize(videoJsOptions), classNames]);
65
- return { Video, ready, player: player.current };
514
+ const [player, setPlayer] = useState(null);
515
+ const playerRef = useRef(null);
516
+ const onReady = useCallback((playerInstance) => {
517
+ setReady(true);
518
+ setPlayer(playerInstance);
519
+ }, []);
520
+ const onDispose = useCallback(() => {
521
+ setReady(false);
522
+ setPlayer(null);
523
+ }, []);
524
+ const Video = useCallback(
525
+ ({ children, ...props }) => /* @__PURE__ */ jsxRuntimeExports.jsx(
526
+ VideoJsWrapper,
527
+ {
528
+ videoJsOptions,
529
+ classNames,
530
+ onReady,
531
+ onDispose,
532
+ playerRef,
533
+ ...props,
534
+ children
535
+ }
536
+ ),
537
+ [videoJsOptions, classNames, onReady, onDispose]
538
+ );
539
+ return { Video, ready, player };
66
540
  };
67
541
  export {
542
+ __private__,
68
543
  useVideoJS
69
544
  };
70
545
  //# sourceMappingURL=react-hook-videojs.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-hook-videojs.es.js","sources":["../src/index.tsx"],"sourcesContent":["import React, {\n useRef,\n useState,\n useLayoutEffect,\n useCallback,\n forwardRef,\n HTMLProps,\n MutableRefObject,\n} from \"react\";\nimport videojs, { VideoJsPlayer, VideoJsPlayerOptions } from \"video.js\";\nimport cloneDeep from \"lodash.clonedeep\";\nimport { dequal } from \"dequal\";\n\n// Function copied from\n// https://github.com/kentcdodds/use-deep-compare-effect/blob/main/src/index.ts\nfunction useDeepCompareMemoize<T>(value: T): T {\n const ref = React.useRef<T>(value);\n const signalRef = React.useRef<number>(0);\n\n if (!dequal(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return React.useMemo(() => ref.current, [signalRef.current]);\n}\n\n// Integrating React and video.js is a bit tricky, especially when supporting\n// React 18 strict mode. We'll do our best to explain what happens in inline comments.\n\nconst VideoJsWrapper = forwardRef<\n VideoJsPlayer,\n {\n children: React.ReactNode;\n videoJsOptions: VideoJsPlayerOptions;\n onReady: () => void;\n onDispose: () => void;\n classNames: string;\n }\n>(\n (\n { children, videoJsOptions, onReady, onDispose, classNames, ...props },\n playerRef\n ) => {\n const player = playerRef as MutableRefObject<VideoJsPlayer | null>;\n // video.js sometimes mutates the provided options object.\n // We clone it to avoid mutation issues.\n const videoJsOptionsCloned = cloneDeep(videoJsOptions);\n const videoNode = useRef<HTMLVideoElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useLayoutEffect(() => {\n if (!videoNode.current?.parentNode) return;\n\n // Once we initialize the player, videojs will start mutating the DOM.\n // We need a snapshot of the state just before, so we know what state\n // to reset the DOM to.\n const originalVideoNodeParent =\n videoNode.current.parentNode.cloneNode(true);\n\n if (!player.current) {\n player.current = videojs(videoNode.current, videoJsOptionsCloned);\n player.current.ready(() => {\n onReady();\n });\n }\n\n return (): void => {\n // Whenever something changes in the options object, we\n // want to reinitialize video.js, and destroy the old player by calling `player.current.dispose()`\n\n if (player.current) {\n player.current.dispose();\n\n // Unfortunately, video.js heavily mutates the DOM in a way that React doesn't\n // like, so we need to readd the removed DOM elements directly after dispose.\n // More concretely, the node marked with `data-vjs-player` will be removed from the\n // DOM. We are readding the cloned original video node parent as it was when React first rendered it,\n // so it is once again synchronized with React.\n if (\n containerRef.current &&\n videoNode.current?.parentNode &&\n !containerRef.current.contains(videoNode.current.parentNode)\n ) {\n containerRef.current.appendChild(originalVideoNodeParent);\n videoNode.current =\n originalVideoNodeParent.firstChild as HTMLVideoElement;\n }\n\n player.current = null;\n onDispose();\n }\n };\n\n // We'll use the serialized videoJsOptions object as a dependency object\n }, [useDeepCompareMemoize(videoJsOptions)]);\n\n return (\n // TODO: can we get by withour introducing an extra div?\n <div ref={containerRef}>\n <div data-vjs-player>\n <video\n ref={videoNode}\n className={`video-js ${classNames}`}\n {...props}\n >\n {children}\n </video>\n </div>\n </div>\n );\n }\n);\n\nVideoJsWrapper.displayName = \"VideoJsWrapper\";\n\ntype VideoProps = {\n children?: React.ReactNode;\n} & Partial<HTMLProps<HTMLVideoElement>>;\n\ntype VideoType = (props: VideoProps) => JSX.Element;\n\nexport const useVideoJS = (\n videoJsOptions: VideoJsPlayerOptions,\n classNames = \"\"\n): {\n Video: VideoType;\n ready: boolean;\n player: VideoJsPlayer | null;\n} => {\n const [ready, setReady] = useState(false);\n\n // player will contain the video.js player object, once it is ready.\n const player = useRef<VideoJsPlayer>(null);\n const Video = useCallback(\n ({ children, ...props }: VideoProps) => (\n <VideoJsWrapper\n videoJsOptions={videoJsOptions}\n classNames={classNames}\n onReady={(): void => setReady(true)}\n onDispose={(): void => setReady(false)}\n {...props}\n ref={player}\n >\n {children}\n </VideoJsWrapper>\n ),\n [useDeepCompareMemoize(videoJsOptions), classNames]\n );\n\n return { Video, ready, player: player.current };\n};\n"],"names":[],"mappings":";;;;AAeA,+BAAkC,OAAa;AACvC,QAAA,MAAM,MAAM,OAAU,KAAK;AAC3B,QAAA,YAAY,MAAM,OAAe,CAAC;AAExC,MAAI,CAAC,OAAO,OAAO,I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QAAM,CAAC,OAAO,YAAY,SAAS,KAAK;AAGlC,QAAA,SAAS,OAAsB,IAAI;AACzC,QAAM,QAAQ,YACZ,CAAC,EAAE,aAAa,YACb,sBAAA,cAAA,gBAAA;AAAA,IACC;AAAA,IACA;AAAA,IACA,SAAS,MAAY,SAAS,IAAI;AAAA,IAClC,WAAW,MAAY,SAAS,KAAK;AAAA,IACpC,GAAG;AAAA,IACJ,KAAK;AAAA,EAAA,GAEJ,QACH,GAEF,CAAC,sBAAsB,cAAc,GAAG,UAAU,CACpD;AAEA,SAAO,EAAE,OAAO,OAAO,QAAQ,OAAO,QAAQ;AAChD;"}
1
+ {"version":3,"file":"react-hook-videojs.es.js","sources":["../../../node_modules/.pnpm/react@19.2.4/node_modules/react/cjs/react-jsx-runtime.production.js","../../../node_modules/.pnpm/react@19.2.4/node_modules/react/cjs/react-jsx-runtime.development.js","../../../node_modules/.pnpm/react@19.2.4/node_modules/react/jsx-runtime.js","../src/deepClone.ts","../src/index.tsx"],"sourcesContent":["/**\n * @license React\n * react-jsx-runtime.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\");\nfunction jsxProd(type, config, maybeKey) {\n var key = null;\n void 0 !== maybeKey && (key = \"\" + maybeKey);\n void 0 !== config.key && (key = \"\" + config.key);\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n config = maybeKey.ref;\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n ref: void 0 !== config ? config : null,\n props: maybeKey\n };\n}\nexports.Fragment = REACT_FRAGMENT_TYPE;\nexports.jsx = jsxProd;\nexports.jsxs = jsxProd;\n","/**\n * @license React\n * react-jsx-runtime.development.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\n\"production\" !== process.env.NODE_ENV &&\n (function () {\n function getComponentNameFromType(type) {\n if (null == type) return null;\n if (\"function\" === typeof type)\n return type.$$typeof === REACT_CLIENT_REFERENCE\n ? null\n : type.displayName || type.name || null;\n if (\"string\" === typeof type) return type;\n switch (type) {\n case REACT_FRAGMENT_TYPE:\n return \"Fragment\";\n case REACT_PROFILER_TYPE:\n return \"Profiler\";\n case REACT_STRICT_MODE_TYPE:\n return \"StrictMode\";\n case REACT_SUSPENSE_TYPE:\n return \"Suspense\";\n case REACT_SUSPENSE_LIST_TYPE:\n return \"SuspenseList\";\n case REACT_ACTIVITY_TYPE:\n return \"Activity\";\n }\n if (\"object\" === typeof type)\n switch (\n (\"number\" === typeof type.tag &&\n console.error(\n \"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.\"\n ),\n type.$$typeof)\n ) {\n case REACT_PORTAL_TYPE:\n return \"Portal\";\n case REACT_CONTEXT_TYPE:\n return type.displayName || \"Context\";\n case REACT_CONSUMER_TYPE:\n return (type._context.displayName || \"Context\") + \".Consumer\";\n case REACT_FORWARD_REF_TYPE:\n var innerType = type.render;\n type = type.displayName;\n type ||\n ((type = innerType.displayName || innerType.name || \"\"),\n (type = \"\" !== type ? \"ForwardRef(\" + type + \")\" : \"ForwardRef\"));\n return type;\n case REACT_MEMO_TYPE:\n return (\n (innerType = type.displayName || null),\n null !== innerType\n ? innerType\n : getComponentNameFromType(type.type) || \"Memo\"\n );\n case REACT_LAZY_TYPE:\n innerType = type._payload;\n type = type._init;\n try {\n return getComponentNameFromType(type(innerType));\n } catch (x) {}\n }\n return null;\n }\n function testStringCoercion(value) {\n return \"\" + value;\n }\n function checkKeyStringCoercion(value) {\n try {\n testStringCoercion(value);\n var JSCompiler_inline_result = !1;\n } catch (e) {\n JSCompiler_inline_result = !0;\n }\n if (JSCompiler_inline_result) {\n JSCompiler_inline_result = console;\n var JSCompiler_temp_const = JSCompiler_inline_result.error;\n var JSCompiler_inline_result$jscomp$0 =\n (\"function\" === typeof Symbol &&\n Symbol.toStringTag &&\n value[Symbol.toStringTag]) ||\n value.constructor.name ||\n \"Object\";\n JSCompiler_temp_const.call(\n JSCompiler_inline_result,\n \"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.\",\n JSCompiler_inline_result$jscomp$0\n );\n return testStringCoercion(value);\n }\n }\n function getTaskName(type) {\n if (type === REACT_FRAGMENT_TYPE) return \"<>\";\n if (\n \"object\" === typeof type &&\n null !== type &&\n type.$$typeof === REACT_LAZY_TYPE\n )\n return \"<...>\";\n try {\n var name = getComponentNameFromType(type);\n return name ? \"<\" + name + \">\" : \"<...>\";\n } catch (x) {\n return \"<...>\";\n }\n }\n function getOwner() {\n var dispatcher = ReactSharedInternals.A;\n return null === dispatcher ? null : dispatcher.getOwner();\n }\n function UnknownOwner() {\n return Error(\"react-stack-top-frame\");\n }\n function hasValidKey(config) {\n if (hasOwnProperty.call(config, \"key\")) {\n var getter = Object.getOwnPropertyDescriptor(config, \"key\").get;\n if (getter && getter.isReactWarning) return !1;\n }\n return void 0 !== config.key;\n }\n function defineKeyPropWarningGetter(props, displayName) {\n function warnAboutAccessingKey() {\n specialPropKeyWarningShown ||\n ((specialPropKeyWarningShown = !0),\n console.error(\n \"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)\",\n displayName\n ));\n }\n warnAboutAccessingKey.isReactWarning = !0;\n Object.defineProperty(props, \"key\", {\n get: warnAboutAccessingKey,\n configurable: !0\n });\n }\n function elementRefGetterWithDeprecationWarning() {\n var componentName = getComponentNameFromType(this.type);\n didWarnAboutElementRef[componentName] ||\n ((didWarnAboutElementRef[componentName] = !0),\n console.error(\n \"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.\"\n ));\n componentName = this.props.ref;\n return void 0 !== componentName ? componentName : null;\n }\n function ReactElement(type, key, props, owner, debugStack, debugTask) {\n var refProp = props.ref;\n type = {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key,\n props: props,\n _owner: owner\n };\n null !== (void 0 !== refProp ? refProp : null)\n ? Object.defineProperty(type, \"ref\", {\n enumerable: !1,\n get: elementRefGetterWithDeprecationWarning\n })\n : Object.defineProperty(type, \"ref\", { enumerable: !1, value: null });\n type._store = {};\n Object.defineProperty(type._store, \"validated\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: 0\n });\n Object.defineProperty(type, \"_debugInfo\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: null\n });\n Object.defineProperty(type, \"_debugStack\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: debugStack\n });\n Object.defineProperty(type, \"_debugTask\", {\n configurable: !1,\n enumerable: !1,\n writable: !0,\n value: debugTask\n });\n Object.freeze && (Object.freeze(type.props), Object.freeze(type));\n return type;\n }\n function jsxDEVImpl(\n type,\n config,\n maybeKey,\n isStaticChildren,\n debugStack,\n debugTask\n ) {\n var children = config.children;\n if (void 0 !== children)\n if (isStaticChildren)\n if (isArrayImpl(children)) {\n for (\n isStaticChildren = 0;\n isStaticChildren < children.length;\n isStaticChildren++\n )\n validateChildKeys(children[isStaticChildren]);\n Object.freeze && Object.freeze(children);\n } else\n console.error(\n \"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.\"\n );\n else validateChildKeys(children);\n if (hasOwnProperty.call(config, \"key\")) {\n children = getComponentNameFromType(type);\n var keys = Object.keys(config).filter(function (k) {\n return \"key\" !== k;\n });\n isStaticChildren =\n 0 < keys.length\n ? \"{key: someKey, \" + keys.join(\": ..., \") + \": ...}\"\n : \"{key: someKey}\";\n didWarnAboutKeySpread[children + isStaticChildren] ||\n ((keys =\n 0 < keys.length ? \"{\" + keys.join(\": ..., \") + \": ...}\" : \"{}\"),\n console.error(\n 'A props object containing a \"key\" prop is being spread into JSX:\\n let props = %s;\\n <%s {...props} />\\nReact keys must be passed directly to JSX without using spread:\\n let props = %s;\\n <%s key={someKey} {...props} />',\n isStaticChildren,\n children,\n keys,\n children\n ),\n (didWarnAboutKeySpread[children + isStaticChildren] = !0));\n }\n children = null;\n void 0 !== maybeKey &&\n (checkKeyStringCoercion(maybeKey), (children = \"\" + maybeKey));\n hasValidKey(config) &&\n (checkKeyStringCoercion(config.key), (children = \"\" + config.key));\n if (\"key\" in config) {\n maybeKey = {};\n for (var propName in config)\n \"key\" !== propName && (maybeKey[propName] = config[propName]);\n } else maybeKey = config;\n children &&\n defineKeyPropWarningGetter(\n maybeKey,\n \"function\" === typeof type\n ? type.displayName || type.name || \"Unknown\"\n : type\n );\n return ReactElement(\n type,\n children,\n maybeKey,\n getOwner(),\n debugStack,\n debugTask\n );\n }\n function validateChildKeys(node) {\n isValidElement(node)\n ? node._store && (node._store.validated = 1)\n : \"object\" === typeof node &&\n null !== node &&\n node.$$typeof === REACT_LAZY_TYPE &&\n (\"fulfilled\" === node._payload.status\n ? isValidElement(node._payload.value) &&\n node._payload.value._store &&\n (node._payload.value._store.validated = 1)\n : node._store && (node._store.validated = 1));\n }\n function isValidElement(object) {\n return (\n \"object\" === typeof object &&\n null !== object &&\n object.$$typeof === REACT_ELEMENT_TYPE\n );\n }\n var React = require(\"react\"),\n REACT_ELEMENT_TYPE = Symbol.for(\"react.transitional.element\"),\n REACT_PORTAL_TYPE = Symbol.for(\"react.portal\"),\n REACT_FRAGMENT_TYPE = Symbol.for(\"react.fragment\"),\n REACT_STRICT_MODE_TYPE = Symbol.for(\"react.strict_mode\"),\n REACT_PROFILER_TYPE = Symbol.for(\"react.profiler\"),\n REACT_CONSUMER_TYPE = Symbol.for(\"react.consumer\"),\n REACT_CONTEXT_TYPE = Symbol.for(\"react.context\"),\n REACT_FORWARD_REF_TYPE = Symbol.for(\"react.forward_ref\"),\n REACT_SUSPENSE_TYPE = Symbol.for(\"react.suspense\"),\n REACT_SUSPENSE_LIST_TYPE = Symbol.for(\"react.suspense_list\"),\n REACT_MEMO_TYPE = Symbol.for(\"react.memo\"),\n REACT_LAZY_TYPE = Symbol.for(\"react.lazy\"),\n REACT_ACTIVITY_TYPE = Symbol.for(\"react.activity\"),\n REACT_CLIENT_REFERENCE = Symbol.for(\"react.client.reference\"),\n ReactSharedInternals =\n React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,\n hasOwnProperty = Object.prototype.hasOwnProperty,\n isArrayImpl = Array.isArray,\n createTask = console.createTask\n ? console.createTask\n : function () {\n return null;\n };\n React = {\n react_stack_bottom_frame: function (callStackForError) {\n return callStackForError();\n }\n };\n var specialPropKeyWarningShown;\n var didWarnAboutElementRef = {};\n var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(\n React,\n UnknownOwner\n )();\n var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));\n var didWarnAboutKeySpread = {};\n exports.Fragment = REACT_FRAGMENT_TYPE;\n exports.jsx = function (type, config, maybeKey) {\n var trackActualOwner =\n 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;\n return jsxDEVImpl(\n type,\n config,\n maybeKey,\n !1,\n trackActualOwner\n ? Error(\"react-stack-top-frame\")\n : unknownOwnerDebugStack,\n trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask\n );\n };\n exports.jsxs = function (type, config, maybeKey) {\n var trackActualOwner =\n 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;\n return jsxDEVImpl(\n type,\n config,\n maybeKey,\n !0,\n trackActualOwner\n ? Error(\"react-stack-top-frame\")\n : unknownOwnerDebugStack,\n trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask\n );\n };\n })();\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('./cjs/react-jsx-runtime.production.js');\n} else {\n module.exports = require('./cjs/react-jsx-runtime.development.js');\n}\n","const cloneWithDescriptor = (\n descriptor: PropertyDescriptor,\n cloneValue: (input: unknown) => unknown,\n): PropertyDescriptor => {\n if (!(\"value\" in descriptor)) {\n return descriptor;\n }\n\n return {\n ...descriptor,\n value: cloneValue(descriptor.value),\n };\n};\n\nconst deepCloneInternal = <T>(value: T, seen: WeakMap<object, unknown>): T => {\n if (value === null || typeof value !== \"object\") {\n return value;\n }\n\n if (typeof Node !== \"undefined\" && value instanceof Node) {\n return value;\n }\n\n const cached = seen.get(value as object);\n if (cached) {\n return cached as T;\n }\n\n if (value instanceof Date) {\n const clonedDate = new Date(value.getTime());\n seen.set(value, clonedDate);\n return clonedDate as T;\n }\n\n if (value instanceof RegExp) {\n const clonedRegExp = new RegExp(value.source, value.flags);\n clonedRegExp.lastIndex = value.lastIndex;\n seen.set(value, clonedRegExp);\n return clonedRegExp as T;\n }\n\n if (value instanceof ArrayBuffer) {\n const clonedBuffer = value.slice(0);\n seen.set(value, clonedBuffer);\n return clonedBuffer as T;\n }\n\n if (ArrayBuffer.isView(value)) {\n if (value instanceof DataView) {\n const clonedBuffer = deepCloneInternal(value.buffer, seen);\n const clonedDataView = new DataView(\n clonedBuffer,\n value.byteOffset,\n value.byteLength,\n );\n seen.set(value, clonedDataView);\n return clonedDataView as T;\n }\n\n const TypedArrayConstructor = value.constructor as {\n new (\n buffer: ArrayBufferLike,\n byteOffset?: number,\n length?: number,\n ): unknown;\n BYTES_PER_ELEMENT: number;\n };\n const clonedBuffer = deepCloneInternal(value.buffer, seen);\n const length = value.byteLength / TypedArrayConstructor.BYTES_PER_ELEMENT;\n const clonedTypedArray = new TypedArrayConstructor(\n clonedBuffer,\n value.byteOffset,\n length,\n );\n seen.set(value, clonedTypedArray);\n return clonedTypedArray as T;\n }\n\n if (value instanceof Map) {\n const clonedMap = new Map<unknown, unknown>();\n seen.set(value, clonedMap);\n\n for (const [key, mapValue] of value.entries()) {\n clonedMap.set(\n deepCloneInternal(key, seen),\n deepCloneInternal(mapValue, seen),\n );\n }\n\n return clonedMap as T;\n }\n\n if (value instanceof Set) {\n const clonedSet = new Set<unknown>();\n seen.set(value, clonedSet);\n\n for (const setValue of value.values()) {\n clonedSet.add(deepCloneInternal(setValue, seen));\n }\n\n return clonedSet as T;\n }\n\n const clonedObject = Array.isArray(value)\n ? (() => {\n const clonedArray: unknown[] = [];\n clonedArray.length = (value as unknown[]).length;\n return clonedArray;\n })()\n : Object.create(Object.getPrototypeOf(value));\n\n seen.set(value as object, clonedObject);\n\n for (const key of Reflect.ownKeys(value as object)) {\n if (Array.isArray(value) && key === \"length\") {\n continue;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(value as object, key);\n if (!descriptor) {\n continue;\n }\n\n Object.defineProperty(\n clonedObject,\n key,\n cloneWithDescriptor(descriptor, (input) =>\n deepCloneInternal(input, seen),\n ),\n );\n }\n\n return clonedObject as T;\n};\n\nconst deepClone = <T>(value: T): T => deepCloneInternal(value, new WeakMap());\n\nexport default deepClone;\n","import { useRef, useState, useEffect, useCallback, useMemo } from \"react\";\nimport type { ComponentPropsWithRef, MutableRefObject, Ref } from \"react\";\nimport videojsModule from \"video.js\";\nimport deepClone from \"./deepClone.js\";\n\ntype VideoJsModule = (typeof import(\"video.js\"))[\"default\"];\ntype VideoJsPlayer = ReturnType<VideoJsModule>;\ntype VideoJsPlayerOptions = Parameters<VideoJsModule>[1];\n\nconst videojs = videojsModule as unknown as VideoJsModule;\n\nconst setVideoNodeRef = (\n videoNode: MutableRefObject<HTMLVideoElement | null>,\n videoRef: Ref<HTMLVideoElement> | undefined,\n value: HTMLVideoElement | null,\n): void => {\n videoNode.current = value;\n\n if (!videoRef) {\n return;\n }\n\n if (typeof videoRef === \"function\") {\n videoRef(value);\n return;\n }\n\n videoRef.current = value;\n};\n\nconst getVideoClassName = (classNames: string, className?: string): string =>\n [\"video-js\", classNames, className].filter(Boolean).join(\" \");\n\nconst restoreDisposedVideoNode = (\n containerNode: HTMLDivElement,\n originalVideoNode: HTMLVideoElement | null,\n videoNode: MutableRefObject<HTMLVideoElement | null>,\n videoRef?: Ref<HTMLVideoElement>,\n): void => {\n if (originalVideoNode && !containerNode.querySelector(\"video\")) {\n containerNode.appendChild(originalVideoNode);\n setVideoNodeRef(\n videoNode,\n videoRef,\n containerNode.querySelector(\"video\") as HTMLVideoElement | null,\n );\n }\n};\n\nconst shouldSkipReadyCallback = (\n disposed: boolean,\n playerRef: MutableRefObject<VideoJsPlayer | null>,\n initializedPlayer: VideoJsPlayer,\n): boolean => disposed || playerRef.current !== initializedPlayer;\n\nconst getCurrentVideoNode = (\n containerNode: HTMLDivElement,\n videoNode: MutableRefObject<HTMLVideoElement | null>,\n): HTMLVideoElement | null => {\n const connectedVideoNode = containerNode.querySelector(\n \"video\",\n ) as HTMLVideoElement | null;\n\n return videoNode.current?.isConnected === true\n ? videoNode.current\n : connectedVideoNode;\n};\n\nconst callOnReadyForCurrentPlayer = (\n disposed: boolean,\n playerRef: MutableRefObject<VideoJsPlayer | null>,\n initializedPlayer: VideoJsPlayer,\n onReady: (player: VideoJsPlayer) => void,\n): void => {\n if (shouldSkipReadyCallback(disposed, playerRef, initializedPlayer)) {\n return;\n }\n\n onReady(initializedPlayer);\n};\n\nexport const __private__ = {\n setVideoNodeRef,\n getVideoClassName,\n restoreDisposedVideoNode,\n shouldSkipReadyCallback,\n callOnReadyForCurrentPlayer,\n getCurrentVideoNode,\n};\n\n// Integrating React and video.js is a bit tricky, especially when supporting\n// React 19 strict mode. We'll do our best to explain what happens in inline comments.\n\ntype VideoElementProps = ComponentPropsWithRef<\"video\">;\n\ntype VideoJsWrapperProps = {\n videoJsOptions: VideoJsPlayerOptions;\n onReady: (player: VideoJsPlayer) => void;\n onDispose: () => void;\n classNames: string;\n playerRef: MutableRefObject<VideoJsPlayer | null>;\n} & VideoElementProps;\n\nconst VideoJsWrapper = ({\n children,\n videoJsOptions,\n onReady,\n onDispose,\n classNames,\n playerRef,\n ref: videoRef,\n className,\n ...props\n}: VideoJsWrapperProps): React.JSX.Element => {\n const videoJsOptionsCloned = useMemo(\n () => deepClone(videoJsOptions),\n [videoJsOptions],\n );\n const videoNode = useRef<HTMLVideoElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n const containerNode = containerRef.current as HTMLDivElement;\n\n const currentVideoNode = getCurrentVideoNode(containerNode, videoNode);\n\n if (!currentVideoNode || !currentVideoNode.isConnected) return;\n\n if (videoNode.current !== currentVideoNode) {\n setVideoNodeRef(videoNode, videoRef, currentVideoNode);\n }\n\n const originalVideoNode = currentVideoNode.cloneNode(\n true,\n ) as HTMLVideoElement;\n\n let disposed = false;\n\n const initializedPlayer = videojs(currentVideoNode, videoJsOptionsCloned);\n playerRef.current = initializedPlayer;\n initializedPlayer.ready(() => {\n callOnReadyForCurrentPlayer(\n disposed,\n playerRef,\n initializedPlayer,\n onReady,\n );\n });\n\n return (): void => {\n // Whenever something changes in the options object, we\n // want to reinitialize video.js, and destroy the old player by calling `player.current.dispose()`\n\n disposed = true;\n initializedPlayer.dispose();\n playerRef.current = null;\n\n restoreDisposedVideoNode(\n containerNode,\n originalVideoNode,\n videoNode,\n videoRef,\n );\n\n onDispose();\n };\n\n // Reinitialize only when deep-compared options or lifecycle handlers change.\n }, [videoJsOptionsCloned, onReady, onDispose, playerRef, videoRef]);\n\n return (\n <div ref={containerRef}>\n <video\n ref={(value) => {\n setVideoNodeRef(videoNode, videoRef, value);\n }}\n className={getVideoClassName(classNames, className)}\n {...props}\n >\n {children}\n </video>\n </div>\n );\n};\n\n/** All standard `<video>` element attributes and the `ref` prop are accepted. */\nexport type VideoProps = VideoElementProps;\n\n/**\n * The `Video` component returned by {@link useVideoJS}.\n *\n * Renders a Video.js-managed `<video>` element. Accepts any prop that a\n * native `<video>` element accepts (including `ref`, `className`, `muted`,\n * `autoPlay`, etc.) as well as child elements such as `<track>` nodes.\n *\n * @example\n * ```tsx\n * const { Video } = useVideoJS(options);\n * return (\n * <Video className=\"my-player\" muted>\n * <track kind=\"captions\" src=\"/captions.vtt\" srcLang=\"en\" default />\n * </Video>\n * );\n * ```\n */\nexport type VideoComponent = (props: VideoProps) => React.JSX.Element;\n\n/**\n * Integrates Video.js with React.\n *\n * Initializes a Video.js player when the returned `Video` component mounts,\n * disposes it on unmount or when `videoJsOptions` changes, and reinitializes\n * with the new configuration — all while handling React 19 Strict Mode's\n * double-invoke lifecycle correctly.\n *\n * @param videoJsOptions - Video.js player options. **Must be memoized** (e.g.\n * with `React.useMemo`) so the player only reinitializes when options values\n * actually change, not on every render.\n * @param classNames - Optional CSS class name(s) appended to the `<video>`\n * node in addition to the required `\"video-js\"` class.\n * @returns An object with three fields:\n * - `Video` — React component to render in JSX. Accepts all `<video>` props\n * and children (e.g. `<track>` elements).\n * - `ready` — `true` once the player has fired its `\"ready\"` event.\n * - `player` — The `VideoJsPlayer` instance when ready, `null` otherwise.\n * Use this to call Video.js API methods imperatively (e.g. in a\n * `useEffect` that depends on `player`).\n *\n * @example\n * ```tsx\n * import React, { useMemo, useEffect } from \"react\";\n * import \"video.js/dist/video-js.css\";\n * import { useVideoJS } from \"react-hook-videojs\";\n *\n * const MyPlayer = ({ src }: { src: string }) => {\n * const options = useMemo(() => ({ sources: [{ src }] }), [src]);\n * const { Video, ready, player } = useVideoJS(options);\n *\n * // Attach event listeners imperatively once the player is ready\n * useEffect(() => {\n * if (!player) return;\n * const onPlay = () => console.log(\"playing\");\n * player.on(\"play\", onPlay);\n * return () => { player.off(\"play\", onPlay); };\n * }, [player]);\n *\n * return <Video />;\n * };\n * ```\n */\nexport const useVideoJS = (\n videoJsOptions: VideoJsPlayerOptions,\n classNames = \"\",\n): {\n Video: VideoComponent;\n ready: boolean;\n player: VideoJsPlayer | null;\n} => {\n const [ready, setReady] = useState(false);\n const [player, setPlayer] = useState<VideoJsPlayer | null>(null);\n\n // player will contain the video.js player object, once it is ready.\n const playerRef = useRef<VideoJsPlayer | null>(null);\n const onReady = useCallback((playerInstance: VideoJsPlayer): void => {\n setReady(true);\n setPlayer(playerInstance);\n }, []);\n const onDispose = useCallback((): void => {\n setReady(false);\n setPlayer(null);\n }, []);\n const Video = useCallback(\n ({ children, ...props }: VideoProps) => (\n <VideoJsWrapper\n videoJsOptions={videoJsOptions}\n classNames={classNames}\n onReady={onReady}\n onDispose={onDispose}\n playerRef={playerRef}\n {...props}\n >\n {children}\n </VideoJsWrapper>\n ),\n [videoJsOptions, classNames, onReady, onDispose],\n );\n\n return { Video, ready, player };\n};\n"],"names":["jsxRuntimeModule","require$$0","require$$1","clonedBuffer","jsx"],"mappings":";;;;;;;;AAWA,MAAI,qBAAqB,uBAAO,IAAI,4BAA4B,GAC9D,sBAAsB,uBAAO,IAAI,gBAAgB;AACnD,WAAS,QAAQ,MAAM,QAAQ,UAAU;AACvC,QAAI,MAAM;AACV,eAAW,aAAa,MAAM,KAAK;AACnC,eAAW,OAAO,QAAQ,MAAM,KAAK,OAAO;AAC5C,QAAI,SAAS,QAAQ;AACnB,iBAAW,CAAA;AACX,eAAS,YAAY;AACnB,kBAAU,aAAa,SAAS,QAAQ,IAAI,OAAO,QAAQ;AAAA,IACjE,MAAS,YAAW;AAClB,aAAS,SAAS;AAClB,WAAO;AAAA,MACL,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA,KAAK,WAAW,SAAS,SAAS;AAAA,MAClC,OAAO;AAAA;EAEX;AACA,6BAAA,WAAmB;AACnB,6BAAA,MAAc;AACd,6BAAA,OAAe;;;;;;;;ACtBf,mBAAiB,QAAQ,IAAI,aAC1B,WAAY;AACX,aAAS,yBAAyB,MAAM;AACtC,UAAI,QAAQ,KAAM,QAAO;AACzB,UAAI,eAAe,OAAO;AACxB,eAAO,KAAK,aAAa,yBACrB,OACA,KAAK,eAAe,KAAK,QAAQ;AACvC,UAAI,aAAa,OAAO,KAAM,QAAO;AACrC,cAAQ,MAAI;AAAA,QACV,KAAK;AACH,iBAAO;AAAA,QACT,KAAK;AACH,iBAAO;AAAA,QACT,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ACxC,QAAM,CAAC,QAAQ,SAAS,IAAI,SAA+B,IAAI;AAG/D,QAAM,YAAY,OAA6B,IAAI;AACnD,QAAM,UAAU,YAAY,CAAC,mBAAwC;AACnE,aAAS,IAAI;AACb,cAAU,cAAc;AAAA,EAC1B,GAAG,CAAA,CAAE;AACL,QAAM,YAAY,YAAY,MAAY;AACxC,aAAS,KAAK;AACd,cAAU,IAAI;AAAA,EAChB,GAAG,CAAA,CAAE;AACL,QAAM,QAAQ;AAAA,IACZ,CAAC,EAAE,UAAU,GAAG,YACdA,kCAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACC,GAAG;AAAA,QAEH;AAAA,MAAA;AAAA,IAAA;AAAA,IAGL,CAAC,gBAAgB,YAAY,SAAS,SAAS;AAAA,EAAA;AAGjD,SAAO,EAAE,OAAO,OAAO,OAAA;AACzB;","x_google_ignoreList":[0,1,2]}
package/package.json CHANGED
@@ -1,58 +1,52 @@
1
1
  {
2
2
  "name": "react-hook-videojs",
3
- "version": "3.0.2",
3
+ "type": "module",
4
+ "version": "4.0.0-beta.1",
4
5
  "description": "A simple react hook to easily integrate video.js with React",
5
6
  "author": "jimmycallin",
6
7
  "license": "MIT",
7
8
  "repository": "jimmycallin/react-hook-videojs",
8
9
  "types": "./dist/index.d.ts",
9
- "main": "dist/react-hook-videojs.umd.js",
10
- "module": "dist/react-hook-videojs.es.js",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/react-hook-videojs.es.js"
14
+ }
15
+ },
11
16
  "source": "src/index.tsx",
12
17
  "engineStrict": false,
13
18
  "engines": {
14
19
  "node": ">=16"
15
20
  },
16
- "scripts": {
17
- "clean": "rimraf dist .tmp",
18
- "build": "vite build && tsc --project tsconfig.types.json",
19
- "test": "npm run test:vitest",
20
- "test:vitest": "vitest run",
21
- "format": "prettier --write .",
22
- "prepare": "npm run clean && npm run build",
23
- "prepublishOnly": "npm run test",
24
- "dev": "vite build --watch"
25
- },
26
21
  "peerDependencies": {
27
- "react": ">=16.8.0 < 19",
28
- "react-dom": ">=16.8.0 < 19",
29
- "video.js": "^7.0.0"
22
+ "react": ">=19 < 20",
23
+ "react-dom": ">=19 < 20",
24
+ "video.js": ">=7 <9"
30
25
  },
31
26
  "devDependencies": {
32
- "@testing-library/react": "^13.3.0",
33
- "@types/lodash.clonedeep": "^4.5.7",
34
- "@types/video.js": "^7.3.42",
35
- "@typescript-eslint/eslint-plugin": "^5.32.0",
36
- "@typescript-eslint/parser": "^5.31.0",
37
- "@vitejs/plugin-react-refresh": "^1.3.6",
38
- "eslint": "^8.20.0",
39
- "eslint-config-prettier": "^8.5.0",
40
- "eslint-plugin-react": "^7.30.1",
41
- "jsdom": "^20.0.0",
42
- "prettier": "^2.7.1",
43
- "react": "^18.2.0",
44
- "react-dom": "^18.2.0",
45
- "rimraf": "^3.0.2",
46
- "typescript": "^4.7.4",
47
- "video.js": "^7.20.1",
48
- "vite": "^3.0.4",
49
- "vitest": "^0.20.2"
27
+ "@testing-library/react": "^16.3.2",
28
+ "@types/react": "^19",
29
+ "@types/react-dom": "^19",
30
+ "@types/video.js": "^7.3.51",
31
+ "@vitejs/plugin-react": "^5.1.4",
32
+ "jsdom": "^28.1.0",
33
+ "react": "^19.2.4",
34
+ "react-dom": "^19.2.4",
35
+ "rimraf": "^6.1.3",
36
+ "typescript": "^5.9.3",
37
+ "video.js": "^8.23.7",
38
+ "vite": "^7.3.1",
39
+ "vitest": "^4.0.18"
50
40
  },
51
41
  "files": [
52
- "dist"
42
+ "dist",
43
+ "README.md",
44
+ "LICENSE"
53
45
  ],
54
- "dependencies": {
55
- "dequal": "^2.0.3",
56
- "lodash.clonedeep": "^4.5.0"
46
+ "scripts": {
47
+ "clean": "rimraf dist .tmp",
48
+ "build": "vite build && tsc --project tsconfig.types.json",
49
+ "test": "pnpm --workspace-root run test:unit",
50
+ "dev": "vite build --watch"
57
51
  }
58
- }
52
+ }
@@ -1,74 +0,0 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("video.js"), require("lodash.clonedeep"), require("dequal")) : typeof define === "function" && define.amd ? define(["exports", "react", "video.js", "lodash.clonedeep", "dequal"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global["react-hook-videojs"] = {}, global.react, global.video.js, global.lodash.clonedeep, global.dequal));
3
- })(this, function(exports2, React, videojs, cloneDeep, dequal) {
4
- "use strict";
5
- const _interopDefaultLegacy = (e) => e && typeof e === "object" && "default" in e ? e : { default: e };
6
- const React__default = /* @__PURE__ */ _interopDefaultLegacy(React);
7
- const videojs__default = /* @__PURE__ */ _interopDefaultLegacy(videojs);
8
- const cloneDeep__default = /* @__PURE__ */ _interopDefaultLegacy(cloneDeep);
9
- function useDeepCompareMemoize(value) {
10
- const ref = React__default.default.useRef(value);
11
- const signalRef = React__default.default.useRef(0);
12
- if (!dequal.dequal(value, ref.current)) {
13
- ref.current = value;
14
- signalRef.current += 1;
15
- }
16
- return React__default.default.useMemo(() => ref.current, [signalRef.current]);
17
- }
18
- const VideoJsWrapper = React.forwardRef(({ children, videoJsOptions, onReady, onDispose, classNames, ...props }, playerRef) => {
19
- const player = playerRef;
20
- const videoJsOptionsCloned = cloneDeep__default.default(videoJsOptions);
21
- const videoNode = React.useRef(null);
22
- const containerRef = React.useRef(null);
23
- React.useLayoutEffect(() => {
24
- var _a;
25
- if (!((_a = videoNode.current) == null ? void 0 : _a.parentNode))
26
- return;
27
- const originalVideoNodeParent = videoNode.current.parentNode.cloneNode(true);
28
- if (!player.current) {
29
- player.current = videojs__default.default(videoNode.current, videoJsOptionsCloned);
30
- player.current.ready(() => {
31
- onReady();
32
- });
33
- }
34
- return () => {
35
- var _a2;
36
- if (player.current) {
37
- player.current.dispose();
38
- if (containerRef.current && ((_a2 = videoNode.current) == null ? void 0 : _a2.parentNode) && !containerRef.current.contains(videoNode.current.parentNode)) {
39
- containerRef.current.appendChild(originalVideoNodeParent);
40
- videoNode.current = originalVideoNodeParent.firstChild;
41
- }
42
- player.current = null;
43
- onDispose();
44
- }
45
- };
46
- }, [useDeepCompareMemoize(videoJsOptions)]);
47
- return /* @__PURE__ */ React__default.default.createElement("div", {
48
- ref: containerRef
49
- }, /* @__PURE__ */ React__default.default.createElement("div", {
50
- "data-vjs-player": true
51
- }, /* @__PURE__ */ React__default.default.createElement("video", {
52
- ref: videoNode,
53
- className: `video-js ${classNames}`,
54
- ...props
55
- }, children)));
56
- });
57
- VideoJsWrapper.displayName = "VideoJsWrapper";
58
- const useVideoJS = (videoJsOptions, classNames = "") => {
59
- const [ready, setReady] = React.useState(false);
60
- const player = React.useRef(null);
61
- const Video = React.useCallback(({ children, ...props }) => /* @__PURE__ */ React__default.default.createElement(VideoJsWrapper, {
62
- videoJsOptions,
63
- classNames,
64
- onReady: () => setReady(true),
65
- onDispose: () => setReady(false),
66
- ...props,
67
- ref: player
68
- }, children), [useDeepCompareMemoize(videoJsOptions), classNames]);
69
- return { Video, ready, player: player.current };
70
- };
71
- exports2.useVideoJS = useVideoJS;
72
- Object.defineProperties(exports2, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
73
- });
74
- //# sourceMappingURL=react-hook-videojs.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-hook-videojs.umd.js","sources":["../src/index.tsx"],"sourcesContent":["import React, {\n useRef,\n useState,\n useLayoutEffect,\n useCallback,\n forwardRef,\n HTMLProps,\n MutableRefObject,\n} from \"react\";\nimport videojs, { VideoJsPlayer, VideoJsPlayerOptions } from \"video.js\";\nimport cloneDeep from \"lodash.clonedeep\";\nimport { dequal } from \"dequal\";\n\n// Function copied from\n// https://github.com/kentcdodds/use-deep-compare-effect/blob/main/src/index.ts\nfunction useDeepCompareMemoize<T>(value: T): T {\n const ref = React.useRef<T>(value);\n const signalRef = React.useRef<number>(0);\n\n if (!dequal(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return React.useMemo(() => ref.current, [signalRef.current]);\n}\n\n// Integrating React and video.js is a bit tricky, especially when supporting\n// React 18 strict mode. We'll do our best to explain what happens in inline comments.\n\nconst VideoJsWrapper = forwardRef<\n VideoJsPlayer,\n {\n children: React.ReactNode;\n videoJsOptions: VideoJsPlayerOptions;\n onReady: () => void;\n onDispose: () => void;\n classNames: string;\n }\n>(\n (\n { children, videoJsOptions, onReady, onDispose, classNames, ...props },\n playerRef\n ) => {\n const player = playerRef as MutableRefObject<VideoJsPlayer | null>;\n // video.js sometimes mutates the provided options object.\n // We clone it to avoid mutation issues.\n const videoJsOptionsCloned = cloneDeep(videoJsOptions);\n const videoNode = useRef<HTMLVideoElement | null>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n useLayoutEffect(() => {\n if (!videoNode.current?.parentNode) return;\n\n // Once we initialize the player, videojs will start mutating the DOM.\n // We need a snapshot of the state just before, so we know what state\n // to reset the DOM to.\n const originalVideoNodeParent =\n videoNode.current.parentNode.cloneNode(true);\n\n if (!player.current) {\n player.current = videojs(videoNode.current, videoJsOptionsCloned);\n player.current.ready(() => {\n onReady();\n });\n }\n\n return (): void => {\n // Whenever something changes in the options object, we\n // want to reinitialize video.js, and destroy the old player by calling `player.current.dispose()`\n\n if (player.current) {\n player.current.dispose();\n\n // Unfortunately, video.js heavily mutates the DOM in a way that React doesn't\n // like, so we need to readd the removed DOM elements directly after dispose.\n // More concretely, the node marked with `data-vjs-player` will be removed from the\n // DOM. We are readding the cloned original video node parent as it was when React first rendered it,\n // so it is once again synchronized with React.\n if (\n containerRef.current &&\n videoNode.current?.parentNode &&\n !containerRef.current.contains(videoNode.current.parentNode)\n ) {\n containerRef.current.appendChild(originalVideoNodeParent);\n videoNode.current =\n originalVideoNodeParent.firstChild as HTMLVideoElement;\n }\n\n player.current = null;\n onDispose();\n }\n };\n\n // We'll use the serialized videoJsOptions object as a dependency object\n }, [useDeepCompareMemoize(videoJsOptions)]);\n\n return (\n // TODO: can we get by withour introducing an extra div?\n <div ref={containerRef}>\n <div data-vjs-player>\n <video\n ref={videoNode}\n className={`video-js ${classNames}`}\n {...props}\n >\n {children}\n </video>\n </div>\n </div>\n );\n }\n);\n\nVideoJsWrapper.displayName = \"VideoJsWrapper\";\n\ntype VideoProps = {\n children?: React.ReactNode;\n} & Partial<HTMLProps<HTMLVideoElement>>;\n\ntype VideoType = (props: VideoProps) => JSX.Element;\n\nexport const useVideoJS = (\n videoJsOptions: VideoJsPlayerOptions,\n classNames = \"\"\n): {\n Video: VideoType;\n ready: boolean;\n player: VideoJsPlayer | null;\n} => {\n const [ready, setReady] = useState(false);\n\n // player will contain the video.js player object, once it is ready.\n const player = useRef<VideoJsPlayer>(null);\n const Video = useCallback(\n ({ children, ...props }: VideoProps) => (\n <VideoJsWrapper\n videoJsOptions={videoJsOptions}\n classNames={classNames}\n onReady={(): void => setReady(true)}\n onDispose={(): void => setReady(false)}\n {...props}\n ref={player}\n >\n {children}\n </VideoJsWrapper>\n ),\n [useDeepCompareMemoize(videoJsOptions), classNames]\n );\n\n return { Video, ready, player: player.current };\n};\n"],"names":["React","dequal","forwardRef","cloneDeep","useRef","useLayoutEffect","videojs","useState","useCallback"],"mappings":";;;;;;;;AAeA,iCAAkC,OAAa;AACvC,UAAA,MAAMA,eAAAA,QAAM,OAAU,KAAK;AAC3B,UAAA,YAAYA,eAAAA,QAAM,OAAe,CAAC;AAExC,QAAI,CAACC,OAAAA,OAAO,OAAO,IAAI,OAAO,GAAG;AAC/B,UAAI,UAAU;AACd,gBAAU,WAAW;AAAA,IACvB;AAEO,WAAAD,eAAA,QAAM,QAAQ,MAAM,IAAI,SAAS,CAAC,UAAU,OAAO,CAAC;AAAA,EAC7D;AAKA,QAAM,iBAAiBE,MAUrB,WAAA,CACE,EAAE,UAAU,gBAAgB,SAAS,WAAW,eAAe,SAC/D,cACG;AACH,UAAM,SAAS;AAGT,UAAA,uBAAuBC,2BAAU,cAAc;AAC/C,UAA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