@editframe/react 0.0.1 → 0.1.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.
@@ -0,0 +1,19 @@
1
+ import { CompositionConfigEditor } from '@editframe/shared-types';
2
+ import React from 'react';
3
+
4
+ interface IPlayerProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
5
+ applicationId?: string;
6
+ config: CompositionConfigEditor;
7
+ dimensions?: {
8
+ height: string;
9
+ width: string;
10
+ };
11
+ hideControls?: boolean;
12
+ host?: string;
13
+ loop: boolean;
14
+ playerState?: 'playing' | 'paused' | 'stopped';
15
+ seek?: number;
16
+ }
17
+ declare const Player: React.FunctionComponent<IPlayerProps>;
18
+
19
+ export { Player };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var c=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var S=(r,t)=>{for(var i in t)c(r,i,{get:t[i],enumerable:!0})},b=(r,t,i,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of h(t))!C.call(r,n)&&n!==i&&c(r,n,{get:()=>t[n],enumerable:!(s=P(t,n))||s.enumerable});return r};var v=r=>b(c({},"__esModule",{value:!0}),r);var R={};S(R,{Player:()=>m});module.exports=v(R);var f=require("@editframe/embed"),o=require("react"),d=require("uuid"),y=require("react/jsx-runtime"),E=({applicationId:r,children:t,config:i,dimensions:s,hideControls:n,host:g,loop:H,playerState:u,seek:p})=>{let a=(0,o.useRef)(!0),e=(0,o.useRef)({}),l=`ef-player-${(0,d.v4)().slice(0,6)}`;return(0,o.useEffect)(()=>(!a.current&&!e.current.setState&&(e.current=new f.Player({applicationId:r,config:i,containerId:l,dimensions:s,host:g||"https://embed.editframe.com",hideControls:n}),a.current=!0),()=>{a.current=!1}),[]),(0,o.useEffect)(()=>(e.current&&e.current.setState&&e.current.setState(u),()=>{e.current&&e.current.setState&&e.current.setState("stopped")}),[u]),(0,o.useEffect)(()=>(e.current&&e.current.setState&&e.current.seek(p),()=>{e.current&&e.current.setState&&e.current.seek(0)}),[p]),(0,y.jsx)("div",{id:l,children:t})},m=E;0&&(module.exports={Player});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{Player as d}from"@editframe/embed";import{useEffect as r,useRef as s}from"react";import{v4 as m}from"uuid";import{jsx as P}from"react/jsx-runtime";var y=({applicationId:a,children:c,config:u,dimensions:p,hideControls:l,host:f,loop:h,playerState:n,seek:o})=>{let t=s(!0),e=s({}),i=`ef-player-${m().slice(0,6)}`;return r(()=>(!t.current&&!e.current.setState&&(e.current=new d({applicationId:a,config:u,containerId:i,dimensions:p,host:f||"https://embed.editframe.com",hideControls:l}),t.current=!0),()=>{t.current=!1}),[]),r(()=>(e.current&&e.current.setState&&e.current.setState(n),()=>{e.current&&e.current.setState&&e.current.setState("stopped")}),[n]),r(()=>(e.current&&e.current.setState&&e.current.seek(o),()=>{e.current&&e.current.setState&&e.current.seek(0)}),[o]),P("div",{id:i,children:c})},g=y;export{g as Player};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@editframe/react",
3
- "version": "0.0.1",
3
+ "author": "Editframe",
4
4
  "description": "",
5
5
  "main": "./dist/index.d.ts",
6
6
  "types": "./dist/index.d.ts",
@@ -19,10 +19,10 @@
19
19
  "peerDependencies": {
20
20
  "react": "^18.2.0"
21
21
  },
22
- "author": "Editframe",
23
- "publishConfig": {
24
- "access": "restricted"
25
- },
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "version": "0.1.1",
26
26
  "scripts": {
27
27
  "build": "tsup src/index.ts --format esm,cjs --dts --minify",
28
28
  "dev": "npm run build -- --watch",
package/.giteep DELETED
File without changes
package/.prettierignore DELETED
@@ -1,4 +0,0 @@
1
- # Ignore artifacts:
2
- /.git
3
- /node_modules
4
- /dist
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
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "tsconfig/react-library.json",
3
- "include": ["src"]
4
- }