gutterpress 0.11.10-alpha.3 → 0.11.10-alpha.7

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 (59) hide show
  1. package/README.md +24 -46
  2. package/dist/api/index.d.ts +1 -1
  3. package/dist/api/index.js +10 -6
  4. package/dist/{build-wvm8haf3.js → build-v8gn687b.js} +7 -6
  5. package/dist/cdp-jg95s674.js +15 -0
  6. package/dist/cdp-smdx6mr3.js +16 -0
  7. package/dist/{cli-w3khh6re.js → cli-2frrxgf3.js} +283 -1142
  8. package/dist/{cli-xk7qfz4m.js → cli-2k72f0ww.js} +1 -4
  9. package/dist/{cli-d8rdk1y7.js → cli-30j93gzt.js} +11 -335
  10. package/dist/{cli-pfczdbyd.js → cli-5qr3z0qa.js} +10 -404
  11. package/dist/{cli-c41yr7he.js → cli-7fkhgtfn.js} +3 -1
  12. package/dist/cli-kkzka31p.js +261 -0
  13. package/dist/{cli-m3jt4tw6.js → cli-wyry8qbw.js} +2 -2
  14. package/dist/cli.js +12 -14
  15. package/dist/{doctor-py6xbmbf.js → doctor-abftekky.js} +3 -3
  16. package/dist/engine/shared/cdp.d.ts +23 -19
  17. package/dist/engine-3gwctsty.js +24 -0
  18. package/dist/engine-mwshptgf.js +25 -0
  19. package/dist/{ext-tg7ntd0y.js → ext-wr3by4tx.js} +7 -6
  20. package/dist/{index-kqftehgy.js → index-dzp0hc2c.js} +4 -2
  21. package/dist/{index-cgbxryk0.js → index-ns8gav3w.js} +344 -1130
  22. package/dist/{index-fnhak0nh.js → index-qf7y4d85.js} +10 -404
  23. package/dist/index-r4wvy5v3.js +267 -0
  24. package/dist/{index-t43k5rq1.js → index-rzm1phg0.js} +23 -356
  25. package/dist/index.d.ts +0 -1
  26. package/dist/index.js +12 -87
  27. package/dist/lib/build-error.d.ts +4 -5
  28. package/dist/lib/build-preflight.d.ts +1 -35
  29. package/dist/lib/build-runner.d.ts +27 -44
  30. package/dist/lib/chromium.d.ts +5 -1
  31. package/dist/lib/engine.d.ts +3 -18
  32. package/dist/lib/extension-manager.d.ts +2 -2
  33. package/dist/lib/extension-manifest.d.ts +1 -1
  34. package/dist/lib/markdown/assemble.d.ts +2 -9
  35. package/dist/lib/markdown/index.d.ts +2 -4
  36. package/dist/lib/markdown/plugins.d.ts +0 -3
  37. package/dist/lib/npm-plugin-installer.d.ts +6 -1
  38. package/dist/lib/plugin-vendor.d.ts +10 -78
  39. package/dist/lib/source-provider.d.ts +1 -1
  40. package/dist/lib/validation-exec.d.ts +5 -6
  41. package/dist/{new-gbjq78y0.js → new-t0m2yyh6.js} +9 -8
  42. package/dist/{preflight-w78jrtm9.js → preflight-tsy2rmyw.js} +7 -6
  43. package/dist/preview/file-watcher.d.ts +4 -43
  44. package/dist/preview/http-server.d.ts +1 -3
  45. package/dist/{preview-bg93vsz1.js → preview-0bqz31w2.js} +7 -6
  46. package/dist/{preview-shell-gqnc5xxe.js → preview-shell-tqndvhbx.js} +5 -7
  47. package/dist/{publish-we0m2hsn.js → publish-38spy866.js} +7 -6
  48. package/dist/render.d.ts +1 -1
  49. package/dist/render.js +1 -9
  50. package/dist/{source-provider-ta09wegv.js → source-provider-pzmz0br9.js} +1 -1
  51. package/dist/{source-provider-7c2ww3bz.js → source-provider-qbthnmqw.js} +1 -1
  52. package/dist/{validate-1tp3nr50.js → validate-k9yge2rh.js} +7 -6
  53. package/package.json +1 -4
  54. package/dist/audit-gw44spqb.js +0 -69
  55. package/dist/engine-qtfrfbpk.js +0 -41
  56. package/dist/engine-trte2tg2.js +0 -40
  57. package/dist/lib/browser-pool.d.ts +0 -35
  58. package/dist/lib/lint-runner.d.ts +0 -29
  59. package/dist/lint-krdp1yec.js +0 -68
