@beff/aula-cli 0.11.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.
Files changed (44) hide show
  1. package/README.md +6 -1
  2. package/dist/src/{aula-voice-tts-HPJAJO2Q.js → aula-voice-tts-H2OQFQ5J.js} +1 -1
  3. package/dist/src/aula.js +2 -2
  4. package/dist/src/{chunk-KCGXC2RV.js → chunk-4FWDTPLR.js} +1 -1
  5. package/dist/src/{chunk-XCPBFMEA.js → chunk-D5N3QDDF.js} +1 -1
  6. package/dist/src/{chunk-Y56UHOZ2.js → chunk-F5RPEFZR.js} +2 -0
  7. package/dist/src/{chunk-5ABPFV55.js → chunk-G44UMBPW.js} +2 -2
  8. package/dist/src/{chunk-5TUGYMFH.js → chunk-S6IM5XXK.js} +3 -3
  9. package/dist/src/{chunk-5XVICDLW.js → chunk-THZNJBUF.js} +133 -18
  10. package/dist/src/{chunk-4PZYWKO5.js → chunk-UBVMGS2E.js} +1 -1
  11. package/dist/src/{chunk-3RB5T3CC.js → chunk-UQOXT6QN.js} +109 -87
  12. package/dist/src/{chunk-DFXG2P7A.js → chunk-WV2UYZND.js} +12 -7
  13. package/dist/src/chunk-XIVHJMET.js +111 -0
  14. package/dist/src/cli.js +29 -93
  15. package/dist/src/{commands-BUM4AG3N.js → commands-PLST75CP.js} +11 -10
  16. package/dist/src/problems-EI4DOEZ4.js +17 -0
  17. package/dist/src/project-7EROVEUE.js +16 -0
  18. package/dist/src/run-NE5HOAXA.js +235 -0
  19. package/dist/src/{server-ALRN2C2W.js → server-KXIU66BB.js} +35 -23
  20. package/dist/src/{site-A2I4P4GX.js → site-HUWODSZ3.js} +21 -77
  21. package/dist/src/workspace-load-DOHFEZFR.js +16 -0
  22. package/dist/web/app/assets/{56cf58c4 → 62289de9}/aula-method.js +1 -1
  23. package/dist/web/app/assets/{56cf58c4 → 62289de9}/aula.js +1 -1
  24. package/dist/web/app/assets/62289de9/build-worker.js +2 -0
  25. package/dist/web/app/assets/{56cf58c4 → 62289de9}/index.js +2 -2
  26. package/dist/web/app/assets/{protocol-C3Pseh4g.js → protocol-kcdbhuRm.js} +4 -4
  27. package/dist/web/app/assets/{src-DTLT9Lbm.js → src-DWqZcp-P.js} +1 -1
  28. package/dist/web/app/assets/{tex-mathjax-8QilZX4j.js → tex-mathjax-eWNptbJg.js} +1 -1
  29. package/dist/web/app/index.html +3 -3
  30. package/dist/web/site/assets/{82624cbe → 82618540}/aula-method.js +1 -1
  31. package/dist/web/site/assets/{82624cbe → 82618540}/aula.js +1 -1
  32. package/dist/web/site/assets/82618540/build-worker.js +2 -0
  33. package/dist/web/site/assets/{82624cbe → 82618540}/index.js +2 -2
  34. package/dist/web/site/assets/{protocol-BOv1ch3F.js → protocol-XMWr-E-D.js} +4 -4
  35. package/dist/web/site/assets/{src-DpS3WA7l.js → src-DfPcHwz-.js} +1 -1
  36. package/dist/web/site/assets/{tex-mathjax-CVHS5J80.js → tex-mathjax-DrZV_cwB.js} +1 -1
  37. package/dist/web/site/index.html +3 -3
  38. package/package.json +1 -1
  39. package/dist/src/chunk-JWBPHDVP.js +0 -104
  40. package/dist/src/problems-2IXR6RUV.js +0 -18
  41. package/dist/src/project-36YBXKCD.js +0 -16
  42. package/dist/src/run-YLF62D3C.js +0 -173
  43. package/dist/web/app/assets/56cf58c4/build-worker.js +0 -2
  44. package/dist/web/site/assets/82624cbe/build-worker.js +0 -2
