@unmade/text-renderer 1.0.0 → 1.1.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 (67) hide show
  1. package/dist/__vite-browser-external-CijFC1_R.js +7 -0
  2. package/dist/baselines/index.d.ts +40 -0
  3. package/dist/ce-adapter/index.cjs +1 -1
  4. package/dist/ce-adapter/index.js +154 -152
  5. package/dist/chunk-3b4jIN3o.js +13 -0
  6. package/dist/constants.d.ts +5 -0
  7. package/dist/glyph/svg-glyph-converter.d.ts +42 -0
  8. package/dist/helpers/bbox.d.ts +33 -0
  9. package/dist/helpers/matrix.d.ts +8 -0
  10. package/dist/helpers/point.d.ts +17 -0
  11. package/dist/helpers/xml.d.ts +1 -0
  12. package/dist/index.d.ts +16 -249
  13. package/dist/index.js +1543 -1954
  14. package/dist/loading/createLoadedFont.d.ts +53 -0
  15. package/dist/loading/index.d.ts +4 -0
  16. package/dist/measuring/conversion.d.ts +2 -0
  17. package/dist/measuring/index.d.ts +28 -0
  18. package/dist/node/baselines/index.d.ts +40 -0
  19. package/dist/node/ce-adapter/ce-types.d.ts +171 -0
  20. package/dist/node/ce-adapter/extractTextPlacements.d.ts +11 -0
  21. package/dist/node/ce-adapter/index.d.ts +12 -0
  22. package/dist/node/ce-adapter/mapStateToRendererOptions.d.ts +13 -0
  23. package/dist/node/ce-adapter/types.d.ts +56 -0
  24. package/dist/node/constants.d.ts +5 -0
  25. package/dist/node/glyph/svg-glyph-converter.d.ts +42 -0
  26. package/dist/node/helpers/bbox.d.ts +33 -0
  27. package/dist/node/helpers/matrix.d.ts +8 -0
  28. package/dist/node/helpers/point.d.ts +17 -0
  29. package/dist/node/helpers/xml.d.ts +1 -0
  30. package/dist/node/index.d.ts +16 -249
  31. package/dist/node/index.js +821 -895
  32. package/dist/node/loading/createLoadedFont.d.ts +53 -0
  33. package/dist/node/loading/index.d.ts +4 -0
  34. package/dist/node/measuring/conversion.d.ts +2 -0
  35. package/dist/node/measuring/index.d.ts +28 -0
  36. package/dist/node/renderText.d.ts +5 -0
  37. package/dist/node/rendering/index.d.ts +42 -0
  38. package/dist/node/svg/index.d.ts +11 -0
  39. package/dist/node/types.d.ts +72 -0
  40. package/dist/renderText.d.ts +5 -0
  41. package/dist/rendering/index.d.ts +42 -0
  42. package/dist/svg/index.d.ts +11 -0
  43. package/dist/types.d.ts +72 -0
  44. package/dist/worker/baselines/index.d.ts +40 -0
  45. package/dist/worker/ce-adapter/ce-types.d.ts +171 -0
  46. package/dist/worker/ce-adapter/extractTextPlacements.d.ts +11 -0
  47. package/dist/worker/ce-adapter/index.d.ts +12 -0
  48. package/dist/worker/ce-adapter/mapStateToRendererOptions.d.ts +13 -0
  49. package/dist/worker/ce-adapter/types.d.ts +56 -0
  50. package/dist/worker/constants.d.ts +5 -0
  51. package/dist/worker/glyph/svg-glyph-converter.d.ts +42 -0
  52. package/dist/worker/helpers/bbox.d.ts +33 -0
  53. package/dist/worker/helpers/matrix.d.ts +8 -0
  54. package/dist/worker/helpers/point.d.ts +17 -0
  55. package/dist/worker/helpers/xml.d.ts +1 -0
  56. package/dist/worker/index.d.ts +16 -249
  57. package/dist/worker/index.js +8003 -9677
  58. package/dist/worker/loading/createLoadedFont.d.ts +53 -0
  59. package/dist/worker/loading/index.d.ts +4 -0
  60. package/dist/worker/measuring/conversion.d.ts +2 -0
  61. package/dist/worker/measuring/index.d.ts +28 -0
  62. package/dist/worker/renderText.d.ts +5 -0
  63. package/dist/worker/rendering/index.d.ts +42 -0
  64. package/dist/worker/svg/index.d.ts +11 -0
  65. package/dist/worker/types.d.ts +72 -0
  66. package/package.json +11 -10
  67. package/dist/__vite-browser-external-l0sNRNKZ.js +0 -1
