@snowcone-app/canvas 0.42.1 → 0.43.1

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 (41) hide show
  1. package/ERROR_CONTRACT.md +45 -0
  2. package/dist/{CanvasRenderer-Bm7KLh38.js → CanvasRenderer-DnYgiWjt.js} +2 -2
  3. package/dist/{CanvasRenderer-Bm7KLh38.js.map → CanvasRenderer-DnYgiWjt.js.map} +1 -1
  4. package/dist/{CanvasStateV1-DPSSkdyD.js → CanvasStateV1-B51bXTyy.js} +2 -2
  5. package/dist/{CanvasStateV1-DPSSkdyD.js.map → CanvasStateV1-B51bXTyy.js.map} +1 -1
  6. package/dist/{ContextualToolbars-BuWJ3vD8.js → ContextualToolbars-DtlxDatY.js} +4 -4
  7. package/dist/{ContextualToolbars-BuWJ3vD8.js.map → ContextualToolbars-DtlxDatY.js.map} +1 -1
  8. package/dist/{EditorCanvasImpl-CtiIZyyt.js → EditorCanvasImpl-B5IEg9tq.js} +6 -6
  9. package/dist/{EditorCanvasImpl-CtiIZyyt.js.map → EditorCanvasImpl-B5IEg9tq.js.map} +1 -1
  10. package/dist/{ExportManager-DCEgNCL-.js → ExportManager-vAuaoF5Q.js} +1212 -1224
  11. package/dist/{ExportManager-DCEgNCL-.js.map → ExportManager-vAuaoF5Q.js.map} +1 -1
  12. package/dist/FontAnalyzer-D9R2PYsy.js.map +1 -1
  13. package/dist/{ImagePanel-WLkHhuBY.js → ImagePanel-kybrF6yT.js} +3 -3
  14. package/dist/{ImagePanel-WLkHhuBY.js.map → ImagePanel-kybrF6yT.js.map} +1 -1
  15. package/dist/SnowconeCanvas-rAUrO9PR.js +1157 -0
  16. package/dist/SnowconeCanvas-rAUrO9PR.js.map +1 -0
  17. package/dist/advanced.mjs +9 -9
  18. package/dist/api/embed.d.ts +1 -0
  19. package/dist/api/stable.d.ts +1 -0
  20. package/dist/components/embed/SnowconeCanvas.d.ts +13 -0
  21. package/dist/{custom-icons-B3auKmXj.js → custom-icons-Dlfrg3A_.js} +2 -2
  22. package/dist/{custom-icons-B3auKmXj.js.map → custom-icons-Dlfrg3A_.js.map} +1 -1
  23. package/dist/design/template-fields.d.ts +5 -0
  24. package/dist/{embed-hQtKIv0u.js → embed-BXa1jr7S.js} +7 -7
  25. package/dist/{embed-hQtKIv0u.js.map → embed-BXa1jr7S.js.map} +1 -1
  26. package/dist/embed.mjs +5 -5
  27. package/dist/errors/editorError.d.ts +4 -1
  28. package/dist/index.mjs +7 -7
  29. package/dist/internals.mjs +4 -4
  30. package/dist/{template-fields-pasAAplQ.js → template-fields-ZZEdYB5H.js} +44 -43
  31. package/dist/{template-fields-pasAAplQ.js.map → template-fields-ZZEdYB5H.js.map} +1 -1
  32. package/dist/{useCommands-htOtw7w6.js → useCommands-d5UM6Cnc.js} +5 -5
  33. package/dist/{useCommands-htOtw7w6.js.map → useCommands-d5UM6Cnc.js.map} +1 -1
  34. package/dist/utils/ExportManager.d.ts +37 -1
  35. package/dist/utils/printFiles.d.ts +23 -0
  36. package/dist/{validation-m6hAaElF.js → validation-C8qNtk6j.js} +9 -9
  37. package/dist/{validation-m6hAaElF.js.map → validation-C8qNtk6j.js.map} +1 -1
  38. package/example/package.json +1 -1
  39. package/package.json +2 -2
  40. package/dist/SnowconeCanvas-1wc08k_m.js +0 -1098
  41. package/dist/SnowconeCanvas-1wc08k_m.js.map +0 -1
@@ -7,7 +7,22 @@ import { PathElement } from '../core/PathElement.js';
7
7
  import { ArtboardManager } from '../core/ArtboardManager.js';
8
8
  import { AnyElementConfig } from '../types/index.js';
9
9
  /** Union of all element types supported by export */
