@melite/models-h3 0.1.5-pre-alpha → 0.2.2-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.
- package/LICENSE +561 -457
- package/README.md +11 -16
- package/lib/actions.d.ts +100 -17
- package/lib/actions.js +1505 -257
- package/lib/chainEdit.d.ts +196 -0
- package/lib/chainEdit.js +334 -0
- package/lib/chainUpscale.d.ts +25 -0
- package/lib/chainUpscale.js +134 -0
- package/lib/extend.d.ts +25 -0
- package/lib/extend.js +221 -0
- package/lib/filmMix.d.ts +28 -12
- package/lib/filmMix.js +47 -16
- package/lib/finalize.js +6 -1
- package/lib/index.d.ts +12 -0
- package/lib/index.js +269 -65
- package/lib/mods/loras.d.ts +18 -95
- package/lib/mods/loras.js +35 -10
- package/lib/refine.d.ts +170 -0
- package/lib/refine.js +775 -0
- package/lib/repair.d.ts +15 -0
- package/lib/repair.js +164 -0
- package/lib/reshoot.d.ts +201 -0
- package/lib/reshoot.js +399 -0
- package/lib/schema.d.ts +70 -13
- package/lib/schema.js +342 -60
- package/lib/swap.d.ts +14 -0
- package/lib/swap.js +95 -0
- package/lib/timelineContract.d.ts +170 -0
- package/lib/timelineContract.js +238 -2
- package/lib/windowSpec.d.ts +23 -0
- package/lib/windowSpec.js +49 -0
- package/package.json +23 -12
package/lib/swap.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { loadVideo, renderMaskedEditChain } from './chainEdit.js';
|
|
2
|
+
/** The swap entry's required media + text seats (the reshoot idiom:
|
|
3
|
+
* an armed doc with an empty seat refuses loud naming the seat). */
|
|
4
|
+
const REQUIRED_SEATS = [
|
|
5
|
+
['source_clip', 'the source video whose person is replaced — ONE staged leaf: the VHS slice loader + the core LoadVideo read it by staged name, and the timeline reads it back off the native VIDEO wire (its video_path string rides along staged but unread)'],
|
|
6
|
+
['still', 'the replacement still (the R2V ref_images LoadImage + the plan picture_1)'],
|
|
7
|
+
['mannequin', 'the mannequin video from the track-card run (the R2V ref_videos H3GreyMannequins output)'],
|
|
8
|
+
['mask', 'ONE staged PNG from the track-card run — the pixel-max UNION of its grown per-frame masks is recommended (per-frame motion rides the mannequin; the edit-latent + masked-target mask, reference GrowMaskWithBlur expand 40)'],
|
|
9
|
+
['swap_prompt', 'the swap action text (agent-composed, user-confirmed — the R2V prompt seat; the estate has no in-graph describers)'],
|
|
10
|
+
];
|
|
11
|
+
const str = (p, k) => typeof p[k] === 'string' ? p[k] : '';
|
|
12
|
+
const num = (p, k, d) => typeof p[k] === 'number' ? p[k] : d;
|
|
13
|
+
/** The swap renderer: validates the bound entry, then composes the
|
|
14
|
+
* masked-edit chain per the reference map above. The film path
|
|
15
|
+
* never reaches here (the card branches ONLY on a non-empty replace
|
|
16
|
+
* bag, and refuses a bag under an armed reshoot — one door per doc).
|
|
17
|
+
* @param entry the replace mod's single bound entry
|
|
18
|
+
* @param p the walked doc params (the lora mod bag + SLA/shift knobs —
|
|
19
|
+
* the family plane this swap renders under)
|
|
20
|
+
* @param facts the family's lane facts (unet off the DECL row)
|
|
21
|
+
* @param g the run's graph builder
|
|
22
|
+
* @param runId the run tree's id (the assemble filename rides it) */
|
|
23
|
+
export function renderH3Swap(entry, p, facts, g, runId) {
|
|
24
|
+
for (const [seat, what] of REQUIRED_SEATS) {
|
|
25
|
+
const v = entry[seat];
|
|
26
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
27
|
+
throw new Error(`h3-timeline replace: '${seat}' names no media — ${what}; a swap needs all five seats bound (source_clip, still, mannequin, mask, swap_prompt)`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const keepAudio = entry.keep_audio !== false;
|
|
31
|
+
const seed = num(entry, 'seed', 0);
|
|
32
|
+
const steps = num(entry, 'steps', 6);
|
|
33
|
+
const clipSeconds = num(entry, 'clip_seconds', 6);
|
|
34
|
+
const resolution = str(entry, 'resolution') || '736p';
|
|
35
|
+
// ── the staged media (the R0 cards' artifacts: the source clip,
|
|
36
|
+
// the still, the track card's mannequin + grown mask) ──
|
|
37
|
+
const [srcFrames, srcAudio] = loadVideo(g, str(entry, 'source_clip'));
|
|
38
|
+
const stillImg = g.node('LoadImage', { image: str(entry, 'still') }).out(0);
|
|
39
|
+
const maskOf = g.node('ImageToMask', {
|
|
40
|
+
image: g.node('LoadImage', { image: str(entry, 'mask') }).out(0),
|
|
41
|
+
channel: 'red',
|
|
42
|
+
}).out(0);
|
|
43
|
+
const [mannequin] = loadVideo(g, str(entry, 'mannequin'));
|
|
44
|
+
renderMaskedEditChain(g, {
|
|
45
|
+
p, facts,
|
|
46
|
+
clipSeconds,
|
|
47
|
+
overlapFrames: num(entry, 'overlap_frames', 39),
|
|
48
|
+
resolution, seed, steps,
|
|
49
|
+
roles: str(entry, 'roles'),
|
|
50
|
+
sourceClip: str(entry, 'source_clip'),
|
|
51
|
+
windowStart: 0,
|
|
52
|
+
picture1: stillImg,
|
|
53
|
+
srcFrames, srcAudio,
|
|
54
|
+
// the ignored literal fallback — the plan node's SOURCE-SLICED
|
|
55
|
+
// shots ride plan_json_input (the swap's own semantics)
|
|
56
|
+
planJson: JSON.stringify({ shots: [{ id: 'swap', prompt: str(entry, 'swap_prompt') }] }),
|
|
57
|
+
planFromSource: true,
|
|
58
|
+
denoise: 1,
|
|
59
|
+
assemble: {
|
|
60
|
+
audioSource: keepAudio ? 'source' : 'generated',
|
|
61
|
+
filename: `${runId}/swap`,
|
|
62
|
+
},
|
|
63
|
+
body: ({ cur, clip, vaeVideo, vaeAudio, mutedChainAudio, sliceAudio }) => {
|
|
64
|
+
// ── the masked edit body: the still anchors identity, the
|
|
65
|
+
// mannequin carries motion, the staged PNG masks the edit ──
|
|
66
|
+
const r2v = g.node('MiniMaxH3ReferenceToVideo', {
|
|
67
|
+
prompt: str(entry, 'swap_prompt'),
|
|
68
|
+
width: cur.out(8), height: cur.out(9), length: cur.out(6),
|
|
69
|
+
ref_image_size: 'match',
|
|
70
|
+
clip, vae: vaeVideo, audio_vae: vaeAudio,
|
|
71
|
+
'ref_images.ref_image_0': stillImg,
|
|
72
|
+
'ref_videos.ref_video_0': mannequin,
|
|
73
|
+
'ref_video_audios.ref_video_audio_0': mutedChainAudio,
|
|
74
|
+
});
|
|
75
|
+
const slice = g.node('H3SourceSlice', {
|
|
76
|
+
source_fps: 24, crop: 'center',
|
|
77
|
+
state: cur.out(0), latent: r2v.out(1),
|
|
78
|
+
audio_vae: vaeAudio, source_frames: srcFrames, source_audio: sliceAudio,
|
|
79
|
+
});
|
|
80
|
+
const edit = g.node('MiniMaxH3FantasticVideoEditLatent', {
|
|
81
|
+
grow: 0, keep_audio: keepAudio, megapixels: 0,
|
|
82
|
+
vae: vaeVideo, images: slice.out(0), mask: maskOf,
|
|
83
|
+
audio_vae: vaeAudio, audio: slice.out(1),
|
|
84
|
+
}).out(0);
|
|
85
|
+
const target = g.node('MiniMaxH3ContexMaskedTarget', {
|
|
86
|
+
mask_meaning: 'white = generate',
|
|
87
|
+
audio_mode: keepAudio ? 'preserve source audio' : 'generate all audio',
|
|
88
|
+
mask_conversion: 'H3 exact (causal/token max)',
|
|
89
|
+
target_latent: edit, mask: maskOf,
|
|
90
|
+
}).out(0);
|
|
91
|
+
return { conditioning: r2v.out(0), targetLatent: target };
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=swap.js.map
|
|
@@ -20,7 +20,126 @@ export interface TimelineCallSpan {
|
|
|
20
20
|
readonly end_frame: number;
|
|
21
21
|
readonly transition?: string;
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export declare function isMediaRef(v: string): boolean;
|
|
23
32
|
export declare function transitionOverlap(transition?: string): number;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
export declare const DOC_FPS_DEFAULT: 24;
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
export declare const FILM_ONLY_KEYS: readonly ["duck_depth_db"];
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
export declare const FAMILY_LAW: {
|
|
111
|
+
readonly lanes: readonly [{
|
|
112
|
+
readonly lane: "t4_chain";
|
|
113
|
+
readonly minCalls: 2;
|
|
114
|
+
}, {
|
|
115
|
+
readonly lane: "t4r";
|
|
116
|
+
readonly guideKeys: readonly ["keyframes", "last_frame", "ref_images", "ref_videos", "ref_audios", "image", "image_name", "ref_image"];
|
|
117
|
+
readonly callGuideKeys: readonly ["image", "ref_images", "ref_image", "image_name"];
|
|
118
|
+
}, {
|
|
119
|
+
readonly lane: "t4_open";
|
|
120
|
+
}];
|
|
121
|
+
readonly deadKeys: {};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
export declare function deriveWindowFamily(raw: Record<string, unknown>): 't4r' | 't4_open' | 't4_chain';
|
|
24
143
|
export declare function spanOverlap(span: TimelineSpan): number;
|
|
25
144
|
export declare function spanStanzaFrames(span: TimelineSpan, carry?: number): number;
|
|
26
145
|
export interface CarriedSpanGrid {
|
|
@@ -32,6 +151,12 @@ export interface CarriedSpanGrid {
|
|
|
32
151
|
}
|
|
33
152
|
export declare function carriedSpanGrid(span: TimelineSpan, carry?: number): CarriedSpanGrid;
|
|
34
153
|
export declare function assertCarriedSpanGrid(span: TimelineSpan, where: string, carry?: number): number;
|
|
154
|
+
/** The booked render clock, one home: the seconds seat rounds its
|
|
155
|
+
* quotient to milliseconds before it rides the wire, so every
|
|
156
|
+
* consumer that needs the value the graph will actually carry (the
|
|
157
|
+
* schema's own rail bounds, the mix ledger) books through here —
|
|
158
|
+
* never a second copy of the rounding. */
|
|
159
|
+
export declare function bookSeconds(lengthFrames: number, fps: number): number;
|
|
35
160
|
export declare function gridSnap(length: number): number;
|
|
36
161
|
/** THE GRID PREDICATE, one owner: a length the engine can render is
|
|
37
162
|
* 22+17k inside [22,362]. Every refusal door asks this question, so
|
|
@@ -39,6 +164,36 @@ export declare function gridSnap(length: number): number;
|
|
|
39
164
|
* drift into different laws. */
|
|
40
165
|
export declare function isGridLength(length: number): boolean;
|
|
41
166
|
export declare function assertGridLength(length: unknown, where: string): number;
|
|
167
|
+
/** The chain policy's masked_av context — the overlap every composed
|
|
168
|
+
* seam after the first carries (the swap's clip law, shared with the
|
|
169
|
+
* extend's window composition). */
|
|
170
|
+
export declare const CONTEXT_OVERLAP_FRAMES = 39;
|
|
171
|
+
/** The plan's scene cap (chain_nodes: a 32-scene cap refuses
|
|
172
|
+
* mis-authored loops) — the composition solver's window ceiling. */
|
|
173
|
+
export declare const MAX_COMPOSED_WINDOWS = 32;
|
|
174
|
+
/** One legal composition of a stated extension. */
|
|
175
|
+
export interface WindowComposition {
|
|
176
|
+
readonly windows: number;
|
|
177
|
+
readonly windowFrames: number;
|
|
178
|
+
readonly deliveredFrames: number;
|
|
179
|
+
}
|
|
180
|
+
/** THE COMPOSITION SOLVER (pure; the door's whole law beyond one
|
|
181
|
+
* window): across every legal window count, the grid lengths on
|
|
182
|
+
* both sides of the exact requirement — the smallest that delivers
|
|
183
|
+
* ≥ stated (ceil) and the largest that delivers ≤ stated (floor) —
|
|
184
|
+
* looking for an EXACT delivery; else a loud refusal naming the
|
|
185
|
+
* neighboring compositions (max under, min over).
|
|
186
|
+
*
|
|
187
|
+
* It lives HERE, on the client-safe contract face, because TWO
|
|
188
|
+
* consumers ask the same question: the extend renderer (what to
|
|
189
|
+
* compose) and the studio's commission rail (what to DRAW — the
|
|
190
|
+
* multiwindow unification audit's §9: the operator could not see
|
|
191
|
+
* the N windows an agent had strung together).
|
|
192
|
+
* @param totalFrames the stated extension, frames at the film clock
|
|
193
|
+
* @param where the refusal's voice ('h3-timeline extend')
|
|
194
|
+
* @param overlap the per-seam context overlap (the policy's 39)
|
|
195
|
+
* @returns the exact composition */
|
|
196
|
+
export declare function solveWindowComposition(totalFrames: number, where: string, overlap?: number): WindowComposition;
|
|
42
197
|
|
|
43
198
|
|
|
44
199
|
|
|
@@ -57,6 +212,21 @@ export declare function refGenreOf(name: string, url?: string): 'image' | 'video
|
|
|
57
212
|
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
213
|
export type KnobKey = (typeof KNOB_ORDER)[number];
|
|
59
214
|
export declare const CALL_KNOB_KEYS: ReadonlySet<string>;
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
export declare const SECOND_PASS_KNOBS: ReadonlySet<string>;
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
60
230
|
export declare const CALL_KEYS: ReadonlySet<string>;
|
|
61
231
|
export declare const LEGACY_KNOB_KEY: {
|
|
62
232
|
readonly sampling_steps: "steps";
|
package/lib/timelineContract.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { deriveFamilyLane } from '@melite/contracts/familyLane';
|
|
1
2
|
export const SEAM_OVERLAP_FRAMES = 22;
|
|
2
3
|
export const GRID_BASE_FRAMES = 22;
|
|
3
4
|
export const GRID_STEP_FRAMES = 17;
|
|
@@ -13,9 +14,146 @@ export const REF_CAPS = {
|
|
|
13
14
|
// the loader row the compose fills.
|
|
14
15
|
refmods: 8,
|
|
15
16
|
};
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export function isMediaRef(v) {
|
|
26
|
+
return v.startsWith('$') || v.startsWith('data:') || v.includes('/') || /\.[A-Za-z0-9]+$/.test(v);
|
|
27
|
+
}
|
|
16
28
|
export function transitionOverlap(transition) {
|
|
17
29
|
return transition === 'cut' ? 0 : SEAM_OVERLAP_FRAMES;
|
|
18
30
|
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
export const DOC_FPS_DEFAULT = 24;
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
export const FILM_ONLY_KEYS = ['duck_depth_db'];
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
export const FAMILY_LAW = {
|
|
109
|
+
lanes: [
|
|
110
|
+
{ lane: 't4_chain', minCalls: 2 },
|
|
111
|
+
{
|
|
112
|
+
lane: 't4r',
|
|
113
|
+
guideKeys: ['keyframes', 'last_frame', 'ref_images', 'ref_videos', 'ref_audios', 'image', 'image_name', 'ref_image'],
|
|
114
|
+
callGuideKeys: ['image', 'ref_images', 'ref_image', 'image_name'],
|
|
115
|
+
},
|
|
116
|
+
{ lane: 't4_open' },
|
|
117
|
+
],
|
|
118
|
+
|
|
119
|
+
// The post chain mounts on every arm (actions.ts), so a finish
|
|
120
|
+
// knob stated on a t4r doc fires there like it does on the open
|
|
121
|
+
// and chain lanes. The empty map keeps the served shape
|
|
122
|
+
// FormSpecDoc.familyLaw declares; the generic dead-key clause in
|
|
123
|
+
// card-base's composeValidate stays for other families' laws.
|
|
124
|
+
deadKeys: {},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
export function deriveWindowFamily(raw) {
|
|
146
|
+
|
|
147
|
+
// the SHARED evaluator over the FAMILY_LAW data above — the same
|
|
148
|
+
|
|
149
|
+
// seat ride. The doc-level guide seats the walk reads (actions.ts
|
|
150
|
+
// guideImage = image ?? image_name; the render's guide0 = image,
|
|
151
|
+
// image_name, ref_image) are DECLARED in the law's guideKeys, so
|
|
152
|
+
// the private spelling below is dead — a seat missed in the data
|
|
153
|
+
// is now a seat every judge misses together, never a split family
|
|
154
|
+
// (the run-899a8448 disease).
|
|
155
|
+
return deriveFamilyLane(FAMILY_LAW, raw);
|
|
156
|
+
}
|
|
19
157
|
export function spanOverlap(span) {
|
|
20
158
|
return transitionOverlap(span.transition);
|
|
21
159
|
}
|
|
@@ -55,6 +193,14 @@ export function assertCarriedSpanGrid(span, where, carry = SEAM_OVERLAP_FRAMES)
|
|
|
55
193
|
}
|
|
56
194
|
return grid.length;
|
|
57
195
|
}
|
|
196
|
+
/** The booked render clock, one home: the seconds seat rounds its
|
|
197
|
+
* quotient to milliseconds before it rides the wire, so every
|
|
198
|
+
* consumer that needs the value the graph will actually carry (the
|
|
199
|
+
* schema's own rail bounds, the mix ledger) books through here —
|
|
200
|
+
* never a second copy of the rounding. */
|
|
201
|
+
export function bookSeconds(lengthFrames, fps) {
|
|
202
|
+
return Math.round((lengthFrames / fps) * 1000) / 1000;
|
|
203
|
+
}
|
|
58
204
|
export function gridSnap(length) {
|
|
59
205
|
const k = Math.round((length - GRID_BASE_FRAMES) / GRID_STEP_FRAMES);
|
|
60
206
|
return Math.min(GRID_MAX_FRAMES, Math.max(GRID_BASE_FRAMES, GRID_BASE_FRAMES + GRID_STEP_FRAMES * k));
|
|
@@ -80,6 +226,67 @@ export function assertGridLength(length, where) {
|
|
|
80
226
|
}
|
|
81
227
|
return length;
|
|
82
228
|
}
|
|
229
|
+
/** The chain policy's masked_av context — the overlap every composed
|
|
230
|
+
* seam after the first carries (the swap's clip law, shared with the
|
|
231
|
+
* extend's window composition). */
|
|
232
|
+
export const CONTEXT_OVERLAP_FRAMES = 39;
|
|
233
|
+
/** The plan's scene cap (chain_nodes: a 32-scene cap refuses
|
|
234
|
+
* mis-authored loops) — the composition solver's window ceiling. */
|
|
235
|
+
export const MAX_COMPOSED_WINDOWS = 32;
|
|
236
|
+
/** The largest 22+17k grid length ≤ x (floored at 22, capped 362). */
|
|
237
|
+
const gridFloorFrames = (x) => Math.min(GRID_MAX_FRAMES, GRID_BASE_FRAMES + GRID_STEP_FRAMES * Math.floor((x - GRID_BASE_FRAMES) / GRID_STEP_FRAMES));
|
|
238
|
+
/** The smallest 22+17k grid length ≥ x (capped at 362); null when x
|
|
239
|
+
* exceeds the grid — that window count cannot carry the total. */
|
|
240
|
+
const gridCeilFrames = (x) => {
|
|
241
|
+
const k = Math.ceil((x - GRID_BASE_FRAMES) / GRID_STEP_FRAMES);
|
|
242
|
+
const length = Math.max(GRID_BASE_FRAMES, GRID_BASE_FRAMES + GRID_STEP_FRAMES * k);
|
|
243
|
+
return length > GRID_MAX_FRAMES ? null : length;
|
|
244
|
+
};
|
|
245
|
+
/** THE COMPOSITION SOLVER (pure; the door's whole law beyond one
|
|
246
|
+
* window): across every legal window count, the grid lengths on
|
|
247
|
+
* both sides of the exact requirement — the smallest that delivers
|
|
248
|
+
* ≥ stated (ceil) and the largest that delivers ≤ stated (floor) —
|
|
249
|
+
* looking for an EXACT delivery; else a loud refusal naming the
|
|
250
|
+
* neighboring compositions (max under, min over).
|
|
251
|
+
*
|
|
252
|
+
* It lives HERE, on the client-safe contract face, because TWO
|
|
253
|
+
* consumers ask the same question: the extend renderer (what to
|
|
254
|
+
* compose) and the studio's commission rail (what to DRAW — the
|
|
255
|
+
* multiwindow unification audit's §9: the operator could not see
|
|
256
|
+
* the N windows an agent had strung together).
|
|
257
|
+
* @param totalFrames the stated extension, frames at the film clock
|
|
258
|
+
* @param where the refusal's voice ('h3-timeline extend')
|
|
259
|
+
* @param overlap the per-seam context overlap (the policy's 39)
|
|
260
|
+
* @returns the exact composition */
|
|
261
|
+
export function solveWindowComposition(totalFrames, where, overlap = CONTEXT_OVERLAP_FRAMES) {
|
|
262
|
+
let bestUnder = null;
|
|
263
|
+
let bestOver = null;
|
|
264
|
+
for (let windows = 1; windows <= MAX_COMPOSED_WINDOWS; windows++) {
|
|
265
|
+
const exact = (totalFrames + (windows - 1) * overlap) / windows;
|
|
266
|
+
for (const windowFrames of [gridFloorFrames(exact), gridCeilFrames(exact)]) {
|
|
267
|
+
if (windowFrames === null)
|
|
268
|
+
continue;
|
|
269
|
+
const delivered = windows * windowFrames - (windows - 1) * overlap;
|
|
270
|
+
if (delivered === totalFrames)
|
|
271
|
+
return { windows, windowFrames, deliveredFrames: delivered };
|
|
272
|
+
const composition = { windows, windowFrames, deliveredFrames: delivered };
|
|
273
|
+
if (delivered < totalFrames) {
|
|
274
|
+
if (bestUnder === null || delivered > bestUnder.deliveredFrames)
|
|
275
|
+
bestUnder = composition;
|
|
276
|
+
}
|
|
277
|
+
else if (bestOver === null || delivered < bestOver.deliveredFrames) {
|
|
278
|
+
bestOver = composition;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
const neighbor = (c) => c === null ? '' :
|
|
283
|
+
` nearest: ${c.windows} windows of ${c.windowFrames}f deliver ${c.deliveredFrames}f (${(c.deliveredFrames / 24).toFixed(3)}s);`;
|
|
284
|
+
throw new Error(`${where}: stated ${totalFrames}f composes nowhere exactly — ` +
|
|
285
|
+
`N uniform 22+17k windows under the ${overlap}f context overlap compose exactly nowhere;` +
|
|
286
|
+
`${neighbor(bestUnder)}${neighbor(bestOver)}` +
|
|
287
|
+
` re-state extend_seconds as a composition's delivered seconds ` +
|
|
288
|
+
`(D frames round-trips D/24 exactly; a single window keeps the 22+17k grid door)`);
|
|
289
|
+
}
|
|
83
290
|
|
|
84
291
|
|
|
85
292
|
|
|
@@ -163,7 +370,17 @@ export function refGenreOf(name, url) {
|
|
|
163
370
|
return 'image';
|
|
164
371
|
return 'video';
|
|
165
372
|
}
|
|
166
|
-
|
|
373
|
+
let urlFace = url?.toLowerCase() ?? '';
|
|
374
|
+
const pathMatch = /(?:^|[?&])path=([^&]+)/.exec(urlFace);
|
|
375
|
+
if (pathMatch !== null) {
|
|
376
|
+
try {
|
|
377
|
+
urlFace = decodeURIComponent(pathMatch[1]);
|
|
378
|
+
}
|
|
379
|
+
catch {
|
|
380
|
+
urlFace = pathMatch[1];
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
const source = `${lowerName} ${urlFace.split('?')[0]}`;
|
|
167
384
|
const extension = source.split('.').pop().split(/[^a-z0-9]/)[0];
|
|
168
385
|
if (['png', 'jpg', 'jpeg', 'webp', 'gif', 'bmp', 'avif'].includes(extension))
|
|
169
386
|
return 'image';
|
|
@@ -187,8 +404,27 @@ export const KNOB_ORDER = [
|
|
|
187
404
|
'length',
|
|
188
405
|
];
|
|
189
406
|
export const CALL_KNOB_KEYS = new Set(KNOB_ORDER);
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
export const SECOND_PASS_KNOBS = new Set([
|
|
414
|
+
'sharpen_enabled', 'sharpen_method', 'sharpen_strength',
|
|
415
|
+
'sharpen_radius', 'sharpen_threshold', 'sharpen_iterations',
|
|
416
|
+
'interpolate_enabled', 'interp_model', 'interp_multiplier',
|
|
417
|
+
]);
|
|
418
|
+
|
|
419
|
+
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
|
|
190
426
|
export const CALL_KEYS = new Set([
|
|
191
|
-
'text', 'start_frame', 'end_frame', 'image',
|
|
427
|
+
'text', 'start_frame', 'end_frame', 'image',
|
|
192
428
|
'transition', 'knobs', 'refs',
|
|
193
429
|
'ref_image', 'image_name', 'ref_images', 'ref_videos', 'ref_audios',
|
|
194
430
|
'beats', 'last_frame', 'first_frame_prev_sec', 'seam_carry',
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface WindowSpecProjection {
|
|
2
|
+
/** the carrier's own key universe (paramSchema dict), sorted. */
|
|
3
|
+
readonly carrierKeys: readonly string[];
|
|
4
|
+
/** the UI-served envelope (the emission's properties), sorted. */
|
|
5
|
+
readonly envelope: readonly string[];
|
|
6
|
+
/** the family door's declared per-window rows, sorted. */
|
|
7
|
+
readonly filmRows: readonly string[];
|
|
8
|
+
/** carrierKeys − envelope: hidden by the carrier's own law, sorted. */
|
|
9
|
+
readonly carrierInternal: readonly string[];
|
|
10
|
+
/** envelope − filmRows: served with a named exemption, sorted. */
|
|
11
|
+
readonly undeclaredServed: readonly string[];
|
|
12
|
+
/** filmRows − envelope: declared wire/internal, sorted. */
|
|
13
|
+
readonly unservedDeclared: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Serve the h3 window's three-home surface as one projection: the
|
|
17
|
+
* carrier universe, the served envelope, and the family door's film
|
|
18
|
+
* rows, plus the three named difference sets the parity wall judges.
|
|
19
|
+
* Pure derivation — no hand lists; a row or knob added on any side
|
|
20
|
+
* shifts the sets and the wall names it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function serveWindowSpec(): WindowSpecProjection;
|
|
23
|
+
//# sourceMappingURL=windowSpec.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// windowSpec.ts — THE H3 WINDOW PROJECTION SEAM (Slice 0 of the P0
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
// The h3 window is function-served: the walk judges the window schema
|
|
5
|
+
// (schema.ts paramSchema + schema()), the family door judges the film
|
|
6
|
+
// action rows (actions.ts film.params), and the UI serves the carrier
|
|
7
|
+
// emission (emitParamsSchema over paramSchema). This module is the ONE
|
|
8
|
+
// serving projection of that three-home surface — a package export the
|
|
9
|
+
// walls (h3-window-parity.spec.ts) and the future hop census consume,
|
|
10
|
+
// never a test helper. Home is models/h3 (it owns both inputs and
|
|
11
|
+
// already depends on card-kit): the discovery.ts home the design
|
|
12
|
+
// sketches would hang a harness→family import, and the card-kit home
|
|
13
|
+
// would invert card-kit→family. New module, no cycle (schema/actions
|
|
14
|
+
// never import back).
|
|
15
|
+
import { emitParamsSchema } from "@melite/comfyui-card-kit/params-emit";
|
|
16
|
+
import { film } from "./actions.js";
|
|
17
|
+
import { paramSchema } from "./schema.js";
|
|
18
|
+
const sorted = (keys) => [...new Set(keys)].sort();
|
|
19
|
+
/**
|
|
20
|
+
* Serve the h3 window's three-home surface as one projection: the
|
|
21
|
+
* carrier universe, the served envelope, and the family door's film
|
|
22
|
+
* rows, plus the three named difference sets the parity wall judges.
|
|
23
|
+
* Pure derivation — no hand lists; a row or knob added on any side
|
|
24
|
+
* shifts the sets and the wall names it.
|
|
25
|
+
*/
|
|
26
|
+
export function serveWindowSpec() {
|
|
27
|
+
const carrierKeys = sorted(Object.keys(paramSchema.dict ?? {}));
|
|
28
|
+
// The bridge rides the toolProjection.ts precedent in two steps:
|
|
29
|
+
// the schemastery object's Meta carries no string index, so the
|
|
30
|
+
// static types cannot prove its overlap with the emitter's minimal
|
|
31
|
+
// face — but the face's whole job is carrying .dict (card-definition
|
|
32
|
+
// Ledger row 23), which this object provably has. Claim only the
|
|
33
|
+
// dict, then take the face the same way the tool face does.
|
|
34
|
+
const carrier = paramSchema;
|
|
35
|
+
const emitted = emitParamsSchema(carrier, ["h3"]);
|
|
36
|
+
const envelope = sorted(Object.keys(emitted.properties ?? {}));
|
|
37
|
+
const filmRows = sorted(film.params.map((r) => r.name));
|
|
38
|
+
const inEnvelope = new Set(envelope);
|
|
39
|
+
const inFilm = new Set(filmRows);
|
|
40
|
+
return {
|
|
41
|
+
carrierKeys,
|
|
42
|
+
envelope,
|
|
43
|
+
filmRows,
|
|
44
|
+
carrierInternal: sorted(carrierKeys.filter((k) => !inEnvelope.has(k))),
|
|
45
|
+
undeclaredServed: sorted(envelope.filter((k) => !inFilm.has(k))),
|
|
46
|
+
unservedDeclared: sorted(filmRows.filter((k) => !inEnvelope.has(k))),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=windowSpec.js.map
|