@@ -0,0 +1,53 @@
1
+ import { Face, Font } from 'harfbuzzjs';
2
+ export interface SVGGlyphData {
3
+ svg: string;
4
+ viewbox: string;
5
+ }
6
+ export interface LoadedFont {
7
+ unitsPerEm: number;
8
+ names: {
9
+ fontFamily: string;
10
+ };
11
+ svgGlyphs?: Map<number, SVGGlyphData>;
12
+ charToGlyph(char: string): {
13
+ index: number;
14
+ advanceWidth: number;
15
+ name: string;
16
+ getBoundingBox(): {
17
+ x1: number;
18
+ y1: number;
19
+ x2: number;
20
+ y2: number;
21
+ };
22
+ };
23
+ getPath(text: string, x: number, y: number, fontSize: number, options?: {
24
+ drawSVG?: boolean;
25
+ }): {
26
+ getBoundingBox(): {
27
+ x1: number;
28
+ y1: number;
29
+ x2: number;
30
+ y2: number;
31
+ };
32
+ toPathData(decimals?: number): string;
33
+ };
34
+ getPaths(text: string, x: number, y: number, fontSize: number, options?: {
35
+ drawSVG?: boolean;
36
+ }): Array<{
37
+ getBoundingBox(): {
38
+ x1: number;
39
+ y1: number;
40
+ x2: number;
41
+ y2: number;
42
+ };
43
+ toPathData(decimals?: number): string;
44
+ }>;
45
+ }
46
+ export declare function boundsFromPath(pathData: string): {
47
+ x1: number;
48
+ y1: number;
49
+ x2: number;
50
+ y2: number;
51
+ } | null;
52
+ export declare function transformPath(pathData: string, scaleX: number, scaleY: number, dx: number): string;
53
+ export declare function createLoadedFont(face: Face, font: Font, familyName: string, svgGlyphs?: Map<number, SVGGlyphData>): LoadedFont;
@@ -0,0 +1,4 @@
1
+ import { createLoadedFont, LoadedFont } from './createLoadedFont';
2
+ export { createLoadedFont, type LoadedFont };
3
+ export declare const getFontCache: () => Map<string, LoadedFont>;
4
+ export declare const loadFont: (fontUrl: string, fetchSVGGlyphs?: boolean) => Promise<LoadedFont>;
@@ -0,0 +1,2 @@
1
+ export declare function millimetersToInches(value: number): number;
2
+ export declare function inchesToMillimeters(value: number): number;
@@ -0,0 +1,28 @@
1
+ import { LoadedFont } from '../loading';
2
+ import { BoxDimensions, PhysicalSize, TextSpacing } from '../types';
3
+ export interface GetFontSizeFromPhysicalSizeOptions {
4
+ font: LoadedFont;
5
+ boxDimensions: BoxDimensions;
6
+ physicalSize: PhysicalSize;
7
+ spacing?: TextSpacing;
8
+ }
9
+ export interface GetTextMetricsAtFontSizeOptions {
10
+ font: LoadedFont;
11
+ text: string;
12
+ fontSize: number;
13
+ spacing?: TextSpacing;
14
+ }
15
+ /**
16
+ * This is the character we use to calculate font sizes
17
+ * when fixed physical text height is set for a placement.
18
+ *
19
+ * The 'I' character is used because of its flat top and bottom.
20
+ * https://en.wikipedia.org/wiki/Cap_height
21
+ */
22
+ export declare const getStandardCharacter: (font: LoadedFont) => string;
23
+ export declare const getFontSizeFromPhysicalSize: ({ font, boxDimensions, physicalSize, spacing, }: GetFontSizeFromPhysicalSizeOptions) => number;
24
+ export declare const getTextMetricsAtFontSize: ({ font, text, fontSize, spacing, }: GetTextMetricsAtFontSizeOptions) => {
25
+ width: number;
26
+ height: number;
27
+ baseline: number;
28
+ };
@@ -0,0 +1,5 @@
1
+ import { RenderTextOptions } from './types';
2
+ /**
3
+ * Synchronous text renderer. Requires a pre-loaded font.
4
+ */
5
+ export declare const renderText: (options: RenderTextOptions) => string;
@@ -0,0 +1,42 @@
1
+ import { LoadedFont } from '../loading';
2
+ import { ColourMap, GlyphFill, HorizontalTextAlignmentValues, TextSpacing } from '../types';
3
+ export interface SvgGlyphEntry {
4
+ content: string;
5
+ viewBox: string;
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ glyphIndex: number;
11
+ }
12
+ export interface PathEntry {
13
+ attributes: {
14
+ d: string;
15
+ 'data-character': string;
16
+ transform: string;
17
+ };
18
+ path: unknown;
19
+ matrix: DOMMatrix;
20
+ glyphData: {
21
+ index: number;
22
+ bbox: {
23
+ x1: number;
24
+ y1: number;
25
+ x2: number;
26
+ y2: number;
27
+ };
28
+ };
29
+ svgGlyph?: SvgGlyphEntry;
30
+ fills?: GlyphFill[];
31
+ }
32
+ export declare const fontUnitsToPixels: (value: number, fontSize: number, unitsPerEm: number) => number;
33
+ export interface GetTextAsPathDataOptions {
34
+ font: LoadedFont;
35
+ baselinePath: string;
36
+ text: string;
37
+ fontSize: number;
38
+ spacing?: TextSpacing;
39
+ horizontalAlignment?: HorizontalTextAlignmentValues;
40
+ colourMap?: ColourMap;
41
+ }
42
+ export declare const getTextAsPathData: ({ font, baselinePath, text, fontSize, spacing, horizontalAlignment, colourMap, }: GetTextAsPathDataOptions) => PathEntry[];
@@ -0,0 +1,11 @@
1
+ import { PathEntry } from '../rendering';
2
+ import { BoxDimensions, ColourInfo, TextSpacing } from '../types';
3
+ export interface AssembleSvgOptions {
4
+ boxDimensions: BoxDimensions;
5
+ paths: PathEntry[];
6
+ spacing?: TextSpacing;
7
+ fontSize?: number;
8
+ fillColour?: ColourInfo;
9
+ strokeColour?: ColourInfo;
10
+ }
11
+ export declare const assembleSvg: ({ boxDimensions, paths, spacing, fontSize, fillColour, strokeColour, }: AssembleSvgOptions) => string;
@@ -0,0 +1,72 @@
1
+ import { LoadedFont } from './loading';
2
+ export type MeasurementUnits = 'mm' | 'in';
3
+ export type BoxDimensions = {
4
+ width: number;
5
+ height: number;
6
+ physicalWidth: number;
7
+ physicalHeight: number;
8
+ physicalUnits: MeasurementUnits;
9
+ };
10
+ export type VerticalTextAlignmentValues = 'centre' | 'top' | 'bottom';
11
+ export type HorizontalTextAlignmentValues = 'left' | 'centre' | 'right' | 'distributed';
12
+ export type PhysicalSize = [height: number, units: MeasurementUnits];
13
+ export type BaselineType = 'flat' | 'curved';
14
+ export type BaselineConfig = {
15
+ type: 'flat';
16
+ } | {
17
+ type: 'curved';
18
+ } | {
19
+ type: 'custom';
20
+ path: string;
21
+ };
22
+ export interface ColourInfo {
23
+ readonly hex: string;
24
+ readonly reference?: string;
25
+ }
26
+ export interface GlyphFill {
27
+ readonly pathData: string;
28
+ readonly colour: ColourInfo;
29
+ }
30
+ /** Maps original hex colour → replacement ColourInfo. */
31
+ export type ColourMap = Readonly<Record<string, ColourInfo>>;
32
+ export interface TextSpacing {
33
+ readonly outlineWidth: number;
34
+ readonly letterSpacing: number;
35
+ readonly letterSpacingOutline: number;
36
+ }
37
+ /** Options for synchronous renderText (font already loaded). */
38
+ export interface RenderTextOptions {
39
+ text: string;
40
+ font: LoadedFont;
41
+ physicalSize: PhysicalSize;
42
+ /** When provided, bypasses the physicalSize → font size calculation. */
43
+ fontSize?: number;
44
+ boxDimensions: BoxDimensions;
45
+ spacing?: TextSpacing;
46
+ verticalAlignment?: VerticalTextAlignmentValues;
47
+ baseline?: BaselineType | BaselineConfig;
48
+ horizontalAlignment?: HorizontalTextAlignmentValues;
49
+ fillColour?: ColourInfo;
50
+ strokeColour?: ColourInfo;
51
+ colourMap?: ColourMap;
52
+ }
53
+ /** Options for async getRenderedText (loads font from URL). */
54
+ export interface GetRenderedTextOptions {
55
+ text: string;
56
+ fontUrl: string;
57
+ physicalSize: PhysicalSize;
58
+ /**
59
+ * Fallback font size (in pixels) to use if the calculated size causes a
60
+ * TOO_WIDE error. Useful when the caller has an authoritative size (e.g.
61
+ * from the CE) that avoids floating-point rounding issues.
62
+ */
63
+ fontSizeFallback?: number;
64
+ boxDimensions: BoxDimensions;
65
+ spacing?: TextSpacing;
66
+ verticalAlignment?: VerticalTextAlignmentValues;
67
+ baseline?: BaselineType | BaselineConfig;
68
+ horizontalAlignment?: HorizontalTextAlignmentValues;
69
+ fillColour?: ColourInfo;
70
+ strokeColour?: ColourInfo;
71
+ colourMap?: ColourMap;
72
+ }
@@ -0,0 +1,5 @@
1
+ import { RenderTextOptions } from './types';
2
+ /**
3
+ * Synchronous text renderer. Requires a pre-loaded font.
4
+ */
5
+ export declare const renderText: (options: RenderTextOptions) => string;
@@ -0,0 +1,42 @@
1
+ import { LoadedFont } from '../loading';
2
+ import { ColourMap, GlyphFill, HorizontalTextAlignmentValues, TextSpacing } from '../types';
3
+ export interface SvgGlyphEntry {
4
+ content: string;
5
+ viewBox: string;
6
+ x: number;
7
+ y: number;
8
+ width: number;
9
+ height: number;
10
+ glyphIndex: number;
11
+ }
12
+ export interface PathEntry {
13
+ attributes: {
14
+ d: string;
15
+ 'data-character': string;
16
+ transform: string;
17
+ };
18
+ path: unknown;
19
+ matrix: DOMMatrix;
20
+ glyphData: {
21
+ index: number;
22
+ bbox: {
23
+ x1: number;
24
+ y1: number;
25
+ x2: number;
26
+ y2: number;
27
+ };
28
+ };
29
+ svgGlyph?: SvgGlyphEntry;
30
+ fills?: GlyphFill[];
31
+ }
32
+ export declare const fontUnitsToPixels: (value: number, fontSize: number, unitsPerEm: number) => number;
33
+ export interface GetTextAsPathDataOptions {
34
+ font: LoadedFont;
35
+ baselinePath: string;
36
+ text: string;
37
+ fontSize: number;
38
+ spacing?: TextSpacing;
39
+ horizontalAlignment?: HorizontalTextAlignmentValues;
40
+ colourMap?: ColourMap;
41
+ }
42
+ export declare const getTextAsPathData: ({ font, baselinePath, text, fontSize, spacing, horizontalAlignment, colourMap, }: GetTextAsPathDataOptions) => PathEntry[];
@@ -0,0 +1,11 @@
1
+ import { PathEntry } from '../rendering';
2
+ import { BoxDimensions, ColourInfo, TextSpacing } from '../types';
3
+ export interface AssembleSvgOptions {
4
+ boxDimensions: BoxDimensions;
5
+ paths: PathEntry[];
6
+ spacing?: TextSpacing;
7
+ fontSize?: number;
8
+ fillColour?: ColourInfo;
9
+ strokeColour?: ColourInfo;
10
+ }
11
+ export declare const assembleSvg: ({ boxDimensions, paths, spacing, fontSize, fillColour, strokeColour, }: AssembleSvgOptions) => string;
@@ -0,0 +1,72 @@
1
+ import { LoadedFont } from './loading';
2
+ export type MeasurementUnits = 'mm' | 'in';
3
+ export type BoxDimensions = {
4
+ width: number;
5
+ height: number;
6
+ physicalWidth: number;
7
+ physicalHeight: number;
8
+ physicalUnits: MeasurementUnits;
9
+ };
10
+ export type VerticalTextAlignmentValues = 'centre' | 'top' | 'bottom';
11
+ export type HorizontalTextAlignmentValues = 'left' | 'centre' | 'right' | 'distributed';
12
+ export type PhysicalSize = [height: number, units: MeasurementUnits];
13
+ export type BaselineType = 'flat' | 'curved';
14
+ export type BaselineConfig = {
15
+ type: 'flat';
16
+ } | {
17
+ type: 'curved';
18
+ } | {
19
+ type: 'custom';
20
+ path: string;
21
+ };
22
+ export interface ColourInfo {
23
+ readonly hex: string;
24
+ readonly reference?: string;
25
+ }
26
+ export interface GlyphFill {
27
+ readonly pathData: string;
28
+ readonly colour: ColourInfo;
29
+ }
30
+ /** Maps original hex colour → replacement ColourInfo. */
31
+ export type ColourMap = Readonly<Record<string, ColourInfo>>;
32
+ export interface TextSpacing {
33
+ readonly outlineWidth: number;
34
+ readonly letterSpacing: number;
35
+ readonly letterSpacingOutline: number;
36
+ }
37
+ /** Options for synchronous renderText (font already loaded). */
38
+ export interface RenderTextOptions {
39
+ text: string;
40
+ font: LoadedFont;
41
+ physicalSize: PhysicalSize;
42
+ /** When provided, bypasses the physicalSize → font size calculation. */
43
+ fontSize?: number;
44
+ boxDimensions: BoxDimensions;
45
+ spacing?: TextSpacing;
46
+ verticalAlignment?: VerticalTextAlignmentValues;
47
+ baseline?: BaselineType | BaselineConfig;
48
+ horizontalAlignment?: HorizontalTextAlignmentValues;
49
+ fillColour?: ColourInfo;
50
+ strokeColour?: ColourInfo;
51
+ colourMap?: ColourMap;
52
+ }
53
+ /** Options for async getRenderedText (loads font from URL). */
54
+ export interface GetRenderedTextOptions {
55
+ text: string;
56
+ fontUrl: string;
57
+ physicalSize: PhysicalSize;
58
+ /**
59
+ * Fallback font size (in pixels) to use if the calculated size causes a
60
+ * TOO_WIDE error. Useful when the caller has an authoritative size (e.g.
61
+ * from the CE) that avoids floating-point rounding issues.
62
+ */
63
+ fontSizeFallback?: number;
64
+ boxDimensions: BoxDimensions;
65
+ spacing?: TextSpacing;
66
+ verticalAlignment?: VerticalTextAlignmentValues;
67
+ baseline?: BaselineType | BaselineConfig;
68
+ horizontalAlignment?: HorizontalTextAlignmentValues;
69
+ fillColour?: ColourInfo;
70
+ strokeColour?: ColourInfo;
71
+ colourMap?: ColourMap;
72
+ }
@@ -0,0 +1,40 @@
1
+ import { BaselineConfig, BaselineType, BoxDimensions, VerticalTextAlignmentValues } from '../types';
2
+ /**
3
+ * Normalise a baseline option (string shorthand or object) into a BaselineConfig.
4
+ */
5
+ export declare const normaliseBaselineOption: (baseline: BaselineType | BaselineConfig | undefined) => BaselineConfig;
6
+ /**
7
+ * Validate a custom baseline SVG path string.
8
+ */
9
+ export declare const validateCustomBaselinePath: (path: string) => void;
10
+ export interface GenerateFlatBaselineOptions {
11
+ boxDimensions: BoxDimensions;
12
+ totalTextHeight: number;
13
+ baseline: number;
14
+ lineHeight: number;
15
+ verticalAlignment?: VerticalTextAlignmentValues;
16
+ lineNumber?: number;
17
+ }
18
+ /**
19
+ * Generate a path as a baseline for straight text
20
+ * This can be called multiple times for multiline text by incrementing the lineNumber parameter
21
+ *
22
+ * @returns an SVG path command to draw the baseline
23
+ */
24
+ export declare const generateFlatBaseline: ({ boxDimensions, totalTextHeight, baseline, lineHeight, verticalAlignment, lineNumber, }: GenerateFlatBaselineOptions) => string;
25
+ export interface GenerateCurvedBaselineOptions {
26
+ boxDimensions: BoxDimensions;
27
+ baseline: number;
28
+ textHeight: number;
29
+ verticalAlignment: VerticalTextAlignmentValues;
30
+ }
31
+ /**
32
+ * Generate a path command to curve text and align that text to the top of the box.
33
+ * Uses two quadratic bezier curves — one from the bottom left to the peak, and a
34
+ * second mirrored from the peak to the end.
35
+ *
36
+ * Curved text is not currently supported for multiline text.
37
+ *
38
+ * @returns an SVG path command to draw the curve
39
+ */
40
+ export declare const generateCurvedBaseline: ({ boxDimensions, baseline, textHeight, verticalAlignment, }: GenerateCurvedBaselineOptions) => string;
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Type declarations for @unmade/configuration-engine
3
+ *
4
+ * CE doesn't ship .d.ts files. These types cover the subset of the
5
+ * factory API and editor shape that the CE adapter needs.
6
+ */
7
+ export interface EditorPaletteColour {
8
+ id: number;
9
+ hex: string;
10
+ name: string;
11
+ display_name?: string;
12
+ reference?: string | null;
13
+ extra?: object | null;
14
+ categories?: string[];
15
+ lab?: [number, number, number];
16
+ }
17
+ export interface EditorPalette {
18
+ id: number;
19
+ name: string;
20
+ slug: string;
21
+ colours: EditorPaletteColour[];
22
+ extended_palette_id?: number;
23
+ extendedPalette?: EditorPalette;
24
+ categories?: string[];
25
+ }
26
+ export interface EditorGarment {
27
+ slug: string;
28
+ size: string;
29
+ name?: string;
30
+ panels_svg?: string;
31
+ embellishment_positions?: EmbellishmentPosition[];
32
+ }
33
+ export interface EmbellishmentPosition {
34
+ placement: string;
35
+ width: number;
36
+ height: number;
37
+ physical_width?: number;
38
+ physical_height?: number;
39
+ physical_width_decimal: number;
40
+ physical_height_decimal: number;
41
+ physical_size_units: string;
42
+ baseline_path?: string;
43
+ rotation: number;
44
+ variant?: string;
45
+ }
46
+ export interface TextLibraryItemFont {
47
+ id: number;
48
+ font_url: string;
49
+ font_family: string;
50
+ letter_spacing?: number;
51
+ letter_spacing_outline?: number;
52
+ outline_width?: number;
53
+ fixed_colours?: Record<string, {
54
+ reference: string;
55
+ hex: string;
56
+ id: string;
57
+ text: string;
58
+ }>;
59
+ }
60
+ export interface TextLibraryItem {
61
+ id: string;
62
+ type: 'text';
63
+ fonts: TextLibraryItemFont[];
64
+ palette?: number;
65
+ }
66
+ export interface PlacementLibraryItem {
67
+ id: string;
68
+ type: string;
69
+ palette?: number;
70
+ }
71
+ export interface BasePlacementSettings {
72
+ manufacturing_methods?: {
73
+ name: string;
74
+ }[];
75
+ vertical_alignment?: string;
76
+ horizontal_alignment?: string;
77
+ }
78
+ export interface PlacementsSettings {
79
+ byId: Record<string, BasePlacementSettings>;
80
+ library: Record<string, PlacementLibraryItem | TextLibraryItem>;
81
+ }
82
+ export interface CombinedEditorSettings {
83
+ editor: string;
84
+ mixins: string[];
85
+ garments: EditorGarment[];
86
+ palettes: number[];
87
+ allPalettes: Record<number, EditorPalette>;
88
+ endpoints: {
89
+ palettes: string;
90
+ [key: string]: string | undefined;
91
+ };
92
+ placements?: PlacementsSettings;
93
+ embellishments?: PlacementsSettings;
94
+ [key: string]: unknown;
95
+ }
96
+ export interface BasePlacementState {
97
+ type: string;
98
+ libraryItemID: string;
99
+ meta?: Record<string, unknown>;
100
+ }
101
+ export interface EditorStateVals {
102
+ placements?: Record<string, BasePlacementState>;
103
+ embellishments?: Record<string, BasePlacementState>;
104
+ [key: string]: unknown;
105
+ }
106
+ export interface EditorState {
107
+ garment?: string;
108
+ vals?: EditorStateVals;
109
+ [key: string]: unknown;
110
+ }
111
+ export interface Palettes {
112
+ byId: Record<string, unknown>;
113
+ getColours(paletteId: number): EditorPaletteColour[];
114
+ getUsedColours(paletteId: number, ids: (number | null)[]): (EditorPaletteColour | null)[];
115
+ getExtendedColours(paletteId: number): EditorPaletteColour[];
116
+ }
117
+ export interface PlacementPositionResult {
118
+ placement: string;
119
+ x: number;
120
+ y: number;
121
+ width: number;
122
+ height: number;
123
+ dimensionsForCanvas: {
124
+ width: number;
125
+ height: number;
126
+ x: number;
127
+ y: number;
128
+ };
129
+ variant: string;
130
+ panel: string;
131
+ rotation: boolean;
132
+ physical_width: number;
133
+ physical_height: number;
134
+ physical_width_decimal: string;
135
+ physical_height_decimal: string;
136
+ physical_size_units: string;
137
+ }
138
+ export interface EditorVariant {
139
+ name: string;
140
+ placements: string[];
141
+ }
142
+ /**
143
+ * Editor instance returned by CE's factory.
144
+ *
145
+ * The exact shape depends on which mixins are applied at runtime.
146
+ * We type the parts the CE adapter needs and treat the rest as opaque.
147
+ * Uses Element rather than SVGElement for cross-environment compatibility.
148
+ */
149
+ export interface ConfigEditor {
150
+ getState(): EditorState & {
151
+ vals: NonNullable<EditorState['vals']>;
152
+ };
153
+ palettes: Palettes;
154
+ settings: CombinedEditorSettings;
155
+ placements?: {
156
+ initialise(): Promise<void>;
157
+ getAssetsAsSVGElements(state: EditorState, manufacturingMethod: string): Promise<Record<string, {
158
+ asset: Element;
159
+ position: PlacementPositionResult;
160
+ }>>;
161
+ };
162
+ embellishments?: {
163
+ initialise(): Promise<void>;
164
+ getAssetsAsSVGElements(state: EditorState, manufacturingMethod: string): Promise<Record<string, {
165
+ asset: Element;
166
+ position: PlacementPositionResult;
167
+ }>>;
168
+ };
169
+ getVariants?(): EditorVariant[];
170
+ getCurrentVariant?(): string;
171
+ }
@@ -0,0 +1,11 @@
1
+ import { ConfigEditor } from './ce-types';
2
+ import { LoadedTextPlacement } from './types';
3
+ /**
4
+ * Extract text placements from a loaded config editor instance.
5
+ *
6
+ * Reads the editor state, resolves fonts and colours from settings and
7
+ * palettes, and returns a structured array of text placements ready for
8
+ * rendering or comparison. Processes both the placements and embellishments
9
+ * buckets.
10
+ */
11
+ export declare function extractTextPlacements(editor: ConfigEditor): LoadedTextPlacement[];
@@ -0,0 +1,12 @@
1
+ /**
2
+ * CE Adapter for @unmade/text-renderer
3
+ *
4
+ * Utilities for extracting text placement state from a loaded
5
+ * @unmade/configuration-engine editor instance and mapping it to
6
+ * renderer options. Intended for use in server-side comparison pipelines
7
+ * and any environment that bridges CE state to the text-renderer.
8
+ */
9
+ export { extractTextPlacements } from './extractTextPlacements';
10
+ export { mapStateToRendererOptions } from './mapStateToRendererOptions';
11
+ export type { BasePlacementSettings, BasePlacementState, CombinedEditorSettings, ConfigEditor, EditorGarment, EditorPalette, EditorPaletteColour, EditorState, EditorStateVals, EditorVariant, EmbellishmentPosition, Palettes, PlacementLibraryItem, PlacementPositionResult, PlacementsSettings, TextLibraryItem, TextLibraryItemFont, } from './ce-types';
12
+ export type { LoadedTextPlacement, TextPlacementFont, TextPlacementPosition, TextPlacementSpacing, } from './types';
@@ -0,0 +1,13 @@
1
+ import { GetRenderedTextOptions } from '../types';
2
+ import { LoadedTextPlacement } from './types';
3
+ /**
4
+ * Map a LoadedTextPlacement to GetRenderedTextOptions for the text-renderer.
5
+ *
6
+ * Handles the key differences between config-engine and text-renderer:
7
+ * - American to British English ('center' -> 'centre')
8
+ * - isDistributed flag -> horizontalAlignment: 'distributed'
9
+ * - isCurved flag -> baseline: 'curved'
10
+ * - baselinePath -> baseline: { type: 'custom', path }
11
+ * - snake_case spacing -> camelCase spacing
12
+ */
13
+ export declare function mapStateToRendererOptions(placement: LoadedTextPlacement): GetRenderedTextOptions;
@@ -0,0 +1,56 @@
1
+ import { EditorPaletteColour } from './ce-types';
2
+ export interface TextPlacementPosition {
3
+ width: number;
4
+ height: number;
5
+ physicalWidth: number;
6
+ physicalHeight: number;
7
+ physicalUnits: string;
8
+ baselinePath?: string;
9
+ rotation: number;
10
+ }
11
+ export interface TextPlacementFont {
12
+ id: number;
13
+ fontUrl: string;
14
+ fontFamily: string;
15
+ letterSpacing: number;
16
+ letterSpacingOutline: number;
17
+ outlineWidth: number;
18
+ fixedColours?: Record<string, {
19
+ reference: string;
20
+ hex: string;
21
+ id: string;
22
+ text: string;
23
+ }>;
24
+ }
25
+ export interface TextPlacementSpacing {
26
+ letter_spacing: number;
27
+ letter_spacing_outline: number;
28
+ line_height?: number;
29
+ }
30
+ export interface LoadedTextPlacement {
31
+ placementId: string;
32
+ displayName: string;
33
+ source: 'placements' | 'embellishments';
34
+ text: string;
35
+ font: TextPlacementFont;
36
+ isCurved: boolean;
37
+ isDistributed: boolean;
38
+ verticalAlignment: string;
39
+ horizontalAlignment: string;
40
+ rotation: number;
41
+ spacing: TextPlacementSpacing | null;
42
+ fillColour: EditorPaletteColour | null;
43
+ outlineColour: EditorPaletteColour | null;
44
+ position: TextPlacementPosition;
45
+ userSetPhysicalSize: [number, string] | null;
46
+ fontMetrics: {
47
+ size: number;
48
+ height: number;
49
+ baseline: number;
50
+ width: number;
51
+ physicalHeight?: number;
52
+ physicalUnits?: string;
53
+ physicalFontSize?: [number, 'mm' | 'in'];
54
+ };
55
+ manufacturingMethod: string;
56
+ }
@@ -0,0 +1,5 @@
1
+ import { TextSpacing } from './types';
2
+ export declare const DEFAULT_OUTLINE_FACTOR = 0.03125;
3
+ export declare const LINE_HEIGHT = 1.1;
4
+ export declare const CURVE_DEPTH = 0.2;
5
+ export declare const DEFAULT_SPACING: TextSpacing;