@@ -0,0 +1,261 @@
1
+ import {
2
+ requireChromiumExecutable
3
+ } from "./cli-7fkhgtfn.js";
4
+
5
+ // src/engine/shared/cdp.ts
6
+ import { spawn } from "node:child_process";
7
+ import { mkdtempSync, rmSync } from "node:fs";
8
+ import { tmpdir } from "node:os";
9
+ import { join } from "node:path";
10
+ import WebSocket from "ws";
11
+ var REQUIRED_MILESTONE = 148;
12
+ function assertMilestone(product, origin, hint = "") {
13
+ const milestone = Number(/Chrome\/(\d+)/.exec(product)?.[1] ?? 0);
14
+ if (milestone < REQUIRED_MILESTONE) {
15
+ throw new Error(`The Gutterpress engine requires Chromium ${REQUIRED_MILESTONE}+; found ${product} ${origin}.` + (hint ? `
16
+ ${hint}` : ""));
17
+ }
18
+ }
19
+ function readyProbeExpr(timeoutMs) {
20
+ return `(async () => {
21
+ await document.fonts.ready;
22
+ if (window.__gpReadyPending) {
23
+ await new Promise((res) => {
24
+ const t = setTimeout(res, ${timeoutMs});
25
+ document.addEventListener('gp:ready', () => { clearTimeout(t); res(); }, { once: true });
26
+ });
27
+ }
28
+ // two rAFs: let layout settle after fonts swap
29
+ await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
30
+ return true;
31
+ })()`;
32
+ }
33
+ var DEFAULT_PRINT_OPTS = {
34
+ printBackground: true,
35
+ preferCSSPageSize: true,
36
+ generateTaggedPDF: true,
37
+ generateDocumentOutline: true
38
+ };
39
+ var DEFAULT_ARGS = [
40
+ "--headless=new",
41
+ "--no-first-run",
42
+ "--no-default-browser-check",
43
+ "--disable-gpu",
44
+ "--no-sandbox",
45
+ "--hide-scrollbars",
46
+ "--allow-file-access-from-files",
47
+ "--font-render-hinting=none"
48
+ ];
49
+ async function launchChromium(opts = {}) {
50
+ const bin = await requireChromiumExecutable();
51
+ const userDataDir = mkdtempSync(join(tmpdir(), "gp-cdp-"));
52
+ const envArgs = (process.env.GUTTERPRESS_CHROMIUM_ARGS ?? "").split(/\s+/).filter(Boolean);
53
+ const ignored = new Set(opts.ignoreDefaultArgs ?? []);
54
+ const args = [
55
+ "--remote-debugging-port=0",
56
+ `--user-data-dir=${userDataDir}`,
57
+ ...DEFAULT_ARGS.filter((a) => !ignored.has(a)),
58
+ ...envArgs,
59
+ ...opts.args ?? [],
60
+ "about:blank"
61
+ ];
62
+ const proc = spawn(bin, args, { stdio: ["ignore", "pipe", "pipe"] });
63
+ const wsUrl = await readDevToolsUrl(proc);
64
+ const conn = await Connection.open(wsUrl);
65
+ const teardown = async () => {
66
+ const exited = new Promise((r) => proc.once("exit", () => r()));
67
+ try {
68
+ await Promise.race([
69
+ conn.send("Browser.close").then(() => exited),
70
+ new Promise((_, rej) => setTimeout(() => rej(new Error("Browser.close timed out")), 5000))
71
+ ]);
72
+ } catch {
73
+ proc.kill("SIGKILL");
74
+ await exited;
75
+ }
76
+ conn.close();
77
+ rmSync(userDataDir, { recursive: true, force: true });
78
+ };
79
+ const version = await conn.send("Browser.getVersion", {});
80
+ try {
81
+ assertMilestone(version.product, `at ${bin}`, `Install a newer Chrome, Chromium, or Edge, or point CHROMIUM_PATH at a ${REQUIRED_MILESTONE}+ binary.`);
82
+ } catch (e) {
83
+ await teardown();
84
+ throw e;
85
+ }
86
+ const milestone = Number(/Chrome\/(\d+)/.exec(version.product)?.[1] ?? 0);
87
+ return {
88
+ wsUrl,
89
+ version: version.product,
90
+ milestone,
91
+ async newPage() {
92
+ const { targetId } = await conn.send("Target.createTarget", { url: "about:blank" });
93
+ const { sessionId } = await conn.send("Target.attachToTarget", { targetId, flatten: true });
94
+ const s = new SessionImpl(conn, sessionId, targetId);
95
+ await s.send("Page.enable");
96
+ await s.send("Runtime.enable");
97
+ return s;
98
+ },
99
+ close: teardown
100
+ };
101
+ }
102
+ function readDevToolsUrl(proc) {
103
+ return new Promise((resolve, reject) => {
104
+ let buf = "";
105
+ const timer = setTimeout(() => reject(new Error(`Chromium did not report a DevTools URL:
106
+ ${buf}`)), 60000);
107
+ proc.stderr.on("data", (d) => {
108
+ buf += String(d);
109
+ const m = /ws:\/\/[^\s]+/.exec(buf);
110
+ if (m) {
111
+ clearTimeout(timer);
112
+ resolve(m[0]);
113
+ }
114
+ });
115
+ proc.once("exit", (code) => {
116
+ clearTimeout(timer);
117
+ reject(new Error(`Chromium exited (${code}) before listening:
118
+ ${buf}`));
119
+ });
120
+ });
121
+ }
122
+
123
+ class Connection {
124
+ ws;
125
+ id = 0;
126
+ pending = new Map;
127
+ listeners = new Map;
128
+ constructor(ws) {
129
+ this.ws = ws;
130
+ ws.on("message", (raw) => this.dispatch(JSON.parse(String(raw))));
131
+ }
132
+ static async open(url) {
133
+ const ws = new WebSocket(url, { maxPayload: 512 * 1024 * 1024 });
134
+ await new Promise((res, rej) => {
135
+ ws.once("open", () => res());
136
+ ws.once("error", rej);
137
+ });
138
+ return new Connection(ws);
139
+ }
140
+ dispatch(msg) {
141
+ if (msg.id !== undefined) {
142
+ const p = this.pending.get(msg.id);
143
+ if (!p)
144
+ return;
145
+ this.pending.delete(msg.id);
146
+ if (msg.error)
147
+ p.reject(new Error(`${msg.error.message} (${msg.error.code})`));
148
+ else
149
+ p.resolve(msg.result);
150
+ return;
151
+ }
152
+ const key = msg.sessionId ? `${msg.sessionId}:${msg.method}` : msg.method;
153
+ for (const fn of this.listeners.get(key) ?? [])
154
+ fn(msg.params);
155
+ for (const fn of this.listeners.get(msg.method) ?? [])
156
+ fn(msg.params);
157
+ }
158
+ send(method, params = {}, sessionId) {
159
+ const id = ++this.id;
160
+ const payload = { id, method, params };
161
+ if (sessionId)
162
+ payload.sessionId = sessionId;
163
+ return new Promise((resolve, reject) => {
164
+ this.pending.set(id, { resolve, reject });
165
+ this.ws.send(JSON.stringify(payload));
166
+ });
167
+ }
168
+ on(key, fn) {
169
+ let set = this.listeners.get(key);
170
+ if (!set)
171
+ this.listeners.set(key, set = new Set);
172
+ set.add(fn);
173
+ return () => set.delete(fn);
174
+ }
175
+ close() {
176
+ this.ws.close();
177
+ }
178
+ }
179
+
180
+ class SessionImpl {
181
+ conn;
182
+ sessionId;
183
+ targetId;
184
+ constructor(conn, sessionId, targetId) {
185
+ this.conn = conn;
186
+ this.sessionId = sessionId;
187
+ this.targetId = targetId;
188
+ }
189
+ send(method, params = {}) {
190
+ return this.conn.send(method, params, this.sessionId);
191
+ }
192
+ on(event, fn) {
193
+ return this.conn.on(`${this.sessionId}:${event}`, fn);
194
+ }
195
+ async evaluate(expression) {
196
+ const res = await this.send("Runtime.evaluate", {
197
+ expression,
198
+ returnByValue: true,
199
+ awaitPromise: true
200
+ });
201
+ if (res.exceptionDetails) {
202
+ const e = res.exceptionDetails;
203
+ throw new Error(`evaluate failed: ${e.exception?.description ?? e.text}`);
204
+ }
205
+ return res.result.value;
206
+ }
207
+ async waitForLoad(fn) {
208
+ const done = new Promise((resolve) => {
209
+ const off = this.on("Page.loadEventFired", () => {
210
+ off();
211
+ resolve();
212
+ });
213
+ });
214
+ await fn();
215
+ await done;
216
+ }
217
+ async setContent(html, baseUrl = "http://gutterpress.spike/") {
218
+ await this.waitForLoad(async () => {
219
+ const { frameTree } = await this.send("Page.getFrameTree");
220
+ await this.send("Page.setDocumentContent", {
221
+ frameId: frameTree.frame.id,
222
+ html
223
+ });
224
+ });
225
+ }
226
+ async navigate(url) {
227
+ await this.waitForLoad(async () => {
228
+ await this.send("Page.navigate", { url });
229
+ });
230
+ }
231
+ async waitForReady(timeoutMs = 15000) {
232
+ await this.evaluate(readyProbeExpr(timeoutMs));
233
+ }
234
+ async printToPDF(opts = {}) {
235
+ const res = await this.send("Page.printToPDF", {
236
+ ...DEFAULT_PRINT_OPTS,
237
+ transferMode: "ReturnAsStream",
238
+ ...opts
239
+ });
240
+ if (!res.stream)
241
+ return Uint8Array.from(Buffer.from(res.data, "base64"));
242
+ const chunks = [];
243
+ try {
244
+ for (;; ) {
245
+ const c = await this.send("IO.read", { handle: res.stream, size: 8 * 1024 * 1024 });
246
+ if (c.data)
247
+ chunks.push(Buffer.from(c.data, c.base64Encoded ? "base64" : "binary"));
248
+ if (c.eof)
249
+ break;
250
+ }
251
+ } finally {
252
+ await this.send("IO.close", { handle: res.stream }).catch(() => {});
253
+ }
254
+ return new Uint8Array(Buffer.concat(chunks));
255
+ }
256
+ async close() {
257
+ await this.conn.send("Target.closeTarget", { targetId: this.targetId });
258
+ }
259
+ }
260
+
261
+ export { REQUIRED_MILESTONE, assertMilestone, readyProbeExpr, DEFAULT_PRINT_OPTS, launchChromium };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "./cli-xk7qfz4m.js";
3
+ } from "./cli-2k72f0ww.js";
4
4
  import {
5
5
  execCapture,
6
6
  findTool,
@@ -8,7 +8,7 @@ import {
8
8
  isToolAvailable,
9
9
  resolveChromiumExecutable,
10
10
  run
11
- } from "./cli-c41yr7he.js";
11
+ } from "./cli-7fkhgtfn.js";
12
12
  import {
13
13
  __require
14
14
  } from "./cli-37x76zdn.js";
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  UsageError,
7
7
  package_default,
