@bitcaster/printkit 0.0.0-stage → 0.1.0

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 (56) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +8 -2
  3. package/README.npm.md +9 -0
  4. package/THIRD_PARTY_NOTICES.md +1973 -0
  5. package/dist/assets/fonts/C400.ttf +0 -0
  6. package/dist/assets/fonts/M400.ttf +0 -0
  7. package/dist/assets/fonts/M600.ttf +0 -0
  8. package/dist/assets/fonts/M700.ttf +0 -0
  9. package/dist/assets/fonts/OFL-IBMPlexMono.txt +93 -0
  10. package/dist/assets/fonts/OFL-LibreCaslonText.txt +93 -0
  11. package/dist/assets/fonts/OFL-Manrope.txt +93 -0
  12. package/dist/assets/fonts/P400.ttf +0 -0
  13. package/dist/assets/fonts/P500.ttf +0 -0
  14. package/dist/assets/pdf.worker.min.mjs +29 -0
  15. package/dist/components/index.d.ts +42 -0
  16. package/dist/components/index.js +1 -0
  17. package/dist/components/p-6By_vSL9.js +1 -0
  18. package/dist/components/p-B85ddf5i.js +58 -0
  19. package/dist/components/p-BEuF_WyR.js +15 -0
  20. package/dist/components/p-C06-VTon.js +1 -0
  21. package/dist/components/p-C5up7ejY.js +22 -0
  22. package/dist/components/p-ChB3W-Ln.js +3 -0
  23. package/dist/components/p-DpEO5JlK.js +2 -0
  24. package/dist/components/p-DzTdZECU.js +21 -0
  25. package/dist/components/pk-editor.d.ts +11 -0
  26. package/dist/components/pk-editor.js +277 -0
  27. package/dist/components/pk-help.d.ts +11 -0
  28. package/dist/components/pk-help.js +1 -0
  29. package/dist/components/pk-template-editor.d.ts +11 -0
  30. package/dist/components/pk-template-editor.js +1 -0
  31. package/dist/types/.stencil/components/pk-editor/pk-editor.d.ts +113 -0
  32. package/dist/types/.stencil/components/pk-help/help.content.d.ts +1 -0
  33. package/dist/types/.stencil/components/pk-help/pk-help.d.ts +9 -0
  34. package/dist/types/.stencil/components/pk-template-editor/pk-template-editor.d.ts +203 -0
  35. package/dist/types/.stencil/services/background-load.d.ts +20 -0
  36. package/dist/types/.stencil/services/background.d.ts +70 -0
  37. package/dist/types/.stencil/services/card-engine.d.ts +123 -0
  38. package/dist/types/.stencil/services/card-render.d.ts +5 -0
  39. package/dist/types/.stencil/services/card.config.d.ts +48 -0
  40. package/dist/types/.stencil/services/cmyk-lut.d.ts +4 -0
  41. package/dist/types/.stencil/services/collide.d.ts +19 -0
  42. package/dist/types/.stencil/services/color.d.ts +12 -0
  43. package/dist/types/.stencil/services/design.d.ts +106 -0
  44. package/dist/types/.stencil/services/fonts.d.ts +32 -0
  45. package/dist/types/.stencil/services/layouts.d.ts +15 -0
  46. package/dist/types/.stencil/services/logo.d.ts +19 -0
  47. package/dist/types/.stencil/services/palette.d.ts +31 -0
  48. package/dist/types/.stencil/services/pdf.d.ts +26 -0
  49. package/dist/types/.stencil/services/qr.d.ts +21 -0
  50. package/dist/types/.stencil/services/spot.d.ts +49 -0
  51. package/dist/types/.stencil/services/terms.d.ts +1 -0
  52. package/dist/types/.stencil/types/card.types.d.ts +403 -0
  53. package/dist/types/.stencil/types/editor.types.d.ts +48 -0
  54. package/dist/types/components.d.ts +320 -0
  55. package/dist/types/stencil-public-runtime.d.ts +1879 -0
  56. package/package.json +46 -4
