gutterpress 0.11.22 → 0.11.23-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -24
- package/dist/{README-3nj919rm.md → README-8ef336pp.md} +1 -1
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.js +16 -22
- package/dist/{build-53bw14h7.js → build-encgnv0c.js} +9 -10
- package/dist/{chapter-01-rkpyvjna.md → chapter-01-gsbjt584.md} +1 -1
- package/dist/chapter-01-s71xrf5q.md +69 -0
- package/dist/{chapter-01-7jwqg1ct.md → chapter-01-wgjfz4w6.md} +1 -1
- package/dist/checks/source/character-table.d.ts +12 -6
- package/dist/{cli-habkc5ng.js → cli-a35w7wzg.js} +5 -4
- package/dist/{cli-kx4hbnx2.js → cli-aqh6brew.js} +1 -1
- package/dist/{cli-1hxxwbaq.js → cli-evg8sbht.js} +1 -1
- package/dist/{cli-cjftezxr.js → cli-kh8v4vvw.js} +2 -1
- package/dist/{cli-ntwqmdnw.js → cli-pwwfxdgb.js} +846 -13
- package/dist/{cli-8kg0wjdt.js → cli-pz4bn98t.js} +185 -9
- package/dist/{cli-zj5xaepv.js → cli-sdmv4bba.js} +57 -117
- package/dist/{cli-ke86zsz6.js → cli-xq6djqbj.js} +51 -54
- package/dist/{index-r7jcsk6h.js → cli-y28j019d.js} +19 -10
- package/dist/cli.js +12 -12
- package/dist/{doctor-xka1frnx.js → doctor-5gtpgpd1.js} +3 -3
- package/dist/{engine-p93f06gj.js → engine-mc5br8g8.js} +1 -2
- package/dist/{engine-0ndvy8vj.js → engine-tn13gk0b.js} +3 -3
- package/dist/{ext-dwfqyy1j.js → ext-wn2a5afq.js} +18 -33
- package/dist/{extension-restore-ct1wk344.js → extension-restore-g8jnmmzq.js} +5 -6
- package/dist/{extension-restore-7vp3vh77.js → extension-restore-s3x1618g.js} +4 -4
- package/dist/{index-apc8w9w8.js → index-0skhjx3e.js} +180 -1
- package/dist/{index-4v7e621e.js → index-2bjcghze.js} +847 -13
- package/dist/index-46ycxe6r.js +18 -0
- package/dist/{index-53nrm5j1.js → index-4x6y8krm.js} +2 -4
- package/dist/{cli-h3phdstf.js → index-5x42amh8.js} +19 -10
- package/dist/{index-93pqkvty.js → index-h6yk5tjx.js} +5 -4
- package/dist/{index-kh7fayjv.js → index-j5z86r4a.js} +57 -54
- package/dist/{index-6cmn2wpd.js → index-x3ema2w3.js} +69 -128
- package/dist/index.js +17 -23
- package/dist/lib/build-runner.d.ts +1 -1
- package/dist/lib/extension-manager.d.ts +16 -43
- package/dist/lib/extension-scaffold.d.ts +3 -3
- package/dist/lib/extension-specifier.d.ts +23 -6
- package/dist/lib/markdown/assemble.d.ts +7 -1
- package/dist/lib/markdown/gutterpress-css.d.ts +1 -1
- package/dist/lib/markdown/index.d.ts +4 -0
- package/dist/lib/markdown/math.d.ts +43 -0
- package/dist/lib/markdown/renderer.d.ts +11 -8
- package/dist/lib/markdown/table.d.ts +46 -0
- package/dist/lib/markdown/typography.d.ts +12 -0
- package/dist/lib/npm-plugin-installer.d.ts +1 -1
- package/dist/lib/plugin-vendor.d.ts +11 -3
- package/dist/lib/presets.d.ts +1 -1
- package/dist/lib/project-gitignore.d.ts +2 -2
- package/dist/lib/project-scaffold.d.ts +6 -8
- package/dist/lib/project-templates.d.ts +6 -1
- package/dist/lib/snippets.d.ts +2 -1
- package/dist/lib/style-resolver.d.ts +1 -2
- package/dist/manifest-eagfhba6.yaml +19 -0
- package/dist/{manifest.schema-399bx3vc.json → manifest.schema-t7nx2stg.json} +12 -5
- package/dist/{new-1pawj2qf.js → new-mhs46pw3.js} +22 -21
- package/dist/{plugins-fr4fnzhb.js → plugins-1sxe0dkz.js} +4 -4
- package/dist/{plugins-g4dgw7mn.js → plugins-2cek4mz1.js} +2 -2
- package/dist/{preflight-ept9q57t.js → preflight-3k2b1x8e.js} +9 -10
- package/dist/preview/file-watcher.d.ts +1 -0
- package/dist/{preview-fxpnjv7k.js → preview-6p9v6rht.js} +9 -10
- package/dist/{publish-zhqqsgmr.js → publish-qgsngy8s.js} +9 -10
- package/dist/render.js +470 -11
- package/dist/schema/manifest.types.d.ts +8 -0
- package/dist/{source-provider-qbfknhyy.js → source-provider-98k5deda.js} +2 -2
- package/dist/{source-provider-2r74a7wp.js → source-provider-knmcam50.js} +2 -2
- package/dist/{validate-t68gvckq.js → validate-0v7xw6wa.js} +9 -10
- package/package.json +2 -1
- package/dist/cli-1ngqzg8s.js +0 -196
- package/dist/index-vay3ff1f.js +0 -213
- package/dist/package-97gm31sg.json +0 -10
- package/dist/package-gag6ykwn.json +0 -10
- package/dist/package-nrhkwf2m.json +0 -10
- package/dist/theme-h5recz6c.css +0 -61
- package/dist/theme-j2bagrfx.css +0 -59
- package/dist/theme-nn6d53zy.css +0 -71
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
launchChromium
|
|
3
3
|
} from "./cli-eyyggect.js";
|
|
4
|
-
import {
|
|
5
|
-
getAssetPath
|
|
6
|
-
} from "./cli-1ngqzg8s.js";
|
|
7
4
|
|
|
8
5
|
// src/engine/compiler/build.ts
|
|
9
|
-
import { readFile } from "node:fs/promises";
|
|
10
|
-
import { resolve } from "node:path";
|
|
6
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
7
|
+
import { resolve as resolve2 } from "node:path";
|
|
11
8
|
import { pathToFileURL } from "node:url";
|
|
12
9
|
|
|
13
10
|
// src/engine/shared/gcpm-extract.ts
|
|
@@ -1126,6 +1123,185 @@ async function inspectPdf(bytes) {
|
|
|
1126
1123
|
return { pageCount: pages.length, boxes, linkTargets, namedDests, outline };
|
|
1127
1124
|
}
|
|
1128
1125
|
|
|
1126
|
+
// src/lib/embedded-assets.ts
|
|
1127
|
+
import { existsSync } from "node:fs";
|
|
1128
|
+
import { mkdtemp, mkdir, writeFile, readFile } from "node:fs/promises";
|
|
1129
|
+
import { tmpdir } from "node:os";
|
|
1130
|
+
import { dirname, join, resolve } from "node:path";
|
|
1131
|
+
import { fileURLToPath } from "node:url";
|
|
1132
|
+
|
|
1133
|
+
// src/assets/favicon.ico
|
|
1134
|
+
var favicon_default = "./favicon-272ga6y0.ico";
|
|
1135
|
+
|
|
1136
|
+
// src/assets/manifest.schema.json
|
|
1137
|
+
var manifest_schema_default = "./manifest.schema-t7nx2stg.json";
|
|
1138
|
+
|
|
1139
|
+
// src/assets/preview/scripts/preview-interface.js
|
|
1140
|
+
var preview_interface_default = "./preview-interface-nnmrxyqm.js";
|
|
1141
|
+
|
|
1142
|
+
// src/assets/preview/scripts/preview-bridge.js
|
|
1143
|
+
var preview_bridge_default = "./preview-bridge-8wjcjec3.js";
|
|
1144
|
+
|
|
1145
|
+
// src/assets/preview/scripts/preview-shell.js
|
|
1146
|
+
var preview_shell_default = "./preview-shell-wk9k3gcd.js";
|
|
1147
|
+
|
|
1148
|
+
// profiles/CGATS21_CRPC1.icc
|
|
1149
|
+
var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
|
|
1150
|
+
|
|
1151
|
+
// src/assets/engine/gutterpress-viewer.js
|
|
1152
|
+
var gutterpress_viewer_default = "./gutterpress-viewer-701vf4qp.js";
|
|
1153
|
+
|
|
1154
|
+
// src/assets/engine/gutterpress-agent.js
|
|
1155
|
+
var gutterpress_agent_default = "./gutterpress-agent-d29ry3ak.js";
|
|
1156
|
+
|
|
1157
|
+
// src/assets/templates/book/manifest.yaml
|
|
1158
|
+
var manifest_default = "./manifest-n1gh3qw5.yaml";
|
|
1159
|
+
|
|
1160
|
+
// src/assets/templates/book/chapter-01.md
|
|
1161
|
+
var chapter_01_default = "./chapter-01-gsbjt584.md";
|
|
1162
|
+
|
|
1163
|
+
// src/assets/templates/zine/manifest.yaml
|
|
1164
|
+
var manifest_default2 = "./manifest-n1gh3qw5.yaml";
|
|
1165
|
+
|
|
1166
|
+
// src/assets/templates/zine/chapter-01.md
|
|
1167
|
+
var chapter_01_default2 = "./chapter-01-wgjfz4w6.md";
|
|
1168
|
+
|
|
1169
|
+
// src/assets/templates/technical/manifest.yaml
|
|
1170
|
+
var manifest_default3 = "./manifest-n1gh3qw5.yaml";
|
|
1171
|
+
|
|
1172
|
+
// src/assets/templates/technical/chapter-01.md
|
|
1173
|
+
var chapter_01_default3 = "./chapter-01-6fn9pvd0.md";
|
|
1174
|
+
|
|
1175
|
+
// src/assets/templates/paper/manifest.yaml
|
|
1176
|
+
var manifest_default4 = "./manifest-eagfhba6.yaml";
|
|
1177
|
+
|
|
1178
|
+
// src/assets/templates/paper/chapter-01.md
|
|
1179
|
+
var chapter_01_default4 = "./chapter-01-s71xrf5q.md";
|
|
1180
|
+
|
|
1181
|
+
// src/assets/extension-templates/plugin/package.json
|
|
1182
|
+
var package_default = "./package-9rv69pxm.json";
|
|
1183
|
+
|
|
1184
|
+
// src/assets/extension-templates/plugin/README.md
|
|
1185
|
+
var README_default = "./README-vsnsc1b3.md";
|
|
1186
|
+
|
|
1187
|
+
// src/assets/extension-templates/plugin/plugin.js.tpl
|
|
1188
|
+
var plugin_js_default = "./plugin.js-cswq7wvd.tpl";
|
|
1189
|
+
|
|
1190
|
+
// src/assets/extension-templates/plugin/styles/plugin.css
|
|
1191
|
+
var plugin_default = "./plugin-spbcem4j.css";
|
|
1192
|
+
|
|
1193
|
+
// src/assets/extension-templates/plugin/snippets/term-box.md
|
|
1194
|
+
var term_box_default = "./term-box-4y0w7y32.md";
|
|
1195
|
+
|
|
1196
|
+
// src/assets/extension-templates/plugin/test/fixture.md
|
|
1197
|
+
var fixture_default = "./fixture-2qnyqgb5.md";
|
|
1198
|
+
|
|
1199
|
+
// src/assets/extension-templates/plugin/test/expected.html
|
|
1200
|
+
var expected_default = "./expected-ycmacem8.html";
|
|
1201
|
+
|
|
1202
|
+
// src/assets/extension-templates/plugin/test/plugin.test.js.tpl
|
|
1203
|
+
var plugin_test_js_default = "./plugin.test.js-xgxrd8hf.tpl";
|
|
1204
|
+
|
|
1205
|
+
// src/assets/extension-templates/look/package.json
|
|
1206
|
+
var package_default2 = "./package-aenwjew3.json";
|
|
1207
|
+
|
|
1208
|
+
// src/assets/extension-templates/look/README.md
|
|
1209
|
+
var README_default2 = "./README-8ef336pp.md";
|
|
1210
|
+
|
|
1211
|
+
// src/assets/extension-templates/look/components.yaml
|
|
1212
|
+
var components_default = "./components-zzqdpt3m.yaml";
|
|
1213
|
+
|
|
1214
|
+
// src/assets/extension-templates/look/snippets/callout.md
|
|
1215
|
+
var callout_default = "./callout-hv56m16h.md";
|
|
1216
|
+
|
|
1217
|
+
// src/assets/extension-templates/look/styles/tokens.css
|
|
1218
|
+
var tokens_default = "./tokens-7984461t.css";
|
|
1219
|
+
|
|
1220
|
+
// src/assets/extension-templates/look/styles/base.css
|
|
1221
|
+
var base_default = "./base-ypqh9n7f.css";
|
|
1222
|
+
|
|
1223
|
+
// src/assets/extension-templates/look/styles/components.css
|
|
1224
|
+
var components_default2 = "./components-aam0fe2z.css";
|
|
1225
|
+
|
|
1226
|
+
// src/assets/extension-templates/look/styles/page-templates.css
|
|
1227
|
+
var page_templates_default = "./page-templates-tx9ryt19.css";
|
|
1228
|
+
|
|
1229
|
+
// src/assets/extension-templates/look/styles/page-rules.css
|
|
1230
|
+
var page_rules_default = "./page-rules-nsj3aw42.css";
|
|
1231
|
+
|
|
1232
|
+
// src/assets/extension-templates/look/styles/book.css
|
|
1233
|
+
var book_default = "./book-ted3tzrp.css";
|
|
1234
|
+
|
|
1235
|
+
// src/lib/embedded-assets.ts
|
|
1236
|
+
var __libdir = dirname(fileURLToPath(import.meta.url));
|
|
1237
|
+
var abs = (p) => resolve(__libdir, p);
|
|
1238
|
+
var filePath = (v) => v;
|
|
1239
|
+
var EMBEDDED_ASSETS = {
|
|
1240
|
+
"favicon.ico": abs(favicon_default),
|
|
1241
|
+
"manifest.schema.json": abs(filePath(manifest_schema_default)),
|
|
1242
|
+
"preview/scripts/preview-interface.js": abs(filePath(preview_interface_default)),
|
|
1243
|
+
"preview/scripts/preview-bridge.js": abs(filePath(preview_bridge_default)),
|
|
1244
|
+
"preview/scripts/preview-shell.js": abs(filePath(preview_shell_default)),
|
|
1245
|
+
"profiles/CGATS21_CRPC1.icc": abs(filePath(CGATS21_CRPC1_default)),
|
|
1246
|
+
"engine/gutterpress-viewer.js": abs(filePath(gutterpress_viewer_default)),
|
|
1247
|
+
"engine/gutterpress-agent.js": abs(filePath(gutterpress_agent_default)),
|
|
1248
|
+
"templates/book/manifest.yaml": abs(filePath(manifest_default)),
|
|
1249
|
+
"templates/book/chapter-01.md": abs(filePath(chapter_01_default)),
|
|
1250
|
+
"templates/zine/manifest.yaml": abs(filePath(manifest_default2)),
|
|
1251
|
+
"templates/zine/chapter-01.md": abs(filePath(chapter_01_default2)),
|
|
1252
|
+
"templates/technical/manifest.yaml": abs(filePath(manifest_default3)),
|
|
1253
|
+
"templates/technical/chapter-01.md": abs(filePath(chapter_01_default3)),
|
|
1254
|
+
"templates/paper/manifest.yaml": abs(filePath(manifest_default4)),
|
|
1255
|
+
"templates/paper/chapter-01.md": abs(filePath(chapter_01_default4)),
|
|
1256
|
+
"extension-templates/plugin/package.json": abs(filePath(package_default)),
|
|
1257
|
+
"extension-templates/plugin/README.md": abs(filePath(README_default)),
|
|
1258
|
+
"extension-templates/plugin/plugin.js.tpl": abs(filePath(plugin_js_default)),
|
|
1259
|
+
"extension-templates/plugin/styles/plugin.css": abs(filePath(plugin_default)),
|
|
1260
|
+
"extension-templates/plugin/snippets/term-box.md": abs(filePath(term_box_default)),
|
|
1261
|
+
"extension-templates/plugin/test/fixture.md": abs(filePath(fixture_default)),
|
|
1262
|
+
"extension-templates/plugin/test/expected.html": abs(filePath(expected_default)),
|
|
1263
|
+
"extension-templates/plugin/test/plugin.test.js.tpl": abs(filePath(plugin_test_js_default)),
|
|
1264
|
+
"extension-templates/look/package.json": abs(filePath(package_default2)),
|
|
1265
|
+
"extension-templates/look/README.md": abs(filePath(README_default2)),
|
|
1266
|
+
"extension-templates/look/components.yaml": abs(filePath(components_default)),
|
|
1267
|
+
"extension-templates/look/snippets/callout.md": abs(filePath(callout_default)),
|
|
1268
|
+
"extension-templates/look/styles/tokens.css": abs(filePath(tokens_default)),
|
|
1269
|
+
"extension-templates/look/styles/base.css": abs(filePath(base_default)),
|
|
1270
|
+
"extension-templates/look/styles/components.css": abs(filePath(components_default2)),
|
|
1271
|
+
"extension-templates/look/styles/page-templates.css": abs(filePath(page_templates_default)),
|
|
1272
|
+
"extension-templates/look/styles/page-rules.css": abs(filePath(page_rules_default)),
|
|
1273
|
+
"extension-templates/look/styles/book.css": abs(filePath(book_default))
|
|
1274
|
+
};
|
|
1275
|
+
var extractPromise = null;
|
|
1276
|
+
async function extractAssets() {
|
|
1277
|
+
const root = await mkdtemp(join(tmpdir(), "gutterpress-assets-"));
|
|
1278
|
+
for (const [relPath, srcPath] of Object.entries(EMBEDDED_ASSETS)) {
|
|
1279
|
+
const dest = join(root, relPath);
|
|
1280
|
+
await mkdir(dirname(dest), { recursive: true });
|
|
1281
|
+
const bytes = await readFile(srcPath);
|
|
1282
|
+
await writeFile(dest, bytes);
|
|
1283
|
+
}
|
|
1284
|
+
return root;
|
|
1285
|
+
}
|
|
1286
|
+
var SENTINEL_ASSET = "engine/gutterpress-viewer.js";
|
|
1287
|
+
async function getAssetsDir() {
|
|
1288
|
+
if (extractPromise) {
|
|
1289
|
+
try {
|
|
1290
|
+
const root = await extractPromise;
|
|
1291
|
+
if (existsSync(join(root, SENTINEL_ASSET))) {
|
|
1292
|
+
return root;
|
|
1293
|
+
}
|
|
1294
|
+
} catch {}
|
|
1295
|
+
extractPromise = null;
|
|
1296
|
+
}
|
|
1297
|
+
extractPromise = extractAssets();
|
|
1298
|
+
return extractPromise;
|
|
1299
|
+
}
|
|
1300
|
+
async function getAssetPath(relPath) {
|
|
1301
|
+
const root = await getAssetsDir();
|
|
1302
|
+
return join(root, relPath);
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1129
1305
|
// src/engine/compiler/tier2.ts
|
|
1130
1306
|
var DEFAULT_SLUG_PT = 18;
|
|
1131
1307
|
function classify(model) {
|
|
@@ -1451,8 +1627,8 @@ function pagePseudoContexts(model) {
|
|
|
1451
1627
|
}
|
|
1452
1628
|
async function build(opts) {
|
|
1453
1629
|
const log = opts.onProgress ?? (() => {});
|
|
1454
|
-
const AGENT = await
|
|
1455
|
-
const VIEWER = await
|
|
1630
|
+
const AGENT = await readFile2(await getAssetPath("engine/gutterpress-agent.js"), "utf8");
|
|
1631
|
+
const VIEWER = await readFile2(await getAssetPath("engine/gutterpress-viewer.js"), "utf8");
|
|
1456
1632
|
const browser = opts.browser ?? await launchChromium();
|
|
1457
1633
|
const ownsBrowser = !opts.browser;
|
|
1458
1634
|
const page = await browser.newPage();
|
|
@@ -1461,7 +1637,7 @@ async function build(opts) {
|
|
|
1461
1637
|
const diagnose = (code, message, severity = "warning") => diagnostics.push({ code, severity, message });
|
|
1462
1638
|
let prints = 0;
|
|
1463
1639
|
try {
|
|
1464
|
-
const url = /^(https?|file):\/\//.test(opts.input) ? opts.input : pathToFileURL(
|
|
1640
|
+
const url = /^(https?|file):\/\//.test(opts.input) ? opts.input : pathToFileURL(resolve2(opts.input)).href;
|
|
1465
1641
|
await page.navigate(url);
|
|
1466
1642
|
await page.evaluate(AGENT);
|
|
1467
1643
|
await page.waitForReady();
|
|
@@ -2503,4 +2679,4 @@ ${lines.length ? lines.join(`
|
|
|
2503
2679
|
`);
|
|
2504
2680
|
}
|
|
2505
2681
|
|
|
2506
|
-
export { lastPageMode, extract, resolvePage, MARGIN_BOX_IGNORED_PROPERTIES, build };
|
|
2682
|
+
export { lastPageMode, extract, resolvePage, getAssetPath, MARGIN_BOX_IGNORED_PROPERTIES, build };
|
|
@@ -1,28 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EXTENSION_MANIFEST_FILENAME,
|
|
3
3
|
TWO_VERSIONS_OPEN,
|
|
4
|
+
bundledExtension,
|
|
4
5
|
extensionCarries,
|
|
5
6
|
extensionStyleList,
|
|
7
|
+
isPathSpecifier,
|
|
6
8
|
loadPlugin,
|
|
9
|
+
parseExtensionSpecifier,
|
|
10
|
+
pinnedNpmSpecifier,
|
|
7
11
|
prettify,
|
|
8
12
|
readExtensionMeta,
|
|
9
13
|
slugify
|
|
10
|
-
} from "./cli-
|
|
14
|
+
} from "./cli-pwwfxdgb.js";
|
|
11
15
|
import {
|
|
12
16
|
log
|
|
13
|
-
} from "./cli-
|
|
17
|
+
} from "./cli-aqh6brew.js";
|
|
14
18
|
import {
|
|
15
19
|
UsageError
|
|
16
20
|
} from "./cli-d8xjns66.js";
|
|
17
|
-
import {
|
|
18
|
-
getAssetsDir
|
|
19
|
-
} from "./cli-1ngqzg8s.js";
|
|
20
21
|
import {
|
|
21
22
|
BuildError,
|
|
22
23
|
EXIT_CODES
|
|
23
24
|
} from "./cli-46ycxe6r.js";
|
|
24
25
|
import {
|
|
25
|
-
|
|
26
|
+
EXTENSIONS_DIR,
|
|
26
27
|
VENDORED_NPM_DIR,
|
|
27
28
|
assertWindowsSafeRelativePath,
|
|
28
29
|
isExactNpmVersion,
|
|
@@ -31,8 +32,9 @@ import {
|
|
|
31
32
|
resolveVendoredPluginInstallRoot,
|
|
32
33
|
vendoredNpmPluginPackageDir,
|
|
33
34
|
vendoredNpmPluginRoot,
|
|
35
|
+
vendoredNpmPluginRoots,
|
|
34
36
|
windowsPathKey
|
|
35
|
-
} from "./cli-
|
|
37
|
+
} from "./cli-y28j019d.js";
|
|
36
38
|
import {
|
|
37
39
|
__require
|
|
38
40
|
} from "./cli-37x76zdn.js";
|
|
@@ -74,7 +76,7 @@ async function withFetchTimeout(options, run) {
|
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
// src/lib/extension-manager.ts
|
|
77
|
-
import {
|
|
79
|
+
import { readdir, readFile as readFile5, rm as rm3, stat } from "node:fs/promises";
|
|
78
80
|
import { existsSync as existsSync3 } from "node:fs";
|
|
79
81
|
import path4 from "node:path";
|
|
80
82
|
import { isSeq as isSeq2, isMap, isScalar, YAMLMap, Scalar } from "yaml";
|
|
@@ -92,43 +94,6 @@ import { existsSync, statSync } from "node:fs";
|
|
|
92
94
|
import { resolve, dirname } from "node:path";
|
|
93
95
|
import { parse as parseYaml, YAMLParseError } from "yaml";
|
|
94
96
|
|
|
95
|
-
// src/lib/extension-specifier.ts
|
|
96
|
-
var BUNDLED_EXTENSIONS = [
|
|
97
|
-
"markdown-it-mark",
|
|
98
|
-
"markdown-it-sub",
|
|
99
|
-
"markdown-it-sup",
|
|
100
|
-
"markdown-it-abbr",
|
|
101
|
-
"gutterpress-gfm-alerts"
|
|
102
|
-
];
|
|
103
|
-
function isBundledExtension(name) {
|
|
104
|
-
return BUNDLED_EXTENSIONS.includes(name);
|
|
105
|
-
}
|
|
106
|
-
function isPathSpecifier(use) {
|
|
107
|
-
return use.startsWith("./") || use.startsWith("../") || use.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(use);
|
|
108
|
-
}
|
|
109
|
-
function parseExtensionSpecifier(use) {
|
|
110
|
-
const spec = use.trim();
|
|
111
|
-
if (!spec) {
|
|
112
|
-
throw new Error("An extension specifier is required — an npm package name, or a ./ path.");
|
|
113
|
-
}
|
|
114
|
-
if (isPathSpecifier(spec))
|
|
115
|
-
return { kind: "path", path: spec };
|
|
116
|
-
if (/\.(m?js|cjs)$/i.test(spec) || !spec.startsWith("@") && spec.includes("/")) {
|
|
117
|
-
throw new Error(`"${spec}" looks like a path — write it as "./${spec}". A specifier that does not ` + "start with ./, ../ or / is an npm package name.");
|
|
118
|
-
}
|
|
119
|
-
const parsed = parseNpmPluginSpec(spec);
|
|
120
|
-
if (isBundledExtension(parsed.name)) {
|
|
121
|
-
if (parsed.selector !== undefined) {
|
|
122
|
-
throw new Error(`"${parsed.name}" is bundled with Gutterpress and always resolves to the bundled copy — ` + `drop "@${parsed.selector}".`);
|
|
123
|
-
}
|
|
124
|
-
return { kind: "bundled", name: parsed.name };
|
|
125
|
-
}
|
|
126
|
-
return parsed.selector === undefined ? { kind: "npm", name: parsed.name } : { kind: "npm", name: parsed.name, version: parsed.selector };
|
|
127
|
-
}
|
|
128
|
-
function pinnedNpmSpecifier(name, version) {
|
|
129
|
-
return `${name}@${version}`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
97
|
// src/lib/presets.ts
|
|
133
98
|
var PRESET_IDS = ["dtrpg", "book", "custom"];
|
|
134
99
|
var DTRPG_PRESET = {
|
|
@@ -569,6 +534,15 @@ function mergeShape(cli, manifest, preset) {
|
|
|
569
534
|
}
|
|
570
535
|
return out;
|
|
571
536
|
}
|
|
537
|
+
var LANGUAGE_TAG = /^[a-zA-Z]{2,3}(-[a-zA-Z0-9]{2,8})*$/;
|
|
538
|
+
function resolveLanguage(value) {
|
|
539
|
+
if (value === undefined)
|
|
540
|
+
return "en";
|
|
541
|
+
if (typeof value !== "string" || !LANGUAGE_TAG.test(value)) {
|
|
542
|
+
throw new UsageError(`Manifest field \`language\` must be a language tag such as "en", "de" or "pt-BR", got ${JSON.stringify(value)}.`);
|
|
543
|
+
}
|
|
544
|
+
return value;
|
|
545
|
+
}
|
|
572
546
|
function resolveConfig(cliOverrides, manifest) {
|
|
573
547
|
const presetName = cliOverrides.preset ?? manifest.preset;
|
|
574
548
|
return resolveWithPreset(cliOverrides, manifest, resolvePreset(presetName));
|
|
@@ -656,6 +630,7 @@ function resolveWithPreset(cliOverrides, manifest, preset) {
|
|
|
656
630
|
return {
|
|
657
631
|
title: c.title ?? m.title ?? "Document",
|
|
658
632
|
authors: c.authors ?? m.authors ?? [],
|
|
633
|
+
language: resolveLanguage(c.language ?? m.language),
|
|
659
634
|
preset: preset.id,
|
|
660
635
|
spec: preset.spec,
|
|
661
636
|
styles: c.styles ?? m.styles,
|
|
@@ -1272,13 +1247,13 @@ async function removeEmptyDirs(dirs) {
|
|
|
1272
1247
|
}
|
|
1273
1248
|
}
|
|
1274
1249
|
async function prepareVendorParent(projectDir, name) {
|
|
1275
|
-
const
|
|
1276
|
-
const npm = path2.join(
|
|
1250
|
+
const extensions = path2.join(projectDir, EXTENSIONS_DIR);
|
|
1251
|
+
const npm = path2.join(extensions, VENDORED_NPM_DIR);
|
|
1277
1252
|
const packageParent = path2.dirname(vendoredNpmPluginRoot(projectDir, name, "0.0.0"));
|
|
1278
1253
|
await mkdir2(projectDir, { recursive: true });
|
|
1279
1254
|
const createdDirs = [];
|
|
1280
1255
|
try {
|
|
1281
|
-
for (const dir of [
|
|
1256
|
+
for (const dir of [extensions, npm, packageParent]) {
|
|
1282
1257
|
if (await ensureDirectory(dir))
|
|
1283
1258
|
createdDirs.push(dir);
|
|
1284
1259
|
}
|
|
@@ -1397,7 +1372,7 @@ function ignoreStatus(gitignore, entry) {
|
|
|
1397
1372
|
return "ignored";
|
|
1398
1373
|
return dir.unignored || file.unignored ? "negated" : "open";
|
|
1399
1374
|
}
|
|
1400
|
-
var PROJECT_GITIGNORE_ENTRIES = ["dist/", "
|
|
1375
|
+
var PROJECT_GITIGNORE_ENTRIES = ["dist/", "extensions/npm/"];
|
|
1401
1376
|
async function ensureProjectGitignore(projectDir) {
|
|
1402
1377
|
const gitignorePath = path3.join(projectDir, ".gitignore");
|
|
1403
1378
|
let existing = null;
|
|
@@ -1425,35 +1400,6 @@ async function ensureProjectGitignore(projectDir) {
|
|
|
1425
1400
|
}
|
|
1426
1401
|
|
|
1427
1402
|
// src/lib/extension-manager.ts
|
|
1428
|
-
var EXTENSIONS_DIR = "extensions";
|
|
1429
|
-
var RECOMMENDED_EXTENSIONS = [
|
|
1430
|
-
{
|
|
1431
|
-
use: "markdown-it-mark",
|
|
1432
|
-
label: "Highlight",
|
|
1433
|
-
description: "Highlight text by wrapping it in `==double equals==`."
|
|
1434
|
-
},
|
|
1435
|
-
{
|
|
1436
|
-
use: "markdown-it-sub",
|
|
1437
|
-
label: "Subscript",
|
|
1438
|
-
description: "Lower text below the line, like the 2 in `H~2~O`."
|
|
1439
|
-
},
|
|
1440
|
-
{
|
|
1441
|
-
use: "markdown-it-sup",
|
|
1442
|
-
label: "Superscript",
|
|
1443
|
-
description: "Raise text above the line, like the th in `29^th^`."
|
|
1444
|
-
},
|
|
1445
|
-
{
|
|
1446
|
-
use: "markdown-it-abbr",
|
|
1447
|
-
label: "Abbreviations",
|
|
1448
|
-
description: "Explain an abbreviation when readers hover over it. Define it once, like `*[GPS]: Global Positioning System`."
|
|
1449
|
-
},
|
|
1450
|
-
{
|
|
1451
|
-
use: "gutterpress-gfm-alerts",
|
|
1452
|
-
label: "Callouts",
|
|
1453
|
-
description: "Turn a quote into a boxed note: start it with `> [!NOTE]` (or `TIP`, `IMPORTANT`, `WARNING`, `CAUTION`)."
|
|
1454
|
-
}
|
|
1455
|
-
];
|
|
1456
|
-
var BUILT_IN_STYLE_SET_IDS = ["clean-book", "zine", "technical-doc"];
|
|
1457
1403
|
var mutationQueues = new Map;
|
|
1458
1404
|
function projectKey(projectDir) {
|
|
1459
1405
|
const resolved = path4.resolve(projectDir);
|
|
@@ -1569,15 +1515,14 @@ async function describeEntry(projectDir, raw) {
|
|
|
1569
1515
|
return withWarnings({ ...common, kind: "npm", name: raw.use, label: raw.use, carries: NO_CARRIES });
|
|
1570
1516
|
}
|
|
1571
1517
|
if (parsed.kind === "bundled") {
|
|
1572
|
-
const
|
|
1573
|
-
const rec = RECOMMENDED_EXTENSIONS.find((r) => r.use === bundledName);
|
|
1518
|
+
const bundled = bundledExtension(parsed.name);
|
|
1574
1519
|
return withWarnings({
|
|
1575
1520
|
...common,
|
|
1576
1521
|
kind: "bundled",
|
|
1577
|
-
name:
|
|
1578
|
-
label:
|
|
1579
|
-
|
|
1580
|
-
carries: { ...NO_CARRIES, markdown: true }
|
|
1522
|
+
name: parsed.name,
|
|
1523
|
+
label: bundled.label,
|
|
1524
|
+
description: bundled.description,
|
|
1525
|
+
carries: { ...NO_CARRIES, ...bundled.css !== undefined ? { styles: true } : { markdown: true } }
|
|
1581
1526
|
});
|
|
1582
1527
|
}
|
|
1583
1528
|
if (parsed.kind === "path") {
|
|
@@ -1699,9 +1644,10 @@ async function removeExtension(projectDir, use) {
|
|
|
1699
1644
|
return;
|
|
1700
1645
|
}
|
|
1701
1646
|
if (parsed.kind === "npm" && parsed.version) {
|
|
1702
|
-
const root
|
|
1703
|
-
|
|
1704
|
-
|
|
1647
|
+
for (const root of vendoredNpmPluginRoots(projectDir, parsed.name, parsed.version)) {
|
|
1648
|
+
await rm3(root, { recursive: true, force: true });
|
|
1649
|
+
await removeEmptyDirs([path4.dirname(root)]);
|
|
1650
|
+
}
|
|
1705
1651
|
}
|
|
1706
1652
|
});
|
|
1707
1653
|
}
|
|
@@ -1819,8 +1765,8 @@ async function vendorNpmExtension(projectDir, input, exportName, options, commit
|
|
|
1819
1765
|
});
|
|
1820
1766
|
try {
|
|
1821
1767
|
const { negated } = await ensureProjectGitignore(projectDir);
|
|
1822
|
-
if (negated.includes("
|
|
1823
|
-
warnings.push("Your .gitignore re-includes
|
|
1768
|
+
if (negated.includes("extensions/npm/")) {
|
|
1769
|
+
warnings.push("Your .gitignore re-includes extensions/npm/, so downloaded extensions will be committed with " + "your book. They shouldn't be: the manifest pins each version and a build downloads a " + "missing copy again.");
|
|
1824
1770
|
}
|
|
1825
1771
|
} catch (error) {
|
|
1826
1772
|
warnings.push(`The extension was installed, but .gitignore could not be updated to keep it out of version history: ` + `${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -1846,24 +1792,32 @@ async function pinnedVersionsOf(projectDir, name) {
|
|
|
1846
1792
|
return versions;
|
|
1847
1793
|
}
|
|
1848
1794
|
async function pruneStaleVersions(projectDir, name, keep) {
|
|
1849
|
-
const
|
|
1795
|
+
const parents = vendoredNpmPluginRoots(projectDir, name, "0.0.0").map((root) => path4.dirname(root));
|
|
1850
1796
|
try {
|
|
1851
|
-
for (const
|
|
1852
|
-
|
|
1853
|
-
continue;
|
|
1854
|
-
let version;
|
|
1797
|
+
for (const parent of parents) {
|
|
1798
|
+
let entries;
|
|
1855
1799
|
try {
|
|
1856
|
-
|
|
1857
|
-
} catch {
|
|
1858
|
-
|
|
1800
|
+
entries = await readdir(parent, { withFileTypes: true });
|
|
1801
|
+
} catch (error) {
|
|
1802
|
+
if (error.code === "ENOENT")
|
|
1803
|
+
continue;
|
|
1804
|
+
throw error;
|
|
1805
|
+
}
|
|
1806
|
+
for (const entry of entries) {
|
|
1807
|
+
if (!entry.isDirectory())
|
|
1808
|
+
continue;
|
|
1809
|
+
let version;
|
|
1810
|
+
try {
|
|
1811
|
+
version = decodeURIComponent(entry.name);
|
|
1812
|
+
} catch {
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
if (!isExactNpmVersion(version) || keep.includes(version))
|
|
1816
|
+
continue;
|
|
1817
|
+
await rm3(path4.join(parent, entry.name), { recursive: true, force: true });
|
|
1859
1818
|
}
|
|
1860
|
-
if (!isExactNpmVersion(version) || keep.includes(version))
|
|
1861
|
-
continue;
|
|
1862
|
-
await rm3(path4.join(parent, entry.name), { recursive: true, force: true });
|
|
1863
1819
|
}
|
|
1864
1820
|
} catch (error) {
|
|
1865
|
-
if (error.code === "ENOENT")
|
|
1866
|
-
return [];
|
|
1867
1821
|
return [
|
|
1868
1822
|
`The extension was installed, but a previous version's downloaded copy could not be removed: ` + `${error instanceof Error ? error.message : String(error)}`
|
|
1869
1823
|
];
|
|
@@ -1954,20 +1908,6 @@ async function uniqueExtensionId(projectDir, base) {
|
|
|
1954
1908
|
}
|
|
1955
1909
|
return candidate;
|
|
1956
1910
|
}
|
|
1957
|
-
async function addBuiltInStyleSet(projectDir, id) {
|
|
1958
|
-
if (!BUILT_IN_STYLE_SET_IDS.includes(id)) {
|
|
1959
|
-
throw new Error(`Unknown built-in look "${id}" (one of: ${BUILT_IN_STYLE_SET_IDS.join(", ")}).`);
|
|
1960
|
-
}
|
|
1961
|
-
return withMutationLock(projectDir, async () => {
|
|
1962
|
-
const dest = path4.join(projectDir, EXTENSIONS_DIR, id);
|
|
1963
|
-
if (!existsSync3(dest)) {
|
|
1964
|
-
const src = path4.join(await getAssetsDir(), "themes", id);
|
|
1965
|
-
await mkdir3(path4.dirname(dest), { recursive: true });
|
|
1966
|
-
await cp(src, dest, { recursive: true });
|
|
1967
|
-
}
|
|
1968
|
-
return addExtensionUnlocked(projectDir, `./${EXTENSIONS_DIR}/${id}`, {});
|
|
1969
|
-
});
|
|
1970
|
-
}
|
|
1971
1911
|
|
|
1972
1912
|
// src/lib/extension-restore.ts
|
|
1973
1913
|
var OFFLINE_REASON = "you appear to be offline (npm can't be reached)";
|
|
@@ -2086,4 +2026,4 @@ async function restoreForCommand(dir, options) {
|
|
|
2086
2026
|
log.warn(problem);
|
|
2087
2027
|
}
|
|
2088
2028
|
|
|
2089
|
-
export {
|
|
2029
|
+
export { PRESET_IDS, PRESETS, TARGETS, TARGET_IDS, publishTargetFor, resolveTargets, applyDefaultPdfStrictChecks, MANIFEST_FILENAMES, loadManifest, loadManifestWithPath, resolveConfig, resolveConfigForTarget, FriendlyHttpError, withFetchTimeout, loadManifestDoc, writeManifestDoc, npmRegistryUrl, ensureProjectGitignore, listProjectExtensions, setExtensionEnabled, removeExtension, addExtension, checkExtensionUpdates, updateExtensions, uniqueExtensionId, restorePinnedExtensions, restoreFailureMessage, restoreOfflineMessage, restoreForCommand };
|