gutterpress 0.11.21 → 0.11.22-alpha.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.
Files changed (51) hide show
  1. package/README.md +11 -0
  2. package/dist/api/index.d.ts +5 -1
  3. package/dist/api/index.js +67 -46
  4. package/dist/{build-0neyk5h6.js → build-se85j9ec.js} +16 -10
  5. package/dist/cli-5553w972.js +75 -0
  6. package/dist/{cli-b57adna7.js → cli-8hccw62p.js} +9 -201
  7. package/dist/cli-9vy4b6ec.js +2089 -0
  8. package/dist/{cli-sqkccnm7.js → cli-d8xjns66.js} +1 -102
  9. package/dist/{cli-j0drzb6f.js → cli-fbwqv7p4.js} +720 -5428
  10. package/dist/cli-gc9av5hs.js +103 -0
  11. package/dist/cli-gmm3bdeq.js +196 -0
  12. package/dist/cli-h3phdstf.js +200 -0
  13. package/dist/{index-qf7y4d85.js → cli-habkc5ng.js} +12 -258
  14. package/dist/cli-pfrg1r9x.js +3073 -0
  15. package/dist/{cli-j79451n6.js → cli-yejbb9f8.js} +5 -76
  16. package/dist/cli.js +15 -13
  17. package/dist/{doctor-fptq8tvn.js → doctor-bv2t82zd.js} +7 -4
  18. package/dist/{engine-x07q927h.js → engine-h4ehmrvf.js} +4 -3
  19. package/dist/{engine-0b8bt05n.js → engine-qwkyhrej.js} +3 -2
  20. package/dist/{ext-gp624t5c.js → ext-a8ndp142.js} +21 -14
  21. package/dist/extension-restore-926mv2qk.js +16 -0
  22. package/dist/extension-restore-q1f7njec.js +20 -0
  23. package/dist/index-38e18a7j.js +3244 -0
  24. package/dist/{index-mr72vt8n.js → index-5h9a38jn.js} +1 -213
  25. package/dist/{cli-5qr3z0qa.js → index-93pqkvty.js} +63 -207
  26. package/dist/index-dhknsvfz.js +213 -0
  27. package/dist/index-dm7hx46j.js +2208 -0
  28. package/dist/{index-t7r8g75c.js → index-gmfh6n05.js} +4 -2
  29. package/dist/index-r7jcsk6h.js +200 -0
  30. package/dist/{index-mr7zs8mv.js → index-tkjvs1gf.js} +4774 -9354
  31. package/dist/index.js +70 -49
  32. package/dist/lib/extension-manifest.d.ts +22 -1
  33. package/dist/lib/markdown/plugins.d.ts +20 -0
  34. package/dist/lib/markdown/two-versions.d.ts +32 -0
  35. package/dist/lib/publish/plugin-provider.d.ts +16 -0
  36. package/dist/lib/publish/run-publish.d.ts +13 -5
  37. package/dist/lib/publish/types.d.ts +34 -2
  38. package/dist/lib/text-diff.d.ts +43 -0
  39. package/dist/lib/two-versions-markers.d.ts +26 -0
  40. package/dist/lib/version-changes.d.ts +87 -0
  41. package/dist/{new-dre6aw05.js → new-nadp2hvb.js} +23 -16
  42. package/dist/plugins-gy4q9vaa.js +26 -0
  43. package/dist/plugins-yeh4shd7.js +24 -0
  44. package/dist/{preflight-1k1zkg1p.js → preflight-c6q25xqa.js} +18 -11
  45. package/dist/{preview-dtrksvxf.js → preview-y8chv4cb.js} +19 -13
  46. package/dist/{publish-g1ytnrmr.js → publish-3qwvxsxa.js} +40 -23
  47. package/dist/render.js +120 -0
  48. package/dist/{source-provider-pzmz0br9.js → source-provider-2r74a7wp.js} +2 -1
  49. package/dist/{source-provider-qbthnmqw.js → source-provider-qbfknhyy.js} +2 -1
  50. package/dist/{validate-yrrq8639.js → validate-w108kk87.js} +16 -10
  51. package/package.json +1 -1
@@ -3,7 +3,6 @@ import {
3
3
  cssQuote,
4
4
  extract,
5
5
  generatedContentCss,
6
- getAssetPath,
7
6
  isIgnoredMarginBoxProperty,
8
7
  isRectoVersoBreak,
9
8
  leaderMarker,
@@ -19,7 +18,10 @@ import {
19
18
  stringValueAt,
20
19
  toFolioPage,
21
20
  wantsRecto
22
- } from "./index-mr72vt8n.js";
21
+ } from "./index-5h9a38jn.js";
22
+ import {
23
+ getAssetPath
24
+ } from "./index-dhknsvfz.js";
23
25
  import {
24
26
  launchChromium
25
27
  } from "./index-bt0qws5c.js";
