<:items>
+{{/in-element}}
\ No newline at end of file
diff --git a/packages/oss-components/src/components/o-s-s/pdf-export.stories.js b/packages/oss-components/src/components/o-s-s/pdf-export.stories.js
new file mode 100644
index 000000000..a506524cd
--- /dev/null
+++ b/packages/oss-components/src/components/o-s-s/pdf-export.stories.js
@@ -0,0 +1,84 @@
+import { hbs } from 'ember-cli-htmlbars';
+import { fn } from 'storybook/test';
+
+const Template = (args) => ({
+ template: hbs`
+
+ {{#if this.exporting}}
+
+ <:content as |pdf|>
+
+ Creator report
+
+
+
+ <:footer>
+
+ Powered by Upfluence
+ www.upfluence.com
+
+
+
+ {{/if}}
+ `,
+ context: args
+});
+
+const defaultArgs = {
+ exporting: false,
+ fileName: 'creator-report.pdf',
+ width: 800,
+ timeout: 30000,
+ onSuccess: fn(),
+ onError: fn()
+};
+
+export default {
+ title: 'Components/OSS::PdfExport',
+ component: 'pdf-export',
+ render: Template,
+ args: defaultArgs,
+ argTypes: {
+ exporting: {
+ description: 'Story only - Renders the component, which starts the export.',
+ table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' } },
+ control: { type: 'boolean' }
+ },
+ fileName: {
+ description: 'The name of the downloaded file',
+ table: { type: { summary: 'string' }, defaultValue: { summary: 'undefined' } },
+ control: { type: 'text' }
+ },
+ width: {
+ description: 'The width, in pixels, at which the content is rendered. The page is scaled to the A4 width.',
+ table: { type: { summary: 'number' }, defaultValue: { summary: 'undefined' } },
+ control: { type: 'number' }
+ },
+ timeout: {
+ description:
+ 'Optional - The delay, in milliseconds, allowed for the content to call ready, then again for the capture',
+ table: { type: { summary: 'number' }, defaultValue: { summary: '30000' } },
+ control: { type: 'number' }
+ },
+ onSuccess: {
+ description: 'Called once the PDF file is downloaded, or offered for download',
+ table: { category: 'Actions', type: { summary: 'onSuccess(): void' } }
+ },
+ onError: {
+ description: 'Called when the export fails or times out',
+ table: { category: 'Actions', type: { summary: 'onError(error: unknown): void' } }
+ }
+ },
+ parameters: {
+ docs: {
+ description: {
+ component:
+ 'Renders the `content` block off-screen and downloads it as an A4 PDF file once the content calls the yielded `ready` action. The optional `footer` block is repeated at the bottom of every page. The component is meant to be rendered only while an export is running.'
+ },
+ iframeHeight: 120
+ }
+ }
+};
+
+export const Usage = {};
diff --git a/packages/oss-components/src/components/o-s-s/pdf-export.ts b/packages/oss-components/src/components/o-s-s/pdf-export.ts
new file mode 100644
index 000000000..e0e9294da
--- /dev/null
+++ b/packages/oss-components/src/components/o-s-s/pdf-export.ts
@@ -0,0 +1,109 @@
+import { assert } from '@ember/debug';
+import { action } from '@ember/object';
+import type Owner from '@ember/owner';
+import { next } from '@ember/runloop';
+import { service } from '@ember/service';
+import { htmlSafe } from '@ember/template';
+import Component from '@glimmer/component';
+
+import type PdfExportService from '../../services/pdf-export';
+
+interface OSSPdfExportArgs {
+ fileName: string;
+ width: number;
+ timeout?: number;
+ onSuccess(): void;
+ onError(error: unknown): void;
+}
+
+const DEFAULT_TIMEOUT = 30_000;
+
+export default class OSSPdfExport extends Component {
+ @service declare pdfExport: PdfExportService;
+
+ portalTarget: HTMLElement = document.body;
+
+ private controller: AbortController = new AbortController();
+ private page?: HTMLElement;
+ private footer?: HTMLElement;
+ private started: boolean = false;
+ private timeoutId?: ReturnType;
+
+ constructor(owner: Owner, args: OSSPdfExportArgs) {
+ super(owner, args);
+
+ assert('[component][OSS::PdfExport] The @fileName argument is mandatory.', args.fileName);
+ assert('[component][OSS::PdfExport] The @width argument is mandatory.', args.width);
+
+ this.restartTimeout();
+ }
+
+ get pageStyle(): ReturnType {
+ return htmlSafe(`width: ${this.args.width}px;`);
+ }
+
+ willDestroy(): void {
+ super.willDestroy();
+ clearTimeout(this.timeoutId);
+ this.controller.abort();
+ }
+
+ @action
+ registerPage(element: HTMLElement): void {
+ this.page = element;
+ }
+
+ @action
+ registerFooter(element: HTMLElement): void {
+ this.footer = element;
+ }
+
+ @action
+ ready(): void {
+ if (this.started) return;
+
+ this.started = true;
+ this.restartTimeout();
+ next(this, this.capture);
+ }
+
+ private restartTimeout(): void {
+ clearTimeout(this.timeoutId);
+ this.timeoutId = setTimeout(
+ () => this.fail(new Error('[component][OSS::PdfExport] The export timed out.')),
+ this.args.timeout ?? DEFAULT_TIMEOUT
+ );
+ }
+
+ private async capture(): Promise {
+ try {
+ await this.pdfExport.export(this.page!, {
+ fileName: this.args.fileName,
+ footer: this.footer,
+ signal: this.controller.signal
+ });
+ this.succeed();
+ } catch (error) {
+ this.fail(error);
+ }
+ }
+
+ private get isFinished(): boolean {
+ return this.isDestroying || this.isDestroyed || this.controller.signal.aborted;
+ }
+
+ private succeed(): void {
+ if (this.isFinished) return;
+
+ clearTimeout(this.timeoutId);
+ this.args.onSuccess();
+ }
+
+ private fail(error: unknown): void {
+ if (this.isFinished) return;
+
+ clearTimeout(this.timeoutId);
+ this.controller.abort();
+ this.args.onError(error);
+ }
+}
diff --git a/packages/oss-components/src/services/pdf-export.ts b/packages/oss-components/src/services/pdf-export.ts
new file mode 100644
index 000000000..3ee66289f
--- /dev/null
+++ b/packages/oss-components/src/services/pdf-export.ts
@@ -0,0 +1,101 @@
+import Service, { service } from '@ember/service';
+
+import type { IntlService } from 'ember-intl';
+
+import measureBoxes from '../utils/pdf-export/measure-boxes';
+import planPages from '../utils/pdf-export/plan-pages';
+import type ToastService from './toast';
+
+export type PdfExportOptions = {
+ fileName: string;
+ footer?: HTMLElement;
+ signal?: AbortSignal;
+};
+
+const A4_HEIGHT_TO_WIDTH = 297 / 210;
+const RENDER_SCALE = 2;
+const JPEG_QUALITY = 0.92;
+const IMAGE_DECODE_TIMEOUT = 5000;
+const OBJECT_URL_LIFETIME = 60_000;
+
+function nextFrame(): Promise {
+ return new Promise((resolve) => requestAnimationFrame(() => resolve()));
+}
+
+function decodeImage(image: HTMLImageElement): Promise {
+ return Promise.race([
+ image.decode().catch(() => undefined),
+ new Promise((resolve) => setTimeout(resolve, IMAGE_DECODE_TIMEOUT))
+ ]);
+}
+
+export default class PdfExportService extends Service {
+ @service declare intl: IntlService;
+ @service declare toast: ToastService;
+
+ async export(element: HTMLElement, { fileName, footer, signal }: PdfExportOptions): Promise {
+ await this.waitForAssets(footer ? [element, footer] : [element]);
+ signal?.throwIfAborted();
+
+ const visibleFooter = footer && footer.offsetWidth > 0 && footer.offsetHeight > 0 ? footer : undefined;
+ const footerHeight = visibleFooter
+ ? visibleFooter.offsetHeight * (element.offsetWidth / visibleFooter.offsetWidth)
+ : 0;
+ const pages = planPages(measureBoxes(element), element.offsetWidth * A4_HEIGHT_TO_WIDTH - footerHeight);
+ const { default: renderPdf } = await import('../utils/pdf-export/render');
+ const blob = await renderPdf(element, {
+ pages,
+ footer: visibleFooter,
+ signal,
+ scale: RENDER_SCALE,
+ quality: JPEG_QUALITY
+ });
+ signal?.throwIfAborted();
+
+ if (this.canDownloadDirectly()) {
+ this.save(blob, fileName);
+ } else {
+ this.offerDownload(blob, fileName);
+ }
+ }
+
+ save(blob: Blob, fileName: string): void {
+ const url = URL.createObjectURL(blob);
+ const link = document.createElement('a');
+ link.href = url;
+ link.download = fileName;
+ document.body.append(link);
+ link.click();
+ link.remove();
+ setTimeout(() => URL.revokeObjectURL(url), OBJECT_URL_LIFETIME);
+ }
+
+ canDownloadDirectly(): boolean {
+ return window.self === window.top || (navigator.userActivation?.isActive ?? true);
+ }
+
+ private offerDownload(blob: Blob, fileName: string): void {
+ this.toast.info(
+ this.intl.t('oss-components.pdf-export.download.message'),
+ this.intl.t('oss-components.pdf-export.download.title'),
+ { timeout: 'none', onclick: () => this.save(blob, fileName) }
+ );
+ }
+
+ private async waitForAssets(elements: HTMLElement[]): Promise {
+ const images = elements.flatMap((element) => Array.from(element.querySelectorAll('img')));
+ images.forEach((image) => (image.loading = 'eager'));
+ elements.forEach((element) => element.getBoundingClientRect());
+
+ await document.fonts.ready;
+ await Promise.all(images.map(decodeImage));
+ await nextFrame();
+ await nextFrame();
+ }
+}
+
+declare module '@ember/service' {
+ interface Registry {
+ 'pdf-export': PdfExportService;
+ }
+}
diff --git a/packages/oss-components/src/utils/pdf-export/cors-fetch.ts b/packages/oss-components/src/utils/pdf-export/cors-fetch.ts
new file mode 100644
index 000000000..5e8fe04e4
--- /dev/null
+++ b/packages/oss-components/src/utils/pdf-export/cors-fetch.ts
@@ -0,0 +1,12 @@
+function withCacheBuster(url: string): string {
+ const separator = url.includes('?') ? '&' : '?';
+ return `${url}${separator}pdf-export=${Date.now()}`;
+}
+
+export default async function corsFetch(url: string): Promise {
+ try {
+ return await fetch(url, { mode: 'cors', cache: 'force-cache' });
+ } catch {
+ return fetch(withCacheBuster(url), { mode: 'cors', cache: 'no-store' });
+ }
+}
diff --git a/packages/oss-components/src/utils/pdf-export/cross-origin-font-faces.ts b/packages/oss-components/src/utils/pdf-export/cross-origin-font-faces.ts
new file mode 100644
index 000000000..dd278c6fe
--- /dev/null
+++ b/packages/oss-components/src/utils/pdf-export/cross-origin-font-faces.ts
@@ -0,0 +1,49 @@
+import corsFetch from './cors-fetch';
+
+const FONT_FACE_RULE = /@font-face\s*{[^}]*}/g;
+const CSS_URL = /url\(\s*(['"]?)(.*?)\1\s*\)/g;
+
+function isReadable(sheet: CSSStyleSheet): boolean {
+ try {
+ return sheet.cssRules !== null;
+ } catch {
+ return false;
+ }
+}
+
+function toAbsoluteUrl(url: string, baseUrl: string): string {
+ try {
+ return new URL(url, baseUrl).href;
+ } catch {
+ return url;
+ }
+}
+
+async function fetchFontFaces(href: string): Promise {
+ try {
+ const response = await corsFetch(href);
+ if (!response.ok) return [];
+
+ const css = await response.text();
+ return (css.match(FONT_FACE_RULE) ?? []).map((rule) =>
+ rule.replace(CSS_URL, (_match, quote: string, url: string) => `url(${quote}${toAbsoluteUrl(url, href)}${quote})`)
+ );
+ } catch {
+ return [];
+ }
+}
+
+export default async function exposeCrossOriginFontFaces(): Promise<() => void> {
+ const hrefs = Array.from(document.styleSheets).flatMap((sheet) =>
+ sheet.href && !isReadable(sheet) ? [sheet.href] : []
+ );
+ const rules = (await Promise.all(hrefs.map(fetchFontFaces))).flat();
+ if (rules.length === 0) return () => {};
+
+ const style = document.createElement('style');
+ style.textContent = rules.join('\n');
+ document.head.append(style);
+ if (style.sheet) style.sheet.disabled = true;
+
+ return () => style.remove();
+}
diff --git a/packages/oss-components/src/utils/pdf-export/measure-boxes.ts b/packages/oss-components/src/utils/pdf-export/measure-boxes.ts
new file mode 100644
index 000000000..f32cecd0a
--- /dev/null
+++ b/packages/oss-components/src/utils/pdf-export/measure-boxes.ts
@@ -0,0 +1,54 @@
+export type PdfBox = {
+ top: number;
+ bottom: number;
+ breakBefore: boolean;
+ breakAfter: boolean;
+ containsForcedBreak: boolean;
+ children: PdfBox[];
+};
+
+const FORCED_BREAKS = ['page', 'always', 'left', 'right', 'recto', 'verso'];
+
+function isForcedBreak(value: string): boolean {
+ return FORCED_BREAKS.includes(value);
+}
+
+function hasOwnText(element: Element): boolean {
+ return Array.from(element.childNodes).some(
+ (node) => node.nodeType === Node.TEXT_NODE && (node.textContent ?? '').trim() !== ''
+ );
+}
+
+function measureChildren(element: Element, rootTop: number, scale: number): PdfBox[] {
+ if (element instanceof SVGElement || hasOwnText(element)) return [];
+
+ return Array.from(element.children).flatMap((child) =>
+ child.getBoundingClientRect().height > 0 ? [measure(child, rootTop, scale)] : measureChildren(child, rootTop, scale)
+ );
+}
+
+function toCssPixels(position: number, rootTop: number, scale: number): number {
+ return Math.round(((position - rootTop) / scale) * 100) / 100;
+}
+
+function measure(element: Element, rootTop: number, scale: number): PdfBox {
+ const rect = element.getBoundingClientRect();
+ const style = getComputedStyle(element);
+ const children = measureChildren(element, rootTop, scale);
+
+ return {
+ top: toCssPixels(rect.top, rootTop, scale),
+ bottom: toCssPixels(rect.bottom, rootTop, scale),
+ breakBefore: isForcedBreak(style.breakBefore),
+ breakAfter: isForcedBreak(style.breakAfter),
+ containsForcedBreak: children.some((child) => child.breakBefore || child.breakAfter || child.containsForcedBreak),
+ children
+ };
+}
+
+export default function measureBoxes(root: HTMLElement): PdfBox {
+ const rootRect = root.getBoundingClientRect();
+ const scale = root.offsetWidth > 0 ? rootRect.width / root.offsetWidth : 1;
+
+ return measure(root, rootRect.top, scale);
+}
diff --git a/packages/oss-components/src/utils/pdf-export/plan-pages.ts b/packages/oss-components/src/utils/pdf-export/plan-pages.ts
new file mode 100644
index 000000000..f1cdd5b9b
--- /dev/null
+++ b/packages/oss-components/src/utils/pdf-export/plan-pages.ts
@@ -0,0 +1,106 @@
+import type { PdfBox } from './measure-boxes';
+
+export type PdfPage = {
+ top: number;
+ bottom: number;
+};
+
+type BoxGroup = {
+ top: number;
+ bottom: number;
+ boxes: PdfBox[];
+ breakBefore: boolean;
+ breakAfter: boolean;
+};
+
+const EPSILON = 0.5;
+
+function groupSideBySideBoxes(boxes: PdfBox[]): BoxGroup[] {
+ const sorted = [...boxes].sort((a, b) => a.top - b.top);
+
+ return sorted.reduce((groups, box) => {
+ const current = groups[groups.length - 1];
+
+ if (current && box.top < current.bottom - EPSILON) {
+ current.bottom = Math.max(current.bottom, box.bottom);
+ current.boxes.push(box);
+ current.breakBefore ||= box.breakBefore;
+ current.breakAfter ||= box.breakAfter;
+ return groups;
+ }
+
+ groups.push({
+ top: box.top,
+ bottom: box.bottom,
+ boxes: [box],
+ breakBefore: box.breakBefore,
+ breakAfter: box.breakAfter
+ });
+ return groups;
+ }, []);
+}
+
+export default function planPages(root: PdfBox, pageHeight: number): PdfPage[] {
+ if (!Number.isFinite(pageHeight) || pageHeight <= EPSILON) {
+ throw new Error(`[utils][pdf-export] The page height must be a positive number, got ${pageHeight}.`);
+ }
+
+ const breaks: number[] = [root.top];
+ let pageTop = root.top;
+ let contentBottom = root.top;
+
+ const addBreak = (position: number): void => {
+ breaks.push(position);
+ pageTop = position;
+ };
+
+ const startPageAt = (position: number): void => {
+ if (position <= pageTop + EPSILON || position >= root.bottom - EPSILON) return;
+
+ if (contentBottom <= pageTop + EPSILON) {
+ breaks[breaks.length - 1] = position;
+ pageTop = position;
+ return;
+ }
+
+ addBreak(position);
+ };
+
+ const sliceUntil = (bottom: number): void => {
+ const end = Math.min(bottom, root.bottom);
+
+ while (end - pageTop > pageHeight + EPSILON) {
+ addBreak(pageTop + pageHeight);
+ }
+ };
+
+ const place = (boxes: PdfBox[]): void => {
+ groupSideBySideBoxes(boxes).forEach((group) => {
+ if (group.breakBefore) startPageAt(group.top);
+
+ const fitsOnPage = group.bottom - pageTop <= pageHeight + EPSILON;
+ const fitsOnEmptyPage = group.bottom - group.top <= pageHeight + EPSILON;
+ const singleBox = group.boxes.length === 1 ? group.boxes[0] : undefined;
+
+ if (!fitsOnPage && fitsOnEmptyPage) {
+ startPageAt(group.top);
+ }
+
+ if (singleBox && singleBox.children.length > 0 && (singleBox.containsForcedBreak || !fitsOnEmptyPage)) {
+ place(singleBox.children);
+ } else {
+ sliceUntil(group.bottom);
+ contentBottom = Math.max(contentBottom, group.bottom);
+ }
+
+ if (group.breakAfter) startPageAt(group.bottom);
+ });
+ };
+
+ place([root]);
+
+ return breaks.map((top, index) => ({
+ top,
+ bottom: Math.min(breaks[index + 1] ?? root.bottom, top + pageHeight)
+ }));
+}
diff --git a/packages/oss-components/src/utils/pdf-export/render.ts b/packages/oss-components/src/utils/pdf-export/render.ts
new file mode 100644
index 000000000..9d2b694ee
--- /dev/null
+++ b/packages/oss-components/src/utils/pdf-export/render.ts
@@ -0,0 +1,183 @@
+import { jsPDF } from 'jspdf';
+import { createContext, destroyContext, domToForeignObjectSvg } from 'modern-screenshot';
+
+import corsFetch from './cors-fetch';
+import exposeCrossOriginFontFaces from './cross-origin-font-faces';
+import type { PdfPage } from './plan-pages';
+
+export type RenderOptions = {
+ pages: PdfPage[];
+ footer?: HTMLElement;
+ scale: number;
+ quality: number;
+ signal?: AbortSignal;
+};
+
+const A4_WIDTH_PT = 595.28;
+const A4_HEIGHT_PT = 841.89;
+const FOOTER_IMAGE_ALIAS = 'oss-pdf-export-footer';
+const USER_AGENT = navigator.userAgent;
+const NEEDS_REDRAW =
+ (USER_AGENT.includes('AppleWebKit') && !USER_AGENT.includes('Chrome')) || USER_AGENT.includes('Firefox');
+const REDRAW_DELAY = 100;
+const MAX_REDRAWS = 3;
+const FONT_AWESOME_ALT_TEXT = /content: '(.+?) \/ [^']*';/g;
+const INVALID_XML_CHARACTERS = /[^\t\n\r\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/gu;
+
+function wait(delay: number): Promise {
+ return new Promise((resolve) => setTimeout(resolve, delay));
+}
+
+function redrawCount(element: HTMLElement): number {
+ return NEEDS_REDRAW ? Math.min(element.querySelectorAll('img').length, MAX_REDRAWS) : 0;
+}
+
+function stripContentAltText(svg: SVGSVGElement): void {
+ svg.querySelectorAll('style').forEach((style) => {
+ style.textContent = (style.textContent ?? '').replace(FONT_AWESOME_ALT_TEXT, "content: '$1';");
+ });
+}
+
+function blobToDataUrl(blob: Blob): Promise {
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onload = () => resolve(reader.result as string);
+ reader.onerror = () => reject(reader.error);
+ reader.readAsDataURL(blob);
+ });
+}
+
+async function fetchImage(url: string): Promise {
+ if (url.startsWith('data:')) return false;
+
+ try {
+ const response = await corsFetch(url);
+ return response.ok ? await blobToDataUrl(await response.blob()) : false;
+ } catch {
+ return false;
+ }
+}
+
+async function cloneToSvgImage(element: HTMLElement): Promise {
+ const context = await createContext(element, {
+ width: element.offsetWidth,
+ height: element.offsetHeight,
+ backgroundColor: '#ffffff',
+ fetchFn: fetchImage,
+ onCreateForeignObjectSvg: stripContentAltText
+ });
+
+ try {
+ const svg = await domToForeignObjectSvg(context);
+ const markup = new XMLSerializer().serializeToString(svg).replace(INVALID_XML_CHARACTERS, '');
+ const image = new Image();
+ image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(markup)}`;
+ await image.decode();
+ return image;
+ } finally {
+ destroyContext(context);
+ }
+}
+
+function canvasToJpeg(canvas: HTMLCanvasElement, quality: number): Promise {
+ return new Promise((resolve, reject) => {
+ canvas.toBlob(
+ (blob) => {
+ if (!blob) {
+ reject(new Error('[utils][pdf-export] The page could not be encoded.'));
+ return;
+ }
+ blob.arrayBuffer().then((buffer) => resolve(new Uint8Array(buffer)), reject);
+ },
+ 'image/jpeg',
+ quality
+ );
+ });
+}
+
+async function rasterize(
+ image: HTMLImageElement,
+ area: { top: number; width: number; height: number; redraws: number },
+ { scale, quality }: Pick
+): Promise {
+ const canvas = document.createElement('canvas');
+ canvas.width = Math.round(area.width * scale);
+ canvas.height = Math.max(1, Math.round(area.height * scale));
+
+ const context = canvas.getContext('2d');
+ if (!context) throw new Error('[utils][pdf-export] Canvas 2D context is not available.');
+
+ const draw = (): void => {
+ context.fillStyle = '#ffffff';
+ context.fillRect(0, 0, canvas.width, canvas.height);
+ context.drawImage(image, 0, area.top, area.width, area.height, 0, 0, canvas.width, canvas.height);
+ };
+
+ draw();
+ for (let index = 0; index < area.redraws; index++) {
+ await wait(REDRAW_DELAY);
+ draw();
+ }
+
+ try {
+ return await canvasToJpeg(canvas, quality);
+ } finally {
+ canvas.width = 0;
+ canvas.height = 0;
+ }
+}
+
+async function rasterizeFooter(footer: HTMLElement, options: RenderOptions): Promise {
+ const image = await cloneToSvgImage(footer);
+
+ try {
+ return await rasterize(
+ image,
+ { top: 0, width: footer.offsetWidth, height: footer.offsetHeight, redraws: redrawCount(footer) },
+ options
+ );
+ } finally {
+ image.src = '';
+ }
+}
+
+async function assemblePdf(element: HTMLElement, options: RenderOptions): Promise {
+ const { pages, footer, signal } = options;
+ const width = element.offsetWidth;
+ const footerJpeg = footer ? await rasterizeFooter(footer, options) : undefined;
+ const footerHeight = footer ? footer.offsetHeight * (A4_WIDTH_PT / footer.offsetWidth) : 0;
+ signal?.throwIfAborted();
+
+ const image = await cloneToSvgImage(element);
+ const redraws = redrawCount(element);
+ const pdf = new jsPDF({ unit: 'pt', format: 'a4', compress: true });
+
+ try {
+ for (const [index, page] of pages.entries()) {
+ signal?.throwIfAborted();
+ if (index > 0) pdf.addPage();
+
+ const height = page.bottom - page.top;
+ const jpeg = await rasterize(image, { top: page.top, width, height, redraws }, options);
+ pdf.addImage(jpeg, 'JPEG', 0, 0, A4_WIDTH_PT, height * (A4_WIDTH_PT / width));
+
+ if (footerJpeg) {
+ pdf.addImage(footerJpeg, 'JPEG', 0, A4_HEIGHT_PT - footerHeight, A4_WIDTH_PT, footerHeight, FOOTER_IMAGE_ALIAS);
+ }
+ }
+
+ return pdf.output('blob');
+ } finally {
+ image.src = '';
+ }
+}
+
+export default async function renderPdf(element: HTMLElement, options: RenderOptions): Promise {
+ const removeFontFaces = await exposeCrossOriginFontFaces();
+
+ try {
+ return await assemblePdf(element, options);
+ } finally {
+ removeFontFaces();
+ }
+}
diff --git a/packages/oss-components/styles/molecules/button-dropdown.less b/packages/oss-components/styles/molecules/button-dropdown.less
index fd481a1c4..edde13ed4 100644
--- a/packages/oss-components/styles/molecules/button-dropdown.less
+++ b/packages/oss-components/styles/molecules/button-dropdown.less
@@ -15,6 +15,10 @@
}
}
+ &--loading .oss-button-dropdown__trigger {
+ cursor: progress;
+ }
+
&--sm {
.oss-button-dropdown__trigger {
height: var(--spacing-px-24);
diff --git a/packages/oss-components/styles/organisms/pdf-export.less b/packages/oss-components/styles/organisms/pdf-export.less
new file mode 100644
index 000000000..2cfcf9a61
--- /dev/null
+++ b/packages/oss-components/styles/organisms/pdf-export.less
@@ -0,0 +1,20 @@
+.oss-pdf-export {
+ position: fixed;
+ top: 0;
+ left: -100000px;
+ pointer-events: none;
+
+ &__page,
+ &__footer {
+ position: relative;
+ contain: layout;
+ background-color: var(--color-white);
+
+ *,
+ *::before,
+ *::after {
+ animation: none !important;
+ transition: none !important;
+ }
+ }
+}
diff --git a/packages/oss-components/styles/oss-components.less b/packages/oss-components/styles/oss-components.less
index 53d4e1e7d..311156f75 100644
--- a/packages/oss-components/styles/oss-components.less
+++ b/packages/oss-components/styles/oss-components.less
@@ -84,6 +84,7 @@
@import 'organisms/attributes-panel';
@import 'organisms/side-panel';
@import 'organisms/popover';
+@import 'organisms/pdf-export';
@import 'organisms/carousel';
@import 'organisms/wizard-container';
@import 'organisms/marketing-banner';
diff --git a/packages/oss-components/translations/en-us.yaml b/packages/oss-components/translations/en-us.yaml
index 8d1270ad5..46b518783 100644
--- a/packages/oss-components/translations/en-us.yaml
+++ b/packages/oss-components/translations/en-us.yaml
@@ -72,6 +72,10 @@ oss-components:
error:
title: Error
subtitle: Failed to copy to your clipboard. Please try again.
+ pdf-export:
+ download:
+ title: Your PDF is ready
+ message: Click here to download it.
access-panel:
search_placeholder: Search...
attributes_panel:
diff --git a/packages/test-app/tests/integration/components/o-s-s/button-dropdown-test.ts b/packages/test-app/tests/integration/components/o-s-s/button-dropdown-test.ts
index 01f5e0405..0ce003d9f 100644
--- a/packages/test-app/tests/integration/components/o-s-s/button-dropdown-test.ts
+++ b/packages/test-app/tests/integration/components/o-s-s/button-dropdown-test.ts
@@ -1,4 +1,4 @@
-import { click, render, setupOnerror } from '@ember/test-helpers';
+import { click, render, setupOnerror, type TestContext } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupRenderingTest } from 'ember-qunit';
@@ -116,6 +116,52 @@ module('Integration | Component | o-s-s/button-dropdown', function (hooks) {
});
});
+ module('When @loading is true', function (hooks) {
+ hooks.beforeEach(function (this: TestContext) {
+ this.mainAction = sinon.stub();
+ });
+
+ test('a spinner replaces the icon', async function (this: TestContext, assert) {
+ await render(
+ hbs`<:items>foo
`
+ );
+
+ assert.dom('.oss-button-dropdown__trigger .fx-row:first-child i').exists({ count: 1 });
+ assert.dom('.oss-button-dropdown__trigger .fx-row:first-child i').hasClass('fa-circle-notch');
+ assert.dom('.oss-button-dropdown__trigger .fx-row:first-child i').hasClass('fa-spin');
+ assert.dom('.oss-button-dropdown__trigger .fx-row:first-child span').hasText('label');
+ });
+
+ test('the button is marked as busy', async function (this: TestContext, assert) {
+ await render(
+ hbs`<:items>foo
`
+ );
+
+ assert.dom('.oss-button-dropdown').hasClass('oss-button-dropdown--loading');
+ assert.dom('.oss-button-dropdown__trigger').hasAttribute('aria-busy', 'true');
+ });
+
+ test('Clicking on the button does not open the dropdown', async function (this: TestContext, assert) {
+ await render(
+ hbs`<:items>foo
`
+ );
+
+ await click('.oss-button-dropdown__trigger');
+
+ assert.dom('.oss-button-dropdown__items').doesNotExist();
+ });
+
+ test('Clicking on the left part does not trigger mainAction', async function (this: TestContext, assert) {
+ await render(
+ hbs`<:items>foo
`
+ );
+
+ await click('.oss-button-dropdown__trigger .fx-row:first-child');
+
+ assert.false(this.mainAction.called);
+ });
+ });
+
module('If @mainAction is defined', function (hooks) {
hooks.beforeEach(function () {
this.mainAction = sinon.stub();
diff --git a/packages/test-app/tests/integration/components/o-s-s/pdf-export-test.ts b/packages/test-app/tests/integration/components/o-s-s/pdf-export-test.ts
new file mode 100644
index 000000000..8c08a106b
--- /dev/null
+++ b/packages/test-app/tests/integration/components/o-s-s/pdf-export-test.ts
@@ -0,0 +1,113 @@
+import { clearRender, render, waitUntil, type TestContext } from '@ember/test-helpers';
+
+import { hbs } from 'ember-cli-htmlbars';
+import { setupRenderingTest } from 'ember-qunit';
+import { module, test } from 'qunit';
+import sinon from 'sinon';
+
+import type PdfExportService from '@upfluence/oss-components/services/pdf-export';
+
+module('Integration | Component | o-s-s/pdf-export', (hooks) => {
+ setupRenderingTest(hooks);
+
+ hooks.beforeEach(function (this: TestContext) {
+ const pdfExport = this.owner.lookup('service:pdf-export') as PdfExportService;
+ this.exportStub = sinon.stub(pdfExport, 'export').resolves();
+ this.onSuccess = sinon.stub();
+ this.onError = sinon.stub();
+ });
+
+ test('it renders the content and the footer off-screen, at the given width', async function (this: TestContext, assert) {
+ await renderComponent();
+
+ assert.dom(document.querySelector('body > .oss-pdf-export')).exists();
+ assert.dom(document.querySelector('.oss-pdf-export__page')).hasAttribute('style', 'width: 400px;');
+ assert.dom(document.querySelector('.oss-pdf-export__page .report-content')).hasText('Report');
+ assert.dom(document.querySelector('.oss-pdf-export__footer')).hasAttribute('style', 'width: 400px;');
+ assert.dom(document.querySelector('.oss-pdf-export__footer .report-footer')).hasText('Footer');
+ });
+
+ test('it exports the page with its footer once the content is ready', async function (this: TestContext, assert) {
+ await renderComponent();
+ await waitUntil(() => this.exportStub.called);
+
+ assert.true(
+ this.exportStub.calledOnceWithExactly(document.querySelector('.oss-pdf-export__page'), {
+ fileName: 'report.pdf',
+ footer: document.querySelector('.oss-pdf-export__footer'),
+ signal: sinon.match.instanceOf(AbortSignal)
+ })
+ );
+ });
+
+ test('it calls @onSuccess when the export succeeds', async function (this: TestContext, assert) {
+ await renderComponent();
+ await waitUntil(() => this.onSuccess.called);
+
+ assert.true(this.onSuccess.calledOnceWithExactly());
+ assert.false(this.onError.called);
+ });
+
+ test('it calls @onError with the error when the export fails', async function (this: TestContext, assert) {
+ const error = new Error('capture failed');
+ this.exportStub.rejects(error);
+
+ await renderComponent();
+ await waitUntil(() => this.onError.called);
+
+ assert.true(this.onError.calledOnceWithExactly(error));
+ assert.false(this.onSuccess.called);
+ });
+
+ test('it calls @onError without exporting when the content never becomes ready', async function (this: TestContext, assert) {
+ await render(hbs`
+
+ <:content>
+ Report
+
+
+ `);
+ await waitUntil(() => this.onError.called);
+
+ assert.true(this.onError.calledOnceWithExactly(sinon.match.instanceOf(Error)));
+ assert.false(this.exportStub.called);
+ });
+
+ test('it calls @onError and aborts the export when it times out', async function (this: TestContext, assert) {
+ this.exportStub.returns(new Promise(() => {}));
+ this.timeout = 10;
+
+ await renderComponent();
+ await waitUntil(() => this.onError.called);
+
+ assert.true(this.onError.calledOnceWithExactly(sinon.match.instanceOf(Error)));
+ assert.true(this.exportStub.firstCall.args[1].signal.aborted);
+ });
+
+ test('it aborts the export without callback when it is destroyed', async function (this: TestContext, assert) {
+ this.exportStub.returns(new Promise(() => {}));
+
+ await renderComponent();
+ await waitUntil(() => this.exportStub.called);
+ await clearRender();
+
+ assert.true(this.exportStub.firstCall.args[1].signal.aborted);
+ assert.false(this.onSuccess.called);
+ assert.false(this.onError.called);
+ });
+
+ async function renderComponent(): Promise {
+ await render(hbs`
+
+ <:content as |pdf|>
+ Report
+
+ <:footer>
+
+
+
+ `);
+ }
+});
diff --git a/packages/test-app/tests/unit/services/pdf-export-test.ts b/packages/test-app/tests/unit/services/pdf-export-test.ts
new file mode 100644
index 000000000..064f13856
--- /dev/null
+++ b/packages/test-app/tests/unit/services/pdf-export-test.ts
@@ -0,0 +1,131 @@
+import { type TestContext } from '@ember/test-helpers';
+
+import { setupIntl } from 'ember-intl/test-support';
+import { setupTest } from 'ember-qunit';
+import { module, test } from 'qunit';
+import sinon from 'sinon';
+
+import type PdfExportService from '@upfluence/oss-components/services/pdf-export';
+import { setupToast } from '@upfluence/oss-components/test-support';
+
+const PAGE_OBJECT = /\/Type \/Page\b(?!s)/g;
+
+function buildReport(): HTMLElement {
+ const root = document.createElement('div');
+ root.setAttribute('style', 'width: 400px; background: white;');
+ ['#5d5fef', '#16b364', '#f79009'].forEach((color, index) => {
+ const section = document.createElement('div');
+ section.setAttribute('style', `height: 300px; background: ${color};`);
+ section.textContent = `Section ${index + 1}`;
+ root.append(section);
+ });
+ return root;
+}
+
+async function readText(blob: Blob): Promise {
+ return new TextDecoder('latin1').decode(await blob.arrayBuffer());
+}
+
+module('Unit | Service | pdf-export', (hooks) => {
+ setupTest(hooks);
+ setupIntl(hooks, 'en-us');
+ setupToast(hooks);
+
+ hooks.beforeEach(function (this: TestContext) {
+ this.service = this.owner.lookup('service:pdf-export') as PdfExportService;
+ this.saveStub = sinon.stub(this.service, 'save');
+ this.report = buildReport();
+ document.querySelector('#ember-testing')!.append(this.report);
+ });
+
+ hooks.afterEach(function (this: TestContext) {
+ this.report.remove();
+ sinon.restore();
+ });
+
+ module('#export', () => {
+ test('it saves the element as an A4 PDF with one page per planned page', async function (this: TestContext, assert) {
+ await this.service.export(this.report, { fileName: 'report.pdf' });
+
+ assert.true(this.saveStub.calledOnceWithExactly(sinon.match.instanceOf(Blob), 'report.pdf'));
+ const blob: Blob = this.saveStub.firstCall.args[0];
+ const text = await readText(blob);
+ assert.strictEqual(blob.type, 'application/pdf');
+ assert.true(text.startsWith('%PDF-'));
+ assert.strictEqual(text.match(PAGE_OBJECT)?.length, 3);
+ });
+
+ test('it loads the lazy images of the element before the capture', async function (this: TestContext, assert) {
+ const image = document.createElement('img');
+ image.loading = 'lazy';
+ image.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
+ this.report.append(image);
+
+ await this.service.export(this.report, { fileName: 'report.pdf' });
+
+ assert.strictEqual(image.loading, 'eager');
+ assert.true(this.saveStub.calledOnceWithExactly(sinon.match.instanceOf(Blob), 'report.pdf'));
+ });
+
+ test('it rejects without saving when the footer is taller than a page', async function (this: TestContext, assert) {
+ const footer = document.createElement('div');
+ footer.setAttribute('style', 'width: 400px; height: 600px;');
+ document.querySelector('#ember-testing')!.append(footer);
+
+ await assert.rejects(this.service.export(this.report, { fileName: 'report.pdf', footer }), (error: Error) =>
+ error.message.startsWith('[utils][pdf-export] The page height must be a positive number')
+ );
+ assert.false(this.saveStub.called);
+
+ footer.remove();
+ });
+
+ test('it stops without saving when the signal is aborted', async function (this: TestContext, assert) {
+ const controller = new AbortController();
+ controller.abort();
+
+ await assert.rejects(
+ this.service.export(this.report, { fileName: 'report.pdf', signal: controller.signal }),
+ (error: Error) => error.name === 'AbortError'
+ );
+ assert.false(this.saveStub.called);
+ });
+
+ test('it offers the download in a toast when the browser cannot download directly', async function (this: TestContext, assert) {
+ sinon.stub(this.service, 'canDownloadDirectly').returns(false);
+
+ await this.service.export(this.report, { fileName: 'report.pdf' });
+
+ assert.false(this.saveStub.called);
+ assert.true(
+ this.toastInfoStub.calledOnceWithExactly(
+ this.intl.t('oss-components.pdf-export.download.message'),
+ this.intl.t('oss-components.pdf-export.download.title'),
+ sinon.match({ timeout: 'none', onclick: sinon.match.func })
+ )
+ );
+
+ this.toastInfoStub.firstCall.args[2].onclick();
+
+ assert.true(this.saveStub.calledOnceWithExactly(sinon.match.instanceOf(Blob), 'report.pdf'));
+ });
+ });
+
+ module('#save', (hooks) => {
+ hooks.beforeEach(function (this: TestContext) {
+ this.saveStub.restore();
+ sinon.stub(URL, 'createObjectURL').returns('blob:pdf-export');
+ this.clickStub = sinon.stub(HTMLAnchorElement.prototype, 'click');
+ });
+
+ test('it clicks a download link with the file name and removes it', function (this: TestContext, assert) {
+ this.service.save(new Blob(['%PDF-'], { type: 'application/pdf' }), 'report.pdf');
+
+ const link: HTMLAnchorElement = this.clickStub.firstCall.thisValue;
+ assert.true(this.clickStub.calledOnceWithExactly());
+ assert.strictEqual(link.download, 'report.pdf');
+ assert.strictEqual(link.getAttribute('href'), 'blob:pdf-export');
+ assert.false(link.isConnected);
+ });
+ });
+});
diff --git a/packages/test-app/tests/unit/utils/pdf-export/cross-origin-font-faces-test.ts b/packages/test-app/tests/unit/utils/pdf-export/cross-origin-font-faces-test.ts
new file mode 100644
index 000000000..a7672f1ec
--- /dev/null
+++ b/packages/test-app/tests/unit/utils/pdf-export/cross-origin-font-faces-test.ts
@@ -0,0 +1,122 @@
+import { type TestContext } from '@ember/test-helpers';
+
+import { module, test } from 'qunit';
+import sinon from 'sinon';
+
+import exposeCrossOriginFontFaces from '@upfluence/oss-components/utils/pdf-export/cross-origin-font-faces';
+
+const SHEET_URL = 'https://cdn.test/fa/css/all.min.css';
+const SHEET_CSS =
+ '.fa{display:inline-block}' +
+ '@font-face{font-family:"Font Awesome 7 Pro";font-weight:900;src:url(../webfonts/fa-solid-900.woff2)format("woff2")}' +
+ '@font-face{font-family:"Font Awesome 7 Brands";src:url(\'https://fonts.test/fa-brands-400.woff2\')}';
+const EXPOSED_RULES =
+ '@font-face{font-family:"Font Awesome 7 Pro";font-weight:900;src:url(https://cdn.test/fa/webfonts/fa-solid-900.woff2)format("woff2")}\n' +
+ '@font-face{font-family:"Font Awesome 7 Brands";src:url(\'https://fonts.test/fa-brands-400.woff2\')}';
+
+function readableSheet(href: string | null): object {
+ return { href, cssRules: [] };
+}
+
+function crossOriginSheet(href: string): object {
+ return {
+ href,
+ get cssRules(): never {
+ throw new DOMException('Cannot access rules', 'SecurityError');
+ }
+ };
+}
+
+function stubStyleSheets(sheets: object[]): void {
+ sinon.stub(document, 'styleSheets').get(() => sheets as unknown as StyleSheetList);
+}
+
+function exposedStyles(): HTMLStyleElement[] {
+ return Array.from(document.head.querySelectorAll('style')).filter((style) => style.sheet?.disabled);
+}
+
+module('Unit | Utility | pdf-export/cross-origin-font-faces', (hooks) => {
+ hooks.beforeEach(function (this: TestContext) {
+ this.fetch = sinon.stub(window, 'fetch');
+ });
+
+ hooks.afterEach(function (this: TestContext) {
+ sinon.restore();
+ exposedStyles().forEach((style) => style.remove());
+ });
+
+ module('with a style sheet the page cannot read', (hooks) => {
+ hooks.beforeEach(function (this: TestContext) {
+ stubStyleSheets([readableSheet('http://localhost/app.css'), crossOriginSheet(SHEET_URL), readableSheet(null)]);
+ });
+
+ test('it fetches only that style sheet', async function (this: TestContext, assert) {
+ this.fetch.resolves(new Response(SHEET_CSS));
+
+ await exposeCrossOriginFontFaces();
+
+ assert.true(this.fetch.calledOnceWithExactly(SHEET_URL, { mode: 'cors', cache: 'force-cache' }));
+ });
+
+ test('it exposes its font faces with absolute URLs in a disabled style sheet', async function (this: TestContext, assert) {
+ this.fetch.resolves(new Response(SHEET_CSS));
+
+ await exposeCrossOriginFontFaces();
+
+ assert.deepEqual(
+ exposedStyles().map((style) => style.textContent),
+ [EXPOSED_RULES]
+ );
+ });
+
+ test('the returned callback removes the exposed font faces', async function (this: TestContext, assert) {
+ this.fetch.resolves(new Response(SHEET_CSS));
+
+ const removeFontFaces = await exposeCrossOriginFontFaces();
+ removeFontFaces();
+
+ assert.strictEqual(exposedStyles().length, 0);
+ });
+
+ test('it refetches the style sheet without cache when the cached copy is rejected', async function (this: TestContext, assert) {
+ this.fetch.onFirstCall().rejects(new TypeError('Failed to fetch'));
+ this.fetch.onSecondCall().resolves(new Response(SHEET_CSS));
+
+ await exposeCrossOriginFontFaces();
+
+ assert.true(
+ this.fetch.secondCall.calledWithExactly(
+ sinon.match(/^https:\/\/cdn\.test\/fa\/css\/all\.min\.css\?pdf-export=\d+$/),
+ {
+ mode: 'cors',
+ cache: 'no-store'
+ }
+ )
+ );
+ assert.deepEqual(
+ exposedStyles().map((style) => style.textContent),
+ [EXPOSED_RULES]
+ );
+ });
+
+ test('it exposes nothing when the style sheet cannot be fetched', async function (this: TestContext, assert) {
+ this.fetch.resolves(new Response('', { status: 403 }));
+
+ await exposeCrossOriginFontFaces();
+
+ assert.strictEqual(exposedStyles().length, 0);
+ });
+ });
+
+ module('when every style sheet is readable', (hooks) => {
+ hooks.beforeEach(function (this: TestContext) {
+ stubStyleSheets([readableSheet('http://localhost/app.css')]);
+ });
+
+ test('it fetches nothing', async function (this: TestContext, assert) {
+ await exposeCrossOriginFontFaces();
+
+ assert.true(this.fetch.notCalled);
+ });
+ });
+});
diff --git a/packages/test-app/tests/unit/utils/pdf-export/measure-boxes-test.ts b/packages/test-app/tests/unit/utils/pdf-export/measure-boxes-test.ts
new file mode 100644
index 000000000..3f9927ca3
--- /dev/null
+++ b/packages/test-app/tests/unit/utils/pdf-export/measure-boxes-test.ts
@@ -0,0 +1,79 @@
+import { type TestContext } from '@ember/test-helpers';
+
+import { module, test } from 'qunit';
+
+import measureBoxes from '@upfluence/oss-components/utils/pdf-export/measure-boxes';
+
+function block(style: string, children: Node[] = []): HTMLElement {
+ const element = document.createElement('div');
+ element.setAttribute('style', style);
+ element.append(...children);
+ return element;
+}
+
+function chart(): SVGSVGElement {
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
+ svg.setAttribute('width', '200');
+ svg.setAttribute('height', '20');
+ svg.style.display = 'block';
+ const rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
+ rect.setAttribute('width', '10');
+ rect.setAttribute('height', '10');
+ svg.append(rect);
+ return svg;
+}
+
+module('Unit | Utility | pdf-export/measure-boxes', (hooks) => {
+ hooks.beforeEach(function (this: TestContext) {
+ this.root = block('width: 200px;', [
+ block('height: 40px;'),
+ block('display: contents;', [block('height: 30px;')]),
+ block('height: 50px; margin-top: 10px;', [block('height: 20px; break-after: page;')]),
+ block('height: 0;'),
+ chart(),
+ block('height: 30px;', [document.createTextNode('Caption'), block('height: 10px;')])
+ ]);
+ document.querySelector('#ember-testing')!.append(this.root);
+ });
+
+ hooks.afterEach(function (this: TestContext) {
+ this.root.remove();
+ });
+
+ test('it measures the element tree relative to the root, in CSS pixels', function (this: TestContext, assert) {
+ assert.deepEqual(measureBoxes(this.root), {
+ top: 0,
+ bottom: 180,
+ breakBefore: false,
+ breakAfter: false,
+ containsForcedBreak: true,
+ children: [
+ { top: 0, bottom: 40, breakBefore: false, breakAfter: false, containsForcedBreak: false, children: [] },
+ { top: 40, bottom: 70, breakBefore: false, breakAfter: false, containsForcedBreak: false, children: [] },
+ {
+ top: 80,
+ bottom: 130,
+ breakBefore: false,
+ breakAfter: false,
+ containsForcedBreak: true,
+ children: [
+ { top: 80, bottom: 100, breakBefore: false, breakAfter: true, containsForcedBreak: false, children: [] }
+ ]
+ },
+ { top: 130, bottom: 150, breakBefore: false, breakAfter: false, containsForcedBreak: false, children: [] },
+ { top: 150, bottom: 180, breakBefore: false, breakAfter: false, containsForcedBreak: false, children: [] }
+ ]
+ });
+ });
+
+ test('it does not descend into an element that holds its own text', function (this: TestContext, assert) {
+ assert.deepEqual(measureBoxes(this.root).children[4], {
+ top: 150,
+ bottom: 180,
+ breakBefore: false,
+ breakAfter: false,
+ containsForcedBreak: false,
+ children: []
+ });
+ });
+});
diff --git a/packages/test-app/tests/unit/utils/pdf-export/plan-pages-test.ts b/packages/test-app/tests/unit/utils/pdf-export/plan-pages-test.ts
new file mode 100644
index 000000000..16f2db414
--- /dev/null
+++ b/packages/test-app/tests/unit/utils/pdf-export/plan-pages-test.ts
@@ -0,0 +1,135 @@
+import { type TestContext } from '@ember/test-helpers';
+
+import { module, test } from 'qunit';
+
+import type { PdfBox } from '@upfluence/oss-components/utils/pdf-export/measure-boxes';
+import planPages from '@upfluence/oss-components/utils/pdf-export/plan-pages';
+
+const PAGE_HEIGHT = 100;
+
+function box(top: number, bottom: number, children: PdfBox[] = [], breaks: Partial = {}): PdfBox {
+ return {
+ top,
+ bottom,
+ breakBefore: false,
+ breakAfter: false,
+ containsForcedBreak: children.some((child) => child.breakBefore || child.breakAfter || child.containsForcedBreak),
+ children,
+ ...breaks
+ };
+}
+
+module('Unit | Utility | pdf-export/plan-pages', () => {
+ test('it keeps content shorter than a page on a single page', function (this: TestContext, assert) {
+ const root = box(0, 80, [box(0, 40), box(40, 80)]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [{ top: 0, bottom: 80 }]);
+ });
+
+ test('it moves a block that does not fit to the next page', function (this: TestContext, assert) {
+ const root = box(0, 150, [box(0, 70), box(80, 150)]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 80 },
+ { top: 80, bottom: 150 }
+ ]);
+ });
+
+ test('it keeps side by side blocks on the same page', function (this: TestContext, assert) {
+ const root = box(0, 160, [box(0, 50), box(60, 130), box(70, 120), box(130, 160)]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 60 },
+ { top: 60, bottom: 160 }
+ ]);
+ });
+
+ test('it splits a block taller than a page between its children', function (this: TestContext, assert) {
+ const root = box(0, 190, [box(0, 190, [box(0, 60), box(60, 120), box(120, 190)])]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 60 },
+ { top: 60, bottom: 120 },
+ { top: 120, bottom: 190 }
+ ]);
+ });
+
+ test('it slices a block taller than a page that has no children', function (this: TestContext, assert) {
+ const root = box(0, 250, [box(0, 250)]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 100 },
+ { top: 100, bottom: 200 },
+ { top: 200, bottom: 250 }
+ ]);
+ });
+
+ test('it starts a new page before a block with a forced break before', function (this: TestContext, assert) {
+ const root = box(0, 60, [box(0, 20), box(20, 60, [], { breakBefore: true })]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 20 },
+ { top: 20, bottom: 60 }
+ ]);
+ });
+
+ test('it starts a new page after a block with a forced break after', function (this: TestContext, assert) {
+ const root = box(0, 60, [box(0, 20, [], { breakAfter: true }), box(30, 60)]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 20 },
+ { top: 20, bottom: 60 }
+ ]);
+ });
+
+ test('it honours a forced break nested in a block that fits on the page', function (this: TestContext, assert) {
+ const root = box(0, 80, [box(0, 80, [box(0, 30, [], { breakAfter: true }), box(40, 80)])]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 30 },
+ { top: 30, bottom: 80 }
+ ]);
+ });
+
+ test('it slices a root taller than a page that has no children', function (this: TestContext, assert) {
+ const root = box(0, 250);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 100 },
+ { top: 100, bottom: 200 },
+ { top: 200, bottom: 250 }
+ ]);
+ });
+
+ test('it moves the page start instead of leaving a page without content', function (this: TestContext, assert) {
+ const root = box(0, 155, [box(0, 50, [], { breakAfter: true }), box(60, 155)]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 60 },
+ { top: 60, bottom: 155 }
+ ]);
+ });
+
+ test('it clips the bottom padding of a split block instead of starting a page for it', function (this: TestContext, assert) {
+ const root = box(0, 225, [box(0, 225, [box(0, 60), box(60, 120), box(120, 215)])]);
+
+ assert.deepEqual(planPages(root, PAGE_HEIGHT), [
+ { top: 0, bottom: 60 },
+ { top: 60, bottom: 120 },
+ { top: 120, bottom: 220 }
+ ]);
+ });
+
+ test('it throws when the page height is not a positive number', function (this: TestContext, assert) {
+ const root = box(0, 80, [box(0, 80)]);
+
+ assert.throws(
+ () => planPages(root, 0),
+ (error: Error) => error.message === '[utils][pdf-export] The page height must be a positive number, got 0.'
+ );
+ assert.throws(
+ () => planPages(root, Number.NaN),
+ (error: Error) => error.message === '[utils][pdf-export] The page height must be a positive number, got NaN.'
+ );
+ });
+});
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 8b00d3abe..3b3d96067 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -31,10 +31,10 @@ importers:
version: 0.8.3(@vitejs/devtools-rolldown@0.8.3)(@vitejs/devtools-vite@0.8.3)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
'@vitejs/devtools-rolldown':
specifier: ^0.8.3
- version: 0.8.3(@devframes/agentic@1.4.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.4.0))(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
+ version: 0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
'@vitejs/devtools-vite':
specifier: ^0.8.3
- version: 0.8.3(@devframes/agentic@1.4.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.4.0))(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
+ version: 0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
eslint:
specifier: ^10.5.0
version: 10.8.0
@@ -95,6 +95,12 @@ importers:
ember-truth-helpers:
specifier: ^4.0.3
version: 4.0.3(ember-source@6.12.1(@glimmer/component@2.2.1)(rsvp@4.8.5))
+ jspdf:
+ specifier: ^4.2.1
+ version: 4.2.1
+ modern-screenshot:
+ specifier: ^4.7.0
+ version: 4.7.0
devDependencies:
'@babel/core':
specifier: ^7.25.2
@@ -3202,6 +3208,9 @@ packages:
'@types/node@20.11.16':
resolution: {integrity: sha512-gKb0enTmRCzXSSUJDq6/sPcqrfCv2mkkG6Jt/clpn5eiCbKTY+SgZUxo+p8ZKMof5dCp9vHQUAB7wOUTod22wQ==}
+ '@types/pako@2.0.4':
+ resolution: {integrity: sha512-VWDCbrLeVXJM9fihYodcLiIv0ku+AlOa/TQ1SvYOaBuyrSKgEcro95LJyIsJ4vSo6BXIxOKxiJAat04CmST9Fw==}
+
'@types/parse-json@4.0.2':
resolution: {integrity: sha512-dISoDXWWQwUquiKsyZ4Ng+HX2KsPL7LyHKHQwgGFEA3IaKac4Obd+h2a/a6waisAoepJlBcx9paWqjA8/HVjCw==}
@@ -3214,6 +3223,9 @@ packages:
'@types/qunit@2.19.14':
resolution: {integrity: sha512-ou2RMtwyDnW1btrMnDMZeL6V5/yRRbuHKrRC6y8IuzDljjVzw6wPCVFb8p4qJD0NkUkf3BdZeJJIBzjK1BUUDQ==}
+ '@types/raf@3.4.3':
+ resolution: {integrity: sha512-c4YAvMedbPZ5tEyxzQdMoOhhJ4RD3rngZIdwC2/qDN3d7JpEhB6fiBRKVY1lg5B7Wk+uPBjn5f39j1/2MY1oOw==}
+
'@types/range-parser@1.2.7':
resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==}
@@ -3818,6 +3830,10 @@ packages:
resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==}
engines: {node: 18 || 20 || >=22}
+ base64-arraybuffer@1.0.2:
+ resolution: {integrity: sha512-I3yl4r9QB5ZRY3XuJVEPfc2XhZO6YweFPI+UovAzn+8/hb3oJ6lnysaFcjVpkCPfVWFUDvoZ8kmVDP7WyRtYtQ==}
+ engines: {node: '>= 0.6.0'}
+
base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
@@ -4165,6 +4181,10 @@ packages:
caniuse-lite@1.0.30001826:
resolution: {integrity: sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==}
+ canvg@3.0.11:
+ resolution: {integrity: sha512-5ON+q7jCTgMp9cjpu4Jo6XbvfYwSB2Ow3kzHKfIyJfaCAOHLbdKPQqGKgfED/R5B+3TFFfe8pegYA+b423SRyA==}
+ engines: {node: '>=10.0.0'}
+
capture-exit@2.0.0:
resolution: {integrity: sha512-PiT/hQmTonHhl/HFGN+Lx3JJUznrVYJ3+AQsnthneZbvW7x+f08Tk7yLJTLEOUvBTbduLeeBkxEaYXUOUrRq6g==}
engines: {node: 6.* || 8.* || >= 10.*}
@@ -4618,6 +4638,9 @@ packages:
resolution: {integrity: sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==}
deprecated: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
+ core-js@3.51.0:
+ resolution: {integrity: sha512-7bDKx/5jm5MxzsXxc93g6Z2+4ZsuT/MddrfRmTDJNAkWsYWHU8EVNEsBiIEWnMAMCHMmRfUEjkuo3jeNBOIHRw==}
+
core-object@3.1.5:
resolution: {integrity: sha512-sA2/4+/PZ/KV6CKgjrVrrUVBKCkdDO02CUlQ0YKTQoYUwPYNOtOAcWlbYhd5v/1JqYaA6oZ4sDlOU4ppVw6Wbg==}
engines: {node: '>= 4'}
@@ -4663,6 +4686,9 @@ packages:
peerDependencies:
postcss: ^8.0.9
+ css-line-break@2.1.0:
+ resolution: {integrity: sha512-FHcKFCZcAha3LwfVBhCQbW2nCNbkZXn7KVUJcsT5/P8YmfsVja0FMPJr0B903j/E69HUphKiV9iQArX8SDYA4w==}
+
css-loader@5.2.7:
resolution: {integrity: sha512-Q7mOvpBNBG7YrVGMxRxcBJZFL75o+cH2abNASdibkj/fffYD8qWbInZrD0S9ccI6vZclF3DsHE7njGlLtaHbhg==}
engines: {node: '>= 10.13.0'}
@@ -5640,6 +5666,9 @@ packages:
fast-ordered-set@1.0.3:
resolution: {integrity: sha512-MxBW4URybFszOx1YlACEoK52P6lE3xiFcPaGCUZ7QQOZ6uJXKo++Se8wa31SjcZ+NC/fdAWX7UtKEfaGgHS2Vg==}
+ fast-png@6.4.0:
+ resolution: {integrity: sha512-kAqZq1TlgBjZcLr5mcN6NP5Rv4V2f22z00c3g8vRrwkcqjerx7BEhPbOnWCPqaHUl2XWQBJQvOT/FQhdMT7X/Q==}
+
fast-sourcemap-concat@2.1.1:
resolution: {integrity: sha512-7h9/x25c6AQwdU3mA8MZDUMR3UCy50f237egBrBkuwjnUZSmfu4ptCf91PZSKzON2Uh5VvIHozYKWcPPgcjxIw==}
engines: {node: 10.* || >= 12.*}
@@ -5679,6 +5708,9 @@ packages:
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
engines: {node: ^12.20 || >= 14.13}
+ fflate@0.8.3:
+ resolution: {integrity: sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==}
+
figures@2.0.0:
resolution: {integrity: sha512-Oa2M9atig69ZkfwiApY8F2Yy+tzMbazyvqv21R0NsSC8floSOC09BbT1ITWAdoMGQvJ/aZnR1KMwdx9tvHnTNA==}
engines: {node: '>=4'}
@@ -6236,6 +6268,10 @@ packages:
resolution: {integrity: sha512-n6l5uca7/y5joxZ3LUePhzmBFUJ+U2YWzhMa8XUTecSeSlQiZdF5XAd/Q3/WUl0VsXgUwWi8I7CNIwdI5WN1SQ==}
engines: {node: '>=20.10'}
+ html2canvas@1.4.1:
+ resolution: {integrity: sha512-fPU6BHNpsyIhr8yyMpTLLxAbkaK8ArIBcmZIRiBLiDhjeqvXolaEmDGmELFuX9I4xDcaKKcJl+TKZLqruBbmWA==}
+ engines: {node: '>=8.0.0'}
+
http-cache-semantics@4.1.1:
resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==}
@@ -6410,6 +6446,9 @@ packages:
resolution: {integrity: sha512-CYdFeFexxhv/Bcny+Q0BfOV+ltRlJcd4BBZBYFX/O0u4npJrgZtIcjokegtiSMAvlMTJ+Koq0GBCc//3bueQxw==}
engines: {node: '>=8'}
+ iobuffer@5.4.0:
+ resolution: {integrity: sha512-DRebOWuqDvxunfkNJAlc3IzWIPD5xVxwUNbHr7xKB8E6aLJxIPfNX3CoMJghcFjpv6RWQsrcJbghtEwSPoJqMA==}
+
ip-address@10.7.6:
resolution: {integrity: sha512-00LYkM6byILa9eQIx6qoaXCM40xTLd56AZ4vyaPW3YTyb49VZYPo5xsiAq4tuQ54GH4R7gVdYScJ1B7B77PuTg==}
engines: {node: '>= 12'}
@@ -6927,6 +6966,9 @@ packages:
jsonify@0.0.1:
resolution: {integrity: sha512-2/Ki0GcmuqSrgFyelQq9M05y7PS0mEwuIzrf3f1fPqkVDVRvZrPZtVSMHxdgo8Aq0sxAOb/cr2aqqA3LeWHVPg==}
+ jspdf@4.2.1:
+ resolution: {integrity: sha512-YyAXyvnmjTbR4bHQRLzex3CuINCDlQnBqoSYyjJwTP2x9jDLuKDzy7aKUl0hgx3uhcl7xzg32agn5vlie6HIlQ==}
+
keyv@3.1.0:
resolution: {integrity: sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA==}
@@ -7614,6 +7656,9 @@ packages:
mlly@1.8.2:
resolution: {integrity: sha512-d+ObxMQFmbt10sretNDytwt85VrbkhhUA/JBGm1MPaWJ65Cl4wOgLaB1NYvJSZ0Ef03MMEU/0xpPMXUIQ29UfA==}
+ modern-screenshot@4.7.0:
+ resolution: {integrity: sha512-9YxN+ddPSMMlhylOv25VHzXrl9u67QRxoh7+SEewGtgUw7t6hHTrjptSDJUSne9oG4Xk/h2cwG15nIt4Hc9ujg==}
+
morgan@1.12.1:
resolution: {integrity: sha512-tljKC0ex20AjO58Ob/eZ53JloycbVswbVNCHx6V6VLGzqt/w8dIynVGL0G8qVjNKwiA7sYSogCrN6QtJ82IV+g==}
engines: {node: '>= 0.8.0'}
@@ -8030,6 +8075,9 @@ packages:
resolution: {integrity: sha512-MQEgDUvXCa3sGvqHg3pzHO8e9gqTCMPVrWUko3vPQGntwegmFo52mZb2abIVTjFnUcW0BcPz0D93jV5Cas1DWA==}
engines: {node: '>=18'}
+ pako@2.2.0:
+ resolution: {integrity: sha512-zJq6RP/5q+TO2OpFV3FHzlPnFjmkb7Nc99a5SNjJE+uu/PkpChs+NIZSSzbBoD+6kjiISXjfYdwj1ZRQ81dz/w==}
+
parent-module@1.0.1:
resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==}
engines: {node: '>=6'}
@@ -8161,6 +8209,9 @@ packages:
perfect-debounce@2.1.0:
resolution: {integrity: sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g==}
+ performance-now@2.1.0:
+ resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==}
+
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
@@ -8556,6 +8607,9 @@ packages:
engines: {node: '>=10'}
hasBin: true
+ raf@3.4.1:
+ resolution: {integrity: sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==}
+
range-parser@1.2.1:
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
engines: {node: '>= 0.6'}
@@ -8810,6 +8864,10 @@ packages:
resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==}
engines: {iojs: '>=1.0.0', node: '>=0.10.0'}
+ rgbcolor@1.0.1:
+ resolution: {integrity: sha512-9aZLIrhRaD97sgVhtJOW6ckOEh6/GnvQtdVNfdZ6s67+3/XwLS9lBcQYzEEhYVeUowN7pRzMLsyGhK2i/xvWbw==}
+ engines: {node: '>= 0.8.15'}
+
rimraf@2.7.1:
resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==}
deprecated: Rimraf versions prior to v4 are no longer supported
@@ -9297,6 +9355,10 @@ packages:
resolution: {integrity: sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==}
deprecated: 'Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility'
+ stackblur-canvas@2.7.0:
+ resolution: {integrity: sha512-yf7OENo23AGJhBriGx0QivY5JP6Y1HbrrDI6WLt6C5auYZXlQrheoY8hD4ibekFKz1HOfE48Ww8kMWMnJD/zcQ==}
+ engines: {node: '>=0.1.14'}
+
stagehand@1.0.1:
resolution: {integrity: sha512-GqXBq2SPWv9hTXDFKS8WrKK1aISB0aKGHZzH+uD4ShAgs+Fz20ZfoerLOm8U+f62iRWLrw6nimOY/uYuTcVhvg==}
engines: {node: 6.* || 8.* || >= 10.*}
@@ -9479,6 +9541,10 @@ packages:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
+ svg-pathdata@6.0.3:
+ resolution: {integrity: sha512-qsjeeq5YjBZ5eMdFuUa4ZosMLxgr5RZ+F+Y1OrDhuOCEInRMA3x74XdBtggJcj9kOeInz0WE+LgCPDkZFlBYJw==}
+ engines: {node: '>=12.0.0'}
+
svg-tags@1.0.0:
resolution: {integrity: sha512-ovssysQTa+luh7A5Weu3Rta6FJlFBBbInjOh722LIt6klpU2/HtdUbszju/G4devcvk8PGt7FCLv5wftu3THUA==}
@@ -9535,6 +9601,9 @@ packages:
engines: {node: ^20.19.0 || ^22.12.0 || ^24.0.0 || >= 26.0.0}
hasBin: true
+ text-segmentation@1.0.3:
+ resolution: {integrity: sha512-iOiPUo/BGnZ6+54OsWxZidGCsdU8YbE4PSpdPinp7DeMtUJNJBoJ/ouUSTJjHkh1KntHaltHl/gDs2FC4i5+Nw==}
+
textextensions@2.6.0:
resolution: {integrity: sha512-49WtAWS+tcsy93dRt6P0P3AMD2m5PvXRhuEA0kaXos5ZLlujtYmpmFsB+QvWUSxE1ZsstmYXfQ7L40+EcQgpAQ==}
engines: {node: '>=0.8'}
@@ -9923,6 +9992,9 @@ packages:
resolution: {integrity: sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==}
engines: {node: '>= 0.4.0'}
+ utrie@1.0.2:
+ resolution: {integrity: sha512-1MLa5ouZiOmQzUbjbu9VmjLzn1QLXBhwpUa7kdLUQK+KQ5KA9I1vk5U4YHe/X2Ch7PYnJfWuWT+VbuxbGwljhw==}
+
uuid@8.3.2:
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
@@ -13036,27 +13108,6 @@ snapshots:
'@types/deep-eql@4.0.2': {}
- '@types/ember@4.0.11':
- dependencies:
- '@types/ember__application': 4.0.11(@babel/core@7.29.13)
- '@types/ember__array': 4.0.10(@babel/core@7.29.13)
- '@types/ember__component': 4.0.22(@babel/core@7.29.13)
- '@types/ember__controller': 4.0.12(@babel/core@7.29.13)
- '@types/ember__debug': 4.0.8(@babel/core@7.29.13)
- '@types/ember__engine': 4.0.11(@babel/core@7.29.13)
- '@types/ember__error': 4.0.6
- '@types/ember__object': 4.0.12(@babel/core@7.29.13)
- '@types/ember__polyfills': 4.0.6
- '@types/ember__routing': 4.0.21(@babel/core@7.29.13)
- '@types/ember__runloop': 4.0.10
- '@types/ember__service': 4.0.9(@babel/core@7.29.13)
- '@types/ember__string': 3.0.15
- '@types/ember__template': 4.0.7
- '@types/ember__test': 4.0.6(@babel/core@7.29.13)
- '@types/ember__utils': 4.0.7
- '@types/rsvp': 4.0.9
- optional: true
-
'@types/ember@4.0.11(@babel/core@7.29.13)':
dependencies:
'@types/ember__application': 4.0.11(@babel/core@7.29.13)
@@ -13084,7 +13135,7 @@ snapshots:
'@types/ember__application@4.0.11(@babel/core@7.29.13)':
dependencies:
'@glimmer/component': 1.1.2(@babel/core@7.29.13)
- '@types/ember': 4.0.11
+ '@types/ember': 4.0.11(@babel/core@7.29.13)
'@types/ember__engine': 4.0.11(@babel/core@7.29.13)
'@types/ember__object': 4.0.12(@babel/core@7.29.13)
'@types/ember__owner': 4.0.9
@@ -13167,11 +13218,6 @@ snapshots:
- supports-color
optional: true
- '@types/ember__runloop@4.0.10':
- dependencies:
- '@types/ember': 4.0.11
- optional: true
-
'@types/ember__runloop@4.0.10(@babel/core@7.29.13)':
dependencies:
'@types/ember': 4.0.11(@babel/core@7.29.13)
@@ -13202,11 +13248,6 @@ snapshots:
- supports-color
optional: true
- '@types/ember__utils@4.0.7':
- dependencies:
- '@types/ember': 4.0.11
- optional: true
-
'@types/ember__utils@4.0.7(@babel/core@7.29.13)':
dependencies:
'@types/ember': 4.0.11(@babel/core@7.29.13)
@@ -13292,6 +13333,8 @@ snapshots:
dependencies:
undici-types: 5.26.5
+ '@types/pako@2.0.4': {}
+
'@types/parse-json@4.0.2': {}
'@types/prop-types@15.7.15': {}
@@ -13300,6 +13343,9 @@ snapshots:
'@types/qunit@2.19.14': {}
+ '@types/raf@3.4.3':
+ optional: true
+
'@types/range-parser@1.2.7': {}
'@types/react@18.2.54':
@@ -13485,7 +13531,7 @@ snapshots:
- ocache
- srvx
- '@vitejs/devtools-rolldown@0.8.3(@devframes/agentic@1.4.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.4.0))(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)':
+ '@vitejs/devtools-rolldown@0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)':
dependencies:
'@rolldown/debug': 1.3.3
'@vitejs/devtools-kit': 0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
@@ -13500,7 +13546,7 @@ snapshots:
- srvx
- vite
- '@vitejs/devtools-vite@0.8.3(@devframes/agentic@1.4.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.4.0))(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)':
+ '@vitejs/devtools-vite@0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)':
dependencies:
'@vitejs/devtools-kit': 0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
envinfo: 7.21.0
@@ -13535,8 +13581,8 @@ snapshots:
pathe: 2.0.3
vite: 8.3.8(@vitejs/devtools@0.8.3)(less@4.2.2)(terser@5.51.2)(yaml@2.9.1)
optionalDependencies:
- '@vitejs/devtools-rolldown': 0.8.3(@devframes/agentic@1.4.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.4.0))(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
- '@vitejs/devtools-vite': 0.8.3(@devframes/agentic@1.4.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.4.0))(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
+ '@vitejs/devtools-rolldown': 0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
+ '@vitejs/devtools-vite': 0.8.3(@devframes/agentic@1.4.0)(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.8)
transitivePeerDependencies:
- '@devframes/plugin-inspect--assets'
- '@devframes/plugin-messages--assets'
@@ -14054,6 +14100,9 @@ snapshots:
balanced-match@4.0.4: {}
+ base64-arraybuffer@1.0.2:
+ optional: true
+
base64-js@1.5.1: {}
base@0.11.2:
@@ -14703,6 +14752,18 @@ snapshots:
caniuse-lite@1.0.30001826: {}
+ canvg@3.0.11:
+ dependencies:
+ '@babel/runtime': 7.29.13
+ '@types/raf': 3.4.3
+ core-js: 3.51.0
+ raf: 3.4.1
+ regenerator-runtime: 0.13.11
+ rgbcolor: 1.0.1
+ stackblur-canvas: 2.7.0
+ svg-pathdata: 6.0.3
+ optional: true
+
capture-exit@2.0.0:
dependencies:
rsvp: 4.8.5
@@ -14990,6 +15051,9 @@ snapshots:
core-js@2.6.12: {}
+ core-js@3.51.0:
+ optional: true
+
core-object@3.1.5:
dependencies:
chalk: 2.4.2
@@ -15042,6 +15106,11 @@ snapshots:
dependencies:
postcss: 8.5.32
+ css-line-break@2.1.0:
+ dependencies:
+ utrie: 1.0.2
+ optional: true
+
css-loader@5.2.7(webpack@5.112.2(postcss@8.5.32)):
dependencies:
icss-utils: 5.1.0(postcss@8.5.32)
@@ -16713,6 +16782,12 @@ snapshots:
dependencies:
blank-object: 1.0.2
+ fast-png@6.4.0:
+ dependencies:
+ '@types/pako': 2.0.4
+ iobuffer: 5.4.0
+ pako: 2.2.0
+
fast-sourcemap-concat@2.1.1:
dependencies:
chalk: 2.4.2
@@ -16758,6 +16833,8 @@ snapshots:
node-domexception: 1.0.0
web-streams-polyfill: 3.3.3
+ fflate@0.8.3: {}
+
figures@2.0.0:
dependencies:
escape-string-regexp: 1.0.5
@@ -17456,6 +17533,12 @@ snapshots:
html-tags@5.1.0: {}
+ html2canvas@1.4.1:
+ dependencies:
+ css-line-break: 2.1.0
+ text-segmentation: 1.0.3
+ optional: true
+
http-cache-semantics@4.1.1: {}
http-errors@1.6.3:
@@ -17654,6 +17737,8 @@ snapshots:
invert-kv@3.0.1: {}
+ iobuffer@5.4.0: {}
+
ip-address@10.7.6: {}
ip@1.1.9: {}
@@ -18166,6 +18251,17 @@ snapshots:
jsonify@0.0.1: {}
+ jspdf@4.2.1:
+ dependencies:
+ '@babel/runtime': 7.29.13
+ fast-png: 6.4.0
+ fflate: 0.8.3
+ optionalDependencies:
+ canvg: 3.0.11
+ core-js: 3.51.0
+ dompurify: 3.3.3
+ html2canvas: 1.4.1
+
keyv@3.1.0:
dependencies:
json-buffer: 3.0.0
@@ -18938,6 +19034,8 @@ snapshots:
pkg-types: 1.3.1
ufo: 1.6.4
+ modern-screenshot@4.7.0: {}
+
morgan@1.12.1:
dependencies:
basic-auth: 2.0.1
@@ -19468,6 +19566,8 @@ snapshots:
dependencies:
find-up-simple: 1.0.1
+ pako@2.2.0: {}
+
parent-module@1.0.1:
dependencies:
callsites: 3.1.0
@@ -19571,6 +19671,9 @@ snapshots:
perfect-debounce@2.1.0: {}
+ performance-now@2.1.0:
+ optional: true
+
picocolors@1.1.1: {}
picomatch@2.3.1: {}
@@ -19942,6 +20045,11 @@ snapshots:
node-watch: 0.7.3
tiny-glob: 0.2.9
+ raf@3.4.1:
+ dependencies:
+ performance-now: 2.1.0
+ optional: true
+
range-parser@1.2.1: {}
raw-body@1.1.7:
@@ -20266,6 +20374,9 @@ snapshots:
reusify@1.0.4: {}
+ rgbcolor@1.0.1:
+ optional: true
+
rimraf@2.7.1:
dependencies:
glob: 7.2.3
@@ -20891,6 +21002,9 @@ snapshots:
stable@0.1.8: {}
+ stackblur-canvas@2.7.0:
+ optional: true
+
stagehand@1.0.1:
dependencies:
debug: 4.4.3
@@ -21106,6 +21220,9 @@ snapshots:
supports-preserve-symlinks-flag@1.0.0: {}
+ svg-pathdata@6.0.3:
+ optional: true
+
svg-tags@1.0.0: {}
svgo@2.8.4:
@@ -21246,6 +21363,11 @@ snapshots:
- walrus
- whiskers
+ text-segmentation@1.0.3:
+ dependencies:
+ utrie: 1.0.2
+ optional: true
+
textextensions@2.6.0: {}
through2@3.0.2:
@@ -21671,6 +21793,11 @@ snapshots:
utils-merge@1.0.1: {}
+ utrie@1.0.2:
+ dependencies:
+ base64-arraybuffer: 1.0.2
+ optional: true
+
uuid@8.3.2: {}
v8-compile-cache@2.4.0: {}