@beff/aula-cli 0.12.0 → 0.13.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.
- package/README.md +6 -1
- package/dist/src/{aula-voice-tts-YOS4IQXV.js → aula-voice-tts-H2OQFQ5J.js} +1 -1
- package/dist/src/aula.js +2 -2
- package/dist/src/{chunk-TDAWUJ2L.js → chunk-4FWDTPLR.js} +1 -1
- package/dist/src/{chunk-RAGZAJKD.js → chunk-D5N3QDDF.js} +1 -1
- package/dist/src/{chunk-DN2LVJO3.js → chunk-F5RPEFZR.js} +1 -0
- package/dist/src/{chunk-2PAZTBSE.js → chunk-G44UMBPW.js} +2 -2
- package/dist/src/{chunk-PZXFW6ZD.js → chunk-S6IM5XXK.js} +3 -3
- package/dist/src/{chunk-AXQBWV7J.js → chunk-THZNJBUF.js} +129 -20
- package/dist/src/{chunk-DC7A435Z.js → chunk-UBVMGS2E.js} +1 -1
- package/dist/src/{chunk-HD6FTA3H.js → chunk-UQOXT6QN.js} +109 -87
- package/dist/src/{chunk-T6CAPT32.js → chunk-WV2UYZND.js} +3 -2
- package/dist/src/chunk-XIVHJMET.js +111 -0
- package/dist/src/cli.js +29 -93
- package/dist/src/{commands-BSDNHYB3.js → commands-PLST75CP.js} +11 -10
- package/dist/src/problems-EI4DOEZ4.js +17 -0
- package/dist/src/project-7EROVEUE.js +16 -0
- package/dist/src/run-NE5HOAXA.js +235 -0
- package/dist/src/{server-TJTMSDO2.js → server-KXIU66BB.js} +24 -21
- package/dist/src/{site-RGPJOWSU.js → site-HUWODSZ3.js} +16 -89
- package/dist/src/workspace-load-DOHFEZFR.js +16 -0
- package/dist/web/app/assets/62289de9/build-worker.js +2 -0
- package/dist/web/app/assets/{bf5dd884 → 62289de9}/index.js +2 -2
- package/dist/web/app/assets/protocol-kcdbhuRm.js +15 -0
- package/dist/web/app/index.html +2 -2
- package/dist/web/site/assets/82618540/build-worker.js +2 -0
- package/dist/web/site/assets/{07fb5cf0 → 82618540}/index.js +2 -2
- package/dist/web/site/assets/protocol-XMWr-E-D.js +15 -0
- package/dist/web/site/index.html +2 -2
- package/package.json +1 -1
- package/dist/src/chunk-4QGX7XXO.js +0 -104
- package/dist/src/problems-CGKCPETU.js +0 -18
- package/dist/src/project-EUFMRQXR.js +0 -16
- package/dist/src/run-ER27SVTA.js +0 -183
- package/dist/web/app/assets/bf5dd884/build-worker.js +0 -2
- package/dist/web/app/assets/protocol-Dc79M9p3.js +0 -15
- package/dist/web/site/assets/07fb5cf0/build-worker.js +0 -2
- package/dist/web/site/assets/protocol-F-4tHoAW.js +0 -15
- /package/dist/web/app/assets/{bf5dd884 → 62289de9}/aula-method.js +0 -0
- /package/dist/web/app/assets/{bf5dd884 → 62289de9}/aula.js +0 -0
- /package/dist/web/site/assets/{07fb5cf0 → 82618540}/aula-method.js +0 -0
- /package/dist/web/site/assets/{07fb5cf0 → 82618540}/aula.js +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{_ as e,a as t,b as n,d as r,i,n as a,r as o,s,t as c,v as l,y as u}from"./src-DfPcHwz-.js";function d(n,r){let i=n.titleParts??[{text:n.title}];return e.narrationScript([...i],t(n.lexicon??{}),[...r])}function f(t,n,r){return e.chapterNarration([...t],[...n],r)}function p(t){return e.estimateNarration([...t])}function m(t){return e.renderDiagnostic(t)}var h=`.!?…`,g=`,;:`,_=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?<=[${_(h)}])\\s+`),RegExp(`(?<=[${_(g)}])\\s+`);var v=`cdf77eccfdc734e7a4ee74708e9be9fb3b9d14b0134ce84e5794c27ef1c76706`;`${{path:`aula-voice-${v.slice(0,12)}.avw`,bytes:21474688,sha256:v}.path}`;var ee=e=>Float64Array.from(e,e=>e.start);function te(e,t){if(t.length===0)return e;let n=new Float32Array(e.length+t.reduce((e,t)=>e+t.samples,0)),r=0,i=0;for(let a of t.toSorted((e,t)=>e.sample-t.sample)){let t=Math.min(a.sample,e.length);n.set(e.subarray(r,t),i),i+=t-r+a.samples,r=t}return n.set(e.subarray(r),i),n}function ne(e,t){let n=t.toSorted((e,t)=>e.sample-t.sample);return e.cues.map(e=>{let t=e.speechStartFrame,r=e.endFrame,i=n.filter(e=>e.sample<=t).reduce((e,t)=>e+t.samples,0),a=n.filter(e=>e.sample>t&&e.sample<r).map(e=>({sample:e.sample-t,samples:e.samples})),o=r-t+a.reduce((e,t)=>e+t.samples,0);return{at:t+i,length:o,waits:a}})}function re(e,t){let n=e.samples.length+t.waits.reduce((e,t)=>e+t.samples,0);if(n!==t.length)throw Error(`a speech of ${String(n)} samples with its waits, at a place of ${String(t.length)}`);return te(new Float32Array(e.samples),t.waits)}function ie(e,t){let n=t[0]?.sampleRate??0;if(t.some(e=>e.sampleRate!==n))throw Error(`the narrator changed its sample rate`);return f(e,t.map(e=>e.words?{samples:e.samples,starts:ee(e.words)}:{samples:e.samples}),n)}function ae(e){let t=e.trim(),n=``,r;if(t.startsWith(`at `)){let e=t.slice(3),i=/^(.*) \((.*)\)$/.exec(e);n=i?.[1]??``,r=i?.[2]??e}else{let e=t.lastIndexOf(`@`,t.search(/:\d+:\d+$/));if(e<0)return null;n=t.slice(0,e),r=t.slice(e+1)}let i=/^(.*):(\d+):(\d+)$/.exec(r);return i?.[1]===void 0||i[2]===void 0||i[3]===void 0?null:{functionName:n.replace(/^(async |new )/,``),url:i[1],line:Number(i[2]),column:Number(i[3])}}var oe=e=>t=>{let n=[];for(let r of(t.stack??``).split(`
|
|
2
|
+
`)){let t=ae(r);if(!t)continue;let i=e(t.url,t.line,t.column);n.push({function:t.functionName,file:i.file,line:i.line,col:i.column})}return n},y=e=>JSON.stringify(e.words);function se(e){let t=0xdeadbeef,n=0x41c6ce57;for(let r of e){for(let e=0;e<r.length;e++){let i=r.charCodeAt(e);t=Math.imul(t^i,0x9e3779b1),n=Math.imul(n^i,0x5f356495)}t=Math.imul(t^r.length^0x9e3779b9,0x9e3779b1),n=Math.imul(n^r.length^0x85ebca6b,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35),n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35),(n>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}var ce=(e,t)=>e===``?t:`${e}/${t}`;function le(e,t,n){let r=t=>{throw Error(`the speech of ${JSON.stringify(e.text)} is not on its clock: ${t}`)};(t.sampleRate!==n.sampleRate||t.samples.length!==n.samples)&&r(`${String(t.samples.length)} samples, and the clock has ${String(n.samples)}`);let i=n.words??[];t.words.length!==i.length&&r(`${String(t.words.length)} words, and the clock has ${String(i.length)}`),t.words.forEach((e,t)=>{let n=i[t]?.start;e.start!==n&&r(`word ${String(t+1)} starts at ${String(e.start)} s, and at ${String(n)} s on the clock`)})}var ue=class{name;constructor(e){this.name=e}project=null;titles=[];script=[];estimates=[];knownRate=void 0;lengths=[];warnings=[];drawings=[];drawn=[];kept=new Map;place={chapter:0,seconds:0};stale=!1;halted=!1;running=!1;errors=[];watcher=null;done=Promise.resolve();changed(){this.watcher?.changed(this.state())}window(){if(this.script.length===0)return[];let e=Math.min(Math.max(this.place.chapter,0),this.script.length-1);return e+1<this.script.length?[e,e+1]:[e]}prune(){let e=this.window(),t=!1;for(let n=0;n<this.drawings.length;n++)e.includes(n)||(this.drawings[n]!==void 0&&(this.drawings[n]=void 0,t=!0),this.drawn[n]=!1);return t}rate(){return this.knownRate??this.drawings.find(e=>e!==void 0)?.chapter.rate??this.estimates[0]?.sampleRate??1}samples(e){let t=[0];return this.script.forEach((n,r)=>{let i=this.drawings[r]?.chapter.length??this.lengths[r],a=this.estimates[r],o=i===void 0?a?Math.round(a.endFrame*e/a.sampleRate):0:i;t.push((t[r]??0)+o)}),t}seconds(){let e=this.rate();return this.samples(e).map(t=>t/e)}order(){let e=this.window(),t=e[0];if(t===void 0)return[];let n=this.script[t]??[],r=this.drawn[t]?this.drawings[t]:void 0,i=0;if(r){let e=this.place.seconds*r.chapter.rate,t=r.places.findIndex(t=>t.at+t.length>e);i=t===-1?r.places.length:t}let a=n.map((e,n)=>[t,n]),o=e[1],s=o===void 0?[]:(this.script[o]??[]).map((e,t)=>[o,t]);return[...a.slice(i),...s,...a.slice(0,i)]}next(){for(let[e,t]of this.order()){let n=this.script[e]??[];if(!this.drawn[e]){let t=n.find(e=>!this.kept.has(y(e)));return t?{kind:`time`,cue:t}:{kind:`draw`,chapter:e}}let r=n[t];if(r&&!this.kept.get(y(r))?.speech)return{kind:`speak`,cue:r}}return null}sound(e,t){let n=this.kept.get(e);if(!n?.speech)return;let r=JSON.stringify(t.waits),i=n.sounds.get(r);return i||(i=re(n.speech,t),n.sounds.set(r,i)),i}draw(e,t){let n=this.script[t]??[],r=n.map(y),i=ie(n,r.map(e=>{let t=this.kept.get(e);if(!t)throw Error(`no clock of the cue ${e}`);return t.timing})),a=e.render(t,i);if(a._tag===`Left`)return a;let{lottie:o,waits:s,embeds:c,background:l,warnings:u}=a.right;this.drawn[t]=!0;let d=i.endFrame+s.reduce((e,t)=>e+t.samples,0);this.knownRate=i.sampleRate,this.lengths[t]=d,this.warnings[t]=u;let f=se([JSON.stringify([r,i,s,c,l]),o]);if(this.drawings[t]?.made===f)return{_tag:`Right`,right:void 0};let p=ne(i,s),m={animation:JSON.parse(o),rate:i.sampleRate,length:d,cues:p.map((e,t)=>({at:e.at,length:e.length,samples:this.sound(r[t]??``,e)})),embeds:c.map(({path:t,image:n,kind:r,start:i,frames:a})=>({path:ce(e.folder,t),...n===void 0?{}:{image:ce(e.folder,n)},kind:r,background:l,at:i,seconds:a/60}))};return this.drawings[t]={made:f,chapter:m,keys:r,places:p},this.changed(),{_tag:`Right`,right:void 0}}spoken(e){let t=!1;this.drawings.forEach((n,r)=>{if(!n?.keys.includes(e))return;let i=n.chapter.cues.map((t,r)=>{let i=n.places[r];return n.keys[r]===e&&i?{...t,samples:this.sound(e,i)}:t});this.drawings[r]={...n,chapter:{...n.chapter,cues:i}},t=!0}),t&&this.changed()}forget(){let e=new Set(this.script.flat().map(y));for(let t of this.kept.keys())e.has(t)||this.kept.delete(t)}state(){let e=this.seconds(),t=e.pop()??0;return{building:this.running,timeline:this.script.map((t,n)=>({title:this.titles[n]??``,start:e[n]??0})),duration:t,errors:this.errors,warnings:this.warnings.flat(),chapters:this.drawings.map(e=>e?.chapter)}}};function de(e){let t=null,n=!1,r=null,i=()=>(r=e.workspace.projects(),r),a=async t=>{if(!t.project){let e=await(r??i());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(e._tag===`Left`)return e;let n=e.right.find(e=>e.name===t.name);if(!n)throw Error(`the workspace has no project ${t.name}`);let a=await(n.readScript?.()??n.script());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(a._tag===`Left`)return a;let{script:o}=a.right;t.project=n,t.titles=n.titles,t.script=o,t.estimates=o.map(e=>p(e)),t.drawings.length!==o.length&&(t.drawings=Array.from({length:o.length},()=>void 0),t.lengths=Array.from({length:o.length},()=>void 0)),t.warnings=Array.from({length:o.length},()=>[]),t.drawn=Array.from({length:o.length},()=>!1),t.prune(),t.changed()}let n=t.project;for(let r=t.next();r&&!t.stale&&!t.halted;r=t.next()){if(r.kind===`draw`){if(await n.readChapter?.(r.chapter),t.stale||t.halted)break;let e=t.draw(n,r.chapter);if(e._tag===`Left`)return e;continue}let{cue:i}=r,a=y(i);if(r.kind===`time`){let n=await e.voice.time(i.words);t.kept.set(a,{timing:n,sounds:new Map});continue}let o=await e.voice.speak(i.words),s=t.kept.get(a);if(!s)throw Error(`no clock of the cue ${a}`);le(i,o,s.timing),s.speech=o,t.spoken(a)}return!t.stale&&!t.halted&&t.forget(),{_tag:`Right`,right:void 0}},o=e=>{e.running=!0,e.done=(async()=>{try{for(;;){e.stale=!1;let t=await a(e);if(e.errors=t._tag===`Left`?t.left:[],!e.stale||e.halted)break}}finally{e.running=!1,e.changed()}})()};return{refresh:e=>{r=null;let i=t;!n&&i&&(i.place=e,i.project=null,i.running?i.stale=!0:o(i))},halt:()=>{r=null,t&&=(t.halted=!0,t.watcher=null,null)},stop:()=>{n=!0,t&&(t.halted=!0,t.watcher=null)},idle:()=>t?.done??Promise.resolve(),build:{list:async()=>{let e=await i();return e._tag===`Left`?e:{_tag:`Right`,right:e.right.map(({name:e,title:t,section:n})=>({name:e,title:t,...n===void 0?{}:{section:n}}))}},watch:(e,r)=>{n||(t?.name!==e&&(t&&(t.halted=!0,t.watcher=null),t=new ue(e),o(t)),t.watcher=r,t.changed())},seek:(e,r)=>{t?.name===e&&(t.place=r,t.prune()&&t.changed(),!n&&!t.running&&t.project&&t.errors.length===0&&t.next()!==null&&o(t))}}}}var fe=e=>{if(typeof e==`boolean`)return null;let t=e.anyOf==null?e.oneOf==null?null:`oneOf`:`anyOf`;if(t==null)return null;let n=e[t];if(n==null)return null;let r=n.filter(e=>!pe(e));if(r.length===n.length||r.length===0)return null;let i=r.map(e=>fe(e)??e);return i.length===1?i[0]:{...e,[t]:i}},pe=e=>typeof e!=`boolean`&&e.type===`null`,me=e=>typeof e==`string`?`"${e}"`:typeof e==`number`||typeof e==`boolean`?`${e}`:typeof e==`bigint`?`${e}n`:e===null?`null`:Array.isArray(e)?`Array`:typeof e==`object`?`Object`:JSON.stringify(e),he=e=>{if(e.length===0)return``;let t=e[0];for(let n of e.slice(1))n.startsWith(`[`)?t+=n:t+=`.`+n;return t},b=(e,t)=>{let n=[...e,...t];return n.length>0?`(${he(n)})`:``},x=e=>e.filter(e=>e.length>0).join(` `),ge=(e,t,n)=>x([b(t,e.path),[e.message,n?`received: ${me(e.received)}`:``].filter(e=>e.length>0).join(`, `)]),_e=(e,t)=>{let n=b(t,e.path),r=S(e.errors,[],!1);return x([n,[`Failed to decode one of (${r.length>5?r.slice(0,5).join(` OR `)+` and more...`:r.join(` | `)})`,`received: ${me(e.received)}`].filter(e=>e.length>0).join(`, `)])},S=(e,t,n)=>e.map(e=>`isUnionError`in e?_e(e,t):ge(e,t,n)),ve=(e,t=[])=>S(e,t,!0).map((e,t,n)=>n.length==1?x([e]):x([`#${t}`,e])).join(` | `),C=Object.getPrototypeOf({});function ye(e){function t(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function n(e){let t=0,n=e.length,r=Array(n);for(;t<n;++t)r[t]=p(e[t]);return r}function r(e){let n={};if(c&&Object.getPrototypeOf(e)!==C)return c(e);let r=s(e),i,a,o;for(i=0,a=r.length;i<a;++i)o=r[i],t(n,o,p(e[o]));return n}function i(e,t){let n=e.length,r=t.length,i=0,a=Array(n+r);for(;i<n;++i)a[i]=p(e[i]);for(i=0;i<r;++i)a[i+n]=p(t[i]);return a}let a=Object.prototype.propertyIsEnumerable;function o(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);for(let r=0,i=n.length;r<i;++r)a.call(e,n[r])&&t.push(n[r]);return t}let s=e?.symbols?o:Object.keys,c=typeof e?.cloneProtoObject==`function`?e.cloneProtoObject:void 0;function l(e){return typeof e==`object`&&!!e&&!(e instanceof RegExp)&&!(e instanceof Date)&&!(e instanceof Map)&&!(e instanceof Set)&&!ArrayBuffer.isView(e)}function u(e){return typeof e!=`object`||!e}let d=typeof Buffer<`u`?e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e)||e instanceof Buffer:e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e),f=e&&typeof e.mergeArray==`function`?e.mergeArray({clone:p,deepmerge:h,getKeys:s,isMergeableObject:l}):i;function p(e){return l(e)?Array.isArray(e)?n(e):r(e):e}function m(e,n){let r={},i=s(e),a=s(n),o,u,d;for(o=0,u=i.length;o<u;++o)d=i[o],a.indexOf(d)===-1&&t(r,d,p(e[d]));for(o=0,u=a.length;o<u;++o)d=a[o],i.indexOf(d)===-1?t(r,d,p(n[d])):c&&l(n[d])&&Object.getPrototypeOf(n[d])!==C?t(r,d,c(n[d])):t(r,d,h(e[d],n[d]));return r}function h(e,t){let n=Array.isArray(t),r=Array.isArray(e);return u(t)||t instanceof Map||t instanceof Set?t:d(e)?p(t):n&&r?f(e,t):n===r?m(e,t):p(t)}function g(){switch(arguments.length){case 0:return{};case 1:return p(arguments[0]);case 2:return h(arguments[0],arguments[1])}let e;for(let t=0,n=arguments.length;t<n;++t)e=h(e,arguments[t]);return e}return g}function be(e){let t=e.deepmerge,n=e.clone;return function(e,r){let i=0,a=r.length,o=Math.max(e.length,r.length),s=Array(o);for(i=0;i<o;++i)i<a?s[i]=t(e[i],r[i]):s[i]=n(e[i]);return s}}ye({mergeArray:be});function w(e,t,n){return[{message:t,path:[...e.path],received:n}]}function xe(e,t){let n=[];for(let r=0;r<=e.length;r++){n.push([r]);for(let i=1;i<=t.length;i++)n[r][i]=r===0?i:Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+(e[r-1]===t[i-1]?0:1)),r>1&&i>1&&e[r-1]===t[i-2]&&e[r-2]===t[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1))}return n[e.length][t.length]}function Se(e,t,n,r){if(n==null){T(e,t);let n=w(e,`extra property`,r);return E(e),n}let i=null,a=Math.max(1,Math.floor(t.length/3));for(let e of n){let n=xe(t,e);n<=a&&n<t.length&&(i==null||n<a)&&(i=e,a=n)}let o=i==null?``:` Did you mean ${JSON.stringify(i)}?`,s=n.length===0?`none`:n.map(e=>JSON.stringify(e)).join(`, `);T(e,t);let c=w(e,`extra property.${o} Allowed: ${s}`,r);return E(e),c}function Ce(e,t,n,r,i){r.validate(e,i)||(T(e,n),t.push(...r.reportDecodeError(e,i)),E(e))}function T(e,t){e.path.push(t)}function E(e){e.path.pop()}function we(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function Te(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function D(e,t){return e?.description==null?t:{...t,description:e.description}}function O(e){let t=e.replace(/\*\//g,`* /`).split(`
|
|
3
|
+
`);return t.length===1?`/** ${t[0]} */`:[`/**`,...t.map(e=>` * ${e}`),` */`].join(`
|
|
4
|
+
`)}function k(e,t){return t==null?{typeExpr:e}:{typeExpr:e,docText:t}}var A=class{metadata;constructor(e){this.metadata=e}describe(e){return k(this.describeTypeExpr(e),this.metadata?.description)}describeChildren(){return[]}};function j(e,t){return t.describe(e).typeExpr}function Ee(e){return e.docText==null?e.typeExpr:`${O(e.docText)}\n${e.typeExpr}`}function M(e,t){let n=`type ${e} = ${t.typeExpr};`;return t.docText==null?n:`${O(t.docText)}\n${n}`}function De(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)||/^(0|[1-9][0-9]*)$/.test(e)?e:JSON.stringify(e)}function N(e,t,n){let r=n instanceof F?`?`:``,i=n.describe(e);return{docText:i.docText,member:`${t}${r}: ${i.typeExpr}`}}function Oe(e,t,n){return N(e,`[K in ${j(e,t)}]`,n)}function ke(e){let t=`${e.member};`;return e.docText==null?t:`${O(e.docText)}\n${t}`}function P(e,t){if(e instanceof Fe)e.collectDescribeRefs(t);else for(let n of e.describeChildren())P(n,t)}var Ae=class extends A{typeName;constructor(e,t){super(e),this.typeName=t}describeTypeExpr(e){return this.typeName}schema(e){return D(this.metadata,{type:this.typeName})}validate(e,t){return typeof t===this.typeName}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return w(e,`expected `+this.typeName,t)}},je=class extends A{constructor(e){super(e)}describeTypeExpr(e){return`any`}schema(e){return D(this.metadata,{})}validate(e,t){return!0}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return w(e,`expected any`,t)}},Me=class extends A{constructor(e){super(e)}describeTypeExpr(e){return`never`}schema(e){return D(this.metadata,{anyOf:[]})}validate(e,t){return!1}parseAfterValidation(e,t){throw Error(`unreachable`)}reportDecodeError(e,t){return w(e,`expected never`,t)}},Ne=class extends A{itemParser;constructor(e,t){super(e),this.itemParser=t}schema(e){T(e,`[]`);let t=this.itemParser.schema(e);return E(e),D(this.metadata,{type:`array`,items:t})}validate(e,t){if(Array.isArray(t)){for(let n=0;n<t.length;n++){let r=t[n];if(!this.itemParser.validate(e,r))return!1}return!0}return!1}parseAfterValidation(e,t){return t.map(t=>this.itemParser.parseAfterValidation(e,t))}reportDecodeError(e,t){if(!Array.isArray(t))return w(e,`expected array`,t);let n=[];for(let r=0;r<t.length;r++)Ce(e,n,`[${r}]`,this.itemParser,t[r]);return n}describeTypeExpr(e){return`Array<${j(e,this.itemParser)}>`}describeChildren(){return[this.itemParser]}},F=class{t;constructor(e){this.t=e}schema(e){return{anyOf:[this.t.schema(e),{type:`null`}]}}validate(e,t){return t==null||this.t.validate(e,t)}parseAfterValidation(e,t){return t==null?t:this.t.parseAfterValidation(e,t)}reportDecodeError(e,t){return this.t.reportDecodeError(e,t)}describe(e){return this.t.describe(e)}describeChildren(){return[this.t]}},I=Object.prototype.hasOwnProperty;function L(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var Pe=class extends A{properties;indexedPropertiesParser;constructor(e,t,n){super(e),this.properties=t,this.indexedPropertiesParser=n}describeTypeExpr(e){let t=Object.keys(this.properties).sort().map(t=>{let n=this.properties[t];return N(e,De(t),n)}),n=this.indexedPropertiesParser.map(({key:t,value:n})=>Oe(e,t,n)),r=[...t,...n];return r.some(e=>e.docText!=null)?r.length===0?`{}`:`{\n${r.map(ke).join(`
|
|
5
|
+
`)}\n}`:`{ ${r.map(e=>e.member).join(`, `)} }`}describeChildren(){return[...Object.values(this.properties),...this.indexedPropertiesParser.flatMap(({key:e,value:t})=>[e,t])]}schema(e){let t={},n=new Set;for(let r in this.properties){T(e,r);let i=this.properties[r].schema(e),a=fe(i);a==null?t[r]=i:(t[r]=a,n.add(r)),E(e)}let r=Object.keys(this.properties).filter(e=>!n.has(e)),i={type:`object`,properties:t,...r.length>0?{required:r}:{}},a=this.indexedPropertiesParser.map(({key:t,value:n})=>{T(e,`[key]`);let r=t.schema(e);E(e),T(e,`[value]`);let i=n.schema(e);return E(e),{type:`object`,additionalProperties:i,propertyNames:r}});if(a.length===0)return D(this.metadata,{...i,additionalProperties:!1});if(Object.keys(t).length===0&&a.length===1){let e=this.indexedPropertiesParser[0].value;return e instanceof Me?D(this.metadata,{type:`object`,additionalProperties:!1}):e instanceof je?D(this.metadata,{...a[0],additionalProperties:!0}):D(this.metadata,a[0])}return D(this.metadata,{allOf:[i,...a]})}validate(e,t){if(typeof t==`object`&&!Array.isArray(t)&&t!==null){let n=Object.keys(this.properties);for(let r of n)if(!this.properties[r].validate(e,t[r]))return!1;if(this.indexedPropertiesParser.length>0){let n=Object.keys(t).filter(e=>!I.call(this.properties,e));for(let r of n){let n=!1;for(let i of this.indexedPropertiesParser){if(!i.key.validate(e,r))continue;let a=t[r];if(i.value.validate(e,a)){n=!0;break}}if(!n&&!this.leavesKeyToIntersection(e,t,r))return!1}}else if(e.disallowExtraProperties&&e.intersectionInput!==t&&Object.keys(t).filter(e=>!I.call(this.properties,e)).length>0)return!1;return!0}return!1}parseAfterValidation(e,t){let n={},r=Object.keys(t);if(e.objectKeyOrder===`input`)for(let i of r)if(I.call(this.properties,i))L(n,i,this.properties[i].parseAfterValidation(e,t[i]));else for(let r of this.indexedPropertiesParser){let a=t[i];if(r.key.validate(e,i)&&r.value.validate(e,a)){let t=r.value.parseAfterValidation(e,a);L(n,r.key.parseAfterValidation(e,i),t)}}else{let i=Object.keys(this.properties).sort();for(let r of i){if(!I.call(t,r))continue;let i=t[r];L(n,r,this.properties[r].parseAfterValidation(e,i))}if(this.indexedPropertiesParser.length>0){let i=r.filter(e=>!I.call(this.properties,e)).sort();for(let r of i){let i=t[r];for(let t of this.indexedPropertiesParser)if(t.key.validate(e,r)&&t.value.validate(e,i)){let a=t.value.parseAfterValidation(e,i);L(n,t.key.parseAfterValidation(e,r),a)}}}}return n}reportDecodeError(e,t){if(typeof t!=`object`||Array.isArray(t)||t===null)return w(e,`expected object`,t);let n=[],r=Object.keys(this.properties);for(let i of r)Ce(e,n,i,this.properties[i],t[i]);if(this.indexedPropertiesParser.length>0){let r=Object.keys(t).filter(e=>!I.call(this.properties,e));for(let i of r)if(!this.leavesKeyToIntersection(e,t,i))for(let r of this.indexedPropertiesParser){let a=r.key.validate(e,i),o=r.value.validate(e,t[i]);if(!(a&&o)){if(T(e,i),!a){let t=r.key.reportDecodeError(e,i);n.push(...t)}if(!o){let a=r.value.reportDecodeError(e,t[i]);n.push(...a)}E(e)}}}else if(e.disallowExtraProperties&&e.intersectionInput!==t){let n=Object.keys(t).filter(e=>!I.call(this.properties,e));if(n.length>0)return n.flatMap(n=>Se(e,n,r,t[n]))}return n}allowedKeys(){return this.indexedPropertiesParser.length>0?null:Object.keys(this.properties)}leavesKeyToIntersection(e,t,n){return e.intersectionInput===t&&!this.indexedPropertiesParser.some(t=>t.key.validate(e,n))}},Fe=class extends A{refName;namedRuntypes;constructor(e,t,n){super(e),this.refName=t,this.namedRuntypes=n}getNamedRuntypes(){return this.namedRuntypes}describeTypeExpr(e){return this.refName}collectDescribeRefs(e){let t=this.refName;e.refCounts[t]=(e.refCounts[t]||0)+1,e.activeRefs.has(t)||e.visitedRefs.has(t)||(e.visitedRefs.add(t),e.activeRefs.add(t),P(this.getNamedRuntypes()[t],e),e.activeRefs.delete(t))}describe(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName],r=()=>k(t,this.metadata?.description);if(e.refCounts[t]>1)return e.activeRefs.has(t)||(e.definitions[t]??(e.activeRefs.add(t),e.definitions[t]=n.describe(e),e.activeRefs.delete(t))),r();let i=n.describe(e);return this.metadata?.description==null?i:k(i.typeExpr,this.metadata.description)}schema(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName];if(e.mode===`contextual`){let r=e.printingContext;if(r==null)throw Error(`INTERNAL ERROR: Missing SchemaPrintingContext`);if(!r.hasDefinition(t)&&!r.isDefinitionInProgress(t)){r.markDefinitionInProgress(t);let i=(r.getNamedTypeSchemaOverride(t)??n).schema(e);r.storeDefinition(t,i)}return D(this.metadata,{$ref:r.getRef(t)})}if(e.seen[t])return D(this.metadata,{});e.seen[t]=!0;var r=n.schema(e);return delete e.seen[t],D(this.metadata,r)}validate(e,t){return this.getNamedRuntypes()[this.refName].validate(e,t)}parseAfterValidation(e,t){return this.getNamedRuntypes()[this.refName].parseAfterValidation(e,t)}reportDecodeError(e,t){return this.getNamedRuntypes()[this.refName].reportDecodeError(e,t)}},Ie=class{_runtype;name;hideTypeNameInDescribe;constructor(e,t,n){this._runtype=e,this.name=t,this.hideTypeNameInDescribe=n}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;let r=ve(n.errors,[]);throw Error(`Failed to parse ${this.name} - ${r}`)}safeParse(e,t){let n=t?.disallowExtraProperties??!1,r=t?.objectKeyOrder??`input`;if(this.validate(e,t)){let t={disallowExtraProperties:n,objectKeyOrder:r};return{success:!0,data:this._runtype.parseAfterValidation(t,e)}}let i={path:[],disallowExtraProperties:n};return{success:!1,errors:this._runtype.reportDecodeError(i,e).slice(0,10)}}validate(e,t){let n={disallowExtraProperties:t?.disallowExtraProperties??!1},r=this._runtype.validate(n,e);if(typeof r!=`boolean`)throw Error(`INTERNAL ERROR: Expected boolean`);return r}schema(){return this._runtype.schema({path:[],seen:{},mode:`flat`})}schemaWithContext(e){let t={path:[],seen:{},mode:`contextual`,printingContext:e};return this._runtype.schema(t)}describe(){let e={activeRefs:new Set,definitions:{},refCounts:{},visitedRefs:new Set};P(this._runtype,e);let t=this._runtype.describe(e),n=Object.keys(e.definitions).sort().map(t=>[t,e.definitions[t]]).map(([e,t])=>M(e,t)).join(`
|
|
6
|
+
|
|
7
|
+
`);return this.hideTypeNameInDescribe?[n,Ee(t)].filter(e=>e!=null&&e.length>0).join(`
|
|
8
|
+
|
|
9
|
+
`):[n,M(`Codec${this.name}`,t)].filter(e=>e!=null&&e.length>0).join(`
|
|
10
|
+
|
|
11
|
+
`)}},Le=(e,t,n)=>new Ie(e,t,n),Re=(e,t)=>{let n=t?.stringFormats??{};for(let t of e.requiredStringFormats)if(n[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(n).forEach(t=>{let r=n[t];we(e.stringFormatters,t,r)});let r=t?.numberFormats??{};for(let t of e.requiredNumberFormats)if(r[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(r).forEach(t=>{let n=r[t];Te(e.numberFormatters,t,n)});let i={};for(let t of Object.keys(e.parsers))i[t]=Le(e.parsers[t],t,!1);return i},ze=[],Be=[],R={},Ve={},He={},Ue=new Fe(void 0,`PackageJson`,R),We=new je(void 0),z=new Ae(void 0,`string`),Ge=new Ne(void 0,z),Ke=new Pe({description:`The part of a package.json that aula reads: how a package names its module and its
|
|
12
|
+
workspace packages, and its version when the CLI compares it to the project's.`},{exports:new F(We),main:new F(z),module:new F(z),name:new F(z),version:new F(z),workspaces:new F(Ge)},[]);Object.assign(R,{PackageJson:Ke});var qe={PackageJson:Ue},Je={buildParsers:e=>Re({parsers:qe,stringFormatters:Ve,numberFormatters:He,requiredStringFormats:ze,requiredNumberFormats:Be},e)}.buildParsers();function Ye(e,t){let n=[...e];return{read:t,list:e=>{let t=e===``?``:`${e}/`,r=new Set;for(let e of n){if(!e.startsWith(t))continue;let[n,...i]=e.slice(t.length).split(`/`);n!==void 0&&i.length>0&&r.add(n)}return Promise.resolve([...r].toSorted())}}}var B=Object.fromEntries([`@beff/aula`,`@beff/aula-method`].map(e=>[e,`aula-provide:${e}`])),V=`aula-projects.ts`;function Xe(e,t){let n=e;for(let[e,r]of Object.entries(B)){let i=t[e];i!==void 0&&(n=n.replaceAll(JSON.stringify(r),JSON.stringify(i)))}return n}var H=`tree:`;function U(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function W(e,t){let n=e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(!n.length)return null;n.pop()}else n.push(e)}return n.join(`/`)}var Ze=new Map([[`ts`,`ts`],[`mts`,`ts`],[`js`,`js`],[`mjs`,`js`],[`json`,`json`]]),Qe=e=>Ze.get(e.slice(e.lastIndexOf(`.`)+1))??`ts`;function $e(e,t){return{name:`aula-tree`,setup(n){n.onResolve({filter:/.*/},async n=>{let r=t[n.path];if(r!==void 0)return{path:r,external:!0};if(n.kind===`entry-point`)return{path:W(``,n.path)??n.path,namespace:`tree`};if(!n.path.startsWith(`./`)&&!n.path.startsWith(`../`)){let t=await at(e,n.path,n.importer);return t===null?{errors:[{text:`cannot find the package "${n.path}" in node_modules or the workspace packages`}]}:{path:t,namespace:`tree`}}let i=W(U(n.importer),n.path);if(i===null)return{errors:[{text:`"${n.path}" is outside the folder you opened`}]};for(let t of[i,`${i}.ts`,`${i}/index.ts`])if(await e.read(t)!==null)return{path:t,namespace:`tree`};return{errors:[{text:`cannot find "${n.path}" (${i})`}]}}),n.onLoad({filter:/.*/,namespace:`tree`},async t=>{let n=await e.read(t.path);return n===null?{errors:[{text:`cannot read ${t.path}`}]}:{contents:n,loader:Qe(t.path)}})}}}function et(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`text`)==`string`}var tt=({text:e,location:t})=>({severity:`error`,code:`bundle-error`,message:e,...t?{location:{file:t.file.replace(H,``),line:t.line,col:t.column+1}}:{},stack:[],related:[]});async function nt(e,t,n,r){let i;try{i=await e.build({entryPoints:[n],bundle:!0,write:!1,format:`esm`,platform:`browser`,target:`es2024`,outfile:`bundle.js`,sourcemap:`both`,sourcesContent:!1,metafile:!0,logLevel:`silent`,plugins:[$e(t,r)]})}catch(e){let t=typeof e==`object`&&e?Reflect.get(e,`errors`):void 0;if(Array.isArray(t)&&t.every(et))return{_tag:`Left`,left:t.map(tt)};throw e}let a=i.outputFiles.find(e=>e.path.endsWith(`.js`))?.text,o=i.outputFiles.find(e=>e.path.endsWith(`.js.map`))?.text;if(a===void 0||o===void 0)throw Error(`esbuild wrote no bundle`);return{_tag:`Right`,right:{code:a,map:o,inputs:Object.keys(i.metafile?.inputs??{}).filter(e=>e.startsWith(H)).map(e=>e.slice(5))}}}function G(e,t){if(typeof e==`string`)return t===`.`?e:null;if(typeof e!=`object`||!e)return null;if(Object.keys(e).some(e=>e.startsWith(`.`)))return t in e?G(Reflect.get(e,t),`.`):null;for(let t of[`browser`,`import`,`default`])if(t in e)return G(Reflect.get(e,t),`.`);return null}function K(e){let t=e.split(`/`),n=e.startsWith(`@`)?2:1,r=t.slice(n).join(`/`);return{name:t.slice(0,n).join(`/`),subpath:r===``?`.`:`./${r}`}}async function q(e,t,n){let r=J(`${t}/package.json`,await e.read(`${t}/package.json`));return r?W(t,G(r.exports,n)??(n===`.`?r.module??r.main??`index.js`:n)):null}async function rt(e,t,n){let{name:r,subpath:i}=K(t);for(let t=U(n);;t=U(t)){let n=await q(e,t===``?`node_modules/${r}`:`${t}/node_modules/${r}`,i);if(n!==null)return n;if(t===``)return null}}function J(e,t){if(t===null)return null;let n=Je.PackageJson.safeParse(JSON.parse(t));return n.success?n.data:null}async function it(e){let t=[],n=await e.read(`pnpm-workspace.yaml`);if(n!==null){let e=!1;for(let r of n.split(`
|
|
13
|
+
`))if(/^packages:\s*$/.test(r))e=!0;else if(/^\S/.test(r))e=!1;else if(e){let e=/^\s*-\s*["']?([^"'#]+?)["']?\s*(#.*)?$/.exec(r)?.[1];e!==void 0&&t.push(e)}}t.push(...J(`package.json`,await e.read(`package.json`))?.workspaces??[]);let r=[];for(let n of t){let t=n.replace(/^\.\//,``).replace(/\/$/,``);if(t.endsWith(`/*`)){let n=t.slice(0,-2);r.push(...(await e.list(n)).map(e=>`${n}/${e}`))}else t.includes(`*`)||r.push(t)}return r}async function at(e,t,n){let r=await rt(e,t,n);if(r!==null)return r;let{name:i,subpath:a}=K(t);for(let t of await it(e))if(J(`${t}/package.json`,await e.read(`${t}/package.json`))?.name===i)return q(e,t,a);return null}var Y=/^(\d+)-/,X=e=>e.replace(Y,``);function ot(e){let t=X(e).replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var Z=(e,t)=>e<t?-1:+(e>t);function st(e,t){let n=Y.exec(e)?.[1],r=Y.exec(t)?.[1];if(n===void 0||r===void 0){if(n!==r)return n===void 0?1:-1}else{let[e,t]=[n.replace(/^0+/,``),r.replace(/^0+/,``)],i=e.length-t.length||Z(e,t);if(i!==0)return i}return Z(X(e),X(t))||Z(e,t)}async function ct(e,t){return(await e.list(t)).filter(e=>e!==`node_modules`&&!e.startsWith(`.`)).toSorted(st)}var Q=async(e,t)=>await e.read(t)!==null;async function lt(e,t){if(await Q(e,`index.ts`))return{_tag:`Right`,right:[{module:`index.ts`,name:X(t)}]};let n=[];for(let t of await ct(e,``))if(await Q(e,`${t}/index.ts`))n.push({module:`${t}/index.ts`,name:X(t)});else for(let r of await ct(e,t)){let i=`${t}/${r}/index.ts`;await Q(e,i)&&n.push({module:i,name:X(r),section:ot(t)})}let r=[];return n.forEach((e,t)=>{let i=n.findIndex(t=>t.name===e.name);if(i===t)return;let a=[n[i],e].map(e=>(e?.module??``).slice(0,-9));r.push({severity:`error`,code:`duplicate-project-name`,message:`two projects have the name ${e.name}: ${a.join(` and `)}`,hint:`the name of a project is its folder name without the order prefix: rename one of the folders`,stack:[],related:[]})}),r.length>0?{_tag:`Left`,left:r}:{_tag:`Right`,right:n}}var ut=`no project here: pass a project or playlist folder (for example: aula web . or aula web examples)`;async function dt(e,t,n,r){if(r.length===0)throw Error(ut);let i=[...r.map((e,t)=>`import p${String(t)} from ${JSON.stringify(`./${e.module}`)};`),`export default [${r.map((e,t)=>`p${String(t)}`).join(`, `)}];`].join(`
|
|
14
|
+
`),a=await nt(e,{read:e=>e===`aula-projects.ts`?Promise.resolve(i):t.read(e),list:e=>t.list(e)},V,B);return a._tag===`Left`?a:{_tag:`Right`,right:{bundle:{name:n,projects:[...r],code:a.right.code,map:a.right.map},inputs:a.right.inputs}}}async function ft(e,t,n){let r=await lt(t,n);return r._tag===`Left`?r:dt(e,t,n,r.right)}var pt=(e,t)=>({frames:e,name:e=>/^[a-z][a-z0-9+.-]*:/.test(e)?void 0:e,exists:()=>!0,...t?{media:t}:{}}),mt=(e,t)=>typeof e==`object`&&e?Reflect.get(e,t):void 0;async function ht(e,t,i,o,s){await u(),await l(),s?.();let c=Xe(e.code,o),d=await n(()=>i.load({code:c,map:e.map}));if(d._tag===`Left`)return{_tag:`Left`,left:[a(d.left,V,t)]};let f=mt(d.right.exports,`default`);if(!Array.isArray(f))throw Error(`${V} has no list of projects`);return{_tag:`Right`,right:f.map((n,i)=>{let a=e.projects[i];if(!r(n))throw Error(`the default export of ${a?.module??``} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ … ] })\``);return yt(a?.name??``,_t(a?.module??`index.ts`),a?.section,n,t)})}}async function gt(e,t,n,r,i,a){let o=await e.name(),[s]=await Promise.all([ft(r,e,o),u().then(async()=>{await l(),a?.()})]);return s._tag===`Left`?s:ht(s.right.bundle,t,n,i)}var _t=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`)));function vt(e,t={}){return t.includeDrafts?[...e]:e.filter(e=>!e.draft)}function yt(e,t,n,r,a){let l=r.chapters.length+1;return{name:e,folder:t,...n===void 0?{}:{section:n},title:r.title,draft:r.draft,chapters:l,titles:[r.title,...r.chapters.map(e=>e.heading)],script:()=>{let e=[];for(let t of r.chapters.keys()){let n=o(r,t+1,{host:a});if(n.value===void 0)return{_tag:`Left`,left:n.diagnostics};e.push(n.value)}return{_tag:`Right`,right:{script:d(r,e)}}},walk:e=>{e>0&&c(r,e,{host:a})},render:(e,t)=>{let n=i(r,e,{host:a,narration:t});if(!n.ok||n.value===void 0)return{_tag:`Left`,left:n.diagnostics};let{lottie:o,waits:c,embeds:l,diagnostics:u}=n.value;return{_tag:`Right`,right:{lottie:o,waits:c,embeds:l,background:(r.theme??s).background,warnings:u}}}}}function bt(e){return e}function xt(e,t){return Object.assign({},e,t)}function St(e,t){return{...e,...t}}function Ct(...e){return Object.assign({},...e)}var wt={create:bt,extend:xt,merge:Ct,override:St},Tt=class extends Error{constructor(e,t){super(e),this.stack=t}};function Et(e,t,n){return e===``?``:` at ${e}:${String(t)}:${String(n)}`}var $=e=>`${e.file}:${String(e.line)}:${String(e.col)}`;function Dt(e,t){if(!(e instanceof Error))return{message:String(e),place:null,stack:[]};let n=t(e),[r]=n;return{message:e.name===`Error`||e.name===``?e.message:`${e.name}: ${e.message}`,place:r?$(r):null,stack:n.map(e=>e.function===``?`at ${$(e)}`:`at ${e.function} (${$(e)})`)}}function Ot(e,t,n){let r=(t,n,r)=>{let i=e.createElement(t);return i.className=n,i.textContent=r,i},i=r(`div`,`crash`,``);i.setAttribute(`role`,`alert`),i.append(r(`h1`,``,`The app stopped because of an error.`),r(`p`,`message`,t.message)),t.place!==null&&i.append(r(`p`,`place`,`at ${t.place}`)),t.stack.length>0&&i.append(r(`pre`,`stack`,t.stack.join(`
|
|
15
|
+
`)));let a=r(`button`,`reload`,`Reload`);a.addEventListener(`click`,n),i.append(a),e.body.replaceChildren(i)}var kt=2e5;function At(e){let{layers:t,...n}=e,r=[JSON.stringify({...n,layers:[]})],i=[],a=0;for(let e of t){let t=JSON.stringify(e);a>0&&a+t.length>kt&&(r.push(`[${i.join(`,`)}]`),i=[],a=0),i.push(t),a+=t.length+1}return i.length>0&&r.push(`[${i.join(`,`)}]`),r}async function jt(e,t){let[n,...r]=e;if(n===void 0)throw Error(`a Lottie animation with no parts`);let i=JSON.parse(n);for(let e of r){await t();let n=JSON.parse(e);i.layers.push(...n)}return i}var Mt=e=>e.map(e=>({...e,text:m(e)}));function Nt(e){let t=Reflect.get(e,`text`);if(typeof t!=`string`)throw Error(`a diagnostic with no text: ${e.message}`);return t}export{oe as _,Tt as a,Ot as c,ht as d,gt as f,de as g,Ye as h,At as i,wt as l,H as m,Mt as n,Dt as o,pt as p,jt as r,Et as s,Nt as t,vt as u};
|
package/dist/web/site/index.html
CHANGED
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
28
28
|
<link rel="icon" href="data:," />
|
|
29
29
|
<title>Aula videos</title>
|
|
30
|
-
<script type="module" crossorigin src="./assets/
|
|
30
|
+
<script type="module" crossorigin src="./assets/82618540/index.js"></script>
|
|
31
31
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-BLXQ4ufn.js">
|
|
32
32
|
<link rel="modulepreload" crossorigin href="./assets/src-DfPcHwz-.js">
|
|
33
|
-
<link rel="modulepreload" crossorigin href="./assets/protocol-
|
|
33
|
+
<link rel="modulepreload" crossorigin href="./assets/protocol-XMWr-E-D.js">
|
|
34
34
|
<link rel="stylesheet" crossorigin href="./assets/index-qn44kZJM.css">
|
|
35
35
|
</head>
|
|
36
36
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beff/aula-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The aula command: runs chapter modules on the inlined engine, checks and lints them, writes PNG pictures for review, makes project zips, and serves the web player with narration.",
|
|
6
6
|
"license": "MIT AND GPL-3.0-or-later",
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
chapterNarration
|
|
3
|
-
} from "./chunk-TDAWUJ2L.js";
|
|
4
|
-
|
|
5
|
-
// ../aula-narration/src/script.ts
|
|
6
|
-
var starts = (words) => Float64Array.from(words, (w) => w.start);
|
|
7
|
-
function joinChapter(cues, speeches) {
|
|
8
|
-
let rate = 0;
|
|
9
|
-
for (const [i, speech] of speeches.entries()) {
|
|
10
|
-
if (!speech.samples.length || speech.samples.some((s) => !Number.isFinite(s))) {
|
|
11
|
-
const text = cues[i]?.text.slice(0, 60) ?? "";
|
|
12
|
-
throw new Error(`the narrator returned empty or invalid audio for ${JSON.stringify(text)}`);
|
|
13
|
-
}
|
|
14
|
-
if (rate !== 0 && speech.sampleRate !== rate) throw new Error("the narrator changed its sample rate");
|
|
15
|
-
rate = speech.sampleRate;
|
|
16
|
-
}
|
|
17
|
-
const spoken = speeches.map((s) => ({ samples: s.samples.length, starts: starts(s.words) }));
|
|
18
|
-
const narration = chapterNarration(cues, spoken, rate);
|
|
19
|
-
const samples = new Float32Array(narration.endFrame);
|
|
20
|
-
for (const [i, speech] of speeches.entries()) samples.set(speech.samples, narration.cues[i]?.speechStartFrame ?? 0);
|
|
21
|
-
return { samples, narration };
|
|
22
|
-
}
|
|
23
|
-
function withWaits(samples, waits) {
|
|
24
|
-
if (waits.length === 0) return samples;
|
|
25
|
-
const out = new Float32Array(samples.length + waits.reduce((sum, w) => sum + w.samples, 0));
|
|
26
|
-
let from = 0;
|
|
27
|
-
let to = 0;
|
|
28
|
-
for (const wait of waits.toSorted((a, b) => a.sample - b.sample)) {
|
|
29
|
-
const at = Math.min(wait.sample, samples.length);
|
|
30
|
-
out.set(samples.subarray(from, at), to);
|
|
31
|
-
to += at - from + wait.samples;
|
|
32
|
-
from = at;
|
|
33
|
-
}
|
|
34
|
-
out.set(samples.subarray(from), to);
|
|
35
|
-
return out;
|
|
36
|
-
}
|
|
37
|
-
function timeChapter(cues, timings) {
|
|
38
|
-
const rate = timings[0]?.sampleRate ?? 0;
|
|
39
|
-
if (timings.some((t) => t.sampleRate !== rate)) throw new Error("the narrator changed its sample rate");
|
|
40
|
-
const spoken = timings.map(
|
|
41
|
-
(t) => t.words ? { samples: t.samples, starts: starts(t.words) } : { samples: t.samples }
|
|
42
|
-
);
|
|
43
|
-
return chapterNarration(cues, spoken, rate);
|
|
44
|
-
}
|
|
45
|
-
async function narrateScript(speak, chapters, speaking) {
|
|
46
|
-
const count = chapters.reduce((sum, c) => sum + c.length, 0);
|
|
47
|
-
let spoken = 0;
|
|
48
|
-
const narrated = [];
|
|
49
|
-
for (const cues of chapters) {
|
|
50
|
-
const speeches = [];
|
|
51
|
-
for (const cue of cues) {
|
|
52
|
-
spoken += 1;
|
|
53
|
-
speaking(spoken, count, cue);
|
|
54
|
-
speeches.push(await speak(cue.words));
|
|
55
|
-
}
|
|
56
|
-
narrated.push(joinChapter(cues, speeches));
|
|
57
|
-
}
|
|
58
|
-
if (!narrated.some((c) => c.narration.sampleRate > 0)) throw new Error("the script has no cues");
|
|
59
|
-
return narrated;
|
|
60
|
-
}
|
|
61
|
-
function scriptAudio(chapters, waits) {
|
|
62
|
-
const sounds = chapters.map((c, i) => withWaits(c.samples, waits[i] ?? []));
|
|
63
|
-
const samples = new Float32Array(sounds.reduce((sum, s) => sum + s.length, 0));
|
|
64
|
-
let at = 0;
|
|
65
|
-
for (const sound of sounds) {
|
|
66
|
-
samples.set(sound, at);
|
|
67
|
-
at += sound.length;
|
|
68
|
-
}
|
|
69
|
-
const sampleRate = chapters.find((c) => c.narration.sampleRate > 0)?.narration.sampleRate ?? 0;
|
|
70
|
-
return { samples, sampleRate };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// ../aula-narration/src/wav.ts
|
|
74
|
-
function wav(samples, rate) {
|
|
75
|
-
const bytes = new Uint8Array(44 + samples.length * 2);
|
|
76
|
-
const view = new DataView(bytes.buffer);
|
|
77
|
-
const text = (at, value) => {
|
|
78
|
-
for (let i = 0; i < value.length; i++) view.setUint8(at + i, value.charCodeAt(i));
|
|
79
|
-
};
|
|
80
|
-
text(0, "RIFF");
|
|
81
|
-
view.setUint32(4, 36 + samples.length * 2, true);
|
|
82
|
-
text(8, "WAVE");
|
|
83
|
-
text(12, "fmt ");
|
|
84
|
-
view.setUint32(16, 16, true);
|
|
85
|
-
view.setUint16(20, 1, true);
|
|
86
|
-
view.setUint16(22, 1, true);
|
|
87
|
-
view.setUint32(24, rate, true);
|
|
88
|
-
view.setUint32(28, rate * 2, true);
|
|
89
|
-
view.setUint16(32, 2, true);
|
|
90
|
-
view.setUint16(34, 16, true);
|
|
91
|
-
text(36, "data");
|
|
92
|
-
view.setUint32(40, samples.length * 2, true);
|
|
93
|
-
samples.forEach((sample, i) => {
|
|
94
|
-
view.setInt16(44 + i * 2, Math.round(Math.min(1, Math.max(-1, sample)) * 32767), true);
|
|
95
|
-
});
|
|
96
|
-
return bytes;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export {
|
|
100
|
-
timeChapter,
|
|
101
|
-
narrateScript,
|
|
102
|
-
scriptAudio,
|
|
103
|
-
wav
|
|
104
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
printDiagnostics
|
|
3
|
-
} from "./chunk-PZXFW6ZD.js";
|
|
4
|
-
import "./chunk-AXQBWV7J.js";
|
|
5
|
-
import "./chunk-4QGX7XXO.js";
|
|
6
|
-
import "./chunk-TDAWUJ2L.js";
|
|
7
|
-
import "./chunk-2PAZTBSE.js";
|
|
8
|
-
import {
|
|
9
|
-
diagnosticsOf
|
|
10
|
-
} from "./chunk-T6CAPT32.js";
|
|
11
|
-
import "./chunk-RAGZAJKD.js";
|
|
12
|
-
import "./chunk-DN2LVJO3.js";
|
|
13
|
-
import "./chunk-VX7UVLQW.js";
|
|
14
|
-
import "./chunk-CZ7CSFO4.js";
|
|
15
|
-
export {
|
|
16
|
-
diagnosticsOf,
|
|
17
|
-
printDiagnostics
|
|
18
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
exists,
|
|
3
|
-
host,
|
|
4
|
-
loadProject
|
|
5
|
-
} from "./chunk-DC7A435Z.js";
|
|
6
|
-
import "./chunk-2PAZTBSE.js";
|
|
7
|
-
import "./chunk-T6CAPT32.js";
|
|
8
|
-
import "./chunk-RAGZAJKD.js";
|
|
9
|
-
import "./chunk-DN2LVJO3.js";
|
|
10
|
-
import "./chunk-VX7UVLQW.js";
|
|
11
|
-
import "./chunk-CZ7CSFO4.js";
|
|
12
|
-
export {
|
|
13
|
-
exists,
|
|
14
|
-
host,
|
|
15
|
-
loadProject
|
|
16
|
-
};
|
package/dist/src/run-ER27SVTA.js
DELETED
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
bundle,
|
|
3
|
-
check,
|
|
4
|
-
exportVideo,
|
|
5
|
-
preview,
|
|
6
|
-
script,
|
|
7
|
-
timeline
|
|
8
|
-
} from "./chunk-HD6FTA3H.js";
|
|
9
|
-
import "./chunk-THQ5Y74K.js";
|
|
10
|
-
import "./chunk-F4XRXW6M.js";
|
|
11
|
-
import "./chunk-4N4NUMKP.js";
|
|
12
|
-
import "./chunk-PZXFW6ZD.js";
|
|
13
|
-
import "./chunk-AXQBWV7J.js";
|
|
14
|
-
import "./chunk-4QGX7XXO.js";
|
|
15
|
-
import "./chunk-TDAWUJ2L.js";
|
|
16
|
-
import "./chunk-DC7A435Z.js";
|
|
17
|
-
import "./chunk-2PAZTBSE.js";
|
|
18
|
-
import {
|
|
19
|
-
wrongArgument
|
|
20
|
-
} from "./chunk-T6CAPT32.js";
|
|
21
|
-
import "./chunk-RAGZAJKD.js";
|
|
22
|
-
import "./chunk-DN2LVJO3.js";
|
|
23
|
-
import "./chunk-VX7UVLQW.js";
|
|
24
|
-
import "./chunk-CZ7CSFO4.js";
|
|
25
|
-
|
|
26
|
-
// src/run.ts
|
|
27
|
-
import path from "node:path";
|
|
28
|
-
var USAGE = `aula: storyboard-first narrated aula videos.
|
|
29
|
-
|
|
30
|
-
<folder> is a project folder: it has index.ts, which exports
|
|
31
|
-
defineProject({ title, theme, chapters }). <chapter> is a chapter name such as
|
|
32
|
-
01-double-the-side (its number and the slug of its heading), or title (the
|
|
33
|
-
title card). Each chapter module holds its script, storyboard notes and
|
|
34
|
-
animations; messages name its lines (file:line:col).
|
|
35
|
-
|
|
36
|
-
aula check <folder> [<chapter> ...] [--json]
|
|
37
|
-
every check, with no narration and no frames, and
|
|
38
|
-
a note for each word whose reading is not clear;
|
|
39
|
-
--json prints the result as one JSON object
|
|
40
|
-
aula preview <folder> <out> [<chapter>[:<line>] ...]
|
|
41
|
-
PNG pictures for review: per chapter, stills,
|
|
42
|
-
motion stills, contact sheets and moves.md
|
|
43
|
-
aula export <folder> <file.mp4> the video to send: narrated in this run, H.264 and
|
|
44
|
-
AAC at 1280x720 and 60 fps; needs ffmpeg
|
|
45
|
-
aula web [<folder>] [--port N] [--host H]
|
|
46
|
-
the web app for a project folder (index.ts) or a
|
|
47
|
-
playlist folder of such projects (default: cwd);
|
|
48
|
-
not a monorepo root that also holds kits; draft:
|
|
49
|
-
true projects stay out of a playlist list; the page
|
|
50
|
-
narrates in the browser; --host defaults to 127.0.0.1
|
|
51
|
-
(use 0.0.0.0 to listen on all interfaces)
|
|
52
|
-
aula bundle <folder> <file.zip> the project zip: the project folder, and the
|
|
53
|
-
packages it imports, to share or host
|
|
54
|
-
aula site <folder> <out> [--title <text>] [--base <path>]
|
|
55
|
-
a website of a project or playlist folder (same as
|
|
56
|
-
aula web; not a monorepo root that also holds kits;
|
|
57
|
-
draft: true projects stay out): the folder's files
|
|
58
|
-
with the packages they import, and the web app, as
|
|
59
|
-
plain files in <out> for any static host; --title
|
|
60
|
-
is the site's title (default: the folder's name);
|
|
61
|
-
--base pins the site to a base path such as /aula/
|
|
62
|
-
(default: it works at any path)
|
|
63
|
-
aula script <folder> [<chapter> ...] the review script: each chapter with its length,
|
|
64
|
-
each spoken beat and what is on screen
|
|
65
|
-
aula timeline <folder> [<chapter> ...]
|
|
66
|
-
print each say and move with its line, second
|
|
67
|
-
and note (agent view)
|
|
68
|
-
aula tokens Kokoro v1.0's token ids of texts, for training
|
|
69
|
-
data: reads JSON lines {"id"?, "text"} on
|
|
70
|
-
stdin, writes {"id"?, "batches": [{"phonemes",
|
|
71
|
-
"ids"}]} on stdout, one batch per model run
|
|
72
|
-
|
|
73
|
-
Errors make the exit code 1. Warnings do not change it.`;
|
|
74
|
-
var VALUED = {
|
|
75
|
-
"--port": { what: "a port number", number: true },
|
|
76
|
-
"--host": { what: "a host", number: false },
|
|
77
|
-
"--title": { what: "a title", number: false },
|
|
78
|
-
"--base": { what: "a base path", number: false }
|
|
79
|
-
};
|
|
80
|
-
function parse(argv, allowed) {
|
|
81
|
-
const args = { positional: [], values: /* @__PURE__ */ new Map(), flags: /* @__PURE__ */ new Set() };
|
|
82
|
-
for (let i = 0; i < argv.length; i++) {
|
|
83
|
-
const arg = argv[i] ?? "";
|
|
84
|
-
const what = VALUED[arg];
|
|
85
|
-
if (what !== void 0 && allowed.includes(arg)) {
|
|
86
|
-
i += 1;
|
|
87
|
-
const value = argv[i];
|
|
88
|
-
if (value === void 0) throw wrongArgument(`${arg} needs ${what.what}`);
|
|
89
|
-
if (!what.number) {
|
|
90
|
-
args.values.set(arg, value);
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
if (!/^[0-9]+$/.test(value)) throw wrongArgument(`${arg} ${value} is not a number`);
|
|
94
|
-
args.values.set(arg, Number(value));
|
|
95
|
-
} else if (allowed.includes(arg)) {
|
|
96
|
-
args.flags.add(arg);
|
|
97
|
-
} else if (arg.startsWith("--")) {
|
|
98
|
-
throw wrongArgument(`unknown option ${arg}`, "run `aula help` for the options of each command");
|
|
99
|
-
} else {
|
|
100
|
-
args.positional.push(arg);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return args;
|
|
104
|
-
}
|
|
105
|
-
var OPTIONS = {
|
|
106
|
-
check: ["--json"],
|
|
107
|
-
web: ["--port", "--host"],
|
|
108
|
-
site: ["--title", "--base"]
|
|
109
|
-
};
|
|
110
|
-
var isHelp = (command) => command === void 0 || command === "help" || command === "-h" || command === "--help";
|
|
111
|
-
var ARITY = {
|
|
112
|
-
check: [0, Infinity],
|
|
113
|
-
preview: [1, Infinity],
|
|
114
|
-
export: [1, 1],
|
|
115
|
-
bundle: [1, 1],
|
|
116
|
-
script: [0, Infinity],
|
|
117
|
-
timeline: [0, Infinity]
|
|
118
|
-
};
|
|
119
|
-
function folderArgs(cwd, command, args) {
|
|
120
|
-
const arity = ARITY[command];
|
|
121
|
-
if (arity === void 0) throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
|
|
122
|
-
const [folder, ...rest] = args.positional;
|
|
123
|
-
if (folder === void 0) throw wrongArgument("missing <folder>: the project folder, which has index.ts");
|
|
124
|
-
if (rest.length < arity[0] || rest.length > arity[1])
|
|
125
|
-
throw wrongArgument("wrong number of arguments", "run `aula help` for the usage");
|
|
126
|
-
return { folder: path.resolve(cwd, folder), rest };
|
|
127
|
-
}
|
|
128
|
-
async function run(capabilities, cwd, command, project, rest, flags = /* @__PURE__ */ new Set()) {
|
|
129
|
-
const [first = "", ...more] = rest;
|
|
130
|
-
switch (command) {
|
|
131
|
-
case "check":
|
|
132
|
-
return check(capabilities, cwd, project, rest, flags.has("--json"));
|
|
133
|
-
case "preview":
|
|
134
|
-
return preview(capabilities, cwd, project, path.resolve(cwd, first), more);
|
|
135
|
-
case "export":
|
|
136
|
-
return exportVideo(capabilities, cwd, project, path.resolve(cwd, first));
|
|
137
|
-
case "bundle":
|
|
138
|
-
return bundle(capabilities, project, path.resolve(cwd, first));
|
|
139
|
-
case "script":
|
|
140
|
-
return script(capabilities, cwd, project, rest);
|
|
141
|
-
case "timeline":
|
|
142
|
-
return timeline(capabilities, cwd, project, rest);
|
|
143
|
-
default:
|
|
144
|
-
throw wrongArgument(`unknown command ${command}`, "run `aula help` for the commands");
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
function webOptions(cwd, args) {
|
|
148
|
-
if (args.positional.length > 1) throw wrongArgument("aula web takes one folder", "run `aula help` for the usage");
|
|
149
|
-
const port = args.values.get("--port");
|
|
150
|
-
const host = args.values.get("--host");
|
|
151
|
-
return {
|
|
152
|
-
root: path.resolve(cwd, args.positional[0] ?? "."),
|
|
153
|
-
port: typeof port === "number" ? port : 0,
|
|
154
|
-
host: typeof host === "string" ? host : "127.0.0.1"
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function siteOptions(cwd, args) {
|
|
158
|
-
const [folder, out, ...more] = args.positional;
|
|
159
|
-
if (folder === void 0 || out === void 0 || more.length > 0)
|
|
160
|
-
throw wrongArgument("aula site takes a playlist folder and an output folder", "run `aula help` for the usage");
|
|
161
|
-
const title = args.values.get("--title");
|
|
162
|
-
const base = args.values.get("--base");
|
|
163
|
-
if (typeof base === "string" && !(base.startsWith("/") && base.endsWith("/")))
|
|
164
|
-
throw wrongArgument(`--base ${base} must start and end with /`, "for example --base /aula/");
|
|
165
|
-
const root = path.resolve(cwd, folder);
|
|
166
|
-
return {
|
|
167
|
-
folder: root,
|
|
168
|
-
out: path.resolve(cwd, out),
|
|
169
|
-
title: typeof title === "string" ? title : path.basename(root),
|
|
170
|
-
base: typeof base === "string" ? base : null
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
var optionsOf = (command) => OPTIONS[command] ?? [];
|
|
174
|
-
export {
|
|
175
|
-
USAGE,
|
|
176
|
-
folderArgs,
|
|
177
|
-
isHelp,
|
|
178
|
-
optionsOf,
|
|
179
|
-
parse,
|
|
180
|
-
run,
|
|
181
|
-
siteOptions,
|
|
182
|
-
webOptions
|
|
183
|
-
};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"../rolldown-runtime-BLXQ4ufn.js";import{a as n,d as r,f as i,g as a,i as o,l as s,m as c,n as l,o as u,p as d,u as f}from"../protocol-Dc79M9p3.js";import{S as p,g as m,v as h,y as g}from"../src-DWqZcp-P.js";var _=44,v=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,y=new Uint8Array(64),b=new Uint8Array(128);for(let e=0;e<v.length;e++){let t=v.charCodeAt(e);y[e]=t,b[t]=e}function x(e){let t=0,n=0,r=0;do r=b[e.next()],t|=(r&31)<<n,n+=5;while(r&32);return t}function S(e){return e&1?-0x80000000|-(e>>>1):e>>>1}function C(e,t){return e.pos>=t?!1:e.peek()!==_}var w=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){let{buffer:t,pos:n}=this,r=t.indexOf(e,n);return r===-1?t.length:r}};function ee(e){let{length:t}=e,n=new w(e),r=[],i=0,a=0,o=0,s=0,c=0;do{let e=n.indexOf(`;`),t=[],l=!0,u=0;for(i=0;n.pos<e;){let r;i+=S(x(n)),i<u&&(l=!1),u=i,C(n,e)?(a+=S(x(n)),o+=S(x(n)),s+=S(x(n)),C(n,e)?(c+=S(x(n)),r=[i,a,o,s,c]):r=[i,a,o,s]):r=[i],t.push(r),n.pos++}l||te(t),r.push(t),n.pos=e+1}while(n.pos<=t);return r}function te(e){e.sort(T)}function T(e,t){return e[0]-t[0]}var E=e(t(((e,t,n)=>{var r;(function(n,i){typeof e==`object`&&t!==void 0?t.exports=i():typeof r==`function`&&r.amd?r(i):(n=typeof globalThis<`u`?globalThis:n||self,n.resolveURI=i())})(n,(function(){let e=/^[\w+.-]+:\/\//,t=/^([\w+.-]+:)\/\/([^@/#?]*@)?(\[[^\]]+\]|[^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,n=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function r(t){return e.test(t)}function i(e){return e.startsWith(`//`)}function a(e){return e.startsWith(`/`)}function o(e){return e.startsWith(`file:`)}function s(e){return/^[.?#]/.test(e)}function c(e){let n=t.exec(e);return u(n[1],n[2]||``,n[3],n[4]||``,n[5]||`/`,n[6]||``,n[7]||``)}function l(e){let t=n.exec(e),r=t[2];return u(`file:`,``,t[1]||``,``,a(r)?r:`/`+r,t[3]||``,t[4]||``)}function u(e,t,n,r,i,a,o){return{scheme:e,user:t,host:n,port:r,path:i,query:a,hash:o,type:7}}function d(e){if(i(e)){let t=c(`http:`+e);return t.scheme=``,t.type=6,t}if(a(e)){let t=c(`http://foo.com`+e);return t.scheme=``,t.host=``,t.type=5,t}if(o(e))return l(e);if(r(e))return c(e);let t=c(`http://foo.com/`+e);return t.scheme=``,t.host=``,t.type=e?e.startsWith(`?`)?3:e.startsWith(`#`)?2:4:1,t}function f(e){if(e.endsWith(`/..`))return e;let t=e.lastIndexOf(`/`);return e.slice(0,t+1)}function p(e,t){m(t,t.type),e.path=e.path===`/`?t.path:f(t.path)+e.path}function m(e,t){let n=t<=4,r=e.path.split(`/`),i=1,a=0,o=!1;for(let e=1;e<r.length;e++){let t=r[e];t?(o=!1,t!==`.`&&(t===`..`?a?(o=!0,a--,i--):n&&(r[i++]=t):(r[i++]=t,a++))):o=!0}let s=``;for(let e=1;e<i;e++)s+=`/`+r[e];(!s||o&&!s.endsWith(`/..`))&&(s+=`/`),e.path=s}function h(e,t){if(!e&&!t)return``;let n=d(e),r=n.type;if(t&&r!==7){let e=d(t),i=e.type;switch(r){case 1:n.hash=e.hash;case 2:n.query=e.query;case 3:case 4:p(n,e);case 5:n.user=e.user,n.host=e.host,n.port=e.port;case 6:n.scheme=e.scheme}i>r&&(r=i)}m(n,r);let i=n.query+n.hash;switch(r){case 2:case 3:return i;case 4:{let r=n.path.slice(1);return r?s(t||e)&&!s(r)?`./`+r+i:r+i:i||`.`}case 5:return n.path+i;default:return n.scheme+`//`+n.user+n.host+n.port+n.path+i}}return h}))}))(),1);function D(e){if(!e)return``;let t=e.lastIndexOf(`/`);return e.slice(0,t+1)}function O(e,t){let n=D(e),r=t?t+`/`:``;return e=>(0,E.default)(r+(e||``),n)}var k=0,ne=1,re=2,ie=3,A=4;function j(e,t){let n=M(e,0);if(n===e.length)return e;t||(e=e.slice());for(let r=n;r<e.length;r=M(e,r+1))e[r]=P(e[r],t);return e}function M(e,t){for(let n=t;n<e.length;n++)if(!N(e[n]))return n;return e.length}function N(e){for(let t=1;t<e.length;t++)if(e[t][k]<e[t-1][k])return!1;return!0}function P(e,t){return t||(e=e.slice()),e.sort(F)}function F(e,t){return e[k]-t[k]}var I=!1;function L(e,t,n,r){for(;n<=r;){let i=n+(r-n>>1),a=e[i][k]-t;if(a===0)return I=!0,i;a<0?n=i+1:r=i-1}return I=!1,n-1}function R(e,t,n){for(let r=n+1;r<e.length&&e[r][k]===t;n=r++);return n}function z(e,t,n){for(let r=n-1;r>=0&&e[r][k]===t;n=r--);return n}function B(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function V(e,t,n,r){let{lastKey:i,lastNeedle:a,lastIndex:o}=n,s=0,c=e.length-1;if(r===i){if(t===a)return I=o!==-1&&e[o][k]===t,o;t>=a?s=o===-1?0:o:c=o}return n.lastKey=r,n.lastNeedle=t,n.lastIndex=L(e,t,s,c)}function H(e){return typeof e==`string`?JSON.parse(e):e}var U="`line` must be greater than 0 (lines start at line 1)",W="`column` must be greater than or equal to 0 (columns start at column 0)",ae=class{constructor(e,t){let n=typeof e==`string`;if(!n&&e._decodedMemo)return e;let r=H(e),{version:i,file:a,names:o,sourceRoot:s,sources:c,sourcesContent:l}=r;this.version=i,this.file=a,this.names=o||[],this.sourceRoot=s,this.sources=c,this.sourcesContent=l,this.ignoreList=r.ignoreList||r.x_google_ignoreList||void 0;let u=O(t,s);this.resolvedSources=c.map(u);let{mappings:d}=r;if(typeof d==`string`)this._encoded=d,this._decoded=void 0;else if(Array.isArray(d))this._encoded=void 0,this._decoded=j(d,n);else if(r.sections)throw Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);else throw Error(`invalid source map: ${JSON.stringify(r)}`);this._decodedMemo=B(),this._bySources=void 0,this._bySourceMemos=void 0}};function G(e){return e}function K(e){var t;return(t=G(e))._decoded||(t._decoded=ee(G(e)._encoded))}function q(e,t){let{line:n,column:r,bias:i}=t;if(n--,n<0)throw Error(U);if(r<0)throw Error(W);let a=K(e);if(n>=a.length)return J(null,null,null,null);let o=a[n],s=oe(o,G(e)._decodedMemo,n,r,i||1);if(s===-1)return J(null,null,null,null);let c=o[s];if(c.length===1)return J(null,null,null,null);let{names:l,resolvedSources:u}=e;return J(u[c[ne]],c[re]+1,c[ie],c.length===5?l[c[A]]:null)}function J(e,t,n,r){return{source:e,line:t,column:n,name:r}}function oe(e,t,n,r,i){let a=V(e,r,t,n);return I?a=(i===-1?R:z)(e,r,a):i===-1&&a++,a===-1||a===e.length?-1:a}var Y=new Map;function se(e,t,n){Y.set(e,{map:new ae(t),prefix:n})}function ce(e,t,n){let r=Y.get(e);if(!r)return{file:e,line:t,column:n};let i=q(r.map,{line:t,column:n-1});return i.source===null||i.line===null||i.column===null?{file:e,line:t,column:n}:{file:i.source.startsWith(r.prefix)?i.source.slice(r.prefix.length):i.source,line:i.line,column:i.column+1}}var X=a(ce);function le(e){let t=0,r=new Map;e.then(e=>{e.addEventListener(`message`,t=>{let i=t.data;if(i.kind===`error`)throw e.close(),new n(`the narrator stopped: ${i.message}`,i.stack);let a=r.get(i.id);r.delete(i.id),a?.(i)}),e.start()});let i=async(n,i)=>{let a=await e;return new Promise(e=>{let o=t++;r.set(o,e),a.postMessage({id:o,kind:n,words:i})})};return{speak:async e=>{let t=await i(`speak`,e);if(t.kind!==`speech`)throw Error(`the narrator answered ${t.kind} to a speech`);return{samples:t.samples,sampleRate:t.sampleRate,words:t.words}},time:async e=>{let t=await i(`time`,e);if(t.kind!==`timing`)throw Error(`the narrator answered ${t.kind} to a clock`);return{samples:t.samples,sampleRate:t.sampleRate,words:t.words}}}}function ue(e){let t=0,n=0,a=!1,c=new Map,u=n=>{let r=r=>{let i=t++,{promise:a,resolve:o}=Promise.withResolvers();return c.set(i,o),e.post({kind:`files`,id:i,tree:n,question:r},[]),a};return{bundle:async()=>{let e=await r({kind:`bundle`});if(e.kind!==`bundle`)throw Error(`the page answered ${e.kind} to a question of the bundle`);return e.result},name:async()=>{let e=await r({kind:`name`});if(e.kind!==`name`)throw Error(`the page answered ${e.kind} to a question of the name`);return e.name},read:async e=>{let t=await r({kind:`read`,path:e});if(t.kind!==`read`)throw Error(`the page answered ${t.kind} to a read of ${e}`);return t.text},bytes:async e=>{let t=await r({kind:`bytes`,path:e});if(t.kind!==`bytes`)throw Error(`the page answered ${t.kind} to a read of the bytes of ${e}`);return t.bytes},list:async e=>{let t=await r({kind:`list`,folder:e});if(t.kind!==`list`)throw Error(`the page answered ${t.kind} to a list of ${e}`);return t.names}}},p=async()=>{let t=u(n++),o=new Map,s=new Set,c=e=>{let t=o.get(e);return t===void 0&&s.add(e),t?{size:t.length,read:()=>t}:void 0},[l]=await Promise.all([t.bundle(),g().then(async()=>{await h(),e.post({kind:`stage`,stage:`engine`},[])})]),f;if(l!==null){if(l._tag===`Left`)return e.post({kind:`stage`,stage:`project`},[]),l;f=await r(l.right,d(X,c),e.modules,e.player)}else{let n=await t.name();if(n===null)return e.post({kind:`stage`,stage:`project`},[]),{_tag:`Right`,right:[]};let r={name:()=>Promise.resolve(n),read:t.read,list:t.list},a=await e.bundler();f=await i(r,d(X,c),e.modules,a,e.player)}if(e.post({kind:`stage`,stage:`project`},[]),f._tag===`Left`)return f;a||(a=!0,e.post({kind:`narrator`},[]));let p=async e=>{for(;;){s.clear();let n=e(),r=[...s].filter(e=>!o.has(e));if(r.length===0)return n;await Promise.all(r.map(async e=>o.set(e,await t.bytes(e))))}};return{_tag:`Right`,right:f.right.map(e=>{let t=new Set;return{...e,readScript:async()=>(await m(),p(()=>e.script())),readChapter:async n=>{t.has(n)||(await m(),await p(()=>e.walk?.(n)),t.add(n))}}})}},_=Promise.withResolvers(),v=f(s.create({voice:le(_.promise),workspace:{projects:p}})),y=[],b=(t,{chapters:n,...r})=>{let i=[],a=[],s=[];n.forEach((e,t)=>{let n=y[t];if(e===n)return;if(!e){i.push([t,void 0]);return}let r=n?.cues.map(e=>e.samples)??[];if(e.animation!==n?.animation){let{animation:n,cues:a,...s}=e,c=a.map(e=>{let t=e.samples?r.indexOf(e.samples):-1;return t===-1?null:t}),l=a.map(({at:e,length:t},n)=>({at:e,length:t,keep:c[n]??null}));i.push([t,{...s,lottie:o(n),cues:l}]),r=c.map(e=>e===null?void 0:r[e])}e.cues.forEach((e,n)=>{if(!e.samples||e.samples===r[n])return;let i=e.samples.slice();s.push(i.buffer),a.push({chapter:t,cue:n,samples:i})})}),y=n;let c={building:r.building,timeline:r.timeline,duration:r.duration,errors:l(r.errors)};e.post({kind:`state`,watch:t,state:c,count:n.length,drawings:i,sounds:a},s)};return t=>{switch(t.kind){case`list`:v.build.list().then(n=>{let r=n._tag===`Left`?{_tag:`Left`,left:l(n.left)}:n;e.post({kind:`listed`,id:t.id,videos:r},[])});return;case`watch`:y=[],v.build.watch(t.name,{changed:e=>{b(t.watch,e)}});return;case`seek`:v.build.seek(t.name,t.place);return;case`halt`:v.halt();return;case`refresh`:v.refresh(t.place);return;case`files`:{let e=c.get(t.id);c.delete(t.id),e?.(t.answer);return}case`narrator`:_.resolve(t.port);return}}}var Z=(e,t=[])=>{self.postMessage(e,{transfer:t})},Q=e=>{let t=u(e,X);Z({kind:`error`,message:t.message,stack:t.stack.map(e=>` ${e}`).join(`
|
|
2
|
-
`)})};self.addEventListener(`error`,e=>{e.preventDefault(),Q(e.error??Error(e.message))}),self.addEventListener(`unhandledrejection`,e=>{e.preventDefault(),Q(e.reason)});var de={"@beff/aula":new URL(`./aula.js`,import.meta.url).href,"@beff/aula-method":new URL(`./aula-method.js`,import.meta.url).href},fe={load:async({code:e,map:t})=>{let n=URL.createObjectURL(new Blob([e],{type:`text/javascript`}));return se(n,t,c),{url:n,exports:await import(n)}}},$=null;function pe(){return $??=(async()=>{let t=performance.now(),[n,r]=await Promise.all([p(()=>import(`../browser-sNTR4ahh.js`).then(t=>e(t.default,1)),[]),p(()=>import(`../esbuild-D6hmBtXM.js`),[])]);return await n.initialize({wasmURL:r.default,worker:!1}),console.log(`aula: esbuild loaded in ${((performance.now()-t)/1e3).toFixed(1)} s`),n})(),$}var me=ue({post:Z,bundler:pe,modules:fe,player:de});self.addEventListener(`message`,e=>{me(e.data)});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import{_ as e,a as t,b as n,d as r,i,n as a,r as o,s,t as c,v as l,y as u}from"./src-DWqZcp-P.js";function d(n,r){let i=n.titleParts??[{text:n.title}];return e.narrationScript([...i],t(n.lexicon??{}),[...r])}function f(t,n,r){return e.chapterNarration([...t],[...n],r)}function p(t){return e.estimateNarration([...t])}function m(t){return e.renderDiagnostic(t)}var h=`.!?…`,g=`,;:`,ee=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?<=[${ee(h)}])\\s+`),RegExp(`(?<=[${ee(g)}])\\s+`);var _=`cdf77eccfdc734e7a4ee74708e9be9fb3b9d14b0134ce84e5794c27ef1c76706`;`${{path:`aula-voice-${_.slice(0,12)}.avw`,bytes:21474688,sha256:_}.path}`;var te=e=>Float64Array.from(e,e=>e.start);function ne(e,t){if(t.length===0)return e;let n=new Float32Array(e.length+t.reduce((e,t)=>e+t.samples,0)),r=0,i=0;for(let a of t.toSorted((e,t)=>e.sample-t.sample)){let t=Math.min(a.sample,e.length);n.set(e.subarray(r,t),i),i+=t-r+a.samples,r=t}return n.set(e.subarray(r),i),n}function re(e,t){let n=t.toSorted((e,t)=>e.sample-t.sample);return e.cues.map(e=>{let t=e.speechStartFrame,r=e.endFrame,i=n.filter(e=>e.sample<=t).reduce((e,t)=>e+t.samples,0),a=n.filter(e=>e.sample>t&&e.sample<r).map(e=>({sample:e.sample-t,samples:e.samples})),o=r-t+a.reduce((e,t)=>e+t.samples,0);return{at:t+i,length:o,waits:a}})}function ie(e,t){let n=e.samples.length+t.waits.reduce((e,t)=>e+t.samples,0);if(n!==t.length)throw Error(`a speech of ${String(n)} samples with its waits, at a place of ${String(t.length)}`);return ne(new Float32Array(e.samples),t.waits)}function ae(e,t){let n=t[0]?.sampleRate??0;if(t.some(e=>e.sampleRate!==n))throw Error(`the narrator changed its sample rate`);return f(e,t.map(e=>e.words?{samples:e.samples,starts:te(e.words)}:{samples:e.samples}),n)}function oe(e){let t=e.trim(),n=``,r;if(t.startsWith(`at `)){let e=t.slice(3),i=/^(.*) \((.*)\)$/.exec(e);n=i?.[1]??``,r=i?.[2]??e}else{let e=t.lastIndexOf(`@`,t.search(/:\d+:\d+$/));if(e<0)return null;n=t.slice(0,e),r=t.slice(e+1)}let i=/^(.*):(\d+):(\d+)$/.exec(r);return i?.[1]===void 0||i[2]===void 0||i[3]===void 0?null:{functionName:n.replace(/^(async |new )/,``),url:i[1],line:Number(i[2]),column:Number(i[3])}}var se=e=>t=>{let n=[];for(let r of(t.stack??``).split(`
|
|
2
|
-
`)){let t=oe(r);if(!t)continue;let i=e(t.url,t.line,t.column);n.push({function:t.functionName,file:i.file,line:i.line,col:i.column})}return n},ce=e=>{if(typeof e==`boolean`)return null;let t=e.anyOf==null?e.oneOf==null?null:`oneOf`:`anyOf`;if(t==null)return null;let n=e[t];if(n==null)return null;let r=n.filter(e=>!le(e));if(r.length===n.length||r.length===0)return null;let i=r.map(e=>ce(e)??e);return i.length===1?i[0]:{...e,[t]:i}},le=e=>typeof e!=`boolean`&&e.type===`null`,ue=e=>typeof e==`string`?`"${e}"`:typeof e==`number`||typeof e==`boolean`?`${e}`:typeof e==`bigint`?`${e}n`:e===null?`null`:Array.isArray(e)?`Array`:typeof e==`object`?`Object`:JSON.stringify(e),de=e=>{if(e.length===0)return``;let t=e[0];for(let n of e.slice(1))n.startsWith(`[`)?t+=n:t+=`.`+n;return t},fe=(e,t)=>{let n=[...e,...t];return n.length>0?`(${de(n)})`:``},v=e=>e.filter(e=>e.length>0).join(` `),pe=(e,t,n)=>v([fe(t,e.path),[e.message,n?`received: ${ue(e.received)}`:``].filter(e=>e.length>0).join(`, `)]),me=(e,t)=>{let n=fe(t,e.path),r=y(e.errors,[],!1);return v([n,[`Failed to decode one of (${r.length>5?r.slice(0,5).join(` OR `)+` and more...`:r.join(` | `)})`,`received: ${ue(e.received)}`].filter(e=>e.length>0).join(`, `)])},y=(e,t,n)=>e.map(e=>`isUnionError`in e?me(e,t):pe(e,t,n)),he=(e,t=[])=>y(e,t,!0).map((e,t,n)=>n.length==1?v([e]):v([`#${t}`,e])).join(` | `),b=Object.getPrototypeOf({});function ge(e){function t(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}function n(e){let t=0,n=e.length,r=Array(n);for(;t<n;++t)r[t]=p(e[t]);return r}function r(e){let n={};if(c&&Object.getPrototypeOf(e)!==b)return c(e);let r=s(e),i,a,o;for(i=0,a=r.length;i<a;++i)o=r[i],t(n,o,p(e[o]));return n}function i(e,t){let n=e.length,r=t.length,i=0,a=Array(n+r);for(;i<n;++i)a[i]=p(e[i]);for(i=0;i<r;++i)a[i+n]=p(t[i]);return a}let a=Object.prototype.propertyIsEnumerable;function o(e){let t=Object.keys(e),n=Object.getOwnPropertySymbols(e);for(let r=0,i=n.length;r<i;++r)a.call(e,n[r])&&t.push(n[r]);return t}let s=e?.symbols?o:Object.keys,c=typeof e?.cloneProtoObject==`function`?e.cloneProtoObject:void 0;function l(e){return typeof e==`object`&&!!e&&!(e instanceof RegExp)&&!(e instanceof Date)&&!(e instanceof Map)&&!(e instanceof Set)&&!ArrayBuffer.isView(e)}function u(e){return typeof e!=`object`||!e}let d=typeof Buffer<`u`?e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e)||e instanceof Buffer:e=>typeof e!=`object`||!e||e instanceof RegExp||e instanceof Date||ArrayBuffer.isView(e),f=e&&typeof e.mergeArray==`function`?e.mergeArray({clone:p,deepmerge:h,getKeys:s,isMergeableObject:l}):i;function p(e){return l(e)?Array.isArray(e)?n(e):r(e):e}function m(e,n){let r={},i=s(e),a=s(n),o,u,d;for(o=0,u=i.length;o<u;++o)d=i[o],a.indexOf(d)===-1&&t(r,d,p(e[d]));for(o=0,u=a.length;o<u;++o)d=a[o],i.indexOf(d)===-1?t(r,d,p(n[d])):c&&l(n[d])&&Object.getPrototypeOf(n[d])!==b?t(r,d,c(n[d])):t(r,d,h(e[d],n[d]));return r}function h(e,t){let n=Array.isArray(t),r=Array.isArray(e);return u(t)||t instanceof Map||t instanceof Set?t:d(e)?p(t):n&&r?f(e,t):n===r?m(e,t):p(t)}function g(){switch(arguments.length){case 0:return{};case 1:return p(arguments[0]);case 2:return h(arguments[0],arguments[1])}let e;for(let t=0,n=arguments.length;t<n;++t)e=h(e,arguments[t]);return e}return g}function _e(e){let t=e.deepmerge,n=e.clone;return function(e,r){let i=0,a=r.length,o=Math.max(e.length,r.length),s=Array(o);for(i=0;i<o;++i)i<a?s[i]=t(e[i],r[i]):s[i]=n(e[i]);return s}}ge({mergeArray:_e});function x(e,t,n){return[{message:t,path:[...e.path],received:n}]}function ve(e,t){let n=[];for(let r=0;r<=e.length;r++){n.push([r]);for(let i=1;i<=t.length;i++)n[r][i]=r===0?i:Math.min(n[r-1][i]+1,n[r][i-1]+1,n[r-1][i-1]+(e[r-1]===t[i-1]?0:1)),r>1&&i>1&&e[r-1]===t[i-2]&&e[r-2]===t[i-1]&&(n[r][i]=Math.min(n[r][i],n[r-2][i-2]+1))}return n[e.length][t.length]}function ye(e,t,n,r){if(n==null){C(e,t);let n=x(e,`extra property`,r);return w(e),n}let i=null,a=Math.max(1,Math.floor(t.length/3));for(let e of n){let n=ve(t,e);n<=a&&n<t.length&&(i==null||n<a)&&(i=e,a=n)}let o=i==null?``:` Did you mean ${JSON.stringify(i)}?`,s=n.length===0?`none`:n.map(e=>JSON.stringify(e)).join(`, `);C(e,t);let c=x(e,`extra property.${o} Allowed: ${s}`,r);return w(e),c}function S(e,t,n,r,i){r.validate(e,i)||(C(e,n),t.push(...r.reportDecodeError(e,i)),w(e))}function C(e,t){e.path.push(t)}function w(e){e.path.pop()}function be(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function xe(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function T(e,t){return e?.description==null?t:{...t,description:e.description}}function E(e){let t=e.replace(/\*\//g,`* /`).split(`
|
|
3
|
-
`);return t.length===1?`/** ${t[0]} */`:[`/**`,...t.map(e=>` * ${e}`),` */`].join(`
|
|
4
|
-
`)}function D(e,t){return t==null?{typeExpr:e}:{typeExpr:e,docText:t}}var O=class{metadata;constructor(e){this.metadata=e}describe(e){return D(this.describeTypeExpr(e),this.metadata?.description)}describeChildren(){return[]}};function k(e,t){return t.describe(e).typeExpr}function Se(e){return e.docText==null?e.typeExpr:`${E(e.docText)}\n${e.typeExpr}`}function A(e,t){let n=`type ${e} = ${t.typeExpr};`;return t.docText==null?n:`${E(t.docText)}\n${n}`}function Ce(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)||/^(0|[1-9][0-9]*)$/.test(e)?e:JSON.stringify(e)}function j(e,t,n){let r=n instanceof P?`?`:``,i=n.describe(e);return{docText:i.docText,member:`${t}${r}: ${i.typeExpr}`}}function we(e,t,n){return j(e,`[K in ${k(e,t)}]`,n)}function Te(e){let t=`${e.member};`;return e.docText==null?t:`${E(e.docText)}\n${t}`}function M(e,t){if(e instanceof L)e.collectDescribeRefs(t);else for(let n of e.describeChildren())M(n,t)}var Ee=class extends O{typeName;constructor(e,t){super(e),this.typeName=t}describeTypeExpr(e){return this.typeName}schema(e){return T(this.metadata,{type:this.typeName})}validate(e,t){return typeof t===this.typeName}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return x(e,`expected `+this.typeName,t)}},N=class extends O{constructor(e){super(e)}describeTypeExpr(e){return`any`}schema(e){return T(this.metadata,{})}validate(e,t){return!0}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return x(e,`expected any`,t)}},De=class extends O{constructor(e){super(e)}describeTypeExpr(e){return`never`}schema(e){return T(this.metadata,{anyOf:[]})}validate(e,t){return!1}parseAfterValidation(e,t){throw Error(`unreachable`)}reportDecodeError(e,t){return x(e,`expected never`,t)}},Oe=class extends O{itemParser;constructor(e,t){super(e),this.itemParser=t}schema(e){C(e,`[]`);let t=this.itemParser.schema(e);return w(e),T(this.metadata,{type:`array`,items:t})}validate(e,t){if(Array.isArray(t)){for(let n=0;n<t.length;n++){let r=t[n];if(!this.itemParser.validate(e,r))return!1}return!0}return!1}parseAfterValidation(e,t){return t.map(t=>this.itemParser.parseAfterValidation(e,t))}reportDecodeError(e,t){if(!Array.isArray(t))return x(e,`expected array`,t);let n=[];for(let r=0;r<t.length;r++)S(e,n,`[${r}]`,this.itemParser,t[r]);return n}describeTypeExpr(e){return`Array<${k(e,this.itemParser)}>`}describeChildren(){return[this.itemParser]}},P=class{t;constructor(e){this.t=e}schema(e){return{anyOf:[this.t.schema(e),{type:`null`}]}}validate(e,t){return t==null||this.t.validate(e,t)}parseAfterValidation(e,t){return t==null?t:this.t.parseAfterValidation(e,t)}reportDecodeError(e,t){return this.t.reportDecodeError(e,t)}describe(e){return this.t.describe(e)}describeChildren(){return[this.t]}},F=Object.prototype.hasOwnProperty;function I(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var ke=class extends O{properties;indexedPropertiesParser;constructor(e,t,n){super(e),this.properties=t,this.indexedPropertiesParser=n}describeTypeExpr(e){let t=Object.keys(this.properties).sort().map(t=>{let n=this.properties[t];return j(e,Ce(t),n)}),n=this.indexedPropertiesParser.map(({key:t,value:n})=>we(e,t,n)),r=[...t,...n];return r.some(e=>e.docText!=null)?r.length===0?`{}`:`{\n${r.map(Te).join(`
|
|
5
|
-
`)}\n}`:`{ ${r.map(e=>e.member).join(`, `)} }`}describeChildren(){return[...Object.values(this.properties),...this.indexedPropertiesParser.flatMap(({key:e,value:t})=>[e,t])]}schema(e){let t={},n=new Set;for(let r in this.properties){C(e,r);let i=this.properties[r].schema(e),a=ce(i);a==null?t[r]=i:(t[r]=a,n.add(r)),w(e)}let r=Object.keys(this.properties).filter(e=>!n.has(e)),i={type:`object`,properties:t,...r.length>0?{required:r}:{}},a=this.indexedPropertiesParser.map(({key:t,value:n})=>{C(e,`[key]`);let r=t.schema(e);w(e),C(e,`[value]`);let i=n.schema(e);return w(e),{type:`object`,additionalProperties:i,propertyNames:r}});if(a.length===0)return T(this.metadata,{...i,additionalProperties:!1});if(Object.keys(t).length===0&&a.length===1){let e=this.indexedPropertiesParser[0].value;return e instanceof De?T(this.metadata,{type:`object`,additionalProperties:!1}):e instanceof N?T(this.metadata,{...a[0],additionalProperties:!0}):T(this.metadata,a[0])}return T(this.metadata,{allOf:[i,...a]})}validate(e,t){if(typeof t==`object`&&!Array.isArray(t)&&t!==null){let n=Object.keys(this.properties);for(let r of n)if(!this.properties[r].validate(e,t[r]))return!1;if(this.indexedPropertiesParser.length>0){let n=Object.keys(t).filter(e=>!F.call(this.properties,e));for(let r of n){let n=!1;for(let i of this.indexedPropertiesParser){if(!i.key.validate(e,r))continue;let a=t[r];if(i.value.validate(e,a)){n=!0;break}}if(!n&&!this.leavesKeyToIntersection(e,t,r))return!1}}else if(e.disallowExtraProperties&&e.intersectionInput!==t&&Object.keys(t).filter(e=>!F.call(this.properties,e)).length>0)return!1;return!0}return!1}parseAfterValidation(e,t){let n={},r=Object.keys(t);if(e.objectKeyOrder===`input`)for(let i of r)if(F.call(this.properties,i))I(n,i,this.properties[i].parseAfterValidation(e,t[i]));else for(let r of this.indexedPropertiesParser){let a=t[i];if(r.key.validate(e,i)&&r.value.validate(e,a)){let t=r.value.parseAfterValidation(e,a);I(n,r.key.parseAfterValidation(e,i),t)}}else{let i=Object.keys(this.properties).sort();for(let r of i){if(!F.call(t,r))continue;let i=t[r];I(n,r,this.properties[r].parseAfterValidation(e,i))}if(this.indexedPropertiesParser.length>0){let i=r.filter(e=>!F.call(this.properties,e)).sort();for(let r of i){let i=t[r];for(let t of this.indexedPropertiesParser)if(t.key.validate(e,r)&&t.value.validate(e,i)){let a=t.value.parseAfterValidation(e,i);I(n,t.key.parseAfterValidation(e,r),a)}}}}return n}reportDecodeError(e,t){if(typeof t!=`object`||Array.isArray(t)||t===null)return x(e,`expected object`,t);let n=[],r=Object.keys(this.properties);for(let i of r)S(e,n,i,this.properties[i],t[i]);if(this.indexedPropertiesParser.length>0){let r=Object.keys(t).filter(e=>!F.call(this.properties,e));for(let i of r)if(!this.leavesKeyToIntersection(e,t,i))for(let r of this.indexedPropertiesParser){let a=r.key.validate(e,i),o=r.value.validate(e,t[i]);if(!(a&&o)){if(C(e,i),!a){let t=r.key.reportDecodeError(e,i);n.push(...t)}if(!o){let a=r.value.reportDecodeError(e,t[i]);n.push(...a)}w(e)}}}else if(e.disallowExtraProperties&&e.intersectionInput!==t){let n=Object.keys(t).filter(e=>!F.call(this.properties,e));if(n.length>0)return n.flatMap(n=>ye(e,n,r,t[n]))}return n}allowedKeys(){return this.indexedPropertiesParser.length>0?null:Object.keys(this.properties)}leavesKeyToIntersection(e,t,n){return e.intersectionInput===t&&!this.indexedPropertiesParser.some(t=>t.key.validate(e,n))}},L=class extends O{refName;namedRuntypes;constructor(e,t,n){super(e),this.refName=t,this.namedRuntypes=n}getNamedRuntypes(){return this.namedRuntypes}describeTypeExpr(e){return this.refName}collectDescribeRefs(e){let t=this.refName;e.refCounts[t]=(e.refCounts[t]||0)+1,e.activeRefs.has(t)||e.visitedRefs.has(t)||(e.visitedRefs.add(t),e.activeRefs.add(t),M(this.getNamedRuntypes()[t],e),e.activeRefs.delete(t))}describe(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName],r=()=>D(t,this.metadata?.description);if(e.refCounts[t]>1)return e.activeRefs.has(t)||(e.definitions[t]??(e.activeRefs.add(t),e.definitions[t]=n.describe(e),e.activeRefs.delete(t))),r();let i=n.describe(e);return this.metadata?.description==null?i:D(i.typeExpr,this.metadata.description)}schema(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName];if(e.mode===`contextual`){let r=e.printingContext;if(r==null)throw Error(`INTERNAL ERROR: Missing SchemaPrintingContext`);if(!r.hasDefinition(t)&&!r.isDefinitionInProgress(t)){r.markDefinitionInProgress(t);let i=(r.getNamedTypeSchemaOverride(t)??n).schema(e);r.storeDefinition(t,i)}return T(this.metadata,{$ref:r.getRef(t)})}if(e.seen[t])return T(this.metadata,{});e.seen[t]=!0;var r=n.schema(e);return delete e.seen[t],T(this.metadata,r)}validate(e,t){return this.getNamedRuntypes()[this.refName].validate(e,t)}parseAfterValidation(e,t){return this.getNamedRuntypes()[this.refName].parseAfterValidation(e,t)}reportDecodeError(e,t){return this.getNamedRuntypes()[this.refName].reportDecodeError(e,t)}},Ae=class{_runtype;name;hideTypeNameInDescribe;constructor(e,t,n){this._runtype=e,this.name=t,this.hideTypeNameInDescribe=n}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;let r=he(n.errors,[]);throw Error(`Failed to parse ${this.name} - ${r}`)}safeParse(e,t){let n=t?.disallowExtraProperties??!1,r=t?.objectKeyOrder??`input`;if(this.validate(e,t)){let t={disallowExtraProperties:n,objectKeyOrder:r};return{success:!0,data:this._runtype.parseAfterValidation(t,e)}}let i={path:[],disallowExtraProperties:n};return{success:!1,errors:this._runtype.reportDecodeError(i,e).slice(0,10)}}validate(e,t){let n={disallowExtraProperties:t?.disallowExtraProperties??!1},r=this._runtype.validate(n,e);if(typeof r!=`boolean`)throw Error(`INTERNAL ERROR: Expected boolean`);return r}schema(){return this._runtype.schema({path:[],seen:{},mode:`flat`})}schemaWithContext(e){let t={path:[],seen:{},mode:`contextual`,printingContext:e};return this._runtype.schema(t)}describe(){let e={activeRefs:new Set,definitions:{},refCounts:{},visitedRefs:new Set};M(this._runtype,e);let t=this._runtype.describe(e),n=Object.keys(e.definitions).sort().map(t=>[t,e.definitions[t]]).map(([e,t])=>A(e,t)).join(`
|
|
6
|
-
|
|
7
|
-
`);return this.hideTypeNameInDescribe?[n,Se(t)].filter(e=>e!=null&&e.length>0).join(`
|
|
8
|
-
|
|
9
|
-
`):[n,A(`Codec${this.name}`,t)].filter(e=>e!=null&&e.length>0).join(`
|
|
10
|
-
|
|
11
|
-
`)}},je=(e,t,n)=>new Ae(e,t,n),Me=(e,t)=>{let n=t?.stringFormats??{};for(let t of e.requiredStringFormats)if(n[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(n).forEach(t=>{let r=n[t];be(e.stringFormatters,t,r)});let r=t?.numberFormats??{};for(let t of e.requiredNumberFormats)if(r[t]==null)throw Error(`Missing custom format ${t}`);Object.keys(r).forEach(t=>{let n=r[t];xe(e.numberFormatters,t,n)});let i={};for(let t of Object.keys(e.parsers))i[t]=je(e.parsers[t],t,!1);return i},Ne=[],Pe=[],Fe={},Ie={},Le={},Re=new L(void 0,`PackageJson`,Fe),ze=new N(void 0),R=new Ee(void 0,`string`),Be=new Oe(void 0,R),Ve=new ke({description:`The part of a package.json that aula reads: how a package names its module and its
|
|
12
|
-
workspace packages, and its version when the CLI compares it to the project's.`},{exports:new P(ze),main:new P(R),module:new P(R),name:new P(R),version:new P(R),workspaces:new P(Be)},[]);Object.assign(Fe,{PackageJson:Ve});var He={PackageJson:Re},Ue={buildParsers:e=>Me({parsers:He,stringFormatters:Ie,numberFormatters:Le,requiredStringFormats:Ne,requiredNumberFormats:Pe},e)}.buildParsers();function We(e,t){let n=[...e];return{read:t,list:e=>{let t=e===``?``:`${e}/`,r=new Set;for(let e of n){if(!e.startsWith(t))continue;let[n,...i]=e.slice(t.length).split(`/`);n!==void 0&&i.length>0&&r.add(n)}return Promise.resolve([...r].toSorted())}}}var z=Object.fromEntries([`@beff/aula`,`@beff/aula-method`].map(e=>[e,`aula-provide:${e}`])),B=`aula-projects.ts`;function Ge(e,t){let n=e;for(let[e,r]of Object.entries(z)){let i=t[e];i!==void 0&&(n=n.replaceAll(JSON.stringify(r),JSON.stringify(i)))}return n}var V=`tree:`;function H(e){let t=e.lastIndexOf(`/`);return t<0?``:e.slice(0,t)}function U(e,t){let n=e===``?[]:e.split(`/`);for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(!n.length)return null;n.pop()}else n.push(e)}return n.join(`/`)}var Ke=new Map([[`ts`,`ts`],[`mts`,`ts`],[`js`,`js`],[`mjs`,`js`],[`json`,`json`]]),qe=e=>Ke.get(e.slice(e.lastIndexOf(`.`)+1))??`ts`;function Je(e,t){return{name:`aula-tree`,setup(n){n.onResolve({filter:/.*/},async n=>{let r=t[n.path];if(r!==void 0)return{path:r,external:!0};if(n.kind===`entry-point`)return{path:U(``,n.path)??n.path,namespace:`tree`};if(!n.path.startsWith(`./`)&&!n.path.startsWith(`../`)){let t=await et(e,n.path,n.importer);return t===null?{errors:[{text:`cannot find the package "${n.path}" in node_modules or the workspace packages`}]}:{path:t,namespace:`tree`}}let i=U(H(n.importer),n.path);if(i===null)return{errors:[{text:`"${n.path}" is outside the folder you opened`}]};for(let t of[i,`${i}.ts`,`${i}/index.ts`])if(await e.read(t)!==null)return{path:t,namespace:`tree`};return{errors:[{text:`cannot find "${n.path}" (${i})`}]}}),n.onLoad({filter:/.*/,namespace:`tree`},async t=>{let n=await e.read(t.path);return n===null?{errors:[{text:`cannot read ${t.path}`}]}:{contents:n,loader:qe(t.path)}})}}}function Ye(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`text`)==`string`}var Xe=({text:e,location:t})=>({severity:`error`,code:`bundle-error`,message:e,...t?{location:{file:t.file.replace(V,``),line:t.line,col:t.column+1}}:{},stack:[],related:[]});async function Ze(e,t,n,r){let i;try{i=await e.build({entryPoints:[n],bundle:!0,write:!1,format:`esm`,platform:`browser`,target:`es2024`,outfile:`bundle.js`,sourcemap:`both`,sourcesContent:!1,metafile:!0,logLevel:`silent`,plugins:[Je(t,r)]})}catch(e){let t=typeof e==`object`&&e?Reflect.get(e,`errors`):void 0;if(Array.isArray(t)&&t.every(Ye))return{_tag:`Left`,left:t.map(Xe)};throw e}let a=i.outputFiles.find(e=>e.path.endsWith(`.js`))?.text,o=i.outputFiles.find(e=>e.path.endsWith(`.js.map`))?.text;if(a===void 0||o===void 0)throw Error(`esbuild wrote no bundle`);return{_tag:`Right`,right:{code:a,map:o,inputs:Object.keys(i.metafile?.inputs??{}).filter(e=>e.startsWith(V)).map(e=>e.slice(5))}}}function W(e,t){if(typeof e==`string`)return t===`.`?e:null;if(typeof e!=`object`||!e)return null;if(Object.keys(e).some(e=>e.startsWith(`.`)))return t in e?W(Reflect.get(e,t),`.`):null;for(let t of[`browser`,`import`,`default`])if(t in e)return W(Reflect.get(e,t),`.`);return null}function G(e){let t=e.split(`/`),n=e.startsWith(`@`)?2:1,r=t.slice(n).join(`/`);return{name:t.slice(0,n).join(`/`),subpath:r===``?`.`:`./${r}`}}async function K(e,t,n){let r=q(`${t}/package.json`,await e.read(`${t}/package.json`));return r?U(t,W(r.exports,n)??(n===`.`?r.module??r.main??`index.js`:n)):null}async function Qe(e,t,n){let{name:r,subpath:i}=G(t);for(let t=H(n);;t=H(t)){let n=await K(e,t===``?`node_modules/${r}`:`${t}/node_modules/${r}`,i);if(n!==null)return n;if(t===``)return null}}function q(e,t){if(t===null)return null;let n=Ue.PackageJson.safeParse(JSON.parse(t));return n.success?n.data:null}async function $e(e){let t=[],n=await e.read(`pnpm-workspace.yaml`);if(n!==null){let e=!1;for(let r of n.split(`
|
|
13
|
-
`))if(/^packages:\s*$/.test(r))e=!0;else if(/^\S/.test(r))e=!1;else if(e){let e=/^\s*-\s*["']?([^"'#]+?)["']?\s*(#.*)?$/.exec(r)?.[1];e!==void 0&&t.push(e)}}t.push(...q(`package.json`,await e.read(`package.json`))?.workspaces??[]);let r=[];for(let n of t){let t=n.replace(/^\.\//,``).replace(/\/$/,``);if(t.endsWith(`/*`)){let n=t.slice(0,-2);r.push(...(await e.list(n)).map(e=>`${n}/${e}`))}else t.includes(`*`)||r.push(t)}return r}async function et(e,t,n){let r=await Qe(e,t,n);if(r!==null)return r;let{name:i,subpath:a}=G(t);for(let t of await $e(e))if(q(`${t}/package.json`,await e.read(`${t}/package.json`))?.name===i)return K(e,t,a);return null}var J=/^(\d+)-/,Y=e=>e.replace(J,``);function tt(e){let t=Y(e).replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var X=(e,t)=>e<t?-1:+(e>t);function nt(e,t){let n=J.exec(e)?.[1],r=J.exec(t)?.[1];if(n===void 0||r===void 0){if(n!==r)return n===void 0?1:-1}else{let[e,t]=[n.replace(/^0+/,``),r.replace(/^0+/,``)],i=e.length-t.length||X(e,t);if(i!==0)return i}return X(Y(e),Y(t))||X(e,t)}async function rt(e,t){return(await e.list(t)).filter(e=>e!==`node_modules`&&!e.startsWith(`.`)).toSorted(nt)}var Z=async(e,t)=>await e.read(t)!==null;async function it(e,t){if(await Z(e,`index.ts`))return{_tag:`Right`,right:[{module:`index.ts`,name:Y(t)}]};let n=[];for(let t of await rt(e,``))if(await Z(e,`${t}/index.ts`))n.push({module:`${t}/index.ts`,name:Y(t)});else for(let r of await rt(e,t)){let i=`${t}/${r}/index.ts`;await Z(e,i)&&n.push({module:i,name:Y(r),section:tt(t)})}let r=[];return n.forEach((e,t)=>{let i=n.findIndex(t=>t.name===e.name);if(i===t)return;let a=[n[i],e].map(e=>(e?.module??``).slice(0,-9));r.push({severity:`error`,code:`duplicate-project-name`,message:`two projects have the name ${e.name}: ${a.join(` and `)}`,hint:`the name of a project is its folder name without the order prefix: rename one of the folders`,stack:[],related:[]})}),r.length>0?{_tag:`Left`,left:r}:{_tag:`Right`,right:n}}var at=`no project here: run from a project or playlist folder, or pass it (for example: aula web examples)`;async function ot(e,t,n,r){if(r.length===0)throw Error(at);let i=[...r.map((e,t)=>`import p${String(t)} from ${JSON.stringify(`./${e.module}`)};`),`export default [${r.map((e,t)=>`p${String(t)}`).join(`, `)}];`].join(`
|
|
14
|
-
`),a=await Ze(e,{read:e=>e===`aula-projects.ts`?Promise.resolve(i):t.read(e),list:e=>t.list(e)},B,z);return a._tag===`Left`?a:{_tag:`Right`,right:{bundle:{name:n,projects:[...r],code:a.right.code,map:a.right.map},inputs:a.right.inputs}}}async function st(e,t,n){let r=await it(t,n);return r._tag===`Left`?r:ot(e,t,n,r.right)}var ct=(e,t)=>({frames:e,name:e=>/^[a-z][a-z0-9+.-]*:/.test(e)?void 0:e,exists:()=>!0,...t?{media:t}:{}}),lt=(e,t)=>typeof e==`object`&&e?Reflect.get(e,t):void 0;async function ut(e,t,i,o,s){await u(),await l(),s?.();let c=Ge(e.code,o),d=await n(()=>i.load({code:c,map:e.map}));if(d._tag===`Left`)return{_tag:`Left`,left:[a(d.left,B,t)]};let f=lt(d.right.exports,`default`);if(!Array.isArray(f))throw Error(`${B} has no list of projects`);return{_tag:`Right`,right:f.map((n,i)=>{let a=e.projects[i];if(!r(n))throw Error(`the default export of ${a?.module??``} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ … ] })\``);return mt(a?.name??``,ft(a?.module??`index.ts`),a?.section,n,t)})}}async function dt(e,t,n,r,i,a){let o=await e.name(),[s]=await Promise.all([st(r,e,o),u().then(async()=>{await l(),a?.()})]);return s._tag===`Left`?s:ut(s.right.bundle,t,n,i)}var ft=e=>e.slice(0,Math.max(0,e.lastIndexOf(`/`)));function pt(e){return e.length===1&&e[0]?.folder===``?[...e]:e.filter(e=>!e.draft)}function mt(e,t,n,r,a){let l=r.chapters.length+1;return{name:e,folder:t,...n===void 0?{}:{section:n},title:r.title,draft:r.draft,chapters:l,titles:[r.title,...r.chapters.map(e=>e.heading)],script:()=>{let e=[];for(let t of r.chapters.keys()){let n=o(r,t+1,{host:a});if(n.value===void 0)return{_tag:`Left`,left:n.diagnostics};e.push(n.value)}return{_tag:`Right`,right:{script:d(r,e)}}},walk:e=>{e>0&&c(r,e,{host:a})},render:(e,t)=>{let n=i(r,e,{host:a,narration:t});if(!n.ok||n.value===void 0)return{_tag:`Left`,left:n.diagnostics};let{lottie:o,waits:c,embeds:l,diagnostics:u}=n.value;return{_tag:`Right`,right:{lottie:o,waits:c,embeds:l,background:(r.theme??s).background,warnings:u}}}}}var Q=e=>JSON.stringify(e.words);function ht(e){let t=0xdeadbeef,n=0x41c6ce57;for(let r of e){for(let e=0;e<r.length;e++){let i=r.charCodeAt(e);t=Math.imul(t^i,0x9e3779b1),n=Math.imul(n^i,0x5f356495)}t=Math.imul(t^r.length^0x9e3779b9,0x9e3779b1),n=Math.imul(n^r.length^0x85ebca6b,0x5f356495)}return t=Math.imul(t^t>>>16,0x85ebca6b)^Math.imul(n^n>>>13,0xc2b2ae35),n=Math.imul(n^n>>>16,0x85ebca6b)^Math.imul(t^t>>>13,0xc2b2ae35),(n>>>0).toString(16).padStart(8,`0`)+(t>>>0).toString(16).padStart(8,`0`)}var gt=(e,t)=>e===``?t:`${e}/${t}`;function _t(e,t,n){let r=t=>{throw Error(`the speech of ${JSON.stringify(e.text)} is not on its clock: ${t}`)};(t.sampleRate!==n.sampleRate||t.samples.length!==n.samples)&&r(`${String(t.samples.length)} samples, and the clock has ${String(n.samples)}`);let i=n.words??[];t.words.length!==i.length&&r(`${String(t.words.length)} words, and the clock has ${String(i.length)}`),t.words.forEach((e,t)=>{let n=i[t]?.start;e.start!==n&&r(`word ${String(t+1)} starts at ${String(e.start)} s, and at ${String(n)} s on the clock`)})}var vt=class{name;constructor(e){this.name=e}project=null;titles=[];script=[];estimates=[];knownRate=void 0;lengths=[];warnings=[];drawings=[];drawn=[];kept=new Map;place={chapter:0,seconds:0};stale=!1;halted=!1;running=!1;errors=[];watcher=null;done=Promise.resolve();changed(){this.watcher?.changed(this.state())}window(){if(this.script.length===0)return[];let e=Math.min(Math.max(this.place.chapter,0),this.script.length-1);return e+1<this.script.length?[e,e+1]:[e]}prune(){let e=this.window(),t=!1;for(let n=0;n<this.drawings.length;n++)e.includes(n)||(this.drawings[n]!==void 0&&(this.drawings[n]=void 0,t=!0),this.drawn[n]=!1);return t}rate(){return this.knownRate??this.drawings.find(e=>e!==void 0)?.chapter.rate??this.estimates[0]?.sampleRate??1}samples(e){let t=[0];return this.script.forEach((n,r)=>{let i=this.drawings[r]?.chapter.length??this.lengths[r],a=this.estimates[r],o=i===void 0?a?Math.round(a.endFrame*e/a.sampleRate):0:i;t.push((t[r]??0)+o)}),t}seconds(){let e=this.rate();return this.samples(e).map(t=>t/e)}order(){let e=this.window(),t=e[0];if(t===void 0)return[];let n=this.script[t]??[],r=this.drawn[t]?this.drawings[t]:void 0,i=0;if(r){let e=this.place.seconds*r.chapter.rate,t=r.places.findIndex(t=>t.at+t.length>e);i=t===-1?r.places.length:t}let a=n.map((e,n)=>[t,n]),o=e[1],s=o===void 0?[]:(this.script[o]??[]).map((e,t)=>[o,t]);return[...a.slice(i),...s,...a.slice(0,i)]}next(){for(let[e,t]of this.order()){let n=this.script[e]??[];if(!this.drawn[e]){let t=n.find(e=>!this.kept.has(Q(e)));return t?{kind:`time`,cue:t}:{kind:`draw`,chapter:e}}let r=n[t];if(r&&!this.kept.get(Q(r))?.speech)return{kind:`speak`,cue:r}}return null}sound(e,t){let n=this.kept.get(e);if(!n?.speech)return;let r=JSON.stringify(t.waits),i=n.sounds.get(r);return i||(i=ie(n.speech,t),n.sounds.set(r,i)),i}draw(e,t){let n=this.script[t]??[],r=n.map(Q),i=ae(n,r.map(e=>{let t=this.kept.get(e);if(!t)throw Error(`no clock of the cue ${e}`);return t.timing})),a=e.render(t,i);if(a._tag===`Left`)return a;let{lottie:o,waits:s,embeds:c,background:l,warnings:u}=a.right;this.drawn[t]=!0;let d=i.endFrame+s.reduce((e,t)=>e+t.samples,0);this.knownRate=i.sampleRate,this.lengths[t]=d,this.warnings[t]=u;let f=ht([JSON.stringify([r,i,s,c,l]),o]);if(this.drawings[t]?.made===f)return{_tag:`Right`,right:void 0};let p=re(i,s),m={animation:JSON.parse(o),rate:i.sampleRate,length:d,cues:p.map((e,t)=>({at:e.at,length:e.length,samples:this.sound(r[t]??``,e)})),embeds:c.map(({path:t,image:n,kind:r,start:i,frames:a})=>({path:gt(e.folder,t),...n===void 0?{}:{image:gt(e.folder,n)},kind:r,background:l,at:i,seconds:a/60}))};return this.drawings[t]={made:f,chapter:m,keys:r,places:p},this.changed(),{_tag:`Right`,right:void 0}}spoken(e){let t=!1;this.drawings.forEach((n,r)=>{if(!n?.keys.includes(e))return;let i=n.chapter.cues.map((t,r)=>{let i=n.places[r];return n.keys[r]===e&&i?{...t,samples:this.sound(e,i)}:t});this.drawings[r]={...n,chapter:{...n.chapter,cues:i}},t=!0}),t&&this.changed()}forget(){let e=new Set(this.script.flat().map(Q));for(let t of this.kept.keys())e.has(t)||this.kept.delete(t)}state(){let e=this.seconds(),t=e.pop()??0;return{building:this.running,timeline:this.script.map((t,n)=>({title:this.titles[n]??``,start:e[n]??0})),duration:t,errors:this.errors,warnings:this.warnings.flat(),chapters:this.drawings.map(e=>e?.chapter)}}};function yt(e){let t=null,n=!1,r=null,i=()=>(r=e.workspace.projects(),r),a=async t=>{if(!t.project){let e=await(r??i());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(e._tag===`Left`)return e;let n=e.right.find(e=>e.name===t.name);if(!n)throw Error(`the workspace has no project ${t.name}`);let a=await(n.readScript?.()??n.script());if(t.stale||t.halted)return{_tag:`Right`,right:void 0};if(a._tag===`Left`)return a;let{script:o}=a.right;t.project=n,t.titles=n.titles,t.script=o,t.estimates=o.map(e=>p(e)),t.drawings.length!==o.length&&(t.drawings=Array.from({length:o.length},()=>void 0),t.lengths=Array.from({length:o.length},()=>void 0)),t.warnings=Array.from({length:o.length},()=>[]),t.drawn=Array.from({length:o.length},()=>!1),t.prune(),t.changed()}let n=t.project;for(let r=t.next();r&&!t.stale&&!t.halted;r=t.next()){if(r.kind===`draw`){if(await n.readChapter?.(r.chapter),t.stale||t.halted)break;let e=t.draw(n,r.chapter);if(e._tag===`Left`)return e;continue}let{cue:i}=r,a=Q(i);if(r.kind===`time`){let n=await e.voice.time(i.words);t.kept.set(a,{timing:n,sounds:new Map});continue}let o=await e.voice.speak(i.words),s=t.kept.get(a);if(!s)throw Error(`no clock of the cue ${a}`);_t(i,o,s.timing),s.speech=o,t.spoken(a)}return!t.stale&&!t.halted&&t.forget(),{_tag:`Right`,right:void 0}},o=e=>{e.running=!0,e.done=(async()=>{try{for(;;){e.stale=!1;let t=await a(e);if(e.errors=t._tag===`Left`?t.left:[],!e.stale||e.halted)break}}finally{e.running=!1,e.changed()}})()};return{refresh:e=>{r=null;let i=t;!n&&i&&(i.place=e,i.project=null,i.running?i.stale=!0:o(i))},halt:()=>{r=null,t&&=(t.halted=!0,t.watcher=null,null)},stop:()=>{n=!0,t&&(t.halted=!0,t.watcher=null)},idle:()=>t?.done??Promise.resolve(),build:{list:async()=>{let e=await i();return e._tag===`Left`?e:{_tag:`Right`,right:pt(e.right).map(({name:e,title:t,section:n})=>({name:e,title:t,...n===void 0?{}:{section:n}}))}},watch:(e,r)=>{n||(t?.name!==e&&(t&&(t.halted=!0,t.watcher=null),t=new vt(e),o(t)),t.watcher=r,t.changed())},seek:(e,r)=>{t?.name===e&&(t.place=r,t.prune()&&t.changed(),!n&&!t.running&&t.project&&t.errors.length===0&&t.next()!==null&&o(t))}}}}function bt(e){return e}function xt(e,t){return Object.assign({},e,t)}function St(e,t){return{...e,...t}}function Ct(...e){return Object.assign({},...e)}var wt={create:bt,extend:xt,merge:Ct,override:St},Tt=class extends Error{constructor(e,t){super(e),this.stack=t}};function Et(e,t,n){return e===``?``:` at ${e}:${String(t)}:${String(n)}`}var $=e=>`${e.file}:${String(e.line)}:${String(e.col)}`;function Dt(e,t){if(!(e instanceof Error))return{message:String(e),place:null,stack:[]};let n=t(e),[r]=n;return{message:e.name===`Error`||e.name===``?e.message:`${e.name}: ${e.message}`,place:r?$(r):null,stack:n.map(e=>e.function===``?`at ${$(e)}`:`at ${e.function} (${$(e)})`)}}function Ot(e,t,n){let r=(t,n,r)=>{let i=e.createElement(t);return i.className=n,i.textContent=r,i},i=r(`div`,`crash`,``);i.setAttribute(`role`,`alert`),i.append(r(`h1`,``,`The app stopped because of an error.`),r(`p`,`message`,t.message)),t.place!==null&&i.append(r(`p`,`place`,`at ${t.place}`)),t.stack.length>0&&i.append(r(`pre`,`stack`,t.stack.join(`
|
|
15
|
-
`)));let a=r(`button`,`reload`,`Reload`);a.addEventListener(`click`,n),i.append(a),e.body.replaceChildren(i)}var kt=2e5;function At(e){let{layers:t,...n}=e,r=[JSON.stringify({...n,layers:[]})],i=[],a=0;for(let e of t){let t=JSON.stringify(e);a>0&&a+t.length>kt&&(r.push(`[${i.join(`,`)}]`),i=[],a=0),i.push(t),a+=t.length+1}return i.length>0&&r.push(`[${i.join(`,`)}]`),r}async function jt(e,t){let[n,...r]=e;if(n===void 0)throw Error(`a Lottie animation with no parts`);let i=JSON.parse(n);for(let e of r){await t();let n=JSON.parse(e);i.layers.push(...n)}return i}var Mt=e=>e.map(e=>({...e,text:m(e)}));function Nt(e){let t=Reflect.get(e,`text`);if(typeof t!=`string`)throw Error(`a diagnostic with no text: ${e.message}`);return t}export{Tt as a,Ot as c,ut as d,dt as f,se as g,We as h,At as i,wt as l,V as m,Mt as n,Dt as o,ct as p,jt as r,Et as s,Nt as t,yt as u};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{r as e,t}from"../rolldown-runtime-BLXQ4ufn.js";import{a as n,d as r,f as i,g as a,i as o,l as s,m as c,n as l,o as u,p as d,u as f}from"../protocol-F-4tHoAW.js";import{S as p,g as m,v as h,y as g}from"../src-DfPcHwz-.js";var _=44,v=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,y=new Uint8Array(64),b=new Uint8Array(128);for(let e=0;e<v.length;e++){let t=v.charCodeAt(e);y[e]=t,b[t]=e}function x(e){let t=0,n=0,r=0;do r=b[e.next()],t|=(r&31)<<n,n+=5;while(r&32);return t}function S(e){return e&1?-0x80000000|-(e>>>1):e>>>1}function C(e,t){return e.pos>=t?!1:e.peek()!==_}var w=class{constructor(e){this.pos=0,this.buffer=e}next(){return this.buffer.charCodeAt(this.pos++)}peek(){return this.buffer.charCodeAt(this.pos)}indexOf(e){let{buffer:t,pos:n}=this,r=t.indexOf(e,n);return r===-1?t.length:r}};function ee(e){let{length:t}=e,n=new w(e),r=[],i=0,a=0,o=0,s=0,c=0;do{let e=n.indexOf(`;`),t=[],l=!0,u=0;for(i=0;n.pos<e;){let r;i+=S(x(n)),i<u&&(l=!1),u=i,C(n,e)?(a+=S(x(n)),o+=S(x(n)),s+=S(x(n)),C(n,e)?(c+=S(x(n)),r=[i,a,o,s,c]):r=[i,a,o,s]):r=[i],t.push(r),n.pos++}l||te(t),r.push(t),n.pos=e+1}while(n.pos<=t);return r}function te(e){e.sort(T)}function T(e,t){return e[0]-t[0]}var E=e(t(((e,t,n)=>{var r;(function(n,i){typeof e==`object`&&t!==void 0?t.exports=i():typeof r==`function`&&r.amd?r(i):(n=typeof globalThis<`u`?globalThis:n||self,n.resolveURI=i())})(n,(function(){let e=/^[\w+.-]+:\/\//,t=/^([\w+.-]+:)\/\/([^@/#?]*@)?(\[[^\]]+\]|[^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/,n=/^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;function r(t){return e.test(t)}function i(e){return e.startsWith(`//`)}function a(e){return e.startsWith(`/`)}function o(e){return e.startsWith(`file:`)}function s(e){return/^[.?#]/.test(e)}function c(e){let n=t.exec(e);return u(n[1],n[2]||``,n[3],n[4]||``,n[5]||`/`,n[6]||``,n[7]||``)}function l(e){let t=n.exec(e),r=t[2];return u(`file:`,``,t[1]||``,``,a(r)?r:`/`+r,t[3]||``,t[4]||``)}function u(e,t,n,r,i,a,o){return{scheme:e,user:t,host:n,port:r,path:i,query:a,hash:o,type:7}}function d(e){if(i(e)){let t=c(`http:`+e);return t.scheme=``,t.type=6,t}if(a(e)){let t=c(`http://foo.com`+e);return t.scheme=``,t.host=``,t.type=5,t}if(o(e))return l(e);if(r(e))return c(e);let t=c(`http://foo.com/`+e);return t.scheme=``,t.host=``,t.type=e?e.startsWith(`?`)?3:e.startsWith(`#`)?2:4:1,t}function f(e){if(e.endsWith(`/..`))return e;let t=e.lastIndexOf(`/`);return e.slice(0,t+1)}function p(e,t){m(t,t.type),e.path=e.path===`/`?t.path:f(t.path)+e.path}function m(e,t){let n=t<=4,r=e.path.split(`/`),i=1,a=0,o=!1;for(let e=1;e<r.length;e++){let t=r[e];t?(o=!1,t!==`.`&&(t===`..`?a?(o=!0,a--,i--):n&&(r[i++]=t):(r[i++]=t,a++))):o=!0}let s=``;for(let e=1;e<i;e++)s+=`/`+r[e];(!s||o&&!s.endsWith(`/..`))&&(s+=`/`),e.path=s}function h(e,t){if(!e&&!t)return``;let n=d(e),r=n.type;if(t&&r!==7){let e=d(t),i=e.type;switch(r){case 1:n.hash=e.hash;case 2:n.query=e.query;case 3:case 4:p(n,e);case 5:n.user=e.user,n.host=e.host,n.port=e.port;case 6:n.scheme=e.scheme}i>r&&(r=i)}m(n,r);let i=n.query+n.hash;switch(r){case 2:case 3:return i;case 4:{let r=n.path.slice(1);return r?s(t||e)&&!s(r)?`./`+r+i:r+i:i||`.`}case 5:return n.path+i;default:return n.scheme+`//`+n.user+n.host+n.port+n.path+i}}return h}))}))(),1);function D(e){if(!e)return``;let t=e.lastIndexOf(`/`);return e.slice(0,t+1)}function O(e,t){let n=D(e),r=t?t+`/`:``;return e=>(0,E.default)(r+(e||``),n)}var k=0,ne=1,re=2,ie=3,A=4;function j(e,t){let n=M(e,0);if(n===e.length)return e;t||(e=e.slice());for(let r=n;r<e.length;r=M(e,r+1))e[r]=P(e[r],t);return e}function M(e,t){for(let n=t;n<e.length;n++)if(!N(e[n]))return n;return e.length}function N(e){for(let t=1;t<e.length;t++)if(e[t][k]<e[t-1][k])return!1;return!0}function P(e,t){return t||(e=e.slice()),e.sort(F)}function F(e,t){return e[k]-t[k]}var I=!1;function L(e,t,n,r){for(;n<=r;){let i=n+(r-n>>1),a=e[i][k]-t;if(a===0)return I=!0,i;a<0?n=i+1:r=i-1}return I=!1,n-1}function R(e,t,n){for(let r=n+1;r<e.length&&e[r][k]===t;n=r++);return n}function z(e,t,n){for(let r=n-1;r>=0&&e[r][k]===t;n=r--);return n}function B(){return{lastKey:-1,lastNeedle:-1,lastIndex:-1}}function V(e,t,n,r){let{lastKey:i,lastNeedle:a,lastIndex:o}=n,s=0,c=e.length-1;if(r===i){if(t===a)return I=o!==-1&&e[o][k]===t,o;t>=a?s=o===-1?0:o:c=o}return n.lastKey=r,n.lastNeedle=t,n.lastIndex=L(e,t,s,c)}function H(e){return typeof e==`string`?JSON.parse(e):e}var U="`line` must be greater than 0 (lines start at line 1)",W="`column` must be greater than or equal to 0 (columns start at column 0)",ae=class{constructor(e,t){let n=typeof e==`string`;if(!n&&e._decodedMemo)return e;let r=H(e),{version:i,file:a,names:o,sourceRoot:s,sources:c,sourcesContent:l}=r;this.version=i,this.file=a,this.names=o||[],this.sourceRoot=s,this.sources=c,this.sourcesContent=l,this.ignoreList=r.ignoreList||r.x_google_ignoreList||void 0;let u=O(t,s);this.resolvedSources=c.map(u);let{mappings:d}=r;if(typeof d==`string`)this._encoded=d,this._decoded=void 0;else if(Array.isArray(d))this._encoded=void 0,this._decoded=j(d,n);else if(r.sections)throw Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);else throw Error(`invalid source map: ${JSON.stringify(r)}`);this._decodedMemo=B(),this._bySources=void 0,this._bySourceMemos=void 0}};function G(e){return e}function K(e){var t;return(t=G(e))._decoded||(t._decoded=ee(G(e)._encoded))}function q(e,t){let{line:n,column:r,bias:i}=t;if(n--,n<0)throw Error(U);if(r<0)throw Error(W);let a=K(e);if(n>=a.length)return J(null,null,null,null);let o=a[n],s=oe(o,G(e)._decodedMemo,n,r,i||1);if(s===-1)return J(null,null,null,null);let c=o[s];if(c.length===1)return J(null,null,null,null);let{names:l,resolvedSources:u}=e;return J(u[c[ne]],c[re]+1,c[ie],c.length===5?l[c[A]]:null)}function J(e,t,n,r){return{source:e,line:t,column:n,name:r}}function oe(e,t,n,r,i){let a=V(e,r,t,n);return I?a=(i===-1?R:z)(e,r,a):i===-1&&a++,a===-1||a===e.length?-1:a}var Y=new Map;function se(e,t,n){Y.set(e,{map:new ae(t),prefix:n})}function ce(e,t,n){let r=Y.get(e);if(!r)return{file:e,line:t,column:n};let i=q(r.map,{line:t,column:n-1});return i.source===null||i.line===null||i.column===null?{file:e,line:t,column:n}:{file:i.source.startsWith(r.prefix)?i.source.slice(r.prefix.length):i.source,line:i.line,column:i.column+1}}var X=a(ce);function le(e){let t=0,r=new Map;e.then(e=>{e.addEventListener(`message`,t=>{let i=t.data;if(i.kind===`error`)throw e.close(),new n(`the narrator stopped: ${i.message}`,i.stack);let a=r.get(i.id);r.delete(i.id),a?.(i)}),e.start()});let i=async(n,i)=>{let a=await e;return new Promise(e=>{let o=t++;r.set(o,e),a.postMessage({id:o,kind:n,words:i})})};return{speak:async e=>{let t=await i(`speak`,e);if(t.kind!==`speech`)throw Error(`the narrator answered ${t.kind} to a speech`);return{samples:t.samples,sampleRate:t.sampleRate,words:t.words}},time:async e=>{let t=await i(`time`,e);if(t.kind!==`timing`)throw Error(`the narrator answered ${t.kind} to a clock`);return{samples:t.samples,sampleRate:t.sampleRate,words:t.words}}}}function ue(e){let t=0,n=0,a=!1,c=new Map,u=n=>{let r=r=>{let i=t++,{promise:a,resolve:o}=Promise.withResolvers();return c.set(i,o),e.post({kind:`files`,id:i,tree:n,question:r},[]),a};return{bundle:async()=>{let e=await r({kind:`bundle`});if(e.kind!==`bundle`)throw Error(`the page answered ${e.kind} to a question of the bundle`);return e.result},name:async()=>{let e=await r({kind:`name`});if(e.kind!==`name`)throw Error(`the page answered ${e.kind} to a question of the name`);return e.name},read:async e=>{let t=await r({kind:`read`,path:e});if(t.kind!==`read`)throw Error(`the page answered ${t.kind} to a read of ${e}`);return t.text},bytes:async e=>{let t=await r({kind:`bytes`,path:e});if(t.kind!==`bytes`)throw Error(`the page answered ${t.kind} to a read of the bytes of ${e}`);return t.bytes},list:async e=>{let t=await r({kind:`list`,folder:e});if(t.kind!==`list`)throw Error(`the page answered ${t.kind} to a list of ${e}`);return t.names}}},p=async()=>{let t=u(n++),o=new Map,s=new Set,c=e=>{let t=o.get(e);return t===void 0&&s.add(e),t?{size:t.length,read:()=>t}:void 0},[l]=await Promise.all([t.bundle(),g().then(async()=>{await h(),e.post({kind:`stage`,stage:`engine`},[])})]),f;if(l!==null){if(l._tag===`Left`)return e.post({kind:`stage`,stage:`project`},[]),l;f=await r(l.right,d(X,c),e.modules,e.player)}else{let n=await t.name();if(n===null)return e.post({kind:`stage`,stage:`project`},[]),{_tag:`Right`,right:[]};let r={name:()=>Promise.resolve(n),read:t.read,list:t.list},a=await e.bundler();f=await i(r,d(X,c),e.modules,a,e.player)}if(e.post({kind:`stage`,stage:`project`},[]),f._tag===`Left`)return f;a||(a=!0,e.post({kind:`narrator`},[]));let p=async e=>{for(;;){s.clear();let n=e(),r=[...s].filter(e=>!o.has(e));if(r.length===0)return n;await Promise.all(r.map(async e=>o.set(e,await t.bytes(e))))}};return{_tag:`Right`,right:f.right.map(e=>{let t=new Set;return{...e,readScript:async()=>(await m(),p(()=>e.script())),readChapter:async n=>{t.has(n)||(await m(),await p(()=>e.walk?.(n)),t.add(n))}}})}},_=Promise.withResolvers(),v=f(s.create({voice:le(_.promise),workspace:{projects:p}})),y=[],b=(t,{chapters:n,...r})=>{let i=[],a=[],s=[];n.forEach((e,t)=>{let n=y[t];if(e===n)return;if(!e){i.push([t,void 0]);return}let r=n?.cues.map(e=>e.samples)??[];if(e.animation!==n?.animation){let{animation:n,cues:a,...s}=e,c=a.map(e=>{let t=e.samples?r.indexOf(e.samples):-1;return t===-1?null:t}),l=a.map(({at:e,length:t},n)=>({at:e,length:t,keep:c[n]??null}));i.push([t,{...s,lottie:o(n),cues:l}]),r=c.map(e=>e===null?void 0:r[e])}e.cues.forEach((e,n)=>{if(!e.samples||e.samples===r[n])return;let i=e.samples.slice();s.push(i.buffer),a.push({chapter:t,cue:n,samples:i})})}),y=n;let c={building:r.building,timeline:r.timeline,duration:r.duration,errors:l(r.errors)};e.post({kind:`state`,watch:t,state:c,count:n.length,drawings:i,sounds:a},s)};return t=>{switch(t.kind){case`list`:v.build.list().then(n=>{let r=n._tag===`Left`?{_tag:`Left`,left:l(n.left)}:n;e.post({kind:`listed`,id:t.id,videos:r},[])});return;case`watch`:y=[],v.build.watch(t.name,{changed:e=>{b(t.watch,e)}});return;case`seek`:v.build.seek(t.name,t.place);return;case`halt`:v.halt();return;case`refresh`:v.refresh(t.place);return;case`files`:{let e=c.get(t.id);c.delete(t.id),e?.(t.answer);return}case`narrator`:_.resolve(t.port);return}}}var Z=(e,t=[])=>{self.postMessage(e,{transfer:t})},Q=e=>{let t=u(e,X);Z({kind:`error`,message:t.message,stack:t.stack.map(e=>` ${e}`).join(`
|
|
2
|
-
`)})};self.addEventListener(`error`,e=>{e.preventDefault(),Q(e.error??Error(e.message))}),self.addEventListener(`unhandledrejection`,e=>{e.preventDefault(),Q(e.reason)});var de={"@beff/aula":new URL(`./aula.js`,import.meta.url).href,"@beff/aula-method":new URL(`./aula-method.js`,import.meta.url).href},fe={load:async({code:e,map:t})=>{let n=URL.createObjectURL(new Blob([e],{type:`text/javascript`}));return se(n,t,c),{url:n,exports:await import(n)}}},$=null;function pe(){return $??=(async()=>{let t=performance.now(),[n,r]=await Promise.all([p(()=>import(`../browser-sNTR4ahh.js`).then(t=>e(t.default,1)),[],import.meta.url),p(()=>import(`../esbuild-CW5RQptO.js`),[],import.meta.url)]);return await n.initialize({wasmURL:r.default,worker:!1}),console.log(`aula: esbuild loaded in ${((performance.now()-t)/1e3).toFixed(1)} s`),n})(),$}var me=ue({post:Z,bundler:pe,modules:fe,player:de});self.addEventListener(`message`,e=>{me(e.data)});
|