@@ -0,0 +1,200 @@
1
+ // src/lib/plugin-vendor.ts
2
+ import { lstat, readFile, realpath } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { exports as resolveExports } from "resolve.exports";
5
+ var PLUGINS_DIR = "plugins";
6
+ var VENDORED_NPM_DIR = "npm";
7
+ var NPM_SEGMENT = /^[a-z0-9][a-z0-9._~-]*$/;
8
+ var EXACT_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
9
+ var WINDOWS_RESERVED = /^(con|prn|aux|nul|clock\$|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\..*)?$/i;
10
+ function isValidNpmPackageName(name) {
11
+ if (!name || name.length > 214 || name !== name.toLowerCase())
12
+ return false;
13
+ if (name.startsWith("@")) {
14
+ const parts = name.slice(1).split("/");
15
+ return parts.length === 2 && parts.every((part) => NPM_SEGMENT.test(part));
16
+ }
17
+ return !name.includes("/") && NPM_SEGMENT.test(name);
18
+ }
19
+ function parseNpmPluginSpec(input) {
20
+ const spec = input.trim();
21
+ if (!spec)
22
+ throw new Error("An npm package name is required.");
23
+ let name = spec;
24
+ let selector;
25
+ if (spec.startsWith("@")) {
26
+ const slash = spec.indexOf("/");
27
+ const versionAt = spec.lastIndexOf("@");
28
+ if (slash > 1 && versionAt > slash) {
29
+ name = spec.slice(0, versionAt);
30
+ selector = spec.slice(versionAt + 1);
31
+ }
32
+ } else {
33
+ const versionAt = spec.lastIndexOf("@");
34
+ if (versionAt > 0) {
35
+ name = spec.slice(0, versionAt);
36
+ selector = spec.slice(versionAt + 1);
37
+ }
38
+ }
39
+ if (!isValidNpmPackageName(name)) {
40
+ throw new Error(`"${name}" is not a valid npm package name. Use a name like ` + "markdown-it-highlightjs or @scope/markdown-it-plugin.");
41
+ }
42
+ if (selector !== undefined && !selector) {
43
+ throw new Error(`The package spec "${spec}" is missing a selector after @.`);
44
+ }
45
+ return selector === undefined ? { name } : { name, selector };
46
+ }
47
+ function isExactNpmVersion(version) {
48
+ return EXACT_VERSION.test(version);
49
+ }
50
+ function encodePathPart(value) {
51
+ return encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
52
+ }
53
+ function vendoredNpmPluginRoot(projectDir, name, version) {
54
+ return path.join(projectDir, PLUGINS_DIR, VENDORED_NPM_DIR, encodePathPart(name), encodePathPart(version));
55
+ }
56
+ function vendoredNpmPluginPackageDir(installRoot, name) {
57
+ return path.join(installRoot, "node_modules", ...name.split("/"));
58
+ }
59
+ function toPosixPath(value) {
60
+ return value.split(path.sep).join("/");
61
+ }
62
+ function assertWindowsSafeRelativePath(relative) {
63
+ if (!relative || relative.includes("\\") || relative.startsWith("/") || /^[a-zA-Z]:/.test(relative)) {
64
+ throw new Error(`Unsafe package path: ${relative || "(empty)"}`);
65
+ }
66
+ const normalized = relative.normalize("NFKC");
67
+ const parts = normalized.split("/");
68
+ if (parts.some((part) => !part || part === "." || part === "..")) {
69
+ throw new Error(`Unsafe package path: ${relative}`);
70
+ }
71
+ for (const part of parts) {
72
+ if (part.length > 255 || /[\u0000-\u001f<>:"|?*]/.test(part) || part.endsWith(".") || part.endsWith(" ") || WINDOWS_RESERVED.test(part)) {
73
+ throw new Error(`Package path is invalid on Windows: ${relative}`);
74
+ }
75
+ }
76
+ }
77
+ function windowsPathKey(relative) {
78
+ return relative.normalize("NFKC").toLowerCase();
79
+ }
80
+ function isContained(root, candidate) {
81
+ const relative = path.relative(root, candidate);
82
+ return relative === "" || !relative.startsWith("..") && !path.isAbsolute(relative);
83
+ }
84
+ function object(value) {
85
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
86
+ }
87
+ async function readPackageJson(packageDir) {
88
+ const packageJsonPath = path.join(packageDir, "package.json");
89
+ const info = await lstat(packageJsonPath);
90
+ if (!info.isFile() || info.isSymbolicLink()) {
91
+ throw new Error(`Package metadata is not a regular file: ${packageJsonPath}`);
92
+ }
93
+ const parsed = object(JSON.parse(await readFile(packageJsonPath, "utf8")));
94
+ if (!parsed)
95
+ throw new Error(`Package metadata is not an object: ${packageJsonPath}`);
96
+ return parsed;
97
+ }
98
+ function packageResolutionTargets(manifest, subpath, condition) {
99
+ if (manifest.exports !== undefined) {
100
+ try {
101
+ const targets2 = resolveExports(manifest, subpath ? `./${subpath}` : ".", { require: condition === "require" }) ?? [];
102
+ return targets2.map((target) => ({ target, exact: true }));
103
+ } catch {
104
+ return [];
105
+ }
106
+ }
107
+ if (subpath)
108
+ return [{ target: subpath, exact: false }];
109
+ const targets = [
110
+ ...condition === "import" && typeof manifest.module === "string" ? [manifest.module] : [],
111
+ ...typeof manifest.main === "string" ? [manifest.main] : [],
112
+ "index.mjs",
113
+ "index.js",
114
+ "index.cjs"
115
+ ];
116
+ return [...new Set(targets)].map((target) => ({ target, exact: false }));
117
+ }
118
+ function safePackageTarget(target) {
119
+ if (!target || target.includes("\\") || target.includes("*") || target.includes("?") || target.includes("#")) {
120
+ return null;
121
+ }
122
+ const relative = target.startsWith("./") ? target.slice(2) : target;
123
+ if (!relative || path.isAbsolute(relative))
124
+ return null;
125
+ assertWindowsSafeRelativePath(relative);
126
+ if (relative.normalize("NFKC").split("/").some((part) => part.toLowerCase() === "node_modules")) {
127
+ return null;
128
+ }
129
+ return relative;
130
+ }
131
+ async function resolveEntryCandidate(packageDir, resolution) {
132
+ const relative = safePackageTarget(resolution.target);
133
+ if (!relative)
134
+ return null;
135
+ const base = path.resolve(packageDir, ...relative.split("/"));
136
+ if (!isContained(packageDir, base))
137
+ return null;
138
+ const candidates = resolution.exact ? [base] : [
139
+ base,
140
+ `${base}.mjs`,
141
+ `${base}.js`,
142
+ `${base}.cjs`,
143
+ `${base}.json`,
144
+ path.join(base, "index.mjs"),
145
+ path.join(base, "index.js"),
146
+ path.join(base, "index.cjs"),
147
+ path.join(base, "index.json")
148
+ ];
149
+ for (const candidate of candidates) {
150
+ try {
151
+ const info = await lstat(candidate);
152
+ if (!info.isFile() || info.isSymbolicLink())
153
+ continue;
154
+ const extension = path.extname(candidate);
155
+ if (extension && ![".js", ".mjs", ".cjs", ".json"].includes(extension))
156
+ continue;
157
+ const [realRoot, realCandidate] = await Promise.all([realpath(packageDir), realpath(candidate)]);
158
+ if (!isContained(realRoot, realCandidate))
159
+ continue;
160
+ return toPosixPath(path.relative(packageDir, realCandidate));
161
+ } catch {}
162
+ }
163
+ return null;
164
+ }
165
+ async function resolvePackageEntry(packageDir, packageJson) {
166
+ const manifest = packageJson ?? await readPackageJson(packageDir);
167
+ for (const condition of ["import", "require"]) {
168
+ for (const target of packageResolutionTargets(manifest, "", condition)) {
169
+ const resolved = await resolveEntryCandidate(packageDir, target);
170
+ if (resolved)
171
+ return resolved;
172
+ }
173
+ }
174
+ throw new Error("Package has no contained JavaScript entry point.");
175
+ }
176
+ async function resolveVendoredPluginInstallRoot(projectDir, expectedName, expectedVersion) {
177
+ const requestedProjectRoot = path.resolve(projectDir);
178
+ const requestedInstallRoot = vendoredNpmPluginRoot(requestedProjectRoot, expectedName, expectedVersion);
179
+ let installInfo;
180
+ try {
181
+ installInfo = await lstat(requestedInstallRoot);
182
+ } catch (error) {
183
+ if (error.code === "ENOENT")
184
+ return null;
185
+ throw error;
186
+ }
187
+ if (!installInfo.isDirectory() || installInfo.isSymbolicLink()) {
188
+ throw new Error("Vendor install root is not a normal directory.");
189
+ }
190
+ const [realProjectRoot, installRoot] = await Promise.all([
191
+ realpath(requestedProjectRoot),
192
+ realpath(requestedInstallRoot)
193
+ ]);
194
+ if (!isContained(realProjectRoot, installRoot)) {
195
+ throw new Error("Vendor install root resolves outside the book folder.");
196
+ }
197
+ return installRoot;
198
+ }
199
+
200
+ export { PLUGINS_DIR, VENDORED_NPM_DIR, isValidNpmPackageName, parseNpmPluginSpec, isExactNpmVersion, vendoredNpmPluginRoot, vendoredNpmPluginPackageDir, toPosixPath, assertWindowsSafeRelativePath, windowsPathKey, packageResolutionTargets, safePackageTarget, resolvePackageEntry, resolveVendoredPluginInstallRoot };