@editframe/react 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Player.d.ts +18 -0
- package/dist/Player.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +115 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +123 -0
- package/dist/index.js.map +1 -0
- package/dist/shared.d.ts +3 -0
- package/dist/shared.d.ts.map +1 -0
- package/package.json +32 -13
- package/.prettierignore +0 -4
- package/.turbo/turbo-build.log +0 -17
- package/CHANGELOG.md +0 -7
- package/prettier.config.js +0 -4
- package/src/Player.tsx +0 -77
- package/src/index.ts +0 -1
- package/tsconfig.json +0 -4
package/dist/Player.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DetailedHTMLProps, FunctionComponent, HTMLAttributes } from 'react';
|
|
2
|
+
import { CompositionConfigEditor } from './shared';
|
|
3
|
+
export interface IPlayerProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
|
|
4
|
+
applicationId?: string;
|
|
5
|
+
config: CompositionConfigEditor;
|
|
6
|
+
dimensions?: {
|
|
7
|
+
height: string;
|
|
8
|
+
width: string;
|
|
9
|
+
};
|
|
10
|
+
hideControls?: boolean;
|
|
11
|
+
host?: string;
|
|
12
|
+
loop: boolean;
|
|
13
|
+
playerState?: 'playing' | 'paused' | 'stopped';
|
|
14
|
+
seek?: number;
|
|
15
|
+
}
|
|
16
|
+
declare const Player: FunctionComponent<IPlayerProps>;
|
|
17
|
+
export default Player;
|
|
18
|
+
//# sourceMappingURL=Player.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Player.d.ts","sourceRoot":"","sources":["../src/Player.tsx"],"names":[],"mappings":"AACA,OAAc,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EAGf,MAAM,OAAO,CAAA;AAGd,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,MAAM,WAAW,YACf,SAAQ,iBAAiB,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,cAAc,CAAC;IACzE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,uBAAuB,CAAA;IAC/B,UAAU,CAAC,EAAE;QACX,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,SAAS,CAAA;IAC9C,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,MAAM,EAAE,iBAAiB,CAAC,YAAY,CAqD3C,CAAA;AACD,eAAe,MAAM,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Player as Player$1 } from '@editframe/embed';
|
|
2
|
+
import React, { useRef, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
5
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
6
|
+
// generators (like Math.random()).
|
|
7
|
+
let getRandomValues;
|
|
8
|
+
const rnds8 = new Uint8Array(16);
|
|
9
|
+
function rng() {
|
|
10
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
11
|
+
if (!getRandomValues) {
|
|
12
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
13
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
14
|
+
|
|
15
|
+
if (!getRandomValues) {
|
|
16
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return getRandomValues(rnds8);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
25
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const byteToHex = [];
|
|
29
|
+
|
|
30
|
+
for (let i = 0; i < 256; ++i) {
|
|
31
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function unsafeStringify(arr, offset = 0) {
|
|
35
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
36
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
37
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
41
|
+
var native = {
|
|
42
|
+
randomUUID
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function v4(options, buf, offset) {
|
|
46
|
+
if (native.randomUUID && !buf && !options) {
|
|
47
|
+
return native.randomUUID();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
options = options || {};
|
|
51
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
52
|
+
|
|
53
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
54
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
55
|
+
|
|
56
|
+
if (buf) {
|
|
57
|
+
offset = offset || 0;
|
|
58
|
+
|
|
59
|
+
for (let i = 0; i < 16; ++i) {
|
|
60
|
+
buf[offset + i] = rnds[i];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return buf;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return unsafeStringify(rnds);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var Player = function (_a) {
|
|
70
|
+
var applicationId = _a.applicationId, children = _a.children, config = _a.config, dimensions = _a.dimensions, hideControls = _a.hideControls, host = _a.host, loop = _a.loop, playerState = _a.playerState, seek = _a.seek;
|
|
71
|
+
var player = useRef(true);
|
|
72
|
+
var embed = useRef({});
|
|
73
|
+
var containerId = "ef-player-".concat(v4().slice(0, 6));
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (!player.current && !embed.current.setState) {
|
|
76
|
+
embed.current = new Player$1({
|
|
77
|
+
applicationId: applicationId,
|
|
78
|
+
config: config,
|
|
79
|
+
containerId: containerId,
|
|
80
|
+
dimensions: dimensions,
|
|
81
|
+
host: host || 'https://embed.editframe.com',
|
|
82
|
+
hideControls: hideControls,
|
|
83
|
+
loop: loop,
|
|
84
|
+
});
|
|
85
|
+
player.current = true;
|
|
86
|
+
}
|
|
87
|
+
return function () {
|
|
88
|
+
player.current = false;
|
|
89
|
+
};
|
|
90
|
+
}, []);
|
|
91
|
+
useEffect(function () {
|
|
92
|
+
if (embed.current && embed.current.setState) {
|
|
93
|
+
embed.current.setState(playerState);
|
|
94
|
+
}
|
|
95
|
+
return function () {
|
|
96
|
+
if (embed.current && embed.current.setState) {
|
|
97
|
+
embed.current.setState('stopped');
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
}, [playerState]);
|
|
101
|
+
useEffect(function () {
|
|
102
|
+
if (embed.current && embed.current.setState) {
|
|
103
|
+
embed.current.seek(seek);
|
|
104
|
+
}
|
|
105
|
+
return function () {
|
|
106
|
+
if (embed.current && embed.current.setState) {
|
|
107
|
+
embed.current.seek(0);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
}, [seek]);
|
|
111
|
+
return React.createElement("div", { id: containerId }, children);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export { Player };
|
|
115
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/rng.js","../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/stringify.js","../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/native.js","../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/v4.js","../src/Player.tsx"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import { Player as PlayerClass } from '@editframe/embed'\nimport React, {\n DetailedHTMLProps,\n FunctionComponent,\n HTMLAttributes,\n useEffect,\n useRef,\n} from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport { CompositionConfigEditor } from './shared'\n\nexport interface IPlayerProps\n extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {\n applicationId?: string\n config: CompositionConfigEditor\n dimensions?: {\n height: string\n width: string\n }\n hideControls?: boolean\n host?: string\n loop: boolean\n playerState?: 'playing' | 'paused' | 'stopped'\n seek?: number\n}\n\nconst Player: FunctionComponent<IPlayerProps> = ({\n applicationId,\n children,\n config,\n dimensions,\n hideControls,\n host,\n loop,\n playerState,\n seek,\n}) => {\n const player = useRef(true)\n const embed = useRef({} as any)\n const containerId = `ef-player-${uuid().slice(0, 6)}`\n useEffect(() => {\n if (!player.current && !embed.current.setState) {\n embed.current = new PlayerClass({\n applicationId,\n config,\n containerId,\n dimensions,\n host: host || 'https://embed.editframe.com',\n hideControls,\n loop,\n })\n player.current = true\n }\n return () => {\n player.current = false\n }\n }, [])\n useEffect(() => {\n if (embed.current && embed.current.setState) {\n embed.current.setState(playerState)\n }\n return () => {\n if (embed.current && embed.current.setState) {\n embed.current.setState('stopped')\n }\n }\n }, [playerState])\n useEffect(() => {\n if (embed.current && embed.current.setState) {\n embed.current.seek(seek)\n }\n return () => {\n if (embed.current && embed.current.setState) {\n embed.current.seek(0)\n }\n }\n }, [seek])\n\n return <div id={containerId}>{children}</div>\n}\nexport default Player\n"],"names":["uuid","PlayerClass"],"mappings":";;;AAAA;AACA;AACA;AACA,IAAI,eAAe,CAAC;AACpB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AAClB,SAAS,GAAG,GAAG;AAC9B;AACA,EAAE,IAAI,CAAC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EAAG,EAAA,QAAQ,CAAO,CAAA;AAC/C;;;;"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var embed = require('@editframe/embed');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
+
|
|
12
|
+
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
13
|
+
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
14
|
+
// generators (like Math.random()).
|
|
15
|
+
let getRandomValues;
|
|
16
|
+
const rnds8 = new Uint8Array(16);
|
|
17
|
+
function rng() {
|
|
18
|
+
// lazy load so that environments that need to polyfill have a chance to do so
|
|
19
|
+
if (!getRandomValues) {
|
|
20
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
21
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
22
|
+
|
|
23
|
+
if (!getRandomValues) {
|
|
24
|
+
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return getRandomValues(rnds8);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Convert array of 16 byte values to UUID string format of the form:
|
|
33
|
+
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
const byteToHex = [];
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < 256; ++i) {
|
|
39
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function unsafeStringify(arr, offset = 0) {
|
|
43
|
+
// Note: Be careful editing this code! It's been tuned for performance
|
|
44
|
+
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
45
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
49
|
+
var native = {
|
|
50
|
+
randomUUID
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function v4(options, buf, offset) {
|
|
54
|
+
if (native.randomUUID && !buf && !options) {
|
|
55
|
+
return native.randomUUID();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
options = options || {};
|
|
59
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
60
|
+
|
|
61
|
+
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
62
|
+
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
63
|
+
|
|
64
|
+
if (buf) {
|
|
65
|
+
offset = offset || 0;
|
|
66
|
+
|
|
67
|
+
for (let i = 0; i < 16; ++i) {
|
|
68
|
+
buf[offset + i] = rnds[i];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return buf;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return unsafeStringify(rnds);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var Player = function (_a) {
|
|
78
|
+
var applicationId = _a.applicationId, children = _a.children, config = _a.config, dimensions = _a.dimensions, hideControls = _a.hideControls, host = _a.host, loop = _a.loop, playerState = _a.playerState, seek = _a.seek;
|
|
79
|
+
var player = React.useRef(true);
|
|
80
|
+
var embed$1 = React.useRef({});
|
|
81
|
+
var containerId = "ef-player-".concat(v4().slice(0, 6));
|
|
82
|
+
React.useEffect(function () {
|
|
83
|
+
if (!player.current && !embed$1.current.setState) {
|
|
84
|
+
embed$1.current = new embed.Player({
|
|
85
|
+
applicationId: applicationId,
|
|
86
|
+
config: config,
|
|
87
|
+
containerId: containerId,
|
|
88
|
+
dimensions: dimensions,
|
|
89
|
+
host: host || 'https://embed.editframe.com',
|
|
90
|
+
hideControls: hideControls,
|
|
91
|
+
loop: loop,
|
|
92
|
+
});
|
|
93
|
+
player.current = true;
|
|
94
|
+
}
|
|
95
|
+
return function () {
|
|
96
|
+
player.current = false;
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
React.useEffect(function () {
|
|
100
|
+
if (embed$1.current && embed$1.current.setState) {
|
|
101
|
+
embed$1.current.setState(playerState);
|
|
102
|
+
}
|
|
103
|
+
return function () {
|
|
104
|
+
if (embed$1.current && embed$1.current.setState) {
|
|
105
|
+
embed$1.current.setState('stopped');
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}, [playerState]);
|
|
109
|
+
React.useEffect(function () {
|
|
110
|
+
if (embed$1.current && embed$1.current.setState) {
|
|
111
|
+
embed$1.current.seek(seek);
|
|
112
|
+
}
|
|
113
|
+
return function () {
|
|
114
|
+
if (embed$1.current && embed$1.current.setState) {
|
|
115
|
+
embed$1.current.seek(0);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}, [seek]);
|
|
119
|
+
return React__default["default"].createElement("div", { id: containerId }, children);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
exports.Player = Player;
|
|
123
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/rng.js","../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/stringify.js","../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/native.js","../../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-browser/v4.js","../src/Player.tsx"],"sourcesContent":["// Unique ID creation requires a high quality random # generator. In the browser we therefore\n// require the crypto API and do not support built-in fallback to lower quality random number\n// generators (like Math.random()).\nlet getRandomValues;\nconst rnds8 = new Uint8Array(16);\nexport default function rng() {\n // lazy load so that environments that need to polyfill have a chance to do so\n if (!getRandomValues) {\n // getRandomValues needs to be invoked in a context where \"this\" is a Crypto implementation.\n getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);\n\n if (!getRandomValues) {\n throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');\n }\n }\n\n return getRandomValues(rnds8);\n}","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nexport default {\n randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import { Player as PlayerClass } from '@editframe/embed'\nimport React, {\n DetailedHTMLProps,\n FunctionComponent,\n HTMLAttributes,\n useEffect,\n useRef,\n} from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport { CompositionConfigEditor } from './shared'\n\nexport interface IPlayerProps\n extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {\n applicationId?: string\n config: CompositionConfigEditor\n dimensions?: {\n height: string\n width: string\n }\n hideControls?: boolean\n host?: string\n loop: boolean\n playerState?: 'playing' | 'paused' | 'stopped'\n seek?: number\n}\n\nconst Player: FunctionComponent<IPlayerProps> = ({\n applicationId,\n children,\n config,\n dimensions,\n hideControls,\n host,\n loop,\n playerState,\n seek,\n}) => {\n const player = useRef(true)\n const embed = useRef({} as any)\n const containerId = `ef-player-${uuid().slice(0, 6)}`\n useEffect(() => {\n if (!player.current && !embed.current.setState) {\n embed.current = new PlayerClass({\n applicationId,\n config,\n containerId,\n dimensions,\n host: host || 'https://embed.editframe.com',\n hideControls,\n loop,\n })\n player.current = true\n }\n return () => {\n player.current = false\n }\n }, [])\n useEffect(() => {\n if (embed.current && embed.current.setState) {\n embed.current.setState(playerState)\n }\n return () => {\n if (embed.current && embed.current.setState) {\n embed.current.setState('stopped')\n }\n }\n }, [playerState])\n useEffect(() => {\n if (embed.current && embed.current.setState) {\n embed.current.seek(seek)\n }\n return () => {\n if (embed.current && embed.current.setState) {\n embed.current.seek(0)\n }\n }\n }, [seek])\n\n return <div id={containerId}>{children}</div>\n}\nexport default Player\n"],"names":["useRef","embed","uuid","useEffect","PlayerClass","React"],"mappings":";;;;;;;;;;;AAAA;AACA;AACA;AACA,IAAI,eAAe,CAAC;AACpB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AAClB,SAAS,GAAG,GAAG;AAC9B;AACA,EAAE,IAAI,CAAC,eAAe,EAAE;AACxB;AACA,IAAI,eAAe,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACrH;AACA,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,MAAM,MAAM,IAAI,KAAK,CAAC,0GAA0G,CAAC,CAAC;AAClI,KAAK;AACL,GAAG;AACH;AACA,EAAE,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;AAChC;;AChBA;AACA;AACA;AACA;AACA;AACA,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB;AACA,KAAK,IAAI,CAAC,GAAG,CAAC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OAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;AAC3C,YAAAA,OAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAA;AACpC,SAAA;QACD,OAAO,YAAA;YACL,IAAIA,OAAK,CAAC,OAAO,IAAIA,OAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;AAC3C,gBAAAA,OAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;AAClC,aAAA;AACH,SAAC,CAAA;AACH,KAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;AACjB,IAAAE,eAAS,CAAC,YAAA;QACR,IAAIF,OAAK,CAAC,OAAO,IAAIA,OAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;AAC3C,YAAAA,OAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,SAAA;QACD,OAAO,YAAA;YACL,IAAIA,OAAK,CAAC,OAAO,IAAIA,OAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;AAC3C,gBAAAA,OAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACtB,aAAA;AACH,SAAC,CAAA;AACH,KAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;AAEV,IAAA,OAAOI,iDAAK,EAAE,EAAE,WAAW,EAAG,EAAA,QAAQ,CAAO,CAAA;AAC/C;;;;"}
|
package/dist/shared.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AAE5D,YAAY,EAAE,uBAAuB,EAAE,CAAA"}
|
package/package.json
CHANGED
|
@@ -2,26 +2,45 @@
|
|
|
2
2
|
"name": "@editframe/react",
|
|
3
3
|
"author": "Editframe",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"keywords": [],
|
|
9
|
+
"peerDependencies": {
|
|
10
|
+
"react": ">=16.8.0",
|
|
11
|
+
"react-dom": ">=16.8.0"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@
|
|
14
|
+
"@babel/core": "^7.15.0",
|
|
15
|
+
"@rollup/plugin-commonjs": "^17.1.0",
|
|
16
|
+
"@rollup/plugin-node-resolve": "^11.2.1",
|
|
17
|
+
"@types/react": "^16.14.14",
|
|
18
|
+
"@types/react-dom": "^16.9.14",
|
|
19
|
+
"autoprefixer": "^10.4.13",
|
|
20
|
+
"babel-loader": "^8.2.2",
|
|
21
|
+
"babel-preset-react-app": "^10.0.0",
|
|
22
|
+
"identity-obj-proxy": "^3.0.0",
|
|
23
|
+
"react": "^16.14.0",
|
|
24
|
+
"react-dom": "^16.14.0",
|
|
25
|
+
"rollup": "^2.56.3",
|
|
26
|
+
"rollup-plugin-copy": "^3.4.0",
|
|
27
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
28
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
29
|
+
"rollup-plugin-typescript2": "^0.29.0",
|
|
30
|
+
"typescript": "^4.8.4",
|
|
15
31
|
"@types/uuid": "^9.0.1",
|
|
16
|
-
"tsup": "^6.6.3",
|
|
17
32
|
"tsconfig": "0.0.0"
|
|
18
33
|
},
|
|
19
|
-
"
|
|
20
|
-
"
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"uuid": "^9.0.0",
|
|
36
|
+
"@editframe/embed": "0.3.0"
|
|
21
37
|
},
|
|
22
|
-
"
|
|
38
|
+
"files": [
|
|
39
|
+
"dist/**"
|
|
40
|
+
],
|
|
41
|
+
"version": "0.1.3",
|
|
23
42
|
"scripts": {
|
|
24
|
-
"build": "
|
|
43
|
+
"build": "rollup -c",
|
|
25
44
|
"dev": "npm run build -- --watch",
|
|
26
45
|
"format": "prettier --write '**/*.{js,ts,tsx}' --loglevel error",
|
|
27
46
|
"lint": "eslint --ext .ts .",
|
package/.prettierignore
DELETED
package/.turbo/turbo-build.log
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @editframe/react@0.1.0 build /home/runner/work/js/js/packages/react
|
|
3
|
-
> tsup src/index.ts --format esm,cjs --dts --minify
|
|
4
|
-
|
|
5
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
6
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
|
-
[34mCLI[39m tsup v6.6.3
|
|
8
|
-
[34mCLI[39m Target: es6
|
|
9
|
-
[34mESM[39m Build start
|
|
10
|
-
[34mCJS[39m Build start
|
|
11
|
-
[32mCJS[39m [1mdist/index.js [22m[32m1.31 KB[39m
|
|
12
|
-
[32mCJS[39m ⚡️ Build success in 74ms
|
|
13
|
-
[32mESM[39m [1mdist/index.mjs [22m[32m830.00 B[39m
|
|
14
|
-
[32mESM[39m ⚡️ Build success in 81ms
|
|
15
|
-
[34mDTS[39m Build start
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in 3997ms
|
|
17
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m564.00 B[39m
|
package/CHANGELOG.md
DELETED
package/prettier.config.js
DELETED
package/src/Player.tsx
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { Player as PlayerClass } from '@editframe/embed'
|
|
2
|
-
import { CompositionConfigEditor } from '@editframe/shared-types'
|
|
3
|
-
import React, { useEffect, useRef } from 'react'
|
|
4
|
-
import { v4 as uuid } from 'uuid'
|
|
5
|
-
|
|
6
|
-
export interface IPlayerProps
|
|
7
|
-
extends React.DetailedHTMLProps<
|
|
8
|
-
React.HTMLAttributes<HTMLDivElement>,
|
|
9
|
-
HTMLDivElement
|
|
10
|
-
> {
|
|
11
|
-
applicationId?: string
|
|
12
|
-
config: CompositionConfigEditor
|
|
13
|
-
dimensions?: {
|
|
14
|
-
height: string
|
|
15
|
-
width: string
|
|
16
|
-
}
|
|
17
|
-
hideControls?: boolean
|
|
18
|
-
host?: string
|
|
19
|
-
loop: boolean
|
|
20
|
-
playerState?: 'playing' | 'paused' | 'stopped'
|
|
21
|
-
seek?: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const Player: React.FunctionComponent<IPlayerProps> = ({
|
|
25
|
-
applicationId,
|
|
26
|
-
children,
|
|
27
|
-
config,
|
|
28
|
-
dimensions,
|
|
29
|
-
hideControls,
|
|
30
|
-
host,
|
|
31
|
-
loop,
|
|
32
|
-
playerState,
|
|
33
|
-
seek,
|
|
34
|
-
}) => {
|
|
35
|
-
const player = useRef(true)
|
|
36
|
-
const embed = useRef({} as any)
|
|
37
|
-
const containerId = `ef-player-${uuid().slice(0, 6)}`
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (!player.current && !embed.current.setState) {
|
|
40
|
-
embed.current = new PlayerClass({
|
|
41
|
-
applicationId,
|
|
42
|
-
config,
|
|
43
|
-
containerId,
|
|
44
|
-
dimensions,
|
|
45
|
-
host: host || 'https://embed.editframe.com',
|
|
46
|
-
hideControls,
|
|
47
|
-
})
|
|
48
|
-
player.current = true
|
|
49
|
-
}
|
|
50
|
-
return () => {
|
|
51
|
-
player.current = false
|
|
52
|
-
}
|
|
53
|
-
}, [])
|
|
54
|
-
useEffect(() => {
|
|
55
|
-
if (embed.current && embed.current.setState) {
|
|
56
|
-
embed.current.setState(playerState)
|
|
57
|
-
}
|
|
58
|
-
return () => {
|
|
59
|
-
if (embed.current && embed.current.setState) {
|
|
60
|
-
embed.current.setState('stopped')
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}, [playerState])
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
if (embed.current && embed.current.setState) {
|
|
66
|
-
embed.current.seek(seek)
|
|
67
|
-
}
|
|
68
|
-
return () => {
|
|
69
|
-
if (embed.current && embed.current.setState) {
|
|
70
|
-
embed.current.seek(0)
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}, [seek])
|
|
74
|
-
|
|
75
|
-
return <div id={containerId}>{children}</div>
|
|
76
|
-
}
|
|
77
|
-
export default Player
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Player } from "./Player";
|
package/tsconfig.json
DELETED