@editframe/react 0.0.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/.giteep +0 -0
- package/.prettierignore +4 -0
- package/package.json +35 -0
- package/src/Player.tsx +77 -0
- package/src/index.ts +1 -0
- package/tsconfig.json +4 -0
package/.giteep
ADDED
|
File without changes
|
package/.prettierignore
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@editframe/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.d.ts",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"react": "^18.2.0",
|
|
9
|
+
"uuid": "^9.0.0",
|
|
10
|
+
"@editframe/embed": "0.1.1",
|
|
11
|
+
"@editframe/shared-types": "3.11.0"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@types/react": "^18.0.28",
|
|
15
|
+
"@types/uuid": "^9.0.1",
|
|
16
|
+
"tsup": "^6.6.3",
|
|
17
|
+
"tsconfig": "0.0.0"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"react": "^18.2.0"
|
|
21
|
+
},
|
|
22
|
+
"author": "Editframe",
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "restricted"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --minify",
|
|
28
|
+
"dev": "npm run build -- --watch",
|
|
29
|
+
"format": "prettier --write '**/*.{js,ts,tsx}' --loglevel error",
|
|
30
|
+
"lint": "eslint --ext .ts .",
|
|
31
|
+
"lint:fix": "eslint --ext .ts . --fix",
|
|
32
|
+
"test": "jest",
|
|
33
|
+
"test:watch": "jest --watch"
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/Player.tsx
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Player } from "./Player";
|
package/tsconfig.json
ADDED