{"schemaVersion":1,"id":"recommended.sm-shot-plan","version":"1.0.0","name":"Shots workflow","description":"An editable production workflow using Shots v2.1.1.","stages":[{"id":"main","blockId":"sm.shot-plan","version":"2.1.1","label":"Shots"}],"connections":[],"packages":[{"manifest":{"schemaVersion":1,"sdkVersion":"0.1.0","id":"sm.shot-plan","version":"2.1.1","name":"Shots","description":"Build a timed shot plan from the current narration, then review and edit narration, visual direction, framing, duration, fulfillment, motion, statements, order, and retained custom fields.","kind":"workspace","runtime":"javascript","entry":"src/run.js","license":"MIT","provenance":{"notice":"Original source (authorship declared by the packager)\nLicense: MIT\nChanges: Original implementation declared by the packager; no reused repository or dependency code.\nFiles: LICENSE, src/run.js, src/view.json\n\nMIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","portableSources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js","src/view.json"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js","upstream/0/src/view.json"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}]},"inputs":{"shotPlan":{"type":"shot-plan","context":"shotPlan","primary":true,"required":false,"default":{"schemaVersion":1,"shots":[]},"description":"The complete current shot plan. Unknown fields and saved media identities are retained."},"transcript":{"type":"transcript","context":"transcript","required":false,"default":{"schemaVersion":1,"text":"","words":[]},"description":"Current narration words and timings used to build an initial plan when the project has no shots."},"script":{"type":"script","context":"script","required":false,"default":{"schemaVersion":1,"text":""},"description":"Current narration text used when word timings are unavailable."},"updatedShotPlan":{"type":"shot-plan","required":false,"default":{"schemaVersion":1,"shots":[]},"description":"The complete edited plan prepared in this workspace."},"commit":{"type":"boolean","default":false,"description":"Prepare the edited plan for StillMade review and Apply."}},"outputs":{"shotPlan":{"type":"shot-plan","primary":true,"role":"production_shot_plan","description":"The complete edited shot plan for the next Step."},"edit":{"type":"workspace-edit","description":"An exact before/after Shots change reviewed before it updates the project."}},"permissions":{"project":["context.shotPlan.read","context.transcript.read","context.script.read","workspace.shotPlan.propose"],"network":[],"filesystem":[],"secrets":[]},"ui":[],"platforms":{"phone":{"supported":true},"browser":{"supported":true},"desktop":{"supported":true}}},"code":"const copy = value => JSON.parse(JSON.stringify(value));\nconst words = Array.isArray(input.transcript?.words) ? input.transcript.words : [];\nconst scriptText = String(input.transcript?.text || input.script?.text || (typeof input.script==='string'?input.script:'')).trim();\nconst timed = word => ({text:String(word?.text || word?.word || '').trim(),start:Number.isFinite(Number(word?.start))?Number(word.start):Number(word?.startMs)/1000,end:Number.isFinite(Number(word?.end))?Number(word.end):Number(word?.endMs)/1000});\nconst make = (text,start,end,index) => ({id:`shot-${index+1}-${Math.max(0,Math.round(start*1000))}`,voiceoverText:text,shotDescription:text?`Show a clear visual for: ${text}`:'',startTime:start,endTime:end,estimatedScreenTime:Math.max(1,Math.round((end-start)*10)/10),generationLength:Math.min(15,Math.max(3,Math.ceil(end-start)+2)),shotSize:index%3===0?'Wide':index%3===1?'Medium':'Close',shotType:'Story',fulfillment:'video'});\nconst fromWords = () => {const clean=words.map(timed).filter(word=>word.text&&Number.isFinite(word.start)&&Number.isFinite(word.end)&&word.end>=word.start);const groups=[];let group=[];clean.forEach(word=>{group.push(word);const duration=word.end-group[0].start,punctuation=/[.!?]$/.test(word.text);if((punctuation&&duration>=2.5)||duration>=6||group.length>=18){groups.push(group);group=[];}});if(group.length)groups.push(group);return groups.map((group,index)=>make(group.map(word=>word.text).join(' '),group[0].start,group[group.length-1].end,index));};\nconst fromScript = () => {const parts=(scriptText.match(/[^.!?]+[.!?]?/g)||[]).map(value=>value.trim()).filter(Boolean);let cursor=0;return parts.map((text,index)=>{const duration=Math.max(2,Math.round(text.split(/\\s+/).length/2.5*10)/10),shot=make(text,cursor,cursor+duration,index);cursor+=duration;return shot;});};\nconst generated = () => ({schemaVersion:1,shots:words.length?fromWords():fromScript()});\nconst source = copy(input.shotPlan || {schemaVersion:1,shots:[]});\nconst fallback = !source.shots?.length ? generated() : source;\nconst candidate = input.commit ? copy(input.updatedShotPlan) : copy(fallback);\nif (!candidate || Array.isArray(candidate) || candidate.schemaVersion !== 1 || !Array.isArray(candidate.shots)) throw new Error('Keep the complete version 1 shot plan.');\nif (candidate.shots.length > 2000 || !candidate.shots.every(shot => shot && !Array.isArray(shot) && typeof shot.id === 'string' && shot.id.length > 0 && shot.id.length <= 200) || new Set(candidate.shots.map(shot => shot.id)).size !== candidate.shots.length) throw new Error('Shots need up to 2,000 distinct retained IDs.');\nreturn {shotPlan:candidate,edit:{schemaVersion:1,title:`Update ${candidate.shots.length} planned shot${candidate.shots.length===1?'':'s'}`,field:'shotPlan',before:source,after:candidate}};\n","view":{"html":"<main class=\"shots-workspace\">\n  <header><div><small>Production workspace</small><h1>Shots</h1><p id=\"summary\">Loading the shot plan…</p></div><div class=\"actions\"><button id=\"build\" type=\"button\" class=\"secondary\">Build from narration</button><button id=\"reset\" type=\"button\" class=\"secondary\">Reset changes</button><button id=\"add\" type=\"button\" class=\"secondary\">Add shot</button><button id=\"save\" type=\"button\" data-stillmade-action=\"run\">Review changes</button></div></header>\n  <output id=\"status\" role=\"status\" aria-live=\"polite\"></output>\n  <section id=\"shots\" class=\"shots\" aria-label=\"Planned shots\"></section>\n  <details><summary>Complete shot-plan data</summary><p>Every field is retained. Use this editor for custom fields not shown on the cards.</p><label for=\"raw\">Complete shot-plan JSON</label><textarea id=\"raw\" class=\"raw\" spellcheck=\"false\"></textarea><button id=\"applyRaw\" type=\"button\" class=\"secondary\">Apply JSON to workspace</button></details>\n</main>\n","css":".shots-workspace{max-width:1100px;margin:0 auto;padding:8px;color:var(--fg)}header,.actions,.card-head,.row,.order{display:flex;align-items:center;gap:10px;flex-wrap:wrap}header{justify-content:space-between;margin-bottom:14px}header h1{margin:2px 0}header p,header small,details p,output{color:var(--fg-muted)}\n.shots{display:grid;gap:12px}.card,details{padding:16px;border:1px solid var(--border-tok);border-radius:var(--r-3);background:var(--bg-elev-1)}.card-head{justify-content:space-between}.card h2{margin:0;font-size:18px}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}label{display:grid;gap:5px;margin:8px 0;font-size:13px;font-weight:600}input,textarea,select{width:100%;background:var(--bg)}textarea{min-height:82px;resize:vertical}.wide{grid-column:1/-1}.secondary{background:transparent;color:var(--fg)}.danger{background:transparent;color:var(--signal)}.raw{min-height:340px;font-family:var(--font-mono);font-size:12px}output{display:block;min-height:24px;margin:8px 2px}.order button{min-width:44px}.empty{padding:28px;text-align:center;border:1px dashed var(--border-tok);border-radius:var(--r-3);color:var(--fg-muted)}\n@media(max-width:760px){.shots-workspace{padding:0}.grid{grid-template-columns:1fr}.actions{width:100%}.actions button{flex:1}.card,details{padding:12px}}\n","javascript":"const status=document.getElementById('status'),summary=document.getElementById('summary'),raw=document.getElementById('raw'),save=document.getElementById('save'),build=document.getElementById('build');\nlet source={schemaVersion:1,shots:[]},draft={schemaVersion:1,shots:[]},transcript={schemaVersion:1,text:'',words:[]},script={schemaVersion:1,text:''},busy=false,revision=0;\nconst clone=value=>JSON.parse(JSON.stringify(value));\nconst text=value=>value===undefined||value===null?'':String(value);\nconst wordStart=word=>Number.isFinite(Number(word?.start))?Number(word.start):Number(word?.startMs)/1000;\nconst wordEnd=word=>Number.isFinite(Number(word?.end))?Number(word.end):Number(word?.endMs)/1000;\nconst make=(line,start,end,index)=>({id:'shot-'+String(index+1)+'-'+String(Math.max(0,Math.round(start*1000))),voiceoverText:line,shotDescription:line?'Show a clear visual for: '+line:'',startTime:start,endTime:end,estimatedScreenTime:Math.max(1,Math.round((end-start)*10)/10),generationLength:Math.min(15,Math.max(3,Math.ceil(end-start)+2)),shotSize:index%3===0?'Wide':index%3===1?'Medium':'Close',shotType:'Story',fulfillment:'video'});\nconst plan=()=>{const words=Array.isArray(transcript.words)?transcript.words.map(word=>({text:text(word?.text||word?.word).trim(),start:wordStart(word),end:wordEnd(word)})).filter(word=>word.text&&Number.isFinite(word.start)&&Number.isFinite(word.end)&&word.end>=word.start):[];if(words.length){const groups=[];let group=[];words.forEach(word=>{group.push(word);const duration=word.end-group[0].start;if((/[.!?]$/.test(word.text)&&duration>=2.5)||duration>=6||group.length>=18){groups.push(group);group=[]}});if(group.length)groups.push(group);return {schemaVersion:1,shots:groups.map((group,index)=>make(group.map(word=>word.text).join(' '),group[0].start,group.at(-1).end,index))}}const narration=text(transcript.text||script.text||(typeof script==='string'?script:'')).trim(),parts=(narration.match(/[^.!?]+[.!?]?/g)||[]).map(value=>value.trim()).filter(Boolean);let cursor=0;return {schemaVersion:1,shots:parts.map((line,index)=>{const duration=Math.max(2,Math.round(line.split(/\\s+/).length/2.5*10)/10),shot=make(line,cursor,cursor+duration,index);cursor+=duration;return shot})}};\nconst field=(label,action,value,type='text',wide=false)=>({tag:'label',className:wide?'wide':'',children:[{tag:'span',text:label},type==='textarea'?{tag:'textarea',action,value:text(value),disabled:busy,label}:{tag:'input',type,action,value:Number.isFinite(value)?value:text(value),disabled:busy,label}]});\nconst choice=(label,action,value,options)=>({tag:'label',children:[{tag:'span',text:label},{tag:'select',action,value:text(value),disabled:busy,label,children:options.map(option=>({tag:'option',text:option,value:option}))}]});\nconst shotCard=(shot,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h2',text:'Shot '+String(index+1)+' · '+(text(shot.shotDescription)||text(shot.title)||shot.id)},{tag:'div',className:'order',children:[{tag:'button',action:'up:'+String(index),text:'↑',className:'secondary',disabled:busy||index===0,label:'Move shot up'},{tag:'button',action:'down:'+String(index),text:'↓',className:'secondary',disabled:busy||index===draft.shots.length-1,label:'Move shot down'},{tag:'button',action:'remove:'+String(index),text:'Remove',className:'danger',disabled:busy}]}]},{tag:'div',className:'grid',children:[field('Narration','narration:'+String(index),shot.voiceoverText,'textarea',true),field('Visual direction','description:'+String(index),shot.shotDescription||shot.description,'textarea',true),choice('Framing','size:'+String(index),shot.shotSize||'Medium',['Wide','Medium','Close','Extreme Close']),choice('Purpose','type:'+String(index),shot.shotType||'Story',['Story','Coverage Wide','Coverage Medium','Cutaway','Insert','Movement','Transition']),field('Screen time (seconds)','duration:'+String(index),shot.estimatedScreenTime,'number'),choice('Fulfillment','fulfillment:'+String(index),shot.fulfillment||'video',['video','imageMotion']),choice('Motion','motion:'+String(index),shot.motionEffect||'Ken Burns',['Ken Burns','Pan Left','Pan Right','Push In','Pull Out','Tilt Up','Tilt Down','Drift','Locked Frame']),choice('Motion speed','speed:'+String(index),shot.motionSpeed||'Slow',['Slow','Medium','Fast']),{tag:'label',children:[{tag:'span',text:'Full-screen statement'},{tag:'input',type:'checkbox',action:'statement:'+String(index),checked:!!shot.statement,disabled:busy,label:'Full-screen statement'}]},field('Statement reveal','reveal:'+String(index),shot.statementReveal||'words')]}]});\nconst ensure=()=>{if(!draft||Array.isArray(draft)||draft.schemaVersion!==1)draft={schemaVersion:1,shots:[]};if(!Array.isArray(draft.shots))draft.shots=[]};\nconst draw=()=>{ensure();StillMade.render('shots',draft.shots.length?draft.shots.map(shotCard):[{tag:'p',className:'empty',text:'No shots yet. Build from narration or add the first shot.'}]);raw.value=JSON.stringify(draft,null,2);summary.textContent=String(draft.shots.length)+' planned shot'+(draft.shots.length===1?'':'s');save.disabled=busy;build.disabled=busy||!(transcript.words?.length||text(transcript.text||script.text||(typeof script==='string'?script:'')).trim());document.getElementById('reset').disabled=busy;document.getElementById('add').disabled=busy};\nconst changed=message=>{revision+=1;raw.value=JSON.stringify(draft,null,2);status.textContent=message||'Changes are local until you choose Review changes.'};\nStillMade.onAction(event=>{if(busy)return;ensure();const parts=event.action.split(':'),kind=parts[0],index=Number(parts[1]),shot=draft.shots.find((item,position)=>position===index);if(kind==='remove'){draft.shots=draft.shots.filter((item,position)=>position!==index);changed();draw();return}if(kind==='up'||kind==='down'){const target=index+(kind==='up'?-1:1);if(target>=0&&target<draft.shots.length){draft.shots=draft.shots.map((item,position)=>position===index?draft.shots.find((candidate,candidatePosition)=>candidatePosition===target):position===target?shot:item);changed('Shot order updated.');draw()}return}if(!shot)return;if(kind==='narration')shot.voiceoverText=event.value;if(kind==='description')shot.shotDescription=event.value;if(kind==='size')shot.shotSize=event.value;if(kind==='type')shot.shotType=event.value;if(kind==='duration'){shot.estimatedScreenTime=Number(event.value);shot.generationLength=Math.min(15,Number(event.value)+2)}if(kind==='fulfillment'){shot.fulfillment=event.value;shot.fulfillmentSetBy='user'}if(kind==='motion')shot.motionEffect=event.value;if(kind==='speed')shot.motionSpeed=event.value;if(kind==='statement'){shot.statement=event.checked;shot.statementSetBy='user'}if(kind==='reveal')shot.statementReveal=event.value;changed()});\nbuild.addEventListener('click',()=>{if(!busy){draft=plan();changed('Built a local draft from the current narration. Review every visual direction before applying.');draw()}});\ndocument.getElementById('add').addEventListener('click',()=>{if(busy)return;ensure();const id='portable-shot-'+String(revision+1)+'-'+String(draft.shots.length+1);draft.shots=[...draft.shots,{id,voiceoverText:'',shotDescription:'',shotSize:'Medium',shotType:'Story',estimatedScreenTime:3,generationLength:5,fulfillment:'video'}];changed();draw()});\ndocument.getElementById('applyRaw').addEventListener('click',()=>{if(busy)return;try{const value=JSON.parse(raw.value);if(!value||Array.isArray(value)||value.schemaVersion!==1||!Array.isArray(value.shots))throw Error('Shot-plan JSON must be a version 1 object with shots.');draft=clone(value);changed();draw();status.textContent='Complete shot-plan data applied to this workspace.'}catch(error){status.textContent=error.message}});\ndocument.getElementById('reset').addEventListener('click',()=>{if(!busy){draft=clone(source);revision+=1;draw();status.textContent='Changes reset to the current project shot plan.'}});\nsave.addEventListener('click',async()=>{if(busy)return;const started=revision;busy=true;draw();status.textContent='Checking the complete shot plan…';try{const result=await StillMade.run({shotPlan:source,transcript,script,updatedShotPlan:draft,commit:true});draft=clone(result.shotPlan);if(started===revision)status.textContent='Shots are ready below. Review the before and after, then choose Apply.'}catch(error){status.textContent=error.message||'The shot plan could not be prepared.'}finally{busy=false;draw()}});\nStillMade.onInput(values=>{source=clone(values.shotPlan||{schemaVersion:1,shots:[]});transcript=clone(values.transcript||{schemaVersion:1,text:'',words:[]});script=clone(values.script||{schemaVersion:1,text:''});draft=source.shots?.length?clone(source):plan();revision+=1;draw();status.textContent=draft.shots.length&&!source.shots?.length?'Built a starting plan from the current narration. Review it before applying.':'Edit any shot. Every unshown project field is retained.'});\n"},"tests":[{"name":"builds timed shots from narration when the project has no plan","input":{"shotPlan":{"schemaVersion":1,"shots":[]},"transcript":{"schemaVersion":1,"text":"Open with the city. Then show the product.","words":[{"text":"Open","start":0,"end":0.5},{"text":"with","start":0.5,"end":1},{"text":"the","start":1,"end":1.3},{"text":"city.","start":1.3,"end":3},{"text":"Then","start":3,"end":3.5},{"text":"show","start":3.5,"end":4},{"text":"the","start":4,"end":4.3},{"text":"product.","start":4.3,"end":7}]},"script":{"schemaVersion":1,"text":"Open with the city. Then show the product."},"updatedShotPlan":{"schemaVersion":1,"shots":[]},"commit":false},"expected":{"shotPlan":{"schemaVersion":1,"shots":[{"id":"shot-1-0","voiceoverText":"Open with the city.","shotDescription":"Show a clear visual for: Open with the city.","startTime":0,"endTime":3,"estimatedScreenTime":3,"generationLength":5,"shotSize":"Wide","shotType":"Story","fulfillment":"video"},{"id":"shot-2-3000","voiceoverText":"Then show the product.","shotDescription":"Show a clear visual for: Then show the product.","startTime":3,"endTime":7,"estimatedScreenTime":4,"generationLength":6,"shotSize":"Medium","shotType":"Story","fulfillment":"video"}]},"edit":{"schemaVersion":1,"title":"Update 2 planned shots","field":"shotPlan","before":{"schemaVersion":1,"shots":[]},"after":{"schemaVersion":1,"shots":[{"id":"shot-1-0","voiceoverText":"Open with the city.","shotDescription":"Show a clear visual for: Open with the city.","startTime":0,"endTime":3,"estimatedScreenTime":3,"generationLength":5,"shotSize":"Wide","shotType":"Story","fulfillment":"video"},{"id":"shot-2-3000","voiceoverText":"Then show the product.","shotDescription":"Show a clear visual for: Then show the product.","startTime":3,"endTime":7,"estimatedScreenTime":4,"generationLength":6,"shotSize":"Medium","shotType":"Story","fulfillment":"video"}]}}}},{"name":"commits the complete edited plan without losing media or custom data","input":{"shotPlan":{"schemaVersion":1,"shots":[{"id":"opening","voiceoverText":"Keep narration","selectedImage":{"assetId":"image-1","versionId":"v1"},"custom":{"approved":true}}]},"transcript":{"schemaVersion":1,"text":"Keep narration","words":[]},"script":{"schemaVersion":1,"text":"Keep narration"},"updatedShotPlan":{"schemaVersion":1,"shots":[{"id":"opening","voiceoverText":"Keep narration","shotDescription":"A better opening","selectedImage":{"assetId":"image-1","versionId":"v2"},"custom":{"approved":true}}]},"commit":true},"expected":{"shotPlan":{"schemaVersion":1,"shots":[{"id":"opening","voiceoverText":"Keep narration","shotDescription":"A better opening","selectedImage":{"assetId":"image-1","versionId":"v2"},"custom":{"approved":true}}]},"edit":{"schemaVersion":1,"title":"Update 1 planned shot","field":"shotPlan","before":{"schemaVersion":1,"shots":[{"id":"opening","voiceoverText":"Keep narration","selectedImage":{"assetId":"image-1","versionId":"v1"},"custom":{"approved":true}}]},"after":{"schemaVersion":1,"shots":[{"id":"opening","voiceoverText":"Keep narration","shotDescription":"A better opening","selectedImage":{"assetId":"image-1","versionId":"v2"},"custom":{"approved":true}}]}}}},{"name":"estimates timing from script sentences when word timings are unavailable","input":{"shotPlan":{"schemaVersion":1,"shots":[]},"transcript":{"schemaVersion":1,"text":"First beat. Second beat here!","words":[]},"script":{"schemaVersion":1,"text":""},"updatedShotPlan":{"schemaVersion":1,"shots":[]},"commit":false},"expected":{"shotPlan":{"schemaVersion":1,"shots":[{"id":"shot-1-0","voiceoverText":"First beat.","shotDescription":"Show a clear visual for: First beat.","startTime":0,"endTime":2,"estimatedScreenTime":2,"generationLength":4,"shotSize":"Wide","shotType":"Story","fulfillment":"video"},{"id":"shot-2-2000","voiceoverText":"Second beat here!","shotDescription":"Show a clear visual for: Second beat here!","startTime":2,"endTime":4,"estimatedScreenTime":2,"generationLength":4,"shotSize":"Medium","shotType":"Story","fulfillment":"video"}]},"edit":{"schemaVersion":1,"title":"Update 2 planned shots","field":"shotPlan","before":{"schemaVersion":1,"shots":[]},"after":{"schemaVersion":1,"shots":[{"id":"shot-1-0","voiceoverText":"First beat.","shotDescription":"Show a clear visual for: First beat.","startTime":0,"endTime":2,"estimatedScreenTime":2,"generationLength":4,"shotSize":"Wide","shotType":"Story","fulfillment":"video"},{"id":"shot-2-2000","voiceoverText":"Second beat here!","shotDescription":"Show a clear visual for: Second beat here!","startTime":2,"endTime":4,"estimatedScreenTime":2,"generationLength":4,"shotSize":"Medium","shotType":"Story","fulfillment":"video"}]}}}},{"name":"keeps an empty project empty without treating document objects as narration","input":{"shotPlan":{"schemaVersion":1,"shots":[]},"transcript":{"schemaVersion":1,"text":"","words":[]},"script":{"schemaVersion":1,"text":""},"updatedShotPlan":{"schemaVersion":1,"shots":[]},"commit":false},"expected":{"shotPlan":{"schemaVersion":1,"shots":[]},"edit":{"schemaVersion":1,"title":"Update 0 planned shots","field":"shotPlan","before":{"schemaVersion":1,"shots":[]},"after":{"schemaVersion":1,"shots":[]}}}}],"portable":{"format":"stillmade-block/1","dependencies":[],"sources":[{"kind":"original","license":"MIT","paths":["LICENSE","src/run.js","src/view.json"],"evidence":["upstream/0/LICENSE","upstream/0/src/run.js","upstream/0/src/view.json"],"changes":"Original implementation declared by the packager; no reused repository or dependency code."}],"files":{"upstream/0/LICENSE":"MIT License\n\nCopyright (c) 2026 StillMade contributors\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","upstream/0/src/run.js":"const copy = value => JSON.parse(JSON.stringify(value));\nconst words = Array.isArray(input.transcript?.words) ? input.transcript.words : [];\nconst scriptText = String(input.transcript?.text || input.script?.text || (typeof input.script==='string'?input.script:'')).trim();\nconst timed = word => ({text:String(word?.text || word?.word || '').trim(),start:Number.isFinite(Number(word?.start))?Number(word.start):Number(word?.startMs)/1000,end:Number.isFinite(Number(word?.end))?Number(word.end):Number(word?.endMs)/1000});\nconst make = (text,start,end,index) => ({id:`shot-${index+1}-${Math.max(0,Math.round(start*1000))}`,voiceoverText:text,shotDescription:text?`Show a clear visual for: ${text}`:'',startTime:start,endTime:end,estimatedScreenTime:Math.max(1,Math.round((end-start)*10)/10),generationLength:Math.min(15,Math.max(3,Math.ceil(end-start)+2)),shotSize:index%3===0?'Wide':index%3===1?'Medium':'Close',shotType:'Story',fulfillment:'video'});\nconst fromWords = () => {const clean=words.map(timed).filter(word=>word.text&&Number.isFinite(word.start)&&Number.isFinite(word.end)&&word.end>=word.start);const groups=[];let group=[];clean.forEach(word=>{group.push(word);const duration=word.end-group[0].start,punctuation=/[.!?]$/.test(word.text);if((punctuation&&duration>=2.5)||duration>=6||group.length>=18){groups.push(group);group=[];}});if(group.length)groups.push(group);return groups.map((group,index)=>make(group.map(word=>word.text).join(' '),group[0].start,group[group.length-1].end,index));};\nconst fromScript = () => {const parts=(scriptText.match(/[^.!?]+[.!?]?/g)||[]).map(value=>value.trim()).filter(Boolean);let cursor=0;return parts.map((text,index)=>{const duration=Math.max(2,Math.round(text.split(/\\s+/).length/2.5*10)/10),shot=make(text,cursor,cursor+duration,index);cursor+=duration;return shot;});};\nconst generated = () => ({schemaVersion:1,shots:words.length?fromWords():fromScript()});\nconst source = copy(input.shotPlan || {schemaVersion:1,shots:[]});\nconst fallback = !source.shots?.length ? generated() : source;\nconst candidate = input.commit ? copy(input.updatedShotPlan) : copy(fallback);\nif (!candidate || Array.isArray(candidate) || candidate.schemaVersion !== 1 || !Array.isArray(candidate.shots)) throw new Error('Keep the complete version 1 shot plan.');\nif (candidate.shots.length > 2000 || !candidate.shots.every(shot => shot && !Array.isArray(shot) && typeof shot.id === 'string' && shot.id.length > 0 && shot.id.length <= 200) || new Set(candidate.shots.map(shot => shot.id)).size !== candidate.shots.length) throw new Error('Shots need up to 2,000 distinct retained IDs.');\nreturn {shotPlan:candidate,edit:{schemaVersion:1,title:`Update ${candidate.shots.length} planned shot${candidate.shots.length===1?'':'s'}`,field:'shotPlan',before:source,after:candidate}};\n","upstream/0/src/view.json":"{\n  \"html\": \"<main class=\\\"shots-workspace\\\">\\n  <header><div><small>Production workspace</small><h1>Shots</h1><p id=\\\"summary\\\">Loading the shot plan…</p></div><div class=\\\"actions\\\"><button id=\\\"build\\\" type=\\\"button\\\" class=\\\"secondary\\\">Build from narration</button><button id=\\\"reset\\\" type=\\\"button\\\" class=\\\"secondary\\\">Reset changes</button><button id=\\\"add\\\" type=\\\"button\\\" class=\\\"secondary\\\">Add shot</button><button id=\\\"save\\\" type=\\\"button\\\" data-stillmade-action=\\\"run\\\">Review changes</button></div></header>\\n  <output id=\\\"status\\\" role=\\\"status\\\" aria-live=\\\"polite\\\"></output>\\n  <section id=\\\"shots\\\" class=\\\"shots\\\" aria-label=\\\"Planned shots\\\"></section>\\n  <details><summary>Complete shot-plan data</summary><p>Every field is retained. Use this editor for custom fields not shown on the cards.</p><label for=\\\"raw\\\">Complete shot-plan JSON</label><textarea id=\\\"raw\\\" class=\\\"raw\\\" spellcheck=\\\"false\\\"></textarea><button id=\\\"applyRaw\\\" type=\\\"button\\\" class=\\\"secondary\\\">Apply JSON to workspace</button></details>\\n</main>\\n\",\n  \"css\": \".shots-workspace{max-width:1100px;margin:0 auto;padding:8px;color:var(--fg)}header,.actions,.card-head,.row,.order{display:flex;align-items:center;gap:10px;flex-wrap:wrap}header{justify-content:space-between;margin-bottom:14px}header h1{margin:2px 0}header p,header small,details p,output{color:var(--fg-muted)}\\n.shots{display:grid;gap:12px}.card,details{padding:16px;border:1px solid var(--border-tok);border-radius:var(--r-3);background:var(--bg-elev-1)}.card-head{justify-content:space-between}.card h2{margin:0;font-size:18px}.grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}label{display:grid;gap:5px;margin:8px 0;font-size:13px;font-weight:600}input,textarea,select{width:100%;background:var(--bg)}textarea{min-height:82px;resize:vertical}.wide{grid-column:1/-1}.secondary{background:transparent;color:var(--fg)}.danger{background:transparent;color:var(--signal)}.raw{min-height:340px;font-family:var(--font-mono);font-size:12px}output{display:block;min-height:24px;margin:8px 2px}.order button{min-width:44px}.empty{padding:28px;text-align:center;border:1px dashed var(--border-tok);border-radius:var(--r-3);color:var(--fg-muted)}\\n@media(max-width:760px){.shots-workspace{padding:0}.grid{grid-template-columns:1fr}.actions{width:100%}.actions button{flex:1}.card,details{padding:12px}}\\n\",\n  \"javascript\": \"const status=document.getElementById('status'),summary=document.getElementById('summary'),raw=document.getElementById('raw'),save=document.getElementById('save'),build=document.getElementById('build');\\nlet source={schemaVersion:1,shots:[]},draft={schemaVersion:1,shots:[]},transcript={schemaVersion:1,text:'',words:[]},script={schemaVersion:1,text:''},busy=false,revision=0;\\nconst clone=value=>JSON.parse(JSON.stringify(value));\\nconst text=value=>value===undefined||value===null?'':String(value);\\nconst wordStart=word=>Number.isFinite(Number(word?.start))?Number(word.start):Number(word?.startMs)/1000;\\nconst wordEnd=word=>Number.isFinite(Number(word?.end))?Number(word.end):Number(word?.endMs)/1000;\\nconst make=(line,start,end,index)=>({id:'shot-'+String(index+1)+'-'+String(Math.max(0,Math.round(start*1000))),voiceoverText:line,shotDescription:line?'Show a clear visual for: '+line:'',startTime:start,endTime:end,estimatedScreenTime:Math.max(1,Math.round((end-start)*10)/10),generationLength:Math.min(15,Math.max(3,Math.ceil(end-start)+2)),shotSize:index%3===0?'Wide':index%3===1?'Medium':'Close',shotType:'Story',fulfillment:'video'});\\nconst plan=()=>{const words=Array.isArray(transcript.words)?transcript.words.map(word=>({text:text(word?.text||word?.word).trim(),start:wordStart(word),end:wordEnd(word)})).filter(word=>word.text&&Number.isFinite(word.start)&&Number.isFinite(word.end)&&word.end>=word.start):[];if(words.length){const groups=[];let group=[];words.forEach(word=>{group.push(word);const duration=word.end-group[0].start;if((/[.!?]$/.test(word.text)&&duration>=2.5)||duration>=6||group.length>=18){groups.push(group);group=[]}});if(group.length)groups.push(group);return {schemaVersion:1,shots:groups.map((group,index)=>make(group.map(word=>word.text).join(' '),group[0].start,group.at(-1).end,index))}}const narration=text(transcript.text||script.text||(typeof script==='string'?script:'')).trim(),parts=(narration.match(/[^.!?]+[.!?]?/g)||[]).map(value=>value.trim()).filter(Boolean);let cursor=0;return {schemaVersion:1,shots:parts.map((line,index)=>{const duration=Math.max(2,Math.round(line.split(/\\\\s+/).length/2.5*10)/10),shot=make(line,cursor,cursor+duration,index);cursor+=duration;return shot})}};\\nconst field=(label,action,value,type='text',wide=false)=>({tag:'label',className:wide?'wide':'',children:[{tag:'span',text:label},type==='textarea'?{tag:'textarea',action,value:text(value),disabled:busy,label}:{tag:'input',type,action,value:Number.isFinite(value)?value:text(value),disabled:busy,label}]});\\nconst choice=(label,action,value,options)=>({tag:'label',children:[{tag:'span',text:label},{tag:'select',action,value:text(value),disabled:busy,label,children:options.map(option=>({tag:'option',text:option,value:option}))}]});\\nconst shotCard=(shot,index)=>({tag:'article',className:'card',children:[{tag:'div',className:'card-head',children:[{tag:'h2',text:'Shot '+String(index+1)+' · '+(text(shot.shotDescription)||text(shot.title)||shot.id)},{tag:'div',className:'order',children:[{tag:'button',action:'up:'+String(index),text:'↑',className:'secondary',disabled:busy||index===0,label:'Move shot up'},{tag:'button',action:'down:'+String(index),text:'↓',className:'secondary',disabled:busy||index===draft.shots.length-1,label:'Move shot down'},{tag:'button',action:'remove:'+String(index),text:'Remove',className:'danger',disabled:busy}]}]},{tag:'div',className:'grid',children:[field('Narration','narration:'+String(index),shot.voiceoverText,'textarea',true),field('Visual direction','description:'+String(index),shot.shotDescription||shot.description,'textarea',true),choice('Framing','size:'+String(index),shot.shotSize||'Medium',['Wide','Medium','Close','Extreme Close']),choice('Purpose','type:'+String(index),shot.shotType||'Story',['Story','Coverage Wide','Coverage Medium','Cutaway','Insert','Movement','Transition']),field('Screen time (seconds)','duration:'+String(index),shot.estimatedScreenTime,'number'),choice('Fulfillment','fulfillment:'+String(index),shot.fulfillment||'video',['video','imageMotion']),choice('Motion','motion:'+String(index),shot.motionEffect||'Ken Burns',['Ken Burns','Pan Left','Pan Right','Push In','Pull Out','Tilt Up','Tilt Down','Drift','Locked Frame']),choice('Motion speed','speed:'+String(index),shot.motionSpeed||'Slow',['Slow','Medium','Fast']),{tag:'label',children:[{tag:'span',text:'Full-screen statement'},{tag:'input',type:'checkbox',action:'statement:'+String(index),checked:!!shot.statement,disabled:busy,label:'Full-screen statement'}]},field('Statement reveal','reveal:'+String(index),shot.statementReveal||'words')]}]});\\nconst ensure=()=>{if(!draft||Array.isArray(draft)||draft.schemaVersion!==1)draft={schemaVersion:1,shots:[]};if(!Array.isArray(draft.shots))draft.shots=[]};\\nconst draw=()=>{ensure();StillMade.render('shots',draft.shots.length?draft.shots.map(shotCard):[{tag:'p',className:'empty',text:'No shots yet. Build from narration or add the first shot.'}]);raw.value=JSON.stringify(draft,null,2);summary.textContent=String(draft.shots.length)+' planned shot'+(draft.shots.length===1?'':'s');save.disabled=busy;build.disabled=busy||!(transcript.words?.length||text(transcript.text||script.text||(typeof script==='string'?script:'')).trim());document.getElementById('reset').disabled=busy;document.getElementById('add').disabled=busy};\\nconst changed=message=>{revision+=1;raw.value=JSON.stringify(draft,null,2);status.textContent=message||'Changes are local until you choose Review changes.'};\\nStillMade.onAction(event=>{if(busy)return;ensure();const parts=event.action.split(':'),kind=parts[0],index=Number(parts[1]),shot=draft.shots.find((item,position)=>position===index);if(kind==='remove'){draft.shots=draft.shots.filter((item,position)=>position!==index);changed();draw();return}if(kind==='up'||kind==='down'){const target=index+(kind==='up'?-1:1);if(target>=0&&target<draft.shots.length){draft.shots=draft.shots.map((item,position)=>position===index?draft.shots.find((candidate,candidatePosition)=>candidatePosition===target):position===target?shot:item);changed('Shot order updated.');draw()}return}if(!shot)return;if(kind==='narration')shot.voiceoverText=event.value;if(kind==='description')shot.shotDescription=event.value;if(kind==='size')shot.shotSize=event.value;if(kind==='type')shot.shotType=event.value;if(kind==='duration'){shot.estimatedScreenTime=Number(event.value);shot.generationLength=Math.min(15,Number(event.value)+2)}if(kind==='fulfillment'){shot.fulfillment=event.value;shot.fulfillmentSetBy='user'}if(kind==='motion')shot.motionEffect=event.value;if(kind==='speed')shot.motionSpeed=event.value;if(kind==='statement'){shot.statement=event.checked;shot.statementSetBy='user'}if(kind==='reveal')shot.statementReveal=event.value;changed()});\\nbuild.addEventListener('click',()=>{if(!busy){draft=plan();changed('Built a local draft from the current narration. Review every visual direction before applying.');draw()}});\\ndocument.getElementById('add').addEventListener('click',()=>{if(busy)return;ensure();const id='portable-shot-'+String(revision+1)+'-'+String(draft.shots.length+1);draft.shots=[...draft.shots,{id,voiceoverText:'',shotDescription:'',shotSize:'Medium',shotType:'Story',estimatedScreenTime:3,generationLength:5,fulfillment:'video'}];changed();draw()});\\ndocument.getElementById('applyRaw').addEventListener('click',()=>{if(busy)return;try{const value=JSON.parse(raw.value);if(!value||Array.isArray(value)||value.schemaVersion!==1||!Array.isArray(value.shots))throw Error('Shot-plan JSON must be a version 1 object with shots.');draft=clone(value);changed();draw();status.textContent='Complete shot-plan data applied to this workspace.'}catch(error){status.textContent=error.message}});\\ndocument.getElementById('reset').addEventListener('click',()=>{if(!busy){draft=clone(source);revision+=1;draw();status.textContent='Changes reset to the current project shot plan.'}});\\nsave.addEventListener('click',async()=>{if(busy)return;const started=revision;busy=true;draw();status.textContent='Checking the complete shot plan…';try{const result=await StillMade.run({shotPlan:source,transcript,script,updatedShotPlan:draft,commit:true});draft=clone(result.shotPlan);if(started===revision)status.textContent='Shots are ready below. Review the before and after, then choose Apply.'}catch(error){status.textContent=error.message||'The shot plan could not be prepared.'}finally{busy=false;draw()}});\\nStillMade.onInput(values=>{source=clone(values.shotPlan||{schemaVersion:1,shots:[]});transcript=clone(values.transcript||{schemaVersion:1,text:'',words:[]});script=clone(values.script||{schemaVersion:1,text:''});draft=source.shots?.length?clone(source):plan();revision+=1;draw();status.textContent=draft.shots.length&&!source.shots?.length?'Built a starting plan from the current narration. Review it before applying.':'Edit any shot. Every unshown project field is retained.'});\\n\"\n}"},"lineage":{"parents":[],"changes":"Packaged original Block source for StillMade."}}}],"license":"MIT"}