embroidery-qc-image 1.0.7 → 1.0.9
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/README.md +61 -84
- package/dist/components/EmbroideryQCImage.d.ts +9 -1
- package/dist/components/EmbroideryQCImage.d.ts.map +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +423 -115
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +424 -114
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,10 +13,9 @@ npm install embroidery-qc-image
|
|
|
13
13
|
```tsx
|
|
14
14
|
import React from "react";
|
|
15
15
|
import { EmbroideryQCImage } from "embroidery-qc-image";
|
|
16
|
-
import "embroidery-qc-image
|
|
16
|
+
import type { EmbroideryQCConfig } from "embroidery-qc-image";
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
const exampleConfig = {
|
|
18
|
+
const exampleConfig: EmbroideryQCConfig = {
|
|
20
19
|
image_url:
|
|
21
20
|
"https://i.etsystatic.com/34592503/r/il/5d3e59/7253371633/il_fullxfull.7253371633_kgqr.jpg",
|
|
22
21
|
sides: [
|
|
@@ -24,16 +23,16 @@ const exampleConfig = {
|
|
|
24
23
|
print_side: "Chest",
|
|
25
24
|
positions: [
|
|
26
25
|
{
|
|
27
|
-
type: "TEXT"
|
|
26
|
+
type: "TEXT",
|
|
28
27
|
text: "Brian",
|
|
29
28
|
text_shape: "No Curved",
|
|
30
29
|
color: null,
|
|
31
|
-
font: "Brittany",
|
|
30
|
+
font: "Brittany Signature",
|
|
32
31
|
floral_pattern: null,
|
|
33
32
|
character_colors: ["Pink (1148)", "Lavender (1032)"],
|
|
34
33
|
},
|
|
35
34
|
{
|
|
36
|
-
type: "TEXT"
|
|
35
|
+
type: "TEXT",
|
|
37
36
|
text: "EST. 2009",
|
|
38
37
|
text_shape: "No Curved",
|
|
39
38
|
color: "Light Denim (1133)",
|
|
@@ -42,7 +41,7 @@ const exampleConfig = {
|
|
|
42
41
|
floral_pattern: "P61",
|
|
43
42
|
},
|
|
44
43
|
{
|
|
45
|
-
type: "ICON"
|
|
44
|
+
type: "ICON",
|
|
46
45
|
icon: 1,
|
|
47
46
|
layer_colors: ["White (9)", "Red (1037)"],
|
|
48
47
|
},
|
|
@@ -52,7 +51,7 @@ const exampleConfig = {
|
|
|
52
51
|
print_side: "Sleeve",
|
|
53
52
|
positions: [
|
|
54
53
|
{
|
|
55
|
-
type: "TEXT"
|
|
54
|
+
type: "TEXT",
|
|
56
55
|
text: "Ayanna",
|
|
57
56
|
text_shape: "No Curved",
|
|
58
57
|
color: "Terra Cotta (1477)",
|
|
@@ -60,7 +59,7 @@ const exampleConfig = {
|
|
|
60
59
|
character_colors: null,
|
|
61
60
|
},
|
|
62
61
|
{
|
|
63
|
-
type: "TEXT"
|
|
62
|
+
type: "TEXT",
|
|
64
63
|
text: "Ryan",
|
|
65
64
|
text_shape: "No Curved",
|
|
66
65
|
color: "Terra Cotta (1477)",
|
|
@@ -83,6 +82,34 @@ const App: React.FC = () => {
|
|
|
83
82
|
export default App;
|
|
84
83
|
```
|
|
85
84
|
|
|
85
|
+
### Export as Data URL
|
|
86
|
+
|
|
87
|
+
If you want to render the embroidery image yourself (for example with an `<img>` tag, download button, or upload flow), use the helper `generateEmbroideryQCImageData`. It returns a Data URL corresponding to the canvas output.
|
|
88
|
+
|
|
89
|
+
```tsx
|
|
90
|
+
import { generateEmbroideryQCImageData } from "embroidery-qc-image";
|
|
91
|
+
|
|
92
|
+
const dataUrl = await generateEmbroideryQCImageData(exampleConfig, {
|
|
93
|
+
width: 4200, // optional, defaults to 4200
|
|
94
|
+
height: 4800, // optional, defaults to 4800
|
|
95
|
+
mimeType: "image/png", // optional
|
|
96
|
+
quality: 0.92 // optional (used for jpeg/webp)
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
if (dataUrl) {
|
|
100
|
+
// Display in an <img> tag
|
|
101
|
+
<img src={dataUrl} alt="Embroidery preview" />;
|
|
102
|
+
|
|
103
|
+
// Or trigger download
|
|
104
|
+
const link = document.createElement("a");
|
|
105
|
+
link.href = dataUrl;
|
|
106
|
+
link.download = "embroidery.png";
|
|
107
|
+
link.click();
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> Need a `Blob` instead? Use `generateEmbroideryQCImageBlob` with the same options.
|
|
112
|
+
|
|
86
113
|
## Props
|
|
87
114
|
|
|
88
115
|
### EmbroideryQCImage
|
|
@@ -98,91 +125,41 @@ export default App;
|
|
|
98
125
|
### EmbroideryQCConfig
|
|
99
126
|
|
|
100
127
|
```typescript
|
|
101
|
-
interface
|
|
102
|
-
image_url?: string; // Optional mockup image URL (displayed at bottom-right)
|
|
103
|
-
sides: Side[]; // Array of sides to render
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
interface Side {
|
|
107
|
-
print_side: string; // e.g., "Chest", "Sleeve"
|
|
108
|
-
positions: Position[]; // Array of positions to render
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
type Position = TextPosition | IconPosition;
|
|
112
|
-
|
|
113
|
-
interface TextPosition {
|
|
128
|
+
export interface TextPosition {
|
|
114
129
|
type: 'TEXT';
|
|
115
|
-
text: string;
|
|
116
|
-
text_shape?: string | null;
|
|
117
|
-
color?: string | null;
|
|
118
|
-
font?: string | null;
|
|
119
|
-
character_colors?: string[] | null;
|
|
120
|
-
floral_pattern?: string | null;
|
|
130
|
+
text: string;
|
|
131
|
+
text_shape?: string | null;
|
|
132
|
+
color?: string | null;
|
|
133
|
+
font?: string | null;
|
|
134
|
+
character_colors?: string[] | null;
|
|
135
|
+
floral_pattern?: string | null;
|
|
121
136
|
}
|
|
122
137
|
|
|
123
|
-
interface IconPosition {
|
|
138
|
+
export interface IconPosition {
|
|
124
139
|
type: 'ICON';
|
|
125
|
-
icon: number;
|
|
126
|
-
layer_colors: string[];
|
|
140
|
+
icon: number;
|
|
141
|
+
layer_colors: string[];
|
|
127
142
|
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## Features
|
|
131
|
-
|
|
132
|
-
- ✅ Render custom text on mockup images with automatic text wrapping
|
|
133
|
-
- ✅ Support for icon placement with multi-layer colors
|
|
134
|
-
- ✅ Character-level color customization (alternating colors)
|
|
135
|
-
- ✅ Font loading from CDN with automatic fallback
|
|
136
|
-
- ✅ Multiple print sides (Chest, Sleeve, etc.)
|
|
137
|
-
- ✅ Floral pattern support with inline display
|
|
138
|
-
- ✅ Automatic font scaling to fit canvas (only scales down, never up)
|
|
139
|
-
- ✅ Smart layout with uniform property grouping
|
|
140
|
-
- ✅ Color swatches displayed inline with labels
|
|
141
|
-
- ✅ Automatic word wrapping for long text
|
|
142
|
-
- ✅ Fixed canvas size (4200x4800)
|
|
143
|
-
- ✅ TypeScript support with full type definitions
|
|
144
|
-
|
|
145
|
-
## Supported Colors
|
|
146
|
-
|
|
147
|
-
The component automatically maps color names to hex values for text rendering:
|
|
148
|
-
- `White (9)`, `Black (8)`, `Red (9)`, `Red (1307)`, `Blue (9)`, `Green (9)`
|
|
149
|
-
- `Forest Green (1397)`, `Brown (9)`, `Cream (9)`, `Beige (9)`
|
|
150
|
-
- `Navy (9)`, `Maroon (9)` and more...
|
|
151
143
|
|
|
152
|
-
|
|
144
|
+
export type Position = TextPosition | IconPosition;
|
|
153
145
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
The swatches are displayed next to "Màu chỉ:" labels, showing visual representation of the thread colors used in the embroidery design.
|
|
160
|
-
|
|
161
|
-
## Font Loading
|
|
162
|
-
|
|
163
|
-
Fonts are automatically loaded from:
|
|
164
|
-
```
|
|
165
|
-
https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/fonts/{FontName}.woff2
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Supported format: WOFF2
|
|
169
|
-
|
|
170
|
-
## Icons
|
|
171
|
-
|
|
172
|
-
Icons are loaded from:
|
|
173
|
-
```
|
|
174
|
-
https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/icons/Icon {IconNumber}.png
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
Example: `icon: 1` → loads `Icon 1.png`
|
|
146
|
+
export interface Side {
|
|
147
|
+
print_side: string;
|
|
148
|
+
positions: Position[];
|
|
149
|
+
}
|
|
178
150
|
|
|
179
|
-
|
|
151
|
+
export interface EmbroideryQCConfig {
|
|
152
|
+
image_url?: string;
|
|
153
|
+
error?: string | null;
|
|
154
|
+
sides: Side[];
|
|
155
|
+
}
|
|
180
156
|
|
|
181
|
-
|
|
157
|
+
export interface EmbroideryQCImageProps {
|
|
158
|
+
config: EmbroideryQCConfig;
|
|
159
|
+
className?: string;
|
|
160
|
+
style?: React.CSSProperties;
|
|
161
|
+
}
|
|
182
162
|
|
|
183
|
-
Floral patterns are loaded from:
|
|
184
|
-
```
|
|
185
|
-
https://s3.hn-1.cloud.cmctelecom.vn/god-system-images/embroidery/florals/{PatternName}.png
|
|
186
163
|
```
|
|
187
164
|
|
|
188
165
|
## License
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { EmbroideryQCImageProps } from "../types";
|
|
2
|
+
import { EmbroideryQCConfig, EmbroideryQCImageProps } from "../types";
|
|
3
3
|
import "./EmbroideryQCImage.css";
|
|
4
|
+
export interface EmbroideryQCImageRenderOptions {
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
7
|
+
mimeType?: "image/png" | "image/jpeg" | "image/webp";
|
|
8
|
+
quality?: number;
|
|
9
|
+
}
|
|
4
10
|
declare const EmbroideryQCImage: React.FC<EmbroideryQCImageProps>;
|
|
11
|
+
export declare const generateEmbroideryQCImageBlob: (config: EmbroideryQCConfig, options?: EmbroideryQCImageRenderOptions) => Promise<Blob | null>;
|
|
12
|
+
export declare const generateEmbroideryQCImageData: (config: EmbroideryQCConfig, options?: EmbroideryQCImageRenderOptions) => Promise<string | null>;
|
|
5
13
|
export default EmbroideryQCImage;
|
|
6
14
|
//# sourceMappingURL=EmbroideryQCImage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"EmbroideryQCImage.d.ts","sourceRoot":"","sources":["../../src/components/EmbroideryQCImage.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAY,MAAM,UAAU,CAAC;AAChF,OAAO,yBAAyB,CAAC;AAwJjC,MAAM,WAAW,8BAA8B;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,YAAY,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA4WD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAqHvD,CAAC;AAkwBF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,IAAI,GAAG,IAAI,CAmBrB,CAAC;AAEF,eAAO,MAAM,6BAA6B,GACxC,QAAQ,kBAAkB,EAC1B,UAAS,8BAAmC,KAC3C,OAAO,CAAC,MAAM,GAAG,IAAI,CAmBvB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ interface Side {
|
|
|
21
21
|
}
|
|
22
22
|
interface EmbroideryQCConfig {
|
|
23
23
|
image_url?: string;
|
|
24
|
+
error_message?: string | null;
|
|
24
25
|
sides: Side[];
|
|
25
26
|
}
|
|
26
27
|
interface EmbroideryQCImageProps {
|
|
@@ -29,7 +30,15 @@ interface EmbroideryQCImageProps {
|
|
|
29
30
|
style?: React.CSSProperties;
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
interface EmbroideryQCImageRenderOptions {
|
|
34
|
+
width?: number;
|
|
35
|
+
height?: number;
|
|
36
|
+
mimeType?: "image/png" | "image/jpeg" | "image/webp";
|
|
37
|
+
quality?: number;
|
|
38
|
+
}
|
|
32
39
|
declare const EmbroideryQCImage: React$1.FC<EmbroideryQCImageProps>;
|
|
40
|
+
declare const generateEmbroideryQCImageBlob: (config: EmbroideryQCConfig, options?: EmbroideryQCImageRenderOptions) => Promise<Blob | null>;
|
|
41
|
+
declare const generateEmbroideryQCImageData: (config: EmbroideryQCConfig, options?: EmbroideryQCImageRenderOptions) => Promise<string | null>;
|
|
33
42
|
|
|
34
|
-
export { EmbroideryQCImage };
|
|
35
|
-
export type { EmbroideryQCConfig, EmbroideryQCImageProps, IconPosition, Position, Side, TextPosition };
|
|
43
|
+
export { EmbroideryQCImage, generateEmbroideryQCImageBlob, generateEmbroideryQCImageData };
|
|
44
|
+
export type { EmbroideryQCConfig, EmbroideryQCImageProps, EmbroideryQCImageRenderOptions, IconPosition, Position, Side, TextPosition };
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,6BAA6B,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAC9G,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC"}
|