gutterpress 0.0.0

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 (230) hide show
  1. package/README.md +422 -0
  2. package/dist/CGATS21_CRPC1-g0e3k7kr.icc +0 -0
  3. package/dist/api/index.d.ts +76 -0
  4. package/dist/api/index.js +272 -0
  5. package/dist/assets/preview/scripts/pagedjs-bridge.d.ts +1 -0
  6. package/dist/assets/preview/scripts/pagedjs-interface.d.ts +1 -0
  7. package/dist/assets/preview/scripts/preview-shell.d.ts +1 -0
  8. package/dist/audit-1jrwwacz.js +66 -0
  9. package/dist/build-5s92kgpc.js +77 -0
  10. package/dist/chapter-01-6fn9pvd0.md +31 -0
  11. package/dist/chapter-01-7jwqg1ct.md +20 -0
  12. package/dist/chapter-01-jj8ftn4c.md +29 -0
  13. package/dist/chapter-01-rkpyvjna.md +26 -0
  14. package/dist/checks/asset/approved-fonts.d.ts +3 -0
  15. package/dist/checks/asset/extensions.d.ts +41 -0
  16. package/dist/checks/asset/font-license.d.ts +3 -0
  17. package/dist/checks/asset/image-alpha.d.ts +3 -0
  18. package/dist/checks/asset/image-color-space.d.ts +3 -0
  19. package/dist/checks/asset/image-file-size.d.ts +3 -0
  20. package/dist/checks/asset/image-resolution.d.ts +3 -0
  21. package/dist/checks/asset/image-tac.d.ts +3 -0
  22. package/dist/checks/asset/index.d.ts +7 -0
  23. package/dist/checks/formatter.d.ts +3 -0
  24. package/dist/checks/heuristic/index.d.ts +4 -0
  25. package/dist/checks/heuristic/layer-count.d.ts +3 -0
  26. package/dist/checks/heuristic/placement-variance.d.ts +3 -0
  27. package/dist/checks/heuristic/section-density.d.ts +3 -0
  28. package/dist/checks/heuristic/text-density.d.ts +3 -0
  29. package/dist/checks/pdf/bleed.d.ts +3 -0
  30. package/dist/checks/pdf/bookmarks.d.ts +3 -0
  31. package/dist/checks/pdf/color-spaces.d.ts +3 -0
  32. package/dist/checks/pdf/cross-refs.d.ts +3 -0
  33. package/dist/checks/pdf/embedded-fonts.d.ts +3 -0
  34. package/dist/checks/pdf/image-resolution.d.ts +3 -0
  35. package/dist/checks/pdf/index.d.ts +15 -0
  36. package/dist/checks/pdf/ink-coverage.d.ts +3 -0
  37. package/dist/checks/pdf/page-labels.d.ts +3 -0
  38. package/dist/checks/pdf/page-size.d.ts +3 -0
  39. package/dist/checks/pdf/pdfx-markers.d.ts +3 -0
  40. package/dist/checks/pdf/pdfx-metadata.d.ts +3 -0
  41. package/dist/checks/pdf/pdfx-structure.d.ts +6 -0
  42. package/dist/checks/pdf/qpdf-structure.d.ts +3 -0
  43. package/dist/checks/pdf/rasterized-pages.d.ts +3 -0
  44. package/dist/checks/pdf/toc-links.d.ts +3 -0
  45. package/dist/checks/pdf/transparency.d.ts +3 -0
  46. package/dist/checks/policy.d.ts +61 -0
  47. package/dist/checks/register-builtins.d.ts +17 -0
  48. package/dist/checks/registry.d.ts +40 -0
  49. package/dist/checks/runner.d.ts +25 -0
  50. package/dist/checks/source/accessibility-alt-text.d.ts +3 -0
  51. package/dist/checks/source/accessibility-heading-order.d.ts +3 -0
  52. package/dist/checks/source/config-file.d.ts +8 -0
  53. package/dist/checks/source/htmlhint.d.ts +3 -0
  54. package/dist/checks/source/index.d.ts +6 -0
  55. package/dist/checks/source/local-refs.d.ts +3 -0
  56. package/dist/checks/source/markdownlint.d.ts +3 -0
  57. package/dist/checks/source/stylelint.d.ts +3 -0
  58. package/dist/checks/tool-check.d.ts +23 -0
  59. package/dist/checks/types.d.ts +52 -0
  60. package/dist/cli-1tyj4bk3.js +124 -0
  61. package/dist/cli-37x76zdn.js +4 -0
  62. package/dist/cli-506tg37g.js +26 -0
  63. package/dist/cli-5bxx0c4y.js +464 -0
  64. package/dist/cli-7ykx7pp0.js +12378 -0
  65. package/dist/cli-h7phg3ka.js +746 -0
  66. package/dist/cli-hvqjs342.js +284 -0
  67. package/dist/cli-yja077f6.js +92 -0
  68. package/dist/cli.js +157 -0
  69. package/dist/constants.d.ts +17 -0
  70. package/dist/doctor-25zjt8dz.js +57 -0
  71. package/dist/favicon-wkbm9cjn.ico +0 -0
  72. package/dist/git-http-yrb4ag6z.js +17 -0
  73. package/dist/index-1tyj4bk3.js +124 -0
  74. package/dist/index-37x76zdn.js +4 -0
  75. package/dist/index-3h3fef7r.js +15218 -0
  76. package/dist/index-5bxx0c4y.js +464 -0
  77. package/dist/index-yja077f6.js +92 -0
  78. package/dist/index.d.ts +32 -0
  79. package/dist/index.js +310 -0
  80. package/dist/lib/app-heartbeat.d.ts +102 -0
  81. package/dist/lib/asset-inline.d.ts +73 -0
  82. package/dist/lib/browser-pool.d.ts +17 -0
  83. package/dist/lib/build-error.d.ts +52 -0
  84. package/dist/lib/build-fingerprint.d.ts +15 -0
  85. package/dist/lib/build-preflight.d.ts +43 -0
  86. package/dist/lib/build-runner.d.ts +161 -0
  87. package/dist/lib/build-staging.d.ts +64 -0
  88. package/dist/lib/chromium.d.ts +20 -0
  89. package/dist/lib/cli-args.d.ts +45 -0
  90. package/dist/lib/desktop.d.ts +14 -0
  91. package/dist/lib/diagnostics.d.ts +64 -0
  92. package/dist/lib/embedded-assets.d.ts +29 -0
  93. package/dist/lib/exec.d.ts +84 -0
  94. package/dist/lib/fetch-timeout.d.ts +41 -0
  95. package/dist/lib/ghostscript.d.ts +48 -0
  96. package/dist/lib/host-policy.d.ts +75 -0
  97. package/dist/lib/image-inspect.d.ts +32 -0
  98. package/dist/lib/install-hints.d.ts +21 -0
  99. package/dist/lib/lint-runner.d.ts +10 -0
  100. package/dist/lib/manifest-config.d.ts +31 -0
  101. package/dist/lib/manifest-doc.d.ts +25 -0
  102. package/dist/lib/manifest.d.ts +41 -0
  103. package/dist/lib/markdown/assemble.d.ts +78 -0
  104. package/dist/lib/markdown/chapter-id.d.ts +24 -0
  105. package/dist/lib/markdown/images.d.ts +34 -0
  106. package/dist/lib/markdown/index.d.ts +78 -0
  107. package/dist/lib/markdown/markdown-it-paged.d.ts +30 -0
  108. package/dist/lib/markdown/plugins.d.ts +69 -0
  109. package/dist/lib/markdown/renderer.d.ts +111 -0
  110. package/dist/lib/npm-plugin-installer.d.ts +33 -0
  111. package/dist/lib/open-path.d.ts +5 -0
  112. package/dist/lib/output-paths.d.ts +23 -0
  113. package/dist/lib/pagedjs-marker.d.ts +42 -0
  114. package/dist/lib/pagedjs.d.ts +26 -0
  115. package/dist/lib/pagination.d.ts +169 -0
  116. package/dist/lib/pdf-inspect.d.ts +123 -0
  117. package/dist/lib/pdf-parse.d.ts +57 -0
  118. package/dist/lib/plugin-manager.d.ts +108 -0
  119. package/dist/lib/plugin-vendor.d.ts +107 -0
  120. package/dist/lib/presets.d.ts +45 -0
  121. package/dist/lib/printsafe.d.ts +17 -0
  122. package/dist/lib/project-scaffold.d.ts +116 -0
  123. package/dist/lib/project-source.d.ts +140 -0
  124. package/dist/lib/project-templates.d.ts +49 -0
  125. package/dist/lib/publish/butler.d.ts +10 -0
  126. package/dist/lib/publish/command-runner.d.ts +18 -0
  127. package/dist/lib/publish/connect.d.ts +23 -0
  128. package/dist/lib/publish/manifest-publish.d.ts +9 -0
  129. package/dist/lib/publish/providers/azure-swa.d.ts +3 -0
  130. package/dist/lib/publish/providers/drivethrurpg.d.ts +10 -0
  131. package/dist/lib/publish/providers/guided.d.ts +3 -0
  132. package/dist/lib/publish/providers/itch.d.ts +5 -0
  133. package/dist/lib/publish/providers/kdp.d.ts +9 -0
  134. package/dist/lib/publish/providers/shopify.d.ts +5 -0
  135. package/dist/lib/publish/registry.d.ts +5 -0
  136. package/dist/lib/publish/run-publish.d.ts +30 -0
  137. package/dist/lib/publish/selections.d.ts +25 -0
  138. package/dist/lib/publish/types.d.ts +258 -0
  139. package/dist/lib/remote-auth/clone.d.ts +87 -0
  140. package/dist/lib/remote-auth/conflict-resolution.d.ts +29 -0
  141. package/dist/lib/remote-auth/diagnose.d.ts +77 -0
  142. package/dist/lib/remote-auth/generic-auth.d.ts +97 -0
  143. package/dist/lib/remote-auth/git-http.d.ts +85 -0
  144. package/dist/lib/remote-auth/github-auth.d.ts +69 -0
  145. package/dist/lib/remote-auth/github-repos.d.ts +64 -0
  146. package/dist/lib/remote-auth/operation-log.d.ts +66 -0
  147. package/dist/lib/remote-auth/recovery/abort-interrupted-operation.d.ts +103 -0
  148. package/dist/lib/remote-auth/recovery/backup.d.ts +113 -0
  149. package/dist/lib/remote-auth/recovery/classify.d.ts +109 -0
  150. package/dist/lib/remote-auth/recovery/context.d.ts +47 -0
  151. package/dist/lib/remote-auth/recovery/dispatch.d.ts +33 -0
  152. package/dist/lib/remote-auth/recovery/failsafe.d.ts +33 -0
  153. package/dist/lib/remote-auth/recovery/inspect.d.ts +74 -0
  154. package/dist/lib/remote-auth/recovery/manual-guidance.d.ts +28 -0
  155. package/dist/lib/remote-auth/recovery/outcome-mapping.d.ts +58 -0
  156. package/dist/lib/remote-auth/recovery/policy.d.ts +47 -0
  157. package/dist/lib/remote-auth/recovery/recover-auth.d.ts +42 -0
  158. package/dist/lib/remote-auth/recovery/recover-binary-conflict.d.ts +37 -0
  159. package/dist/lib/remote-auth/recovery/recover-corrupt-index.d.ts +40 -0
  160. package/dist/lib/remote-auth/recovery/recover-detached-head.d.ts +70 -0
  161. package/dist/lib/remote-auth/recovery/recover-interrupted-cherry-pick.d.ts +23 -0
  162. package/dist/lib/remote-auth/recovery/recover-interrupted-merge.d.ts +28 -0
  163. package/dist/lib/remote-auth/recovery/recover-interrupted-rebase.d.ts +39 -0
  164. package/dist/lib/remote-auth/recovery/recover-merge-conflict.d.ts +34 -0
  165. package/dist/lib/remote-auth/recovery/recover-missing-git-dir.d.ts +37 -0
  166. package/dist/lib/remote-auth/recovery/recover-missing-objects.d.ts +56 -0
  167. package/dist/lib/remote-auth/recovery/recover-network.d.ts +34 -0
  168. package/dist/lib/remote-auth/recovery/recover-non-fast-forward.d.ts +27 -0
  169. package/dist/lib/remote-auth/recovery/recover-stale-lock.d.ts +76 -0
  170. package/dist/lib/remote-auth/recovery/recover-unrelated-histories.d.ts +44 -0
  171. package/dist/lib/remote-auth/recovery/recover-wrong-remote.d.ts +35 -0
  172. package/dist/lib/remote-auth/recovery/types.d.ts +235 -0
  173. package/dist/lib/remote-auth/resolution-plan.d.ts +64 -0
  174. package/dist/lib/remote-auth/sync-messages.d.ts +26 -0
  175. package/dist/lib/remote-auth/sync-types.d.ts +225 -0
  176. package/dist/lib/remote-auth/sync.d.ts +45 -0
  177. package/dist/lib/remote-auth/test-access.d.ts +47 -0
  178. package/dist/lib/remote-auth/test-support/git-http-server.d.ts +71 -0
  179. package/dist/lib/remote-auth/token-store.d.ts +95 -0
  180. package/dist/lib/remote-auth/transport.d.ts +105 -0
  181. package/dist/lib/slug.d.ts +28 -0
  182. package/dist/lib/snippets.d.ts +39 -0
  183. package/dist/lib/source-provider.d.ts +244 -0
  184. package/dist/lib/static-serve.d.ts +54 -0
  185. package/dist/lib/style-resolver.d.ts +30 -0
  186. package/dist/lib/theme-import.d.ts +70 -0
  187. package/dist/lib/theme-manager.d.ts +128 -0
  188. package/dist/lib/tool-probe.d.ts +37 -0
  189. package/dist/lib/validation-exec.d.ts +47 -0
  190. package/dist/lib/validation-profile.d.ts +18 -0
  191. package/dist/lib/version.d.ts +9 -0
  192. package/dist/lint-f63nxjfj.js +65 -0
  193. package/dist/manifest-n1gh3qw5.yaml +9 -0
  194. package/dist/manifest-ryyg71nf.yaml +9 -0
  195. package/dist/manifest.schema-rn1dpdpn.json +564 -0
  196. package/dist/new-7b08a42h.js +105 -0
  197. package/dist/paged.polyfill-n95pbxfn.js +33288 -0
  198. package/dist/pagedjs-bridge-vn4hk9fx.js +111 -0
  199. package/dist/pagedjs-interface-80g3xa8p.js +498 -0
  200. package/dist/platform.d.ts +100 -0
  201. package/dist/plugin-wf2cbmwc.js +129 -0
  202. package/dist/preflight-tg4mpz1h.js +222 -0
  203. package/dist/preview/file-watcher.d.ts +174 -0
  204. package/dist/preview/http-server.d.ts +45 -0
  205. package/dist/preview/lifecycle.d.ts +67 -0
  206. package/dist/preview/server-context.d.ts +36 -0
  207. package/dist/preview-h2bwbb2x.js +102 -0
  208. package/dist/preview-shell-rghtfmc8.js +155 -0
  209. package/dist/project-source-0tg0r6vm.js +17 -0
  210. package/dist/publish-ztaet53r.js +233 -0
  211. package/dist/render.d.ts +20 -0
  212. package/dist/render.js +682 -0
  213. package/dist/repair-jkp4n3j8.js +171 -0
  214. package/dist/schema/manifest.types.d.ts +218 -0
  215. package/dist/server.d.ts +34 -0
  216. package/dist/source-provider-hp96b5jf.js +46 -0
  217. package/dist/test-helpers/testkit.d.ts +91 -0
  218. package/dist/theme-0yzvthe8.css +65 -0
  219. package/dist/theme-570zmh2t.css +58 -0
  220. package/dist/theme-6a2fngc8.json +6 -0
  221. package/dist/theme-cd6efzjw.json +6 -0
  222. package/dist/theme-nya4nqh6.css +70 -0
  223. package/dist/theme-tqfypc1w.json +6 -0
  224. package/dist/theme-xt0hjb1b.json +6 -0
  225. package/dist/theme-zz2ktzqs.css +60 -0
  226. package/dist/types.d.ts +31 -0
  227. package/dist/utils/file-utils.d.ts +53 -0
  228. package/dist/utils/logger.d.ts +59 -0
  229. package/dist/validate-k2drs19j.js +99 -0
  230. package/package.json +102 -0
