@aicut/core 0.1.1 → 0.2.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 +29 -0
- package/dist/chunk-CCDON7CU.js +87 -0
- package/dist/chunk-CCDON7CU.js.map +1 -0
- package/dist/index.d.cts +3 -119
- package/dist/index.d.ts +3 -119
- package/dist/index.js +4 -85
- package/dist/index.js.map +1 -1
- package/dist/lighting/index.cjs +19373 -0
- package/dist/lighting/index.cjs.map +1 -0
- package/dist/lighting/index.d.cts +193 -0
- package/dist/lighting/index.d.ts +193 -0
- package/dist/lighting/index.js +19310 -0
- package/dist/lighting/index.js.map +1 -0
- package/dist/types-C95koNwJ.d.cts +120 -0
- package/dist/types-C95koNwJ.d.ts +120 -0
- package/package.json +15 -3
- package/styles/theme.css +312 -0
package/README.md
CHANGED
|
@@ -142,6 +142,35 @@ exportBtn.onclick = () => editor.requestExport();
|
|
|
142
142
|
editor.toolbarRight.appendChild(exportBtn);
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
+
## Lighting picker (opt-in sub-entry)
|
|
146
|
+
|
|
147
|
+
A separate component for AI relighting workflows — drag a light dot around a 3D sphere wrapping a subject frame, control brightness / color / direction. Three.js is bundled only on this sub-entry, so consumers of the video editor pay zero bytes for it.
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { LightingEditor } from "@aicut/core/lighting";
|
|
151
|
+
import "@aicut/core/styles.css";
|
|
152
|
+
|
|
153
|
+
const ed = LightingEditor.create({
|
|
154
|
+
container: document.getElementById("light")!,
|
|
155
|
+
subjectImageUrl: "/frames/subject.jpg",
|
|
156
|
+
smartEnabled: true, // default; false → no slot column at all
|
|
157
|
+
smartOpen: true, // default; user can toggle via × / header pill
|
|
158
|
+
onChange: (cfg) => console.log(cfg),
|
|
159
|
+
onGenerate: (cfg) => fetch("/relight", { method: "POST", body: JSON.stringify(cfg) }),
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Host appends UI into the smart slot (prompt textarea, presets, generate btn, …).
|
|
163
|
+
ed.smartSlot.appendChild(myAiUI);
|
|
164
|
+
|
|
165
|
+
// Runtime control:
|
|
166
|
+
ed.setSmartOpen(false);
|
|
167
|
+
ed.setSmartEnabled(false);
|
|
168
|
+
ed.setView("front");
|
|
169
|
+
ed.setConfig({ brightness: 0.8, color: "#ffaa3a" });
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Locale extension `LightingLocale` (separate from the video editor's `Locale`) is also exported with `lightingLocaleEn` / `lightingLocaleZh`.
|
|
173
|
+
|
|
145
174
|
## Standalone Timeline
|
|
146
175
|
|
|
147
176
|
```ts
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/i18n.ts
|
|
2
|
+
var localeEn = {
|
|
3
|
+
undo: "Undo",
|
|
4
|
+
redo: "Redo",
|
|
5
|
+
split: "Split",
|
|
6
|
+
trimLeft: "Trim left edge",
|
|
7
|
+
trimRight: "Trim right edge",
|
|
8
|
+
speedComingSoon: "Speed (coming soon)",
|
|
9
|
+
playPause: "Play / Pause (Space)",
|
|
10
|
+
fullscreen: "Fullscreen preview",
|
|
11
|
+
snap: "Snap",
|
|
12
|
+
snapOnTitle: "Turn off snap",
|
|
13
|
+
snapOffTitle: "Turn on snap",
|
|
14
|
+
zoomOut: "Zoom out",
|
|
15
|
+
zoomIn: "Zoom in",
|
|
16
|
+
reset: "Reset edits (keep sources)",
|
|
17
|
+
exitFullscreen: "Exit fullscreen",
|
|
18
|
+
exitFullscreenTitle: "Exit fullscreen (Esc)",
|
|
19
|
+
newTrack: "+ New track",
|
|
20
|
+
videoTrackLabel: "Video {n}",
|
|
21
|
+
audioTrackLabel: "Audio {n}"
|
|
22
|
+
};
|
|
23
|
+
var localeZh = {
|
|
24
|
+
undo: "\u64A4\u9500",
|
|
25
|
+
redo: "\u91CD\u505A",
|
|
26
|
+
split: "\u5206\u5272",
|
|
27
|
+
trimLeft: "\u5411\u5DE6\u88C1\u526A",
|
|
28
|
+
trimRight: "\u5411\u53F3\u88C1\u526A",
|
|
29
|
+
speedComingSoon: "\u53D8\u901F\uFF08\u5373\u5C06\u5230\u6765\uFF09",
|
|
30
|
+
playPause: "\u64AD\u653E / \u6682\u505C (Space)",
|
|
31
|
+
fullscreen: "\u5168\u5C4F\u9884\u89C8",
|
|
32
|
+
snap: "\u5438\u9644",
|
|
33
|
+
snapOnTitle: "\u5173\u95ED\u5438\u9644",
|
|
34
|
+
snapOffTitle: "\u5F00\u542F\u5438\u9644",
|
|
35
|
+
zoomOut: "\u7F29\u5C0F",
|
|
36
|
+
zoomIn: "\u653E\u5927",
|
|
37
|
+
reset: "\u91CD\u7F6E\u7F16\u8F91\uFF08\u4FDD\u7559\u89C6\u9891\u6E90\uFF09",
|
|
38
|
+
exitFullscreen: "\u9000\u51FA\u5168\u5C4F",
|
|
39
|
+
exitFullscreenTitle: "\u9000\u51FA\u5168\u5C4F (Esc)",
|
|
40
|
+
newTrack: "+ \u65B0\u8F68\u9053",
|
|
41
|
+
videoTrackLabel: "\u89C6\u9891 {n}",
|
|
42
|
+
audioTrackLabel: "\u97F3\u9891 {n}"
|
|
43
|
+
};
|
|
44
|
+
function mergeLocale(partial) {
|
|
45
|
+
return partial ? { ...localeEn, ...partial } : localeEn;
|
|
46
|
+
}
|
|
47
|
+
function formatLabel(template, vars) {
|
|
48
|
+
return template.replace(
|
|
49
|
+
/\{(\w+)\}/g,
|
|
50
|
+
(_, k) => k in vars ? String(vars[k]) : `{${k}}`
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/theme.ts
|
|
55
|
+
var THEME_VARS = {
|
|
56
|
+
brand: "--color-brand",
|
|
57
|
+
secondary: "--color-secondary",
|
|
58
|
+
surface: "--color-surface",
|
|
59
|
+
dark: "--color-dark",
|
|
60
|
+
muted: "--color-muted",
|
|
61
|
+
card: "--color-card",
|
|
62
|
+
success: "--color-success",
|
|
63
|
+
warning: "--color-warning",
|
|
64
|
+
info: "--color-info",
|
|
65
|
+
error: "--color-error",
|
|
66
|
+
controlsBg: "--aicut-controls-bg",
|
|
67
|
+
controlsBorder: "--aicut-controls-border",
|
|
68
|
+
controlsText: "--aicut-controls-text",
|
|
69
|
+
controlsHover: "--aicut-controls-hover",
|
|
70
|
+
controlsActive: "--aicut-controls-active",
|
|
71
|
+
previewBg: "--aicut-preview-bg",
|
|
72
|
+
radiusSm: "--aicut-radius-sm",
|
|
73
|
+
radiusMd: "--aicut-radius-md",
|
|
74
|
+
radiusLg: "--aicut-radius-lg"
|
|
75
|
+
};
|
|
76
|
+
function applyTheme(root, theme) {
|
|
77
|
+
if (!theme) return;
|
|
78
|
+
for (const key of Object.keys(theme)) {
|
|
79
|
+
const cssVar = THEME_VARS[key];
|
|
80
|
+
const value = theme[key];
|
|
81
|
+
if (cssVar && value) root.style.setProperty(cssVar, value);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { applyTheme, formatLabel, localeEn, localeZh, mergeLocale };
|
|
86
|
+
//# sourceMappingURL=chunk-CCDON7CU.js.map
|
|
87
|
+
//# sourceMappingURL=chunk-CCDON7CU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n.ts","../src/theme.ts"],"names":[],"mappings":"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","file":"chunk-CCDON7CU.js","sourcesContent":["/**\n * UI strings the editor paints into the DOM (toolbar tooltips, the\n * fullscreen exit button) and onto the timeline canvas (phantom new-\n * track label, track header labels). Every user-visible literal in\n * `@aicut/core` flows through this interface — there are no hidden\n * hard-coded translations elsewhere in the library.\n *\n * Defaults to English. Hosts that want Chinese (or any other locale)\n * pass `locale: localeZh` to `Editor.create` / `Timeline.create`, or\n * override individual keys with `locale: { undo: \"撤销\" }`.\n */\nexport interface Locale {\n // Toolbar tooltips\n undo: string;\n redo: string;\n split: string;\n trimLeft: string;\n trimRight: string;\n speedComingSoon: string;\n playPause: string;\n fullscreen: string;\n snap: string;\n /** Title shown on the snap button when snap is ON (clicking turns OFF). */\n snapOnTitle: string;\n /** Title shown when snap is OFF (clicking turns ON). */\n snapOffTitle: string;\n zoomOut: string;\n zoomIn: string;\n reset: string;\n\n // Fullscreen exit overlay\n exitFullscreen: string;\n exitFullscreenTitle: string;\n\n // Timeline canvas labels\n /** Phantom row that appears under the last track during a drag. */\n newTrack: string;\n /** Track header — `{n}` is replaced with the 1-based track index. */\n videoTrackLabel: string;\n /** Same template format as videoTrackLabel. */\n audioTrackLabel: string;\n}\n\n/** English. The library default — chosen over Chinese as the OSS norm. */\nexport const localeEn: Locale = {\n undo: \"Undo\",\n redo: \"Redo\",\n split: \"Split\",\n trimLeft: \"Trim left edge\",\n trimRight: \"Trim right edge\",\n speedComingSoon: \"Speed (coming soon)\",\n playPause: \"Play / Pause (Space)\",\n fullscreen: \"Fullscreen preview\",\n snap: \"Snap\",\n snapOnTitle: \"Turn off snap\",\n snapOffTitle: \"Turn on snap\",\n zoomOut: \"Zoom out\",\n zoomIn: \"Zoom in\",\n reset: \"Reset edits (keep sources)\",\n exitFullscreen: \"Exit fullscreen\",\n exitFullscreenTitle: \"Exit fullscreen (Esc)\",\n newTrack: \"+ New track\",\n videoTrackLabel: \"Video {n}\",\n audioTrackLabel: \"Audio {n}\",\n};\n\n/** Simplified Chinese. */\nexport const localeZh: Locale = {\n undo: \"撤销\",\n redo: \"重做\",\n split: \"分割\",\n trimLeft: \"向左裁剪\",\n trimRight: \"向右裁剪\",\n speedComingSoon: \"变速(即将到来)\",\n playPause: \"播放 / 暂停 (Space)\",\n fullscreen: \"全屏预览\",\n snap: \"吸附\",\n snapOnTitle: \"关闭吸附\",\n snapOffTitle: \"开启吸附\",\n zoomOut: \"缩小\",\n zoomIn: \"放大\",\n reset: \"重置编辑(保留视频源)\",\n exitFullscreen: \"退出全屏\",\n exitFullscreenTitle: \"退出全屏 (Esc)\",\n newTrack: \"+ 新轨道\",\n videoTrackLabel: \"视频 {n}\",\n audioTrackLabel: \"音频 {n}\",\n};\n\n/** Spread defaults under host overrides — host can supply a partial. */\nexport function mergeLocale(partial: Partial<Locale> | undefined): Locale {\n return partial ? { ...localeEn, ...partial } : localeEn;\n}\n\n/**\n * Replace `{key}` placeholders in a template. We only need `{n}`\n * substitution today; the implementation is generic so additional\n * keys (e.g. `{name}`) won't need a second pass.\n */\nexport function formatLabel(\n template: string,\n vars: Record<string, string | number>,\n): string {\n return template.replace(/\\{(\\w+)\\}/g, (_, k) =>\n k in vars ? String(vars[k]) : `{${k}}`,\n );\n}\n","import type { Theme } from \"./types.js\";\n\n/**\n * Map `Theme` keys to the CSS custom property they write.\n *\n * Brand/palette keys share names with iqvise's globals.css so hosts\n * that already define `--color-brand` etc. at the page level get the\n * editor in their palette for free — `theme` props ONLY needed when\n * scoping to this editor instance.\n *\n * Chrome keys keep the `--aicut-controls-*` prefix because they have\n * no analogue in the host palette.\n */\nconst THEME_VARS: Record<keyof Theme, string> = {\n brand: \"--color-brand\",\n secondary: \"--color-secondary\",\n surface: \"--color-surface\",\n dark: \"--color-dark\",\n muted: \"--color-muted\",\n card: \"--color-card\",\n success: \"--color-success\",\n warning: \"--color-warning\",\n info: \"--color-info\",\n error: \"--color-error\",\n controlsBg: \"--aicut-controls-bg\",\n controlsBorder: \"--aicut-controls-border\",\n controlsText: \"--aicut-controls-text\",\n controlsHover: \"--aicut-controls-hover\",\n controlsActive: \"--aicut-controls-active\",\n previewBg: \"--aicut-preview-bg\",\n radiusSm: \"--aicut-radius-sm\",\n radiusMd: \"--aicut-radius-md\",\n radiusLg: \"--aicut-radius-lg\",\n};\n\nexport function applyTheme(root: HTMLElement, theme: Theme | undefined): void {\n if (!theme) return;\n for (const key of Object.keys(theme) as Array<keyof Theme>) {\n const cssVar = THEME_VARS[key];\n const value = theme[key];\n if (cssVar && value) root.style.setProperty(cssVar, value);\n }\n}\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,121 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* fullscreen exit button) and onto the timeline canvas (phantom new-
|
|
4
|
-
* track label, track header labels). Every user-visible literal in
|
|
5
|
-
* `@aicut/core` flows through this interface — there are no hidden
|
|
6
|
-
* hard-coded translations elsewhere in the library.
|
|
7
|
-
*
|
|
8
|
-
* Defaults to English. Hosts that want Chinese (or any other locale)
|
|
9
|
-
* pass `locale: localeZh` to `Editor.create` / `Timeline.create`, or
|
|
10
|
-
* override individual keys with `locale: { undo: "撤销" }`.
|
|
11
|
-
*/
|
|
12
|
-
interface Locale {
|
|
13
|
-
undo: string;
|
|
14
|
-
redo: string;
|
|
15
|
-
split: string;
|
|
16
|
-
trimLeft: string;
|
|
17
|
-
trimRight: string;
|
|
18
|
-
speedComingSoon: string;
|
|
19
|
-
playPause: string;
|
|
20
|
-
fullscreen: string;
|
|
21
|
-
snap: string;
|
|
22
|
-
/** Title shown on the snap button when snap is ON (clicking turns OFF). */
|
|
23
|
-
snapOnTitle: string;
|
|
24
|
-
/** Title shown when snap is OFF (clicking turns ON). */
|
|
25
|
-
snapOffTitle: string;
|
|
26
|
-
zoomOut: string;
|
|
27
|
-
zoomIn: string;
|
|
28
|
-
reset: string;
|
|
29
|
-
exitFullscreen: string;
|
|
30
|
-
exitFullscreenTitle: string;
|
|
31
|
-
/** Phantom row that appears under the last track during a drag. */
|
|
32
|
-
newTrack: string;
|
|
33
|
-
/** Track header — `{n}` is replaced with the 1-based track index. */
|
|
34
|
-
videoTrackLabel: string;
|
|
35
|
-
/** Same template format as videoTrackLabel. */
|
|
36
|
-
audioTrackLabel: string;
|
|
37
|
-
}
|
|
38
|
-
/** English. The library default — chosen over Chinese as the OSS norm. */
|
|
39
|
-
declare const localeEn: Locale;
|
|
40
|
-
/** Simplified Chinese. */
|
|
41
|
-
declare const localeZh: Locale;
|
|
42
|
-
/** Spread defaults under host overrides — host can supply a partial. */
|
|
43
|
-
declare function mergeLocale(partial: Partial<Locale> | undefined): Locale;
|
|
44
|
-
/**
|
|
45
|
-
* Replace `{key}` placeholders in a template. We only need `{n}`
|
|
46
|
-
* substitution today; the implementation is generic so additional
|
|
47
|
-
* keys (e.g. `{name}`) won't need a second pass.
|
|
48
|
-
*/
|
|
49
|
-
declare function formatLabel(template: string, vars: Record<string, string | number>): string;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Milliseconds. All timing in the project is expressed as integer ms to
|
|
53
|
-
* keep JSON serialization unambiguous (no frame-rate coupling in the
|
|
54
|
-
* data model — the renderer can present time as frames if it wants).
|
|
55
|
-
*/
|
|
56
|
-
type Ms = number;
|
|
57
|
-
interface MediaSource {
|
|
58
|
-
id: string;
|
|
59
|
-
url: string;
|
|
60
|
-
kind: "video" | "audio";
|
|
61
|
-
/** Optional — probed lazily from the <video> element if absent. */
|
|
62
|
-
duration?: Ms;
|
|
63
|
-
name?: string;
|
|
64
|
-
}
|
|
65
|
-
interface Clip {
|
|
66
|
-
id: string;
|
|
67
|
-
sourceId: string;
|
|
68
|
-
/** Window into the source — `in` inclusive, `out` exclusive. */
|
|
69
|
-
in: Ms;
|
|
70
|
-
out: Ms;
|
|
71
|
-
/** Position on the timeline. */
|
|
72
|
-
start: Ms;
|
|
73
|
-
/**
|
|
74
|
-
* Playback rate. 1 = normal, 2 = 2× speed. Default 1.
|
|
75
|
-
* Persisted in the project JSON so a host can restore exactly.
|
|
76
|
-
*/
|
|
77
|
-
speed?: number;
|
|
78
|
-
}
|
|
79
|
-
interface Track {
|
|
80
|
-
id: string;
|
|
81
|
-
kind: "video" | "audio";
|
|
82
|
-
/** Clips on this track. Must be kept sorted by `start` and non-overlapping. */
|
|
83
|
-
clips: Clip[];
|
|
84
|
-
}
|
|
85
|
-
interface Project {
|
|
86
|
-
/** Schema version — bump when breaking the JSON shape. */
|
|
87
|
-
version: 1;
|
|
88
|
-
sources: MediaSource[];
|
|
89
|
-
tracks: Track[];
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Subset of CSS variables the editor honors. Pass any custom values
|
|
93
|
-
* via `Editor` options; everything is forwarded as `--aicut-*` on the
|
|
94
|
-
* editor's root container, so a host can also override via plain CSS.
|
|
95
|
-
*/
|
|
96
|
-
interface Theme {
|
|
97
|
-
brand?: string;
|
|
98
|
-
secondary?: string;
|
|
99
|
-
surface?: string;
|
|
100
|
-
dark?: string;
|
|
101
|
-
muted?: string;
|
|
102
|
-
card?: string;
|
|
103
|
-
success?: string;
|
|
104
|
-
warning?: string;
|
|
105
|
-
info?: string;
|
|
106
|
-
error?: string;
|
|
107
|
-
/** Toolbar / ruler chrome. Background of the editor frame. */
|
|
108
|
-
controlsBg?: string;
|
|
109
|
-
controlsBorder?: string;
|
|
110
|
-
controlsText?: string;
|
|
111
|
-
controlsHover?: string;
|
|
112
|
-
controlsActive?: string;
|
|
113
|
-
/** Letterbox color around the preview video. Defaults to black. */
|
|
114
|
-
previewBg?: string;
|
|
115
|
-
radiusSm?: string;
|
|
116
|
-
radiusMd?: string;
|
|
117
|
-
radiusLg?: string;
|
|
118
|
-
}
|
|
1
|
+
import { M as Ms, T as Track, C as Clip, a as MediaSource, P as Project, b as Theme, L as Locale } from './types-C95koNwJ.cjs';
|
|
2
|
+
export { f as formatLabel, l as localeEn, c as localeZh, m as mergeLocale } from './types-C95koNwJ.cjs';
|
|
119
3
|
|
|
120
4
|
interface EditorOptions {
|
|
121
5
|
/** Host element to mount the editor into. Will be wiped on init. */
|
|
@@ -637,4 +521,4 @@ declare class Timeline {
|
|
|
637
521
|
private applySnap;
|
|
638
522
|
}
|
|
639
523
|
|
|
640
|
-
export {
|
|
524
|
+
export { Clip, Editor, type EditorApi, type EditorEventMap, type EditorEventName, type EditorOptions, HEADER_WIDTH, Locale, MediaSource, Ms, Project, RULER_HEIGHT, TRACK_HEIGHT, Theme, Timeline, type TimelineOptions, Track, createEmptyProject, createId, normalizeProject };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,121 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* fullscreen exit button) and onto the timeline canvas (phantom new-
|
|
4
|
-
* track label, track header labels). Every user-visible literal in
|
|
5
|
-
* `@aicut/core` flows through this interface — there are no hidden
|
|
6
|
-
* hard-coded translations elsewhere in the library.
|
|
7
|
-
*
|
|
8
|
-
* Defaults to English. Hosts that want Chinese (or any other locale)
|
|
9
|
-
* pass `locale: localeZh` to `Editor.create` / `Timeline.create`, or
|
|
10
|
-
* override individual keys with `locale: { undo: "撤销" }`.
|
|
11
|
-
*/
|
|
12
|
-
interface Locale {
|
|
13
|
-
undo: string;
|
|
14
|
-
redo: string;
|
|
15
|
-
split: string;
|
|
16
|
-
trimLeft: string;
|
|
17
|
-
trimRight: string;
|
|
18
|
-
speedComingSoon: string;
|
|
19
|
-
playPause: string;
|
|
20
|
-
fullscreen: string;
|
|
21
|
-
snap: string;
|
|
22
|
-
/** Title shown on the snap button when snap is ON (clicking turns OFF). */
|
|
23
|
-
snapOnTitle: string;
|
|
24
|
-
/** Title shown when snap is OFF (clicking turns ON). */
|
|
25
|
-
snapOffTitle: string;
|
|
26
|
-
zoomOut: string;
|
|
27
|
-
zoomIn: string;
|
|
28
|
-
reset: string;
|
|
29
|
-
exitFullscreen: string;
|
|
30
|
-
exitFullscreenTitle: string;
|
|
31
|
-
/** Phantom row that appears under the last track during a drag. */
|
|
32
|
-
newTrack: string;
|
|
33
|
-
/** Track header — `{n}` is replaced with the 1-based track index. */
|
|
34
|
-
videoTrackLabel: string;
|
|
35
|
-
/** Same template format as videoTrackLabel. */
|
|
36
|
-
audioTrackLabel: string;
|
|
37
|
-
}
|
|
38
|
-
/** English. The library default — chosen over Chinese as the OSS norm. */
|
|
39
|
-
declare const localeEn: Locale;
|
|
40
|
-
/** Simplified Chinese. */
|
|
41
|
-
declare const localeZh: Locale;
|
|
42
|
-
/** Spread defaults under host overrides — host can supply a partial. */
|
|
43
|
-
declare function mergeLocale(partial: Partial<Locale> | undefined): Locale;
|
|
44
|
-
/**
|
|
45
|
-
* Replace `{key}` placeholders in a template. We only need `{n}`
|
|
46
|
-
* substitution today; the implementation is generic so additional
|
|
47
|
-
* keys (e.g. `{name}`) won't need a second pass.
|
|
48
|
-
*/
|
|
49
|
-
declare function formatLabel(template: string, vars: Record<string, string | number>): string;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Milliseconds. All timing in the project is expressed as integer ms to
|
|
53
|
-
* keep JSON serialization unambiguous (no frame-rate coupling in the
|
|
54
|
-
* data model — the renderer can present time as frames if it wants).
|
|
55
|
-
*/
|
|
56
|
-
type Ms = number;
|
|
57
|
-
interface MediaSource {
|
|
58
|
-
id: string;
|
|
59
|
-
url: string;
|
|
60
|
-
kind: "video" | "audio";
|
|
61
|
-
/** Optional — probed lazily from the <video> element if absent. */
|
|
62
|
-
duration?: Ms;
|
|
63
|
-
name?: string;
|
|
64
|
-
}
|
|
65
|
-
interface Clip {
|
|
66
|
-
id: string;
|
|
67
|
-
sourceId: string;
|
|
68
|
-
/** Window into the source — `in` inclusive, `out` exclusive. */
|
|
69
|
-
in: Ms;
|
|
70
|
-
out: Ms;
|
|
71
|
-
/** Position on the timeline. */
|
|
72
|
-
start: Ms;
|
|
73
|
-
/**
|
|
74
|
-
* Playback rate. 1 = normal, 2 = 2× speed. Default 1.
|
|
75
|
-
* Persisted in the project JSON so a host can restore exactly.
|
|
76
|
-
*/
|
|
77
|
-
speed?: number;
|
|
78
|
-
}
|
|
79
|
-
interface Track {
|
|
80
|
-
id: string;
|
|
81
|
-
kind: "video" | "audio";
|
|
82
|
-
/** Clips on this track. Must be kept sorted by `start` and non-overlapping. */
|
|
83
|
-
clips: Clip[];
|
|
84
|
-
}
|
|
85
|
-
interface Project {
|
|
86
|
-
/** Schema version — bump when breaking the JSON shape. */
|
|
87
|
-
version: 1;
|
|
88
|
-
sources: MediaSource[];
|
|
89
|
-
tracks: Track[];
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Subset of CSS variables the editor honors. Pass any custom values
|
|
93
|
-
* via `Editor` options; everything is forwarded as `--aicut-*` on the
|
|
94
|
-
* editor's root container, so a host can also override via plain CSS.
|
|
95
|
-
*/
|
|
96
|
-
interface Theme {
|
|
97
|
-
brand?: string;
|
|
98
|
-
secondary?: string;
|
|
99
|
-
surface?: string;
|
|
100
|
-
dark?: string;
|
|
101
|
-
muted?: string;
|
|
102
|
-
card?: string;
|
|
103
|
-
success?: string;
|
|
104
|
-
warning?: string;
|
|
105
|
-
info?: string;
|
|
106
|
-
error?: string;
|
|
107
|
-
/** Toolbar / ruler chrome. Background of the editor frame. */
|
|
108
|
-
controlsBg?: string;
|
|
109
|
-
controlsBorder?: string;
|
|
110
|
-
controlsText?: string;
|
|
111
|
-
controlsHover?: string;
|
|
112
|
-
controlsActive?: string;
|
|
113
|
-
/** Letterbox color around the preview video. Defaults to black. */
|
|
114
|
-
previewBg?: string;
|
|
115
|
-
radiusSm?: string;
|
|
116
|
-
radiusMd?: string;
|
|
117
|
-
radiusLg?: string;
|
|
118
|
-
}
|
|
1
|
+
import { M as Ms, T as Track, C as Clip, a as MediaSource, P as Project, b as Theme, L as Locale } from './types-C95koNwJ.js';
|
|
2
|
+
export { f as formatLabel, l as localeEn, c as localeZh, m as mergeLocale } from './types-C95koNwJ.js';
|
|
119
3
|
|
|
120
4
|
interface EditorOptions {
|
|
121
5
|
/** Host element to mount the editor into. Will be wiped on init. */
|
|
@@ -637,4 +521,4 @@ declare class Timeline {
|
|
|
637
521
|
private applySnap;
|
|
638
522
|
}
|
|
639
523
|
|
|
640
|
-
export {
|
|
524
|
+
export { Clip, Editor, type EditorApi, type EditorEventMap, type EditorEventName, type EditorOptions, HEADER_WIDTH, Locale, MediaSource, Ms, Project, RULER_HEIGHT, TRACK_HEIGHT, Theme, Timeline, type TimelineOptions, Track, createEmptyProject, createId, normalizeProject };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { mergeLocale, applyTheme, formatLabel } from './chunk-CCDON7CU.js';
|
|
2
|
+
export { formatLabel, localeEn, localeZh, mergeLocale } from './chunk-CCDON7CU.js';
|
|
3
|
+
|
|
1
4
|
// src/events.ts
|
|
2
5
|
var EventBus = class {
|
|
3
6
|
listeners = /* @__PURE__ */ new Map();
|
|
@@ -513,90 +516,6 @@ var PlaybackEngine = class {
|
|
|
513
516
|
}
|
|
514
517
|
};
|
|
515
518
|
|
|
516
|
-
// src/theme.ts
|
|
517
|
-
var THEME_VARS = {
|
|
518
|
-
brand: "--color-brand",
|
|
519
|
-
secondary: "--color-secondary",
|
|
520
|
-
surface: "--color-surface",
|
|
521
|
-
dark: "--color-dark",
|
|
522
|
-
muted: "--color-muted",
|
|
523
|
-
card: "--color-card",
|
|
524
|
-
success: "--color-success",
|
|
525
|
-
warning: "--color-warning",
|
|
526
|
-
info: "--color-info",
|
|
527
|
-
error: "--color-error",
|
|
528
|
-
controlsBg: "--aicut-controls-bg",
|
|
529
|
-
controlsBorder: "--aicut-controls-border",
|
|
530
|
-
controlsText: "--aicut-controls-text",
|
|
531
|
-
controlsHover: "--aicut-controls-hover",
|
|
532
|
-
controlsActive: "--aicut-controls-active",
|
|
533
|
-
previewBg: "--aicut-preview-bg",
|
|
534
|
-
radiusSm: "--aicut-radius-sm",
|
|
535
|
-
radiusMd: "--aicut-radius-md",
|
|
536
|
-
radiusLg: "--aicut-radius-lg"
|
|
537
|
-
};
|
|
538
|
-
function applyTheme(root, theme) {
|
|
539
|
-
if (!theme) return;
|
|
540
|
-
for (const key of Object.keys(theme)) {
|
|
541
|
-
const cssVar = THEME_VARS[key];
|
|
542
|
-
const value = theme[key];
|
|
543
|
-
if (cssVar && value) root.style.setProperty(cssVar, value);
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
// src/i18n.ts
|
|
548
|
-
var localeEn = {
|
|
549
|
-
undo: "Undo",
|
|
550
|
-
redo: "Redo",
|
|
551
|
-
split: "Split",
|
|
552
|
-
trimLeft: "Trim left edge",
|
|
553
|
-
trimRight: "Trim right edge",
|
|
554
|
-
speedComingSoon: "Speed (coming soon)",
|
|
555
|
-
playPause: "Play / Pause (Space)",
|
|
556
|
-
fullscreen: "Fullscreen preview",
|
|
557
|
-
snap: "Snap",
|
|
558
|
-
snapOnTitle: "Turn off snap",
|
|
559
|
-
snapOffTitle: "Turn on snap",
|
|
560
|
-
zoomOut: "Zoom out",
|
|
561
|
-
zoomIn: "Zoom in",
|
|
562
|
-
reset: "Reset edits (keep sources)",
|
|
563
|
-
exitFullscreen: "Exit fullscreen",
|
|
564
|
-
exitFullscreenTitle: "Exit fullscreen (Esc)",
|
|
565
|
-
newTrack: "+ New track",
|
|
566
|
-
videoTrackLabel: "Video {n}",
|
|
567
|
-
audioTrackLabel: "Audio {n}"
|
|
568
|
-
};
|
|
569
|
-
var localeZh = {
|
|
570
|
-
undo: "\u64A4\u9500",
|
|
571
|
-
redo: "\u91CD\u505A",
|
|
572
|
-
split: "\u5206\u5272",
|
|
573
|
-
trimLeft: "\u5411\u5DE6\u88C1\u526A",
|
|
574
|
-
trimRight: "\u5411\u53F3\u88C1\u526A",
|
|
575
|
-
speedComingSoon: "\u53D8\u901F\uFF08\u5373\u5C06\u5230\u6765\uFF09",
|
|
576
|
-
playPause: "\u64AD\u653E / \u6682\u505C (Space)",
|
|
577
|
-
fullscreen: "\u5168\u5C4F\u9884\u89C8",
|
|
578
|
-
snap: "\u5438\u9644",
|
|
579
|
-
snapOnTitle: "\u5173\u95ED\u5438\u9644",
|
|
580
|
-
snapOffTitle: "\u5F00\u542F\u5438\u9644",
|
|
581
|
-
zoomOut: "\u7F29\u5C0F",
|
|
582
|
-
zoomIn: "\u653E\u5927",
|
|
583
|
-
reset: "\u91CD\u7F6E\u7F16\u8F91\uFF08\u4FDD\u7559\u89C6\u9891\u6E90\uFF09",
|
|
584
|
-
exitFullscreen: "\u9000\u51FA\u5168\u5C4F",
|
|
585
|
-
exitFullscreenTitle: "\u9000\u51FA\u5168\u5C4F (Esc)",
|
|
586
|
-
newTrack: "+ \u65B0\u8F68\u9053",
|
|
587
|
-
videoTrackLabel: "\u89C6\u9891 {n}",
|
|
588
|
-
audioTrackLabel: "\u97F3\u9891 {n}"
|
|
589
|
-
};
|
|
590
|
-
function mergeLocale(partial) {
|
|
591
|
-
return partial ? { ...localeEn, ...partial } : localeEn;
|
|
592
|
-
}
|
|
593
|
-
function formatLabel(template, vars) {
|
|
594
|
-
return template.replace(
|
|
595
|
-
/\{(\w+)\}/g,
|
|
596
|
-
(_, k) => k in vars ? String(vars[k]) : `{${k}}`
|
|
597
|
-
);
|
|
598
|
-
}
|
|
599
|
-
|
|
600
519
|
// src/ui/thumbnails.ts
|
|
601
520
|
var THUMB_HEIGHT = 44;
|
|
602
521
|
var THUMB_WIDTH = Math.round(THUMB_HEIGHT * (16 / 9));
|
|
@@ -3326,6 +3245,6 @@ function clampScale2(s) {
|
|
|
3326
3245
|
return Math.max(MIN_PX_PER_SEC, Math.min(MAX_PX_PER_SEC, s));
|
|
3327
3246
|
}
|
|
3328
3247
|
|
|
3329
|
-
export { Editor, HEADER_WIDTH, RULER_HEIGHT, TRACK_HEIGHT, Timeline, createEmptyProject, createId,
|
|
3248
|
+
export { Editor, HEADER_WIDTH, RULER_HEIGHT, TRACK_HEIGHT, Timeline, createEmptyProject, createId, normalizeProject };
|
|
3330
3249
|
//# sourceMappingURL=index.js.map
|
|
3331
3250
|
//# sourceMappingURL=index.js.map
|