@@ -2,37 +2,26 @@ import {
2
2
  PACKAGE
3
3
  } from "./chunk-A5QHTZKT.js";
4
4
  import {
5
- createNodeBundler,
6
- nodeTree
7
- } from "./chunk-THQ5Y74K.js";
8
- import {
9
- loadBuiltProjects,
10
- workspaceHost
11
- } from "./chunk-5XVICDLW.js";
12
- import "./chunk-JWBPHDVP.js";
5
+ resolveRootProjects
6
+ } from "./chunk-XIVHJMET.js";
7
+ import "./chunk-THQ5Y74K.js";
8
+ import "./chunk-THZNJBUF.js";
13
9
  import {
14
10
  AULA_VOICE_WEIGHTS
15
- } from "./chunk-KCGXC2RV.js";
11
+ } from "./chunk-4FWDTPLR.js";
16
12
  import {
17
- Problems,
18
- bundleWorkspace,
19
- projectModules,
20
13
  wrongArgument
21
- } from "./chunk-DFXG2P7A.js";
22
- import "./chunk-XCPBFMEA.js";
23
- import {
24
- v8Frames
25
- } from "./chunk-Y56UHOZ2.js";
14
+ } from "./chunk-WV2UYZND.js";
15
+ import "./chunk-D5N3QDDF.js";
16
+ import "./chunk-F5RPEFZR.js";
26
17
  import {
27
18
  fault
28
19
  } from "./chunk-VX7UVLQW.js";
29
20
  import "./chunk-CZ7CSFO4.js";
30
21
 
31
22
  // src/site.ts
32
- import { existsSync } from "node:fs";
33
- import os from "node:os";
34
23
  import path from "node:path";
35
- import { fileURLToPath, pathToFileURL } from "node:url";
24
+ import { fileURLToPath } from "node:url";
36
25
  var PAGE = new URL("web/site/", PACKAGE);
37
26
  var PAGE_FOLDER = fileURLToPath(PAGE);
38
27
  var WRITTEN = ["index.html", "assets", "bundle.json", "media", "tree", "tree.json"];
@@ -62,38 +51,11 @@ async function mediaFiles(capabilities, folder, projects) {
62
51
  const inProject = (file) => folders.some((own) => own === "." || file.startsWith(`${own}/`));
63
52
  return (await walk(capabilities, folder)).filter((file) => MEDIA_FILE.test(file) && inProject(file)).toSorted();
64
53
  }