@@ -0,0 +1,403 @@
1
+ /** CMYK color, each channel 0..1 */
2
+ export type Cmyk = [number, number, number, number];
3
+ export type ColorRole = 'bg' | 'ink' | 'muted' | 'accent' | 'onAccent' | 'bgMuted';
4
+ /** Reference to a color of the template's own list (`template.colors`) by its id */
5
+ export type PaletteRef = `p:${string}`;
6
+ export type ColorRef = ColorRole | Cmyk | PaletteRef;
7
+ /**
8
+ * A color of the template's own list. With `spot` and a usable name it prints on its own plate named `name`, the CMYK
9
+ * value being the alternate for screens and proofs; `overprint` lets that plate print over what lies underneath.
10
+ */
11
+ export interface PaletteColor {
12
+ id: string;
13
+ name: string;
14
+ cmyk: Cmyk;
15
+ spot?: boolean;
16
+ overprint?: boolean;
17
+ }
18
+ /** Built-in font files */
19
+ export type BaseFontId = 'M400' | 'M600' | 'M700' | 'C400' | 'P400' | 'P500';
20
+ /** Faces of the uploaded house font: regular, medium, bold */
21
+ export type CustomFontId = 'X400' | 'X500' | 'X700';
22
+ export type FontId = BaseFontId | CustomFontId;
23
+ /** Which face of the font pair a line uses */
24
+ export type FontRole = 'display' | 'body' | 'detail';
25
+ /** Uploaded house font: one TTF/OTF/WOFF data URL per face; missing faces fall back to the nearest uploaded one */
26
+ export interface CustomFont {
27
+ name: string;
28
+ files: Partial<Record<CustomFontId, string>>;
29
+ }
30
+ export type FormatKey = '85x55' | '90x50' | 'us' | 'a6' | 'a5' | 'a4' | 'a3' | 'a2' | 'a1' | 'a0' | 'dinlang' | 'custom';
31
+ /** Product kind: decides built-in fields, offered formats and presets, and what the QR code encodes */
32
+ export type Product = 'card' | 'flyer' | 'poster';
33
+ export type LayoutKey = 'kante' | 'linie' | 'mitte' | 'plakat' | 'leer';
34
+ export type PairKey = 'grotesk' | 'antiqua' | 'technik' | 'custom';
35
+ export type ThemeKey = 'kobalt' | 'signal' | 'tanne' | 'petrol' | 'graphit' | 'nacht';
36
+ export type Side = 'front' | 'back';
37
+ export type Bleed = 0 | 2 | 3 | 5;
38
+ export type PhoneSeg = 'cc' | 'area' | 'num' | 'ext';
39
+ export type StyleKey = 'name' | 'role' | 'company' | 'detail' | 'detailMuted' | 'label' | 'big' | 'tag' | 'tagDetail' | 'bigInk' | 'tagMuted' | 'detailAccent' | 'mono' | 'bigInv' | 'tagInv' | 'detailInv';
40
+ export interface Format {
41
+ W: number;
42
+ H: number;
43
+ label: string;
44
+ }
45
+ export interface FormatDef extends Format {
46
+ products: Product[];
47
+ }
48
+ export interface FontPair {
49
+ name: string;
50
+ display: FontId;
51
+ body: FontId;
52
+ detail: FontId;
53
+ ds: number;
54
+ dispScale?: number;
55
+ }
56
+ export interface Theme {
57
+ name: string;
58
+ bg: Cmyk;
59
+ ink: Cmyk;
60
+ muted: Cmyk;
61
+ accent: Cmyk;
62
+ onAccent: Cmyk;
63
+ bgMuted: Cmyk;
64
+ }
65
+ export interface StyleDef {
66
+ f: FontRole;
67
+ s: number;
68
+ c: ColorRole;
69
+ ls?: number;
70
+ d?: 1;
71
+ }
72
+ export interface TextStyle {
73
+ font: FontId;
74
+ size: number;
75
+ color: ColorRef;
76
+ ls: number;
77
+ }
78
+ /** Per-line override of a style: size in pt, color, face of the font pair, and the color of a prefix like "Tel." */
79
+ export interface StyleOv {
80
+ size?: number;
81
+ color?: ColorRef;
82
+ f?: FontRole;
83
+ label?: ColorRef;
84
+ }
85
+ export interface PhoneValue {
86
+ cc: string;
87
+ area: string;
88
+ num: string;
89
+ ext: string;
90
+ }
91
+ /** Uploaded raster image: PNG/JPEG data URL plus its pixel size (for fitting and print resolution) */
92
+ export interface ImageValue {
93
+ src: string;
94
+ w: number;
95
+ h: number;
96
+ }
97
+ export type FieldValue = string | PhoneValue | ImageValue;
98
+ export type CardData = Record<string, FieldValue>;
99
+ /** Where a field sits on the card. Layouts place groups, so custom fields land in their group automatically. */
100
+ export type FieldGroup = 'person' | 'address' | 'contact' | 'back' | 'content';
101
+ /** text: plain line; labeled: line with a prefix like "E-Mail"; phone: split into country/area/number/extension */
102
+ export type FieldKind = 'text' | 'labeled' | 'phone' | 'multiline' | 'image';
103
+ export type InputType = 'text' | 'email' | 'url';
104
+ /** What a custom field adds to the vCard QR code: org-unit is appended to ORG (department) */
105
+ export type VcardRole = 'org-unit' | 'url' | 'email' | 'tel' | 'note';
106
+ export interface FieldConfig {
107
+ key: string;
108
+ label: string;
109
+ kind: FieldKind;
110
+ group: FieldGroup;
111
+ /** Sort order inside the group and in the form */
112
+ order: number;
113
+ placeholder?: string;
114
+ required?: boolean;
115
+ /** Visible on the card but not editable by the customer */
116
+ locked?: boolean;
117
+ /** Neither on the card nor in the form */
118
+ hidden?: boolean;
119
+ default?: FieldValue;
120
+ /** Phone without extension (mobile numbers) */
121
+ mobile?: boolean;
122
+ /** Prefix for labeled/phone fields, per label mode */
123
+ labelText?: string;
124
+ labelShort?: string;
125
+ inputType?: InputType;
126
+ /** text/labeled fields: the customer picks one of these values instead of typing */
127
+ choices?: string[];
128
+ autocomplete?: string;
129
+ /** Custom fields only: role in the vCard QR code; without it the field is not in the vCard */
130
+ vcard?: VcardRole;
131
+ }
132
+ /** Partial field definition; unknown keys create new custom fields (label is then required). */
133
+ export type FieldOverride = Partial<FieldConfig> & {
134
+ key: string;
135
+ };
136
+ /**
137
+ * hasText: the SVG contains <text>, which the PDF prints in a standard font; px: pixel size of PNG/JPEG logos (for the print resolution).
138
+ * kind 'pdf': data is a data:application/pdf URL whose first page is placed as vector (spot colors kept), `box` is the
139
+ * placed area of that page in mm (TrimBox, else CropBox), `preview` a transparent PNG of it for the screen, `spots` the
140
+ * spot color names it uses (so the editor can check that the accent's spot color is named the same).
141
+ */
142
+ export interface Logo {
143
+ kind: 'svg' | 'png' | 'jpeg' | 'pdf';
144
+ data: string;
145
+ ar: number;
146
+ hasText?: boolean;
147
+ px?: {
148
+ w: number;
149
+ h: number;
150
+ };
151
+ name?: string;
152
+ box?: PageBox;
153
+ preview?: ImageValue;
154
+ spots?: string[];
155
+ }
156
+ export interface Template {
157
+ v: 1;
158
+ product: Product;
159
+ layout: LayoutKey;
160
+ fonts: PairKey;
161
+ theme: ThemeKey | 'custom';
162
+ /**
163
+ * The template's own colors, set in the template editor. With this list the scheme (`theme`, `accent…`) is no longer
164
+ * used: elements refer to these colors as `p:<id>`.
165
+ */
166
+ colors?: PaletteColor[];
167
+ /** Uploaded house font, used when `fonts` is 'custom' */
168
+ font?: CustomFont;
169
+ /** Accent of the 'custom' scheme */
170
+ accent: Cmyk;
171
+ /** Optional spot color name of the accent (e.g. HKS 43 K); a note for the print shop, and the plate name with accentSpot */
172
+ accentName: string;
173
+ /** Print the accent as a spot color (own plate named accentName, CMYK as the alternate); only with theme 'custom' and a name */
174
+ accentSpot?: boolean;
175
+ /** The spot color overprints what lies underneath instead of knocking it out */
176
+ accentOverprint?: boolean;
177
+ phone: 'intl' | 'nat';
178
+ labels: 'text' | 'short' | 'none';
179
+ qr: boolean;
180
+ format: FormatKey;
181
+ /** Trim size in mm when format is 'custom' */
182
+ size: {
183
+ W: number;
184
+ H: number;
185
+ };
186
+ orientation: 'portrait' | 'landscape';
187
+ /** Printed sides: 1 (front only) or 2 */
188
+ sides: 1 | 2;
189
+ /** Bleed in mm (0 = none) */
190
+ bleed: Bleed;
191
+ marks: boolean;
192
+ outline: boolean;
193
+ guides: boolean;
194
+ logo: Logo | null;
195
+ locked: string[];
196
+ defaults: CardData;
197
+ fields?: FieldOverride[];
198
+ /** Own layout from the template editor; replaces the preset named in `layout` when set */
199
+ design?: CardDesign;
200
+ /** Images used by the design, kept apart so dragging does not copy them */
201
+ images?: Record<string, ImageValue>;
202
+ /** PDF page(s) printed underneath everything (vector in the PDF, preview image on screen) */
203
+ background?: PdfBackground;
204
+ }
205
+ /** Page geometry of a background PDF page in mm, PDF coordinates (origin bottom-left of the media box) */
206
+ export interface PageBox {
207
+ x: number;
208
+ y: number;
209
+ w: number;
210
+ h: number;
211
+ }
212
+ export interface BackgroundPage {
213
+ /** 0-based page index in the PDF */
214
+ page: number;
215
+ media: PageBox;
216
+ /** TrimBox if the PDF has one */
217
+ trim?: PageBox;
218
+ /** BleedBox if the PDF has one */
219
+ bleed?: PageBox;
220
+ /** Rendered media box for the screen */
221
+ preview: ImageValue;
222
+ }
223
+ export interface PdfBackground {
224
+ src: string;
225
+ name?: string;
226
+ pages: number;
227
+ front?: BackgroundPage;
228
+ back?: BackgroundPage;
229
+ }
230
+ export type ArtItem = {
231
+ t: 'rect';
232
+ x: number;
233
+ y: number;
234
+ w: number;
235
+ h: number;
236
+ c: ColorRef;
237
+ } | {
238
+ t: 'circle';
239
+ cx: number;
240
+ cy: number;
241
+ r: number;
242
+ c: ColorRef;
243
+ } | {
244
+ t: 'line';
245
+ x1: number;
246
+ y1: number;
247
+ x2: number;
248
+ y2: number;
249
+ w: number;
250
+ c: ColorRef;
251
+ } | {
252
+ t: 'logo';
253
+ x: number;
254
+ y: number;
255
+ w: number;
256
+ h: number;
257
+ align: 'left' | 'right' | 'center';
258
+ }
259
+ /** QR code: vCard of the business card fields, or the text of the field named in `src`; `c` (or the legacy `accent`) colors the modules when dark enough */
260
+ | {
261
+ t: 'qr';
262
+ x: number;
263
+ y: number;
264
+ size: number;
265
+ src?: string;
266
+ accent?: boolean;
267
+ c?: ColorRef;
268
+ }
269
+ /** Image box: a template image (`img`, key into template.images) or a customer photo (`field`); cover fills and crops, contain fits */
270
+ | {
271
+ t: 'image';
272
+ x: number;
273
+ y: number;
274
+ w: number;
275
+ h: number;
276
+ fit: 'cover' | 'contain';
277
+ img?: string;
278
+ field?: string;
279
+ };
280
+ /** A stack line: an explicit field, all fields of a group, or computed text */
281
+ export type LineSrc = ({
282
+ k: string;
283
+ style: StyleKey;
284
+ dy?: number;
285
+ plain?: boolean;
286
+ } & StyleOv) | ({
287
+ g: FieldGroup;
288
+ style: StyleKey;
289
+ dy?: number;
290
+ } & StyleOv) | ({
291
+ fn: 'initials';
292
+ style: StyleKey;
293
+ } & StyleOv);
294
+ export interface StackDef {
295
+ x: number;
296
+ y: number;
297
+ anchor: 'top' | 'bottom' | 'middle';
298
+ align: 'left' | 'right' | 'center';
299
+ lh: number;
300
+ maxW: number;
301
+ lines: LineSrc[];
302
+ }
303
+ export interface SideLayout {
304
+ art: ArtItem[];
305
+ stacks: StackDef[];
306
+ }
307
+ /** A layout stored as data (mm, for the template's format). Logo and QR items are skipped when the template has none. */
308
+ export interface CardDesign {
309
+ front: SideLayout;
310
+ back: SideLayout;
311
+ }
312
+ export interface LayoutCtx {
313
+ W: number;
314
+ H: number;
315
+ qr: boolean;
316
+ logo: {
317
+ ar: number;
318
+ } | null;
319
+ d: CardData;
320
+ /** True if at least one field of the given keys/groups will print */
321
+ filledCount(srcs: LineSrc[]): number;
322
+ capH(style: StyleKey): number;
323
+ }
324
+ export interface LayoutDef {
325
+ name: string;
326
+ products: Product[];
327
+ front(c: LayoutCtx): SideLayout;
328
+ back(c: LayoutCtx): SideLayout;
329
+ }
330
+ /** Resolved line spec after expanding groups */
331
+ export type LineSpec = {
332
+ type: 'text' | 'lab';
333
+ key: string;
334
+ style: StyleKey;
335
+ dy?: number;
336
+ ov?: StyleOv;
337
+ } | {
338
+ type: 'phone';
339
+ key: string;
340
+ style: StyleKey;
341
+ dy?: number;
342
+ ov?: StyleOv;
343
+ } | {
344
+ type: 'static';
345
+ fn: 'initials';
346
+ style: StyleKey;
347
+ dy?: number;
348
+ ov?: StyleOv;
349
+ };
350
+ export interface EditRef {
351
+ key: string;
352
+ seg?: PhoneSeg;
353
+ }
354
+ export interface Run {
355
+ text: string;
356
+ ph?: string;
357
+ style: StyleKey;
358
+ ed?: EditRef;
359
+ ov?: StyleOv;
360
+ }
361
+ export interface Placed {
362
+ id: string;
363
+ text: string;
364
+ ph?: string;
365
+ ed?: EditRef;
366
+ st: TextStyle;
367
+ x: number;
368
+ y: number;
369
+ over?: boolean;
370
+ /** Part of a wrapped paragraph: edited in the form, not directly on the card */
371
+ multi?: boolean;
372
+ /** Index of the stack the run belongs to */
373
+ si: number;
374
+ }
375
+ export interface FitIssue {
376
+ side: Side;
377
+ key: string;
378
+ k: number;
379
+ over: boolean;
380
+ }
381
+ /** error blocks the PDF (missing required field, text that does not fit, invalid format); warn and info are shown only */
382
+ export interface Issue {
383
+ level: 'error' | 'warn' | 'info';
384
+ text: string;
385
+ key?: string;
386
+ }
387
+ /** Context for drawing a card into the DOM */
388
+ export interface CardCtx {
389
+ d: CardData;
390
+ print: boolean;
391
+ /** px per mm */
392
+ S: number;
393
+ /** bleed in mm */
394
+ b: number;
395
+ guides: boolean;
396
+ /** contenteditable text on the card */
397
+ inline: boolean;
398
+ omitLocked: boolean;
399
+ active?: string;
400
+ /** Show empty image boxes as placeholders (default: when not in print view) */
401
+ imgGhost?: boolean;
402
+ editable(key: string): boolean;
403
+ }
@@ -0,0 +1,48 @@
1
+ import { CardData, CustomFont, ImageValue, Issue, PdfBackground } from './card.types';
2
+ /** Result of validate() and detail of pkValidity: valid means no issue of level error; confirmed is the „Daten geprüft“ tick (always true without the confirm prop) */
3
+ export interface Validity {
4
+ valid: boolean;
5
+ issues: Issue[];
6
+ confirmed: boolean;
7
+ }
8
+ export interface PdfDetail {
9
+ blob: Blob;
10
+ filename: string;
11
+ data: CardData;
12
+ }
13
+ export interface StatusMsg {
14
+ text: string;
15
+ level: '' | 'ok' | 'err';
16
+ }
17
+ /** Selected element in the template editor (index into the side's stacks or art list) */
18
+ export type Selection = {
19
+ kind: 'stack';
20
+ i: number;
21
+ } | {
22
+ kind: 'art';
23
+ i: number;
24
+ };
25
+ /** Tabs in working order: set up the template, arrange elements, configure fields */
26
+ export type EditorTab = 'design' | 'element' | 'fields';
27
+ /** How several selected elements are aligned: to the common left/center/right or top/middle/bottom */
28
+ export type AlignHow = 'left' | 'hcenter' | 'right' | 'top' | 'vcenter' | 'bottom';
29
+ /** Box in mm used for hit areas in the template editor */
30
+ export interface Box {
31
+ x: number;
32
+ y: number;
33
+ w: number;
34
+ h: number;
35
+ }
36
+ /** Resize handle: box corners/edges, circle radius, line end points, text block max width */
37
+ export type Handle = 'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w' | 'r' | 'p1' | 'p2' | 'maxw';
38
+ /** Undo step of the template editor: JSON of the light parts, heavy parts by reference */
39
+ export interface Snapshot {
40
+ json: string;
41
+ images?: Record<string, ImageValue>;
42
+ background?: PdfBackground;
43
+ font?: CustomFont;
44
+ }
45
+ /** Data the template editor previews with: sample values, what a customer starts with, or long values */
46
+ export type PreviewMode = 'sample' | 'customer' | 'stress';
47
+ /** Kind offered when creating a custom field; sets kind, prefix, input check and vCard role together */
48
+ export type NewFieldKind = 'text' | 'labeled' | 'email' | 'url' | 'phone' | 'multiline' | 'image';