10
- type ExportElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
10
+ export type ExportElement = TextElement | ImageElement | GroupElement | ShapeElement | PathElement;
11
+ /** A rect of an artboard, in artboard units (its own px), exported on its own; `id` keys the result. */
12
+ export interface ExportRegion {
13
+ id: string;
14
+ x: number;
15
+ y: number;
16
+ width: number;
17
+ height: number;
18
+ }
19
+ /** One print file: a lossless PNG and the pixels it holds (`scale` = its pixels per artboard unit). */
20
+ export interface PrintFile {
21
+ blob: Blob;
22
+ width: number;
23
+ height: number;
24
+ scale: number;
25
+ }
11
26
  /** Serialized workspace document for JSON import/export. */
12
27
  export interface CanvasDocument {
13
28
  metadata: {
@@ -101,6 +116,27 @@ export declare class ExportManager {
101
116
  * worker), so font readiness matters here even when no fallback occurred.
102
117
  */
103
118
  private static mainThreadExportToDataURL;
119
+ /**
120
+ * One artboard's PRINT file: a lossless PNG of the artboard (or of `region`, a rect of it in artboard units) at
121
+ * `scale` pixels per artboard unit, painted from every image's ORIGINAL pixels (the worker's 4,000 px bitmap cap,
122
+ * `DEFAULT_MAX_BITMAP_DIMENSION`, keeps the live preview light; a print needs what the shopper uploaded).
123
+ *
124
+ * Painted on the main thread (the worker would cache an uncapped copy of every picture), one canvas, released as
125
+ * soon as it is encoded: the caller asks for files one at a time, so a phone holds one print canvas at most.
126
+ * Throws `E_PRINT_FILE_FAILED` (typed, with the size asked for) when the device could not hold or encode it.
127
+ */
128
+ static exportPrintFile(artboard: ArtboardElement, elements: ExportElement[], options: {
129
+ scale: number;
130
+ region?: ExportRegion;
131
+ }): Promise<PrintFile>;
132
+ /**
133
+ * Paint an artboard (or a rect of it) on a detached main-thread canvas: background, compositing (knockout / clip),
134
+ * every visible element with its masks / distress / layer effects, then the artboard's distress texture and image
135
+ * mask. The one main-thread painter: the blob, data URL and print exports all use it (the blob path used to skip
136
+ * masks, distress and the artboard effects the data URL path drew). A hidden layer is not part of the design and is
137
+ * never painted (as the worker serializer drops it).
138
+ */
139
+ private static renderOnMainThread;
104
140
  /**
105
141
  * Apply clip path for export background (uses 0,0 as origin since background is drawn before translate)
106
142
  */
@@ -0,0 +1,23 @@
1
+ import { ArtboardElement } from '../core/ArtboardElement.js';
2
+ import { ExportElement, ExportRegion, PrintFile } from './ExportManager.js';
3
+ export type { ExportRegion, PrintFile };
4
+ export interface PrintFilesRequest {
5
+ /**
6
+ * Pixels per artboard unit, keyed by RESULT key (an artboard's name, or a region's id). Not named: 1, the artboard's
7
+ * own px. An engraving file is made at 2 (twice the area's 300 dpi px); a phone may ask for less where one file would
8
+ * not fit one of its canvases.
9
+ */
10
+ scale?: Readonly<Record<string, number>>;
11
+ /** Artboards made as rects of themselves (artboard units), one file per rect, keyed by the rect's id. */
12
+ regions?: Readonly<Record<string, ReadonlyArray<ExportRegion>>>;
13
+ }
14
+ /** How long a print file waits for a picture still loading on its artboard before it refuses. */
15
+ export declare const PRINT_FILE_IMAGE_WAIT_MS = 10000;
16
+ /**
17
+ * Make the print files of `artboards`, one at a time: each artboard whole (keyed by its name), or each of its
18
+ * `regions` (keyed by region id). `elementsOn(artboard)` gives the artboard's elements (live instances: their
19
+ * pictures' original pixels are what is painted).
20
+ */
21
+ export declare function exportPrintFiles(artboards: readonly ArtboardElement[], elementsOn: (artboard: ArtboardElement) => ExportElement[], request?: PrintFilesRequest, options?: {
22
+ imageWaitMs?: number;
23
+ }): Promise<Record<string, PrintFile>>;
@@ -2,16 +2,16 @@ import { jsx as r, jsxs as y, Fragment as Pn } from "react/jsx-runtime";
2
2
  import * as $n from "react";
3
3
  import je, { useState as le, useEffect as Ie, useCallback as ft, useMemo as xs, useContext as Ar, createContext as Dr, useRef as we, useImperativeHandle as nr, forwardRef as Nr } from "react";
4
4
  import { b as rs, x as sr, z as _s, A as $s, e as Ts, q as Br, c as zr, v as Or } from "./design-builder-C8s1r4MF.js";
5
- import { l as rr, I as Oe, s as Xr, u as or, c as Fn, v as Qt, i as _e, J as Lr, G as Yr, H as Hr, F as _r, W as $r, T as dn, q as un, r as hn, B as Ct, Y as Fr, Z as Wr, _ as Vr, D as ir, k as Kr, b as ar } from "./useCommands-htOtw7w6.js";
5
+ import { l as rr, I as Oe, s as Xr, u as or, c as Fn, v as Qt, i as _e, J as Lr, G as Yr, H as Hr, F as _r, W as $r, T as dn, q as un, r as hn, B as Ct, Y as Fr, Z as Wr, _ as Vr, D as ir, k as Kr, b as ar } from "./useCommands-d5UM6Cnc.js";
6
6
  import { I as Lt, G as Re, b9 as Is, x as ys, af as cr, ba as Fs, bb as Ur, a1 as Cn, bc as Gr, bd as us, P as wn, c as On, a6 as en, a4 as ms, be as qr, T as Qe, u as jr, bf as Jn, bg as Zr, bh as Jr, bi as Qr, a5 as lr, a3 as eo, bj as Es, a2 as to, g as no, S as Qn, ax as so, z as Bn } from "./FontAnalyzer-D9R2PYsy.js";
7
7
  import { createPortal as dr } from "react-dom";
8
- import { b as ro, n as ur, g as _n, c as oo, r as io, d as ao, C as Ws, e as Vs, f as gs, T as co, a as lo, A as uo, S as ho, I as fo } from "./CanvasRenderer-Bm7KLh38.js";
8
+ import { b as ro, n as ur, g as _n, c as oo, r as io, d as ao, C as Ws, e as Vs, f as gs, T as co, a as lo, A as uo, S as ho, I as fo } from "./CanvasRenderer-DnYgiWjt.js";
9
9
  import { u as po } from "./ThemeContext-Rjz25x9X.js";
10
10
  import { renderToStaticMarkup as mo } from "react-dom/server";
11
- import { D as Ps, n as As, o as hr, p as Ds, e as go, q as Mt } from "./ContextualToolbars-BuWJ3vD8.js";
12
- import { L as Tt, S as fr, T as zt, I as xo } from "./custom-icons-B3auKmXj.js";
11
+ import { D as Ps, n as As, o as hr, p as Ds, e as go, q as Mt } from "./ContextualToolbars-DtlxDatY.js";
12
+ import { L as Tt, S as fr, T as zt, I as xo } from "./custom-icons-Dlfrg3A_.js";
13
13
  import * as ts from "@radix-ui/react-radio-group";
14
- import { S as yo, U as Ks, V as Us } from "./ExportManager-DCEgNCL-.js";
14
+ import { S as yo, U as Ks, V as Us } from "./ExportManager-vAuaoF5Q.js";
15
15
  import { cva as pr } from "class-variance-authority";
16
16
  import { debounce as Gs } from "lodash-es";
17
17
  const bo = {
@@ -5659,12 +5659,12 @@ async function Ja() {
5659
5659
  ] = await Promise.all([
5660
5660
  Promise.resolve().then(() => va),
5661
5661
  Promise.resolve().then(() => wa),
5662
- import("./ImagePanel-WLkHhuBY.js"),
5662
+ import("./ImagePanel-kybrF6yT.js"),
5663
5663
  Promise.resolve().then(() => Ra),
5664
5664
  Promise.resolve().then(() => Ta),
5665
- import("./ContextualToolbars-BuWJ3vD8.js").then((c) => c.s),
5665
+ import("./ContextualToolbars-DtlxDatY.js").then((c) => c.s),
5666
5666
  Promise.resolve().then(() => Ia),
5667
- import("./ContextualToolbars-BuWJ3vD8.js").then((c) => c.r)
5667
+ import("./ContextualToolbars-DtlxDatY.js").then((c) => c.r)
5668
5668
  ]);
5669
5669
  It("effects-panel", {
5670
5670
  component: e,
@@ -8694,4 +8694,4 @@ export {
8694
8694
  Za as u,
8695
8695
  oc as v
8696
8696
  };
8697
- //# sourceMappingURL=validation-m6hAaElF.js.map
8697
+ //# sourceMappingURL=validation-C8qNtk6j.js.map