@unmade/text-renderer 1.1.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 -2004
  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 -945
  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 +8002 -9726
  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,7 @@
1
+ import { t as e } from "./chunk-3b4jIN3o.js";
2
+ //#region __vite-browser-external
3
+ var t = /* @__PURE__ */ e(((e, t) => {
4
+ t.exports = {};
5
+ }));
6
+ //#endregion
7
+ export default t();
@@ -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;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function P(t){return t.type==="text"}function w(t){const i=t.getState().garment;return t.settings.garments.find(s=>s.slug===i)}function A(t,l,i){if(!t.embellishment_positions)return;const s=t.embellishment_positions.filter(o=>o.placement!==l?!1:!i||!o.variant?!0:o.variant===i||o.variant.toLowerCase()==="common");if(i&&s.length>1){const o=s.find(a=>a.variant===i);if(o)return o}return s[0]}function U(t,l){const i=t.fonts.find(s=>s.id===l);if(i)return{id:i.id,fontUrl:i.font_url,fontFamily:i.font_family,letterSpacing:i.letter_spacing??0,letterSpacingOutline:i.letter_spacing_outline??0,outlineWidth:i.outline_width??0,fixedColours:i.fixed_colours}}function v(t,l,i,s,o,a){const{library:h}=o,u=[];for(const[r,f]of Object.entries(s)){if(f.type!=="text")continue;const d=f,{meta:e}=d;if(!e?.text)continue;const{libraryItemID:z}=d,g=h[z];if(!g||!P(g))continue;const y=e.font;if(y===void 0)continue;const m=U(g,y);if(!m)continue;const c=A(l,r,a);if(!c)continue;let x=null,b=null;if(e.colours&&g.palette!=null)try{const n=t.palettes.getUsedColours(g.palette,e.colours);x=n[0]??null,b=n[1]??null}catch(n){console.warn(`[extractTextPlacements] Colour resolution failed for ${r}:`,n)}const S=o.byId?.[r],p={vertical:"top",horizontal:"left"};if(S){const n=S;n.vertical_alignment&&(p.vertical=n.vertical_alignment),n.horizontal_alignment&&(p.horizontal=n.horizontal_alignment)}u.push({placementId:r,displayName:r,source:i,text:e.text,font:m,isCurved:e.isCurved??!1,isDistributed:e.isDistributed??!1,verticalAlignment:e.verticalAlignment??p.vertical,horizontalAlignment:e.horizontalAlignment??p.horizontal,rotation:e.rotation??0,spacing:e.spacing??null,fillColour:x,outlineColour:b,position:{width:c.width,height:c.height,physicalWidth:c.physical_width_decimal,physicalHeight:c.physical_height_decimal,physicalUnits:c.physical_size_units,baselinePath:c.baseline_path,rotation:c.rotation},userSetPhysicalSize:e.retainedPhysicalSize??null,fontMetrics:(()=>{const n=e.fontMetrics??{size:0,height:0,baseline:0,width:0},C=n.physicalFontSize||(n.physicalHeight!=null&&n.physicalHeight>0&&n.physicalUnits!=null?[n.physicalHeight,n.physicalUnits]:void 0);return{...n,physicalFontSize:C}})(),manufacturingMethod:e.manufacturing_method??""})}return u}function O(t){const l=t.getState(),i=w(t);if(!i)return console.warn("[extractTextPlacements] No matching garment found"),[];const s=typeof t.getCurrentVariant=="function"?t.getCurrentVariant():void 0,o=[],a=l.vals?.placements,h=t.settings.placements;a&&h&&o.push(...v(t,i,"placements",a,h,s));const u=l.vals?.embellishments,r=t.settings.embellishments;return u&&r&&o.push(...v(t,i,"embellishments",u,r,s)),o.length===0&&console.warn("[extractTextPlacements] No text entries found in either placements or embellishments"),o}function _(t){return t==="center"?"centre":t}function T(t){let l=_(t.horizontalAlignment);t.isDistributed&&(l="distributed");let i;t.position.baselinePath?i={type:"custom",path:t.position.baselinePath}:t.isCurved?i="curved":i="flat";const s=t.userSetPhysicalSize?[t.userSetPhysicalSize[0],t.userSetPhysicalSize[1]]:t.fontMetrics.physicalFontSize!=null?t.fontMetrics.physicalFontSize:[t.position.physicalHeight,t.position.physicalUnits],a={outlineWidth:t.outlineColour!=null?t.font.outlineWidth:0,letterSpacing:t.spacing?.letter_spacing??0,letterSpacingOutline:t.spacing?.letter_spacing_outline??0},h=t.fillColour?{hex:t.fillColour.hex,reference:t.fillColour.reference??void 0}:void 0,u=t.outlineColour?{hex:t.outlineColour.hex,reference:t.outlineColour.reference??void 0}:void 0;let r;if(t.font.fixedColours){const f={};for(const[d,e]of Object.entries(t.font.fixedColours))f[d]={hex:e.hex,reference:e.reference};r=f}return{text:t.text,fontUrl:t.font.fontUrl,physicalSize:s,fontSizeFallback:t.fontMetrics.size,boxDimensions:{width:t.position.width,height:t.position.height,physicalWidth:t.position.physicalWidth,physicalHeight:t.position.physicalHeight,physicalUnits:t.position.physicalUnits},spacing:a,verticalAlignment:_(t.verticalAlignment),horizontalAlignment:l,baseline:i,fillColour:h,strokeColour:u,colourMap:r}}exports.extractTextPlacements=O;exports.mapStateToRendererOptions=T;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});function e(e){return e.type===`text`}function t(e){let t=e.getState().garment;return e.settings.garments.find(e=>e.slug===t)}function n(e,t,n){if(!e.embellishment_positions)return;let r=e.embellishment_positions.filter(e=>e.placement===t?!n||!e.variant?!0:e.variant===n||e.variant.toLowerCase()===`common`:!1);if(n&&r.length>1){let e=r.find(e=>e.variant===n);if(e)return e}return r[0]}function r(e,t){let n=e.fonts.find(e=>e.id===t);if(n)return{id:n.id,fontUrl:n.font_url,fontFamily:n.font_family,letterSpacing:n.letter_spacing??0,letterSpacingOutline:n.letter_spacing_outline??0,outlineWidth:n.outline_width??0,fixedColours:n.fixed_colours}}function i(t,i,a,o,s,c){let{library:l}=s,u=[];for(let[d,f]of Object.entries(o)){if(f.type!==`text`)continue;let o=f,{meta:p}=o;if(!p?.text)continue;let{libraryItemID:m}=o,h=l[m];if(!h||!e(h))continue;let g=p.font;if(g===void 0)continue;let _=r(h,g);if(!_)continue;let v=n(i,d,c);if(!v)continue;let y=null,b=null;if(p.colours&&h.palette!=null)try{let e=t.palettes.getUsedColours(h.palette,p.colours);y=e[0]??null,b=e[1]??null}catch(e){console.warn(`[extractTextPlacements] Colour resolution failed for ${d}:`,e)}let x=s.byId?.[d],S={vertical:`top`,horizontal:`left`};if(x){let e=x;e.vertical_alignment&&(S.vertical=e.vertical_alignment),e.horizontal_alignment&&(S.horizontal=e.horizontal_alignment)}u.push({placementId:d,displayName:d,source:a,text:p.text,font:_,isCurved:p.isCurved??!1,isDistributed:p.isDistributed??!1,verticalAlignment:p.verticalAlignment??S.vertical,horizontalAlignment:p.horizontalAlignment??S.horizontal,rotation:p.rotation??0,spacing:p.spacing??null,fillColour:y,outlineColour:b,position:{width:v.width,height:v.height,physicalWidth:v.physical_width_decimal,physicalHeight:v.physical_height_decimal,physicalUnits:v.physical_size_units,baselinePath:v.baseline_path,rotation:v.rotation},userSetPhysicalSize:p.retainedPhysicalSize??null,fontMetrics:(()=>{let e=p.fontMetrics??{size:0,height:0,baseline:0,width:0},t=e.physicalFontSize||(e.physicalHeight!=null&&e.physicalHeight>0&&e.physicalUnits!=null?[e.physicalHeight,e.physicalUnits]:void 0);return{...e,physicalFontSize:t}})(),manufacturingMethod:p.manufacturing_method??``})}return u}function a(e){let n=e.getState(),r=t(e);if(!r)return console.warn(`[extractTextPlacements] No matching garment found`),[];let a=typeof e.getCurrentVariant==`function`?e.getCurrentVariant():void 0,o=[],s=n.vals?.placements,c=e.settings.placements;s&&c&&o.push(...i(e,r,`placements`,s,c,a));let l=n.vals?.embellishments,u=e.settings.embellishments;return l&&u&&o.push(...i(e,r,`embellishments`,l,u,a)),o.length===0&&console.warn(`[extractTextPlacements] No text entries found in either placements or embellishments`),o}function o(e){return e===`center`?`centre`:e}function s(e){let t=o(e.horizontalAlignment);e.isDistributed&&(t=`distributed`);let n;n=e.position.baselinePath?{type:`custom`,path:e.position.baselinePath}:e.isCurved?`curved`:`flat`;let r=e.userSetPhysicalSize?[e.userSetPhysicalSize[0],e.userSetPhysicalSize[1]]:e.fontMetrics.physicalFontSize==null?[e.position.physicalHeight,e.position.physicalUnits]:e.fontMetrics.physicalFontSize,i={outlineWidth:e.outlineColour==null?0:e.font.outlineWidth,letterSpacing:e.spacing?.letter_spacing??0,letterSpacingOutline:e.spacing?.letter_spacing_outline??0},a=e.fillColour?{hex:e.fillColour.hex,reference:e.fillColour.reference??void 0}:void 0,s=e.outlineColour?{hex:e.outlineColour.hex,reference:e.outlineColour.reference??void 0}:void 0,c;if(e.font.fixedColours){let t={};for(let[n,r]of Object.entries(e.font.fixedColours))t[n]={hex:r.hex,reference:r.reference};c=t}return{text:e.text,fontUrl:e.font.fontUrl,physicalSize:r,fontSizeFallback:e.fontMetrics.size,boxDimensions:{width:e.position.width,height:e.position.height,physicalWidth:e.position.physicalWidth,physicalHeight:e.position.physicalHeight,physicalUnits:e.position.physicalUnits},spacing:i,verticalAlignment:o(e.verticalAlignment),horizontalAlignment:t,baseline:n,fillColour:a,strokeColour:s,colourMap:c}}exports.extractTextPlacements=a,exports.mapStateToRendererOptions=s;
@@ -1,160 +1,162 @@
1
- function w(t) {
2
- return t.type === "text";
1
+ //#region src/ce-adapter/extractTextPlacements.ts
2
+ function e(e) {
3
+ return e.type === "text";
3
4
  }
4
- function P(t) {
5
- const i = t.getState().garment;
6
- return t.settings.garments.find((s) => s.slug === i);
5
+ function t(e) {
6
+ let t = e.getState().garment;
7
+ return e.settings.garments.find((e) => e.slug === t);
7
8
  }
8
- function A(t, l, i) {
9
- if (!t.embellishment_positions) return;
10
- const s = t.embellishment_positions.filter((o) => o.placement !== l ? !1 : !i || !o.variant ? !0 : o.variant === i || o.variant.toLowerCase() === "common");
11
- if (i && s.length > 1) {
12
- const o = s.find((a) => a.variant === i);
13
- if (o) return o;
14
- }
15
- return s[0];
9
+ function n(e, t, n) {
10
+ if (!e.embellishment_positions) return;
11
+ let r = e.embellishment_positions.filter((e) => e.placement === t ? !n || !e.variant ? !0 : e.variant === n || e.variant.toLowerCase() === "common" : !1);
12
+ if (n && r.length > 1) {
13
+ let e = r.find((e) => e.variant === n);
14
+ if (e) return e;
15
+ }
16
+ return r[0];
16
17
  }
17
- function U(t, l) {
18
- const i = t.fonts.find((s) => s.id === l);
19
- if (i)
20
- return {
21
- id: i.id,
22
- fontUrl: i.font_url,
23
- fontFamily: i.font_family,
24
- letterSpacing: i.letter_spacing ?? 0,
25
- letterSpacingOutline: i.letter_spacing_outline ?? 0,
26
- outlineWidth: i.outline_width ?? 0,
27
- fixedColours: i.fixed_colours
28
- };
18
+ function r(e, t) {
19
+ let n = e.fonts.find((e) => e.id === t);
20
+ if (n) return {
21
+ id: n.id,
22
+ fontUrl: n.font_url,
23
+ fontFamily: n.font_family,
24
+ letterSpacing: n.letter_spacing ?? 0,
25
+ letterSpacingOutline: n.letter_spacing_outline ?? 0,
26
+ outlineWidth: n.outline_width ?? 0,
27
+ fixedColours: n.fixed_colours
28
+ };
29
29
  }
30
- function S(t, l, i, s, o, a) {
31
- const { library: h } = o, u = [];
32
- for (const [r, f] of Object.entries(s)) {
33
- if (f.type !== "text") continue;
34
- const d = f, { meta: e } = d;
35
- if (!e?.text) continue;
36
- const { libraryItemID: z } = d, g = h[z];
37
- if (!g || !w(g)) continue;
38
- const y = e.font;
39
- if (y === void 0) continue;
40
- const m = U(g, y);
41
- if (!m) continue;
42
- const c = A(l, r, a);
43
- if (!c) continue;
44
- let x = null, b = null;
45
- if (e.colours && g.palette != null)
46
- try {
47
- const n = t.palettes.getUsedColours(
48
- g.palette,
49
- e.colours
50
- );
51
- x = n[0] ?? null, b = n[1] ?? null;
52
- } catch (n) {
53
- console.warn(`[extractTextPlacements] Colour resolution failed for ${r}:`, n);
54
- }
55
- const v = o.byId?.[r], p = {
56
- vertical: "top",
57
- horizontal: "left"
58
- };
59
- if (v) {
60
- const n = v;
61
- n.vertical_alignment && (p.vertical = n.vertical_alignment), n.horizontal_alignment && (p.horizontal = n.horizontal_alignment);
62
- }
63
- u.push({
64
- placementId: r,
65
- displayName: r,
66
- source: i,
67
- text: e.text,
68
- font: m,
69
- isCurved: e.isCurved ?? !1,
70
- isDistributed: e.isDistributed ?? !1,
71
- verticalAlignment: e.verticalAlignment ?? p.vertical,
72
- horizontalAlignment: e.horizontalAlignment ?? p.horizontal,
73
- rotation: e.rotation ?? 0,
74
- spacing: e.spacing ?? null,
75
- fillColour: x,
76
- outlineColour: b,
77
- position: {
78
- width: c.width,
79
- height: c.height,
80
- physicalWidth: c.physical_width_decimal,
81
- physicalHeight: c.physical_height_decimal,
82
- physicalUnits: c.physical_size_units,
83
- baselinePath: c.baseline_path,
84
- rotation: c.rotation
85
- },
86
- userSetPhysicalSize: e.retainedPhysicalSize ?? null,
87
- fontMetrics: (() => {
88
- const n = e.fontMetrics ?? { size: 0, height: 0, baseline: 0, width: 0 }, C = n.physicalFontSize || (n.physicalHeight != null && n.physicalHeight > 0 && n.physicalUnits != null ? [n.physicalHeight, n.physicalUnits] : void 0);
89
- return { ...n, physicalFontSize: C };
90
- })(),
91
- manufacturingMethod: e.manufacturing_method ?? ""
92
- });
93
- }
94
- return u;
30
+ function i(t, i, a, o, s, c) {
31
+ let { library: l } = s, u = [];
32
+ for (let [d, f] of Object.entries(o)) {
33
+ if (f.type !== "text") continue;
34
+ let o = f, { meta: p } = o;
35
+ if (!p?.text) continue;
36
+ let { libraryItemID: m } = o, h = l[m];
37
+ if (!h || !e(h)) continue;
38
+ let g = p.font;
39
+ if (g === void 0) continue;
40
+ let _ = r(h, g);
41
+ if (!_) continue;
42
+ let v = n(i, d, c);
43
+ if (!v) continue;
44
+ let y = null, b = null;
45
+ if (p.colours && h.palette != null) try {
46
+ let e = t.palettes.getUsedColours(h.palette, p.colours);
47
+ y = e[0] ?? null, b = e[1] ?? null;
48
+ } catch (e) {
49
+ console.warn(`[extractTextPlacements] Colour resolution failed for ${d}:`, e);
50
+ }
51
+ let x = s.byId?.[d], S = {
52
+ vertical: "top",
53
+ horizontal: "left"
54
+ };
55
+ if (x) {
56
+ let e = x;
57
+ e.vertical_alignment && (S.vertical = e.vertical_alignment), e.horizontal_alignment && (S.horizontal = e.horizontal_alignment);
58
+ }
59
+ u.push({
60
+ placementId: d,
61
+ displayName: d,
62
+ source: a,
63
+ text: p.text,
64
+ font: _,
65
+ isCurved: p.isCurved ?? !1,
66
+ isDistributed: p.isDistributed ?? !1,
67
+ verticalAlignment: p.verticalAlignment ?? S.vertical,
68
+ horizontalAlignment: p.horizontalAlignment ?? S.horizontal,
69
+ rotation: p.rotation ?? 0,
70
+ spacing: p.spacing ?? null,
71
+ fillColour: y,
72
+ outlineColour: b,
73
+ position: {
74
+ width: v.width,
75
+ height: v.height,
76
+ physicalWidth: v.physical_width_decimal,
77
+ physicalHeight: v.physical_height_decimal,
78
+ physicalUnits: v.physical_size_units,
79
+ baselinePath: v.baseline_path,
80
+ rotation: v.rotation
81
+ },
82
+ userSetPhysicalSize: p.retainedPhysicalSize ?? null,
83
+ fontMetrics: (() => {
84
+ let e = p.fontMetrics ?? {
85
+ size: 0,
86
+ height: 0,
87
+ baseline: 0,
88
+ width: 0
89
+ }, t = e.physicalFontSize || (e.physicalHeight != null && e.physicalHeight > 0 && e.physicalUnits != null ? [e.physicalHeight, e.physicalUnits] : void 0);
90
+ return {
91
+ ...e,
92
+ physicalFontSize: t
93
+ };
94
+ })(),
95
+ manufacturingMethod: p.manufacturing_method ?? ""
96
+ });
97
+ }
98
+ return u;
95
99
  }
96
- function F(t) {
97
- const l = t.getState(), i = P(t);
98
- if (!i)
99
- return console.warn("[extractTextPlacements] No matching garment found"), [];
100
- const s = typeof t.getCurrentVariant == "function" ? t.getCurrentVariant() : void 0, o = [], a = l.vals?.placements, h = t.settings.placements;
101
- a && h && o.push(...S(t, i, "placements", a, h, s));
102
- const u = l.vals?.embellishments, r = t.settings.embellishments;
103
- return u && r && o.push(...S(t, i, "embellishments", u, r, s)), o.length === 0 && console.warn("[extractTextPlacements] No text entries found in either placements or embellishments"), o;
100
+ function a(e) {
101
+ let n = e.getState(), r = t(e);
102
+ if (!r) return console.warn("[extractTextPlacements] No matching garment found"), [];
103
+ let a = typeof e.getCurrentVariant == "function" ? e.getCurrentVariant() : void 0, o = [], s = n.vals?.placements, c = e.settings.placements;
104
+ s && c && o.push(...i(e, r, "placements", s, c, a));
105
+ let l = n.vals?.embellishments, u = e.settings.embellishments;
106
+ return l && u && o.push(...i(e, r, "embellishments", l, u, a)), o.length === 0 && console.warn("[extractTextPlacements] No text entries found in either placements or embellishments"), o;
104
107
  }
105
- function _(t) {
106
- return t === "center" ? "centre" : t;
108
+ //#endregion
109
+ //#region src/ce-adapter/mapStateToRendererOptions.ts
110
+ function o(e) {
111
+ return e === "center" ? "centre" : e;
107
112
  }
108
- function H(t) {
109
- let l = _(t.horizontalAlignment);
110
- t.isDistributed && (l = "distributed");
111
- let i;
112
- t.position.baselinePath ? i = { type: "custom", path: t.position.baselinePath } : t.isCurved ? i = "curved" : i = "flat";
113
- const s = t.userSetPhysicalSize ? [
114
- t.userSetPhysicalSize[0],
115
- t.userSetPhysicalSize[1]
116
- ] : t.fontMetrics.physicalFontSize != null ? t.fontMetrics.physicalFontSize : [t.position.physicalHeight, t.position.physicalUnits], a = {
117
- outlineWidth: t.outlineColour != null ? t.font.outlineWidth : 0,
118
- letterSpacing: t.spacing?.letter_spacing ?? 0,
119
- letterSpacingOutline: t.spacing?.letter_spacing_outline ?? 0
120
- }, h = t.fillColour ? {
121
- hex: t.fillColour.hex,
122
- reference: t.fillColour.reference ?? void 0
123
- } : void 0, u = t.outlineColour ? {
124
- hex: t.outlineColour.hex,
125
- reference: t.outlineColour.reference ?? void 0
126
- } : void 0;
127
- let r;
128
- if (t.font.fixedColours) {
129
- const f = {};
130
- for (const [d, e] of Object.entries(t.font.fixedColours))
131
- f[d] = { hex: e.hex, reference: e.reference };
132
- r = f;
133
- }
134
- return {
135
- text: t.text,
136
- fontUrl: t.font.fontUrl,
137
- physicalSize: s,
138
- fontSizeFallback: t.fontMetrics.size,
139
- boxDimensions: {
140
- width: t.position.width,
141
- height: t.position.height,
142
- physicalWidth: t.position.physicalWidth,
143
- physicalHeight: t.position.physicalHeight,
144
- physicalUnits: t.position.physicalUnits
145
- },
146
- spacing: a,
147
- verticalAlignment: _(
148
- t.verticalAlignment
149
- ),
150
- horizontalAlignment: l,
151
- baseline: i,
152
- fillColour: h,
153
- strokeColour: u,
154
- colourMap: r
155
- };
113
+ function s(e) {
114
+ let t = o(e.horizontalAlignment);
115
+ e.isDistributed && (t = "distributed");
116
+ let n;
117
+ n = e.position.baselinePath ? {
118
+ type: "custom",
119
+ path: e.position.baselinePath
120
+ } : e.isCurved ? "curved" : "flat";
121
+ let r = e.userSetPhysicalSize ? [e.userSetPhysicalSize[0], e.userSetPhysicalSize[1]] : e.fontMetrics.physicalFontSize == null ? [e.position.physicalHeight, e.position.physicalUnits] : e.fontMetrics.physicalFontSize, i = {
122
+ outlineWidth: e.outlineColour == null ? 0 : e.font.outlineWidth,
123
+ letterSpacing: e.spacing?.letter_spacing ?? 0,
124
+ letterSpacingOutline: e.spacing?.letter_spacing_outline ?? 0
125
+ }, a = e.fillColour ? {
126
+ hex: e.fillColour.hex,
127
+ reference: e.fillColour.reference ?? void 0
128
+ } : void 0, s = e.outlineColour ? {
129
+ hex: e.outlineColour.hex,
130
+ reference: e.outlineColour.reference ?? void 0
131
+ } : void 0, c;
132
+ if (e.font.fixedColours) {
133
+ let t = {};
134
+ for (let [n, r] of Object.entries(e.font.fixedColours)) t[n] = {
135
+ hex: r.hex,
136
+ reference: r.reference
137
+ };
138
+ c = t;
139
+ }
140
+ return {
141
+ text: e.text,
142
+ fontUrl: e.font.fontUrl,
143
+ physicalSize: r,
144
+ fontSizeFallback: e.fontMetrics.size,
145
+ boxDimensions: {
146
+ width: e.position.width,
147
+ height: e.position.height,
148
+ physicalWidth: e.position.physicalWidth,
149
+ physicalHeight: e.position.physicalHeight,
150
+ physicalUnits: e.position.physicalUnits
151
+ },
152
+ spacing: i,
153
+ verticalAlignment: o(e.verticalAlignment),
154
+ horizontalAlignment: t,
155
+ baseline: n,
156
+ fillColour: a,
157
+ strokeColour: s,
158
+ colourMap: c
159
+ };
156
160
  }
157
- export {
158
- F as extractTextPlacements,
159
- H as mapStateToRendererOptions
160
- };
161
+ //#endregion
162
+ export { a as extractTextPlacements, s as mapStateToRendererOptions };
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : a, n));
12
+ //#endregion
13
+ export { c as n, o as t };
@@ -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;
@@ -0,0 +1,42 @@
1
+ import { LoadedFont } from '../loading';
2
+ import { ColourInfo, ColourMap, GlyphFill } from '../types';
3
+ /**
4
+ * Get the unique colours used by a font's SVG glyphs.
5
+ *
6
+ * @param font - A loaded font with svgGlyphs populated
7
+ * @returns Array of unique hex colour strings found in the font's SVG glyphs
8
+ */
9
+ export declare function getFontColours(font: LoadedFont): string[];
10
+ /**
11
+ * Extract fill paths from SVG content with optional colour remapping.
12
+ *
13
+ * @param svgContent - Raw SVG string from the font's SVG table
14
+ * @param colourMap - Optional mapping of original colours to replacements
15
+ * @returns Array of GlyphFill objects
16
+ */
17
+ export declare function extractFillsFromSVG(svgContent: string, colourMap?: ColourMap): GlyphFill[];
18
+ /**
19
+ * Apply colour map to remap a colour value.
20
+ *
21
+ * @param colour - Original colour hex string
22
+ * @param colourMap - Optional colour replacement mapping
23
+ * @returns ColourInfo with hex and optional reference
24
+ */
25
+ export declare function applyColourMap(colour: string, colourMap?: ColourMap): ColourInfo;
26
+ /**
27
+ * Extract the inner content from a raw SVG glyph string.
28
+ * Strips the XML declaration and outer <svg> wrapper, returning the inner elements.
29
+ */
30
+ export declare function extractSvgGlyphContent(rawSvg: string): string;
31
+ /**
32
+ * Namespace all IDs in SVG content to prevent collisions when multiple
33
+ * glyphs are embedded in the same document. Prefixes all id attributes
34
+ * and updates all references (href, url(), clip-path, mask, filter).
35
+ */
36
+ export declare function namespaceSvgIds(svgContent: string, prefix: string): string;
37
+ /**
38
+ * Remap colour values in raw SVG content. Replaces fill, stroke,
39
+ * and stop-color attribute values according to the colour map.
40
+ * Also handles elements without explicit fill that default to black.
41
+ */
42
+ export declare function remapSvgColours(svgContent: string, colourMap: ColourMap): string;
@@ -0,0 +1,33 @@
1
+ export declare class Box {
2
+ corners: DOMPoint[];
3
+ x1: number;
4
+ y1: number;
5
+ x2: number;
6
+ y2: number;
7
+ _x3: number | undefined;
8
+ _y3: number | undefined;
9
+ _x4: number | undefined;
10
+ _y4: number | undefined;
11
+ get x3(): number;
12
+ get y3(): number;
13
+ get x4(): number;
14
+ get y4(): number;
15
+ constructor(x1: number, y1: number, x2: number, y2: number, x3?: number, y3?: number, x4?: number, y4?: number);
16
+ transform(matrix: DOMMatrix): void;
17
+ toPointsArray(): number[][];
18
+ getBBox(): BBox;
19
+ }
20
+ export declare class BBox extends Box {
21
+ get x(): number;
22
+ get y(): number;
23
+ get width(): number;
24
+ get height(): number;
25
+ add(box: Box): void;
26
+ addPoint(x: number, y: number): void;
27
+ serialize(): {
28
+ x: number;
29
+ y: number;
30
+ width: number;
31
+ height: number;
32
+ };
33
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Create a matrix with optional initial values
3
+ * Detects what style of matrix is supported by the browser
4
+ *
5
+ * @param {Array} initialValues - the initial values for the matrix
6
+ * @returns {DOMMatrix} the new matrix
7
+ */
8
+ export declare const createMatrix: (initialValues?: number[]) => DOMMatrix;
@@ -0,0 +1,17 @@
1
+ export declare class Point {
2
+ private x;
3
+ private y;
4
+ constructor(x: number, y: number);
5
+ get X(): number;
6
+ get Y(): number;
7
+ toSVGString(): string;
8
+ }
9
+ /**
10
+ * Rotate a point about a pivot point
11
+ *
12
+ * @param point - the point to rotate
13
+ * @param rotate - the amount in degrees
14
+ * @param pivotPoint - the point around which to rotate
15
+ * @returns the new point
16
+ */
17
+ export declare function rotatePoint(point: Point, rotate: number, pivotPoint?: Point): Point;
@@ -0,0 +1 @@
1
+ export declare function escapeXML(str: string): string;