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
@@ -1,20 +1,3 @@
1
- // src/lib/build-error.ts
2
- var EXIT_CODES = {
3
- OK: 0,
4
- FINDINGS: 1,
5
- USAGE: 2,
6
- PIPELINE: 3
7
- };
8
-
9
- class BuildError extends Error {
10
- exitCode;
11
- constructor(message, exitCode = EXIT_CODES.PIPELINE, options) {
12
- super(message, options);
13
- this.name = "BuildError";
14
- this.exitCode = exitCode;
15
- }
16
- }
17
-
18
1
  // src/engine/shared/synthesis.ts
19
2
  var RECTO_VERSO_VALUES = /^(right|recto|left|verso)$/;
20
3
  function isRectoVersoBreak(decl) {
@@ -137,201 +120,6 @@ function generatedContentCss(selectors) {
137
120
  `);
138
121
  }
139
122
 
140
- // src/lib/embedded-assets.ts
141
- import { existsSync } from "node:fs";
142
- import { mkdtemp, mkdir, writeFile, readFile } from "node:fs/promises";
143
- import { tmpdir } from "node:os";
144
- import { dirname, join, resolve } from "node:path";
145
- import { fileURLToPath } from "node:url";
146
-
147
- // src/assets/favicon.ico
148
- var favicon_default = "./favicon-272ga6y0.ico";
149
-
150
- // src/assets/manifest.schema.json
151
- var manifest_schema_default = "./manifest.schema-n292sb77.json";
152
-
153
- // src/assets/preview/scripts/preview-interface.js
154
- var preview_interface_default = "./preview-interface-nnmrxyqm.js";
155
-
156
- // src/assets/preview/scripts/preview-bridge.js
157
- var preview_bridge_default = "./preview-bridge-8wjcjec3.js";
158
-
159
- // src/assets/preview/scripts/preview-shell.js
160
- var preview_shell_default = "./preview-shell-wk9k3gcd.js";
161
-
162
- // profiles/CGATS21_CRPC1.icc
163
- var CGATS21_CRPC1_default = "./CGATS21_CRPC1-g0e3k7kr.icc";
164
-
165
- // src/assets/engine/gutterpress-viewer.js
166
- var gutterpress_viewer_default = "./gutterpress-viewer-w7njnkj7.js";
167
-
168
- // src/assets/engine/gutterpress-agent.js
169
- var gutterpress_agent_default = "./gutterpress-agent-d29ry3ak.js";
170
-
171
- // src/assets/templates/book/manifest.yaml
172
- var manifest_default = "./manifest-n1gh3qw5.yaml";
173
-
174
- // src/assets/templates/book/chapter-01.md
175
- var chapter_01_default = "./chapter-01-rkpyvjna.md";
176
-
177
- // src/assets/templates/zine/manifest.yaml
178
- var manifest_default2 = "./manifest-n1gh3qw5.yaml";
179
-
180
- // src/assets/templates/zine/chapter-01.md
181
- var chapter_01_default2 = "./chapter-01-7jwqg1ct.md";
182
-
183
- // src/assets/templates/technical/manifest.yaml
184
- var manifest_default3 = "./manifest-n1gh3qw5.yaml";
185
-
186
- // src/assets/templates/technical/chapter-01.md
187
- var chapter_01_default3 = "./chapter-01-6fn9pvd0.md";
188
-
189
- // src/assets/extension-templates/plugin/package.json
190
- var package_default = "./package-9rv69pxm.json";
191
-
192
- // src/assets/extension-templates/plugin/README.md
193
- var README_default = "./README-vsnsc1b3.md";
194
-
195
- // src/assets/extension-templates/plugin/plugin.js.tpl
196
- var plugin_js_default = "./plugin.js-cswq7wvd.tpl";
197
-
198
- // src/assets/extension-templates/plugin/styles/plugin.css
199
- var plugin_default = "./plugin-spbcem4j.css";
200
-
201
- // src/assets/extension-templates/plugin/snippets/term-box.md
202
- var term_box_default = "./term-box-4y0w7y32.md";
203
-
204
- // src/assets/extension-templates/plugin/test/fixture.md
205
- var fixture_default = "./fixture-2qnyqgb5.md";
206
-
207
- // src/assets/extension-templates/plugin/test/expected.html
208
- var expected_default = "./expected-ycmacem8.html";
209
-
210
- // src/assets/extension-templates/plugin/test/plugin.test.js.tpl
211
- var plugin_test_js_default = "./plugin.test.js-xgxrd8hf.tpl";
212
-
213
- // src/assets/extension-templates/theme/package.json
214
- var package_default2 = "./package-aenwjew3.json";
215
-
216
- // src/assets/extension-templates/theme/README.md
217
- var README_default2 = "./README-3nj919rm.md";
218
-
219
- // src/assets/extension-templates/theme/components.yaml
220
- var components_default = "./components-zzqdpt3m.yaml";
221
-
222
- // src/assets/extension-templates/theme/snippets/callout.md
223
- var callout_default = "./callout-hv56m16h.md";
224
-
225
- // src/assets/extension-templates/theme/styles/tokens.css
226
- var tokens_default = "./tokens-7984461t.css";
227
-
228
- // src/assets/extension-templates/theme/styles/base.css
229
- var base_default = "./base-ypqh9n7f.css";
230
-
231
- // src/assets/extension-templates/theme/styles/components.css
232
- var components_default2 = "./components-aam0fe2z.css";
233
-
234
- // src/assets/extension-templates/theme/styles/page-templates.css
235
- var page_templates_default = "./page-templates-tx9ryt19.css";
236
-
237
- // src/assets/extension-templates/theme/styles/page-rules.css
238
- var page_rules_default = "./page-rules-nsj3aw42.css";
239
-
240
- // src/assets/extension-templates/theme/styles/book.css
241
- var book_default = "./book-ted3tzrp.css";
242
-
243
- // src/assets/themes/clean-book/theme.css
244
- var theme_default = "./theme-j2bagrfx.css";
245
-
246
- // src/assets/themes/clean-book/package.json
247
- var package_default3 = "./package-97gm31sg.json";
248
-
249
- // src/assets/themes/zine/theme.css
250
- var theme_default2 = "./theme-h5recz6c.css";
251
-
252
- // src/assets/themes/zine/package.json
253
- var package_default4 = "./package-gag6ykwn.json";
254
-
255
- // src/assets/themes/technical-doc/theme.css
256
- var theme_default3 = "./theme-nn6d53zy.css";
257
-
258
- // src/assets/themes/technical-doc/package.json
259
- var package_default5 = "./package-nrhkwf2m.json";
260
-
261
- // src/lib/embedded-assets.ts
262
- var __libdir = dirname(fileURLToPath(import.meta.url));
263
- var abs = (p) => resolve(__libdir, p);
264
- var filePath = (v) => v;
265
- var EMBEDDED_ASSETS = {
266
- "favicon.ico": abs(favicon_default),
267
- "manifest.schema.json": abs(filePath(manifest_schema_default)),
268
- "preview/scripts/preview-interface.js": abs(filePath(preview_interface_default)),
269
- "preview/scripts/preview-bridge.js": abs(filePath(preview_bridge_default)),
270
- "preview/scripts/preview-shell.js": abs(filePath(preview_shell_default)),
271
- "profiles/CGATS21_CRPC1.icc": abs(filePath(CGATS21_CRPC1_default)),
272
- "engine/gutterpress-viewer.js": abs(filePath(gutterpress_viewer_default)),
273
- "engine/gutterpress-agent.js": abs(filePath(gutterpress_agent_default)),
274
- "templates/book/manifest.yaml": abs(filePath(manifest_default)),
275
- "templates/book/chapter-01.md": abs(filePath(chapter_01_default)),
276
- "templates/zine/manifest.yaml": abs(filePath(manifest_default2)),
277
- "templates/zine/chapter-01.md": abs(filePath(chapter_01_default2)),
278
- "templates/technical/manifest.yaml": abs(filePath(manifest_default3)),
279
- "templates/technical/chapter-01.md": abs(filePath(chapter_01_default3)),
280
- "extension-templates/plugin/package.json": abs(filePath(package_default)),
281
- "extension-templates/plugin/README.md": abs(filePath(README_default)),
282
- "extension-templates/plugin/plugin.js.tpl": abs(filePath(plugin_js_default)),
283
- "extension-templates/plugin/styles/plugin.css": abs(filePath(plugin_default)),
284
- "extension-templates/plugin/snippets/term-box.md": abs(filePath(term_box_default)),
285
- "extension-templates/plugin/test/fixture.md": abs(filePath(fixture_default)),
286
- "extension-templates/plugin/test/expected.html": abs(filePath(expected_default)),
287
- "extension-templates/plugin/test/plugin.test.js.tpl": abs(filePath(plugin_test_js_default)),
288
- "extension-templates/theme/package.json": abs(filePath(package_default2)),
289
- "extension-templates/theme/README.md": abs(filePath(README_default2)),
290
- "extension-templates/theme/components.yaml": abs(filePath(components_default)),
291
- "extension-templates/theme/snippets/callout.md": abs(filePath(callout_default)),
292
- "extension-templates/theme/styles/tokens.css": abs(filePath(tokens_default)),
293
- "extension-templates/theme/styles/base.css": abs(filePath(base_default)),
294
- "extension-templates/theme/styles/components.css": abs(filePath(components_default2)),
295
- "extension-templates/theme/styles/page-templates.css": abs(filePath(page_templates_default)),
296
- "extension-templates/theme/styles/page-rules.css": abs(filePath(page_rules_default)),
297
- "extension-templates/theme/styles/book.css": abs(filePath(book_default)),
298
- "themes/clean-book/theme.css": abs(filePath(theme_default)),
299
- "themes/clean-book/package.json": abs(filePath(package_default3)),
300
- "themes/zine/theme.css": abs(filePath(theme_default2)),
301
- "themes/zine/package.json": abs(filePath(package_default4)),
302
- "themes/technical-doc/theme.css": abs(filePath(theme_default3)),
303
- "themes/technical-doc/package.json": abs(filePath(package_default5))
304
- };
305
- var extractPromise = null;
306
- async function extractAssets() {
307
- const root = await mkdtemp(join(tmpdir(), "gutterpress-assets-"));
308
- for (const [relPath, srcPath] of Object.entries(EMBEDDED_ASSETS)) {
309
- const dest = join(root, relPath);
310
- await mkdir(dirname(dest), { recursive: true });
311
- const bytes = await readFile(srcPath);
312
- await writeFile(dest, bytes);
313
- }
314
- return root;
315
- }
316
- var SENTINEL_ASSET = "engine/gutterpress-viewer.js";
317
- async function getAssetsDir() {
318
- if (extractPromise) {
319
- try {
320
- const root = await extractPromise;
321
- if (existsSync(join(root, SENTINEL_ASSET))) {
322
- return root;
323
- }
324
- } catch {}
325
- extractPromise = null;
326
- }
327
- extractPromise = extractAssets();
328
- return extractPromise;
329
- }
330
- async function getAssetPath(relPath) {
331
- const root = await getAssetsDir();
332
- return join(root, relPath);
333
- }
334
-
335
123
  // src/engine/shared/margin-box-support.ts
336
124
  var MARGIN_BOX_IGNORED_PROPERTIES = new Set([
337
125
  "transform",
@@ -946,4 +734,4 @@ function specificity(r) {
946
734
  return (r.name ? 2 : 0) + r.pseudos.length;
947
735
  }
948
736
 
949
- export { EXIT_CODES, BuildError, isRectoVersoBreak, wantsRecto, planRectoBlanks, lastPageMode, signaturePadding, parseWhich, stringValueAt, stringSymbols, cssQuote, counterStyleName, restartedPageValues, toFolioPage, leaderMarker, generatedContentCss, getAssetsDir, getAssetPath, MARGIN_BOX_IGNORED_PROPERTIES, isIgnoredMarginBoxProperty, marginBoxRectPt, marginBoxAlign, extract, splitTopLevel, parseSize, resolvePage };
737
+ export { isRectoVersoBreak, wantsRecto, planRectoBlanks, lastPageMode, signaturePadding, parseWhich, stringValueAt, stringSymbols, cssQuote, counterStyleName, restartedPageValues, toFolioPage, leaderMarker, generatedContentCss, MARGIN_BOX_IGNORED_PROPERTIES, isIgnoredMarginBoxProperty, marginBoxRectPt, marginBoxAlign, extract, splitTopLevel, parseSize, resolvePage };
@@ -1,8 +1,12 @@
1
+ import {
2
+ PLUGINS_DIR,
3
+ VENDORED_NPM_DIR
4
+ } from "./index-r7jcsk6h.js";
1
5
  import {
2
6
  capabilitiesFor,
3
7
  detectProjectSource,
4
8
  findEnclosingRepoDir
5
- } from "./cli-v5mp7a6q.js";
9
+ } from "./index-v5mp7a6q.js";
6
10
 
7
11
  // src/lib/git-fs.ts
8
12
  import * as nodeFs from "node:fs";
@@ -82,7 +86,7 @@ var gitFs = {
82
86
  };
83
87
 
84
88
  // src/lib/source-provider.ts
85
- import path3 from "node:path";
89
+ import path2 from "node:path";
86
90
  import git from "isomorphic-git";
87
91
 
88
92
  // src/lib/remote-auth/operation-log.ts
@@ -99,6 +103,52 @@ function sanitizeLogText(value, secrets = []) {
99
103
  }
100
104
  return text.replace(/\/\/[^/\s]*@/g, "//").replace(/([?&](?:access_token|token|password|secret|key|code)=)[^&#\s]*/gi, "$1[redacted]").replace(/\b(Bearer|Basic)\s+[A-Za-z0-9+/_.=~-]+/gi, "$1 [redacted]").replace(/\b(?:gh[pousr]_[A-Za-z0-9_]+|github_pat_[A-Za-z0-9_]+)/g, "[redacted]").replace(/[\s\x00-\x1f\x7f]+/g, " ").trim().slice(0, 6000);
101
105
  }
106
+ function errorLogData(error) {
107
+ const out = { error: error == null ? String(error) : undefined };
108
+ let current = error;
109
+ const seen = new Set;
110
+ for (let depth = 0;depth < 3 && current != null && !seen.has(current); depth++) {
111
+ seen.add(current);
112
+ const prefix = depth === 0 ? "" : `cause${depth}_`;
113
+ if (typeof current !== "object") {
114
+ out[`${prefix}error`] = String(current);
115
+ break;
116
+ }
117
+ const err = current;
118
+ out[`${prefix}error`] = typeof err.message === "string" ? err.message : "Unknown error";
119
+ for (const key of ["code", "name", "caller", "stack", "syscall", "path"]) {
120
+ if (typeof err[key] === "string")
121
+ out[`${prefix}${key}`] = err[key];
122
+ }
123
+ const data = err.data;
124
+ if (data && typeof data === "object") {
125
+ for (const key of [
126
+ "statusCode",
127
+ "reason",
128
+ "prettyDetails",
129
+ "oid",
130
+ "ref",
131
+ "what",
132
+ "filepath",
133
+ "filepaths",
134
+ "bothModified",
135
+ "deleteByUs",
136
+ "deleteByTheirs"
137
+ ]) {
138
+ const value = data[key];
139
+ if (typeof value === "string" || typeof value === "number")
140
+ out[`${prefix}${key}`] = value;
141
+ else if (Array.isArray(value)) {
142
+ out[`${prefix}${key}`] = value.filter((v) => typeof v === "string").slice(0, 50);
143
+ if (value.length > 50)
144
+ out[`${prefix}${key}Count`] = value.length;
145
+ }
146
+ }
147
+ }
148
+ current = err.cause;
149
+ }
150
+ return out;
151
+ }
102
152
  var noop = {
103
153
  debug: () => {},
104
154
  info: () => {},
@@ -131,6 +181,11 @@ function createFileLogger(logFile, operation, minLevel = "debug", options = {})
131
181
  error: (step, message, data) => write("error", step, message, data)
132
182
  };
133
183
  }
184
+ function resolveLogger(logFile, operation, options = {}) {
185
+ if (!logFile)
186
+ return noop;
187
+ return createFileLogger(logFile, operation, "debug", options);
188
+ }
134
189
  function formatData(data, clean) {
135
190
  if (!data)
136
191
  return "";
@@ -147,205 +202,6 @@ function formatData(data, clean) {
147
202
  return parts.length > 0 ? " " + parts.join(" ") : "";
148
203
  }
149
204
 
150
- // src/lib/plugin-vendor.ts
151
- import { lstat, readFile, realpath } from "node:fs/promises";
152
- import path2 from "node:path";
153
- import { exports as resolveExports } from "resolve.exports";
154
- var PLUGINS_DIR = "plugins";
155
- var VENDORED_NPM_DIR = "npm";
156
- var NPM_SEGMENT = /^[a-z0-9][a-z0-9._~-]*$/;
157
- 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-]+)*)?$/;
158
- var WINDOWS_RESERVED = /^(con|prn|aux|nul|clock\$|conin\$|conout\$|com[1-9¹²³]|lpt[1-9¹²³])(?:\..*)?$/i;
159
- function isValidNpmPackageName(name) {
160
- if (!name || name.length > 214 || name !== name.toLowerCase())
161
- return false;
162
- if (name.startsWith("@")) {
163
- const parts = name.slice(1).split("/");
164
- return parts.length === 2 && parts.every((part) => NPM_SEGMENT.test(part));
165
- }
166
- return !name.includes("/") && NPM_SEGMENT.test(name);
167
- }
168
- function parseNpmPluginSpec(input) {
169
- const spec = input.trim();
170
- if (!spec)
171
- throw new Error("An npm package name is required.");
172
- let name = spec;
173
- let selector;
174
- if (spec.startsWith("@")) {
175
- const slash = spec.indexOf("/");
176
- const versionAt = spec.lastIndexOf("@");
177
- if (slash > 1 && versionAt > slash) {
178
- name = spec.slice(0, versionAt);
179
- selector = spec.slice(versionAt + 1);
180
- }
181
- } else {
182
- const versionAt = spec.lastIndexOf("@");
183
- if (versionAt > 0) {
184
- name = spec.slice(0, versionAt);
185
- selector = spec.slice(versionAt + 1);
186
- }
187
- }
188
- if (!isValidNpmPackageName(name)) {
189
- throw new Error(`"${name}" is not a valid npm package name. Use a name like ` + "markdown-it-highlightjs or @scope/markdown-it-plugin.");
190
- }
191
- if (selector !== undefined && !selector) {
192
- throw new Error(`The package spec "${spec}" is missing a selector after @.`);
193
- }
194
- return selector === undefined ? { name } : { name, selector };
195
- }
196
- function isExactNpmVersion(version) {
197
- return EXACT_VERSION.test(version);
198
- }
199
- function encodePathPart(value) {
200
- return encodeURIComponent(value).replace(/[!'()*]/g, (char) => `%${char.charCodeAt(0).toString(16).toUpperCase()}`);
201
- }
202
- function vendoredNpmPluginRoot(projectDir, name, version) {
203
- return path2.join(projectDir, PLUGINS_DIR, VENDORED_NPM_DIR, encodePathPart(name), encodePathPart(version));
204
- }
205
- function vendoredNpmPluginPackageDir(installRoot, name) {
206
- return path2.join(installRoot, "node_modules", ...name.split("/"));
207
- }
208
- function toPosixPath(value) {
209
- return value.split(path2.sep).join("/");
210
- }
211
- function assertWindowsSafeRelativePath(relative) {
212
- if (!relative || relative.includes("\\") || relative.startsWith("/") || /^[a-zA-Z]:/.test(relative)) {
213
- throw new Error(`Unsafe package path: ${relative || "(empty)"}`);
214
- }
215
- const normalized = relative.normalize("NFKC");
216
- const parts = normalized.split("/");
217
- if (parts.some((part) => !part || part === "." || part === "..")) {
218
- throw new Error(`Unsafe package path: ${relative}`);
219
- }
220
- for (const part of parts) {
221
- if (part.length > 255 || /[\u0000-\u001f<>:"|?*]/.test(part) || part.endsWith(".") || part.endsWith(" ") || WINDOWS_RESERVED.test(part)) {
222
- throw new Error(`Package path is invalid on Windows: ${relative}`);
223
- }
224
- }
225
- }
226
- function windowsPathKey(relative) {
227
- return relative.normalize("NFKC").toLowerCase();
228
- }
229
- function isContained(root, candidate) {
230
- const relative = path2.relative(root, candidate);
231
- return relative === "" || !relative.startsWith("..") && !path2.isAbsolute(relative);
232
- }
233
- function object(value) {
234
- return value !== null && typeof value === "object" && !Array.isArray(value) ? value : null;
235
- }
236
- async function readPackageJson(packageDir) {
237
- const packageJsonPath = path2.join(packageDir, "package.json");
238
- const info = await lstat(packageJsonPath);
239
- if (!info.isFile() || info.isSymbolicLink()) {
240
- throw new Error(`Package metadata is not a regular file: ${packageJsonPath}`);
241
- }
242
- const parsed = object(JSON.parse(await readFile(packageJsonPath, "utf8")));
243
- if (!parsed)
244
- throw new Error(`Package metadata is not an object: ${packageJsonPath}`);
245
- return parsed;
246
- }
247
- function packageResolutionTargets(manifest, subpath, condition) {
248
- if (manifest.exports !== undefined) {
249
- try {
250
- const targets2 = resolveExports(manifest, subpath ? `./${subpath}` : ".", { require: condition === "require" }) ?? [];
251
- return targets2.map((target) => ({ target, exact: true }));
252
- } catch {
253
- return [];
254
- }
255
- }
256
- if (subpath)
257
- return [{ target: subpath, exact: false }];
258
- const targets = [
259
- ...condition === "import" && typeof manifest.module === "string" ? [manifest.module] : [],
260
- ...typeof manifest.main === "string" ? [manifest.main] : [],
261
- "index.mjs",
262
- "index.js",
263
- "index.cjs"
264
- ];
265
- return [...new Set(targets)].map((target) => ({ target, exact: false }));
266
- }
267
- function safePackageTarget(target) {
268
- if (!target || target.includes("\\") || target.includes("*") || target.includes("?") || target.includes("#")) {
269
- return null;
270
- }
271
- const relative = target.startsWith("./") ? target.slice(2) : target;
272
- if (!relative || path2.isAbsolute(relative))
273
- return null;
274
- assertWindowsSafeRelativePath(relative);
275
- if (relative.normalize("NFKC").split("/").some((part) => part.toLowerCase() === "node_modules")) {
276
- return null;
277
- }
278
- return relative;
279
- }
280
- async function resolveEntryCandidate(packageDir, resolution) {
281
- const relative = safePackageTarget(resolution.target);
282
- if (!relative)
283
- return null;
284
- const base = path2.resolve(packageDir, ...relative.split("/"));
285
- if (!isContained(packageDir, base))
286
- return null;
287
- const candidates = resolution.exact ? [base] : [
288
- base,
289
- `${base}.mjs`,
290
- `${base}.js`,
291
- `${base}.cjs`,
292
- `${base}.json`,
293
- path2.join(base, "index.mjs"),
294
- path2.join(base, "index.js"),
295
- path2.join(base, "index.cjs"),
296
- path2.join(base, "index.json")
297
- ];
298
- for (const candidate of candidates) {
299
- try {
300
- const info = await lstat(candidate);
301
- if (!info.isFile() || info.isSymbolicLink())
302
- continue;
303
- const extension = path2.extname(candidate);
304
- if (extension && ![".js", ".mjs", ".cjs", ".json"].includes(extension))
305
- continue;
306
- const [realRoot, realCandidate] = await Promise.all([realpath(packageDir), realpath(candidate)]);
307
- if (!isContained(realRoot, realCandidate))
308
- continue;
309
- return toPosixPath(path2.relative(packageDir, realCandidate));
310
- } catch {}
311
- }
312
- return null;
313
- }
314
- async function resolvePackageEntry(packageDir, packageJson) {
315
- const manifest = packageJson ?? await readPackageJson(packageDir);
316
- for (const condition of ["import", "require"]) {
317
- for (const target of packageResolutionTargets(manifest, "", condition)) {
318
- const resolved = await resolveEntryCandidate(packageDir, target);
319
- if (resolved)
320
- return resolved;
321
- }
322
- }
323
- throw new Error("Package has no contained JavaScript entry point.");
324
- }
325
- async function resolveVendoredPluginInstallRoot(projectDir, expectedName, expectedVersion) {
326
- const requestedProjectRoot = path2.resolve(projectDir);
327
- const requestedInstallRoot = vendoredNpmPluginRoot(requestedProjectRoot, expectedName, expectedVersion);
328
- let installInfo;
329
- try {
330
- installInfo = await lstat(requestedInstallRoot);
331
- } catch (error) {
332
- if (error.code === "ENOENT")
333
- return null;
334
- throw error;
335
- }
336
- if (!installInfo.isDirectory() || installInfo.isSymbolicLink()) {
337
- throw new Error("Vendor install root is not a normal directory.");
338
- }
339
- const [realProjectRoot, installRoot] = await Promise.all([
340
- realpath(requestedProjectRoot),
341
- realpath(requestedInstallRoot)
342
- ]);
343
- if (!isContained(realProjectRoot, installRoot)) {
344
- throw new Error("Vendor install root resolves outside the book folder.");
345
- }
346
- return installRoot;
347
- }
348
-
349
205
  // src/lib/source-provider.ts
350
206
  var noopLogger = {
351
207
  debug: () => {},
@@ -363,7 +219,7 @@ var DEFAULT_BRANCH = "main";
363
219
  var SNAPSHOT_STAGING_MARKER = "gutterpress-snapshot-staging";
364
220
  var repoQueues = new Map;
365
221
  function repoLockKey(projectDir) {
366
- const resolved = path3.resolve(projectDir);
222
+ const resolved = path2.resolve(projectDir);
367
223
  try {
368
224
  return gitFs.realpathSync(resolved);
369
225
  } catch {
@@ -453,7 +309,7 @@ async function listWorkdirChanges(dir, cache = {}) {
453
309
  if (workdirOid !== stageOid) {
454
310
  adds.push(filepath);
455
311
  } else {
456
- const fileBytes = await gitFs.promises.readFile(path3.join(dir, filepath));
312
+ const fileBytes = await gitFs.promises.readFile(path2.join(dir, filepath));
457
313
  const { oid: actualOid } = await git.hashBlob({ object: fileBytes });
458
314
  if (actualOid !== stageOid)
459
315
  adds.push(filepath);
@@ -724,10 +580,10 @@ function providerFor(source) {
724
580
  }
725
581
  }
726
582
  function gitDirFor(projectDir) {
727
- return path3.join(projectDir, ".git");
583
+ return path2.join(projectDir, ".git");
728
584
  }
729
585
  function snapshotStagingMarkerPath(projectDir) {
730
- return path3.join(gitDirFor(projectDir), SNAPSHOT_STAGING_MARKER);
586
+ return path2.join(gitDirFor(projectDir), SNAPSHOT_STAGING_MARKER);
731
587
  }
732
588
  var RESTORE_BACKUP_MESSAGE = "Automatic backup before restoring an earlier version";
733
589
  var AUTO_SNAPSHOT_MESSAGE = "Automatic snapshot";
@@ -880,9 +736,9 @@ async function switchBranch(options) {
880
736
  const changedPaths = fromOid && fromOid !== toOid ? await diffCommitPaths(repoDir, fromOid, toOid, cache) : [];
881
737
  return {
882
738
  current: branch,
883
- changedFiles: changedPaths.map((p) => path3.join(repoDir, p))
739
+ changedFiles: changedPaths.map((p) => path2.join(repoDir, p))
884
740
  };
885
741
  });
886
742
  }
887
743
 
888
- export { PLUGINS_DIR, VENDORED_NPM_DIR, isValidNpmPackageName, parseNpmPluginSpec, isExactNpmVersion, vendoredNpmPluginRoot, vendoredNpmPluginPackageDir, assertWindowsSafeRelativePath, windowsPathKey, packageResolutionTargets, safePackageTarget, resolvePackageEntry, resolveVendoredPluginInstallRoot, gitScopeFor, HISTORY_PAGE_LIMIT, withRepoLock, whenGitIdle, __repoLockQueueSizeForTests, resolveGitAuthor, listWorkdirChanges, stageChanges, hasPendingChanges, hasUncommittedChanges, snapshotWorkingTreeUnlocked, isNoChangesError, countUnversionedChanges, providerFor, gitDirFor, snapshotStagingMarkerPath, RESTORE_BACKUP_MESSAGE, AUTO_SNAPSHOT_MESSAGE, restoreVersionWithBackup, SWITCH_BRANCH_SNAPSHOT_MESSAGE, listLocalBranches, switchBranch };
744
+ export { gitFs, errorLogData, resolveLogger, gitScopeFor, HISTORY_PAGE_LIMIT, withRepoLock, whenGitIdle, __repoLockQueueSizeForTests, resolveGitAuthor, listWorkdirChanges, stageChanges, hasPendingChanges, hasUncommittedChanges, snapshotWorkingTreeUnlocked, isNoChangesError, countUnversionedChanges, providerFor, gitDirFor, snapshotStagingMarkerPath, RESTORE_BACKUP_MESSAGE, AUTO_SNAPSHOT_MESSAGE, restoreVersionWithBackup, SWITCH_BRANCH_SNAPSHOT_MESSAGE, listLocalBranches, switchBranch };