@aexol/spectral 0.9.90 → 0.9.91

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.
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/extensions/pdf/tools/generate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,oCAAoC,CAAC;AACzG,OAAO,KAAK,EAAE,SAAS,EAAa,WAAW,EAA6B,MAAM,aAAa,CAAC;AAiBhG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAuG/E;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO7E"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/extensions/pdf/tools/generate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,oCAAoC,CAAC;AACzG,OAAO,KAAK,EAAE,SAAS,EAAa,WAAW,EAA6B,MAAM,aAAa,CAAC;AAiBhG,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAkH/E;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAO7E"}
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
- import { createDocumentPaths, ensureDir, toDisplayPath } from "../utils/paths.js";
2
+ import { createDocumentPaths, ensureDir, pathToFileHref, toDisplayPath } from "../utils/paths.js";
3
3
  import { printCssWarning, validateHtmlDocument } from "../utils/html.js";
4
4
  import { renderPdf } from "../utils/renderer.js";
5
5
  import { errorResult, textResult } from "./helpers.js";
@@ -23,6 +23,7 @@ export function registerGenerateTool(ext, config) {
23
23
  "For polished PDFs, use designer_list_systems and designer_get_system before writing the HTML.",
24
24
  "Keep the saved HTML source as the editable artifact; refine it and call pdf_render again for updates.",
25
25
  "Use print CSS with @page, fixed margins, break-inside avoidance, and print-color-adjust: exact.",
26
+ "Write print-native HTML designed for the page format (e.g. A4 landscape = 297x210mm). Do NOT write interactive slide-deck HTML with position:absolute + JS scale() transforms — those break in headless PDF rendering.",
26
27
  ],