8
8
  rejectUnknownFlags
9
- } from "./cli-xk7qfz4m.js";
9
+ } from "./cli-2k72f0ww.js";
10
10
  import {
11
11
  EXIT_CODES
12
12
  } from "./cli-46ycxe6r.js";
@@ -18,16 +18,14 @@ import {
18
18
  import { defineCommand, parseArgs, runMain } from "citty";
19
19
  import { statSync } from "node:fs";
20
20
  var SUBCOMMANDS = {
21
- new: () => import("./new-gbjq78y0.js").then((m) => m.default),
22
- preview: () => import("./preview-bg93vsz1.js").then((m) => m.default),
23
- build: () => import("./build-wvm8haf3.js").then((m) => m.default),
24
- publish: () => import("./publish-we0m2hsn.js").then((m) => m.default),
25
- lint: () => import("./lint-krdp1yec.js").then((m) => m.default),
26
- validate: () => import("./validate-1tp3nr50.js").then((m) => m.default),
27
- audit: () => import("./audit-gw44spqb.js").then((m) => m.default),
28
- preflight: () => import("./preflight-w78jrtm9.js").then((m) => m.default),
29
- doctor: () => import("./doctor-py6xbmbf.js").then((m) => m.default),
30
- ext: () => import("./ext-tg7ntd0y.js").then((m) => m.default)
21
+ new: () => import("./new-t0m2yyh6.js").then((m) => m.default),
22
+ preview: () => import("./preview-0bqz31w2.js").then((m) => m.default),
23
+ build: () => import("./build-v8gn687b.js").then((m) => m.default),
24
+ publish: () => import("./publish-38spy866.js").then((m) => m.default),
25
+ validate: () => import("./validate-k9yge2rh.js").then((m) => m.default),
26
+ preflight: () => import("./preflight-tsy2rmyw.js").then((m) => m.default),
27
+ doctor: () => import("./doctor-abftekky.js").then((m) => m.default),
28
+ ext: () => import("./ext-wr3by4tx.js").then((m) => m.default)
31
29
  };
32
30
  var VERSION = package_default.version;
33
31
  var main = defineCommand({
@@ -52,7 +50,7 @@ async function preflightRequiredInvocations(rawArgs) {
52
50
  const [command, ...commandArgs] = rawArgs;
53
51
  try {
54
52
  if (command === "new") {
55
- const { newArgs } = await import("./new-gbjq78y0.js");
53
+ const { newArgs } = await import("./new-t0m2yyh6.js");
56
54
  rejectUnknownFlags(commandArgs, newArgs, "new");
57
55
  const parsed = parseArgs(commandArgs, {
58
56
  ...newArgs,
@@ -64,7 +62,7 @@ async function preflightRequiredInvocations(rawArgs) {
64
62
  return;
65
63
  }
66
64
  if (command === "preflight") {
67
- const { preflightArgs } = await import("./preflight-w78jrtm9.js");
65
+ const { preflightArgs } = await import("./preflight-tsy2rmyw.js");
68
66
  rejectUnknownFlags(commandArgs, preflightArgs, "preflight");
69
67
  const parsed = parseArgs(commandArgs, {
70
68
  ...preflightArgs,
@@ -84,7 +82,7 @@ async function preflightRequiredInvocations(rawArgs) {
84
82
  }
85
83
  if (subcommand.startsWith("-"))
86
84
  return;
87
- const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-tg7ntd0y.js");
85
+ const { EXT_SUBCOMMANDS, extAddArgs, extRemoveArgs, extEnableArgs, extDisableArgs } = await import("./ext-wr3by4tx.js");
88
86
  if (!EXT_SUBCOMMANDS.includes(subcommand)) {
89
87
  throw new UsageError(`gutterpress ext: unknown command "${subcommand}"`);
90
88
  }
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  getSystemDiagnostics,
3
3
  log
4
- } from "./cli-m3jt4tw6.js";
4
+ } from "./cli-wyry8qbw.js";
5
5
  import {
6
6
  UsageError,
7
7
  rejectExtraPositionals,
8
8
  rejectUnknownFlags
9
- } from "./cli-xk7qfz4m.js";
10
- import"./cli-c41yr7he.js";
9
+ } from "./cli-2k72f0ww.js";
11
10
  import"./cli-46ycxe6r.js";
11
+ import"./cli-7fkhgtfn.js";
12
12
  import"./cli-37x76zdn.js";
13
13
 
14
14
  // src/commands/doctor.ts
@@ -1,4 +1,3 @@
1
- export declare function findChromium(): string;
2
1
  /**
3
2
  * Gutterpress targets exactly one engine.
4
3
  *
@@ -42,10 +41,13 @@ export declare function findChromium(): string;
42
41
  export declare const REQUIRED_MILESTONE = 148;
43
42
  /**
44
43
  * Refuse to paginate on a browser below the floor. The invariant belongs to
45
- * the `Browser` CONTRACT, not to any one way of obtaining a browser — the
46
- * launch/connect paths and the host-injected path (an Electron
47
- * `EngineBrowser`, `lib/engine.ts`) must enforce the identical rule with the
48
- * identical message, or the two drift (they already had once).
44
+ * the `Browser` CONTRACT, not to any one way of obtaining a browser — every
45
+ * producer of a `Browser` enforces it once, at construction: `launchChromium`
46
+ * below for the CLI's external Chromium, and the desktop's
47
+ * `createElectronEngineBrowser` (packages/desktop/electron/engine-browser.ts)
48
+ * for Electron's bundled one. Consumers (`lib/build-runner.ts`, the compiler)
49
+ * trust a `Browser` they are handed; a second check downstream is drift
50
+ * waiting to happen (the two messages had already diverged once).
49
51
  */
50
52
  export declare function assertMilestone(product: string, origin: string, hint?: string): void;
51
53
  /**
@@ -89,20 +91,22 @@ export interface Session {
89
91
  printToPDF(opts?: Record<string, unknown>): Promise<Uint8Array>;
90
92
  close(): Promise<void>;
91
93
  }
92
- export declare function launchChromium(opts?: {
93
- headless?: boolean;
94
- args?: string[];
95
- }): Promise<Browser>;
96
94
  /**
97
- * Attach to an ALREADY-RUNNING Chromium (a pooled/pre-warmed browser owned by
98
- * the caller, e.g. `browser-pool.ts`'s puppeteer instance via
99
- * `browser.wsEndpoint()`) instead of spawning a new process.
95
+ * Launch the system Chromium and verify it meets {@link REQUIRED_MILESTONE}.
96
+ *
97
+ * Binary resolution is `lib/chromium.ts`'s (`CHROMIUM_PATH`, then standard
98
+ * install locations, then a PATH probe) — the same resolver the preflight
99
+ * presence check and `gutterpress doctor` use, so what they report is what
100
+ * gets launched. Extra flags come from `GUTTERPRESS_CHROMIUM_ARGS`
101
+ * (containers/CI, e.g. `--disable-dev-shm-usage`; see docs/docker.md) and
102
+ * `opts.args`; `opts.ignoreDefaultArgs` removes entries from
103
+ * {@link DEFAULT_ARGS} for a test that needs a host WITHOUT one of them.
100
104
  *
101
- * Deliberately the mirror image of `launchChromium`: same version pin, same
102
- * `Session`/`newPage` machinery (`checkMilestoneAndWrap`, shared below), but
103
- * `close()` only drops OUR websocket connection — it never sends
104
- * `Browser.close`, kills a process, or removes a profile dir, because this
105
- * function didn't create any of those. Ownership of the underlying browser's
106
- * lifecycle stays entirely with whoever handed us `wsUrl`.
105
+ * The launch is also the one and only milestone check: a too-old browser is
106
+ * torn down and rejected here, with the override hint, before any caller
107
+ * gets a `Browser`.
107
108
  */
108
- export declare function connectChromium(wsUrl: string): Promise<Browser>;
109
+ export declare function launchChromium(opts?: {
110
+ args?: string[];
111
+ ignoreDefaultArgs?: string[];
112
+ }): Promise<Browser>;
@@ -0,0 +1,24 @@
1
+ import {
2
+ build
3
+ } from "./index-dzp0hc2c.js";
4
+ import {
5
+ BuildError
6
+ } from "./index-r4wvy5v3.js";
7
+ import"./index-rzm1phg0.js";
8
+ import"./index-37x76zdn.js";
9
+
10
+ // src/lib/engine.ts
11
+ import { writeFile } from "node:fs/promises";
12
+ async function buildNativePdf(htmlFile, outPdf, options, browser) {
13
+ let result;
14
+ try {
15
+ result = await build({ input: htmlFile, browser, ...options });
16
+ } catch (err) {
17
+ throw new BuildError(`PDF build failed: ${err instanceof Error ? err.message : String(err)}`);
18
+ }
19
+ await writeFile(outPdf, result.bytes);
20
+ return result.diagnostics;
21
+ }
22
+ export {
23
+ buildNativePdf
24
+ };
@@ -0,0 +1,25 @@
1
+ import {
2
+ build
3
+ } from "./cli-30j93gzt.js";
4
+ import {
5
+ BuildError
6
+ } from "./cli-46ycxe6r.js";
7
+ import"./cli-kkzka31p.js";
8
+ import"./cli-7fkhgtfn.js";
9
+ import"./cli-37x76zdn.js";
10
+
11
+ // src/lib/engine.ts
12
+ import { writeFile } from "node:fs/promises";
13
+ async function buildNativePdf(htmlFile, outPdf, options, browser) {
14
+ let result;
15
+ try {
16
+ result = await build({ input: htmlFile, browser, ...options });
17
+ } catch (err) {
18
+ throw new BuildError(`PDF build failed: ${err instanceof Error ? err.message : String(err)}`);
19
+ }
20
+ await writeFile(outPdf, result.bytes);
21
+ return result.diagnostics;
22
+ }
23
+ export {
24
+ buildNativePdf
25
+ };
@@ -10,21 +10,22 @@ import {
10
10
  removeExtension,
11
11
  searchNpmExtensions,
12
12
  setExtensionEnabled
13
- } from "./cli-w3khh6re.js";
14
- import"./cli-m3jt4tw6.js";
13
+ } from "./cli-2frrxgf3.js";
14
+ import"./cli-wyry8qbw.js";
15
15
  import {
16
16
  UsageError,
17
17
  exitForUsage,
18
18
  rejectExtraPositionals,
19
19
  rejectUnknownFlags,
20
20
  resolveProjectDir
21
- } from "./cli-xk7qfz4m.js";
22
- import"./cli-d8rdk1y7.js";
23
- import"./cli-c41yr7he.js";
21
+ } from "./cli-2k72f0ww.js";
22
+ import"./cli-30j93gzt.js";
24
23
  import {
25
24
  EXIT_CODES
26
25
  } from "./cli-46ycxe6r.js";
27
- import"./cli-pfczdbyd.js";
26
+ import"./cli-kkzka31p.js";
27
+ import"./cli-7fkhgtfn.js";
28
+ import"./cli-5qr3z0qa.js";
28
29
  import"./cli-v5mp7a6q.js";
29
30
  import"./cli-37x76zdn.js";
30
31
 
@@ -1,10 +1,12 @@
1
1
  import {
2
2
  getAssetPath,
3
3
  isIgnoredMarginBoxProperty,
4
- launchChromium,
5
4
  marginBoxAlign,
6
5
  marginBoxRectPt
7
- } from "./index-t43k5rq1.js";
6
+ } from "./index-r4wvy5v3.js";
7
+ import {
8
+ launchChromium
9
+ } from "./index-rzm1phg0.js";
8
10
 
9
11
  // src/engine/compiler/build.ts
10
12
  import { readFile } from "node:fs/promises";