@beff/aula-cli 0.4.3 → 0.5.1
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/dist/src/aula-render.core.wasm +0 -0
- package/dist/src/{chunk-7KT36JRP.js → chunk-2NMVSQG4.js} +83 -93
- package/dist/src/{chunk-46KT47TH.js → chunk-5VYKT646.js} +1 -1
- package/dist/src/chunk-A5QHTZKT.js +6 -0
- package/dist/src/{chunk-CIFP475T.js → chunk-DQ2NGXNI.js} +6 -321
- package/dist/src/chunk-EQ3DVZV5.js +15 -0
- package/dist/src/chunk-IKKANHTF.js +94 -0
- package/dist/src/chunk-JDXHKYLZ.js +369 -0
- package/dist/src/chunk-JVCECTG2.js +77 -0
- package/dist/src/{chunk-BT3Z5CJI.js → chunk-YBHISJLN.js} +70 -31
- package/dist/src/cli.js +12 -7
- package/dist/src/{commands-QCUCX2GF.js → commands-34YCDSR5.js} +8 -5
- package/dist/src/{problems-7BVC64RO.js → problems-U4QXN6RO.js} +4 -2
- package/dist/src/project-WS7P5VIH.js +12 -0
- package/dist/src/render-child.js +284 -9
- package/dist/src/{run-5WC5WRZ2.js → run-7PM6EPND.js} +45 -9
- package/dist/src/{server-GK3EWFX3.js → server-YQYW4FT4.js} +6 -5
- package/dist/src/site-SVNNSF72.js +139 -0
- package/dist/web/app/assets/__vite-browser-external-CJXyzDbj.js +1 -0
- package/dist/web/app/assets/aula-voice-worker-Ca14p_J5.js +52 -0
- package/dist/web/app/assets/{aula.core5-Bnq4-bLp.wasm → aula.core5-BsYwXoy8.wasm} +0 -0
- package/dist/web/app/assets/{ebd381c3 → b274e91c}/aula-method.js +1 -1
- package/dist/web/app/assets/b274e91c/aula.js +1 -0
- package/dist/web/app/assets/{ebd381c3 → b274e91c}/build-worker.js +2 -2
- package/dist/web/app/assets/b274e91c/index.js +52 -0
- package/dist/web/app/assets/{index-C_rGCAZR.css → index-BXxc0ZmT.css} +1 -1
- package/dist/web/app/assets/protocol-BejjzB3o.js +15 -0
- package/dist/web/app/assets/src-BA-sYAmS.js +25 -0
- package/dist/web/app/index.html +4 -4
- package/dist/web/site/assets/27f0d05e/aula-method.js +1 -0
- package/dist/web/site/assets/27f0d05e/aula.js +1 -0
- package/dist/web/site/assets/27f0d05e/build-worker.js +696 -0
- package/dist/web/site/assets/27f0d05e/index.js +52 -0
- package/dist/web/site/assets/__vite-browser-external-BtQTJ51O.js +1 -0
- package/dist/web/site/assets/__vite-browser-external-CHF7v6EZ.js +1 -0
- package/dist/web/site/assets/aula-voice-worker-CaLJBS98.js +54 -0
- package/dist/web/site/assets/aula.core-BtiPQSZi.wasm +0 -0
- package/dist/web/site/assets/aula.core5-BsYwXoy8.wasm +0 -0
- package/dist/web/site/assets/esbuild-BaXVPFT2.wasm +0 -0
- package/dist/web/site/assets/index-Dn5gqwRn.css +2 -0
- package/dist/web/site/assets/protocol-fozbK8HD.js +15 -0
- package/dist/web/site/assets/rolldown-runtime-BLXQ4ufn.js +1 -0
- package/dist/web/site/assets/src-BXUc4CQF.js +25 -0
- package/dist/web/site/index.html +39 -0
- package/package.json +2 -2
- package/dist/src/chunk-GFCJYE75.js +0 -42
- package/dist/src/project-NWT5MDQI.js +0 -11
- package/dist/web/app/assets/__vite-browser-external-BVodma7T.js +0 -1
- package/dist/web/app/assets/aula-voice-worker-D9iPLcHQ.js +0 -52
- package/dist/web/app/assets/ebd381c3/aula.js +0 -1
- package/dist/web/app/assets/ebd381c3/index.js +0 -52
- package/dist/web/app/assets/protocol-B46WpNW5.js +0 -15
- package/dist/web/app/assets/src-nkkXaLup.js +0 -25
|
@@ -5,16 +5,19 @@ import {
|
|
|
5
5
|
preview,
|
|
6
6
|
script,
|
|
7
7
|
timeline
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-JDXHKYLZ.js";
|
|
9
|
+
import "./chunk-DQ2NGXNI.js";
|
|
10
|
+
import "./chunk-IKKANHTF.js";
|
|
10
11
|
import "./chunk-2XGNOG2U.js";
|
|
11
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-EQ3DVZV5.js";
|
|
13
|
+
import "./chunk-YBHISJLN.js";
|
|
12
14
|
import "./chunk-S74JLCZK.js";
|
|
13
15
|
import "./chunk-6LC3WXJ7.js";
|
|
14
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-5VYKT646.js";
|
|
17
|
+
import "./chunk-JVCECTG2.js";
|
|
15
18
|
import {
|
|
16
19
|
wrongArgument
|
|
17
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-2NMVSQG4.js";
|
|
18
21
|
|
|
19
22
|
// src/run.ts
|
|
20
23
|
import path from "node:path";
|
|
@@ -41,6 +44,14 @@ aula web [<folder>] [--port N] the web app for the folder if it has index
|
|
|
41
44
|
the page narrates in the browser
|
|
42
45
|
aula bundle <folder> <file.zip> the project zip: the project folder, and the
|
|
43
46
|
packages it imports, to share or host
|
|
47
|
+
aula site <folder> <out> [--title <text>] [--base <path>]
|
|
48
|
+
a website of the projects of a playlist folder (the
|
|
49
|
+
same projects, order and sections as aula web):
|
|
50
|
+
the folder's files with the packages they import,
|
|
51
|
+
and the web app, as plain files in <out> for any
|
|
52
|
+
static host; --title is the site's title (default:
|
|
53
|
+
the folder's name); --base pins the site to a base
|
|
54
|
+
path such as /aula/ (default: it works at any path)
|
|
44
55
|
aula script <folder> print the narration text with lines
|
|
45
56
|
aula timeline <folder> [<chapter> ...]
|
|
46
57
|
print each say and move with its line, second
|
|
@@ -52,7 +63,9 @@ aula tokens Kokoro v1.0's token ids of texts, for trai
|
|
|
52
63
|
|
|
53
64
|
Errors make the exit code 1. Warnings do not change it.`;
|
|
54
65
|
var VALUED = {
|
|
55
|
-
"--port": "a port number"
|
|
66
|
+
"--port": { what: "a port number", number: true },
|
|
67
|
+
"--title": { what: "a title", number: false },
|
|
68
|
+
"--base": { what: "a base path", number: false }
|
|
56
69
|
};
|
|
57
70
|
function parse(argv, allowed) {
|
|
58
71
|
const args = { positional: [], values: /* @__PURE__ */ new Map(), flags: /* @__PURE__ */ new Set() };
|
|
@@ -62,7 +75,11 @@ function parse(argv, allowed) {
|
|
|
62
75
|
if (what !== void 0 && allowed.includes(arg)) {
|
|
63
76
|
i += 1;
|
|
64
77
|
const value = argv[i];
|
|
65
|
-
if (value === void 0) throw wrongArgument(`${arg} needs ${what}`);
|
|
78
|
+
if (value === void 0) throw wrongArgument(`${arg} needs ${what.what}`);
|
|
79
|
+
if (!what.number) {
|
|
80
|
+
args.values.set(arg, value);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
66
83
|
if (!/^[0-9]+$/.test(value)) throw wrongArgument(`${arg} ${value} is not a number`);
|
|
67
84
|
args.values.set(arg, Number(value));
|
|
68
85
|
} else if (allowed.includes(arg)) {
|
|
@@ -77,7 +94,8 @@ function parse(argv, allowed) {
|
|
|
77
94
|
}
|
|
78
95
|
var OPTIONS = {
|
|
79
96
|
check: ["--json"],
|
|
80
|
-
web: ["--port"]
|
|
97
|
+
web: ["--port"],
|
|
98
|
+
site: ["--title", "--base"]
|
|
81
99
|
};
|
|
82
100
|
var isHelp = (command) => command === void 0 || command === "help" || command === "-h" || command === "--help";
|
|
83
101
|
var ARITY = {
|
|
@@ -118,7 +136,24 @@ async function run(capabilities, cwd, command, project, rest, flags = /* @__PURE
|
|
|
118
136
|
}
|
|
119
137
|
function webOptions(cwd, args) {
|
|
120
138
|
if (args.positional.length > 1) throw wrongArgument("aula web takes one folder", "run `aula help` for the usage");
|
|
121
|
-
|
|
139
|
+
const port = args.values.get("--port");
|
|
140
|
+
return { root: path.resolve(cwd, args.positional[0] ?? "."), port: typeof port === "number" ? port : 0 };
|
|
141
|
+
}
|
|
142
|
+
function siteOptions(cwd, args) {
|
|
143
|
+
const [folder, out, ...more] = args.positional;
|
|
144
|
+
if (folder === void 0 || out === void 0 || more.length > 0)
|
|
145
|
+
throw wrongArgument("aula site takes a playlist folder and an output folder", "run `aula help` for the usage");
|
|
146
|
+
const title = args.values.get("--title");
|
|
147
|
+
const base = args.values.get("--base");
|
|
148
|
+
if (typeof base === "string" && !(base.startsWith("/") && base.endsWith("/")))
|
|
149
|
+
throw wrongArgument(`--base ${base} must start and end with /`, "for example --base /aula/");
|
|
150
|
+
const root = path.resolve(cwd, folder);
|
|
151
|
+
return {
|
|
152
|
+
folder: root,
|
|
153
|
+
out: path.resolve(cwd, out),
|
|
154
|
+
title: typeof title === "string" ? title : path.basename(root),
|
|
155
|
+
base: typeof base === "string" ? base : null
|
|
156
|
+
};
|
|
122
157
|
}
|
|
123
158
|
var optionsOf = (command) => OPTIONS[command] ?? [];
|
|
124
159
|
export {
|
|
@@ -128,5 +163,6 @@ export {
|
|
|
128
163
|
optionsOf,
|
|
129
164
|
parse,
|
|
130
165
|
run,
|
|
166
|
+
siteOptions,
|
|
131
167
|
webOptions
|
|
132
168
|
};
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PACKAGE
|
|
3
|
+
} from "./chunk-A5QHTZKT.js";
|
|
1
4
|
import "./chunk-S74JLCZK.js";
|
|
2
5
|
import {
|
|
3
6
|
SERVER_WEIGHTS_PATH
|
|
4
7
|
} from "./chunk-6LC3WXJ7.js";
|
|
5
8
|
import {
|
|
6
9
|
exists
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-5VYKT646.js";
|
|
11
|
+
import "./chunk-JVCECTG2.js";
|
|
12
|
+
import "./chunk-2NMVSQG4.js";
|
|
9
13
|
|
|
10
14
|
// src/web/server.ts
|
|
11
15
|
import { once } from "node:events";
|
|
@@ -13,9 +17,6 @@ import { createServer } from "node:http";
|
|
|
13
17
|
import { basename, dirname, join } from "node:path";
|
|
14
18
|
import { AulaError } from "@beff/aula/errors";
|
|
15
19
|
|
|
16
|
-
// src/package.ts
|
|
17
|
-
var PACKAGE = new URL("../", import.meta.url);
|
|
18
|
-
|
|
19
20
|
// src/web/page.ts
|
|
20
21
|
import { fault } from "@beff/aula/errors";
|
|
21
22
|
var APP = new URL("web/app/", PACKAGE);
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
diskTree,
|
|
3
|
+
packageFiles
|
|
4
|
+
} from "./chunk-DQ2NGXNI.js";
|
|
5
|
+
import "./chunk-YBHISJLN.js";
|
|
6
|
+
import {
|
|
7
|
+
PACKAGE
|
|
8
|
+
} from "./chunk-A5QHTZKT.js";
|
|
9
|
+
import "./chunk-S74JLCZK.js";
|
|
10
|
+
import {
|
|
11
|
+
AULA_VOICE_WEIGHTS
|
|
12
|
+
} from "./chunk-6LC3WXJ7.js";
|
|
13
|
+
import {
|
|
14
|
+
Problems,
|
|
15
|
+
projectModules,
|
|
16
|
+
wrongArgument
|
|
17
|
+
} from "./chunk-2NMVSQG4.js";
|
|
18
|
+
|
|
19
|
+
// src/site.ts
|
|
20
|
+
import path from "node:path";
|
|
21
|
+
import { fileURLToPath } from "node:url";
|
|
22
|
+
import { fault } from "@beff/aula/errors";
|
|
23
|
+
var PAGE = new URL("web/site/", PACKAGE);
|
|
24
|
+
var PAGE_FOLDER = fileURLToPath(PAGE);
|
|
25
|
+
var WRITTEN = ["index.html", "assets", "tree", "tree.json", AULA_VOICE_WEIGHTS.path];
|
|
26
|
+
var escapeHtml = (text) => text.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """);
|
|
27
|
+
function pageHtml(html, title, base) {
|
|
28
|
+
const titled = html.replace(/<title>[^<]*<\/title>/, () => `<title>${escapeHtml(title)}</title>`);
|
|
29
|
+
if (base === null) return titled;
|
|
30
|
+
return titled.replace("<head>", () => `<head>
|
|
31
|
+
<base href="${escapeHtml(base)}" />`);
|
|
32
|
+
}
|
|
33
|
+
async function walk(capabilities, folder, from = "") {
|
|
34
|
+
const found = [];
|
|
35
|
+
const entries = await capabilities.fs.readdir(path.join(folder, from), { withFileTypes: true });
|
|
36
|
+
for (const entry of entries.toSorted((a, b) => a.name < b.name ? -1 : 1)) {
|
|
37
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
38
|
+
const at = from === "" ? entry.name : `${from}/${entry.name}`;
|
|
39
|
+
const stat = await capabilities.fs.stat(path.join(folder, at));
|
|
40
|
+
if (stat.isDirectory()) found.push(...await walk(capabilities, folder, at));
|
|
41
|
+
else if (stat.isFile()) found.push(at);
|
|
42
|
+
}
|
|
43
|
+
return found;
|
|
44
|
+
}
|
|
45
|
+
var sameBytes = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
|
|
46
|
+
var packageOf = (at) => /^node_modules\/(?:@[^/]+\/)?[^/]+/.exec(at)?.[0] ?? at;
|
|
47
|
+
async function differs(capabilities, files, at, source) {
|
|
48
|
+
const kept = files.get(at);
|
|
49
|
+
if (kept === void 0 || kept === source) return false;
|
|
50
|
+
const [a, b] = await Promise.all([capabilities.fs.readFile(kept), capabilities.fs.readFile(source)]);
|
|
51
|
+
return !sameBytes(new Uint8Array(a), new Uint8Array(b));
|
|
52
|
+
}
|
|
53
|
+
async function packages(capabilities, folder, modules) {
|
|
54
|
+
const root = path.parse(folder).root;
|
|
55
|
+
const home = path.relative(root, folder).split(path.sep).join("/");
|
|
56
|
+
const tree = diskTree(capabilities, root);
|
|
57
|
+
const files = /* @__PURE__ */ new Map();
|
|
58
|
+
const esbuild = await import("esbuild-wasm");
|
|
59
|
+
try {
|
|
60
|
+
for (const { module } of modules) {
|
|
61
|
+
const own = path.posix.dirname(module);
|
|
62
|
+
const project = own === "." ? home : `${home}/${own}`;
|
|
63
|
+
const found = await packageFiles(esbuild, tree, project);
|
|
64
|
+
if (found._tag === "Left") throw new Problems(found.left);
|
|
65
|
+
const apart = /* @__PURE__ */ new Set();
|
|
66
|
+
for (const [at, from] of found.right) {
|
|
67
|
+
if (await differs(capabilities, files, at, path.join(root, from))) apart.add(packageOf(at));
|
|
68
|
+
}
|
|
69
|
+
for (const [at, from] of found.right) {
|
|
70
|
+
files.set(apart.has(packageOf(at)) ? `${own}/${at}` : at, path.join(root, from));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} finally {
|
|
74
|
+
await esbuild.stop();
|
|
75
|
+
}
|
|
76
|
+
return files;
|
|
77
|
+
}
|
|
78
|
+
async function pageFiles(capabilities) {
|
|
79
|
+
if (!capabilities.fs.existsSync(new URL("index.html", PAGE))) {
|
|
80
|
+
fault("the site page is not built", "run `pnpm --filter aula-web-pages build`");
|
|
81
|
+
}
|
|
82
|
+
return walk(capabilities, PAGE_FOLDER);
|
|
83
|
+
}
|
|
84
|
+
var inside = (outer, inner) => {
|
|
85
|
+
const relative = path.relative(outer, inner);
|
|
86
|
+
return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
87
|
+
};
|
|
88
|
+
async function site(capabilities, options) {
|
|
89
|
+
const { folder, out, title, base } = options;
|
|
90
|
+
if (!capabilities.fs.existsSync(folder) || !(await capabilities.fs.stat(folder)).isDirectory()) {
|
|
91
|
+
throw wrongArgument(`${folder} is not a folder`, "give the playlist folder: the folder of the projects");
|
|
92
|
+
}
|
|
93
|
+
if (inside(folder, out) || inside(out, folder)) {
|
|
94
|
+
throw wrongArgument(
|
|
95
|
+
"the output folder and the playlist folder hold each other",
|
|
96
|
+
"give an output folder that is outside the playlist folder"
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
const listed = await projectModules(diskTree(capabilities, folder), path.basename(folder));
|
|
100
|
+
if (listed._tag === "Left") throw new Problems(listed.left);
|
|
101
|
+
if (listed.right.length === 0) {
|
|
102
|
+
throw wrongArgument(
|
|
103
|
+
`no project in ${folder}`,
|
|
104
|
+
"give a folder that has index.ts, or whose subfolders have index.ts"
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const own = await walk(capabilities, folder);
|
|
108
|
+
const files = new Map(own.map((file) => [file, path.join(folder, file)]));
|
|
109
|
+
for (const [at, from] of await packages(capabilities, folder, listed.right)) files.set(at, from);
|
|
110
|
+
const weights = await capabilities.weights();
|
|
111
|
+
const page = await pageFiles(capabilities);
|
|
112
|
+
const html = pageHtml(await capabilities.fs.readFile(path.join(PAGE_FOLDER, "index.html"), "utf8"), title, base);
|
|
113
|
+
await capabilities.fs.mkdir(out, { recursive: true });
|
|
114
|
+
for (const name of WRITTEN) await capabilities.fs.rm(path.join(out, name), { recursive: true, force: true });
|
|
115
|
+
let bytes = weights.length + html.length;
|
|
116
|
+
const copy = async (from, to) => {
|
|
117
|
+
const data = await capabilities.fs.readFile(from);
|
|
118
|
+
bytes += data.length;
|
|
119
|
+
await capabilities.fs.mkdir(path.dirname(to), { recursive: true });
|
|
120
|
+
await capabilities.fs.writeFile(to, data);
|
|
121
|
+
};
|
|
122
|
+
for (const file of page) if (file !== "index.html") await copy(path.join(PAGE_FOLDER, file), path.join(out, file));
|
|
123
|
+
for (const [at, from] of files) await copy(from, path.join(out, "tree", at));
|
|
124
|
+
const paths = [...files.keys()].toSorted();
|
|
125
|
+
await capabilities.fs.writeFile(path.join(out, "index.html"), html);
|
|
126
|
+
await capabilities.fs.writeFile(
|
|
127
|
+
path.join(out, "tree.json"),
|
|
128
|
+
JSON.stringify({ name: path.basename(folder), files: paths })
|
|
129
|
+
);
|
|
130
|
+
await capabilities.fs.writeFile(path.join(out, AULA_VOICE_WEIGHTS.path), weights);
|
|
131
|
+
capabilities.log.out(
|
|
132
|
+
`${out}: ${String(listed.right.length)} projects, ${String(files.size)} files, ${String(Math.ceil(bytes / 1024))} kB`
|
|
133
|
+
);
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
export {
|
|
137
|
+
pageHtml,
|
|
138
|
+
site
|
|
139
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./aula-voice-worker-Ca14p_J5.js";var t=/* @__PURE__ */ e(((e,t)=>{t.exports={}}));export default t();
|