@@ -0,0 +1,284 @@
1
+ // package.json
2
+ var package_default = {
3
+ name: "gutterpress",
4
+ version: "0.0.0",
5
+ description: "Markdown-to-PDF converter for professional print layout using Paged.js and Ghostscript.",
6
+ author: "itlackey",
7
+ license: "MPL-2.0",
8
+ keywords: [
9
+ "markdown",
10
+ "pdf",
11
+ "print",
12
+ "pagedjs",
13
+ "ghostscript",
14
+ "book",
15
+ "publishing",
16
+ "ttrpg"
17
+ ],
18
+ repository: {
19
+ type: "git",
20
+ url: "https://github.com/dimm-city/gutterpress.git"
21
+ },
22
+ homepage: "https://github.com/dimm-city/gutterpress#readme",
23
+ bugs: {
24
+ url: "https://github.com/dimm-city/gutterpress/issues"
25
+ },
26
+ type: "module",
27
+ main: "./dist/index.js",
28
+ types: "./dist/index.d.ts",
29
+ bin: {
30
+ gutterpress: "./dist/cli.js"
31
+ },
32
+ exports: {
33
+ ".": {
34
+ types: "./dist/index.d.ts",
35
+ default: "./dist/index.js"
36
+ },
37
+ "./api": {
38
+ types: "./dist/api/index.d.ts",
39
+ default: "./dist/api/index.js"
40
+ },
41
+ "./render": {
42
+ types: "./dist/render.d.ts",
43
+ default: "./dist/render.js"
44
+ }
45
+ },
46
+ files: [
47
+ "dist/",
48
+ "README.md",
49
+ "LICENSE"
50
+ ],
51
+ scripts: {
52
+ "build:library": "rimraf dist && bun build src/index.ts src/api/index.ts --target=node --packages=external --splitting --outdir=dist && bun build src/render.ts --target=node --packages=external --outdir=dist && node scripts/check-render-pure.mjs && tsc -p tsconfig.build.json",
53
+ build: "bun run build:library && bun build src/cli.ts --target=node --packages=external --splitting --outdir=dist",
54
+ prepublishOnly: "bun run build",
55
+ test: "bun test",
56
+ typecheck: "tsc --noEmit"
57
+ },
58
+ engines: {
59
+ bun: ">=1.0.0",
60
+ node: ">=22.0.0"
61
+ },
62
+ dependencies: {
63
+ acorn: "8.16.0",
64
+ chokidar: "^5.0.0",
65
+ citty: "^0.2.0",
66
+ diff3: "0.0.3",
67
+ "es-module-lexer": "2.0.0",
68
+ fflate: "0.8.3",
69
+ glob: "^13.0.0",
70
+ htmlhint: "^1.9.2",
71
+ "isomorphic-git": "^1.38.4",
72
+ "markdown-it": "^14.1.0",
73
+ "markdown-it-abbr": "^2.0.0",
74
+ "markdown-it-attrs": "^4.3.0",
75
+ "markdown-it-deflist": "^3.0.1",
76
+ "markdown-it-footnote": "^4.0.0",
77
+ "markdown-it-mark": "^4.0.0",
78
+ "markdown-it-source-map": "^0.1.1",
79
+ "markdown-it-sub": "^2.0.0",
80
+ "markdown-it-sup": "^2.0.0",
81
+ markdownlint: "^0.40.0",
82
+ "pdf-lib": "^1.17.1",
83
+ postcss: "^8.5.18",
84
+ "puppeteer-core": "^25.0.4",
85
+ "resolve.exports": "2.0.3",
86
+ semver: "7.8.0",
87
+ tar: "7.5.20",
88
+ unpdf: "^1.6.2",
89
+ ws: "^8.21.0",
90
+ yaml: "^2.8.2"
91
+ },
92
+ devDependencies: {
93
+ "@types/bun": "latest",
94
+ "@types/markdown-it": "^14.1.2",
95
+ "@types/node": "^22.0.0",
96
+ "@types/semver": "^7.7.1",
97
+ "@types/ws": "^8.5.13",
98
+ pagedjs: "^0.4.3",
99
+ playwright: "^1.60.0",
100
+ rimraf: "^6.0.0",
101
+ typescript: "^5"
102
+ }
103
+ };
104
+
105
+ // src/lib/build-error.ts
106
+ var EXIT_CODES = {
107
+ OK: 0,
108
+ FINDINGS: 1,
109
+ USAGE: 2,
110
+ PIPELINE: 3
111
+ };
112
+
113
+ class BuildError extends Error {
114
+ exitCode;
115
+ constructor(message, exitCode = EXIT_CODES.PIPELINE, options) {
116
+ super(message, options);
117
+ this.name = "BuildError";
118
+ this.exitCode = exitCode;
119
+ }
120
+ }
121
+
122
+ // src/constants.ts
123
+ var NETWORK = {
124
+ DEFAULT_PORT: 3579
125
+ };
126
+ var DEBOUNCE = {
127
+ FILE_WATCH: 100
128
+ };
129
+
130
+ // src/lib/cli-args.ts
131
+ class UsageError extends Error {
132
+ exitCode;
133
+ constructor(message, exitCode = EXIT_CODES.USAGE) {
134
+ super(message);
135
+ this.name = "UsageError";
136
+ this.exitCode = exitCode;
137
+ }
138
+ }
139
+ function camelCaseFlag(name) {
140
+ return name.replace(/-([a-z0-9])/g, (_, char) => char.toUpperCase());
141
+ }
142
+ function kebabCaseFlag(name) {
143
+ return name.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
144
+ }
145
+ function takesValue(definition) {
146
+ return definition.type === "string" || definition.type === "enum";
147
+ }
148
+ function rejectUnknownFlags(rawArgs, declared, commandName) {
149
+ const longFlags = new Map;
150
+ const shortFlags = new Map;
151
+ for (const [name, definition] of Object.entries(declared)) {
152
+ if (definition.type === "positional")
153
+ continue;
154
+ for (const variant of new Set([
155
+ name,
156
+ camelCaseFlag(name),
157
+ kebabCaseFlag(name)
158
+ ])) {
159
+ longFlags.set(variant, definition);
160
+ }
161
+ const aliases = Array.isArray(definition.alias) ? definition.alias : definition.alias ? [definition.alias] : [];
162
+ for (const alias of aliases) {
163
+ longFlags.set(alias, definition);
164
+ if (alias.length === 1)
165
+ shortFlags.set(alias, definition);
166
+ }
167
+ if (name.length === 1)
168
+ shortFlags.set(name, definition);
169
+ }
170
+ const reject = (option) => {
171
+ throw new UsageError(`gutterpress ${commandName}: unknown option ${option}`);
172
+ };
173
+ const missingValue = (option) => {
174
+ throw new UsageError(`gutterpress ${commandName}: option ${option} requires a value`);
175
+ };
176
+ const isDeclaredOptionBoundary = (token) => {
177
+ if (token === "--" || token === "--help" || token === "-h")
178
+ return true;
179
+ if (token.startsWith("--")) {
180
+ const rawName = token.slice(2).split("=", 1)[0];
181
+ const directDefinition = longFlags.get(rawName);
182
+ if (directDefinition)
183
+ return true;
184
+ if (!rawName.startsWith("no-"))
185
+ return false;
186
+ return longFlags.get(rawName.slice(3))?.type === "boolean";
187
+ }
188
+ return token.startsWith("-") && token.length > 1 && shortFlags.has(token[1]);
189
+ };
190
+ const consumeValue = (index, option) => {
191
+ const value = rawArgs[index + 1];
192
+ if (value === undefined || isDeclaredOptionBoundary(value)) {
193
+ missingValue(option);
194
+ }
195
+ return index + 1;
196
+ };
197
+ for (let i = 0;i < rawArgs.length; i++) {
198
+ const token = rawArgs[i];
199
+ if (token === "--")
200
+ break;
201
+ if (token === "--help" || token === "-h" || token === "-")
202
+ continue;
203
+ if (token.startsWith("--")) {
204
+ const equalsAt = token.indexOf("=");
205
+ const option = equalsAt === -1 ? token : token.slice(0, equalsAt);
206
+ const rawName = option.slice(2);
207
+ const directDefinition = longFlags.get(rawName);
208
+ const negated = !directDefinition && rawName.startsWith("no-");
209
+ const name = negated ? rawName.slice(3) : rawName;
210
+ const definition = directDefinition ?? longFlags.get(name);
211
+ if (!definition)
212
+ throw new UsageError(`gutterpress ${commandName}: unknown option ${option}`);
213
+ if (negated && (definition.type !== "boolean" || equalsAt !== -1))
214
+ reject(option);
215
+ if (!negated && takesValue(definition)) {
216
+ if (equalsAt === -1) {
217
+ i = consumeValue(i, option);
218
+ } else if (token.slice(equalsAt + 1).length === 0) {
219
+ missingValue(option);
220
+ }
221
+ }
222
+ continue;
223
+ }
224
+ if (!token.startsWith("-") || token.length === 1)
225
+ continue;
226
+ const body = token.slice(1);
227
+ for (let j = 0;j < body.length; j++) {
228
+ const alias = body[j];
229
+ const definition = shortFlags.get(alias);
230
+ if (!definition)
231
+ throw new UsageError(`gutterpress ${commandName}: unknown option ${token}`);
232
+ if (takesValue(definition)) {
233
+ const attached = body.slice(j + 1);
234
+ if (attached.length === 0) {
235
+ i = consumeValue(i, `-${alias}`);
236
+ } else if (attached === "=") {
237
+ missingValue(`-${alias}`);
238
+ }
239
+ break;
240
+ }
241
+ }
242
+ }
243
+ }
244
+ function rejectExtraPositionals(positionals, expectedCount, commandName) {
245
+ const extras = (positionals ?? []).slice(expectedCount);
246
+ if (extras.length > 0) {
247
+ throw new UsageError(`gutterpress ${commandName}: unexpected extra argument(s): ${extras.join(" ")}`);
248
+ }
249
+ }
250
+ function parseFormat(raw, opts) {
251
+ if (raw === undefined)
252
+ return opts.default;
253
+ if (raw === "")
254
+ throw new UsageError("--format requires a value.");
255
+ if (raw === "html" || raw === "pdf" || raw === "pdfx")
256
+ return raw;
257
+ throw new UsageError(`Invalid --format value: "${raw}". Expected "html", "pdf", or "pdfx".`);
258
+ }
259
+ function parsePdfxFlavor(raw, format) {
260
+ if (raw === undefined)
261
+ return;
262
+ if (raw === "")
263
+ throw new UsageError("--pdfx-flavor requires a value.");
264
+ if (format !== "pdfx") {
265
+ throw new UsageError(`--pdfx-flavor is only valid with --format pdfx (got --format ${format}).`);
266
+ }
267
+ if (raw === "x1a" || raw === "x3")
268
+ return raw;
269
+ throw new UsageError(`Invalid --pdfx-flavor value: "${raw}". Expected "x1a" or "x3".`);
270
+ }
271
+ function resolvePort(raw) {
272
+ if (raw === undefined)
273
+ return NETWORK.DEFAULT_PORT;
274
+ if (raw === "" || typeof raw === "string" && raw.trim() === "") {
275
+ throw new UsageError("--port requires a value.");
276
+ }
277
+ const n = typeof raw === "number" || typeof raw === "string" ? Number(raw) : NaN;
278
+ if (!Number.isFinite(n) || !Number.isInteger(n) || n < 0 || n > 65535) {
279
+ throw new UsageError(`Invalid --port value: "${raw}". Expected an integer from 0 to 65535 (0 = OS-assigned).`);
280
+ }
281
+ return n;
282
+ }
283
+
284
+ export { package_default, DEBOUNCE, EXIT_CODES, BuildError, UsageError, rejectUnknownFlags, rejectExtraPositionals, parseFormat, parsePdfxFlavor, resolvePort };
@@ -0,0 +1,92 @@
1
+ // src/lib/remote-auth/git-http.ts
2
+ import httpNode from "isomorphic-git/http/node";
3
+ var GIT_HTTP_IDLE_TIMEOUT_MS = 60000;
4
+ var GIT_HTTP_UPLOAD_TIMEOUT_MS = 30 * 60000;
5
+ var SMALL_BODY_MAX_BYTES = 256 * 1024;
6
+ function isSmallBody(body) {
7
+ if (!Array.isArray(body))
8
+ return false;
9
+ let total = 0;
10
+ for (const c of body) {
11
+ const size = c?.byteLength;
12
+ if (typeof size !== "number")
13
+ return false;
14
+ total += size;
15
+ }
16
+ return total <= SMALL_BODY_MAX_BYTES;
17
+ }
18
+ function gitTimeoutError(what, ms) {
19
+ return new Error(`Git network operation timed out after ${Math.round(ms / 1000)}s (${what}); ` + `couldn't reach the remote (ETIMEDOUT).`);
20
+ }
21
+ function withIdleTimeout(http, idleMs = GIT_HTTP_IDLE_TIMEOUT_MS, uploadMs = GIT_HTTP_UPLOAD_TIMEOUT_MS) {
22
+ return {
23
+ async request(options) {
24
+ let timer;
25
+ let trip;
26
+ const tripped = new Promise((_, reject) => {
27
+ trip = reject;
28
+ });
29
+ tripped.catch(() => {});
30
+ const arm = (ms, what) => {
31
+ if (timer)
32
+ clearTimeout(timer);
33
+ timer = setTimeout(() => trip(gitTimeoutError(what, ms)), ms);
34
+ timer.unref?.();
35
+ };
36
+ const disarm = () => {
37
+ if (timer)
38
+ clearTimeout(timer);
39
+ timer = undefined;
40
+ };
41
+ const race = (p) => Promise.race([p, tripped]).catch((e) => {
42
+ p.catch(() => {});
43
+ throw e;
44
+ });
45
+ const body = options.body;
46
+ const isLargeUpload = body != null && !isSmallBody(body);
47
+ arm(isLargeUpload ? uploadMs : idleMs, isLargeUpload ? "the upload did not complete" : "the remote did not respond");
48
+ let res;
49
+ try {
50
+ res = await race(http.request(options));
51
+ } finally {
52
+ disarm();
53
+ }
54
+ const rawBody = res.body;
55
+ if (!rawBody || typeof rawBody[Symbol.asyncIterator] !== "function") {
56
+ return res;
57
+ }
58
+ const source = rawBody[Symbol.asyncIterator]();
59
+ const guardedBody = {
60
+ async next() {
61
+ arm(idleMs, "the remote stopped sending data");
62
+ try {
63
+ const step = await race(source.next());
64
+ disarm();
65
+ return step;
66
+ } catch (e) {
67
+ disarm();
68
+ try {
69
+ Promise.resolve(source.return?.()).catch(() => {});
70
+ } catch {}
71
+ throw e;
72
+ }
73
+ },
74
+ return(value) {
75
+ disarm();
76
+ try {
77
+ return Promise.resolve(source.return?.(value) ?? { done: true, value: undefined });
78
+ } catch {
79
+ return Promise.resolve({ done: true, value: undefined });
80
+ }
81
+ },
82
+ [Symbol.asyncIterator]() {
83
+ return this;
84
+ }
85
+ };
86
+ return { ...res, body: guardedBody };
87
+ }
88
+ };
89
+ }
90
+ var defaultGitHttp = withIdleTimeout(httpNode);
91
+
92
+ export { GIT_HTTP_IDLE_TIMEOUT_MS, GIT_HTTP_UPLOAD_TIMEOUT_MS, SMALL_BODY_MAX_BYTES, isSmallBody, withIdleTimeout, defaultGitHttp };
package/dist/cli.js ADDED
@@ -0,0 +1,157 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ previewArgs
4
+ } from "./cli-506tg37g.js";
5
+ import {
6
+ EXIT_CODES,
7
+ UsageError,
8
+ package_default,
9
+ rejectUnknownFlags
10
+ } from "./cli-hvqjs342.js";
11
+ import {
12
+ __require
13
+ } from "./cli-37x76zdn.js";
14
+
15
+ // src/cli.ts
16
+ import { defineCommand, parseArgs, runMain } from "citty";
17
+ import { statSync } from "node:fs";
18
+ var SUBCOMMANDS = {
19
+ new: () => import("./new-7b08a42h.js").then((m) => m.default),
20
+ preview: () => import("./preview-h2bwbb2x.js").then((m) => m.default),
21
+ build: () => import("./build-5s92kgpc.js").then((m) => m.default),
22
+ publish: () => import("./publish-ztaet53r.js").then((m) => m.default),
23
+ lint: () => import("./lint-f63nxjfj.js").then((m) => m.default),
24
+ validate: () => import("./validate-k2drs19j.js").then((m) => m.default),
25
+ audit: () => import("./audit-1jrwwacz.js").then((m) => m.default),
26
+ preflight: () => import("./preflight-tg4mpz1h.js").then((m) => m.default),
27
+ repair: () => import("./repair-jkp4n3j8.js").then((m) => m.default),
28
+ doctor: () => import("./doctor-25zjt8dz.js").then((m) => m.default),
29
+ plugin: () => import("./plugin-wf2cbmwc.js").then((m) => m.default)
30
+ };
31
+ var VERSION = package_default.version;
32
+ var main = defineCommand({
33
+ meta: {
34
+ name: "gutterpress",
35
+ version: VERSION,
36
+ description: "Markdown to print-ready PDF (and static-site HTML) using Chromium + Paged.js"
37
+ },
38
+ setup({ rawArgs }) {
39
+ return preflightRequiredInvocations(rawArgs);
40
+ },
41
+ subCommands: SUBCOMMANDS
42
+ });
43
+ function exitUsage(error) {
44
+ if (error instanceof UsageError) {
45
+ console.error(error.message);
46
+ process.exit(error.exitCode);
47
+ }
48
+ throw error;
49
+ }
50
+ async function preflightRequiredInvocations(rawArgs) {
51
+ const [command, ...commandArgs] = rawArgs;
52
+ try {
53
+ if (command === "new") {
54
+ const { newArgs } = await import("./new-7b08a42h.js");
55
+ rejectUnknownFlags(commandArgs, newArgs, "new");
56
+ const parsed2 = parseArgs(commandArgs, {
57
+ ...newArgs,
58
+ name: { ...newArgs.name, required: false }
59
+ });
60
+ if (parsed2.name === undefined) {
61
+ throw new UsageError("gutterpress new: missing required positional argument NAME");
62
+ }
63
+ return;
64
+ }
65
+ if (command === "preflight") {
66
+ const { preflightArgs } = await import("./preflight-tg4mpz1h.js");
67
+ rejectUnknownFlags(commandArgs, preflightArgs, "preflight");
68
+ const parsed2 = parseArgs(commandArgs, {
69
+ ...preflightArgs,
70
+ pdf: { ...preflightArgs.pdf, required: false }
71
+ });
72
+ if (parsed2.pdf === undefined) {
73
+ throw new UsageError("gutterpress preflight: missing required argument --pdf");
74
+ }
75
+ return;
76
+ }
77
+ if (command !== "plugin")
78
+ return;
79
+ const [subcommand, ...subcommandArgs] = commandArgs;
80
+ if (subcommand === undefined)
81
+ return;
82
+ if (subcommand === "--" || subcommand === "-") {
83
+ throw new UsageError(`gutterpress plugin: expected a subcommand before ${subcommand}`);
84
+ }
85
+ if (subcommand.startsWith("-"))
86
+ return;
87
+ if (subcommand !== "add") {
88
+ throw new UsageError(`gutterpress plugin: unknown command "${subcommand}"`);
89
+ }
90
+ const { pluginAddArgs } = await import("./plugin-wf2cbmwc.js");
91
+ rejectUnknownFlags(subcommandArgs, pluginAddArgs, "plugin add");
92
+ const parsed = parseArgs(subcommandArgs, {
93
+ ...pluginAddArgs,
94
+ package: { ...pluginAddArgs.package, required: false }
95
+ });
96
+ if (parsed.package === undefined) {
97
+ throw new UsageError("gutterpress plugin add: missing required positional argument PACKAGE");
98
+ }
99
+ } catch (error) {
100
+ exitUsage(error);
101
+ }
102
+ }
103
+ function isDirectory(candidate) {
104
+ try {
105
+ return statSync(candidate).isDirectory();
106
+ } catch {
107
+ return false;
108
+ }
109
+ }
110
+ function editDistance(left, right) {
111
+ let previous = Array.from({ length: right.length + 1 }, (_, i) => i);
112
+ for (let i = 1;i <= left.length; i++) {
113
+ const current = [i];
114
+ for (let j = 1;j <= right.length; j++) {
115
+ current[j] = Math.min(current[j - 1] + 1, previous[j] + 1, previous[j - 1] + (left[i - 1] === right[j - 1] ? 0 : 1));
116
+ }
117
+ previous = current;
118
+ }
119
+ return previous[right.length];
120
+ }
121
+ function closestSubcommand(input) {
122
+ const commands = Object.keys(SUBCOMMANDS);
123
+ const closest = commands.map((command) => ({ command, distance: editDistance(input, command) })).sort((a, b) => a.distance - b.distance)[0];
124
+ if (!closest)
125
+ return;
126
+ return closest.distance <= Math.max(2, Math.floor(input.length / 3)) ? closest.command : undefined;
127
+ }
128
+ function resolveImplicitPreview(rawArgs) {
129
+ try {
130
+ rejectUnknownFlags(rawArgs, previewArgs, "preview");
131
+ } catch {
132
+ return { usePreview: true };
133
+ }
134
+ const positional = parseArgs(rawArgs, previewArgs)._[0];
135
+ return positional === undefined || isDirectory(positional) ? { usePreview: true } : { usePreview: false, unknownCommand: positional };
136
+ }
137
+ var rawArgs = process.argv.slice(2);
138
+ if (rawArgs.length === 1 && rawArgs[0] === "plugin")
139
+ rawArgs.push("--help");
140
+ var wantsHelp = rawArgs.includes("--help") || rawArgs.includes("-h");
141
+ var wantsVersion = rawArgs.length === 1 && (rawArgs[0] === "--version" || rawArgs[0] === "-v");
142
+ var firstArg = rawArgs[0];
143
+ var isKnownSubcommand = firstArg !== undefined && firstArg in SUBCOMMANDS;
144
+ var shouldRun = true;
145
+ if (!wantsHelp && !wantsVersion && !isKnownSubcommand) {
146
+ const implicit = resolveImplicitPreview(rawArgs);
147
+ if (implicit.usePreview) {
148
+ rawArgs.unshift("preview");
149
+ } else {
150
+ const suggestion = closestSubcommand(implicit.unknownCommand);
151
+ console.error(`Unknown command "${implicit.unknownCommand}".` + (suggestion ? ` Did you mean "${suggestion}"?` : ` Run "gutterpress --help" to see available commands.`));
152
+ process.exitCode = EXIT_CODES.USAGE;
153
+ shouldRun = false;
154
+ }
155
+ }
156
+ if (shouldRun)
157
+ runMain(main, { rawArgs });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Application-wide constants
3
+ */
4
+ /**
5
+ * Network-related constants
6
+ */
7
+ export declare const NETWORK: {
8
+ /** Default port for preview server */
9
+ readonly DEFAULT_PORT: 3579;
10
+ };
11
+ /**
12
+ * Debounce delays in milliseconds
13
+ */
14
+ export declare const DEBOUNCE: {
15
+ /** Debounce delay for file watch events */
16
+ readonly FILE_WATCH: 100;
17
+ };
@@ -0,0 +1,57 @@
1
+ import {
2
+ getSystemDiagnostics,
3
+ log
4
+ } from "./cli-h7phg3ka.js";
5
+ import {
6
+ UsageError,
7
+ rejectExtraPositionals,
8
+ rejectUnknownFlags
9
+ } from "./cli-hvqjs342.js";
10
+ import"./cli-37x76zdn.js";
11
+
12
+ // src/commands/doctor.ts
13
+ import { defineCommand } from "citty";
14
+ var commandArgs = {};
15
+ var doctor_default = defineCommand({
16
+ meta: {
17
+ name: "doctor",
18
+ description: "Check system tools used by Gutterpress"
19
+ },
20
+ args: commandArgs,
21
+ async run({ args, rawArgs }) {
22
+ try {
23
+ rejectUnknownFlags(rawArgs, commandArgs, "doctor");
24
+ rejectExtraPositionals(args._, 0, "doctor");
25
+ const diagnostics = await getSystemDiagnostics();
26
+ console.log(`gutterpress ${diagnostics.libVersion}`);
27
+ console.log(`System: ${diagnostics.platform.os} ${diagnostics.platform.arch} ` + `(${diagnostics.platform.release}), Node ${diagnostics.platform.node}`);
28
+ console.log(`Config: ${diagnostics.configDir}`);
29
+ console.log("");
30
+ console.log("Tools:");
31
+ for (const tool of diagnostics.tools) {
32
+ const version = tool.version ? `, ${tool.version}` : "";
33
+ console.log(` [${tool.found ? "ok" : "missing"}] ${tool.name} (${tool.bin}${version})`);
34
+ if (tool.path)
35
+ console.log(` Path: ${tool.path}`);
36
+ console.log(` Used by: ${tool.usedBy.map((use) => use.feature).join(", ")}`);
37
+ if (!tool.found) {
38
+ console.log(" Install:");
39
+ for (const line of tool.installHint.split(/\r?\n/)) {
40
+ console.log(` ${line}`);
41
+ }
42
+ }
43
+ }
44
+ console.log("");
45
+ console.log(`Setup guide: ${diagnostics.docsUrl}`);
46
+ } catch (error) {
47
+ if (error instanceof UsageError) {
48
+ log.error(error.message);
49
+ process.exit(error.exitCode);
50
+ }
51
+ throw error;
52
+ }
53
+ }
54
+ });
55
+ export {
56
+ doctor_default as default
57
+ };
Binary file
@@ -0,0 +1,17 @@
1
+ import {
2
+ GIT_HTTP_IDLE_TIMEOUT_MS,
3
+ GIT_HTTP_UPLOAD_TIMEOUT_MS,
4
+ SMALL_BODY_MAX_BYTES,
5
+ defaultGitHttp,
6
+ isSmallBody,
7
+ withIdleTimeout
8
+ } from "./cli-yja077f6.js";
9
+ import"./cli-37x76zdn.js";
10
+ export {
11
+ withIdleTimeout,
12
+ isSmallBody,
13
+ defaultGitHttp,
14
+ SMALL_BODY_MAX_BYTES,
15
+ GIT_HTTP_UPLOAD_TIMEOUT_MS,
16
+ GIT_HTTP_IDLE_TIMEOUT_MS
17
+ };