65
- var METHOD_STUB = "export const paragraph = () => () => ({});\n";
66
- async function listVideos(capabilities, workspaceBundle) {
67
- const scratch = await capabilities.fs.mkdtemp(path.join(os.tmpdir(), "aula-site-videos-"));
68
- let count = 0;
69
- try {
70
- const method = path.join(scratch, "aula-method.mjs");
71
- await capabilities.fs.writeFile(method, METHOD_STUB);
72
- const bundledAula = path.join(path.dirname(fileURLToPath(import.meta.url)), "aula.js");
73
- const player = {
74
- "@beff/aula": existsSync(bundledAula) ? pathToFileURL(bundledAula).href : import.meta.resolve("@beff/aula"),
75
- "@beff/aula-method": pathToFileURL(method).href
76
- };
77
- const modules = {
78
- load: async ({ code }) => {
79
- count += 1;
80
- const file = path.join(scratch, `bundle-${String(count)}.mjs`);
81
- await capabilities.fs.writeFile(file, code);
82
- const url = pathToFileURL(file).href;
83
- return { url, exports: await import(url) };
84
- }
85
- };
86
- const loaded = await loadBuiltProjects(workspaceBundle, workspaceHost(v8Frames), modules, player);
87
- if (loaded._tag === "Left") throw new Problems(loaded.left);
88
- return loaded.right.map(({ name: projectName, title, section }) => ({
89
- name: projectName,
90
- title,
91
- ...section === void 0 ? {} : { section }
92
- }));
93
- } finally {
94
- await capabilities.fs.rm(scratch, { recursive: true, force: true });
95
- }
96
- }
54
+ var videosOf = (projects) => projects.map(({ name: projectName, title, section }) => ({
55
+ name: projectName,
56
+ title,
57
+ ...section === void 0 ? {} : { section }
58
+ }));
97
59
  async function pageFiles(capabilities) {
98
60
  if (!capabilities.fs.existsSync(new URL("index.html", PAGE))) {
99
61
  fault("the site page is not built", "run `pnpm --filter aula-web-pages build`");
@@ -105,37 +67,19 @@ var inside = (outer, inner) => {
105
67
  return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
106
68
  };
107
69
  async function site(capabilities, options) {
108
- const { folder, out, title, base } = options;
70
+ const { folder, out, title, base, includeDrafts = false } = options;
109
71
  if (!capabilities.fs.existsSync(folder) || !(await capabilities.fs.stat(folder)).isDirectory()) {
110
- throw wrongArgument(`${folder} is not a folder`, "give the playlist folder: the folder of the projects");
72
+ throw wrongArgument(`${folder} is not a folder`, "give a project or playlist folder");
111
73
  }
112
74
  if (inside(folder, out) || inside(out, folder)) {
113
75
  throw wrongArgument(
114
- "the output folder and the playlist folder hold each other",
115
- "give an output folder that is outside the playlist folder"
76
+ "the output folder and the root folder hold each other",
77
+ "give an output folder that is outside the root folder"
116
78
  );
117
79
  }
118
- const tree = nodeTree(capabilities, folder);
119
- const folderName = path.basename(folder);
120
- const listed = await projectModules(tree, folderName);
121
- if (listed._tag === "Left") throw new Problems(listed.left);
122
- if (listed.right.length === 0) {
123
- throw wrongArgument(
124
- `no project in ${folder}`,
125
- "give a folder that has index.ts, or whose subfolders have index.ts"
126
- );
127
- }
128
- const bundler = createNodeBundler();
129
- let workspaceBundle;
130
- let videos;
131
- try {
132
- const bundled = await bundleWorkspace(bundler, tree, folderName);
133
- if (bundled._tag === "Left") throw new Problems(bundled.left);
134
- workspaceBundle = bundled.right.bundle;
135
- videos = await listVideos(capabilities, workspaceBundle);
136
- } finally {
137
- await bundler.stop();
138
- }
80
+ const { projects, bundle: workspaceBundle } = await resolveRootProjects(capabilities, folder, includeDrafts);
81
+ if (projects.length === 0) return true;
82
+ const videos = videosOf(projects);
139
83
  const media = await mediaFiles(capabilities, folder, workspaceBundle.projects);
140
84
  const bundleJson = JSON.stringify({ ...workspaceBundle, videos, media });
141
85
  const weights = await capabilities.weights();
@@ -0,0 +1,16 @@
1
+ import {
2
+ resolveOneProject,
3
+ resolveRootProjects
4
+ } from "./chunk-XIVHJMET.js";
5
+ import "./chunk-THQ5Y74K.js";
6
+ import "./chunk-THZNJBUF.js";
7
+ import "./chunk-4FWDTPLR.js";
8
+ import "./chunk-WV2UYZND.js";
9
+ import "./chunk-D5N3QDDF.js";
10
+ import "./chunk-F5RPEFZR.js";
11
+ import "./chunk-VX7UVLQW.js";
12
+ import "./chunk-CZ7CSFO4.js";
13
+ export {
14
+ resolveOneProject,
15
+ resolveRootProjects
16
+ };
@@ -1,2 +1,2 @@
1
- import{f as e}from"../src-DTLT9Lbm.js";import"./aula.js";var t=e=>JSON.stringify(e);function n(e){return!/\s/.test(e)&&!e.includes(`://`)&&/[/.]/.test(e)}function r(e,t){if(t.length!==1||t.raw.length!==1)throw Error(`${e}: a \${…} is not allowed in this tag`);let n=t[0]??``;if(n.includes(`
1
+ import{f as e}from"../src-DWqZcp-P.js";import"./aula.js";var t=e=>JSON.stringify(e);function n(e){return!/\s/.test(e)&&!e.includes(`://`)&&/[/.]/.test(e)}function r(e,t){if(t.length!==1||t.raw.length!==1)throw Error(`${e}: a \${…} is not allowed in this tag`);let n=t[0]??``;if(n.includes(`
2
2
  `))throw Error(`${e}: the text must be one line`);return n}function i(e,r,i){let a=[],o=(t,n,r=e.place)=>{a.push({code:t,message:n,...r===void 0?{}:{at:r}})};i.mechanism.trim()===``&&o(`method-no-mechanism`,`the paragraph has no mechanism: name the one mechanism that the viewer must understand`);for(let e of i.sources)n(e)&&!r.exists(e)&&o(`method-missing-source`,`${t(e)}: this path is not a file: correct the path or add the file`);return a}function a(t){let n=r(`paragraph`,t);return({sources:t},r)=>e({mechanism:n,sources:t},(e,a)=>[...i(e,a,{mechanism:n,sources:t}),...r?.(e,a)??[]])}export{a as paragraph};
@@ -1 +1 @@
1
- export{c as defineChapter,l as defineProject,u as embed,y as loadEngine,o as m,f as paragraph,p as pronounce,m as say,h as show}from"../src-DTLT9Lbm.js";
1
+ export{c as defineChapter,l as defineProject,u as embed,y as loadEngine,o as m,f as paragraph,p as pronounce,m as say,h as show}from"../src-DWqZcp-P.js";
@@ -0,0 +1,2 @@
1
+ import{r as e,t}from"../rolldown-runtime-BLXQ4ufn.js";import{_ as n,a as r,d as i,f as a,g as o,i as s,l as c,m as l,n as u,o as d,p as f,u as p}from"../protocol-kcdbhuRm.js";import{S as m,g as h,v as g,y as _}from"../src-DWqZcp-P.js";var v=44,y=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,b=new Uint8Array(64),x=new Uint8Array(128);for(let e=0;e<y.length;e++){let t=y.charCodeAt(e);b[e]=t,x[t]=e}function S(e){let t=0,n=0,r=0;do r=x[e.next()],t|=(r&31)<<n,n+=5;while(r&32);return t}function C(e){return e&1?-0x80000000|-(e>>>1):e>>>1}function w(e,t){return e.pos>=t?!1:e.peek()!==v}var ee=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 te(e){let{length:t}=e,n=new ee(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+=C(S(n)),i<u&&(l=!1),u=i,w(n,e)?(a+=C(S(n)),o+=C(S(n)),s+=C(S(n)),w(n,e)?(c+=C(S(n)),r=[i,a,o,s,c]):r=[i,a,o,s]):r=[i],t.push(r),n.pos++}l||T(t),r.push(t),n.pos=e+1}while(n.pos<=t);return r}function T(e){e.sort(E)}function E(e,t){return e[0]-t[0]}var ne=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 re(e,t){let n=D(e),r=t?t+`/`:``;return e=>(0,ne.default)(r+(e||``),n)}var O=0,ie=1,ae=2,k=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][O]<e[t-1][O])return!1;return!0}function P(e,t){return t||(e=e.slice()),e.sort(F)}function F(e,t){return e[O]-t[O]}var I=!1;function L(e,t,n,r){for(;n<=r;){let i=n+(r-n>>1),a=e[i][O]-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][O]===t;n=r++);return n}function z(e,t,n){for(let r=n-1;r>=0&&e[r][O]===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][O]===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)",oe="`column` must be greater than or equal to 0 (columns start at column 0)",W=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=re(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=te(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(oe);let a=K(e);if(n>=a.length)return J(null,null,null,null);let o=a[n],s=se(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[ie]],c[ae]+1,c[k],c.length===5?l[c[A]]:null)}function J(e,t,n,r){return{source:e,line:t,column:n,name:r}}function se(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 ce(e,t,n){Y.set(e,{map:new W(t),prefix:n})}function le(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=n(le);function ue(e){let t=0,n=new Map;e.then(e=>{e.addEventListener(`message`,t=>{let i=t.data;if(i.kind===`error`)throw e.close(),new r(`the narrator stopped: ${i.message}`,i.stack);let a=n.get(i.id);n.delete(i.id),a?.(i)}),e.start()});let i=async(r,i)=>{let a=await e;return new Promise(e=>{let o=t++;n.set(o,e),a.postMessage({id:o,kind:r,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 de(e){let t=0,n=0,r=!1,l=new Map,d=n=>{let r=r=>{let i=t++,{promise:a,resolve:o}=Promise.withResolvers();return l.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}}},m=async()=>{let t=d(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(),_().then(async()=>{await g(),e.post({kind:`stage`,stage:`engine`},[])})]),u,m=!1;if(l!==null){if(l._tag===`Left`)return e.post({kind:`stage`,stage:`project`},[]),l;m=l.right.includeDrafts===!0,u=await i(l.right,f(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},i=await e.bundler();u=await a(r,f(X,c),e.modules,i,e.player)}if(e.post({kind:`stage`,stage:`project`},[]),u._tag===`Left`)return u;u={_tag:`Right`,right:p(u.right,{includeDrafts:m})},r||(r=!0,e.post({kind:`narrator`},[]));let v=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:u.right.map(e=>{let t=new Set;return{...e,readScript:async()=>(await h(),v(()=>e.script())),readChapter:async n=>{t.has(n)||(await h(),await v(()=>e.walk?.(n)),t.add(n))}}})}},v=Promise.withResolvers(),y=o(c.create({voice:ue(v.promise),workspace:{projects:m}})),b=[],x=(t,{chapters:n,...r})=>{let i=[],a=[],o=[];n.forEach((e,t)=>{let n=b[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,...o}=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,{...o,lottie:s(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();o.push(i.buffer),a.push({chapter:t,cue:n,samples:i})})}),b=n;let c={building:r.building,timeline:r.timeline,duration:r.duration,errors:u(r.errors)};e.post({kind:`state`,watch:t,state:c,count:n.length,drawings:i,sounds:a},o)};return t=>{switch(t.kind){case`list`:y.build.list().then(n=>{let r=n._tag===`Left`?{_tag:`Left`,left:u(n.left)}:n;e.post({kind:`listed`,id:t.id,videos:r},[])});return;case`watch`:b=[],y.build.watch(t.name,{changed:e=>{x(t.watch,e)}});return;case`seek`:y.build.seek(t.name,t.place);return;case`halt`:y.halt();return;case`refresh`:y.refresh(t.place);return;case`files`:{let e=l.get(t.id);l.delete(t.id),e?.(t.answer);return}case`narrator`:v.resolve(t.port);return}}}var Z=(e,t=[])=>{self.postMessage(e,{transfer:t})},Q=e=>{let t=d(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 fe={"@beff/aula":new URL(`./aula.js`,import.meta.url).href,"@beff/aula-method":new URL(`./aula-method.js`,import.meta.url).href},pe={load:async({code:e,map:t})=>{let n=URL.createObjectURL(new Blob([e],{type:`text/javascript`}));return ce(n,t,l),{url:n,exports:await import(n)}}},$=null;function me(){return $??=(async()=>{let t=performance.now(),[n,r]=await Promise.all([m(()=>import(`../browser-sNTR4ahh.js`).then(t=>e(t.default,1)),[]),m(()=>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 he=de({post:Z,bundler:me,modules:pe,player:fe});self.addEventListener(`message`,e=>{he(e.data)});