shaka-video-element 0.6.9 → 0.6.10
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/react.d.ts +6 -5
- package/dist/react.js +151 -86
- package/package.json +5 -3
- package/shaka-video-element.d.ts +10 -0
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CustomMediaElement from '../shaka-video-element.js';
|
|
3
|
+
|
|
4
|
+
declare const _default: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<CustomMediaElement>, "disablePictureInPicture" | "height" | "onenterpictureinpicture" | "onleavepictureinpicture" | "playsInline" | "poster" | "videoHeight" | "videoWidth" | "width" | "cancelVideoFrameCallback" | "getVideoPlaybackQuality" | "requestPictureInPicture" | "requestVideoFrameCallback" | "autoplay" | "buffered" | "controls" | "crossOrigin" | "currentSrc" | "currentTime" | "defaultMuted" | "defaultPlaybackRate" | "disableRemotePlayback" | "duration" | "ended" | "error" | "loop" | "mediaKeys" | "muted" | "networkState" | "onencrypted" | "onwaitingforkey" | "paused" | "playbackRate" | "played" | "preload" | "preservesPitch" | "readyState" | "remote" | "seekable" | "seeking" | "sinkId" | "src" | "srcObject" | "textTracks" | "volume" | "addTextTrack" | "canPlayType" | "fastSeek" | "load" | "pause" | "play" | "setMediaKeys" | "setSinkId" | "NETWORK_EMPTY" | "NETWORK_IDLE" | "NETWORK_LOADING" | "NETWORK_NO_SOURCE" | "HAVE_NOTHING" | "HAVE_METADATA" | "HAVE_CURRENT_DATA" | "HAVE_FUTURE_DATA" | "HAVE_ENOUGH_DATA"> & {} & Partial<Omit<CustomMediaElement, keyof HTMLElement | "connectedCallback" | "disconnectedCallback" | "attributeChangedCallback" | "adoptedCallback">> & React.RefAttributes<CustomMediaElement>>;
|
|
5
|
+
|
|
6
|
+
export { _default as default };
|
package/dist/react.js
CHANGED
|
@@ -1,95 +1,160 @@
|
|
|
1
|
-
|
|
2
|
-
'use client';
|
|
1
|
+
"use client";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
import
|
|
3
|
+
// dist/react.ts
|
|
4
|
+
import React from "react";
|
|
5
|
+
import CustomMediaElement from "../shaka-video-element.js";
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
7
|
+
// ../../node_modules/ce-la-react/dist/ce-la-react.js
|
|
8
|
+
var reservedReactProps = /* @__PURE__ */ new Set([
|
|
9
|
+
"style",
|
|
10
|
+
"children",
|
|
11
|
+
"ref",
|
|
12
|
+
"key",
|
|
13
|
+
"suppressContentEditableWarning",
|
|
14
|
+
"suppressHydrationWarning",
|
|
15
|
+
"dangerouslySetInnerHTML"
|
|
16
|
+
]);
|
|
17
|
+
var reactPropToAttrNameMap = {
|
|
18
|
+
className: "class",
|
|
19
|
+
htmlFor: "for"
|
|
20
|
+
};
|
|
21
|
+
function defaultToAttributeName(propName) {
|
|
22
|
+
return propName.toLowerCase();
|
|
23
|
+
}
|
|
24
|
+
function defaultToAttributeValue(propValue) {
|
|
25
|
+
if (typeof propValue === "boolean") return propValue ? "" : void 0;
|
|
26
|
+
if (typeof propValue === "function") return void 0;
|
|
27
|
+
if (typeof propValue === "object" && propValue !== null) return void 0;
|
|
28
|
+
return propValue;
|
|
29
|
+
}
|
|
30
|
+
function createComponent({
|
|
31
|
+
react: React2,
|
|
32
|
+
tagName,
|
|
33
|
+
elementClass,
|
|
34
|
+
events,
|
|
35
|
+
displayName,
|
|
36
|
+
toAttributeName = defaultToAttributeName,
|
|
37
|
+
toAttributeValue = defaultToAttributeValue
|
|
38
|
+
}) {
|
|
39
|
+
const IS_REACT_19_OR_NEWER = Number.parseInt(React2.version) >= 19;
|
|
40
|
+
const ReactComponent = React2.forwardRef((props, ref) => {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const elementRef = React2.useRef(null);
|
|
43
|
+
const prevElemPropsRef = React2.useRef(/* @__PURE__ */ new Map());
|
|
44
|
+
const eventProps = {};
|
|
45
|
+
const attrs = {};
|
|
46
|
+
const reactProps = {};
|
|
47
|
+
const elementProps = {};
|
|
48
|
+
for (const [k, v] of Object.entries(props)) {
|
|
49
|
+
if (reservedReactProps.has(k)) {
|
|
50
|
+
reactProps[k] = v;
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const attrName = toAttributeName(reactPropToAttrNameMap[k] ?? k);
|
|
54
|
+
if (k in elementClass.prototype && !(k in (((_a = globalThis.HTMLElement) == null ? void 0 : _a.prototype) ?? {})) && !((_b = elementClass.observedAttributes) == null ? void 0 : _b.some((attr) => attr === attrName))) {
|
|
55
|
+
elementProps[k] = v;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (k.startsWith("on")) {
|
|
59
|
+
eventProps[k] = v;
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const attrValue = toAttributeValue(v);
|
|
63
|
+
if (attrName && attrValue != null) {
|
|
64
|
+
attrs[attrName] = String(attrValue);
|
|
65
|
+
if (!IS_REACT_19_OR_NEWER) {
|
|
66
|
+
reactProps[attrName] = attrValue;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (attrName && IS_REACT_19_OR_NEWER) {
|
|
70
|
+
reactProps[attrName] = v;
|
|
71
|
+
}
|
|
27
72
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
73
|
+
if (typeof window !== "undefined") {
|
|
74
|
+
for (const propName in eventProps) {
|
|
75
|
+
const callback = eventProps[propName];
|
|
76
|
+
const useCapture = propName.endsWith("Capture");
|
|
77
|
+
const eventName = ((events == null ? void 0 : events[propName]) ?? propName.slice(2).toLowerCase()).slice(
|
|
78
|
+
0,
|
|
79
|
+
useCapture ? -7 : void 0
|
|
80
|
+
);
|
|
81
|
+
React2.useLayoutEffect(() => {
|
|
82
|
+
const eventTarget = elementRef == null ? void 0 : elementRef.current;
|
|
83
|
+
if (!eventTarget || typeof callback !== "function") return;
|
|
84
|
+
eventTarget.addEventListener(eventName, callback, useCapture);
|
|
85
|
+
return () => {
|
|
86
|
+
eventTarget.removeEventListener(eventName, callback, useCapture);
|
|
87
|
+
};
|
|
88
|
+
}, [elementRef == null ? void 0 : elementRef.current, callback]);
|
|
89
|
+
}
|
|
90
|
+
React2.useLayoutEffect(() => {
|
|
91
|
+
if (elementRef.current === null) return;
|
|
92
|
+
const newElemProps = /* @__PURE__ */ new Map();
|
|
93
|
+
for (const key in elementProps) {
|
|
94
|
+
setProperty(elementRef.current, key, elementProps[key]);
|
|
95
|
+
prevElemPropsRef.current.delete(key);
|
|
96
|
+
newElemProps.set(key, elementProps[key]);
|
|
97
|
+
}
|
|
98
|
+
for (const [key, _value] of prevElemPropsRef.current) {
|
|
99
|
+
setProperty(elementRef.current, key, void 0);
|
|
100
|
+
}
|
|
101
|
+
prevElemPropsRef.current = newElemProps;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (typeof window === "undefined" && (elementClass == null ? void 0 : elementClass.getTemplateHTML) && (elementClass == null ? void 0 : elementClass.shadowRootOptions)) {
|
|
105
|
+
const { mode, delegatesFocus } = elementClass.shadowRootOptions;
|
|
106
|
+
const templateShadowRoot = React2.createElement("template", {
|
|
107
|
+
shadowrootmode: mode,
|
|
108
|
+
shadowrootdelegatesfocus: delegatesFocus,
|
|
109
|
+
dangerouslySetInnerHTML: {
|
|
110
|
+
__html: elementClass.getTemplateHTML(attrs)
|
|
57
111
|
}
|
|
58
|
-
}
|
|
59
|
-
[
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
112
|
+
});
|
|
113
|
+
reactProps.children = [templateShadowRoot, reactProps.children];
|
|
114
|
+
}
|
|
115
|
+
return React2.createElement(tagName, {
|
|
116
|
+
...reactProps,
|
|
117
|
+
ref: React2.useCallback(
|
|
118
|
+
(node) => {
|
|
119
|
+
elementRef.current = node;
|
|
120
|
+
if (typeof ref === "function") {
|
|
121
|
+
ref(node);
|
|
122
|
+
} else if (ref !== null) {
|
|
123
|
+
ref.current = node;
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
[ref]
|
|
127
|
+
)
|
|
128
|
+
});
|
|
63
129
|
});
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
function propsToAttrs(props = {}) {
|
|
74
|
-
let attrs = {};
|
|
75
|
-
for (let [propName, propValue] of Object.entries(props)) {
|
|
76
|
-
let attrName = toAttrName(propName, propValue);
|
|
77
|
-
if (attrName) attrs[attrName] = toAttrValue(propValue);
|
|
130
|
+
ReactComponent.displayName = displayName ?? elementClass.name;
|
|
131
|
+
return ReactComponent;
|
|
132
|
+
}
|
|
133
|
+
function setProperty(node, name, value) {
|
|
134
|
+
var _a;
|
|
135
|
+
node[name] = value;
|
|
136
|
+
if (value == null && name in (((_a = globalThis.HTMLElement) == null ? void 0 : _a.prototype) ?? {})) {
|
|
137
|
+
node.removeAttribute(name);
|
|
78
138
|
}
|
|
79
|
-
return attrs;
|
|
80
139
|
}
|
|
81
140
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
141
|
+
// dist/react.ts
|
|
142
|
+
var react_default = createComponent({
|
|
143
|
+
react: React,
|
|
144
|
+
tagName: "shaka-video",
|
|
145
|
+
elementClass: CustomMediaElement
|
|
146
|
+
});
|
|
147
|
+
export {
|
|
148
|
+
react_default as default
|
|
149
|
+
};
|
|
150
|
+
/*! Bundled license information:
|
|
90
151
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
152
|
+
ce-la-react/dist/ce-la-react.js:
|
|
153
|
+
(**
|
|
154
|
+
* @license
|
|
155
|
+
* Copyright 2018 Google LLC
|
|
156
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
157
|
+
*
|
|
158
|
+
* Modified version of `@lit/react` for vanilla custom elements with support for SSR.
|
|
159
|
+
*)
|
|
160
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaka-video-element",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Custom element (web component) for Shaka Player",
|
|
5
5
|
"author": "@muxinc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
"directory": "packages/shaka-video-element"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
|
+
"shaka-video-element.d.ts",
|
|
17
18
|
"dist"
|
|
18
19
|
],
|
|
19
20
|
"type": "module",
|
|
20
21
|
"main": "shaka-video-element.js",
|
|
22
|
+
"types": "shaka-video-element.d.ts",
|
|
21
23
|
"exports": {
|
|
22
24
|
".": "./shaka-video-element.js",
|
|
23
25
|
"./react": "./dist/react.js"
|
|
@@ -34,9 +36,9 @@
|
|
|
34
36
|
"shaka-player": "~4.8.4"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
|
-
"build-react-wrapper": "^0.1.
|
|
39
|
+
"build-react-wrapper": "^0.1.7",
|
|
38
40
|
"npm-run-all": "^4.1.5",
|
|
39
|
-
"wet-run": "^1.2.
|
|
41
|
+
"wet-run": "^1.2.5"
|
|
40
42
|
},
|
|
41
43
|
"keywords": [
|
|
42
44
|
"shaka",
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export default class CustomVideoElement extends HTMLVideoElement {
|
|
2
|
+
static readonly observedAttributes: string[];
|
|
3
|
+
attributeChangedCallback(
|
|
4
|
+
attrName: string,
|
|
5
|
+
oldValue?: string | null,
|
|
6
|
+
newValue?: string | null
|
|
7
|
+
): void;
|
|
8
|
+
connectedCallback(): void;
|
|
9
|
+
disconnectedCallback(): void;
|
|
10
|
+
}
|