@unmade/text-renderer 0.1.5 → 0.1.7
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.
- package/dist/ce-adapter/ce-types.d.ts +4 -2
- package/dist/ce-adapter/index.cjs +1 -1
- package/dist/ce-adapter/index.js +3 -2
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +11 -0
- package/dist/index.js +929 -922
- package/dist/node/index.cjs +5 -5
- package/dist/node/index.d.ts +11 -0
- package/dist/node/index.js +930 -923
- package/dist/worker/index.cjs +15 -15
- package/dist/worker/index.d.ts +11 -0
- package/dist/worker/index.js +1553 -1546
- package/package.json +15 -15
|
@@ -34,8 +34,10 @@ export interface EmbellishmentPosition {
|
|
|
34
34
|
placement: string;
|
|
35
35
|
width: number;
|
|
36
36
|
height: number;
|
|
37
|
-
physical_width
|
|
38
|
-
physical_height
|
|
37
|
+
physical_width?: number;
|
|
38
|
+
physical_height?: number;
|
|
39
|
+
physical_width_decimal: number;
|
|
40
|
+
physical_height_decimal: number;
|
|
39
41
|
physical_size_units: string;
|
|
40
42
|
baseline_path?: string;
|
|
41
43
|
rotation: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function z(t){return t.type==="text"}function C(t){const i=t.getState().garment;return t.settings.garments.find(o=>o.slug===i)}function P(t,n){if(t.embellishment_positions)return t.embellishment_positions.find(i=>i.placement===n)}function w(t,n){const i=t.fonts.find(o=>o.id===n);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,n,i,o,r){const{library:u}=r,c=[];for(const[s,h]of Object.entries(o)){if(h.type!=="text")continue;const f=h,{meta:e}=f;if(!e?.text)continue;const{libraryItemID:d}=f,g=u[d];if(!g||!z(g))continue;const y=e.font;if(y===void 0)continue;const m=w(g,y);if(!m)continue;const a=P(n,s);if(!a)continue;let
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function z(t){return t.type==="text"}function C(t){const i=t.getState().garment;return t.settings.garments.find(o=>o.slug===i)}function P(t,n){if(t.embellishment_positions)return t.embellishment_positions.find(i=>i.placement===n)}function w(t,n){const i=t.fonts.find(o=>o.id===n);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,n,i,o,r){const{library:u}=r,c=[];for(const[s,h]of Object.entries(o)){if(h.type!=="text")continue;const f=h,{meta:e}=f;if(!e?.text)continue;const{libraryItemID:d}=f,g=u[d];if(!g||!z(g))continue;const y=e.font;if(y===void 0)continue;const m=w(g,y);if(!m)continue;const a=P(n,s);if(!a)continue;let S=null,x=null;if(e.colours&&g.palette!=null)try{const l=t.palettes.getUsedColours(g.palette,e.colours);S=l[0]??null,x=l[1]??null}catch(l){console.warn(`[extractTextPlacements] Colour resolution failed for ${s}:`,l)}const b=r.byId?.[s],p={vertical:"top",horizontal:"left"};if(b){const l=b;l.vertical_alignment&&(p.vertical=l.vertical_alignment),l.horizontal_alignment&&(p.horizontal=l.horizontal_alignment)}c.push({placementId:s,displayName:s,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:S,outlineColour:x,position:{width:a.width,height:a.height,physicalWidth:a.physical_width_decimal,physicalHeight:a.physical_height_decimal,physicalUnits:a.physical_size_units,baselinePath:a.baseline_path,rotation:a.rotation},userSetPhysicalSize:e.retainedPhysicalSize??null,fontMetrics:e.fontMetrics??{size:0,height:0,baseline:0,width:0},manufacturingMethod:e.manufacturing_method??""})}return c}function A(t){const n=t.getState(),i=C(t);if(!i)return console.warn("[extractTextPlacements] No matching garment found"),[];const o=[],r=n.vals?.placements,u=t.settings.placements;r&&u&&o.push(...v(t,i,"placements",r,u));const c=n.vals?.embellishments,s=t.settings.embellishments;return c&&s&&o.push(...v(t,i,"embellishments",c,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 O(t){let n=_(t.horizontalAlignment);t.isDistributed&&(n="distributed");let i;t.position.baselinePath?i={type:"custom",path:t.position.baselinePath}:t.isCurved?i="curved":i="flat";const o=t.userSetPhysicalSize?[t.userSetPhysicalSize[0],t.userSetPhysicalSize[1]]:t.fontMetrics.physicalFontSize!=null?t.fontMetrics.physicalFontSize:[t.position.physicalHeight,t.position.physicalUnits],r=t.outlineColour!=null,u=t.spacing?{outlineWidth:r?t.font.outlineWidth:0,letterSpacing:t.spacing.letter_spacing,letterSpacingOutline:t.spacing.letter_spacing_outline}:{outlineWidth:r?t.font.outlineWidth:0,letterSpacing:t.font.letterSpacing,letterSpacingOutline:t.font.letterSpacingOutline},c=t.fillColour?{hex:t.fillColour.hex,reference:t.fillColour.reference??void 0}:void 0,s=t.outlineColour?{hex:t.outlineColour.hex,reference:t.outlineColour.reference??void 0}:void 0;let h;if(t.font.fixedColours){const f={};for(const[e,d]of Object.entries(t.font.fixedColours))f[e]={hex:d.hex,reference:d.reference};h=f}return{text:t.text,fontUrl:t.font.fontUrl,physicalSize:o,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:u,verticalAlignment:_(t.verticalAlignment),horizontalAlignment:n,baseline:i,fillColour:c,strokeColour:s,colourMap:h}}exports.extractTextPlacements=A;exports.mapStateToRendererOptions=O;
|
package/dist/ce-adapter/index.js
CHANGED
|
@@ -74,8 +74,8 @@ function v(t, n, i, o, r) {
|
|
|
74
74
|
position: {
|
|
75
75
|
width: a.width,
|
|
76
76
|
height: a.height,
|
|
77
|
-
physicalWidth: a.
|
|
78
|
-
physicalHeight: a.
|
|
77
|
+
physicalWidth: a.physical_width_decimal,
|
|
78
|
+
physicalHeight: a.physical_height_decimal,
|
|
79
79
|
physicalUnits: a.physical_size_units,
|
|
80
80
|
baselinePath: a.baseline_path,
|
|
81
81
|
rotation: a.rotation
|
|
@@ -133,6 +133,7 @@ function O(t) {
|
|
|
133
133
|
text: t.text,
|
|
134
134
|
fontUrl: t.font.fontUrl,
|
|
135
135
|
physicalSize: o,
|
|
136
|
+
fontSizeFallback: t.fontMetrics.size,
|
|
136
137
|
boxDimensions: {
|
|
137
138
|
width: t.position.width,
|
|
138
139
|
height: t.position.height,
|