@player-ui/react 0.4.0 → 0.4.1-next.0
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/index.cjs.js +73 -41
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +73 -41
- package/package.json +13 -5
- package/src/asset/index.tsx +19 -7
- package/src/player.tsx +33 -20
package/dist/index.cjs.js
CHANGED
|
@@ -14,19 +14,19 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
14
14
|
|
|
15
15
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
16
|
|
|
17
|
-
var __defProp$
|
|
18
|
-
var __getOwnPropSymbols$
|
|
19
|
-
var __hasOwnProp$
|
|
20
|
-
var __propIsEnum$
|
|
21
|
-
var __defNormalProp$
|
|
22
|
-
var __spreadValues$
|
|
17
|
+
var __defProp$4 = Object.defineProperty;
|
|
18
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
19
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
20
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
21
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
22
|
+
var __spreadValues$4 = (a, b) => {
|
|
23
23
|
for (var prop in b || (b = {}))
|
|
24
|
-
if (__hasOwnProp$
|
|
25
|
-
__defNormalProp$
|
|
26
|
-
if (__getOwnPropSymbols$
|
|
27
|
-
for (var prop of __getOwnPropSymbols$
|
|
28
|
-
if (__propIsEnum$
|
|
29
|
-
__defNormalProp$
|
|
24
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
25
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
26
|
+
if (__getOwnPropSymbols$4)
|
|
27
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
28
|
+
if (__propIsEnum$4.call(b, prop))
|
|
29
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
30
30
|
}
|
|
31
31
|
return a;
|
|
32
32
|
};
|
|
@@ -39,14 +39,23 @@ const ReactAsset = (props) => {
|
|
|
39
39
|
} else if ("asset" in props) {
|
|
40
40
|
unwrapped = props.asset;
|
|
41
41
|
}
|
|
42
|
-
if (!unwrapped
|
|
43
|
-
throw Error(`Cannot determine asset type
|
|
42
|
+
if (!unwrapped) {
|
|
43
|
+
throw Error(`Cannot determine asset type for props: ${JSON.stringify(props)}`);
|
|
44
|
+
}
|
|
45
|
+
if (typeof unwrapped !== "object") {
|
|
46
|
+
throw Error(`Asset was not an object got (${typeof unwrapped}) instead: ${unwrapped}`);
|
|
47
|
+
}
|
|
48
|
+
if (unwrapped.type === void 0) {
|
|
49
|
+
const info = unwrapped.id === void 0 ? JSON.stringify(props) : `id: ${unwrapped.id}`;
|
|
50
|
+
throw Error(`Asset is missing type for ${info}`);
|
|
44
51
|
}
|
|
45
52
|
const Impl = registry == null ? void 0 : registry.get(unwrapped);
|
|
46
53
|
if (!Impl) {
|
|
47
54
|
throw Error(`No implementation found for id: ${unwrapped.id} type: ${unwrapped.type}`);
|
|
48
55
|
}
|
|
49
|
-
return /* @__PURE__ */ React__default["default"].createElement(Impl, __spreadValues$
|
|
56
|
+
return /* @__PURE__ */ React__default["default"].createElement(Impl, __spreadValues$4({
|
|
57
|
+
key: unwrapped.id
|
|
58
|
+
}, unwrapped));
|
|
50
59
|
};
|
|
51
60
|
|
|
52
61
|
const PlayerContext = React__default["default"].createContext({});
|
|
@@ -115,24 +124,24 @@ function useGetConstant(key) {
|
|
|
115
124
|
return player == null ? void 0 : player.constantsController.getConstants(key, "constants");
|
|
116
125
|
}
|
|
117
126
|
|
|
118
|
-
var __defProp$
|
|
119
|
-
var __getOwnPropSymbols$
|
|
120
|
-
var __hasOwnProp$
|
|
121
|
-
var __propIsEnum$
|
|
122
|
-
var __defNormalProp$
|
|
123
|
-
var __spreadValues$
|
|
127
|
+
var __defProp$3 = Object.defineProperty;
|
|
128
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
129
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
130
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
131
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
132
|
+
var __spreadValues$3 = (a, b) => {
|
|
124
133
|
for (var prop in b || (b = {}))
|
|
125
|
-
if (__hasOwnProp$
|
|
126
|
-
__defNormalProp$
|
|
127
|
-
if (__getOwnPropSymbols$
|
|
128
|
-
for (var prop of __getOwnPropSymbols$
|
|
129
|
-
if (__propIsEnum$
|
|
130
|
-
__defNormalProp$
|
|
134
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
135
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
136
|
+
if (__getOwnPropSymbols$3)
|
|
137
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
138
|
+
if (__propIsEnum$3.call(b, prop))
|
|
139
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
131
140
|
}
|
|
132
141
|
return a;
|
|
133
142
|
};
|
|
134
143
|
const ReactPlayer$1 = ({ view }) => {
|
|
135
|
-
return /* @__PURE__ */ React__default["default"].createElement(ReactAsset, __spreadValues$
|
|
144
|
+
return /* @__PURE__ */ React__default["default"].createElement(ReactAsset, __spreadValues$3({}, view));
|
|
136
145
|
};
|
|
137
146
|
|
|
138
147
|
class OnUpdatePlugin {
|
|
@@ -162,6 +171,22 @@ class OnUpdatePlugin {
|
|
|
162
171
|
}
|
|
163
172
|
}
|
|
164
173
|
|
|
174
|
+
var __defProp$2 = Object.defineProperty;
|
|
175
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
176
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
177
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
178
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
179
|
+
var __spreadValues$2 = (a, b) => {
|
|
180
|
+
for (var prop in b || (b = {}))
|
|
181
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
182
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
183
|
+
if (__getOwnPropSymbols$2)
|
|
184
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
185
|
+
if (__propIsEnum$2.call(b, prop))
|
|
186
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
187
|
+
}
|
|
188
|
+
return a;
|
|
189
|
+
};
|
|
165
190
|
var __async$1 = (__this, __arguments, generator) => {
|
|
166
191
|
return new Promise((resolve, reject) => {
|
|
167
192
|
var fulfilled = (value) => {
|
|
@@ -182,8 +207,8 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
182
207
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
183
208
|
});
|
|
184
209
|
};
|
|
185
|
-
const WEB_PLAYER_VERSION = "0.4.0";
|
|
186
|
-
const COMMIT = "
|
|
210
|
+
const WEB_PLAYER_VERSION = "0.4.1-next.0";
|
|
211
|
+
const COMMIT = "3fca14a3bf47195b400f5989a2f3ecbc5f73ac4b";
|
|
187
212
|
const _window = typeof window === "undefined" ? void 0 : window;
|
|
188
213
|
class ReactPlayer {
|
|
189
214
|
constructor(options) {
|
|
@@ -213,7 +238,7 @@ class ReactPlayer {
|
|
|
213
238
|
}
|
|
214
239
|
});
|
|
215
240
|
onUpdatePlugin.apply(this.player);
|
|
216
|
-
this.Component = this.
|
|
241
|
+
this.Component = this.createReactPlayerComponent();
|
|
217
242
|
this.reactPlayerInfo = {
|
|
218
243
|
playerVersion: this.player.getVersion(),
|
|
219
244
|
playerCommit: this.player.getCommit(),
|
|
@@ -244,13 +269,9 @@ class ReactPlayer {
|
|
|
244
269
|
getReactPlayerCommit() {
|
|
245
270
|
return this.reactPlayerInfo.reactPlayerCommit;
|
|
246
271
|
}
|
|
247
|
-
|
|
248
|
-
const
|
|
249
|
-
const ReactPlayerComponent = () => {
|
|
250
|
-
const view = reactSubscribe.useSubscribedState(this.viewUpdateSubscription);
|
|
251
|
-
if (this.options.suspend) {
|
|
252
|
-
this.viewUpdateSubscription.suspend();
|
|
253
|
-
}
|
|
272
|
+
createReactPlayerComponent() {
|
|
273
|
+
const BaseComp = this.hooks.webComponent.call(this.createReactComp());
|
|
274
|
+
const ReactPlayerComponent = (props) => {
|
|
254
275
|
return /* @__PURE__ */ React__default["default"].createElement(reactErrorBoundary.ErrorBoundary, {
|
|
255
276
|
fallbackRender: () => null,
|
|
256
277
|
onError: (err) => {
|
|
@@ -261,15 +282,26 @@ class ReactPlayer {
|
|
|
261
282
|
}
|
|
262
283
|
}, /* @__PURE__ */ React__default["default"].createElement(PlayerContext.Provider, {
|
|
263
284
|
value: { player: this.player }
|
|
264
|
-
}, /* @__PURE__ */ React__default["default"].createElement(
|
|
285
|
+
}, /* @__PURE__ */ React__default["default"].createElement(BaseComp, __spreadValues$2({}, props))));
|
|
286
|
+
};
|
|
287
|
+
return ReactPlayerComponent;
|
|
288
|
+
}
|
|
289
|
+
createReactComp() {
|
|
290
|
+
const ActualPlayerComp = this.hooks.playerComponent.call(ReactPlayer$1);
|
|
291
|
+
const WebPlayerComponent = () => {
|
|
292
|
+
const view = reactSubscribe.useSubscribedState(this.viewUpdateSubscription);
|
|
293
|
+
if (this.options.suspend) {
|
|
294
|
+
this.viewUpdateSubscription.suspend();
|
|
295
|
+
}
|
|
296
|
+
return /* @__PURE__ */ React__default["default"].createElement(AssetContext.Provider, {
|
|
265
297
|
value: {
|
|
266
298
|
registry: this.assetRegistry
|
|
267
299
|
}
|
|
268
300
|
}, view && /* @__PURE__ */ React__default["default"].createElement(ActualPlayerComp, {
|
|
269
301
|
view
|
|
270
|
-
}))
|
|
302
|
+
}));
|
|
271
303
|
};
|
|
272
|
-
return
|
|
304
|
+
return WebPlayerComponent;
|
|
273
305
|
}
|
|
274
306
|
setWaitForNextViewUpdate() {
|
|
275
307
|
const shouldCallResetHook = this.options.suspend && this.hooks.onBeforeViewReset.isUsed();
|
package/dist/index.d.ts
CHANGED
|
@@ -100,6 +100,7 @@ declare class ReactPlayer {
|
|
|
100
100
|
getReactPlayerVersion(): string;
|
|
101
101
|
/** Returns the git commit used to build the React Player version */
|
|
102
102
|
getReactPlayerCommit(): string;
|
|
103
|
+
private createReactPlayerComponent;
|
|
103
104
|
private createReactComp;
|
|
104
105
|
/**
|
|
105
106
|
* Call this method to force the ReactPlayer to wait for the next view-update before performing the next render.
|
package/dist/index.esm.js
CHANGED
|
@@ -7,19 +7,19 @@ import { Registry } from '@player-ui/partial-match-registry';
|
|
|
7
7
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
8
8
|
import { MetricsCorePluginSymbol, RequestTimeWebPlugin } from '@player-ui/metrics-plugin';
|
|
9
9
|
|
|
10
|
-
var __defProp$
|
|
11
|
-
var __getOwnPropSymbols$
|
|
12
|
-
var __hasOwnProp$
|
|
13
|
-
var __propIsEnum$
|
|
14
|
-
var __defNormalProp$
|
|
15
|
-
var __spreadValues$
|
|
10
|
+
var __defProp$4 = Object.defineProperty;
|
|
11
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
12
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
14
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
15
|
+
var __spreadValues$4 = (a, b) => {
|
|
16
16
|
for (var prop in b || (b = {}))
|
|
17
|
-
if (__hasOwnProp$
|
|
18
|
-
__defNormalProp$
|
|
19
|
-
if (__getOwnPropSymbols$
|
|
20
|
-
for (var prop of __getOwnPropSymbols$
|
|
21
|
-
if (__propIsEnum$
|
|
22
|
-
__defNormalProp$
|
|
17
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
18
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
19
|
+
if (__getOwnPropSymbols$4)
|
|
20
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
21
|
+
if (__propIsEnum$4.call(b, prop))
|
|
22
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
23
23
|
}
|
|
24
24
|
return a;
|
|
25
25
|
};
|
|
@@ -32,14 +32,23 @@ const ReactAsset = (props) => {
|
|
|
32
32
|
} else if ("asset" in props) {
|
|
33
33
|
unwrapped = props.asset;
|
|
34
34
|
}
|
|
35
|
-
if (!unwrapped
|
|
36
|
-
throw Error(`Cannot determine asset type
|
|
35
|
+
if (!unwrapped) {
|
|
36
|
+
throw Error(`Cannot determine asset type for props: ${JSON.stringify(props)}`);
|
|
37
|
+
}
|
|
38
|
+
if (typeof unwrapped !== "object") {
|
|
39
|
+
throw Error(`Asset was not an object got (${typeof unwrapped}) instead: ${unwrapped}`);
|
|
40
|
+
}
|
|
41
|
+
if (unwrapped.type === void 0) {
|
|
42
|
+
const info = unwrapped.id === void 0 ? JSON.stringify(props) : `id: ${unwrapped.id}`;
|
|
43
|
+
throw Error(`Asset is missing type for ${info}`);
|
|
37
44
|
}
|
|
38
45
|
const Impl = registry == null ? void 0 : registry.get(unwrapped);
|
|
39
46
|
if (!Impl) {
|
|
40
47
|
throw Error(`No implementation found for id: ${unwrapped.id} type: ${unwrapped.type}`);
|
|
41
48
|
}
|
|
42
|
-
return /* @__PURE__ */ React.createElement(Impl, __spreadValues$
|
|
49
|
+
return /* @__PURE__ */ React.createElement(Impl, __spreadValues$4({
|
|
50
|
+
key: unwrapped.id
|
|
51
|
+
}, unwrapped));
|
|
43
52
|
};
|
|
44
53
|
|
|
45
54
|
const PlayerContext = React.createContext({});
|
|
@@ -108,24 +117,24 @@ function useGetConstant(key) {
|
|
|
108
117
|
return player == null ? void 0 : player.constantsController.getConstants(key, "constants");
|
|
109
118
|
}
|
|
110
119
|
|
|
111
|
-
var __defProp$
|
|
112
|
-
var __getOwnPropSymbols$
|
|
113
|
-
var __hasOwnProp$
|
|
114
|
-
var __propIsEnum$
|
|
115
|
-
var __defNormalProp$
|
|
116
|
-
var __spreadValues$
|
|
120
|
+
var __defProp$3 = Object.defineProperty;
|
|
121
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
122
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
123
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
124
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
125
|
+
var __spreadValues$3 = (a, b) => {
|
|
117
126
|
for (var prop in b || (b = {}))
|
|
118
|
-
if (__hasOwnProp$
|
|
119
|
-
__defNormalProp$
|
|
120
|
-
if (__getOwnPropSymbols$
|
|
121
|
-
for (var prop of __getOwnPropSymbols$
|
|
122
|
-
if (__propIsEnum$
|
|
123
|
-
__defNormalProp$
|
|
127
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
128
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
129
|
+
if (__getOwnPropSymbols$3)
|
|
130
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
131
|
+
if (__propIsEnum$3.call(b, prop))
|
|
132
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
124
133
|
}
|
|
125
134
|
return a;
|
|
126
135
|
};
|
|
127
136
|
const ReactPlayer$1 = ({ view }) => {
|
|
128
|
-
return /* @__PURE__ */ React.createElement(ReactAsset, __spreadValues$
|
|
137
|
+
return /* @__PURE__ */ React.createElement(ReactAsset, __spreadValues$3({}, view));
|
|
129
138
|
};
|
|
130
139
|
|
|
131
140
|
class OnUpdatePlugin {
|
|
@@ -155,6 +164,22 @@ class OnUpdatePlugin {
|
|
|
155
164
|
}
|
|
156
165
|
}
|
|
157
166
|
|
|
167
|
+
var __defProp$2 = Object.defineProperty;
|
|
168
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
169
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
170
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
171
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
172
|
+
var __spreadValues$2 = (a, b) => {
|
|
173
|
+
for (var prop in b || (b = {}))
|
|
174
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
175
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
176
|
+
if (__getOwnPropSymbols$2)
|
|
177
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
178
|
+
if (__propIsEnum$2.call(b, prop))
|
|
179
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
180
|
+
}
|
|
181
|
+
return a;
|
|
182
|
+
};
|
|
158
183
|
var __async$1 = (__this, __arguments, generator) => {
|
|
159
184
|
return new Promise((resolve, reject) => {
|
|
160
185
|
var fulfilled = (value) => {
|
|
@@ -175,8 +200,8 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
175
200
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
176
201
|
});
|
|
177
202
|
};
|
|
178
|
-
const WEB_PLAYER_VERSION = "0.4.0";
|
|
179
|
-
const COMMIT = "
|
|
203
|
+
const WEB_PLAYER_VERSION = "0.4.1-next.0";
|
|
204
|
+
const COMMIT = "3fca14a3bf47195b400f5989a2f3ecbc5f73ac4b";
|
|
180
205
|
const _window = typeof window === "undefined" ? void 0 : window;
|
|
181
206
|
class ReactPlayer {
|
|
182
207
|
constructor(options) {
|
|
@@ -206,7 +231,7 @@ class ReactPlayer {
|
|
|
206
231
|
}
|
|
207
232
|
});
|
|
208
233
|
onUpdatePlugin.apply(this.player);
|
|
209
|
-
this.Component = this.
|
|
234
|
+
this.Component = this.createReactPlayerComponent();
|
|
210
235
|
this.reactPlayerInfo = {
|
|
211
236
|
playerVersion: this.player.getVersion(),
|
|
212
237
|
playerCommit: this.player.getCommit(),
|
|
@@ -237,13 +262,9 @@ class ReactPlayer {
|
|
|
237
262
|
getReactPlayerCommit() {
|
|
238
263
|
return this.reactPlayerInfo.reactPlayerCommit;
|
|
239
264
|
}
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
const ReactPlayerComponent = () => {
|
|
243
|
-
const view = useSubscribedState(this.viewUpdateSubscription);
|
|
244
|
-
if (this.options.suspend) {
|
|
245
|
-
this.viewUpdateSubscription.suspend();
|
|
246
|
-
}
|
|
265
|
+
createReactPlayerComponent() {
|
|
266
|
+
const BaseComp = this.hooks.webComponent.call(this.createReactComp());
|
|
267
|
+
const ReactPlayerComponent = (props) => {
|
|
247
268
|
return /* @__PURE__ */ React.createElement(ErrorBoundary, {
|
|
248
269
|
fallbackRender: () => null,
|
|
249
270
|
onError: (err) => {
|
|
@@ -254,15 +275,26 @@ class ReactPlayer {
|
|
|
254
275
|
}
|
|
255
276
|
}, /* @__PURE__ */ React.createElement(PlayerContext.Provider, {
|
|
256
277
|
value: { player: this.player }
|
|
257
|
-
}, /* @__PURE__ */ React.createElement(
|
|
278
|
+
}, /* @__PURE__ */ React.createElement(BaseComp, __spreadValues$2({}, props))));
|
|
279
|
+
};
|
|
280
|
+
return ReactPlayerComponent;
|
|
281
|
+
}
|
|
282
|
+
createReactComp() {
|
|
283
|
+
const ActualPlayerComp = this.hooks.playerComponent.call(ReactPlayer$1);
|
|
284
|
+
const WebPlayerComponent = () => {
|
|
285
|
+
const view = useSubscribedState(this.viewUpdateSubscription);
|
|
286
|
+
if (this.options.suspend) {
|
|
287
|
+
this.viewUpdateSubscription.suspend();
|
|
288
|
+
}
|
|
289
|
+
return /* @__PURE__ */ React.createElement(AssetContext.Provider, {
|
|
258
290
|
value: {
|
|
259
291
|
registry: this.assetRegistry
|
|
260
292
|
}
|
|
261
293
|
}, view && /* @__PURE__ */ React.createElement(ActualPlayerComp, {
|
|
262
294
|
view
|
|
263
|
-
}))
|
|
295
|
+
}));
|
|
264
296
|
};
|
|
265
|
-
return
|
|
297
|
+
return WebPlayerComponent;
|
|
266
298
|
}
|
|
267
299
|
setWaitForNextViewUpdate() {
|
|
268
300
|
const shouldCallResetHook = this.options.suspend && this.hooks.onBeforeViewReset.isUsed();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-ui/react",
|
|
3
|
-
"version": "0.4.0",
|
|
3
|
+
"version": "0.4.1-next.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"react-dom": "^17.0.2"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@player-ui/player": "0.4.0",
|
|
15
|
-
"@player-ui/partial-match-registry": "0.4.0",
|
|
16
|
-
"@player-ui/metrics-plugin": "0.4.0",
|
|
17
|
-
"@player-ui/react-subscribe": "0.4.0",
|
|
14
|
+
"@player-ui/player": "0.4.1-next.0",
|
|
15
|
+
"@player-ui/partial-match-registry": "0.4.1-next.0",
|
|
16
|
+
"@player-ui/metrics-plugin": "0.4.1-next.0",
|
|
17
|
+
"@player-ui/react-subscribe": "0.4.1-next.0",
|
|
18
18
|
"react-error-boundary": "^3.1.3",
|
|
19
19
|
"tapable-ts": "^0.2.3",
|
|
20
20
|
"@babel/runtime": "7.15.4"
|
|
@@ -60,6 +60,14 @@
|
|
|
60
60
|
{
|
|
61
61
|
"name": "Kelly Harrop",
|
|
62
62
|
"url": "https://github.com/kharrop"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Alejandro Fimbres",
|
|
66
|
+
"url": "https://github.com/lexfm"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "Rafael Campos",
|
|
70
|
+
"url": "https://github.com/rafbcampos"
|
|
63
71
|
}
|
|
64
72
|
]
|
|
65
73
|
}
|
package/src/asset/index.tsx
CHANGED
|
@@ -29,12 +29,24 @@ export const ReactAsset = (
|
|
|
29
29
|
unwrapped = (props as unknown as AssetWrapper).asset;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
if (!unwrapped) {
|
|
33
|
+
throw Error(
|
|
34
|
+
`Cannot determine asset type for props: ${JSON.stringify(props)}`
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (typeof unwrapped !== 'object') {
|
|
39
|
+
throw Error(
|
|
40
|
+
`Asset was not an object got (${typeof unwrapped}) instead: ${unwrapped}`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (unwrapped.type === undefined) {
|
|
45
|
+
const info =
|
|
46
|
+
unwrapped.id === undefined
|
|
47
|
+
? JSON.stringify(props)
|
|
48
|
+
: `id: ${unwrapped.id}`;
|
|
49
|
+
throw Error(`Asset is missing type for ${info}`);
|
|
38
50
|
}
|
|
39
51
|
|
|
40
52
|
const Impl = registry?.get(unwrapped);
|
|
@@ -45,5 +57,5 @@ export const ReactAsset = (
|
|
|
45
57
|
);
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
return <Impl {...unwrapped} />;
|
|
60
|
+
return <Impl key={unwrapped.id} {...unwrapped} />;
|
|
49
61
|
};
|
package/src/player.tsx
CHANGED
|
@@ -19,8 +19,8 @@ import type { ReactPlayerProps } from './app';
|
|
|
19
19
|
import PlayerComp from './app';
|
|
20
20
|
import OnUpdatePlugin from './plugins/onupdate-plugin';
|
|
21
21
|
|
|
22
|
-
const WEB_PLAYER_VERSION = '0.4.0';
|
|
23
|
-
const COMMIT = '
|
|
22
|
+
const WEB_PLAYER_VERSION = '0.4.1-next.0';
|
|
23
|
+
const COMMIT = '3fca14a3bf47195b400f5989a2f3ecbc5f73ac4b';
|
|
24
24
|
|
|
25
25
|
export interface DevtoolsGlobals {
|
|
26
26
|
/** A global for a plugin to load to Player for devtools */
|
|
@@ -138,7 +138,7 @@ export class ReactPlayer {
|
|
|
138
138
|
|
|
139
139
|
onUpdatePlugin.apply(this.player);
|
|
140
140
|
|
|
141
|
-
this.Component = this.
|
|
141
|
+
this.Component = this.createReactPlayerComponent();
|
|
142
142
|
this.reactPlayerInfo = {
|
|
143
143
|
playerVersion: this.player.getVersion(),
|
|
144
144
|
playerCommit: this.player.getCommit(),
|
|
@@ -182,17 +182,11 @@ export class ReactPlayer {
|
|
|
182
182
|
return this.reactPlayerInfo.reactPlayerCommit;
|
|
183
183
|
}
|
|
184
184
|
|
|
185
|
-
private
|
|
186
|
-
const
|
|
187
|
-
|
|
188
|
-
/** the component to use to render Player */
|
|
189
|
-
const ReactPlayerComponent = () => {
|
|
190
|
-
const view = useSubscribedState<View>(this.viewUpdateSubscription);
|
|
191
|
-
|
|
192
|
-
if (this.options.suspend) {
|
|
193
|
-
this.viewUpdateSubscription.suspend();
|
|
194
|
-
}
|
|
185
|
+
private createReactPlayerComponent(): React.ComponentType<ReactPlayerComponentProps> {
|
|
186
|
+
const BaseComp = this.hooks.webComponent.call(this.createReactComp());
|
|
195
187
|
|
|
188
|
+
/** Wrap the Error boundary and context provider after the hook call to catch anything wrapped by the hook */
|
|
189
|
+
const ReactPlayerComponent = (props: ReactPlayerComponentProps) => {
|
|
196
190
|
return (
|
|
197
191
|
<ErrorBoundary
|
|
198
192
|
fallbackRender={() => null}
|
|
@@ -205,13 +199,7 @@ export class ReactPlayer {
|
|
|
205
199
|
}}
|
|
206
200
|
>
|
|
207
201
|
<PlayerContext.Provider value={{ player: this.player }}>
|
|
208
|
-
<
|
|
209
|
-
value={{
|
|
210
|
-
registry: this.assetRegistry,
|
|
211
|
-
}}
|
|
212
|
-
>
|
|
213
|
-
{view && <ActualPlayerComp view={view} />}
|
|
214
|
-
</AssetContext.Provider>
|
|
202
|
+
<BaseComp {...props} />
|
|
215
203
|
</PlayerContext.Provider>
|
|
216
204
|
</ErrorBoundary>
|
|
217
205
|
);
|
|
@@ -220,6 +208,31 @@ export class ReactPlayer {
|
|
|
220
208
|
return ReactPlayerComponent;
|
|
221
209
|
}
|
|
222
210
|
|
|
211
|
+
private createReactComp(): React.ComponentType<ReactPlayerComponentProps> {
|
|
212
|
+
const ActualPlayerComp = this.hooks.playerComponent.call(PlayerComp);
|
|
213
|
+
|
|
214
|
+
/** the component to use to render the player */
|
|
215
|
+
const WebPlayerComponent = () => {
|
|
216
|
+
const view = useSubscribedState<View>(this.viewUpdateSubscription);
|
|
217
|
+
|
|
218
|
+
if (this.options.suspend) {
|
|
219
|
+
this.viewUpdateSubscription.suspend();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return (
|
|
223
|
+
<AssetContext.Provider
|
|
224
|
+
value={{
|
|
225
|
+
registry: this.assetRegistry,
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
228
|
+
{view && <ActualPlayerComp view={view} />}
|
|
229
|
+
</AssetContext.Provider>
|
|
230
|
+
);
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
return WebPlayerComponent;
|
|
234
|
+
}
|
|
235
|
+
|
|
223
236
|
/**
|
|
224
237
|
* Call this method to force the ReactPlayer to wait for the next view-update before performing the next render.
|
|
225
238
|
* If the `suspense` option is set, this will suspend while an update is pending, otherwise nothing will be rendered.
|