@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.
@@ -0,0 +1,193 @@
1
+ import { b as Theme, L as Locale } from '../types-C95koNwJ.cjs';
2
+
3
+ /**
4
+ * Lighting-editor-specific string keys. Kept in a SEPARATE interface
5
+ * from the video editor's `Locale` so the timeline-only consumer's
6
+ * type doesn't grow unused fields, but exported so a single host
7
+ * locale object can spread both shapes together.
8
+ */
9
+ interface LightingLocale {
10
+ lightingGlobalTitle: string;
11
+ lightingSmartMode: string;
12
+ lightingBrightness: string;
13
+ lightingColor: string;
14
+ lightingKeyTitle: string;
15
+ lightingRim: string;
16
+ lightingViewPerspective: string;
17
+ lightingViewFront: string;
18
+ lightingResetParams: string;
19
+ /** Aria label / tooltip for the × button that closes the Smart panel. */
20
+ lightingSmartClose: string;
21
+ /** Tooltip / label for the controls-header Smart Mode toggle. */
22
+ lightingSmartToggle: string;
23
+ lightingDirLeft: string;
24
+ lightingDirRight: string;
25
+ lightingDirTop: string;
26
+ lightingDirBottom: string;
27
+ lightingDirFront: string;
28
+ lightingDirBack: string;
29
+ }
30
+ declare const lightingLocaleEn: LightingLocale;
31
+ declare const lightingLocaleZh: LightingLocale;
32
+ declare function mergeLightingLocale(partial: Partial<LightingLocale> | undefined): LightingLocale;
33
+
34
+ /** One of the six canonical key-light directions plus a sentinel for free-drag. */
35
+ type KeyPreset = "left" | "right" | "top" | "bottom" | "front" | "back" | "custom";
36
+ /** Snapshot of every adjustable lighting parameter — what `onChange` emits. */
37
+ interface LightingConfig {
38
+ /** 0–1 multiplier. Snapped to 5 UI levels (0 / 0.25 / 0.5 / 0.75 / 1). */
39
+ brightness: number;
40
+ /** Hex RGB string, e.g. "#ffffff". */
41
+ color: string;
42
+ /**
43
+ * Unit vector from the subject toward the light. `(0,0,1)` = light in
44
+ * front of the subject, `(0,1,0)` = light directly overhead, etc.
45
+ * Always renormalised on write.
46
+ */
47
+ keyDirection: {
48
+ x: number;
49
+ y: number;
50
+ z: number;
51
+ };
52
+ /** Which canonical direction the dot is closest to, or `"custom"`. */
53
+ keyPreset: KeyPreset;
54
+ /** Rim / contour light toggle. */
55
+ rim: boolean;
56
+ }
57
+ type LightingView = "perspective" | "front";
58
+ interface LightingEditorOptions {
59
+ /** Host element. Will be wiped on init. */
60
+ container: HTMLElement;
61
+ /**
62
+ * Image URL or data URI shown on the in-sphere plane (the "subject"
63
+ * being lit). Can be swapped at runtime via `setSubjectImage`.
64
+ */
65
+ subjectImageUrl?: string;
66
+ /** Initial config — merges over the safe defaults below. */
67
+ config?: Partial<LightingConfig>;
68
+ /** Initial camera view. Default `"perspective"`. */
69
+ view?: LightingView;
70
+ /**
71
+ * Whether the Smart Mode feature is wired in at all. When false the
72
+ * slot column never renders and the controls header hides the
73
+ * Smart Mode toggle — the layout becomes a clean 2-column
74
+ * (scene + controls). Default `true`.
75
+ */
76
+ smartEnabled?: boolean;
77
+ /**
78
+ * When `smartEnabled` is true, whether the Smart Mode slot panel
79
+ * starts open. Hosts toggle later via `api.setSmartOpen(bool)` or
80
+ * by clicking the library-rendered × button. Default `true`.
81
+ */
82
+ smartOpen?: boolean;
83
+ /** Theme tokens — same shape as the video Editor's theme. */
84
+ theme?: Theme;
85
+ /** Locale overrides on top of English defaults (`localeEn` + `lightingLocaleEn`). */
86
+ locale?: Partial<Locale & LightingLocale>;
87
+ /** Fires on any config mutation (drag, slider, preset click, toggle). */
88
+ onChange?: (cfg: LightingConfig) => void;
89
+ /**
90
+ * Surface event for the host's own "Generate" button — the library
91
+ * never wires this. Use `api.requestGenerate()` from your UI.
92
+ */
93
+ onGenerate?: (cfg: LightingConfig) => void;
94
+ /** Fires when the user toggles the Smart Mode panel via × / toggle. */
95
+ onSmartOpenChange?: (open: boolean) => void;
96
+ }
97
+ /** Safe, conservative defaults for first mount. */
98
+ declare const DEFAULT_LIGHTING_CONFIG: LightingConfig;
99
+
100
+ /**
101
+ * Top-level lighting picker. Mirrors `Editor`'s lifecycle — `static
102
+ * create(opts)`, wipes the container, owns DOM + WebGL, exposes
103
+ * `destroy()` and reactive `setTheme` / `setLocale`. Separate from
104
+ * the video Editor; the two can coexist in the same host page.
105
+ *
106
+ * Layout (left → right):
107
+ * [scene 240px] [controls 220px] [smartSlot (drawer)]
108
+ * The smart slot is host-supplied. Library renders a × close button
109
+ * + a "Smart mode" toggle in the controls header when the slot is
110
+ * available; `smartEnabled: false` removes the slot entirely.
111
+ */
112
+ declare class LightingEditor {
113
+ private root;
114
+ private opts;
115
+ private config;
116
+ private view;
117
+ private locale;
118
+ private smartEnabled;
119
+ private smartOpen;
120
+ private scene;
121
+ private controls;
122
+ private sceneViewport;
123
+ private viewToggleEl;
124
+ private body;
125
+ private smartWrapper;
126
+ private smartCloseBtn;
127
+ private smartToggleEl;
128
+ private smartToggleThumb;
129
+ /** Host slot the React/Vue wrapper portals/teleports into. Stable
130
+ * reference across smartOpen toggles — only the wrapper around it
131
+ * collapses/expands. Always present even when `smartEnabled: false`
132
+ * so portals don't blow up; just detached from the visible tree. */
133
+ readonly smartSlot: HTMLDivElement;
134
+ private resizeObs;
135
+ private destroyed;
136
+ static create(opts: LightingEditorOptions): LightingEditor;
137
+ constructor(opts: LightingEditorOptions);
138
+ getConfig(): LightingConfig;
139
+ setConfig(partial: Partial<LightingConfig>, _reason?: "external" | "reset"): void;
140
+ setSubjectImage(url: string): void;
141
+ setView(v: LightingView): void;
142
+ getView(): LightingView;
143
+ /** Enable/disable the entire Smart Mode feature at runtime. */
144
+ setSmartEnabled(enabled: boolean): void;
145
+ isSmartEnabled(): boolean;
146
+ /** Open/close the smart slot drawer when enabled. No-op when disabled. */
147
+ setSmartOpen(open: boolean): void;
148
+ isSmartOpen(): boolean;
149
+ setTheme(theme: Theme): void;
150
+ setLocale(locale: Partial<Locale & LightingLocale>): void;
151
+ requestGenerate(): void;
152
+ destroy(): void;
153
+ private applyMutation;
154
+ private buildViewToggle;
155
+ private syncViewToggle;
156
+ /**
157
+ * Build the smart slot column wrapper: × close button + the actual
158
+ * host slot. Wrapper handles the drawer animation; slot reference
159
+ * stays stable so portals don't have to relocate.
160
+ */
161
+ private buildSmartWrapper;
162
+ /** Pill-style toggle that lives in the controls header. Re-opens
163
+ * the smart drawer when the host has closed it via ×. */
164
+ private buildSmartToggle;
165
+ /** Re-translate smart-related labels after a locale swap. */
166
+ private syncSmartLocale;
167
+ /** Mirror smart state to data-* attrs + toggle thumb position.
168
+ * Drives the CSS that collapses the column when closed. */
169
+ private syncSmartState;
170
+ }
171
+
172
+ /**
173
+ * Canonical key-light direction unit vectors. Coordinate space matches
174
+ * three.js's defaults — +X right, +Y up, +Z toward the camera. So
175
+ * `front: (0, 0, 1)` means "light positioned between the camera and
176
+ * the subject," which is the most flattering portrait default.
177
+ */
178
+ declare const PRESET_DIRECTIONS: Record<Exclude<KeyPreset, "custom">, {
179
+ x: number;
180
+ y: number;
181
+ z: number;
182
+ }>;
183
+ /**
184
+ * Decide which preset (if any) a given unit-vector direction snaps to.
185
+ * Returns `"custom"` when no preset is within `PRESET_SNAP_RADIANS`.
186
+ */
187
+ declare function snapToPreset(d: {
188
+ x: number;
189
+ y: number;
190
+ z: number;
191
+ }): KeyPreset;
192
+
193
+ export { DEFAULT_LIGHTING_CONFIG, type KeyPreset, type LightingConfig, LightingEditor, type LightingEditorOptions, type LightingLocale, type LightingView, PRESET_DIRECTIONS, lightingLocaleEn, lightingLocaleZh, mergeLightingLocale, snapToPreset };
@@ -0,0 +1,193 @@
1
+ import { b as Theme, L as Locale } from '../types-C95koNwJ.js';
2
+
3
+ /**
4
+ * Lighting-editor-specific string keys. Kept in a SEPARATE interface
5
+ * from the video editor's `Locale` so the timeline-only consumer's
6
+ * type doesn't grow unused fields, but exported so a single host
7
+ * locale object can spread both shapes together.
8
+ */
9
+ interface LightingLocale {
10
+ lightingGlobalTitle: string;
11
+ lightingSmartMode: string;
12
+ lightingBrightness: string;
13
+ lightingColor: string;
14
+ lightingKeyTitle: string;
15
+ lightingRim: string;
16
+ lightingViewPerspective: string;
17
+ lightingViewFront: string;
18
+ lightingResetParams: string;
19
+ /** Aria label / tooltip for the × button that closes the Smart panel. */
20
+ lightingSmartClose: string;
21
+ /** Tooltip / label for the controls-header Smart Mode toggle. */
22
+ lightingSmartToggle: string;
23
+ lightingDirLeft: string;
24
+ lightingDirRight: string;
25
+ lightingDirTop: string;
26
+ lightingDirBottom: string;
27
+ lightingDirFront: string;
28
+ lightingDirBack: string;
29
+ }
30
+ declare const lightingLocaleEn: LightingLocale;
31
+ declare const lightingLocaleZh: LightingLocale;
32
+ declare function mergeLightingLocale(partial: Partial<LightingLocale> | undefined): LightingLocale;
33
+
34
+ /** One of the six canonical key-light directions plus a sentinel for free-drag. */
35
+ type KeyPreset = "left" | "right" | "top" | "bottom" | "front" | "back" | "custom";
36
+ /** Snapshot of every adjustable lighting parameter — what `onChange` emits. */
37
+ interface LightingConfig {
38
+ /** 0–1 multiplier. Snapped to 5 UI levels (0 / 0.25 / 0.5 / 0.75 / 1). */
39
+ brightness: number;
40
+ /** Hex RGB string, e.g. "#ffffff". */
41
+ color: string;
42
+ /**
43
+ * Unit vector from the subject toward the light. `(0,0,1)` = light in
44
+ * front of the subject, `(0,1,0)` = light directly overhead, etc.
45
+ * Always renormalised on write.
46
+ */
47
+ keyDirection: {
48
+ x: number;
49
+ y: number;
50
+ z: number;
51
+ };
52
+ /** Which canonical direction the dot is closest to, or `"custom"`. */
53
+ keyPreset: KeyPreset;
54
+ /** Rim / contour light toggle. */
55
+ rim: boolean;
56
+ }
57
+ type LightingView = "perspective" | "front";
58
+ interface LightingEditorOptions {
59
+ /** Host element. Will be wiped on init. */
60
+ container: HTMLElement;
61
+ /**
62
+ * Image URL or data URI shown on the in-sphere plane (the "subject"
63
+ * being lit). Can be swapped at runtime via `setSubjectImage`.
64
+ */
65
+ subjectImageUrl?: string;
66
+ /** Initial config — merges over the safe defaults below. */
67
+ config?: Partial<LightingConfig>;
68
+ /** Initial camera view. Default `"perspective"`. */
69
+ view?: LightingView;
70
+ /**
71
+ * Whether the Smart Mode feature is wired in at all. When false the
72
+ * slot column never renders and the controls header hides the
73
+ * Smart Mode toggle — the layout becomes a clean 2-column
74
+ * (scene + controls). Default `true`.
75
+ */
76
+ smartEnabled?: boolean;
77
+ /**
78
+ * When `smartEnabled` is true, whether the Smart Mode slot panel
79
+ * starts open. Hosts toggle later via `api.setSmartOpen(bool)` or
80
+ * by clicking the library-rendered × button. Default `true`.
81
+ */
82
+ smartOpen?: boolean;
83
+ /** Theme tokens — same shape as the video Editor's theme. */
84
+ theme?: Theme;
85
+ /** Locale overrides on top of English defaults (`localeEn` + `lightingLocaleEn`). */
86
+ locale?: Partial<Locale & LightingLocale>;
87
+ /** Fires on any config mutation (drag, slider, preset click, toggle). */
88
+ onChange?: (cfg: LightingConfig) => void;
89
+ /**
90
+ * Surface event for the host's own "Generate" button — the library
91
+ * never wires this. Use `api.requestGenerate()` from your UI.
92
+ */
93
+ onGenerate?: (cfg: LightingConfig) => void;
94
+ /** Fires when the user toggles the Smart Mode panel via × / toggle. */
95
+ onSmartOpenChange?: (open: boolean) => void;
96
+ }
97
+ /** Safe, conservative defaults for first mount. */
98
+ declare const DEFAULT_LIGHTING_CONFIG: LightingConfig;
99
+
100
+ /**
101
+ * Top-level lighting picker. Mirrors `Editor`'s lifecycle — `static
102
+ * create(opts)`, wipes the container, owns DOM + WebGL, exposes
103
+ * `destroy()` and reactive `setTheme` / `setLocale`. Separate from
104
+ * the video Editor; the two can coexist in the same host page.
105
+ *
106
+ * Layout (left → right):
107
+ * [scene 240px] [controls 220px] [smartSlot (drawer)]
108
+ * The smart slot is host-supplied. Library renders a × close button
109
+ * + a "Smart mode" toggle in the controls header when the slot is
110
+ * available; `smartEnabled: false` removes the slot entirely.
111
+ */
112
+ declare class LightingEditor {
113
+ private root;
114
+ private opts;
115
+ private config;
116
+ private view;
117
+ private locale;
118
+ private smartEnabled;
119
+ private smartOpen;
120
+ private scene;
121
+ private controls;
122
+ private sceneViewport;
123
+ private viewToggleEl;
124
+ private body;
125
+ private smartWrapper;
126
+ private smartCloseBtn;
127
+ private smartToggleEl;
128
+ private smartToggleThumb;
129
+ /** Host slot the React/Vue wrapper portals/teleports into. Stable
130
+ * reference across smartOpen toggles — only the wrapper around it
131
+ * collapses/expands. Always present even when `smartEnabled: false`
132
+ * so portals don't blow up; just detached from the visible tree. */
133
+ readonly smartSlot: HTMLDivElement;
134
+ private resizeObs;
135
+ private destroyed;
136
+ static create(opts: LightingEditorOptions): LightingEditor;
137
+ constructor(opts: LightingEditorOptions);
138
+ getConfig(): LightingConfig;
139
+ setConfig(partial: Partial<LightingConfig>, _reason?: "external" | "reset"): void;
140
+ setSubjectImage(url: string): void;
141
+ setView(v: LightingView): void;
142
+ getView(): LightingView;
143
+ /** Enable/disable the entire Smart Mode feature at runtime. */
144
+ setSmartEnabled(enabled: boolean): void;
145
+ isSmartEnabled(): boolean;
146
+ /** Open/close the smart slot drawer when enabled. No-op when disabled. */
147
+ setSmartOpen(open: boolean): void;
148
+ isSmartOpen(): boolean;
149
+ setTheme(theme: Theme): void;
150
+ setLocale(locale: Partial<Locale & LightingLocale>): void;
151
+ requestGenerate(): void;
152
+ destroy(): void;
153
+ private applyMutation;
154
+ private buildViewToggle;
155
+ private syncViewToggle;
156
+ /**
157
+ * Build the smart slot column wrapper: × close button + the actual
158
+ * host slot. Wrapper handles the drawer animation; slot reference
159
+ * stays stable so portals don't have to relocate.
160
+ */
161
+ private buildSmartWrapper;
162
+ /** Pill-style toggle that lives in the controls header. Re-opens
163
+ * the smart drawer when the host has closed it via ×. */
164
+ private buildSmartToggle;
165
+ /** Re-translate smart-related labels after a locale swap. */
166
+ private syncSmartLocale;
167
+ /** Mirror smart state to data-* attrs + toggle thumb position.
168
+ * Drives the CSS that collapses the column when closed. */
169
+ private syncSmartState;
170
+ }
171
+
172
+ /**
173
+ * Canonical key-light direction unit vectors. Coordinate space matches
174
+ * three.js's defaults — +X right, +Y up, +Z toward the camera. So
175
+ * `front: (0, 0, 1)` means "light positioned between the camera and
176
+ * the subject," which is the most flattering portrait default.
177
+ */
178
+ declare const PRESET_DIRECTIONS: Record<Exclude<KeyPreset, "custom">, {
179
+ x: number;
180
+ y: number;
181
+ z: number;
182
+ }>;
183
+ /**
184
+ * Decide which preset (if any) a given unit-vector direction snaps to.
185
+ * Returns `"custom"` when no preset is within `PRESET_SNAP_RADIANS`.
186
+ */
187
+ declare function snapToPreset(d: {
188
+ x: number;
189
+ y: number;
190
+ z: number;
191
+ }): KeyPreset;
192
+
193
+ export { DEFAULT_LIGHTING_CONFIG, type KeyPreset, type LightingConfig, LightingEditor, type LightingEditorOptions, type LightingLocale, type LightingView, PRESET_DIRECTIONS, lightingLocaleEn, lightingLocaleZh, mergeLightingLocale, snapToPreset };