@beff/aula-cli 0.1.1 → 0.3.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 +1 -1
- package/dist/src/{chunk-QWNBVWUQ.js → chunk-5MXHQCWH.js} +26 -9
- package/dist/src/{chunk-IAQZ6DTC.js → chunk-7IQUN2SB.js} +45 -6
- package/dist/src/{chunk-XUBCUJW5.js → chunk-H54BN5R7.js} +6 -9
- package/dist/src/{chunk-YX73KJQ6.js → chunk-HDAMZF5B.js} +20 -23
- package/dist/src/cli.js +8 -8
- package/dist/src/{commands-M246OWYJ.js → commands-DUMGD7TE.js} +4 -4
- package/dist/src/{problems-Y67BY7WB.js → problems-DYLEPGE6.js} +3 -3
- package/dist/src/{run-CTVGU7EK.js → run-72KOJGZE.js} +14 -9
- package/dist/src/{server-5OGXX6BF.js → server-BWWN7KZA.js} +4 -3
- package/dist/web/app/assets/__vite-browser-external-BTSih4Wj.js +1 -0
- package/dist/web/app/assets/{aula-voice-worker-DymX5vwM.js → aula-voice-worker-DfzMG86o.js} +10 -10
- package/dist/web/app/assets/{aula.core5-YhDIb7Me.wasm → aula.core5-CdA2Cc_n.wasm} +0 -0
- package/dist/web/app/assets/d1a3d405/aula-method.js +1 -0
- package/dist/web/app/assets/d1a3d405/aula.js +1 -0
- package/dist/web/app/assets/{build-worker.js → d1a3d405/build-worker.js} +2 -2
- package/dist/web/app/assets/{index-B8_aMtuI.js → d1a3d405/index.js} +3 -3
- package/dist/web/app/assets/{protocol-CnlzsyRt.js → protocol-B85V84gE.js} +10 -10
- package/dist/web/app/assets/{src-CmWmmzpF.js → src-BV6xlpP7.js} +6 -6
- package/dist/web/app/index.html +3 -3
- package/package.json +2 -2
- package/dist/web/app/assets/__vite-browser-external-BN30sEqc.js +0 -1
- package/dist/web/app/assets/aula-method.js +0 -1
- package/dist/web/app/assets/aula.js +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`)){let t=
|
|
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-BV6xlpP7.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:`519b3e3cff634d6dd8edec9fe322da64cdf184f866bb0c101dc364d9874c8440`}.path}`;var h=e=>Float64Array.from(e,e=>e.start);function g(e,t){let n=0;for(let[r,i]of t.entries()){if(!i.samples.length||i.samples.some(e=>!Number.isFinite(e))){let t=e[r]?.text.slice(0,60)??``;throw Error(`the narrator returned empty or invalid audio for ${JSON.stringify(t)}`)}if(n!==0&&i.sampleRate!==n)throw Error(`the narrator changed its sample rate`);n=i.sampleRate}let r=l(e,t.map(e=>({samples:e.samples.length,starts:h(e.words)})),n),i=new Float32Array(r.endFrame);for(let[e,n]of t.entries())i.set(n.samples,r.cues[e]?.speechStartFrame??0);return{samples:i,narration:r}}function ee(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 te(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)}async function ne(e,t){let n=[];for(let r of t){let t=[];for(let n of r)t.push(await e.time(n.words,n.speed));n.push(te(r,t))}return 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
|
+
`)){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},ae=class{titles=[];estimates=[];files=[];warnings=[];seconds=[];made=[];revisions=[];pending=[];stale=!1;halted=!1;from=0;doing=null;running=!0;errors=[];watcher=null;download;constructor(e){this.download=e}next(){return[...this.files.keys()].map(e=>(e+this.from)%this.files.length).find(e=>this.pending[e]===!0)??null}changed(){this.watcher?.changed(this.state())}duration(e){return this.seconds[e]??this.estimates[e]??0}starts(){let e=0;return this.files.map((t,n)=>(e+=this.duration(n),e-this.duration(n)))}seek(e){this.from=Math.max(0,this.starts().findLastIndex(t=>t<=e))}state(){let e=this.starts(),t=this.files.map((t,n)=>({title:this.titles[n]??``,start:e[n]??0,complete:t!==void 0})),n=[];t.forEach((e,r)=>{if(!e.complete)return;let i=e.start+this.duration(r),a=n.at(-1);a&&t[r-1]?.complete===!0?a[1]=i:n.push([e.start,i])});let r=this.running?this.status():``;return{building:this.running,timeline:t,duration:this.files.reduce((e,t,n)=>e+this.duration(n),0),ready:n,status:r,errors:this.errors,warnings:this.warnings.flat(),chapters:[...this.files]}}status(){let e=this.doing;if(!e)return`Loading the video…`;let t=`${e.what} chapter ${String(e.index+1)} of ${String(this.files.length)}`;if(e.what!==`Narrating`)return`${t}…`;let n=this.download();return n===``?e.cue?`${t}: cue ${String(e.cue.at+1)} of ${String(e.cue.of)}`:`${t}…`:`${t}: ${n}`}publish(e,t,n){let r=JSON.stringify([t.narration,n]),i=this.made[e];if(r===i)return;i!==void 0&&(this.revisions[e]=(this.revisions[e]??0)+1),this.made[e]=r;let a=JSON.parse(n),o=t.narration.sampleRate,s=this.revisions[e]??0;this.files[e]={samples:t.samples,rate:o,animation:a,revision:s},this.seconds[e]=t.samples.length/o,this.changed()}};function oe(e){let t=new Map,n=!1,r=``;e.voice.onDownload(e=>{r=e;for(let e of t.values())e.running&&e.changed()});let i=async(t,n)=>{let r=await e.workspace.projects();if(r._tag===`Left`)return r;let i=r.right.find(e=>e.name===t);if(!i)throw Error(`the workspace has no project ${t}`);let a=i.script();if(a._tag===`Left`)return a;let{script:o}=a.right,s=await ne(e.voice,o);n.titles=i.titles,n.estimates=s.map(e=>e.endFrame/e.sampleRate),n.files.length!==i.chapters&&(n.files=Array.from({length:i.chapters},()=>void 0),n.seconds=[],n.made=[],n.revisions=Array.from({length:i.chapters},()=>0),n.warnings=[]),n.pending=Array.from({length:i.chapters},()=>!0),n.changed();for(let t=n.next();t!==null&&!n.stale&&!n.halted;t=n.next()){let r=o[t];if(r===void 0)throw Error(`the script has no chapter ${String(t)}`);n.doing={what:`Narrating`,index:t},n.changed();let a=[];for(;a.length<r.length&&!(n.stale||n.halted||n.next()!==t);){let i=r[a.length];if(i===void 0)break;n.doing={what:`Narrating`,index:t,cue:{at:a.length,of:r.length}},n.changed(),a.push(await e.voice.speak(i.words,i.speed))}if(a.length<r.length)continue;n.doing={what:`Drawing`,index:t},n.changed();let s=g(r,a),c=i.render(t,s.narration);if(c._tag===`Left`)return c;let{lottie:l,waits:u,warnings:d}=c.right;n.warnings[t]=d,n.publish(t,{...s,samples:ee(s.samples,u)},l),n.pending[t]=!1}return{_tag:`Right`,right:void 0}},a=async(e,t)=>{t.running=!0;try{for(;;){t.stale=!1;let n=await i(e,t);if(t.errors=n._tag===`Left`?n.left:[],t.doing=null,!t.stale||t.halted)break}}finally{t.doing=null,t.running=!1,t.changed()}};return{refresh:e=>{if(!n)for(let[n,r]of t)r.halted||(r.seek(e),r.running?r.stale=!0:a(n,r))},stop:()=>{n=!0;for(let e of t.values())e.halted=!0,e.watcher=null},build:{list:async()=>{let t=await e.workspace.projects();return t._tag===`Left`?t:{_tag:`Right`,right:t.right.map(({name:e,title:t,section:n})=>({name:e,title:t,...n===void 0?{}:{section:n}}))}},watch:(e,i)=>{if(n)return;for(let[n,r]of t)r.halted=n!==e,r.halted&&(r.watcher=null);let o=t.get(e);o?.running!==!0&&(o=new ae(()=>r),t.set(e,o),a(e,o)),o.watcher=i,o.changed()},seek:(e,n)=>{t.get(e)?.seek(n)}}}}var _=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=>!se(e));if(r.length===n.length||r.length===0)return null;let i=r.map(e=>_(e)??e);return i.length===1?i[0]:{...e,[t]:i}},se=e=>typeof e!=`boolean`&&e.type===`null`,v=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),ce=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},le=(e,t)=>{let n=[...e,...t];return n.length>0?`(${ce(n)})`:``},y=e=>e.filter(e=>e.length>0).join(` `),ue=(e,t,n)=>y([le(t,e.path),[e.message,n?`received: ${v(e.received)}`:``].filter(e=>e.length>0).join(`, `)]),de=(e,t)=>{let n=le(t,e.path),r=b(e.errors,[],!1);return y([n,[`Failed to decode one of (${r.length>5?r.slice(0,5).join(` OR `)+` and more...`:r.join(` | `)})`,`received: ${v(e.received)}`].filter(e=>e.length>0).join(`, `)])},b=(e,t,n)=>e.map(e=>`isUnionError`in e?de(e,t):ue(e,t,n)),fe=(e,t=[])=>b(e,t,!0).map((e,t,n)=>n.length==1?y([e]):y([`#${t}`,e])).join(` | `),x=Object.getPrototypeOf({});function pe(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)!==x)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])!==x?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 me(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}}pe({mergeArray:me});function S(e,t,n){return[{message:t,path:[...e.path],received:n}]}function he(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 ge(e,t,n,r){if(n==null){w(e,t);let n=S(e,`extra property`,r);return T(e),n}let i=null,a=Math.max(1,Math.floor(t.length/3));for(let e of n){let n=he(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(`, `);w(e,t);let c=S(e,`extra property.${o} Allowed: ${s}`,r);return T(e),c}function C(e,t,n,r,i){r.validate(e,i)||(w(e,n),t.push(...r.reportDecodeError(e,i)),T(e))}function w(e,t){e.path.push(t)}function T(e){e.path.pop()}function _e(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function ve(e,t,n){e[t]=typeof n==`function`?{validator:n}:n}function E(e,t){return e?.description==null?t:{...t,description:e.description}}function D(e){let t=e.replace(/\*\//g,`* /`).split(`
|
|
3
3
|
`);return t.length===1?`/** ${t[0]} */`:[`/**`,...t.map(e=>` * ${e}`),` */`].join(`
|
|
4
|
-
`)}function O(e,t){return t==null?{typeExpr:e}:{typeExpr:e,docText:t}}var k=class{metadata;constructor(e){this.metadata=e}describe(e){return O(this.describeTypeExpr(e),this.metadata?.description)}describeChildren(){return[]}};function A(e,t){return t.describe(e).typeExpr}function
|
|
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){w(e,r);let i=this.properties[r].schema(e),a=_(i);a==null?t[r]=i:(t[r]=a,n.add(r)),T(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})=>{w(e,`[key]`);let r=t.schema(e);T(e),w(e,`[value]`);let i=n.schema(e);return T(e),{type:`object`,additionalProperties:i,propertyNames:r}});if(a.length===0)return E(this.metadata,{...i,additionalProperties:!1});if(Object.keys(t).length===0&&a.length===1){let e=this.indexedPropertiesParser[0].value;return e instanceof
|
|
4
|
+
`)}function O(e,t){return t==null?{typeExpr:e}:{typeExpr:e,docText:t}}var k=class{metadata;constructor(e){this.metadata=e}describe(e){return O(this.describeTypeExpr(e),this.metadata?.description)}describeChildren(){return[]}};function A(e,t){return t.describe(e).typeExpr}function ye(e){return e.docText==null?e.typeExpr:`${D(e.docText)}\n${e.typeExpr}`}function j(e,t){let n=`type ${e} = ${t.typeExpr};`;return t.docText==null?n:`${D(t.docText)}\n${n}`}function be(e){return/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e)||/^(0|[1-9][0-9]*)$/.test(e)?e:JSON.stringify(e)}function M(e,t,n){let r=n instanceof F?`?`:``,i=n.describe(e);return{docText:i.docText,member:`${t}${r}: ${i.typeExpr}`}}function xe(e,t,n){return M(e,`[K in ${A(e,t)}]`,n)}function Se(e){let t=`${e.member};`;return e.docText==null?t:`${D(e.docText)}\n${t}`}function N(e,t){if(e instanceof R)e.collectDescribeRefs(t);else for(let n of e.describeChildren())N(n,t)}var Ce=class extends k{typeName;constructor(e,t){super(e),this.typeName=t}describeTypeExpr(e){return this.typeName}schema(e){return E(this.metadata,{type:this.typeName})}validate(e,t){return typeof t===this.typeName}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return S(e,`expected `+this.typeName,t)}},P=class extends k{constructor(e){super(e)}describeTypeExpr(e){return`any`}schema(e){return E(this.metadata,{})}validate(e,t){return!0}parseAfterValidation(e,t){return t}reportDecodeError(e,t){return S(e,`expected any`,t)}},we=class extends k{constructor(e){super(e)}describeTypeExpr(e){return`never`}schema(e){return E(this.metadata,{anyOf:[]})}validate(e,t){return!1}parseAfterValidation(e,t){throw Error(`unreachable`)}reportDecodeError(e,t){return S(e,`expected never`,t)}},Te=class extends k{itemParser;constructor(e,t){super(e),this.itemParser=t}schema(e){w(e,`[]`);let t=this.itemParser.schema(e);return T(e),E(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 S(e,`expected array`,t);let n=[];for(let r=0;r<t.length;r++)C(e,n,`[${r}]`,this.itemParser,t[r]);return n}describeTypeExpr(e){return`Array<${A(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 Ee=class extends k{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 M(e,be(t),n)}),n=this.indexedPropertiesParser.map(({key:t,value:n})=>xe(e,t,n)),r=[...t,...n];return r.some(e=>e.docText!=null)?r.length===0?`{}`:`{\n${r.map(Se).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){w(e,r);let i=this.properties[r].schema(e),a=_(i);a==null?t[r]=i:(t[r]=a,n.add(r)),T(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})=>{w(e,`[key]`);let r=t.schema(e);T(e),w(e,`[value]`);let i=n.schema(e);return T(e),{type:`object`,additionalProperties:i,propertyNames:r}});if(a.length===0)return E(this.metadata,{...i,additionalProperties:!1});if(Object.keys(t).length===0&&a.length===1){let e=this.indexedPropertiesParser[0].value;return e instanceof we?E(this.metadata,{type:`object`,additionalProperties:!1}):e instanceof P?E(this.metadata,{...a[0],additionalProperties:!0}):E(this.metadata,a[0])}return E(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 S(e,`expected object`,t);let n=[],r=Object.keys(this.properties);for(let i of r)C(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(w(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)}T(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=>ge(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))}},R=class extends k{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),N(this.getNamedRuntypes()[t],e),e.activeRefs.delete(t))}describe(e){let t=this.refName,n=this.getNamedRuntypes()[this.refName],r=()=>O(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:O(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 E(this.metadata,{$ref:r.getRef(t)})}if(e.seen[t])return E(this.metadata,{});e.seen[t]=!0;var r=n.schema(e);return delete e.seen[t],E(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)}},De=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=fe(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};N(this._runtype,e);let t=this._runtype.describe(e),n=Object.keys(e.definitions).sort().map(t=>[t,e.definitions[t]]).map(([e,t])=>j(e,t)).join(`
|
|
6
6
|
|
|
7
|
-
`);return this.hideTypeNameInDescribe?[n,
|
|
7
|
+
`);return this.hideTypeNameInDescribe?[n,ye(t)].filter(e=>e!=null&&e.length>0).join(`
|
|
8
8
|
|
|
9
9
|
`):[n,j(`Codec${this.name}`,t)].filter(e=>e!=null&&e.length>0).join(`
|
|
10
10
|
|
|
11
|
-
`)}},
|
|
12
|
-
workspace packages.`},{exports:new F(
|
|
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
|
|
14
|
-
`),[f]=await Promise.all([
|
|
15
|
-
`)));let a=r(`button`,`reload`,`Reload`);a.addEventListener(`click`,n),i.append(a),e.body.replaceChildren(i)}var
|
|
11
|
+
`)}},Oe=(e,t,n)=>new De(e,t,n),ke=(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];_e(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];ve(e.numberFormatters,t,n)});let i={};for(let t of Object.keys(e.parsers))i[t]=Oe(e.parsers[t],t,!1);return i},Ae=[],je=[],z={},Me={},Ne={},Pe=new R(void 0,`PackageJson`,z),Fe=new P(void 0),B=new Ce(void 0,`string`),Ie=new Te(void 0,B),Le=new Ee({description:`The part of a package.json that aula reads: how a package names its module and its
|
|
12
|
+
workspace packages.`},{exports:new F(Fe),main:new F(B),module:new F(B),name:new F(B),workspaces:new F(Ie)},[]);Object.assign(z,{PackageJson:Le});var Re={PackageJson:Pe},ze={buildParsers:e=>ke({parsers:Re,stringFormatters:Me,numberFormatters:Ne,requiredStringFormats:Ae,requiredNumberFormats:je},e)}.buildParsers(),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 Be=new Map([[`ts`,`ts`],[`mts`,`ts`],[`js`,`js`],[`mjs`,`js`],[`json`,`json`]]),Ve=e=>Be.get(e.slice(e.lastIndexOf(`.`)+1))??`ts`;function He(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 Je(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:Ve(t.path)}})}}}function Ue(e){return typeof e==`object`&&!!e&&typeof Reflect.get(e,`text`)==`string`}var We=({text:e,location:t})=>({severity:`error`,message:e,...t?{location:{file:t.file.replace(V,``),line:t.line,col:t.column+1}}:{},stack:[],related:[]});async function Ge(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:[He(t,r)]})}catch(e){let t=typeof e==`object`&&e?Reflect.get(e,`errors`):void 0;if(Array.isArray(t)&&t.every(Ue))return{_tag:`Left`,left:t.map(We)};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 Ke(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=ze.PackageJson.safeParse(JSON.parse(t));return n.success?n.data:null}async function qe(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 Je(e,t,n){let r=await Ke(e,t,n);if(r!==null)return r;let{name:i,subpath:a}=G(t);for(let t of await qe(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 Ye(e){let t=Y(e).replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}var X=(e,t)=>e<t?-1:+(e>t);function Xe(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 Ze(e,t){return(await e.list(t)).filter(e=>e!==`node_modules`&&!e.startsWith(`.`)).toSorted(Xe)}var Z=async(e,t)=>await e.read(t)!==null;async function Qe(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 Ze(e,``))if(await Z(e,`${t}/index.ts`))n.push({module:`${t}/index.ts`,name:Y(t)});else for(let r of await Ze(e,t)){let i=`${t}/${r}/index.ts`;await Z(e,i)&&n.push({module:i,name:Y(r),section:Ye(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`,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 $e=e=>({frames:e,name:e=>/^[a-z][a-z0-9+.-]*:/.test(e)?void 0:e,exists:()=>!0}),et=(e,t)=>typeof e==`object`&&e?Reflect.get(e,t):void 0,Q=`aula-projects.ts`;async function tt(e,i,a,o,c){let l=await Qe(e,await e.name());if(l._tag===`Left`)return l;let u=l.right.map(e=>e.module);if(u.length===0)throw Error(`no project here: open a folder that has index.ts, or whose subfolders have index.ts`);let d=[...u.map((e,t)=>`import p${String(t)} from ${JSON.stringify(`./${e}`)};`),`export default [${u.map((e,t)=>`p${String(t)}`).join(`, `)}];`].join(`
|
|
14
|
+
`),[f]=await Promise.all([Ge(o,{read:t=>t===Q?Promise.resolve(d):e.read(t),list:t=>e.list(t)},Q,c),s()]);if(f._tag===`Left`)return f;let p=await t(()=>a.load(f.right));if(p._tag===`Left`)return{_tag:`Left`,left:[r(p.left,Q,i)]};let m=et(p.right.exports,`default`);if(!Array.isArray(m))throw Error(`${Q} has no list of projects`);return{_tag:`Right`,right:m.map((e,t)=>{if(!n(e))throw Error(`the default export of ${u[t]??``} is not made by defineProject: write \`export default defineProject({ title, theme, chapters: [ … ] })\``);let{name:r,section:a}=l.right[t]??{name:``};return nt(r,a,e,i)})}}function nt(t,n,r,a){let o=r.chapters.length+1;return{name:t,...n===void 0?{}:{section:n},title:r.title,chapters:o,titles:[r.title,...r.chapters.map(e=>e.heading)],script:()=>{let t=[];for(let n of r.chapters.keys()){let i=e(r,n+1,{host:a});if(i.value===void 0)return{_tag:`Left`,left:i.diagnostics};t.push(i.value)}return{_tag:`Right`,right:{script:c(r,t)}}},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:s,diagnostics:c}=n.value;return{_tag:`Right`,right:{lottie:o,waits:s,warnings:c}}}}}function rt(e){return e}function it(e,t){return Object.assign({},e,t)}function at(e,t){return{...e,...t}}function ot(...e){return Object.assign({},...e)}var st={create:rt,extend:it,merge:ot,override:at},ct=class extends Error{constructor(e,t){super(e),this.stack=t}};function lt(e,t,n){return e===``?``:` at ${e}:${String(t)}:${String(n)}`}var $=e=>`${e.file}:${String(e.line)}:${String(e.col)}`;function ut(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 dt(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 ft=2e5;function pt(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>ft&&(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 mt(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 ht=e=>e.map(e=>({...e,text:d(e)}));function gt(e){let t=Reflect.get(e,`text`);if(typeof t!=`string`)throw Error(`a diagnostic with no text: ${e.message}`);return t}export{ct as a,dt as c,$e as d,V as f,u as h,pt as i,st as l,ie as m,ht as n,ut as o,oe as p,mt as r,lt as s,gt as t,tt as u};
|