pulpweaver4-cli 0.0.0-stage → 0.0.88
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/bridge.d.ts +25 -0
- package/dist/bridge.js +109 -0
- package/dist/bridge.js.map +1 -0
- package/dist/build.d.ts +12 -0
- package/dist/build.js +95 -0
- package/dist/build.js.map +1 -0
- package/dist/chromium.d.ts +83 -0
- package/dist/chromium.js +213 -0
- package/dist/chromium.js.map +1 -0
- package/dist/commands.d.ts +217 -0
- package/dist/commands.js +162 -0
- package/dist/commands.js.map +1 -0
- package/dist/csl.d.ts +8 -0
- package/dist/csl.js +53 -0
- package/dist/csl.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +135 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +13 -0
- package/dist/lint.js +80 -0
- package/dist/lint.js.map +1 -0
- package/dist/new.d.ts +12 -0
- package/dist/new.js +92 -0
- package/dist/new.js.map +1 -0
- package/dist/node-fs.d.ts +17 -0
- package/dist/node-fs.js +78 -0
- package/dist/node-fs.js.map +1 -0
- package/dist/page/host.d.ts +111 -0
- package/dist/page/host.js +202 -0
- package/dist/page/host.js.map +1 -0
- package/dist/page/test-setup.d.ts +11 -0
- package/dist/page/test-setup.js +24 -0
- package/dist/page/test-setup.js.map +1 -0
- package/dist/paint-corpus.d.ts +8 -0
- package/dist/paint-corpus.js +89 -0
- package/dist/paint-corpus.js.map +1 -0
- package/dist/plugin-commands.d.ts +26 -0
- package/dist/plugin-commands.js +49 -0
- package/dist/plugin-commands.js.map +1 -0
- package/dist/plugins.d.ts +23 -0
- package/dist/plugins.js +85 -0
- package/dist/plugins.js.map +1 -0
- package/dist/problems.d.ts +29 -0
- package/dist/problems.js +28 -0
- package/dist/problems.js.map +1 -0
- package/dist/profiles.d.ts +37 -0
- package/dist/profiles.js +224 -0
- package/dist/profiles.js.map +1 -0
- package/dist/pw.d.ts +2 -0
- package/dist/pw.js +4 -0
- package/dist/pw.js.map +1 -0
- package/dist/spike.d.ts +27 -0
- package/dist/spike.js +79 -0
- package/dist/spike.js.map +1 -0
- package/dist/test.d.ts +35 -0
- package/dist/test.js +228 -0
- package/dist/test.js.map +1 -0
- package/docs/README.md +9 -0
- package/docs/reference/commands/build.md +40 -0
- package/docs/reference/commands/index.md +42 -0
- package/docs/reference/commands/lint.md +35 -0
- package/docs/reference/commands/new.md +34 -0
- package/docs/reference/commands/preflight.md +35 -0
- package/docs/reference/commands/profiles.md +57 -0
- package/docs/reference/commands/spike.md +30 -0
- package/docs/reference/commands/test.md +47 -0
- package/package.json +40 -4
- package/template/chapters/01-beginning.dj +14 -0
- package/template/chapters/02-writing.dj +16 -0
- package/template/fonts/CrimsonPro-Italic-VF.ttf +0 -0
- package/template/fonts/CrimsonPro-VF.ttf +0 -0
- package/template/fonts/NotoSansSymbols2-Boxes.ttf +0 -0
- package/template/fonts/OFL.txt +94 -0
- package/template/gitignore +2 -0
- package/template/pulpweaver4.toml +23 -0
- package/template/styles/book.css +109 -0
- package/template/tests/book.test.ts +23 -0
- package/README.md +0 -3
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Page } from 'playwright';
|
|
2
|
+
import type { ChromiumHostOptions } from './chromium.js';
|
|
3
|
+
import type { HostReply } from './page/host.js';
|
|
4
|
+
/** A module beside this one, run from its sources (`.ts`, in the repository's tests) or from `dist/` (`.js`). */
|
|
5
|
+
export declare function sibling(path: string): string;
|
|
6
|
+
/** The page side's module, which `ChromiumHost` bundles with the core as `pw.host`. */
|
|
7
|
+
export declare const PAGE_HOST_MODULE: string;
|
|
8
|
+
/**
|
|
9
|
+
* The server's routes for the project's plugins (`page/host.ts`'s
|
|
10
|
+
* `pluginImporter`): `/project/<path>`, a module in the project's folder,
|
|
11
|
+
* as it is; `/plugins/<name>.js`, an npm plugin, bundled from
|
|
12
|
+
* `node_modules`. The core in each is left to the page.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pluginRoutes(projectDir: string): NonNullable<ChromiumHostOptions['routes']>;
|
|
15
|
+
/** An npm plugin of the project's, bundled from `node_modules` for the browser, with its imports of the core left as they are. */
|
|
16
|
+
export declare function bundlePlugin(projectDir: string, name: string): Promise<string>;
|
|
17
|
+
/**
|
|
18
|
+
* What `page/host.ts` calls: the project's folder, its packages' files, the
|
|
19
|
+
* standard profiles and CSL files, each call's value or error as data.
|
|
20
|
+
* `fetcher` is how CSL files are fetched, Node's `fetch` unless a test
|
|
21
|
+
* serves them.
|
|
22
|
+
*/
|
|
23
|
+
export declare function projectCalls(projectDir: string, env?: NodeJS.ProcessEnv, fetcher?: typeof fetch): (op: string, args: unknown[]) => Promise<HostReply>;
|
|
24
|
+
/** Gives the page the project's folder and the rest of what `page/host.ts` calls, as `pwHostCall`. */
|
|
25
|
+
export declare function exposeProject(page: Page, projectDir: string, env?: NodeJS.ProcessEnv, fetcher?: typeof fetch): Promise<void>;
|
package/dist/bridge.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLI's side of a build in Chromium (`page/host.ts` is the page's): the
|
|
3
|
+
* project's folder as the page's file system, its plugins served to the
|
|
4
|
+
* page (its npm ones bundled), and the standard ICC profiles, fetched once
|
|
5
|
+
* into a cache, which the page can't fetch across origins (`profiles.ts`),
|
|
6
|
+
* and those the user downloaded into it with `pw profiles get`; and the CSL
|
|
7
|
+
* project's styles and locales a project names, fetched once into the same
|
|
8
|
+
* cache (`csl.ts`).
|
|
9
|
+
*/
|
|
10
|
+
import { readFile } from 'node:fs/promises';
|
|
11
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
12
|
+
import { fileURLToPath } from 'node:url';
|
|
13
|
+
import { build } from 'esbuild';
|
|
14
|
+
import { VFSError } from 'pulpweaver4';
|
|
15
|
+
import { NodeFS } from './node-fs.js';
|
|
16
|
+
import { packageDir, packageEntry } from './plugins.js';
|
|
17
|
+
import { cslText } from './csl.js';
|
|
18
|
+
import { cachedProfile, standardProfile } from './profiles.js';
|
|
19
|
+
/** A module beside this one, run from its sources (`.ts`, in the repository's tests) or from `dist/` (`.js`). */
|
|
20
|
+
export function sibling(path) {
|
|
21
|
+
return fileURLToPath(new URL(`${path}${import.meta.url.endsWith('.ts') ? '.ts' : '.js'}`, import.meta.url));
|
|
22
|
+
}
|
|
23
|
+
/** The page side's module, which `ChromiumHost` bundles with the core as `pw.host`. */
|
|
24
|
+
export const PAGE_HOST_MODULE = sibling('./page/host');
|
|
25
|
+
/**
|
|
26
|
+
* The server's routes for the project's plugins (`page/host.ts`'s
|
|
27
|
+
* `pluginImporter`): `/project/<path>`, a module in the project's folder,
|
|
28
|
+
* as it is; `/plugins/<name>.js`, an npm plugin, bundled from
|
|
29
|
+
* `node_modules`. The core in each is left to the page.
|
|
30
|
+
*/
|
|
31
|
+
export function pluginRoutes(projectDir) {
|
|
32
|
+
return async (url) => {
|
|
33
|
+
if (url.startsWith('/project/') && /\.m?js$/.test(url)) {
|
|
34
|
+
return { type: 'text/javascript', body: await readFile(inside(projectDir, url.slice('/project/'.length))) };
|
|
35
|
+
}
|
|
36
|
+
const m = /^\/plugins\/(.+)\.js$/.exec(url);
|
|
37
|
+
if (!m)
|
|
38
|
+
return undefined;
|
|
39
|
+
return { type: 'text/javascript', body: await bundlePlugin(projectDir, decodeURIComponent(m[1])) };
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/** An npm plugin of the project's, bundled from `node_modules` for the browser, with its imports of the core left as they are. */
|
|
43
|
+
export async function bundlePlugin(projectDir, name) {
|
|
44
|
+
const { dir, json } = await packageDir(name, projectDir);
|
|
45
|
+
const bundle = await build({
|
|
46
|
+
entryPoints: [inside(dir, packageEntry(json))],
|
|
47
|
+
bundle: true,
|
|
48
|
+
format: 'esm',
|
|
49
|
+
platform: 'browser',
|
|
50
|
+
target: 'es2023',
|
|
51
|
+
external: ['pulpweaver4', 'pulpweaver4/*'],
|
|
52
|
+
write: false,
|
|
53
|
+
logLevel: 'silent',
|
|
54
|
+
});
|
|
55
|
+
return bundle.outputFiles[0].text;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* What `page/host.ts` calls: the project's folder, its packages' files, the
|
|
59
|
+
* standard profiles and CSL files, each call's value or error as data.
|
|
60
|
+
* `fetcher` is how CSL files are fetched, Node's `fetch` unless a test
|
|
61
|
+
* serves them.
|
|
62
|
+
*/
|
|
63
|
+
export function projectCalls(projectDir, env = process.env, fetcher = fetch) {
|
|
64
|
+
const fs = new NodeFS(projectDir);
|
|
65
|
+
const ops = {
|
|
66
|
+
readFile: async (path) => Buffer.from(await fs.readFile(path)).toString('base64'),
|
|
67
|
+
writeFile: (path, data) => fs.writeFile(path, 'text' in data ? data.text : Buffer.from(data.base64, 'base64')),
|
|
68
|
+
readDir: (path) => fs.readDir(path),
|
|
69
|
+
stat: (path) => fs.stat(path),
|
|
70
|
+
mkdir: (path) => fs.mkdir(path),
|
|
71
|
+
remove: (path) => fs.remove(path),
|
|
72
|
+
packageFile: async (name, path) => {
|
|
73
|
+
const { dir, json } = await packageDir(name, projectDir);
|
|
74
|
+
return readFile(inside(dir, join(dirname(packageEntry(json)), path)), 'utf8');
|
|
75
|
+
},
|
|
76
|
+
standardProfile: async (url, file) => Buffer.from(await standardProfile(url, file, env)).toString('base64'),
|
|
77
|
+
// One the user downloaded with `pw profiles get`, or null: pw never downloads it for a build.
|
|
78
|
+
downloadedProfile: async (file) => {
|
|
79
|
+
const data = await cachedProfile(file, env);
|
|
80
|
+
return data ? Buffer.from(data).toString('base64') : null;
|
|
81
|
+
},
|
|
82
|
+
// A style or locale from the CSL repositories, or null if there is none.
|
|
83
|
+
cslText: async (url) => (await cslText(url, env, fetcher)) ?? null,
|
|
84
|
+
};
|
|
85
|
+
return async (op, args) => {
|
|
86
|
+
try {
|
|
87
|
+
const fn = ops[op];
|
|
88
|
+
if (!fn)
|
|
89
|
+
throw new Error(`pw: no host call ${JSON.stringify(op)}`);
|
|
90
|
+
return { value: await fn(...args) };
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
if (e instanceof VFSError)
|
|
94
|
+
return { error: { message: e.message, code: e.code, path: e.path } };
|
|
95
|
+
return { error: { message: e instanceof Error ? e.message : String(e) } };
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/** Gives the page the project's folder and the rest of what `page/host.ts` calls, as `pwHostCall`. */
|
|
100
|
+
export async function exposeProject(page, projectDir, env = process.env, fetcher = fetch) {
|
|
101
|
+
await page.exposeFunction('pwHostCall', projectCalls(projectDir, env, fetcher));
|
|
102
|
+
}
|
|
103
|
+
function inside(dir, path) {
|
|
104
|
+
const file = resolve(dir, path);
|
|
105
|
+
if (relative(dir, file).split(sep)[0] === '..')
|
|
106
|
+
throw new Error(`${path} is outside the package`);
|
|
107
|
+
return file;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAClC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAE9D,i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.js';
|
|
2
|
+
import type { BuildReport, BuildRequest } from './page/host.js';
|
|
3
|
+
/** Builds the project in `dir` in the core's Chromium host: what `pw build` prints and returns, without printing. */
|
|
4
|
+
export declare function buildProject(dir: string, request: BuildRequest, host?: ChromiumHostOptions, env?: NodeJS.ProcessEnv): Promise<BuildReport>;
|
|
5
|
+
/** `pw build`'s arguments: the project's folder, and the editions. */
|
|
6
|
+
export declare function parseBuildArgs(args: readonly string[]): {
|
|
7
|
+
dir: string;
|
|
8
|
+
editions?: string[];
|
|
9
|
+
} | {
|
|
10
|
+
usage: string;
|
|
11
|
+
};
|
|
12
|
+
export declare function buildCommand(args: readonly string[], out: (line: string) => void, host: ChromiumHostOptions, env: NodeJS.ProcessEnv): Promise<number>;
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pw build [<dir>] [--edition <name>|all]`
|
|
3
|
+
* (https://plans.inkylabs.com/pulpweaver#commands): every edition of the
|
|
4
|
+
* project, or the one named, written to `dist/<edition>/` by the core in
|
|
5
|
+
* headless Chromium (`page/host.ts`'s `buildProject`), its problems printed
|
|
6
|
+
* as a compiler prints them. Any error fails the build.
|
|
7
|
+
*/
|
|
8
|
+
import { stat } from 'node:fs/promises';
|
|
9
|
+
import { join, resolve } from 'node:path';
|
|
10
|
+
import { hasErrors, sortProblems, summarizeProblems } from 'pulpweaver4';
|
|
11
|
+
import { exposeProject, PAGE_HOST_MODULE, pluginRoutes } from './bridge.js';
|
|
12
|
+
import { ChromiumHost } from './chromium.js';
|
|
13
|
+
import { printProblems } from './problems.js';
|
|
14
|
+
/** Builds the project in `dir` in the core's Chromium host: what `pw build` prints and returns, without printing. */
|
|
15
|
+
export async function buildProject(dir, request, host = {}, env = process.env) {
|
|
16
|
+
const chromium = await ChromiumHost.launch({ ...host, extra: { ...host.extra, host: PAGE_HOST_MODULE }, routes: pluginRoutes(dir) });
|
|
17
|
+
try {
|
|
18
|
+
await exposeProject(chromium.page, dir, env, host.fetch);
|
|
19
|
+
return await chromium.page.evaluate((req) => globalThis.pw.host.buildProject(req), request);
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
await chromium.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** `pw build`'s arguments: the project's folder, and the editions. */
|
|
26
|
+
export function parseBuildArgs(args) {
|
|
27
|
+
const editions = [];
|
|
28
|
+
let dir;
|
|
29
|
+
for (let i = 0; i < args.length; i++) {
|
|
30
|
+
const a = args[i];
|
|
31
|
+
if (a === '--edition') {
|
|
32
|
+
const name = args[++i];
|
|
33
|
+
if (!name)
|
|
34
|
+
return { usage: '--edition names an edition, or all' };
|
|
35
|
+
editions.push(name);
|
|
36
|
+
}
|
|
37
|
+
else if (a.startsWith('--edition=')) {
|
|
38
|
+
editions.push(a.slice('--edition='.length));
|
|
39
|
+
}
|
|
40
|
+
else if (a.startsWith('-')) {
|
|
41
|
+
return { usage: `unknown option ${a}` };
|
|
42
|
+
}
|
|
43
|
+
else if (dir === undefined) {
|
|
44
|
+
dir = a;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
return { usage: `one project at a time, not ${dir} and ${a}` };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const all = editions.length === 0 || editions.includes('all');
|
|
51
|
+
return { dir: dir ?? '.', ...(all ? {} : { editions }) };
|
|
52
|
+
}
|
|
53
|
+
export async function buildCommand(args, out, host, env) {
|
|
54
|
+
const parsed = parseBuildArgs(args);
|
|
55
|
+
if ('usage' in parsed) {
|
|
56
|
+
out(`pw build: ${parsed.usage}`);
|
|
57
|
+
return 2;
|
|
58
|
+
}
|
|
59
|
+
const dir = resolve(parsed.dir);
|
|
60
|
+
if (!(await stat(join(dir, 'pulpweaver4.toml')).catch(() => undefined))) {
|
|
61
|
+
out(`pw build: ${parsed.dir} has no pulpweaver4.toml; start a project there with pw new ${parsed.dir}`);
|
|
62
|
+
return 2;
|
|
63
|
+
}
|
|
64
|
+
const report = await buildProject(dir, {
|
|
65
|
+
...(parsed.editions ? { editions: parsed.editions } : {}),
|
|
66
|
+
...(env['SOURCE_DATE_EPOCH'] !== undefined && env['SOURCE_DATE_EPOCH'] !== '' ? { sourceDateEpoch: env['SOURCE_DATE_EPOCH'] } : {}),
|
|
67
|
+
}, host, env);
|
|
68
|
+
if (report.refused !== undefined) {
|
|
69
|
+
out(`pw build: ${report.refused}`);
|
|
70
|
+
return 2;
|
|
71
|
+
}
|
|
72
|
+
if (report.unknown !== undefined) {
|
|
73
|
+
out(`pw build: pulpweaver4.toml has no edition ${JSON.stringify(report.unknown)}`);
|
|
74
|
+
return 2;
|
|
75
|
+
}
|
|
76
|
+
printProblems(report.problems, new Map(Object.entries(report.sources)), out, { env });
|
|
77
|
+
for (const e of report.editions)
|
|
78
|
+
out(`pw build: ${e.name}: ${describeFiles(e.files)}`);
|
|
79
|
+
if (hasErrors(report.problems)) {
|
|
80
|
+
// Counted as printed: a problem several editions found is one.
|
|
81
|
+
out(`pw build: failed, with ${summarizeProblems(sortProblems(report.problems))}`);
|
|
82
|
+
return 1;
|
|
83
|
+
}
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
/** What an edition wrote: its file, or its folder and how many files. */
|
|
87
|
+
function describeFiles(files) {
|
|
88
|
+
if (files.length === 0)
|
|
89
|
+
return 'nothing written';
|
|
90
|
+
if (files.length === 1)
|
|
91
|
+
return files[0];
|
|
92
|
+
const dir = files[0].split('/').slice(0, 2).join('/');
|
|
93
|
+
return `${dir}/ (${files.length} files)`;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACz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AAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;IACrF,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ;QAAE,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IACtF,IAAI,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC/B,+DAA+D;QAC/D,GAAG,CAAC,0BAA0B,iBAAiB,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAA;QACjF,OAAO,CAAC,CAAA;IACV,CAAC;IACD,OAAO,CAAC,CAAA;AACV,CAAC;AAED,yEAAyE;AACzE,SAAS,aAAa,CAAC,KAAwB;IAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,iBAAiB,CAAA;IAChD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAE,CAAA;IACxC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACtD,OAAO,GAAG,GAAG,MAAM,KAAK,CAAC,MAAM,SAAS,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type Page } from 'playwright';
|
|
2
|
+
/**
|
|
3
|
+
* A dependency of the core's, as the core's entry finds it: npm may not
|
|
4
|
+
* hoist it beside the CLI (a global install, pnpm), so the CLI's own
|
|
5
|
+
* resolution can't be relied on (#103).
|
|
6
|
+
*/
|
|
7
|
+
export declare function coreDependency(coreEntry: string, name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* The Chromium build pulpweaver4 lays out in, and the Playwright release
|
|
10
|
+
* that downloads it (`npx playwright@1.63.0 install chromium`; its
|
|
11
|
+
* `browsers.json`). They change together, with `playwright` in
|
|
12
|
+
* package.json, nixpkgs' `playwright-driver` in MODULE.bazel, and the
|
|
13
|
+
* calibrations that depend on the renderer.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CHROMIUM: {
|
|
16
|
+
readonly version: '153.0.8010.12';
|
|
17
|
+
readonly revision: '1243';
|
|
18
|
+
readonly playwright: '1.63.0';
|
|
19
|
+
};
|
|
20
|
+
/** The locale and time zone of the page the core runs in, whatever the machine's. */
|
|
21
|
+
export declare const PAGE_LOCALE = "en-US";
|
|
22
|
+
export declare const PAGE_TIME_ZONE = "UTC";
|
|
23
|
+
export interface ChromiumHostOptions {
|
|
24
|
+
/** The core's entry module; the installed `pulpweaver4` package's by default. */
|
|
25
|
+
coreEntry?: string;
|
|
26
|
+
/** A directory whose files are served under `/fonts/`. */
|
|
27
|
+
fontsDir?: string;
|
|
28
|
+
/** A directory whose files are served under `/images/`. */
|
|
29
|
+
imagesDir?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Modules bundled with the core, each exported from it under a name, for
|
|
32
|
+
* test support the package leaves out: `{ testing: '…/corpus.ts' }` makes
|
|
33
|
+
* `pw.testing`.
|
|
34
|
+
*/
|
|
35
|
+
extra?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* Run in a Chromium other than {@link CHROMIUM}, with a warning, instead of
|
|
38
|
+
* refusing to: its layout may differ, so its output is not reproducible.
|
|
39
|
+
* Set by `PW_ANY_CHROMIUM`.
|
|
40
|
+
*/
|
|
41
|
+
anyChromium?: boolean;
|
|
42
|
+
/** Where warnings go: stderr by default. */
|
|
43
|
+
warn?: (message: string) => void;
|
|
44
|
+
/** More of the server's paths: a file's type and bytes, or nothing for a 404. */
|
|
45
|
+
routes?: (path: string) => Promise<{
|
|
46
|
+
type: string;
|
|
47
|
+
body: string | Uint8Array;
|
|
48
|
+
} | undefined>;
|
|
49
|
+
/** Called with the page before it loads, for a test to answer its requests elsewhere (`page.route`): an https plugin's, say. */
|
|
50
|
+
onPage?: (page: Page) => Promise<void>;
|
|
51
|
+
/** How the CLI fetches the CSL project's styles and locales a build names (`csl.ts`): Node's `fetch`, unless a test serves them. */
|
|
52
|
+
fetch?: typeof fetch;
|
|
53
|
+
}
|
|
54
|
+
/** Chromium can't be used: the wrong build, or none installed. */
|
|
55
|
+
export declare class ChromiumError extends Error {
|
|
56
|
+
name: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The browser's environment: the machine's, but in a fixed locale and time
|
|
60
|
+
* zone. The context's `locale` sets what a page's scripts see, but Blink
|
|
61
|
+
* still lays out in the process's locale (LANG and the rest) where an
|
|
62
|
+
* element's language doesn't say: in Turkish, the spike page's footnote
|
|
63
|
+
* set differently. C.UTF-8 because Chromium turns OPFS names into native
|
|
64
|
+
* paths in the locale's charset.
|
|
65
|
+
*/
|
|
66
|
+
export declare function browserEnvironment(env: NodeJS.ProcessEnv): Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Refuses a Chromium other than {@link CHROMIUM}, by its version
|
|
69
|
+
* (`browser.version()`), with a `ChromiumError`; or, with `anyChromium`,
|
|
70
|
+
* warns about it.
|
|
71
|
+
*/
|
|
72
|
+
export declare function checkChromium(version: string, opts?: Pick<ChromiumHostOptions, 'anyChromium' | 'warn'>): void;
|
|
73
|
+
export declare class ChromiumHost {
|
|
74
|
+
private readonly browser;
|
|
75
|
+
private readonly server;
|
|
76
|
+
/** A page with the core loaded as `globalThis.pw`. */
|
|
77
|
+
readonly page: Page;
|
|
78
|
+
/** The server's origin, which serves `/fonts/`. */
|
|
79
|
+
readonly origin: string;
|
|
80
|
+
private constructor();
|
|
81
|
+
static launch(opts?: ChromiumHostOptions): Promise<ChromiumHost>;
|
|
82
|
+
close(): Promise<void>;
|
|
83
|
+
}
|
package/dist/chromium.js
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The core, hosted in headless Chromium: the CLI runs the same code a
|
|
3
|
+
* browser runs (https://plans.inkylabs.com/pulpweaver#where-it-runs). The
|
|
4
|
+
* core is bundled for the browser with esbuild, served with HarfBuzz's
|
|
5
|
+
* WebAssembly and the project's fonts from a local server, and loaded into a
|
|
6
|
+
* page of Playwright's Chromium in its new headless mode, which lays text
|
|
7
|
+
* out exactly as a headed one does.
|
|
8
|
+
*
|
|
9
|
+
* The Chromium is pinned (https://plans.inkylabs.com/pulpweaver#performance-and-incremental-builds):
|
|
10
|
+
* `playwright` is an exact dependency, and each Playwright release
|
|
11
|
+
* downloads one Chromium build, the one {@link CHROMIUM} names, which the
|
|
12
|
+
* layout is calibrated against. Any other is refused, unless
|
|
13
|
+
* `PW_ANY_CHROMIUM` is set, and then warned about. The browser's locale
|
|
14
|
+
* and time zone, and its page's, are fixed, not the machine's, so nothing
|
|
15
|
+
* in it can depend on where the build runs.
|
|
16
|
+
*/
|
|
17
|
+
import { readFile } from 'node:fs/promises';
|
|
18
|
+
import http from 'node:http';
|
|
19
|
+
import { createRequire } from 'node:module';
|
|
20
|
+
import path from 'node:path';
|
|
21
|
+
import { fileURLToPath } from 'node:url';
|
|
22
|
+
import { build } from 'esbuild';
|
|
23
|
+
import { chromium } from 'playwright';
|
|
24
|
+
/**
|
|
25
|
+
* A dependency of the core's, as the core's entry finds it: npm may not
|
|
26
|
+
* hoist it beside the CLI (a global install, pnpm), so the CLI's own
|
|
27
|
+
* resolution can't be relied on (#103).
|
|
28
|
+
*/
|
|
29
|
+
export function coreDependency(coreEntry, name) {
|
|
30
|
+
return createRequire(coreEntry).resolve(name);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The Chromium build pulpweaver4 lays out in, and the Playwright release
|
|
34
|
+
* that downloads it (`npx playwright@1.63.0 install chromium`; its
|
|
35
|
+
* `browsers.json`). They change together, with `playwright` in
|
|
36
|
+
* package.json, nixpkgs' `playwright-driver` in MODULE.bazel, and the
|
|
37
|
+
* calibrations that depend on the renderer.
|
|
38
|
+
*/
|
|
39
|
+
export const CHROMIUM = { version: '153.0.8010.12', revision: '1243', playwright: '1.63.0' };
|
|
40
|
+
/** The locale and time zone of the page the core runs in, whatever the machine's. */
|
|
41
|
+
export const PAGE_LOCALE = 'en-US';
|
|
42
|
+
export const PAGE_TIME_ZONE = 'UTC';
|
|
43
|
+
/** Chromium can't be used: the wrong build, or none installed. */
|
|
44
|
+
export class ChromiumError extends Error {
|
|
45
|
+
name = 'ChromiumError';
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The browser's environment: the machine's, but in a fixed locale and time
|
|
49
|
+
* zone. The context's `locale` sets what a page's scripts see, but Blink
|
|
50
|
+
* still lays out in the process's locale (LANG and the rest) where an
|
|
51
|
+
* element's language doesn't say: in Turkish, the spike page's footnote
|
|
52
|
+
* set differently. C.UTF-8 because Chromium turns OPFS names into native
|
|
53
|
+
* paths in the locale's charset.
|
|
54
|
+
*/
|
|
55
|
+
export function browserEnvironment(env) {
|
|
56
|
+
const fixed = {};
|
|
57
|
+
for (const [k, v] of Object.entries(env)) {
|
|
58
|
+
if (v !== undefined && !/^(LANG|LANGUAGE|LC_[A-Z]+|TZ)$/.test(k))
|
|
59
|
+
fixed[k] = v;
|
|
60
|
+
}
|
|
61
|
+
return { ...fixed, LANG: 'C.UTF-8', LC_ALL: 'C.UTF-8', LANGUAGE: PAGE_LOCALE.replace('-', '_'), TZ: PAGE_TIME_ZONE };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Refuses a Chromium other than {@link CHROMIUM}, by its version
|
|
65
|
+
* (`browser.version()`), with a `ChromiumError`; or, with `anyChromium`,
|
|
66
|
+
* warns about it.
|
|
67
|
+
*/
|
|
68
|
+
export function checkChromium(version, opts = {}) {
|
|
69
|
+
if (version === CHROMIUM.version)
|
|
70
|
+
return;
|
|
71
|
+
const message = `pulpweaver4 lays out in Chromium ${CHROMIUM.version} (Playwright ${CHROMIUM.playwright}'s build ${CHROMIUM.revision}), not ${version}`;
|
|
72
|
+
if (!opts.anyChromium) {
|
|
73
|
+
throw new ChromiumError(`${message}, so its output would not be reproducible; install it with: npx playwright@${CHROMIUM.playwright} install chromium, or set PW_ANY_CHROMIUM=1 to build anyway`);
|
|
74
|
+
}
|
|
75
|
+
;
|
|
76
|
+
(opts.warn ?? ((m) => process.stderr.write(`${m}\n`)))(`warning: ${message}: the layout may differ, and the output is not reproducible`);
|
|
77
|
+
}
|
|
78
|
+
// The import map lets a module the page imports later (a plugin, which leaves pulpweaver4 out of its bundle) share the core.
|
|
79
|
+
const PAGE = `<!doctype html><html><head><meta charset="utf-8">
|
|
80
|
+
<script type="importmap">{"imports":{"pulpweaver4":"/pulpweaver4.js"}}</script></head><body>
|
|
81
|
+
<script type="module">import * as pw from '/pulpweaver4.js'; globalThis.pw = pw; globalThis.pwReady = true</script>
|
|
82
|
+
</body></html>`;
|
|
83
|
+
export class ChromiumHost {
|
|
84
|
+
browser;
|
|
85
|
+
server;
|
|
86
|
+
page;
|
|
87
|
+
origin;
|
|
88
|
+
constructor(browser, server,
|
|
89
|
+
/** A page with the core loaded as `globalThis.pw`. */
|
|
90
|
+
page,
|
|
91
|
+
/** The server's origin, which serves `/fonts/`. */
|
|
92
|
+
origin) {
|
|
93
|
+
this.browser = browser;
|
|
94
|
+
this.server = server;
|
|
95
|
+
this.page = page;
|
|
96
|
+
this.origin = origin;
|
|
97
|
+
}
|
|
98
|
+
static async launch(opts = {}) {
|
|
99
|
+
const entry = opts.coreEntry ?? fileURLToPath(import.meta.resolve('pulpweaver4'));
|
|
100
|
+
// One bundle, so the extra modules share the core's classes and state.
|
|
101
|
+
const extra = Object.entries(opts.extra ?? {}).map(([name, file]) => `export * as ${name} from ${JSON.stringify(file)}\n`);
|
|
102
|
+
const bundle = await build({
|
|
103
|
+
...(extra.length
|
|
104
|
+
? { stdin: { contents: `export * from ${JSON.stringify(entry)}\n${extra.join('')}`, resolveDir: path.dirname(entry), loader: 'ts' } }
|
|
105
|
+
: { entryPoints: [entry] }),
|
|
106
|
+
bundle: true,
|
|
107
|
+
format: 'esm',
|
|
108
|
+
platform: 'browser',
|
|
109
|
+
target: 'es2023',
|
|
110
|
+
// harfbuzzjs imports it only in its Node branch, never in a browser.
|
|
111
|
+
external: ['module'],
|
|
112
|
+
// An extra module's own imports of the core are the core itself, not a second copy.
|
|
113
|
+
alias: { 'pulpweaver4/test': path.join(path.dirname(entry), 'test', `index${path.extname(entry)}`), pulpweaver4: entry },
|
|
114
|
+
write: false,
|
|
115
|
+
logLevel: 'warning',
|
|
116
|
+
});
|
|
117
|
+
const js = bundle.outputFiles[0].contents;
|
|
118
|
+
// The PDF writer's, Little CMS's and HarfBuzz's subsetter's WebAssembly,
|
|
119
|
+
// which the bundle fetches from beside itself (core's pdf/wasm,
|
|
120
|
+
// colour/wasm and fonts/wasm, in its sources and in dist alike).
|
|
121
|
+
const pdfWasm = await readFile(path.join(path.dirname(entry), 'pdf', 'wasm', 'pulpweaver4_pdf_bg.wasm'));
|
|
122
|
+
const lcmsWasm = await readFile(path.join(path.dirname(entry), 'colour', 'wasm', 'lcms2.wasm'));
|
|
123
|
+
const subsetWasm = await readFile(path.join(path.dirname(entry), 'fonts', 'wasm', 'harfbuzz-subset.wasm'));
|
|
124
|
+
const wasm = await readFile(path.join(path.dirname(coreDependency(entry, 'harfbuzzjs')), 'harfbuzz.wasm'));
|
|
125
|
+
const fontsDir = opts.fontsDir;
|
|
126
|
+
// The hyphenation patterns, each fetched from patterns/ beside the bundle
|
|
127
|
+
// when a language first needs it (core's hyphenation/patterns).
|
|
128
|
+
const patternsDir = path.join(path.dirname(entry), 'hyphenation', 'patterns');
|
|
129
|
+
// Math's font ranges and speech rules, fetched from mathjax/ beside the
|
|
130
|
+
// bundle when math first needs them (core's math/mathjax).
|
|
131
|
+
const mathDir = path.join(path.dirname(entry), 'math', 'mathjax');
|
|
132
|
+
// The web edition's script and what it loads, which the web output
|
|
133
|
+
// fetches from runtime/ beside the bundle to copy into a site (core's
|
|
134
|
+
// web/runtime).
|
|
135
|
+
const runtimeDir = path.join(path.dirname(entry), 'web', 'runtime');
|
|
136
|
+
const server = http.createServer(async (req, res) => {
|
|
137
|
+
const url = decodeURIComponent((req.url ?? '/').split('?')[0]);
|
|
138
|
+
const send = (type, body) => {
|
|
139
|
+
res.writeHead(200, { 'content-type': type });
|
|
140
|
+
res.end(body);
|
|
141
|
+
};
|
|
142
|
+
try {
|
|
143
|
+
if (url === '/')
|
|
144
|
+
return send('text/html', PAGE);
|
|
145
|
+
if (url === '/pulpweaver4.js')
|
|
146
|
+
return send('text/javascript', js);
|
|
147
|
+
if (url === '/harfbuzz.wasm')
|
|
148
|
+
return send('application/wasm', wasm);
|
|
149
|
+
if (url === '/wasm/pulpweaver4_pdf_bg.wasm')
|
|
150
|
+
return send('application/wasm', pdfWasm);
|
|
151
|
+
if (url === '/wasm/lcms2.wasm')
|
|
152
|
+
return send('application/wasm', lcmsWasm);
|
|
153
|
+
if (url === '/wasm/harfbuzz-subset.wasm')
|
|
154
|
+
return send('application/wasm', subsetWasm);
|
|
155
|
+
if (/^\/patterns\/[a-z-]+\.wasm$/.test(url)) {
|
|
156
|
+
return send('application/wasm', await readFile(path.join(patternsDir, url.slice('/patterns/'.length))));
|
|
157
|
+
}
|
|
158
|
+
if (/^\/mathjax\/(svg|sre)\/[A-Za-z-]+\.json$/.test(url)) {
|
|
159
|
+
return send('application/json', await readFile(path.join(mathDir, url.slice('/mathjax/'.length))));
|
|
160
|
+
}
|
|
161
|
+
if (/^\/runtime\/[\w.-]+$/.test(url)) {
|
|
162
|
+
const type = url.endsWith('.wasm') ? 'application/wasm' : 'text/plain';
|
|
163
|
+
return send(type, await readFile(path.join(runtimeDir, url.slice('/runtime/'.length))));
|
|
164
|
+
}
|
|
165
|
+
if (opts.imagesDir && url.startsWith('/images/') && !url.includes('..')) {
|
|
166
|
+
return send('application/octet-stream', await readFile(path.join(opts.imagesDir, url.slice('/images/'.length))));
|
|
167
|
+
}
|
|
168
|
+
if (fontsDir && url.startsWith('/fonts/') && !url.includes('..')) {
|
|
169
|
+
return send('font/sfnt', await readFile(path.join(fontsDir, url.slice('/fonts/'.length))));
|
|
170
|
+
}
|
|
171
|
+
const routed = await opts.routes?.(url);
|
|
172
|
+
if (routed)
|
|
173
|
+
return send(routed.type, routed.body);
|
|
174
|
+
}
|
|
175
|
+
catch { /* not found */ }
|
|
176
|
+
res.writeHead(404);
|
|
177
|
+
res.end();
|
|
178
|
+
});
|
|
179
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
180
|
+
const origin = `http://127.0.0.1:${server.address().port}`;
|
|
181
|
+
// channel 'chromium': the full browser in the new headless mode. The old
|
|
182
|
+
// headless shell hints glyph advances to whole pixels.
|
|
183
|
+
let browser;
|
|
184
|
+
try {
|
|
185
|
+
browser = await chromium.launch({ channel: 'chromium', args: [`--lang=${PAGE_LOCALE}`], env: browserEnvironment(process.env) });
|
|
186
|
+
}
|
|
187
|
+
catch (e) {
|
|
188
|
+
server.close();
|
|
189
|
+
if (e instanceof Error && /Executable doesn't exist/.test(e.message)) {
|
|
190
|
+
throw new ChromiumError(`Chromium ${CHROMIUM.version} isn't installed; install it with: npx playwright@${CHROMIUM.playwright} install chromium`);
|
|
191
|
+
}
|
|
192
|
+
throw e;
|
|
193
|
+
}
|
|
194
|
+
try {
|
|
195
|
+
checkChromium(browser.version(), opts);
|
|
196
|
+
}
|
|
197
|
+
catch (e) {
|
|
198
|
+
await browser.close();
|
|
199
|
+
server.close();
|
|
200
|
+
throw e;
|
|
201
|
+
}
|
|
202
|
+
const page = await browser.newPage({ locale: PAGE_LOCALE, timezoneId: PAGE_TIME_ZONE });
|
|
203
|
+
await opts.onPage?.(page);
|
|
204
|
+
await page.goto(`${origin}/`);
|
|
205
|
+
await page.waitForFunction(() => globalThis.pwReady === true);
|
|
206
|
+
return new ChromiumHost(browser, server, page, origin);
|
|
207
|
+
}
|
|
208
|
+
async close() {
|
|
209
|
+
await this.browser.close();
|
|
210
|
+
await new Promise((resolve) => this.server.close(resolve));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
//# sourceMappingURL=chromium.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chromium.js","sourceRoot":"","sources":["../src/chromium.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAA2B,QAAQ,EAAE,MAAM,YAAY,CAAA;AAE9D;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,IAAY;IAC5D,OAAO,aAAa,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAC/C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAW,CAAA;AAErG,qFAAqF;AACrF,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA;AAClC,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,CAAA;AA+BnC,kEAAkE;AAClE,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,IAAI,GAAG,eAAe,CAAA;CAChC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAsB;IACvD,MAAM,KAAK,GAA2B,EAAE,CAAA;IACxC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,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