@beff/aula-cli 0.4.0 → 0.4.2

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.
@@ -1,4 +1,4 @@
1
- import{a as e,b as t,d as n,i as r,o as i,s as a,v as o,y as s}from"./src-BktLa5tx.js";function c(e,t){let n=e.titleParts??[{text:e.title}];return o.narrationScript([...n],a(e.lexicon??{}),[...t])}function l(e,t,n){return o.chapterNarration([...e],[...t],n)}function u(e){return o.estimateNarration([...e])}function d(e){return o.renderDiagnostic(e)}var f=`.!?…`,p=`,;:`,m=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?<=[${m(f)}])\\s+`),RegExp(`(?<=[${m(p)}])\\s+`),`${{path:`aula-voice.avw`,bytes:33478208,sha256:`7a6039017a2783f7f3954a3531148e761b683807ebd3bb1436505f72379e81a1`}.path}`;var h=e=>Float64Array.from(e,e=>e.start);function g(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 ee(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 te(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 g(new Float32Array(e.samples),t.waits)}function ne(e,t){let n=t[0]?.sampleRate??0;if(t.some(e=>e.sampleRate!==n))throw Error(`the narrator changed its sample rate`);return l(e,t.map(e=>e.words?{samples:e.samples,starts:h(e.words)}:{samples:e.samples}),n)}function re(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 ie=e=>t=>{let n=[];for(let r of(t.stack??``).split(`
1
+ import{a as e,b as t,d as n,i as r,o as i,s as a,v as o,y as s}from"./src-DYumAKNc.js";function c(e,t){let n=e.titleParts??[{text:e.title}];return o.narrationScript([...n],a(e.lexicon??{}),[...t])}function l(e,t,n){return o.chapterNarration([...e],[...t],n)}function u(e){return o.estimateNarration([...e])}function d(e){return o.renderDiagnostic(e)}var f=`.!?…`,p=`,;:`,m=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);RegExp(`(?<=[${m(f)}])\\s+`),RegExp(`(?<=[${m(p)}])\\s+`),`${{path:`aula-voice.avw`,bytes:33478208,sha256:`7a6039017a2783f7f3954a3531148e761b683807ebd3bb1436505f72379e81a1`}.path}`;var h=e=>Float64Array.from(e,e=>e.start);function g(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 ee(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 te(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 g(new Float32Array(e.samples),t.waits)}function ne(e,t){let n=t[0]?.sampleRate??0;if(t.some(e=>e.sampleRate!==n))throw Error(`the narrator changed its sample rate`);return l(e,t.map(e=>e.words?{samples:e.samples,starts:h(e.words)}:{samples:e.samples}),n)}function re(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 ie=e=>t=>{let n=[];for(let r of(t.stack??``).split(`
2
2
  `)){let t=re(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},_=e=>JSON.stringify(e.words);function ae(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 oe=class{name;constructor(e){this.name=e}titles=[];script=[];estimates=[];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())}rate(){return 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],a=this.estimates[r],o=i?i.chapter.length:a?Math.round(a.endFrame*e/a.sampleRate):0;t.push((t[r]??0)+o)}),t}seconds(){let e=this.rate();return this.samples(e).map(t=>t/e)}at(e){let t=this.seconds().slice(0,-1),n=Math.max(0,t.findLastIndex(t=>t<=e));return{chapter:n,seconds:Math.max(0,e-(t[n]??0))}}order(){let e=this.script.flatMap((e,t)=>e.map((e,n)=>[t,n])),{chapter:t,seconds:n}=this.place,r=this.drawn[t]?this.drawings[t]:void 0,i=0;if(r){let e=n*r.chapter.rate,t=r.places.findIndex(t=>t.at+t.length>e);i=t===-1?r.places.length:t}let a=Math.max(0,e.findIndex(([e,n])=>e>t||e===t&&n>=i));return[...e.slice(a),...e.slice(0,a)]}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(_(e)));return t?{kind:`time`,cue:t}:{kind:`draw`,chapter:e}}let r=n[t];if(r&&!this.kept.get(_(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=te(n.speech,t),n.sounds.set(r,i)),i}draw(e,t){let n=this.script[t]??[],r=n.map(_),i=ne(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,warnings:c}=a.right;this.drawn[t]=!0;let l=JSON.stringify([r,i,o,s]);if(this.drawings[t]?.made===l)return{_tag:`Right`,right:void 0};let u=ee(i,s),d={animation:JSON.parse(o),rate:i.sampleRate,length:i.endFrame+s.reduce((e,t)=>e+t.samples,0),cues:u.map((e,t)=>({at:e.at,length:e.length,samples:this.sound(r[t]??``,e)}))};return this.drawings[t]={made:l,chapter:d,keys:r,places:u,warnings:c},this.changed(),{_tag:`Right`,right:void 0}}spoken(e){this.drawings.forEach((t,n)=>{if(!t?.keys.includes(e))return;let r=t.chapter.cues.map((n,r)=>{let i=t.places[r];return t.keys[r]===e&&i?{...n,samples:this.sound(e,i)}:n});this.drawings[n]={...t,chapter:{...t.chapter,cues:r}}}),this.changed()}forget(){let e=new Set(this.script.flat().map(_));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.drawings.flatMap(e=>e?.warnings??[]),chapters:this.drawings.map(e=>e?.chapter)}}};function se(e){let t=null,n=!1,r=null,i=()=>(r=e.workspace.projects(),r),a=async t=>{let n=await(r??i());if(n._tag===`Left`)return n;let a=n.right.find(e=>e.name===t.name);if(!a)throw Error(`the workspace has no project ${t.name}`);let o=a.script();if(o._tag===`Left`)return o;let{script:s}=o.right;t.titles=a.titles,t.script=s,t.estimates=s.map(e=>u(e)),t.drawings.length!==s.length&&(t.drawings=Array.from({length:s.length},()=>void 0)),t.drawn=Array.from({length:s.length},()=>!1),t.changed();for(let n=t.next();n&&!t.stale&&!t.halted;n=t.next()){if(n.kind===`draw`){let e=t.draw(a,n.chapter);if(e._tag===`Left`)return e;continue}let{cue:r}=n,i=_(r);if(n.kind===`time`){let n=await e.voice.time(r.words);t.kept.set(i,{timing:n,sounds:new Map});continue}let o=await e.voice.speak(r.words),s=t.kept.get(i);if(!s)throw Error(`no clock of the cue ${i}`);ae(r,o,s.timing),s.speech=o,t.spoken(i)}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=i.at(e),i.running?i.stale=!0:o(i))},halt:()=>{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 oe(e),o(t)),t.watcher=r,t.changed())},seek:(e,n)=>{t?.name===e&&(t.place=t.at(n))}}}}var v=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=>!ce(e));if(r.length===n.length||r.length===0)return null;let i=r.map(e=>v(e)??e);return i.length===1?i[0]:{...e,[t]:i}},ce=e=>typeof e!=`boolean`&&e.type===`null`,le=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),ue=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},y=(e,t)=>{let n=[...e,...t];return n.length>0?`(${ue(n)})`:``},b=e=>e.filter(e=>e.length>0).join(` `),de=(e,t,n)=>b([y(t,e.path),[e.message,n?`received: ${le(e.received)}`:``].filter(e=>e.length>0).join(`, `)]),fe=(e,t)=>{let n=y(t,e.path),r=x(e.errors,[],!1);return b([n,[`Failed to decode one of (${r.length>5?r.slice(0,5).join(` OR `)+` and more...`:r.join(` | `)})`,`received: ${le(e.received)}`].filter(e=>e.length>0).join(`, `)])},x=(e,t,n)=>e.map(e=>`isUnionError`in e?fe(e,t):de(e,t,n)),pe=(e,t=[])=>x(e,t,!0).map((e,t,n)=>n.length==1?b([e]):b([`#${t}`,e])).join(` | `),S=Object.getPrototypeOf({});function me(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)!==S)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])!==S?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 he(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}}me({mergeArray:he});function C(e,t,n){return[{message:t,path:[...e.path],received:n}]}function ge(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 _e(e,t,n,r){if(n==null){T(e,t);let n=C(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=ge(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=C(e,`extra property.${o} Allowed: ${s}`,r);return E(e),c}function w(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 ve(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function ye(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
3
  `);return t.length===1?`/** ${t[0]} */`:[`/**`,...t.map(e=>` * ${e}`),` */`].join(`
4
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 be(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 xe(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 I?`?`:``,i=n.describe(e);return{docText:i.docText,member:`${t}${r}: ${i.typeExpr}`}}function Se(e,t,n){return N(e,`[K in ${j(e,t)}]`,n)}function Ce(e){let t=`${e.member};`;return e.docText==null?t:`${O(e.docText)}\n${t}`}function P(e,t){if(e instanceof z)e.collectDescribeRefs(t);else for(let n of e.describeChildren())P(n,t)}var we=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 C(e,`expected `+this.typeName,t)}},F=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 C(e,`expected any`,t)}},Te=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 C(e,`expected never`,t)}},Ee=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 C(e,`expected array`,t);let n=[];for(let r=0;r<t.length;r++)w(e,n,`[${r}]`,this.itemParser,t[r]);return n}describeTypeExpr(e){return`Array<${j(e,this.itemParser)}>`}describeChildren(){return[this.itemParser]}},I=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]}},L=Object.prototype.hasOwnProperty;function R(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var De=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,xe(t),n)}),n=this.indexedPropertiesParser.map(({key:t,value:n})=>Se(e,t,n)),r=[...t,...n];return r.some(e=>e.docText!=null)?r.length===0?`{}`:`{\n${r.map(Ce).join(`