@editframe/react 0.26.3-beta.0 → 0.30.0-beta.13

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.
@@ -1,13 +0,0 @@
1
- import { EFTimeDisplay } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const TimeDisplay = createComponent({
6
- tagName: "ef-time-display",
7
- elementClass: EFTimeDisplay,
8
- react: React,
9
- });
10
-
11
- export type TimeDisplayProps = {
12
- className?: string;
13
- };
@@ -1,9 +0,0 @@
1
- import { EFAudio as EFAudioElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Audio = createComponent({
6
- tagName: "ef-audio",
7
- elementClass: EFAudioElement,
8
- react: React,
9
- });
@@ -1,39 +0,0 @@
1
- import {
2
- EFCaptionsActiveWord as EFCaptionsActiveWordElement,
3
- EFCaptionsAfterActiveWord as EFCaptionsAfterActiveWordElement,
4
- EFCaptionsBeforeActiveWord as EFCaptionsBeforeActiveWordElement,
5
- EFCaptions as EFCaptionsElement,
6
- EFCaptionsSegment as EFCaptionsSegmentElement,
7
- } from "@editframe/elements";
8
- import React from "react";
9
- import { createComponent } from "../hooks/create-element";
10
-
11
- export const Captions = createComponent({
12
- tagName: "ef-captions",
13
- elementClass: EFCaptionsElement,
14
- react: React,
15
- });
16
-
17
- export const CaptionsActiveWord = createComponent({
18
- tagName: "ef-captions-active-word",
19
- elementClass: EFCaptionsActiveWordElement,
20
- react: React,
21
- });
22
-
23
- export const CaptionsSegment = createComponent({
24
- tagName: "ef-captions-segment",
25
- elementClass: EFCaptionsSegmentElement,
26
- react: React,
27
- });
28
-
29
- export const CaptionsBeforeActiveWord = createComponent({
30
- tagName: "ef-captions-before-active-word",
31
- elementClass: EFCaptionsBeforeActiveWordElement,
32
- react: React,
33
- });
34
-
35
- export const CaptionsAfterActiveWord = createComponent({
36
- tagName: "ef-captions-after-active-word",
37
- elementClass: EFCaptionsAfterActiveWordElement,
38
- react: React,
39
- });
@@ -1,9 +0,0 @@
1
- import { EFImage as EFImageElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Image = createComponent({
6
- tagName: "ef-image",
7
- elementClass: EFImageElement,
8
- react: React,
9
- });
@@ -1,11 +0,0 @@
1
- import { EFSurface as EFSurfaceElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Surface = createComponent({
6
- tagName: "ef-surface",
7
- elementClass: EFSurfaceElement,
8
- react: React,
9
- displayName: "Surface",
10
- events: {},
11
- });
@@ -1,11 +0,0 @@
1
- import { EFThumbnailStrip as EFThumbnailStripElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const ThumbnailStrip = createComponent({
6
- tagName: "ef-thumbnail-strip",
7
- elementClass: EFThumbnailStripElement,
8
- react: React,
9
- displayName: "ThumbnailStrip",
10
- events: {},
11
- });
@@ -1,9 +0,0 @@
1
- import { EFTimegroup as EFTimegroupElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Timegroup = createComponent({
6
- tagName: "ef-timegroup",
7
- elementClass: EFTimegroupElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFVideo as EFVideoElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Video = createComponent({
6
- tagName: "ef-video",
7
- elementClass: EFVideoElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFWaveform as EFWaveformElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Waveform = createComponent({
6
- tagName: "ef-waveform",
7
- elementClass: EFWaveformElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFConfiguration } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Configuration = createComponent({
6
- tagName: "ef-configuration",
7
- elementClass: EFConfiguration,
8
- react: React,
9
- });
@@ -1,112 +0,0 @@
1
- import React from "react";
2
- import { createRoot, hydrateRoot, type Root } from "react-dom/client";
3
- import { renderToString } from "react-dom/server";
4
- import { test as baseTest, describe, vi } from "vitest";
5
- import { Timegroup } from "../elements/Timegroup";
6
- import { setIsomorphicEffect } from "../hooks/create-element";
7
- import { Configuration } from "./Configuration";
8
- import { Controls } from "./Controls";
9
- import { Preview } from "./Preview";
10
- import { TogglePlay } from "./TogglePlay";
11
-
12
- const test = baseTest.extend<{
13
- root: Root;
14
- markup: JSX.Element;
15
- stringMarkup: string;
16
- hydratedContainer: HTMLElement;
17
- renderedContainer: HTMLElement;
18
- }>({
19
- // biome-ignore lint/correctness/noEmptyPattern: Required by Vitest fixture syntax
20
- markup: async ({}, use) => {
21
- const markup = (
22
- <>
23
- <Configuration>
24
- {/* biome-ignore lint/correctness/useUniqueElementIds: OK for test fixture with single instance */}
25
- <Preview id="test-preview">
26
- <Timegroup mode="fixed" duration="10s" />
27
- </Preview>
28
- <Controls target="test-preview">
29
- <TogglePlay />
30
- </Controls>
31
- </Configuration>
32
- </>
33
- );
34
- await use(markup);
35
- },
36
- stringMarkup: async ({ markup }, use) => {
37
- setIsomorphicEffect(React.useEffect);
38
- const stringMarkup = renderToString(markup);
39
- setIsomorphicEffect(React.useLayoutEffect);
40
- await use(stringMarkup);
41
- },
42
- hydratedContainer: async ({ stringMarkup, markup }, use) => {
43
- const container = document.createElement("div");
44
- document.body.appendChild(container);
45
- container.innerHTML = stringMarkup;
46
- hydrateRoot(container, markup);
47
- await use(container);
48
- container.remove();
49
- },
50
- // biome-ignore lint/correctness/noEmptyPattern: Required by Vitest fixture syntax
51
- renderedContainer: async ({}, use) => {
52
- const container = document.createElement("div");
53
- document.body.appendChild(container);
54
- await use(container);
55
- container.remove();
56
- },
57
- root: async ({ renderedContainer, markup }, use) => {
58
- const root = createRoot(renderedContainer);
59
- root.render(markup);
60
- await use(root);
61
- root.unmount();
62
- },
63
- });
64
-
65
- describe("Controls", () => {
66
- describe("renderedContainer", () => {
67
- test.skip("works", async ({ renderedContainer, expect }) => {
68
- await vi.waitUntil(
69
- () => {
70
- return renderedContainer.innerHTML.includes("ef-controls");
71
- },
72
- { timeout: 5000 },
73
- );
74
- const controls =
75
- // biome-ignore lint/style/noNonNullAssertion: Safe in tests where elements are guaranteed to exist
76
- renderedContainer.getElementsByTagName("ef-controls")[0]!;
77
- const preview =
78
- // biome-ignore lint/style/noNonNullAssertion: Safe in tests where elements are guaranteed to exist
79
- renderedContainer.getElementsByTagName("ef-preview")[0]!;
80
- const togglePlay =
81
- // biome-ignore lint/style/noNonNullAssertion: Safe in tests where elements are guaranteed to exist
82
- renderedContainer.getElementsByTagName("ef-toggle-play")[0]!;
83
-
84
- expect(controls.targetElement).toBe(preview);
85
- expect(togglePlay.efContext).toBe(preview);
86
- }, 5000);
87
- });
88
-
89
- describe("hydratedContainer", () => {
90
- test("proxies contexts following hydration", async ({
91
- hydratedContainer,
92
- expect,
93
- }) => {
94
- await vi.waitUntil(
95
- () => hydratedContainer.innerHTML.includes("ef-controls"),
96
- { timeout: 5000 },
97
- );
98
- const controls =
99
- // biome-ignore lint/style/noNonNullAssertion: Safe in tests where elements are guaranteed to exist
100
- hydratedContainer.getElementsByTagName("ef-controls")[0]!;
101
- const preview =
102
- // biome-ignore lint/style/noNonNullAssertion: Safe in tests where elements are guaranteed to exist
103
- hydratedContainer.getElementsByTagName("ef-preview")[0]!;
104
- const togglePlay =
105
- // biome-ignore lint/style/noNonNullAssertion: Safe in tests where elements are guaranteed to exist
106
- hydratedContainer.getElementsByTagName("ef-toggle-play")[0]!;
107
-
108
- expect(controls.targetElement).toBe(preview);
109
- expect(togglePlay.efContext).toBe(preview);
110
- }, 5000);
111
- });
112
- });
@@ -1,9 +0,0 @@
1
- import { EFControls as EFControlsElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Controls = createComponent({
6
- tagName: "ef-controls",
7
- elementClass: EFControlsElement,
8
- react: React,
9
- });
package/src/gui/EFDial.ts DELETED
@@ -1,12 +0,0 @@
1
- import { EFDial as EFDialElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Dial = createComponent({
6
- tagName: "ef-dial",
7
- elementClass: EFDialElement,
8
- react: React,
9
- events: {
10
- onChange: "change",
11
- },
12
- });
@@ -1,12 +0,0 @@
1
- import { EFResizableBox as EFResizableBoxElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const ResizableBox = createComponent({
6
- tagName: "ef-resizable-box",
7
- elementClass: EFResizableBoxElement,
8
- react: React,
9
- events: {
10
- onBoundsChange: "bounds-change",
11
- },
12
- });
@@ -1,9 +0,0 @@
1
- import { EFFilmstrip as EFFilmstripElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Filmstrip = createComponent({
6
- tagName: "ef-filmstrip",
7
- elementClass: EFFilmstripElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFFitScale as EFFitScaleElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const FitScale = createComponent({
6
- tagName: "ef-fit-scale",
7
- elementClass: EFFitScaleElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFFocusOverlay as EFFocusOverlayElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const FocusOverlay = createComponent({
6
- tagName: "ef-focus-overlay",
7
- elementClass: EFFocusOverlayElement,
8
- react: React,
9
- });
package/src/gui/Pause.ts DELETED
@@ -1,9 +0,0 @@
1
- import { EFPause as EFPauseElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Pause = createComponent({
6
- tagName: "ef-pause",
7
- elementClass: EFPauseElement,
8
- react: React,
9
- });
package/src/gui/Play.ts DELETED
@@ -1,9 +0,0 @@
1
- import { EFPlay as EFPlayElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Play = createComponent({
6
- tagName: "ef-play",
7
- elementClass: EFPlayElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFPreview as EFPreviewElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Preview = createComponent({
6
- tagName: "ef-preview",
7
- elementClass: EFPreviewElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFScrubber as EFScrubberElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Scrubber = createComponent({
6
- tagName: "ef-scrubber",
7
- elementClass: EFScrubberElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFToggleLoop as EFToggleLoopElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const ToggleLoop = createComponent({
6
- tagName: "ef-toggle-loop",
7
- elementClass: EFToggleLoopElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFTogglePlay as EFTogglePlayElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const TogglePlay = createComponent({
6
- tagName: "ef-toggle-play",
7
- elementClass: EFTogglePlayElement,
8
- react: React,
9
- });
@@ -1,9 +0,0 @@
1
- import { EFWorkbench as EFWorkbenchElement } from "@editframe/elements";
2
- import React from "react";
3
- import { createComponent } from "../hooks/create-element";
4
-
5
- export const Workbench = createComponent({
6
- tagName: "ef-workbench",
7
- elementClass: EFWorkbenchElement,
8
- react: React,
9
- });
@@ -1,167 +0,0 @@
1
- import React from "react";
2
-
3
- let isomorphicEffect =
4
- typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
5
-
6
- export function setIsomorphicEffect(
7
- effect: typeof React.useLayoutEffect | typeof React.useEffect,
8
- ) {
9
- isomorphicEffect = effect;
10
- }
11
-
12
- const reservedReactProperties = new Set([
13
- "children",
14
- "localName",
15
- "ref",
16
- "style",
17
- "className",
18
- ]);
19
- const listenedEvents = new WeakMap<Element, Map<string, EventListenerObject>>();
20
-
21
- type Constructor<T> = { new (): T };
22
- type EventNames = Record<string, string>;
23
-
24
- type EventListeners<E extends EventNames> = {
25
- [K in keyof E]?: (e: Event) => void;
26
- };
27
-
28
- type ElementProps<I> = Partial<Omit<I, keyof HTMLElement>>;
29
- type ComponentProps<I, E extends EventNames = {}> = Omit<
30
- React.HTMLAttributes<I>,
31
- keyof E | keyof ElementProps<I>
32
- > &
33
- EventListeners<E> &
34
- ElementProps<I>;
35
-
36
- export type ReactWebComponent<
37
- I extends HTMLElement,
38
- E extends EventNames = {},
39
- > = React.ForwardRefExoticComponent<
40
- ComponentProps<I, E> & React.RefAttributes<I>
41
- >;
42
-
43
- export interface Options<I extends HTMLElement, E extends EventNames = {}> {
44
- react: typeof React;
45
- tagName: string;
46
- elementClass: Constructor<I>;
47
- events?: E;
48
- displayName?: string;
49
- }
50
-
51
- function addOrUpdateEventListener(
52
- node: Element,
53
- event: string,
54
- listener?: (e?: Event) => void,
55
- ) {
56
- let events = listenedEvents.get(node);
57
- if (!events) {
58
- events = new Map();
59
- listenedEvents.set(node, events);
60
- }
61
- let handler = events.get(event);
62
-
63
- if (listener) {
64
- if (!handler) {
65
- handler = { handleEvent: listener };
66
- events.set(event, handler);
67
- node.addEventListener(event, handler);
68
- } else {
69
- handler.handleEvent = listener;
70
- }
71
- } else if (handler) {
72
- events.delete(event);
73
- node.removeEventListener(event, handler);
74
- }
75
- }
76
-
77
- function setProperty<E extends Element>(
78
- node: E,
79
- name: string,
80
- value: unknown,
81
- old: unknown,
82
- events?: EventNames,
83
- ) {
84
- const event = events?.[name];
85
- if (event) {
86
- if (value !== old)
87
- addOrUpdateEventListener(node, event, value as (e?: Event) => void);
88
- return;
89
- }
90
- node[name as keyof E] = value as E[keyof E];
91
- if (
92
- (value === undefined || value === null) &&
93
- name in HTMLElement.prototype
94
- ) {
95
- node.removeAttribute(name);
96
- }
97
- }
98
-
99
- export function createComponent<
100
- I extends HTMLElement,
101
- E extends EventNames = {},
102
- >({
103
- react: React,
104
- tagName,
105
- elementClass,
106
- events,
107
- displayName,
108
- }: Options<I, E>): ReactWebComponent<I, E> {
109
- const eventProps = new Set(Object.keys(events ?? {}));
110
-
111
- const ReactComponent = React.forwardRef<I, ComponentProps<I, E>>(
112
- (props, ref) => {
113
- const elementRef = React.useRef<I | null>(null);
114
- const prevPropsRef = React.useRef(new Map<string, unknown>());
115
-
116
- const reactProps: Record<string, unknown> = {
117
- suppressHydrationWarning: true,
118
- };
119
- const elementProps: Record<string, unknown> = {};
120
-
121
- for (const [k, v] of Object.entries(props)) {
122
- if (reservedReactProperties.has(k)) {
123
- reactProps[k === "className" ? "class" : k] = v;
124
- continue;
125
- }
126
- if (eventProps.has(k) || k in elementClass.prototype)
127
- elementProps[k] = v;
128
- reactProps[k] = v;
129
- }
130
-
131
- isomorphicEffect(() => {
132
- if (!elementRef.current) return;
133
- const newProps = new Map<string, unknown>();
134
- for (const key in elementProps) {
135
- setProperty(
136
- elementRef.current,
137
- key,
138
- props[key as keyof typeof props],
139
- prevPropsRef.current.get(key),
140
- events,
141
- );
142
- prevPropsRef.current.delete(key);
143
- newProps.set(key, props[key as keyof typeof props]);
144
- }
145
- for (const [key, value] of prevPropsRef.current) {
146
- setProperty(elementRef.current, key, undefined, value, events);
147
- }
148
- prevPropsRef.current = newProps;
149
-
150
- // Remove defer-hydration if present
151
- elementRef.current.removeAttribute("defer-hydration");
152
- }, [props]);
153
-
154
- return React.createElement(tagName, {
155
- ...reactProps,
156
- ref: (node: I) => {
157
- elementRef.current = node;
158
- if (typeof ref === "function") ref(node);
159
- else if (ref) ref.current = node;
160
- },
161
- });
162
- },
163
- );
164
-
165
- ReactComponent.displayName = displayName ?? elementClass.name;
166
- return ReactComponent as ReactWebComponent<I, E>;
167
- }