@editframe/create 0.43.0 → 0.45.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/README.md +11 -0
- package/dist/index.js +16 -28
- package/dist/index.js.map +1 -1
- package/dist/skills/editframe-brand-video-generator/README.md +155 -0
- package/dist/skills/editframe-brand-video-generator/SKILL.md +207 -0
- package/dist/skills/editframe-brand-video-generator/references/brand-examples.md +178 -0
- package/dist/skills/editframe-brand-video-generator/references/color-psychology.md +227 -0
- package/dist/skills/editframe-brand-video-generator/references/composition-patterns.md +383 -0
- package/dist/skills/editframe-brand-video-generator/references/editing.md +66 -0
- package/dist/skills/editframe-brand-video-generator/references/emotional-arcs.md +496 -0
- package/dist/skills/editframe-brand-video-generator/references/genre-selection.md +135 -0
- package/dist/skills/editframe-brand-video-generator/references/transition-styles.md +611 -0
- package/dist/skills/editframe-brand-video-generator/references/typography-personalities.md +326 -0
- package/dist/skills/editframe-brand-video-generator/references/video-archetypes.md +86 -0
- package/dist/skills/editframe-brand-video-generator/references/video-fundamentals.md +169 -0
- package/dist/skills/editframe-brand-video-generator/references/visual-metaphors.md +50 -0
- package/dist/skills/editframe-composition/SKILL.md +169 -0
- package/dist/skills/editframe-composition/references/audio.md +483 -0
- package/dist/skills/editframe-composition/references/captions.md +844 -0
- package/dist/skills/editframe-composition/references/composition-model.md +73 -0
- package/dist/skills/editframe-composition/references/configuration.md +403 -0
- package/dist/skills/editframe-composition/references/css-parts.md +105 -0
- package/dist/skills/editframe-composition/references/css-variables.md +640 -0
- package/dist/skills/editframe-composition/references/entry-points.md +810 -0
- package/dist/skills/editframe-composition/references/events.md +499 -0
- package/dist/skills/editframe-composition/references/getting-started.md +259 -0
- package/dist/skills/editframe-composition/references/hooks.md +234 -0
- package/dist/skills/editframe-composition/references/image.md +241 -0
- package/dist/skills/editframe-composition/references/r3f.md +580 -0
- package/dist/skills/editframe-composition/references/render-api.md +484 -0
- package/dist/skills/editframe-composition/references/render-strategies.md +119 -0
- package/dist/skills/editframe-composition/references/render-to-video.md +1101 -0
- package/dist/skills/editframe-composition/references/scripting.md +606 -0
- package/dist/skills/editframe-composition/references/sequencing.md +116 -0
- package/dist/skills/editframe-composition/references/server-rendering.md +753 -0
- package/dist/skills/editframe-composition/references/surface.md +329 -0
- package/dist/skills/editframe-composition/references/text.md +627 -0
- package/dist/skills/editframe-composition/references/time-model.md +99 -0
- package/dist/skills/editframe-composition/references/timegroup-modes.md +102 -0
- package/dist/skills/editframe-composition/references/timegroup.md +457 -0
- package/dist/skills/editframe-composition/references/timeline-root.md +398 -0
- package/dist/skills/editframe-composition/references/transcription.md +47 -0
- package/dist/skills/editframe-composition/references/transitions.md +608 -0
- package/dist/skills/editframe-composition/references/use-media-info.md +357 -0
- package/dist/skills/editframe-composition/references/video.md +506 -0
- package/dist/skills/editframe-composition/references/waveform.md +327 -0
- package/dist/skills/editframe-editor-gui/SKILL.md +152 -0
- package/dist/skills/editframe-editor-gui/references/active-root-temporal.md +657 -0
- package/dist/skills/editframe-editor-gui/references/canvas.md +947 -0
- package/dist/skills/editframe-editor-gui/references/controls.md +366 -0
- package/dist/skills/editframe-editor-gui/references/dial.md +756 -0
- package/dist/skills/editframe-editor-gui/references/editor-toolkit.md +587 -0
- package/dist/skills/editframe-editor-gui/references/filmstrip.md +460 -0
- package/dist/skills/editframe-editor-gui/references/fit-scale.md +772 -0
- package/dist/skills/editframe-editor-gui/references/focus-overlay.md +561 -0
- package/dist/skills/editframe-editor-gui/references/hierarchy.md +544 -0
- package/dist/skills/editframe-editor-gui/references/overlay-item.md +634 -0
- package/dist/skills/editframe-editor-gui/references/overlay-layer.md +429 -0
- package/dist/skills/editframe-editor-gui/references/pan-zoom.md +568 -0
- package/dist/skills/editframe-editor-gui/references/pause.md +397 -0
- package/dist/skills/editframe-editor-gui/references/play.md +370 -0
- package/dist/skills/editframe-editor-gui/references/preview.md +391 -0
- package/dist/skills/editframe-editor-gui/references/resizable-box.md +749 -0
- package/dist/skills/editframe-editor-gui/references/scrubber.md +588 -0
- package/dist/skills/editframe-editor-gui/references/thumbnail-strip.md +566 -0
- package/dist/skills/editframe-editor-gui/references/time-display.md +492 -0
- package/dist/skills/editframe-editor-gui/references/timeline-ruler.md +489 -0
- package/dist/skills/editframe-editor-gui/references/timeline.md +604 -0
- package/dist/skills/editframe-editor-gui/references/toggle-loop.md +618 -0
- package/dist/skills/editframe-editor-gui/references/toggle-play.md +526 -0
- package/dist/skills/editframe-editor-gui/references/transform-handles.md +924 -0
- package/dist/skills/editframe-editor-gui/references/trim-handles.md +725 -0
- package/dist/skills/editframe-editor-gui/references/workbench.md +453 -0
- package/dist/skills/editframe-motion-design/SKILL.md +101 -0
- package/dist/skills/editframe-motion-design/references/0-editframe.md +299 -0
- package/dist/skills/editframe-motion-design/references/1-intent.md +201 -0
- package/dist/skills/editframe-motion-design/references/2-physics-model.md +405 -0
- package/dist/skills/editframe-motion-design/references/3-attention.md +350 -0
- package/dist/skills/editframe-motion-design/references/4-process.md +418 -0
- package/dist/skills/editframe-vite-plugin/SKILL.md +75 -0
- package/dist/skills/editframe-vite-plugin/references/file-api.md +111 -0
- package/dist/skills/editframe-vite-plugin/references/getting-started.md +96 -0
- package/dist/skills/editframe-vite-plugin/references/jit-transcoding.md +91 -0
- package/dist/skills/editframe-vite-plugin/references/local-assets.md +75 -0
- package/dist/skills/editframe-vite-plugin/references/visual-testing.md +136 -0
- package/dist/skills/editframe-webhooks/SKILL.md +126 -0
- package/dist/skills/editframe-webhooks/references/events.md +382 -0
- package/dist/skills/editframe-webhooks/references/getting-started.md +232 -0
- package/dist/skills/editframe-webhooks/references/security.md +418 -0
- package/dist/skills/editframe-webhooks/references/testing.md +409 -0
- package/dist/skills/editframe-webhooks/references/troubleshooting.md +457 -0
- package/dist/templates/html/AGENTS.md +13 -0
- package/dist/templates/react/AGENTS.md +13 -0
- package/dist/utils.js +15 -16
- package/dist/utils.js.map +1 -1
- package/package.json +2 -2
- package/tsdown.config.ts +4 -0
- package/dist/detectAgent.js +0 -89
- package/dist/detectAgent.js.map +0 -1
|
@@ -0,0 +1,810 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Package Entry Points
|
|
3
|
+
description: Complete guide to Editframe package entry points and exports — when to import from @editframe/elements vs @editframe/react vs core.
|
|
4
|
+
type: reference
|
|
5
|
+
nav:
|
|
6
|
+
parent: "Advanced"
|
|
7
|
+
priority: 40
|
|
8
|
+
api:
|
|
9
|
+
packages:
|
|
10
|
+
- name: "@editframe/elements"
|
|
11
|
+
exports:
|
|
12
|
+
- path: "."
|
|
13
|
+
description: Full browser package (Web Components, DOM APIs)
|
|
14
|
+
safe_in: ["browser"]
|
|
15
|
+
- path: "./server"
|
|
16
|
+
description: SSR-safe types and utilities (no DOM, no Web Components)
|
|
17
|
+
safe_in: ["browser", "node", "ssr"]
|
|
18
|
+
- path: "./node"
|
|
19
|
+
description: Node.js-safe types and utilities (alias for ./server)
|
|
20
|
+
safe_in: ["browser", "node", "ssr"]
|
|
21
|
+
- path: "./styles.css"
|
|
22
|
+
description: Component styles
|
|
23
|
+
safe_in: ["browser"]
|
|
24
|
+
- path: "./theme.css"
|
|
25
|
+
description: Theme variables (CSS custom properties)
|
|
26
|
+
safe_in: ["browser"]
|
|
27
|
+
- name: "@editframe/react"
|
|
28
|
+
exports:
|
|
29
|
+
- path: "."
|
|
30
|
+
description: Full browser package (all React components and hooks)
|
|
31
|
+
safe_in: ["browser"]
|
|
32
|
+
- path: "./server"
|
|
33
|
+
description: SSR-safe React composition components
|
|
34
|
+
safe_in: ["browser", "node", "ssr"]
|
|
35
|
+
- path: "./r3f"
|
|
36
|
+
description: React Three Fiber integration (browser-only)
|
|
37
|
+
safe_in: ["browser"]
|
|
38
|
+
react:
|
|
39
|
+
generate: true
|
|
40
|
+
componentName: "Package Entry Points"
|
|
41
|
+
importPath: "@editframe/react"
|
|
42
|
+
nav:
|
|
43
|
+
parent: "Advanced / Package Configuration"
|
|
44
|
+
priority: 90
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
# Package Entry Points
|
|
48
|
+
|
|
49
|
+
<!-- html-only -->
|
|
50
|
+
Editframe packages provide multiple entry points to support different environments: browser, server-side rendering (SSR), and Node.js. This guide explains what each entry point exports and when to use it.
|
|
51
|
+
<!-- /html-only -->
|
|
52
|
+
<!-- react-only -->
|
|
53
|
+
`@editframe/react` provides three entry points to support different environments and use cases.
|
|
54
|
+
<!-- /react-only -->
|
|
55
|
+
|
|
56
|
+
## @editframe/elements
|
|
57
|
+
|
|
58
|
+
The core Web Components package with four entry points:
|
|
59
|
+
|
|
60
|
+
### `.` (Main Entry)
|
|
61
|
+
|
|
62
|
+
**Path:** `@editframe/elements`
|
|
63
|
+
|
|
64
|
+
**Environment:** Browser only
|
|
65
|
+
|
|
66
|
+
**What's Included:**
|
|
67
|
+
- All Web Component class definitions (`<ef-timegroup>`, `<ef-video>`, etc.)
|
|
68
|
+
- DOM manipulation utilities
|
|
69
|
+
- Canvas and WebGL rendering code
|
|
70
|
+
- Video encoding (WebCodecs, FFmpeg.wasm)
|
|
71
|
+
- All browser-specific APIs
|
|
72
|
+
|
|
73
|
+
**Usage:**
|
|
74
|
+
```typescript
|
|
75
|
+
import { EFTimegroup } from "@editframe/elements";
|
|
76
|
+
import "@editframe/elements/styles.css";
|
|
77
|
+
|
|
78
|
+
const timegroup = document.createElement("ef-timegroup");
|
|
79
|
+
timegroup.setAttribute("mode", "sequence");
|
|
80
|
+
timegroup.setAttribute("duration", "10s");
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Do NOT use in:**
|
|
84
|
+
- Server-side rendering
|
|
85
|
+
- Node.js scripts
|
|
86
|
+
- Build tools (without DOM shims)
|
|
87
|
+
|
|
88
|
+
### `./server` (SSR Safe)
|
|
89
|
+
|
|
90
|
+
**Path:** `@editframe/elements/server`
|
|
91
|
+
|
|
92
|
+
**Environment:** Browser, Node.js, SSR
|
|
93
|
+
|
|
94
|
+
**What's Included:**
|
|
95
|
+
- TypeScript type definitions (zero runtime code)
|
|
96
|
+
- `getRenderInfo()` utility for extracting metadata from HTML
|
|
97
|
+
- Render option types (`RenderToVideoOptions`, `RenderProgress`, etc.)
|
|
98
|
+
|
|
99
|
+
**What's NOT Included:**
|
|
100
|
+
- Web Component definitions
|
|
101
|
+
- DOM APIs
|
|
102
|
+
- Canvas, WebGL, WebCodecs
|
|
103
|
+
- Any browser-specific code
|
|
104
|
+
|
|
105
|
+
**Usage:**
|
|
106
|
+
```typescript
|
|
107
|
+
// Safe in Node.js, SSR, and browser
|
|
108
|
+
import type { EFTimegroup, RenderToVideoOptions } from "@editframe/elements/server";
|
|
109
|
+
import { getRenderInfo } from "@editframe/elements/server";
|
|
110
|
+
|
|
111
|
+
const html = `<ef-timegroup mode="sequence" duration="10s">...</ef-timegroup>`;
|
|
112
|
+
const info = await getRenderInfo(html);
|
|
113
|
+
console.log(info.durationMs); // 10000
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Use when:**
|
|
117
|
+
- Building Node.js tools that need type information
|
|
118
|
+
- Server-side rendering with Next.js, Remix, etc.
|
|
119
|
+
- Static site generation
|
|
120
|
+
- Type-checking server code
|
|
121
|
+
|
|
122
|
+
### `./node` (Node.js Safe)
|
|
123
|
+
|
|
124
|
+
**Path:** `@editframe/elements/node`
|
|
125
|
+
|
|
126
|
+
**Environment:** Browser, Node.js, SSR
|
|
127
|
+
|
|
128
|
+
**What's Included:**
|
|
129
|
+
- Alias for `./server` (backward compatibility)
|
|
130
|
+
- Same exports as `./server`
|
|
131
|
+
|
|
132
|
+
**Usage:**
|
|
133
|
+
```typescript
|
|
134
|
+
import { getRenderInfo } from "@editframe/elements/node";
|
|
135
|
+
import type { EFTimegroup } from "@editframe/elements/node";
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Note:** Prefer `./server` for new code. This entry exists for backward compatibility with `@editframe/cli`.
|
|
139
|
+
|
|
140
|
+
### `./styles.css` (Component Styles)
|
|
141
|
+
|
|
142
|
+
**Path:** `@editframe/elements/styles.css`
|
|
143
|
+
|
|
144
|
+
**Environment:** Browser only
|
|
145
|
+
|
|
146
|
+
**What's Included:**
|
|
147
|
+
- Base styles for all Editframe elements
|
|
148
|
+
- Layout and positioning utilities
|
|
149
|
+
- Default visual appearance
|
|
150
|
+
|
|
151
|
+
**Usage:**
|
|
152
|
+
```typescript
|
|
153
|
+
// Vite, Webpack, etc.
|
|
154
|
+
import "@editframe/elements/styles.css";
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```html
|
|
158
|
+
<!-- Plain HTML -->
|
|
159
|
+
<link rel="stylesheet" href="/node_modules/@editframe/elements/dist/style.css">
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Note:** Required for proper element rendering. Import once in your application root.
|
|
163
|
+
|
|
164
|
+
### `./theme.css` (Theme Variables)
|
|
165
|
+
|
|
166
|
+
**Path:** `@editframe/elements/theme.css`
|
|
167
|
+
|
|
168
|
+
**Environment:** Browser only
|
|
169
|
+
|
|
170
|
+
**What's Included:**
|
|
171
|
+
- CSS custom properties for theming
|
|
172
|
+
- Color palette variables
|
|
173
|
+
- Spacing and typography scales
|
|
174
|
+
- Component-specific theme tokens
|
|
175
|
+
|
|
176
|
+
**Usage:**
|
|
177
|
+
```typescript
|
|
178
|
+
import "@editframe/elements/theme.css";
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
**Customization:**
|
|
182
|
+
```css
|
|
183
|
+
/* Override theme variables */
|
|
184
|
+
:root {
|
|
185
|
+
--ef-color-primary: #ff6b6b;
|
|
186
|
+
--ef-color-background: #1a1a1a;
|
|
187
|
+
--ef-spacing-unit: 8px;
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
**Note:** Optional. Only import if you're using GUI components (Workbench, Timeline, etc.) or want to customize the theme.
|
|
192
|
+
|
|
193
|
+
## @editframe/react
|
|
194
|
+
|
|
195
|
+
The React wrapper package with three entry points:
|
|
196
|
+
|
|
197
|
+
### `.` (Main Entry)
|
|
198
|
+
|
|
199
|
+
**Path:** `@editframe/react`
|
|
200
|
+
|
|
201
|
+
**Environment:** Browser only
|
|
202
|
+
|
|
203
|
+
**What's Included:**
|
|
204
|
+
<!-- html-only -->
|
|
205
|
+
- All React components (composition + GUI)
|
|
206
|
+
- All hooks (`useTimingInfo`, `usePlayback`, `usePanZoomTransform`, etc.)
|
|
207
|
+
- Browser-specific utilities
|
|
208
|
+
|
|
209
|
+
**Usage:**
|
|
210
|
+
```tsx
|
|
211
|
+
import {
|
|
212
|
+
Timegroup,
|
|
213
|
+
Video,
|
|
214
|
+
Audio,
|
|
215
|
+
Image,
|
|
216
|
+
Text,
|
|
217
|
+
Preview,
|
|
218
|
+
Workbench,
|
|
219
|
+
Timeline,
|
|
220
|
+
useTimingInfo,
|
|
221
|
+
usePlayback,
|
|
222
|
+
} from "@editframe/react";
|
|
223
|
+
|
|
224
|
+
export const VideoEditor = () => {
|
|
225
|
+
const { currentTimeMs, durationMs } = useTimingInfo();
|
|
226
|
+
|
|
227
|
+
return (
|
|
228
|
+
<Workbench rendering={false}>
|
|
229
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
230
|
+
<Video src="/intro.mp4" className="size-full" />
|
|
231
|
+
</Timegroup>
|
|
232
|
+
</Workbench>
|
|
233
|
+
);
|
|
234
|
+
};
|
|
235
|
+
```
|
|
236
|
+
<!-- /html-only -->
|
|
237
|
+
<!-- react-only -->
|
|
238
|
+
**Composition Components:**
|
|
239
|
+
- `Timegroup`, `Video`, `Audio`, `Image`
|
|
240
|
+
- `Text`, `TextSegment`
|
|
241
|
+
- `Captions` + sub-components
|
|
242
|
+
- `Surface`, `Waveform`, `PanZoom`
|
|
243
|
+
|
|
244
|
+
**GUI Components:**
|
|
245
|
+
- `Preview`, `Workbench`, `Controls`
|
|
246
|
+
- `Timeline`, `Filmstrip`, `TimelineRuler`
|
|
247
|
+
- `Scrubber`, `TimeDisplay`, `TrimHandles`
|
|
248
|
+
- `Canvas`, `TransformHandles`, `Hierarchy`
|
|
249
|
+
- `Play`, `Pause`, `TogglePlay`, `ToggleLoop`
|
|
250
|
+
- `OverlayLayer`, `OverlayItem`
|
|
251
|
+
- `FocusOverlay`, `FitScale`, `ActiveRootTemporal`
|
|
252
|
+
- `Dial`, `ResizableBox`
|
|
253
|
+
|
|
254
|
+
**Hooks:**
|
|
255
|
+
- `useTimingInfo`, `usePlayback`
|
|
256
|
+
- `usePanZoomTransform`, `useMediaInfo`
|
|
257
|
+
- All composition-related hooks
|
|
258
|
+
|
|
259
|
+
**Utilities:**
|
|
260
|
+
- `Configuration`, `TimelineRoot`
|
|
261
|
+
- Browser rendering utilities
|
|
262
|
+
|
|
263
|
+
### Basic Usage
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import {
|
|
267
|
+
Timegroup,
|
|
268
|
+
Video,
|
|
269
|
+
Audio,
|
|
270
|
+
Text,
|
|
271
|
+
Preview,
|
|
272
|
+
Workbench,
|
|
273
|
+
useTimingInfo,
|
|
274
|
+
} from "@editframe/react";
|
|
275
|
+
|
|
276
|
+
export const VideoEditor = () => {
|
|
277
|
+
const { currentTimeMs, durationMs } = useTimingInfo();
|
|
278
|
+
|
|
279
|
+
return (
|
|
280
|
+
<Workbench rendering={false}>
|
|
281
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
282
|
+
<Video src="/intro.mp4" className="size-full" />
|
|
283
|
+
<Audio src="/music.mp3" volume={0.3} />
|
|
284
|
+
<Text className="absolute inset-0 flex items-center justify-center text-6xl">
|
|
285
|
+
Hello World
|
|
286
|
+
</Text>
|
|
287
|
+
</Timegroup>
|
|
288
|
+
</Workbench>
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
### Do NOT Use In
|
|
294
|
+
|
|
295
|
+
- Server-side rendering (will crash)
|
|
296
|
+
- Node.js scripts
|
|
297
|
+
- React Server Components
|
|
298
|
+
<!-- /react-only -->
|
|
299
|
+
|
|
300
|
+
**Do NOT use in:**
|
|
301
|
+
- Server-side rendering (will crash)
|
|
302
|
+
- Node.js scripts
|
|
303
|
+
- React Server Components
|
|
304
|
+
|
|
305
|
+
### `./server` (SSR Safe)
|
|
306
|
+
|
|
307
|
+
**Path:** `@editframe/react/server`
|
|
308
|
+
|
|
309
|
+
**Environment:** Browser, Node.js, SSR
|
|
310
|
+
|
|
311
|
+
**What's Included:**
|
|
312
|
+
- Composition React components only:
|
|
313
|
+
- `Timegroup`, `Video`, `Audio`, `Image`, `Text`, `Captions`, `Surface`, `Waveform`, `PanZoom`
|
|
314
|
+
- Caption sub-components: `CaptionsActiveWord`, `CaptionsBeforeActiveWord`, etc.
|
|
315
|
+
- All types from `@editframe/elements/server`
|
|
316
|
+
|
|
317
|
+
**What's NOT Included:**
|
|
318
|
+
- GUI components (`Preview`, `Workbench`, `Timeline`, `Controls`, etc.)
|
|
319
|
+
- Hooks (`useTimingInfo`, `usePlayback`, etc.)
|
|
320
|
+
- Browser-specific utilities
|
|
321
|
+
|
|
322
|
+
**Usage:**
|
|
323
|
+
```tsx
|
|
324
|
+
// Safe in SSR
|
|
325
|
+
import { Timegroup, Video, Audio } from "@editframe/react/server";
|
|
326
|
+
|
|
327
|
+
export const VideoComposition = () => {
|
|
328
|
+
return (
|
|
329
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
330
|
+
<Video src="/intro.mp4" className="size-full" />
|
|
331
|
+
<Audio src="/music.mp3" volume={0.3} />
|
|
332
|
+
</Timegroup>
|
|
333
|
+
);
|
|
334
|
+
};
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Use when:**
|
|
338
|
+
- Server-side rendering (Next.js App Router, Remix loaders)
|
|
339
|
+
- Pre-rendering static HTML
|
|
340
|
+
- React Server Components
|
|
341
|
+
- Node.js rendering utilities
|
|
342
|
+
|
|
343
|
+
### `./r3f` (React Three Fiber)
|
|
344
|
+
|
|
345
|
+
**Path:** `@editframe/react/r3f`
|
|
346
|
+
|
|
347
|
+
**Environment:** Browser only
|
|
348
|
+
|
|
349
|
+
**What's Included:**
|
|
350
|
+
- `CompositionCanvas` - Main-thread R3F canvas with timeline sync
|
|
351
|
+
- `OffscreenCompositionCanvas` - Web worker R3F canvas
|
|
352
|
+
- `useCompositionTime()` - Hook to read timeline position in 3D scenes
|
|
353
|
+
- `renderOffscreen()` - Worker-side entry point for offscreen rendering
|
|
354
|
+
- Worker protocol types
|
|
355
|
+
|
|
356
|
+
**Usage:**
|
|
357
|
+
```tsx
|
|
358
|
+
import { Timegroup } from "@editframe/react";
|
|
359
|
+
import { CompositionCanvas, useCompositionTime } from "@editframe/react/r3f";
|
|
360
|
+
|
|
361
|
+
function RotatingBox() {
|
|
362
|
+
const { timeMs } = useCompositionTime();
|
|
363
|
+
return <box rotation={[0, timeMs / 1000, 0]} />;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export const Video = () => {
|
|
367
|
+
return (
|
|
368
|
+
<Timegroup mode="fixed" duration="10s" className="w-[1920px] h-[1080px]">
|
|
369
|
+
<CompositionCanvas shadows>
|
|
370
|
+
<RotatingBox />
|
|
371
|
+
</CompositionCanvas>
|
|
372
|
+
</Timegroup>
|
|
373
|
+
);
|
|
374
|
+
};
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Use when:**
|
|
378
|
+
- Rendering 3D scenes with React Three Fiber
|
|
379
|
+
- Creating 3D motion graphics
|
|
380
|
+
- Integrating Three.js with Editframe timelines
|
|
381
|
+
|
|
382
|
+
**Do NOT use in:**
|
|
383
|
+
- Server-side rendering
|
|
384
|
+
- Browsers without WebGL support
|
|
385
|
+
|
|
386
|
+
## Entry Point Decision Tree
|
|
387
|
+
|
|
388
|
+
### For Browser Applications
|
|
389
|
+
|
|
390
|
+
<!-- html-only -->
|
|
391
|
+
```
|
|
392
|
+
Do you need 3D rendering?
|
|
393
|
+
├─ Yes → @editframe/react/r3f
|
|
394
|
+
└─ No
|
|
395
|
+
├─ Using React?
|
|
396
|
+
│ └─ Yes → @editframe/react
|
|
397
|
+
└─ No (vanilla JS/TS)
|
|
398
|
+
└─ @editframe/elements
|
|
399
|
+
```
|
|
400
|
+
<!-- /html-only -->
|
|
401
|
+
<!-- react-only -->
|
|
402
|
+
```
|
|
403
|
+
Do you need 3D rendering?
|
|
404
|
+
├─ Yes → @editframe/react/r3f
|
|
405
|
+
└─ No → @editframe/react
|
|
406
|
+
```
|
|
407
|
+
<!-- /react-only -->
|
|
408
|
+
|
|
409
|
+
### For Server-Side Rendering
|
|
410
|
+
|
|
411
|
+
<!-- html-only -->
|
|
412
|
+
```
|
|
413
|
+
Do you need to render React components?
|
|
414
|
+
├─ Yes → @editframe/react/server
|
|
415
|
+
└─ No
|
|
416
|
+
├─ Need types only?
|
|
417
|
+
│ └─ Yes → @editframe/elements/server (type imports)
|
|
418
|
+
└─ Need getRenderInfo()?
|
|
419
|
+
└─ Yes → @editframe/elements/server
|
|
420
|
+
```
|
|
421
|
+
<!-- /html-only -->
|
|
422
|
+
<!-- react-only -->
|
|
423
|
+
```
|
|
424
|
+
Is this a Server Component / SSR function?
|
|
425
|
+
├─ Yes → @editframe/react/server
|
|
426
|
+
└─ No (Client Component)
|
|
427
|
+
├─ Need editor UI?
|
|
428
|
+
│ └─ Yes → @editframe/react (with dynamic import)
|
|
429
|
+
└─ Need composition only?
|
|
430
|
+
└─ Yes → @editframe/react/server
|
|
431
|
+
```
|
|
432
|
+
<!-- /react-only -->
|
|
433
|
+
|
|
434
|
+
### For Node.js Scripts
|
|
435
|
+
|
|
436
|
+
```
|
|
437
|
+
What do you need?
|
|
438
|
+
├─ Extract metadata from HTML → @editframe/elements/server (getRenderInfo)
|
|
439
|
+
├─ Type definitions → @editframe/elements/server (type imports)
|
|
440
|
+
└─ Render React to HTML → @editframe/react/server (with react-dom/server)
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Import Examples
|
|
444
|
+
|
|
445
|
+
### Browser App (React)
|
|
446
|
+
|
|
447
|
+
```tsx
|
|
448
|
+
// main.tsx
|
|
449
|
+
import "@editframe/elements/styles.css";
|
|
450
|
+
import "@editframe/elements/theme.css";
|
|
451
|
+
|
|
452
|
+
import {
|
|
453
|
+
Timegroup,
|
|
454
|
+
Video,
|
|
455
|
+
Audio,
|
|
456
|
+
Workbench,
|
|
457
|
+
useTimingInfo,
|
|
458
|
+
} from "@editframe/react";
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
<!-- html-only -->
|
|
462
|
+
### Browser App (Vanilla)
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
// main.ts
|
|
466
|
+
import "@editframe/elements/styles.css";
|
|
467
|
+
import { EFTimegroup, EFVideo } from "@editframe/elements";
|
|
468
|
+
|
|
469
|
+
const timegroup = document.createElement("ef-timegroup");
|
|
470
|
+
// ...
|
|
471
|
+
```
|
|
472
|
+
<!-- /html-only -->
|
|
473
|
+
|
|
474
|
+
### Next.js App Router (Server Component)
|
|
475
|
+
|
|
476
|
+
```tsx
|
|
477
|
+
// app/video/page.tsx
|
|
478
|
+
import { Timegroup, Video } from "@editframe/react/server";
|
|
479
|
+
|
|
480
|
+
export default function VideoPage() {
|
|
481
|
+
return (
|
|
482
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
483
|
+
<Video src="/video.mp4" className="size-full" />
|
|
484
|
+
</Timegroup>
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
### Next.js Pages Router (SSR + Client)
|
|
490
|
+
|
|
491
|
+
```tsx
|
|
492
|
+
// pages/editor.tsx
|
|
493
|
+
import dynamic from "next/dynamic";
|
|
494
|
+
import { Timegroup, Video } from "@editframe/react/server";
|
|
495
|
+
|
|
496
|
+
const Workbench = dynamic(
|
|
497
|
+
() => import("@editframe/react").then((m) => m.Workbench),
|
|
498
|
+
{ ssr: false }
|
|
499
|
+
);
|
|
500
|
+
|
|
501
|
+
export default function EditorPage() {
|
|
502
|
+
return (
|
|
503
|
+
<>
|
|
504
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
505
|
+
<Video src="/video.mp4" className="size-full" />
|
|
506
|
+
</Timegroup>
|
|
507
|
+
<Workbench rendering={false} />
|
|
508
|
+
</>
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Node.js Tool
|
|
514
|
+
|
|
515
|
+
```typescript
|
|
516
|
+
// build.ts
|
|
517
|
+
import { getRenderInfo } from "@editframe/elements/server";
|
|
518
|
+
import type { RenderInfo } from "@editframe/elements/server";
|
|
519
|
+
import { readFileSync } from "fs";
|
|
520
|
+
|
|
521
|
+
const html = readFileSync("./composition.html", "utf-8");
|
|
522
|
+
const info: RenderInfo = await getRenderInfo(html);
|
|
523
|
+
console.log(`Duration: ${info.durationMs}ms`);
|
|
524
|
+
console.log(`Size: ${info.width}x${info.height}`);
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### React + 3D Scene
|
|
528
|
+
|
|
529
|
+
```tsx
|
|
530
|
+
// Video.tsx
|
|
531
|
+
import { Timegroup } from "@editframe/react";
|
|
532
|
+
import { CompositionCanvas, useCompositionTime } from "@editframe/react/r3f";
|
|
533
|
+
|
|
534
|
+
function Scene() {
|
|
535
|
+
const { timeMs } = useCompositionTime();
|
|
536
|
+
return <box rotation={[0, timeMs / 1000, 0]} />;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
export const Video = () => {
|
|
540
|
+
return (
|
|
541
|
+
<Timegroup mode="fixed" duration="10s" className="w-[1920px] h-[1080px]">
|
|
542
|
+
<CompositionCanvas>
|
|
543
|
+
<Scene />
|
|
544
|
+
</CompositionCanvas>
|
|
545
|
+
</Timegroup>
|
|
546
|
+
);
|
|
547
|
+
};
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
<!-- react-only -->
|
|
551
|
+
### Browser App
|
|
552
|
+
|
|
553
|
+
```tsx
|
|
554
|
+
// main.tsx
|
|
555
|
+
import ReactDOM from "react-dom/client";
|
|
556
|
+
import {
|
|
557
|
+
Configuration,
|
|
558
|
+
TimelineRoot,
|
|
559
|
+
Timegroup,
|
|
560
|
+
Video,
|
|
561
|
+
Workbench,
|
|
562
|
+
} from "@editframe/react";
|
|
563
|
+
import "@editframe/elements/styles.css";
|
|
564
|
+
|
|
565
|
+
const Video = () => (
|
|
566
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
567
|
+
<Video src="/video.mp4" className="size-full" />
|
|
568
|
+
</Timegroup>
|
|
569
|
+
);
|
|
570
|
+
|
|
571
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
572
|
+
<Configuration mediaEngine="local">
|
|
573
|
+
<TimelineRoot id="root" component={Video} />
|
|
574
|
+
</Configuration>
|
|
575
|
+
);
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### SSR App (Next.js)
|
|
579
|
+
|
|
580
|
+
```tsx
|
|
581
|
+
// app/video/page.tsx (Server Component)
|
|
582
|
+
import { Timegroup, Video } from "@editframe/react/server";
|
|
583
|
+
|
|
584
|
+
export default function VideoPage() {
|
|
585
|
+
return (
|
|
586
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
587
|
+
<Video src="/video.mp4" className="size-full" />
|
|
588
|
+
</Timegroup>
|
|
589
|
+
);
|
|
590
|
+
}
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
### SSR App with Editor UI
|
|
594
|
+
|
|
595
|
+
```tsx
|
|
596
|
+
// pages/editor.tsx
|
|
597
|
+
import dynamic from "next/dynamic";
|
|
598
|
+
import { Timegroup, Video } from "@editframe/react/server";
|
|
599
|
+
|
|
600
|
+
const Workbench = dynamic(
|
|
601
|
+
() => import("@editframe/react").then((m) => m.Workbench),
|
|
602
|
+
{ ssr: false }
|
|
603
|
+
);
|
|
604
|
+
|
|
605
|
+
export default function EditorPage() {
|
|
606
|
+
return (
|
|
607
|
+
<>
|
|
608
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
609
|
+
<Video src="/video.mp4" className="size-full" />
|
|
610
|
+
</Timegroup>
|
|
611
|
+
<Workbench rendering={false} />
|
|
612
|
+
</>
|
|
613
|
+
);
|
|
614
|
+
}
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
### Node.js Pre-rendering
|
|
618
|
+
|
|
619
|
+
```typescript
|
|
620
|
+
// build.ts
|
|
621
|
+
import { renderToString } from "react-dom/server";
|
|
622
|
+
import { Timegroup, Video } from "@editframe/react/server";
|
|
623
|
+
import { writeFileSync } from "fs";
|
|
624
|
+
|
|
625
|
+
const composition = (
|
|
626
|
+
<Timegroup mode="sequence" className="w-[1920px] h-[1080px]">
|
|
627
|
+
<Video src="/video.mp4" className="size-full" />
|
|
628
|
+
</Timegroup>
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
const html = renderToString(composition);
|
|
632
|
+
writeFileSync("./dist/composition.html", html);
|
|
633
|
+
```
|
|
634
|
+
<!-- /react-only -->
|
|
635
|
+
|
|
636
|
+
## Package.json Exports (Technical Reference)
|
|
637
|
+
|
|
638
|
+
### @editframe/elements
|
|
639
|
+
|
|
640
|
+
```json
|
|
641
|
+
{
|
|
642
|
+
"name": "@editframe/elements",
|
|
643
|
+
"exports": {
|
|
644
|
+
".": {
|
|
645
|
+
"import": {
|
|
646
|
+
"types": "./dist/index.d.ts",
|
|
647
|
+
"default": "./dist/index.js"
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
"./server": {
|
|
651
|
+
"import": {
|
|
652
|
+
"types": "./dist/server.d.ts",
|
|
653
|
+
"default": "./dist/server.js"
|
|
654
|
+
}
|
|
655
|
+
},
|
|
656
|
+
"./node": {
|
|
657
|
+
"import": {
|
|
658
|
+
"types": "./dist/node.d.ts",
|
|
659
|
+
"default": "./dist/node.js"
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
"./styles.css": "./dist/style.css",
|
|
663
|
+
"./theme.css": "./dist/gui/ef-theme.css"
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
### @editframe/react
|
|
669
|
+
|
|
670
|
+
```json
|
|
671
|
+
{
|
|
672
|
+
"name": "@editframe/react",
|
|
673
|
+
"exports": {
|
|
674
|
+
".": {
|
|
675
|
+
"import": {
|
|
676
|
+
"types": "./dist/index.d.ts",
|
|
677
|
+
"default": "./dist/index.js"
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
"./server": {
|
|
681
|
+
"import": {
|
|
682
|
+
"types": "./dist/server.d.ts",
|
|
683
|
+
"default": "./dist/server.js"
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
"./r3f": {
|
|
687
|
+
"import": {
|
|
688
|
+
"types": "./dist/r3f/index.d.ts",
|
|
689
|
+
"default": "./dist/r3f/index.js"
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
## Common Errors and Solutions
|
|
697
|
+
|
|
698
|
+
### Error: `customElements is not defined`
|
|
699
|
+
|
|
700
|
+
**Problem:** Imported main entry during SSR.
|
|
701
|
+
|
|
702
|
+
**Solution:**
|
|
703
|
+
```typescript
|
|
704
|
+
// ❌ Wrong
|
|
705
|
+
import { Timegroup } from "@editframe/react";
|
|
706
|
+
|
|
707
|
+
// ✅ Correct
|
|
708
|
+
import { Timegroup } from "@editframe/react/server";
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
### Error: `Cannot find module '@editframe/react/server'`
|
|
712
|
+
|
|
713
|
+
**Problem:** Outdated package version (pre-0.37.0).
|
|
714
|
+
|
|
715
|
+
**Solution:**
|
|
716
|
+
```bash
|
|
717
|
+
npm install @editframe/react@latest
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
### Error: Module not found in Vite/Webpack
|
|
721
|
+
|
|
722
|
+
**Problem:** Bundler doesn't recognize subpath exports.
|
|
723
|
+
|
|
724
|
+
**Solution:** Update bundler configuration or use newer versions (Vite 3+, Webpack 5+).
|
|
725
|
+
|
|
726
|
+
### Import CSS files in TypeScript
|
|
727
|
+
|
|
728
|
+
**Problem:** TypeScript complains about CSS imports.
|
|
729
|
+
|
|
730
|
+
**Solution:**
|
|
731
|
+
```typescript
|
|
732
|
+
// Add declaration file
|
|
733
|
+
// src/global.d.ts
|
|
734
|
+
declare module "*.css" {
|
|
735
|
+
const content: string;
|
|
736
|
+
export default content;
|
|
737
|
+
}
|
|
738
|
+
```
|
|
739
|
+
|
|
740
|
+
<!-- react-only -->
|
|
741
|
+
### Error: GUI component not found in `/server`
|
|
742
|
+
|
|
743
|
+
**Problem:** Trying to import GUI component from SSR entry.
|
|
744
|
+
|
|
745
|
+
**Solution:** Use dynamic import:
|
|
746
|
+
```tsx
|
|
747
|
+
const Workbench = dynamic(
|
|
748
|
+
() => import("@editframe/react").then((m) => m.Workbench),
|
|
749
|
+
{ ssr: false }
|
|
750
|
+
);
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
### Error: `window is not defined`
|
|
754
|
+
|
|
755
|
+
**Problem:** Browser code running on server.
|
|
756
|
+
|
|
757
|
+
**Solution:** Check environment:
|
|
758
|
+
```tsx
|
|
759
|
+
if (typeof window !== "undefined") {
|
|
760
|
+
// Browser-only code
|
|
761
|
+
}
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
## Comparison with @editframe/elements
|
|
765
|
+
|
|
766
|
+
`@editframe/react` wraps `@editframe/elements` Web Components:
|
|
767
|
+
|
|
768
|
+
| @editframe/elements | @editframe/react | Environment |
|
|
769
|
+
|---------------------|------------------|-------------|
|
|
770
|
+
| `.` | `.` | Browser |
|
|
771
|
+
| `./server` | `./server` | Browser, Node, SSR |
|
|
772
|
+
| `./node` | N/A | Browser, Node, SSR |
|
|
773
|
+
| N/A | `./r3f` | Browser |
|
|
774
|
+
| `./styles.css` | N/A | Browser |
|
|
775
|
+
| `./theme.css` | N/A | Browser |
|
|
776
|
+
|
|
777
|
+
Import CSS from `@editframe/elements`:
|
|
778
|
+
```tsx
|
|
779
|
+
import "@editframe/elements/styles.css";
|
|
780
|
+
import "@editframe/elements/theme.css"; // Optional
|
|
781
|
+
```
|
|
782
|
+
|
|
783
|
+
## Type-Only Imports
|
|
784
|
+
|
|
785
|
+
Always safe in any environment:
|
|
786
|
+
|
|
787
|
+
```typescript
|
|
788
|
+
import type {
|
|
789
|
+
TimegroupProps,
|
|
790
|
+
VideoProps,
|
|
791
|
+
RenderToVideoOptions,
|
|
792
|
+
} from "@editframe/react/server";
|
|
793
|
+
|
|
794
|
+
function createVideoProps(): VideoProps {
|
|
795
|
+
return {
|
|
796
|
+
src: "/video.mp4",
|
|
797
|
+
className: "size-full",
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
```
|
|
801
|
+
<!-- /react-only -->
|
|
802
|
+
|
|
803
|
+
## Related
|
|
804
|
+
|
|
805
|
+
- [server-rendering.md](references/server-rendering.md) - SSR integration guide
|
|
806
|
+
- [r3f.md](references/r3f.md) - React Three Fiber integration
|
|
807
|
+
<!-- react-only -->
|
|
808
|
+
- [configuration.md](references/configuration.md) - Configuration component
|
|
809
|
+
<!-- /react-only -->
|
|
810
|
+
- [getting-started.md](references/getting-started.md) - Installation and setup
|