@interlacejs/editor 1.0.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/dist/index.cjs +3405 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +582 -0
- package/dist/index.d.ts +582 -0
- package/dist/index.js +3380 -0
- package/dist/index.js.map +1 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { Strings, ContentTypeRegistry, SerializedInteractiveMediaDocument, Placement, ContentInstance, Hook } from '@interlacejs/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Localized strings consumed by `PreviewModal`. Extends the core
|
|
7
|
+
* `Strings` so a host passing a single translation table covers every
|
|
8
|
+
* editor surface. The fields below are the ones specific to the
|
|
9
|
+
* preview modal; everything else (cancel, close, content error, …)
|
|
10
|
+
* is inherited from `Strings`.
|
|
11
|
+
*/
|
|
12
|
+
interface PreviewModalStrings extends Strings {
|
|
13
|
+
/** Heading shown at the top of the modal. */
|
|
14
|
+
title: string;
|
|
15
|
+
/** Shown while the player is initializing. */
|
|
16
|
+
loadingLabel: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The current video source value held by `VideoSourceInput`. `duration` is
|
|
21
|
+
* optional because the editor usually learns it from the host's `<video>`
|
|
22
|
+
* element after the URL resolves; the component only writes `src` directly.
|
|
23
|
+
*/
|
|
24
|
+
interface VideoSourceValue {
|
|
25
|
+
src?: string;
|
|
26
|
+
duration?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Localized strings consumed by `VideoSourceInput`. Extends the core
|
|
30
|
+
* `Strings` so a host passing a single translation table covers every
|
|
31
|
+
* editor surface. The fields below are the ones specific to the
|
|
32
|
+
* video-source step; everything else (cancel, close, content error, …)
|
|
33
|
+
* is inherited from `Strings`.
|
|
34
|
+
*/
|
|
35
|
+
interface VideoSourceInputStrings extends Strings {
|
|
36
|
+
/** Heading for the file upload row. */
|
|
37
|
+
uploadLabel: string;
|
|
38
|
+
/** Label for the trigger button that opens the native file picker. */
|
|
39
|
+
uploadButtonLabel: string;
|
|
40
|
+
/** Shown next to the button while a file is being uploaded. */
|
|
41
|
+
uploadingLabel: string;
|
|
42
|
+
/** Inline error text shown when the upload promise rejects. */
|
|
43
|
+
uploadFailedLabel: string;
|
|
44
|
+
/** Label for the button that re-opens the file picker after a failure. */
|
|
45
|
+
retryLabel: string;
|
|
46
|
+
/** Label for the "direct URL" text input. */
|
|
47
|
+
urlLabel: string;
|
|
48
|
+
/** Placeholder for the URL text input. */
|
|
49
|
+
urlPlaceholder: string;
|
|
50
|
+
/** Label for the button that commits the URL draft. */
|
|
51
|
+
applyUrlLabel: string;
|
|
52
|
+
/** Shown when no video source has been chosen yet. */
|
|
53
|
+
noVideoSelectedLabel: string;
|
|
54
|
+
/** Shown above a known video URL. */
|
|
55
|
+
currentSourceLabel: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Defaults are derived from core's `DEFAULT_STRINGS` so a host that
|
|
59
|
+
* overrides the core base gets matching inheritance automatically; the
|
|
60
|
+
* video-source-specific fields are filled in alongside.
|
|
61
|
+
*/
|
|
62
|
+
declare const DEFAULT_VIDEO_SOURCE_INPUT_STRINGS: VideoSourceInputStrings;
|
|
63
|
+
interface VideoSourceInputProps {
|
|
64
|
+
/**
|
|
65
|
+
* The current video source, if any. When `value.src` is set, the
|
|
66
|
+
* component displays the existing source above the inputs and treats the
|
|
67
|
+
* URL draft as a *replacement* candidate. When it is absent, the
|
|
68
|
+
* component behaves as the very first step of a new document.
|
|
69
|
+
*/
|
|
70
|
+
value?: VideoSourceValue;
|
|
71
|
+
/**
|
|
72
|
+
* Called when a usable video URL is ready, whether the user pasted it
|
|
73
|
+
* directly or an upload promise resolved. The component awaits the
|
|
74
|
+
* upload promise itself; the host is only ever handed a URL.
|
|
75
|
+
*/
|
|
76
|
+
onChange: (next: {
|
|
77
|
+
src: string;
|
|
78
|
+
duration?: number;
|
|
79
|
+
}) => void;
|
|
80
|
+
/**
|
|
81
|
+
* Host-supplied upload callback. The component awaits this promise; the
|
|
82
|
+
* resolved string is written into the document. A rejection is surfaced
|
|
83
|
+
* via the inline error state and (optionally) `onError` — it does not
|
|
84
|
+
* crash the authoring flow.
|
|
85
|
+
*/
|
|
86
|
+
onUpload: (file: File) => Promise<string>;
|
|
87
|
+
/** Optional callback for upload promise rejections. */
|
|
88
|
+
onError?: (error: Error) => void;
|
|
89
|
+
/** Optional string overrides. */
|
|
90
|
+
strings?: Partial<VideoSourceInputStrings>;
|
|
91
|
+
/** Disables both the URL and file controls. */
|
|
92
|
+
disabled?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* VideoSourceInput - the first step of a new document's authoring flow.
|
|
96
|
+
* Accepts either a direct URL or a file. When a file is provided, the
|
|
97
|
+
* host's `onUpload` callback is invoked and the component awaits the
|
|
98
|
+
* resolved URL before calling `onChange`. Loading and failure states are
|
|
99
|
+
* surfaced inline without crashing the surrounding authoring flow.
|
|
100
|
+
*
|
|
101
|
+
* Token discipline: every file selection bumps an internal counter; if a
|
|
102
|
+
* later selection starts (or the component unmounts) before the previous
|
|
103
|
+
* upload resolves, the stale result is dropped. This prevents a slow
|
|
104
|
+
* upload from overwriting the URL of a fast one chosen after it, and
|
|
105
|
+
* prevents a late resolution from committing into a torn-down tree.
|
|
106
|
+
*/
|
|
107
|
+
declare function VideoSourceInput({ value, onChange, onUpload, onError, strings: stringsOverride, disabled, }: VideoSourceInputProps): React__default.JSX.Element;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Editor-local strings layered on top of the core `Strings`. Hosts pass
|
|
111
|
+
* `strings?: Partial<EditorStrings>` and may override any subset of the
|
|
112
|
+
* fields; the rest fall back to the defaults exported alongside.
|
|
113
|
+
*/
|
|
114
|
+
interface EditorStrings extends Strings {
|
|
115
|
+
/** Heading for the video source step when no document is loaded. */
|
|
116
|
+
videoSourceInputTitle: string;
|
|
117
|
+
/** Title for the preview surface. */
|
|
118
|
+
previewTitle: string;
|
|
119
|
+
/** Label for the button that opens the preview modal. */
|
|
120
|
+
previewLabel: string;
|
|
121
|
+
/** Label for the button that re-opens the video source step on an existing document. */
|
|
122
|
+
replaceVideoLabel: string;
|
|
123
|
+
/** Label for the button that aborts a replace and returns to the authoring surface. */
|
|
124
|
+
replaceCancelLabel: string;
|
|
125
|
+
/** Label for the button that triggers `onSave`. */
|
|
126
|
+
saveLabel: string;
|
|
127
|
+
/** Shown when no item is selected for placement editing. */
|
|
128
|
+
noItemSelectedLabel: string;
|
|
129
|
+
/**
|
|
130
|
+
* Heading for the placement editor section.
|
|
131
|
+
*
|
|
132
|
+
* @deprecated Unused since the placement editor became a video-frame
|
|
133
|
+
* overlay (there is no separate placement section to head). Retained
|
|
134
|
+
* for backward compatibility with hosts passing
|
|
135
|
+
* `strings.placementLabel`. Will be removed in a future major.
|
|
136
|
+
*/
|
|
137
|
+
placementLabel: string;
|
|
138
|
+
/** Heading for the timeline area. */
|
|
139
|
+
timelineHeading: string;
|
|
140
|
+
/**
|
|
141
|
+
* Heading for the add-content area.
|
|
142
|
+
*
|
|
143
|
+
* @deprecated Unused since the content type picker moved into the
|
|
144
|
+
* Hook details panel. Retained for backward compatibility with hosts
|
|
145
|
+
* passing `strings.addContentHeading`. Will be removed in a future
|
|
146
|
+
* major.
|
|
147
|
+
*/
|
|
148
|
+
addContentHeading: string;
|
|
149
|
+
/** Heading for the Hook section (shown when a hook is selected). */
|
|
150
|
+
hookHeading: string;
|
|
151
|
+
/** Heading for the inline content editor subsection of the Hook section. */
|
|
152
|
+
contentEditorHeading: string;
|
|
153
|
+
/**
|
|
154
|
+
* Label for the button that opens the content editor slot.
|
|
155
|
+
*
|
|
156
|
+
* @deprecated Unused since the slot opens on entry selection. Retained
|
|
157
|
+
* for backward compatibility with hosts passing `strings.editContentLabel`
|
|
158
|
+
* at the 1.0 API freeze. Will be removed in a future major.
|
|
159
|
+
*/
|
|
160
|
+
editContentLabel: string;
|
|
161
|
+
/** Shown when a host-supplied onError fires during a load failure. */
|
|
162
|
+
loadErrorTitle: string;
|
|
163
|
+
/** Shown when the video element has not yet reported a duration. */
|
|
164
|
+
durationUnknownLabel: string;
|
|
165
|
+
/**
|
|
166
|
+
* String overrides forwarded to the embedded `VideoSourceInput`. The
|
|
167
|
+
* first screen of the drop-in component is otherwise unreachable to a
|
|
168
|
+
* host passing `strings`. Any field omitted falls back to
|
|
169
|
+
* `DEFAULT_VIDEO_SOURCE_INPUT_STRINGS` in `VideoSourceInput`.
|
|
170
|
+
*/
|
|
171
|
+
videoSource?: Partial<VideoSourceInputStrings>;
|
|
172
|
+
/**
|
|
173
|
+
* String overrides forwarded to the preview modal. Any field omitted
|
|
174
|
+
* falls back to `DEFAULT_PREVIEW_MODAL_STRINGS` in `PreviewModal`.
|
|
175
|
+
*/
|
|
176
|
+
previewModal?: Partial<PreviewModalStrings>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Defaults are derived from core's `DEFAULT_STRINGS` so a host that
|
|
180
|
+
* overrides the core base gets matching inheritance automatically. The
|
|
181
|
+
* editor-specific fields are filled in alongside.
|
|
182
|
+
*/
|
|
183
|
+
declare const DEFAULT_EDITOR_STRINGS: EditorStrings;
|
|
184
|
+
/**
|
|
185
|
+
* Optional theme overrides. Hosts that want to recolor the editor without
|
|
186
|
+
* shipping a CSS file can pass a `theme`; the editor applies these via
|
|
187
|
+
* inline `style` on its root wrapper and on the save button. Anything not
|
|
188
|
+
* provided falls back to a neutral default.
|
|
189
|
+
*/
|
|
190
|
+
interface EditorTheme {
|
|
191
|
+
accentColor?: string;
|
|
192
|
+
backgroundColor?: string;
|
|
193
|
+
surfaceColor?: string;
|
|
194
|
+
borderColor?: string;
|
|
195
|
+
textColor?: string;
|
|
196
|
+
mutedTextColor?: string;
|
|
197
|
+
}
|
|
198
|
+
interface InterlaceEditorProps {
|
|
199
|
+
/** Registry of content types available for authoring. */
|
|
200
|
+
contentTypeRegistry: ContentTypeRegistry;
|
|
201
|
+
/**
|
|
202
|
+
* Optional serialized document. Omit for a brand-new document (the
|
|
203
|
+
* editor shows the video source step first). Provide to edit an
|
|
204
|
+
* existing document; the editor calls `deserialize()` + `validate()`
|
|
205
|
+
* on mount and surfaces any warnings via `onError`.
|
|
206
|
+
*/
|
|
207
|
+
document?: SerializedInteractiveMediaDocument;
|
|
208
|
+
/**
|
|
209
|
+
* Host-supplied upload callback. Called by the video source step when
|
|
210
|
+
* the user selects a file. The resolved URL is written into the
|
|
211
|
+
* document; the host owns persistence.
|
|
212
|
+
*/
|
|
213
|
+
onUpload: (file: File) => Promise<string>;
|
|
214
|
+
/**
|
|
215
|
+
* Receives `authoringStore.serialize()`'s output on save. The host
|
|
216
|
+
* owns persistence — the editor never persists on its own.
|
|
217
|
+
*/
|
|
218
|
+
onSave: (doc: SerializedInteractiveMediaDocument) => void;
|
|
219
|
+
/** Optional string overrides. */
|
|
220
|
+
strings?: Partial<EditorStrings>;
|
|
221
|
+
/** Optional theme overrides. */
|
|
222
|
+
theme?: EditorTheme;
|
|
223
|
+
/** Optional error callback for upload, load, and runtime failures. */
|
|
224
|
+
onError?: (error: Error) => void;
|
|
225
|
+
/**
|
|
226
|
+
* Host-level adapter type. Defaults to `"native"`. **Not** persisted
|
|
227
|
+
* into the core serialized document; the host must re-supply this on
|
|
228
|
+
* reload. The editor does not pass it to `serialize()`.
|
|
229
|
+
*/
|
|
230
|
+
adapterType?: string;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* InterlaceEditor - the top-level component a host app actually renders
|
|
234
|
+
* to author an interactive video document. Mirrors `InteractiveVideoPlayer`
|
|
235
|
+
* on the player side: it is the single drop-in surface for the editor.
|
|
236
|
+
*
|
|
237
|
+
* The component composes:
|
|
238
|
+
* - `VideoSourceInput` (shown first when the document has no video source)
|
|
239
|
+
* - An authoring-time video surface (a `<video>` element) used by the
|
|
240
|
+
* placement editor (Phase 3) and the timeline playhead (Phase 4)
|
|
241
|
+
* - `PreviewModal` for the gated "what students will see" surface
|
|
242
|
+
* (replaces the prior always-on preview). The modal mounts
|
|
243
|
+
* `InteractiveVideoPlayer` + a fresh `NativeVideoAdapter` over its
|
|
244
|
+
* own `<video>`, so the student view and the authoring view are
|
|
245
|
+
* decoupled.
|
|
246
|
+
* - `KeyframeTimeline` for keyframe-style hook CRUD
|
|
247
|
+
* - `PlacementEditor` for the selected item's placement
|
|
248
|
+
* - `InspectorPanel` (Hook details) plus the inline `ContentTypeEditor`
|
|
249
|
+
* for editing the selected hook; new hooks are added at the playhead
|
|
250
|
+
* and re-typed from Hook details
|
|
251
|
+
*
|
|
252
|
+
* Behavior:
|
|
253
|
+
* - Video duration is captured from the preview `<video>`'s
|
|
254
|
+
* `loadedmetadata` and pushed into the store so the serialized
|
|
255
|
+
* document is not stale.
|
|
256
|
+
* - A "Replace video" button re-opens the source step in replace mode.
|
|
257
|
+
* - A "Preview" button opens the modal; opening the modal pauses the
|
|
258
|
+
* authoring video so the two surfaces do not play in parallel.
|
|
259
|
+
* - `adapterType` is a host-level prop (default `"native"`); it is not
|
|
260
|
+
* written into the serialized document.
|
|
261
|
+
*/
|
|
262
|
+
declare function InterlaceEditor({ contentTypeRegistry, document, onUpload, onSave, strings: stringsOverride, theme, onError, }: InterlaceEditorProps): React.JSX.Element;
|
|
263
|
+
|
|
264
|
+
interface ContentTypeEditorProps<TData = unknown> {
|
|
265
|
+
/** The content type to mount, or `null` while the hook has no content type yet. */
|
|
266
|
+
contentTypeId: string | null;
|
|
267
|
+
registry: ContentTypeRegistry;
|
|
268
|
+
data: TData;
|
|
269
|
+
onChange: (newData: TData) => void;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* ContentTypeEditor - the inline, chrome-free surface that mounts a
|
|
273
|
+
* content type's own editing interface (`renderEditor` /
|
|
274
|
+
* `updateEditor` / `unmount` via the shared
|
|
275
|
+
* `useContentTypeEditorMount` lifecycle).
|
|
276
|
+
*
|
|
277
|
+
* Renders nothing while `contentTypeId` is null (a newly created hook
|
|
278
|
+
* without a content type yet) or when the type is not registered —
|
|
279
|
+
* callers label the subsection and decide visibility.
|
|
280
|
+
*/
|
|
281
|
+
declare function ContentTypeEditor<TData = unknown>({ contentTypeId, registry, data, onChange, }: ContentTypeEditorProps<TData>): React__default.JSX.Element | null;
|
|
282
|
+
|
|
283
|
+
interface ContentTypeEditorSlotProps<TData = unknown> {
|
|
284
|
+
contentTypeId: string | null;
|
|
285
|
+
isOpen: boolean;
|
|
286
|
+
onClose: () => void;
|
|
287
|
+
onSave?: (data: TData) => void;
|
|
288
|
+
registry: ContentTypeRegistry;
|
|
289
|
+
data: TData;
|
|
290
|
+
onChange: (newData: TData) => void;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* ContentTypeEditorSlot - modal that mounts the content type's own
|
|
294
|
+
* editing interface via `renderEditor` / `updateEditor` / `unmount`.
|
|
295
|
+
*
|
|
296
|
+
* @deprecated The editor's own composition no longer opens this modal —
|
|
297
|
+
* the content editor renders inline under the timeline
|
|
298
|
+
* (`ContentTypeEditor`). Retained for hosts composing their own modal
|
|
299
|
+
* UX. Will be reconsidered at the next major.
|
|
300
|
+
*/
|
|
301
|
+
declare function ContentTypeEditorSlot<TData = unknown>({ contentTypeId, isOpen, onClose, onSave, registry, data, onChange, }: ContentTypeEditorSlotProps<TData>): React__default.JSX.Element | null;
|
|
302
|
+
|
|
303
|
+
interface ContentTypePickerProps {
|
|
304
|
+
registeredTypes: string[];
|
|
305
|
+
selectedType: string | null;
|
|
306
|
+
onSelect: (typeId: string) => void;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* ContentTypePicker - dropdown for selecting content type when creating new content.
|
|
310
|
+
*/
|
|
311
|
+
declare const ContentTypePicker: React__default.FC<ContentTypePickerProps>;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* PlacementEditor - an overlay for positioning a hook's placement
|
|
315
|
+
* rectangle on the video frame. Must be stacked (via a `position:
|
|
316
|
+
* relative` container) directly on top of a `<video>` element; the
|
|
317
|
+
* overlay maps placement percentages against its *own* rendered box,
|
|
318
|
+
* which equals the video frame when the container hugs the video.
|
|
319
|
+
*
|
|
320
|
+
* Interaction model:
|
|
321
|
+
* - Drag the rectangle to move it (pointer capture keeps the drag
|
|
322
|
+
* alive when the pointer leaves the frame, so the bounds clamps
|
|
323
|
+
* are reachable by overshooting past the video edge).
|
|
324
|
+
* - Drag any of the 8 handles (4 corners + 4 edges) to resize. The
|
|
325
|
+
* opposite edge stays anchored on west/north handles.
|
|
326
|
+
* - Arrow keys on the focused rectangle nudge by 1% (5% with Shift).
|
|
327
|
+
* - The X/Y/W/H numerical inputs clamp through the same policy as
|
|
328
|
+
* the pointer paths.
|
|
329
|
+
*
|
|
330
|
+
* Clamping policy (`clampPlacement`): move keeps the rectangle fully
|
|
331
|
+
* inside the frame; resize keeps the origin anchored and enforces a
|
|
332
|
+
* minimum size so a hook can never be resized into invisibility.
|
|
333
|
+
*/
|
|
334
|
+
interface PlacementEditorProps {
|
|
335
|
+
placement: Placement;
|
|
336
|
+
onPlacementChange: (placement: Placement) => void;
|
|
337
|
+
}
|
|
338
|
+
/** Minimum rectangle size in percent of the frame, per axis. */
|
|
339
|
+
declare const PLACEMENT_MIN_SIZE = 1;
|
|
340
|
+
type DragIntent = "move" | "resize";
|
|
341
|
+
/**
|
|
342
|
+
* Centralized bounds policy for every placement change path (drag,
|
|
343
|
+
* handles, keyboard nudge, numerical inputs).
|
|
344
|
+
*
|
|
345
|
+
* - "move": the rectangle must stay fully inside the frame —
|
|
346
|
+
* `x ∈ [0, 100 − width]`, `y ∈ [0, 100 − height]`.
|
|
347
|
+
* - "resize": the origin stays anchored —
|
|
348
|
+
* `width ∈ [MIN, 100 − x]`, `height ∈ [MIN, 100 − y]`. An
|
|
349
|
+
* out-of-range origin (possible from a loaded document with bad
|
|
350
|
+
* data) is repaired first so both the bounds and the minimum size
|
|
351
|
+
* can hold simultaneously.
|
|
352
|
+
*/
|
|
353
|
+
declare function clampPlacement(next: Placement, intent: DragIntent): Placement;
|
|
354
|
+
/**
|
|
355
|
+
* PlacementEditor overlay. See the interface doc for the interaction
|
|
356
|
+
* model. All %↔pixel conversion happens against this component's own
|
|
357
|
+
* frame layer (`getBoundingClientRect`), which equals the video frame
|
|
358
|
+
* when the parent stacks it over the video with `position: relative`.
|
|
359
|
+
*/
|
|
360
|
+
declare const PlacementEditor: React__default.FC<PlacementEditorProps>;
|
|
361
|
+
interface PlacementInputsProps {
|
|
362
|
+
placement: Placement;
|
|
363
|
+
onPlacementChange: (placement: Placement) => void;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* PlacementInputs - numerical X/Y/W/H editor for a placement. Lives
|
|
367
|
+
* separately from `PlacementEditor` so the overlay frame does not have
|
|
368
|
+
* to host a control panel that would otherwise occlude the video's
|
|
369
|
+
* native controls. Hosts render this in their own toolbar (the
|
|
370
|
+
* editor's `InterlaceEditor` puts it in a row below the video toolbar;
|
|
371
|
+
* standalone hosts compose it however they like).
|
|
372
|
+
*
|
|
373
|
+
* X/Y edits use the "move" policy (position clamped so the rect stays
|
|
374
|
+
* inside the frame). W/H edits use the "resize" policy (size clamped,
|
|
375
|
+
* with the 1% minimum).
|
|
376
|
+
*/
|
|
377
|
+
declare const PlacementInputs: React__default.FC<PlacementInputsProps>;
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Localized strings consumed by `InspectorPanel`. Extends the core
|
|
381
|
+
* `Strings` so a host passing a single translation table covers every
|
|
382
|
+
* editor surface.
|
|
383
|
+
*/
|
|
384
|
+
interface InspectorPanelStrings extends Strings {
|
|
385
|
+
/** Heading for the panel. */
|
|
386
|
+
inspectorHeading: string;
|
|
387
|
+
/** Label above the title input. */
|
|
388
|
+
titleLabel: string;
|
|
389
|
+
/** Label for the delete button. */
|
|
390
|
+
deleteLabel: string;
|
|
391
|
+
/** Label for the read-only hook-type row. */
|
|
392
|
+
hookTypeLabel: string;
|
|
393
|
+
/** Rendered value for a blocking hook's type row. */
|
|
394
|
+
blockingTypeLabel: string;
|
|
395
|
+
/** Rendered value for a non-blocking hook's type row. */
|
|
396
|
+
nonBlockingTypeLabel: string;
|
|
397
|
+
/** Label above the blocking hook's timestamp input. */
|
|
398
|
+
timestampLabel: string;
|
|
399
|
+
/** Label above a non-blocking hook's start input. */
|
|
400
|
+
startLabel: string;
|
|
401
|
+
/** Label above a non-blocking hook's end input. */
|
|
402
|
+
endLabel: string;
|
|
403
|
+
/** Label above the placement inputs. */
|
|
404
|
+
placementLabel: string;
|
|
405
|
+
/** Label above the content type row. */
|
|
406
|
+
contentTypeLabel: string;
|
|
407
|
+
}
|
|
408
|
+
declare const DEFAULT_INSPECTOR_PANEL_STRINGS: InspectorPanelStrings;
|
|
409
|
+
interface InspectorPanelEntry {
|
|
410
|
+
id: string;
|
|
411
|
+
title: string;
|
|
412
|
+
hookType: "blocking" | "non-blocking";
|
|
413
|
+
/** Anchor time for a blocking hook (seconds). */
|
|
414
|
+
timestamp?: number;
|
|
415
|
+
/** Range start for a non-blocking hook (seconds). */
|
|
416
|
+
start?: number;
|
|
417
|
+
/** Range end for a non-blocking hook (seconds). */
|
|
418
|
+
end?: number;
|
|
419
|
+
/** Total video duration (bounds for the time inputs). */
|
|
420
|
+
videoDuration: number;
|
|
421
|
+
/**
|
|
422
|
+
* The hook's resolved content type id, or `null` while the hook is
|
|
423
|
+
* pending (newly created, content type not yet chosen).
|
|
424
|
+
*/
|
|
425
|
+
contentTypeId: string | null;
|
|
426
|
+
/** Registered content type ids (drives the picker for pending hooks). */
|
|
427
|
+
registeredTypes: string[];
|
|
428
|
+
}
|
|
429
|
+
interface InspectorPanelProps {
|
|
430
|
+
entry: InspectorPanelEntry;
|
|
431
|
+
onTitleChange: (title: string) => void;
|
|
432
|
+
onTimeChange: (updates: {
|
|
433
|
+
timestamp?: number;
|
|
434
|
+
start?: number;
|
|
435
|
+
end?: number;
|
|
436
|
+
}) => void;
|
|
437
|
+
/** Called when a pending hook's content type is chosen (materializes it). */
|
|
438
|
+
onContentTypeSelect: (contentTypeId: string) => void;
|
|
439
|
+
placement?: Placement;
|
|
440
|
+
onPlacementChange?: (placement: Placement) => void;
|
|
441
|
+
onDelete: () => void;
|
|
442
|
+
strings?: Partial<InspectorPanelStrings>;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* InspectorPanel - the "Hook details" panel for the currently selected
|
|
446
|
+
* hook. Shows the title input, the read-only hook type, editable
|
|
447
|
+
* time/timespan inputs, the manual placement inputs, the content type
|
|
448
|
+
* (a picker for pending hooks; read-only for hooks that already have
|
|
449
|
+
* one — switching an existing hook's type would discard its authored
|
|
450
|
+
* data), and the delete action.
|
|
451
|
+
*
|
|
452
|
+
* The content *editing* surface itself lives in the inline
|
|
453
|
+
* `ContentTypeEditor`, rendered by `InterlaceEditor` directly under
|
|
454
|
+
* this panel when the hook has a content type.
|
|
455
|
+
*/
|
|
456
|
+
declare const InspectorPanel: React__default.FC<InspectorPanelProps>;
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Localized strings consumed by `KeyframeTimeline`. Extends the core
|
|
460
|
+
* `Strings` so a host passing a single translation table covers every
|
|
461
|
+
* editor surface.
|
|
462
|
+
*/
|
|
463
|
+
interface KeyframeTimelineStrings extends Strings {
|
|
464
|
+
/** Label for the "add blocking hook at playhead" button. */
|
|
465
|
+
addBlockingLabel: string;
|
|
466
|
+
/** Label for the "add non-blocking hook at playhead" button. */
|
|
467
|
+
addNonBlockingLabel: string;
|
|
468
|
+
/** Label for the zoom-in button. */
|
|
469
|
+
zoomInLabel: string;
|
|
470
|
+
/** Label for the zoom-out button. */
|
|
471
|
+
zoomOutLabel: string;
|
|
472
|
+
/** Label for the play button. */
|
|
473
|
+
playLabel: string;
|
|
474
|
+
/** Label for the pause button. */
|
|
475
|
+
pauseLabel: string;
|
|
476
|
+
/** Accessible label for the playhead slider. */
|
|
477
|
+
playheadLabel: string;
|
|
478
|
+
/** Shown in the track when there are no hooks. */
|
|
479
|
+
emptyLabel: string;
|
|
480
|
+
/** Accessible label for the ruler strip. */
|
|
481
|
+
rulerLabel: string;
|
|
482
|
+
/** Accessible label for the keyframe track. */
|
|
483
|
+
trackLabel: string;
|
|
484
|
+
/** Accessible label prefix for a blocking keyframe (composed with the title + time). */
|
|
485
|
+
blockingKeyframeLabel: string;
|
|
486
|
+
/** Accessible label prefix for a non-blocking range bar. */
|
|
487
|
+
nonBlockingRangeLabel: string;
|
|
488
|
+
}
|
|
489
|
+
declare const DEFAULT_KEYFRAME_TIMELINE_STRINGS: KeyframeTimelineStrings;
|
|
490
|
+
interface KeyframeTimelineEntry {
|
|
491
|
+
id: string;
|
|
492
|
+
title: string;
|
|
493
|
+
hookType: "blocking" | "non-blocking";
|
|
494
|
+
timestamp?: number;
|
|
495
|
+
start?: number;
|
|
496
|
+
end?: number;
|
|
497
|
+
}
|
|
498
|
+
interface KeyframeTimelineProps {
|
|
499
|
+
entries: KeyframeTimelineEntry[];
|
|
500
|
+
selectedId?: string;
|
|
501
|
+
/** Total video duration in seconds; the strip's time axis. */
|
|
502
|
+
videoDuration: number;
|
|
503
|
+
/** Current playhead position in seconds. */
|
|
504
|
+
currentTime: number;
|
|
505
|
+
/** Whether the authoring video is currently playing (drives the play/pause button). */
|
|
506
|
+
isPlaying: boolean;
|
|
507
|
+
onSeek: (time: number) => void;
|
|
508
|
+
onTogglePlay: () => void;
|
|
509
|
+
onSelectEntry: (id: string) => void;
|
|
510
|
+
onUpdateEntry: (id: string, updates: {
|
|
511
|
+
timestamp?: number;
|
|
512
|
+
start?: number;
|
|
513
|
+
end?: number;
|
|
514
|
+
}) => void;
|
|
515
|
+
onDeleteEntry: (id: string) => void;
|
|
516
|
+
onAddEntry: (hookType: "blocking" | "non-blocking") => void;
|
|
517
|
+
/** Called when the user clicks the track background (not a keyframe, range, or the ruler). */
|
|
518
|
+
onDeselect?: () => void;
|
|
519
|
+
strings?: Partial<KeyframeTimelineStrings>;
|
|
520
|
+
}
|
|
521
|
+
/**
|
|
522
|
+
* KeyframeTimeline - a horizontal, zoomable video-editor timeline.
|
|
523
|
+
*
|
|
524
|
+
* Visual grammar:
|
|
525
|
+
* - Blocking hooks render as point keyframes (diamonds) at their timestamp.
|
|
526
|
+
* - Non-blocking hooks render as range bars spanning start → end; the body
|
|
527
|
+
* drags to move (duration preserved), the edges drag to resize one side.
|
|
528
|
+
* - A playhead line tracks `currentTime`; dragging it (or clicking the
|
|
529
|
+
* ruler) seeks via `onSeek`.
|
|
530
|
+
*
|
|
531
|
+
* Interaction:
|
|
532
|
+
* - Drag survives the pointer leaving the strip (pointer capture +
|
|
533
|
+
* window-level fallbacks — the PlacementEditor pattern).
|
|
534
|
+
* - Drag snapping is to integer seconds; hold Shift to bypass.
|
|
535
|
+
* - Zoom via the +/- buttons or ctrl+wheel (native non-passive listener,
|
|
536
|
+
* since React's synthetic onWheel cannot preventDefault).
|
|
537
|
+
* - Keyboard: the playhead is a slider (arrow keys ±1s, ±5s with Shift);
|
|
538
|
+
* a selected keyframe nudges with the same keys through `onUpdateEntry`.
|
|
539
|
+
*
|
|
540
|
+
* Adding a hook happens at the current playhead (`onAddEntry`), which is
|
|
541
|
+
* the keyframe metaphor: the playhead is the insertion point.
|
|
542
|
+
*/
|
|
543
|
+
declare const KeyframeTimeline: React__default.FC<KeyframeTimelineProps>;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* A single interactive media entry being authored: its content instance
|
|
547
|
+
* plus the hook describing when/where it appears.
|
|
548
|
+
*/
|
|
549
|
+
interface InteractiveMediaItem {
|
|
550
|
+
content: ContentInstance;
|
|
551
|
+
hook: Hook;
|
|
552
|
+
}
|
|
553
|
+
interface AuthoringStoreState {
|
|
554
|
+
items: InteractiveMediaItem[];
|
|
555
|
+
videoSrc: string;
|
|
556
|
+
videoDuration: number;
|
|
557
|
+
}
|
|
558
|
+
interface LoadDocumentResult {
|
|
559
|
+
validationErrors: string[];
|
|
560
|
+
warnings: string[];
|
|
561
|
+
}
|
|
562
|
+
interface AuthoringStore {
|
|
563
|
+
state: AuthoringStoreState;
|
|
564
|
+
addItem: (item: InteractiveMediaItem) => void;
|
|
565
|
+
removeItem: (id: string) => void;
|
|
566
|
+
updateItem: (id: string, item: InteractiveMediaItem) => void;
|
|
567
|
+
/**
|
|
568
|
+
* Serializes the current items into a document via core's `serialize`.
|
|
569
|
+
* The legacy `adapterType` argument is accepted (and ignored) so existing
|
|
570
|
+
* callers do not break; the new core serializer does not produce it.
|
|
571
|
+
*/
|
|
572
|
+
serialize: (adapterType?: unknown) => SerializedInteractiveMediaDocument;
|
|
573
|
+
loadDocument: (doc: SerializedInteractiveMediaDocument, registry: ContentTypeRegistry) => LoadDocumentResult;
|
|
574
|
+
setVideoMetadata: (src: string, duration: number) => void;
|
|
575
|
+
}
|
|
576
|
+
/**
|
|
577
|
+
* Authoring store for managing interactive content creation.
|
|
578
|
+
* Handles document state, serialization, and item management.
|
|
579
|
+
*/
|
|
580
|
+
declare function useAuthoringStore(initialVideoSrc: string, initialDuration: number): AuthoringStore;
|
|
581
|
+
|
|
582
|
+
export { type AuthoringStore, type AuthoringStoreState, ContentTypeEditor, type ContentTypeEditorProps, ContentTypeEditorSlot, type ContentTypeEditorSlotProps, ContentTypePicker, type ContentTypePickerProps, DEFAULT_EDITOR_STRINGS, DEFAULT_INSPECTOR_PANEL_STRINGS, DEFAULT_KEYFRAME_TIMELINE_STRINGS, DEFAULT_VIDEO_SOURCE_INPUT_STRINGS, type EditorStrings, type EditorTheme, InspectorPanel, type InspectorPanelEntry, type InspectorPanelProps, type InspectorPanelStrings, type InteractiveMediaItem, InterlaceEditor, type InterlaceEditorProps, KeyframeTimeline, type KeyframeTimelineEntry, type KeyframeTimelineProps, type KeyframeTimelineStrings, type LoadDocumentResult, PLACEMENT_MIN_SIZE, PlacementEditor, type PlacementEditorProps, PlacementInputs, type PlacementInputsProps, VideoSourceInput, type VideoSourceInputProps, type VideoSourceInputStrings, type VideoSourceValue, clampPlacement, useAuthoringStore };
|