@formfeed/devkit 0.3.6 → 0.3.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.
package/index.cjs CHANGED
@@ -32,6 +32,7 @@ __export(index_exports, {
32
32
  diagnose: () => diagnose,
33
33
  findProject: () => findProject,
34
34
  generateTypes: () => generateTypes,
35
+ htmlSnapshot: () => htmlSnapshot,
35
36
  isIgnored: () => isIgnored,
36
37
  listLocalFiles: () => listLocalFiles,
37
38
  listTemplateSlugs: () => listTemplateSlugs,
@@ -538,6 +539,16 @@ async function renderOfficeLocal(project, tpl, data, options = {}) {
538
539
  if (options.locale) context.locale = options.locale;
539
540
  return (0, import_engine4.renderOffice)(tpl.file.bytes, { engine: tpl.meta.engine, data, context, images: options.images, random: options.random });
540
541
  }
542
+ function htmlSnapshot(rendered) {
543
+ let snapshot = rendered.document;
544
+ if (rendered.headerHtml) snapshot += `
545
+ <!-- formfeed:header -->
546
+ ${rendered.headerHtml}`;
547
+ if (rendered.footerHtml) snapshot += `
548
+ <!-- formfeed:footer -->
549
+ ${rendered.footerHtml}`;
550
+ return snapshot;
551
+ }
541
552
  function officeSnapshot(filled) {
542
553
  return (0, import_engine4.officeTextParts)(filled).map((part) => `--- ${part.name} ---
543
554
  ${prettyXml(part.xml)}`).join("\n");
@@ -1264,6 +1275,7 @@ function localTypeSource(tpl) {
1264
1275
  diagnose,
1265
1276
  findProject,
1266
1277
  generateTypes,
1278
+ htmlSnapshot,
1267
1279
  isIgnored,
1268
1280
  listLocalFiles,
1269
1281
  listTemplateSlugs,
package/index.js CHANGED
@@ -480,6 +480,16 @@ async function renderOfficeLocal(project, tpl, data, options = {}) {
480
480
  if (options.locale) context.locale = options.locale;
481
481
  return renderOffice(tpl.file.bytes, { engine: tpl.meta.engine, data, context, images: options.images, random: options.random });
482
482
  }
483
+ function htmlSnapshot(rendered) {
484
+ let snapshot = rendered.document;
485
+ if (rendered.headerHtml) snapshot += `
486
+ <!-- formfeed:header -->
487
+ ${rendered.headerHtml}`;
488
+ if (rendered.footerHtml) snapshot += `
489
+ <!-- formfeed:footer -->
490
+ ${rendered.footerHtml}`;
491
+ return snapshot;
492
+ }
483
493
  function officeSnapshot(filled) {
484
494
  return officeTextParts(filled).map((part) => `--- ${part.name} ---
485
495
  ${prettyXml(part.xml)}`).join("\n");
@@ -1205,6 +1215,7 @@ export {
1205
1215
  diagnose,
1206
1216
  findProject,
1207
1217
  generateTypes,
1218
+ htmlSnapshot,
1208
1219
  isIgnored,
1209
1220
  listLocalFiles,
1210
1221
  listTemplateSlugs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formfeed/devkit",
3
- "version": "0.3.6",
3
+ "version": "0.3.7",
4
4
  "description": "Formfeed template folders, project config and local rendering, shared by the CLI and @formfeed/testing.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,8 +30,8 @@
30
30
  ],
31
31
  "sideEffects": false,
32
32
  "dependencies": {
33
- "@formfeed/engine": "0.3.6",
34
- "@formfeed/sdk": "0.3.6"
33
+ "@formfeed/engine": "0.3.7",
34
+ "@formfeed/sdk": "0.3.7"
35
35
  },
36
36
  "keywords": [
37
37
  "formfeed",
package/types/index.d.cts CHANGED
@@ -6,7 +6,7 @@ export type { LocalOfficeFile, LocalTemplate, ProjectState, SharedPartialState,
6
6
  export { brandFromJson, brandPath, readBrand, writeBrand } from './lib/brand.cjs';
7
7
  export { collectPartials } from './lib/partials.cjs';
8
8
  export type { CollectedPartials } from './lib/partials.cjs';
9
- export { diagnose, officeSnapshot, prettyXml, previewDocument, renderContext, renderLocal, renderOfficeLocal, renderedSettings } from './lib/local-render.cjs';
9
+ export { diagnose, htmlSnapshot, officeSnapshot, prettyXml, previewDocument, renderContext, renderLocal, renderOfficeLocal, renderedSettings } from './lib/local-render.cjs';
10
10
  export type { LocalDiagnostic, OfficeLocalOptions } from './lib/local-render.cjs';
11
11
  export { contentTypeFor, listLocalFiles, localFilePath, sha256File, writeLocalFile } from './lib/files.cjs';
12
12
  export type { LocalFile, LocalFileListing } from './lib/files.cjs';
package/types/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export type { LocalOfficeFile, LocalTemplate, ProjectState, SharedPartialState,
6
6
  export { brandFromJson, brandPath, readBrand, writeBrand } from './lib/brand.js';
7
7
  export { collectPartials } from './lib/partials.js';
8
8
  export type { CollectedPartials } from './lib/partials.js';
9
- export { diagnose, officeSnapshot, prettyXml, previewDocument, renderContext, renderLocal, renderOfficeLocal, renderedSettings } from './lib/local-render.js';
9
+ export { diagnose, htmlSnapshot, officeSnapshot, prettyXml, previewDocument, renderContext, renderLocal, renderOfficeLocal, renderedSettings } from './lib/local-render.js';
10
10
  export type { LocalDiagnostic, OfficeLocalOptions } from './lib/local-render.js';
11
11
  export { contentTypeFor, listLocalFiles, localFilePath, sha256File, writeLocalFile } from './lib/files.js';
12
12
  export type { LocalFile, LocalFileListing } from './lib/files.js';
@@ -23,6 +23,13 @@ export interface OfficeLocalOptions {
23
23
  }
24
24
  /** Fills a Word or PowerPoint template with the shared engine, as the render-worker does. */
25
25
  export declare function renderOfficeLocal(project: Project, tpl: LocalTemplate, data: unknown, options?: OfficeLocalOptions): Promise<OfficeRenderResult>;
26
+ /**
27
+ * An HTML template's snapshot: the assembled document, then the rendered header and footer under
28
+ * `<!-- formfeed:header -->` and `<!-- formfeed:footer -->` lines when the template has them.
29
+ * Chromium prints header and footer from templates of their own, outside the document, so a
30
+ * snapshot of the document alone passed a changed footer unnoticed.
31
+ */
32
+ export declare function htmlSnapshot(rendered: Pick<RenderedDocument, 'document' | 'headerHtml' | 'footerHtml'>): string;
26
33
  /**
27
34
  * The filled parts of a Word or PowerPoint document as readable text for snapshots: each part's XML,
28
35
  * one element per line and indented, text kept beside its element, under a `--- <part> ---` line.
@@ -23,6 +23,13 @@ export interface OfficeLocalOptions {
23
23
  }
24
24
  /** Fills a Word or PowerPoint template with the shared engine, as the render-worker does. */
25
25
  export declare function renderOfficeLocal(project: Project, tpl: LocalTemplate, data: unknown, options?: OfficeLocalOptions): Promise<OfficeRenderResult>;
26
+ /**
27
+ * An HTML template's snapshot: the assembled document, then the rendered header and footer under
28
+ * `<!-- formfeed:header -->` and `<!-- formfeed:footer -->` lines when the template has them.
29
+ * Chromium prints header and footer from templates of their own, outside the document, so a
30
+ * snapshot of the document alone passed a changed footer unnoticed.
31
+ */
32
+ export declare function htmlSnapshot(rendered: Pick<RenderedDocument, 'document' | 'headerHtml' | 'footerHtml'>): string;
26
33
  /**
27
34
  * The filled parts of a Word or PowerPoint document as readable text for snapshots: each part's XML,
28
35
  * one element per line and indented, text kept beside its element, under a `--- <part> ---` line.