@@ -75,17 +75,19 @@ function configure(node) {
} ;
const render = ( ) => {
const count = Math . max ( 1 , Math . min ( MAX _CLIPS , Number ( countWidget . value ) || 1 ) ) ;
while ( state . clips . length < count ) state . clips . push ( { duration : Number ( secondsWidget . value ) || 4 , slots : [ ] } ) ;
const chunkDuration = Number ( secondsWidget . value ) || 4 ;
while ( state . clips . length < count ) state . clips . push ( { duration : chunkDuration , slots : [ ] } ) ;
state . clips = state . clips . slice ( 0 , count ) ; active = Math . min ( active , count - 1 ) ;
panel . replaceChildren ( ) ;
const tabs = el ( "div" ) ; tabs . style . cssText = "display:flex;flex-wrap:wrap;gap:3px;margin-bottom:6px" ;
state . clips . forEach ( ( clip , index ) => { const button = el ( "button" , ` Clip ${ index + 1 } ` ) ; button . type = "button" ; button . disabled = index === active ; button . onclick = ( ) => { active = index ; render ( ) ; } ; tabs . append ( button ) ; } ) ;
panel . append ( tabs ) ;
const clip = state . clips [ active ] ;
const durationRow = el ( "div" ) ; durationRow . style . cssText = "display:flex;align-items:center;gap:8px;margin:4px 0" ;
durationRow . append ( el ( "strong" , ` Clip ${ active + 1 } ` ) , el ( "span" , "duration" ) ) ;
const duration = input ( "number" , clip . duration , ( value ) => { clip . duration = Math . max ( 0.1 , Number ( value ) || 0.1 ) ; clip . slots . forEach ( ( slot ) => { slot . end = Math . min ( slot . end , clip . duration ) ; } ) ; setState ( ) ; render ( ) ; } ) ;
duration . step = 0.1 ; duration . style . width = "70px" ; durationRow . append ( duration , el ( "span" , "seconds" ) ) ; panel . append ( durationRow ) ;
// All clips share the one authoritative project duration widget.
const duration = chunkDuration ;
clip . duration = duration ;
const durationRow = el ( "div" ) ; durationRow . style . cssText = "display:flex;align-items:center;gap:8px;margin:4px 0;color:#b7d6bf" ;
durationRow . append ( el ( "strong" , ` Clip ${ active + 1 } ` ) , el ( "span" , ` · ${ duration . toFixed ( 1 ) } s shared chunk duration ` ) ) ; panel . append ( durationRow ) ;
const timeline = el ( "div" ) ; timeline . style . cssText = "display:flex;height:38px;gap:2px;margin:8px 0 3px;background:#15251a;border-radius:3px;overflow:hidden" ;
const palette = [ "#4b9b67" , "#4d7fb1" , "#a87945" , "#8c5aa8" , "#a44f5d" , "#3f8e8a" ] ;
clip . slots . forEach ( ( slot , index ) => { const segment = el ( "button" , ` Shot ${ index + 1 } \n ${ ( slot . text || "unscripted" ) . slice ( 0 , 18 ) } ` ) ; segment . type = "button" ; segment . title = ` ${ slot . start . toFixed ( 1 ) } s– ${ slot . end . toFixed ( 1 ) } s ` ; segment . style . cssText = ` flex: ${ Math . max ( 0.1 , slot . end - slot . start ) } ;border:0;color:white;background: ${ palette [ index % palette . length ] } ;white-space:pre-wrap;font-size:10px;overflow:hidden ` ; segment . onclick = ( ) => { prompt . focus ( ) ; } ; timeline . append ( segment ) ; } ) ;
@@ -104,12 +106,23 @@ function configure(node) {
const add = el ( "button" , "@ Add shot" ) ; add . type = "button" ; add . onclick = ( ) => { addSlot ( clip ) ; setState ( ) ; render ( ) ; } ; actions . append ( add ) ;
if ( clip . slots . length > 1 ) { const remove = el ( "button" , "Remove last shot" ) ; remove . type = "button" ; remove . onclick = ( ) => { clip . slots . pop ( ) ; clip . slots . at ( - 1 ) . end = clip . duration ; setState ( ) ; render ( ) ; } ; actions . append ( remove ) ; }
panel . append ( actions ) ;
display . computeSize = ( width ) => [ Math . max ( 360 , Number ( width ) || 360 ) , Math . min ( 620 , 185 + clip . slots . length * 42 ) ] ;
display . computeSize = ( width ) => [ Math . max ( 360 , Number ( width ) || 360 ) , Math . min ( 620 , 160 + clip . slots . length * 42 ) ] ;
node . setSize ? . ( [ Math . max ( 360 , Number ( node . size ? . [ 0 ] ) || 360 ) , Number ( node . computeSize ? . ( ) [ 1 ] ) || 420 ] ) ;
} ;
const refresh = ( ) => { state = readState ( stateWidget , Number ( countWidget . value ) || 2 , Number ( secondsWidget . value ) || 4 ) ; render ( ) ; setState ( ) ; } ;
countWidget . callback = ( ( previous ) => function ( ... args ) { const result = previous ? . apply ( this , args ) ; refresh ( ) ; return result ; } ) ( countWidget . callback ) ;
secondsWidget . callback = ( ( previous ) => function ( ... args ) { const result = previous ? . apply ( this , args ) ; render ( ) ; return result ; } ) ( secondsWidget . callback ) ;
secondsWidget . callback = ( ( previous ) => function ( ... args ) {
const result = previous ? . apply ( this , args ) ;
const duration = Math . max ( 0.1 , Number ( secondsWidget . value ) || 0.1 ) ;
state . clips . forEach ( ( clip ) => {
clip . duration = duration ;
clip . slots . forEach ( ( slot ) => {
slot . start = Math . min ( Number ( slot . start ) || 0 , Math . max ( 0 , duration - 0.1 ) ) ;
slot . end = Math . min ( Math . max ( Number ( slot . end ) || duration , slot . start + 0.1 ) , duration ) ;
} ) ;
} ) ;
setState ( ) ; render ( ) ; return result ;
} ) ( secondsWidget . callback ) ;
stateWidget . callback = ( ( previous ) => function ( ... args ) { const result = previous ? . apply ( this , args ) ; render ( ) ; return result ; } ) ( stateWidget . callback ) ;
node . _ _dumasSequencePromptBuilder = refresh ;
refresh ( ) ;