27
28
  parameters: {
28
29
  type: "object",
@@ -34,6 +35,9 @@ export function registerGenerateTool(ext, config) {
34
35
  orientation: { type: "string", enum: [...orientationEnum], description: "Page orientation. Default: portrait." },
35
36
  printBackground: { type: "boolean", description: "Render CSS backgrounds. Default: true." },
36
37
  allowRemoteAssets: { type: "boolean", description: "Allow http/https assets during validation/render. Default: false." },
38
+ viewport: { type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, description: "Override the browser viewport before rendering (useful for slide decks). Default: auto." },
39
+ width: { type: "number", description: "Override PDF page width in pixels. Default: auto from format." },
40
+ height: { type: "number", description: "Override PDF page height in pixels. Default: auto from format." },
37
41
  margin: {
38
42
  type: "object",
39
43
  properties: {
@@ -77,6 +81,9 @@ export function registerGenerateTool(ext, config) {
77
81
  margin,
78
82
  printBackground: p.printBackground ?? true,
79
83
  allowRemoteAssets,
84
+ viewport: p.viewport,
85
+ width: p.width,
86
+ height: p.height,
80
87
  waitUntil: allowRemoteAssets ? "networkidle" : "load",
81
88
  });
82
89
  writeManifest(paths.manifestPath, { ...manifest, updatedAt: new Date().toISOString() });
@@ -95,6 +102,7 @@ export function registerGenerateTool(ext, config) {
95
102
  id: paths.id,
96
103
  htmlPath: toDisplayPath(ctx.cwd, paths.htmlPath),
97
104
  pdfPath: toDisplayPath(ctx.cwd, paths.pdfPath),
105
+ pdfUrl: pathToFileHref(paths.pdfPath),
98
106
  manifestPath: toDisplayPath(ctx.cwd, paths.manifestPath),
99
107
  bytes: rendered.bytes,
100
108
  warning,
@@ -1 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/extensions/pdf/tools/render.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,oCAAoC,CAAC;AACzG,OAAO,KAAK,EAAE,SAAS,EAAqD,MAAM,aAAa,CAAC;AAgBhG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAsG7E"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../../src/extensions/pdf/tools/render.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAoC,MAAM,oCAAoC,CAAC;AACzG,OAAO,KAAK,EAAE,SAAS,EAAqD,MAAM,aAAa,CAAC;AAgBhG,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,SAAS,GAAG,IAAI,CAgH7E"}
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { basename, dirname, extname, join } from "node:path";
3
- import { assertInsideWorkspace, ensureParent, resolveWorkspacePath, toDisplayPath } from "../utils/paths.js";
3
+ import { assertInsideWorkspace, ensureParent, pathToFileHref, resolveWorkspacePath, toDisplayPath } from "../utils/paths.js";
4
4
  import { printCssWarning, validateHtmlDocument } from "../utils/html.js";
5
5
  import { renderPdf } from "../utils/renderer.js";
6
6
  import { errorResult, textResult } from "./helpers.js";
@@ -31,6 +31,9 @@ export function registerRenderTool(ext, config) {
31
31
  orientation: { type: "string", enum: ["portrait", "landscape"], description: "Page orientation. Default: portrait." },
32
32
  printBackground: { type: "boolean", description: "Render CSS backgrounds. Default: true." },
33
33
  allowRemoteAssets: { type: "boolean", description: "Allow http/https assets during validation/render. Default: false." },
34
+ viewport: { type: "object", properties: { width: { type: "number" }, height: { type: "number" } }, description: "Override the browser viewport before rendering. Default: auto." },
35
+ width: { type: "number", description: "Override PDF page width in pixels. Default: auto from format." },
36
+ height: { type: "number", description: "Override PDF page height in pixels. Default: auto from format." },
34
37
  margin: {
35
38
  type: "object",
36
39
  properties: {
@@ -67,6 +70,9 @@ export function registerRenderTool(ext, config) {
67
70
  margin,
68
71
  printBackground: p.printBackground ?? true,
69
72
  allowRemoteAssets,
73
+ viewport: p.viewport,
74
+ width: p.width,
75
+ height: p.height,
70
76
  waitUntil: allowRemoteAssets ? "networkidle" : "load",
71
77
  });
72
78
  const now = new Date().toISOString();
@@ -97,6 +103,7 @@ export function registerRenderTool(ext, config) {
97
103
  isError: false,
98
104
  htmlPath: toDisplayPath(ctx.cwd, htmlPath),
99
105
  pdfPath: toDisplayPath(ctx.cwd, outputPath),
106
+ pdfUrl: pathToFileHref(outputPath),
100
107
  manifestPath: toDisplayPath(ctx.cwd, manifestPath),
101
108
  bytes: rendered.bytes,
102
109
  warning,
@@ -25,6 +25,8 @@ export interface PdfManifest {
25
25
  page: {
26
26
  format: PdfFormat;
27
27
  orientation: PdfOrientation;
28
+ width?: number;
29
+ height?: number;
28
30
  margin: Required<PdfMargin>;
29
31
  };
30
32
  source: "generated" | "rendered";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/extensions/pdf/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,QAAQ,CAAC;AACxC,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;AAEtD,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,aAAa,EAAE,SAAS,CAAC;IACzB,kBAAkB,EAAE,cAAc,CAAC;IACnC,aAAa,EAAE,QAAQ,CAAC,SAAS,C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IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE;QACJ,MAAM,EAAE,SAAS,CAAC;QAClB,WAAW,EAAE,cAAc,CAAC;QAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;KAC7B,CAAC;IACF,MAAM,EAAE,WAAW,GAAG,UAAU,CAAC;CAClC"}
@@ -4,6 +4,12 @@ export interface RenderPdfOptions {
4
4
  pdfPath: string;
5
5
  format: PdfFormat;
6
6
  orientation: PdfOrientation;
7
+ width?: number;
8
+ height?: number;
9
+ viewport?: {
10
+ width: number;
11
+ height: number;
12
+ };
7
13
  margin: Required<PdfMargin>;
8
14
  printBackground: boolean;
9
15
  allowRemoteAssets: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../src/extensions/pdf/utils/renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGnF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,cAAc,CAAC;IAC5B,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,aAAa,CAAC;CACnC;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAA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IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAkBzK"}
@@ -5,6 +5,9 @@ export async function renderPdf(config, opts) {
5
5
  const browser = await chromium.launch({ headless: true });
6
6
  try {
7
7
  const page = await browser.newPage();
8
+ if (opts.viewport) {
9
+ await page.setViewportSize(opts.viewport);
10
+ }
8
11
  page.setDefaultTimeout(config.renderTimeoutMs);
9
12
  if (!opts.allowRemoteAssets) {
10
13
  await page.route("**/*", (route) => {
@@ -24,6 +27,8 @@ export async function renderPdf(config, opts) {
24
27
  format: opts.format,
25
28
  landscape: opts.orientation === "landscape",
26
29
  printBackground: opts.printBackground,
30
+ ...(opts.width ? { width: opts.width } : {}),
31
+ ...(opts.height ? { height: opts.height } : {}),
27
32
  margin: opts.margin,
28
33
  });
29
34
  if (!existsSync(opts.pdfPath))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aexol/spectral",
3
- "version": "0.9.90",
3
+ "version": "0.9.91",
4
4
  "description": "AI coding agent for Aexol with relay-based browser access.",
5
5
  "type": "module",
6
6
  "private": false,