@melite/models-h3 0.0.0-stage → 0.1.5-pre-alpha

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,79 @@
1
+ export declare const SEAM_OVERLAP_FRAMES = 22;
2
+ export declare const GRID_BASE_FRAMES = 22;
3
+ export declare const GRID_STEP_FRAMES = 17;
4
+ export declare const GRID_MAX_FRAMES = 362;
5
+ export declare const GRID_REMAINDER = 5;
6
+ export declare const IMAGE_BUS_SLOTS = 9;
7
+ export declare const REF_CAPS: {
8
+ readonly images: 8;
9
+ readonly videos: 3;
10
+ readonly audios: 3;
11
+ readonly refmods: 8;
12
+ };
13
+ export interface TimelineSpan {
14
+ readonly start: number;
15
+ readonly end: number;
16
+ readonly transition?: string;
17
+ }
18
+ export interface TimelineCallSpan {
19
+ readonly start_frame: number;
20
+ readonly end_frame: number;
21
+ readonly transition?: string;
22
+ }
23
+ export declare function transitionOverlap(transition?: string): number;
24
+ export declare function spanOverlap(span: TimelineSpan): number;
25
+ export declare function spanStanzaFrames(span: TimelineSpan, carry?: number): number;
26
+ export interface CarriedSpanGrid {
27
+ readonly generatedStart: number;
28
+ readonly generatedEnd: number;
29
+ readonly length: number;
30
+ readonly lowerEnd: number;
31
+ readonly upperEnd: number;
32
+ }
33
+ export declare function carriedSpanGrid(span: TimelineSpan, carry?: number): CarriedSpanGrid;
34
+ export declare function assertCarriedSpanGrid(span: TimelineSpan, where: string, carry?: number): number;
35
+ export declare function gridSnap(length: number): number;
36
+ /** THE GRID PREDICATE, one owner: a length the engine can render is
37
+ * 22+17k inside [22,362]. Every refusal door asks this question, so
38
+ * knob pins, single windows, cut windows, and carried windows cannot
39
+ * drift into different laws. */
40
+ export declare function isGridLength(length: number): boolean;
41
+ export declare function assertGridLength(length: unknown, where: string): number;
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ export declare function assertSpanGrid(span: TimelineSpan, where: string, carry?: number): number;
51
+ export declare function deliveredFrames(call: TimelineCallSpan, index: number): number;
52
+ export declare function imageReferenceCap(hasLastFrame: boolean): number;
53
+ export declare function splitRefList(value: string | undefined): string[];
54
+ export declare function normalizeDeclaredRefs(value: unknown): string[];
55
+ export declare function joinRefList(value: unknown): string | undefined;
56
+ export declare function refGenreOf(name: string, url?: string): 'image' | 'video' | 'audio' | 'other';
57
+ export declare const KNOB_ORDER: readonly ["steps", "denoise", "sampler_name", "sched_name", "shift_video", "shift_audio", "sla_sparsity", "sla_block_size", "sla_min_seq_len", "sla_dense_last_steps", "sla_protect_audio", "sla_stabilize_motion", "sla_reference_protection", "sla_dense_backend", "sla_dense_steps", "sla_disable_fp16_accum", "sharpen_enabled", "sharpen_method", "sharpen_strength", "sharpen_radius", "sharpen_threshold", "sharpen_iterations", "interpolate_enabled", "interp_model", "interp_multiplier", "length"];
58
+ export type KnobKey = (typeof KNOB_ORDER)[number];
59
+ export declare const CALL_KNOB_KEYS: ReadonlySet<string>;
60
+ export declare const CALL_KEYS: ReadonlySet<string>;
61
+ export declare const LEGACY_KNOB_KEY: {
62
+ readonly sampling_steps: "steps";
63
+ readonly sampler: "sampler_name";
64
+ readonly scheduler: "sched_name";
65
+ readonly h3_sla_sparsity: "sla_sparsity";
66
+ readonly h3_sla_block_size: "sla_block_size";
67
+ readonly h3_sla_min_seq_len: "sla_min_seq_len";
68
+ readonly h3_sla_dense_last_steps: "sla_dense_last_steps";
69
+ readonly h3_sla_protect_audio: "sla_protect_audio";
70
+ readonly h3_sla_stabilize_motion: "sla_stabilize_motion";
71
+ readonly h3_sla_reference_protection: "sla_reference_protection";
72
+ readonly h3_sla_dense_backend: "sla_dense_backend";
73
+ readonly h3_sla_dense_steps: "sla_dense_steps";
74
+ readonly h3_sla_disable_fp16_accum: "sla_disable_fp16_accum";
75
+ readonly interpolate_model: "interp_model";
76
+ readonly interpolate_multiplier: "interp_multiplier";
77
+ };
78
+ export declare function migrateCallKnobKey(key: string): string;
79
+ //# sourceMappingURL=timelineContract.d.ts.map
@@ -0,0 +1,216 @@
1
+ export const SEAM_OVERLAP_FRAMES = 22;
2
+ export const GRID_BASE_FRAMES = 22;
3
+ export const GRID_STEP_FRAMES = 17;
4
+ export const GRID_MAX_FRAMES = 362;
5
+ export const GRID_REMAINDER = 5;
6
+ export const IMAGE_BUS_SLOTS = 9;
7
+ export const REF_CAPS = {
8
+ images: 8,
9
+ videos: 3,
10
+ audios: 3,
11
+
12
+ // owns MAX_SLOTS = 8 — one slot per mod; strength/copies ride
13
+ // the loader row the compose fills.
14
+ refmods: 8,
15
+ };
16
+ export function transitionOverlap(transition) {
17
+ return transition === 'cut' ? 0 : SEAM_OVERLAP_FRAMES;
18
+ }
19
+ export function spanOverlap(span) {
20
+ return transitionOverlap(span.transition);
21
+ }
22
+ export function spanStanzaFrames(span, carry = 0) {
23
+ const k = Math.round((span.end - span.start + carry - GRID_BASE_FRAMES) / GRID_STEP_FRAMES);
24
+ return Math.min(GRID_MAX_FRAMES, Math.max(GRID_BASE_FRAMES, GRID_BASE_FRAMES + GRID_STEP_FRAMES * k));
25
+ }
26
+ export function carriedSpanGrid(span, carry = SEAM_OVERLAP_FRAMES) {
27
+ const generatedStart = span.start - carry;
28
+ const requestedLength = span.end - span.start + carry;
29
+ const length = spanStanzaFrames(span, carry);
30
+ const rawIndex = (requestedLength - GRID_BASE_FRAMES) / GRID_STEP_FRAMES;
31
+ const maxIndex = (GRID_MAX_FRAMES - GRID_BASE_FRAMES) / GRID_STEP_FRAMES;
32
+ const lowerIndex = Math.max(0, Math.min(maxIndex, Math.floor(rawIndex)));
33
+ const upperIndex = Math.max(0, Math.min(maxIndex, Math.ceil(rawIndex)));
34
+ const endAt = (index) => generatedStart + GRID_BASE_FRAMES + GRID_STEP_FRAMES * index;
35
+ return {
36
+ generatedStart,
37
+ generatedEnd: generatedStart + length,
38
+ length,
39
+ lowerEnd: endAt(lowerIndex),
40
+ upperEnd: endAt(upperIndex),
41
+ };
42
+ }
43
+ export function assertCarriedSpanGrid(span, where, carry = SEAM_OVERLAP_FRAMES) {
44
+ const grid = carriedSpanGrid(span, carry);
45
+ const requestedLength = span.end - span.start + carry;
46
+ if (grid.length !== requestedLength) {
47
+ const legal = grid.lowerEnd === grid.upperEnd
48
+ ? `${grid.lowerEnd}`
49
+ : `${grid.lowerEnd} and ${grid.upperEnd}`;
50
+ throw new Error(`${where}: authored range ${span.start}→${span.end} cannot land on the 22+17k carried grid; ` +
51
+ `generated snapped range ${grid.generatedStart}→${grid.generatedEnd}; ` +
52
+ `legal neighboring end frames ${legal} ` +
53
+ `(a carried window's span is 17f — its 22f seam is the generation head; ` +
54
+ `a first or cut window is 22+17f)`);
55
+ }
56
+ return grid.length;
57
+ }
58
+ export function gridSnap(length) {
59
+ const k = Math.round((length - GRID_BASE_FRAMES) / GRID_STEP_FRAMES);
60
+ return Math.min(GRID_MAX_FRAMES, Math.max(GRID_BASE_FRAMES, GRID_BASE_FRAMES + GRID_STEP_FRAMES * k));
61
+ }
62
+ /** THE GRID PREDICATE, one owner: a length the engine can render is
63
+ * 22+17k inside [22,362]. Every refusal door asks this question, so
64
+ * knob pins, single windows, cut windows, and carried windows cannot
65
+ * drift into different laws. */
66
+ export function isGridLength(length) {
67
+ return Number.isInteger(length) &&
68
+ length >= GRID_BASE_FRAMES &&
69
+ length <= GRID_MAX_FRAMES &&
70
+ (length - GRID_BASE_FRAMES) % GRID_STEP_FRAMES === 0;
71
+ }
72
+ export function assertGridLength(length, where) {
73
+ if (typeof length !== 'number' || !isGridLength(length)) {
74
+ const nearest = typeof length === 'number' && Number.isFinite(length)
75
+ ? gridSnap(Math.min(GRID_MAX_FRAMES, Math.max(GRID_BASE_FRAMES, Math.round(length))))
76
+ : 124;
77
+ throw new Error(`${where}: length ${String(length)}f is off-grid — the engine renders ` +
78
+ `22+17k frames in [22,362] (nearest legal: ${nearest}f); ` +
79
+ `the doc-proven geometry is 0→124→243→362`);
80
+ }
81
+ return length;
82
+ }
83
+
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ export function assertSpanGrid(span, where, carry = 0) {
92
+ if (carry > 0)
93
+ return assertCarriedSpanGrid(span, where, carry);
94
+ const length = span.end - span.start;
95
+ if (!isGridLength(length)) {
96
+ throw new Error(`${where}: authored range ${span.start}→${span.end} has length ${length}f, which cannot land on the 22+17k grid ` +
97
+ `(nearest legal: ${gridSnap(length)}f); the doc-proven geometry is 0→124→243→362 ` +
98
+ `(a first or cut window is 22+17f; a carried window's span is 17f — its 22f seam is the generation head)`);
99
+ }
100
+ return length;
101
+ }
102
+ export function deliveredFrames(call, index) {
103
+ const span = call.end_frame - call.start_frame;
104
+ if (index === 0 || call.transition === 'cut')
105
+ return span;
106
+ return Math.max(0, span - SEAM_OVERLAP_FRAMES);
107
+ }
108
+ export function imageReferenceCap(hasLastFrame) {
109
+ return hasLastFrame ? REF_CAPS.images - 1 : REF_CAPS.images;
110
+ }
111
+ export function splitRefList(value) {
112
+ if (!value)
113
+ return [];
114
+ const out = [];
115
+ let i = 0;
116
+ while (i < value.length) {
117
+ while (i < value.length && (value[i] === ',' || value[i] === ' ' || value[i] === '\t'))
118
+ i++;
119
+ if (i >= value.length)
120
+ break;
121
+ const start = i;
122
+ const isData = value.startsWith('data:', i);
123
+ let mimeComma = false;
124
+ while (i < value.length) {
125
+ if (value[i] === ',') {
126
+ if (isData && !mimeComma) {
127
+ mimeComma = true;
128
+ i++;
129
+ continue;
130
+ }
131
+ break;
132
+ }
133
+ i++;
134
+ }
135
+ let end = i;
136
+ while (end > start && (value[end - 1] === ' ' || value[end - 1] === '\t'))
137
+ end--;
138
+ out.push(value.slice(start, end));
139
+ }
140
+ return out;
141
+ }
142
+ export function normalizeDeclaredRefs(value) {
143
+ if (Array.isArray(value)) {
144
+ return value.filter((entry) => typeof entry === 'string' && entry.trim() !== '');
145
+ }
146
+ if (typeof value === 'string')
147
+ return splitRefList(value);
148
+ return [];
149
+ }
150
+ export function joinRefList(value) {
151
+ if (Array.isArray(value)) {
152
+ const entries = value.map(String).map((entry) => entry.trim()).filter(Boolean);
153
+ return entries.length > 0 ? entries.join(', ') : undefined;
154
+ }
155
+ if (typeof value === 'string' && value.trim())
156
+ return value.trim();
157
+ return undefined;
158
+ }
159
+ export function refGenreOf(name, url) {
160
+ const lowerName = name.toLowerCase();
161
+ if (/^video_w\d+_/.test(lowerName)) {
162
+ if (lowerName.endsWith('_last_frame') || lowerName.includes('_prev'))
163
+ return 'image';
164
+ return 'video';
165
+ }
166
+ const source = `${lowerName} ${url ? url.toLowerCase().split('?')[0] : ''}`;
167
+ const extension = source.split('.').pop().split(/[^a-z0-9]/)[0];
168
+ if (['png', 'jpg', 'jpeg', 'webp', 'gif', 'bmp', 'avif'].includes(extension))
169
+ return 'image';
170
+ if (['mp4', 'webm', 'mov', 'mkv', 'avi', 'm4v'].includes(extension))
171
+ return 'video';
172
+ if (['mp3', 'wav', 'flac', 'ogg', 'm4a', 'aac', 'opus'].includes(extension))
173
+ return 'audio';
174
+ return 'other';
175
+ }
176
+ export const KNOB_ORDER = [
177
+ 'steps', 'denoise', 'sampler_name', 'sched_name',
178
+ 'shift_video', 'shift_audio',
179
+ 'sla_sparsity', 'sla_block_size',
180
+ 'sla_min_seq_len', 'sla_dense_last_steps',
181
+ 'sla_protect_audio', 'sla_stabilize_motion',
182
+ 'sla_reference_protection', 'sla_dense_backend',
183
+ 'sla_dense_steps', 'sla_disable_fp16_accum',
184
+ 'sharpen_enabled', 'sharpen_method', 'sharpen_strength',
185
+ 'sharpen_radius', 'sharpen_threshold', 'sharpen_iterations',
186
+ 'interpolate_enabled', 'interp_model', 'interp_multiplier',
187
+ 'length',
188
+ ];
189
+ export const CALL_KNOB_KEYS = new Set(KNOB_ORDER);
190
+ export const CALL_KEYS = new Set([
191
+ 'text', 'start_frame', 'end_frame', 'image', 'clip', 'audio',
192
+ 'transition', 'knobs', 'refs',
193
+ 'ref_image', 'image_name', 'ref_images', 'ref_videos', 'ref_audios',
194
+ 'beats', 'last_frame', 'first_frame_prev_sec', 'seam_carry',
195
+ ]);
196
+ export const LEGACY_KNOB_KEY = {
197
+ sampling_steps: 'steps',
198
+ sampler: 'sampler_name',
199
+ scheduler: 'sched_name',
200
+ h3_sla_sparsity: 'sla_sparsity',
201
+ h3_sla_block_size: 'sla_block_size',
202
+ h3_sla_min_seq_len: 'sla_min_seq_len',
203
+ h3_sla_dense_last_steps: 'sla_dense_last_steps',
204
+ h3_sla_protect_audio: 'sla_protect_audio',
205
+ h3_sla_stabilize_motion: 'sla_stabilize_motion',
206
+ h3_sla_reference_protection: 'sla_reference_protection',
207
+ h3_sla_dense_backend: 'sla_dense_backend',
208
+ h3_sla_dense_steps: 'sla_dense_steps',
209
+ h3_sla_disable_fp16_accum: 'sla_disable_fp16_accum',
210
+ interpolate_model: 'interp_model',
211
+ interpolate_multiplier: 'interp_multiplier',
212
+ };
213
+ export function migrateCallKnobKey(key) {
214
+ return LEGACY_KNOB_KEY[key] ?? key;
215
+ }
216
+ //# sourceMappingURL=timelineContract.js.map
package/package.json CHANGED
@@ -1,6 +1,60 @@
1
1
  {
2
2
  "name": "@melite/models-h3",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.5-pre-alpha",
4
+ "license": "SSPL-1.0",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./lib/index.d.ts",
9
+ "default": "./lib/index.js"
10
+ },
11
+ "./package.json": "./package.json",
12
+ "./mods/loras": {
13
+ "types": "./lib/mods/loras.d.ts",
14
+ "default": "./lib/mods/loras.js"
15
+ },
16
+ "./timelineContract": {
17
+ "types": "./lib/timelineContract.d.ts",
18
+ "default": "./lib/timelineContract.js"
19
+ },
20
+ "./filmMix": {
21
+ "types": "./lib/filmMix.d.ts",
22
+ "default": "./lib/filmMix.js"
23
+ },
24
+ "./actions": {
25
+ "types": "./lib/actions.d.ts",
26
+ "default": "./lib/actions.js"
27
+ },
28
+ "./schema": {
29
+ "types": "./lib/schema.d.ts",
30
+ "default": "./lib/schema.js"
31
+ }
32
+ },
33
+ "dependencies": {
34
+ "@deepseek-ai/schemastery": "^3.18.4",
35
+ "@melite/contracts": "0.1.5-pre-alpha",
36
+ "@melite/comfyui-card-kit": "0.1.5-pre-alpha"
37
+ },
38
+ "devDependencies": {
39
+ "@types/node": "^22.20.0",
40
+ "typescript": "^5.9.3",
41
+ "@deepseek-ai/cordis": "^4.0.4",
42
+ "@deepseek-ai/cosmokit": "~1.8.5"
43
+ },
44
+ "files": [
45
+ "lib/index.js",
46
+ "lib/**/*.js",
47
+ "lib/**/*.d.ts"
48
+ ],
49
+ "peerDependencies": {
50
+ "@deepseek-ai/cordis": "^4.0.4",
51
+ "@deepseek-ai/cosmokit": "~1.8.5"
52
+ },
53
+ "scripts": {
54
+ "build": "tsc -p tsconfig.build-mods.json && tsc -p tsconfig.build.json",
55
+ "typecheck": "tsc --noEmit"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }