bsign-customization-full 0.0.5 → 0.0.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/{AppDemo2-DRug1ZYk.js → AppDemo2-DtXW6HLh.js} +1729 -1711
- package/dist/{index-BqhEkZ1q.js → index--fus9V0R.js} +2 -2
- package/dist/{index.es-BG7Zgq9X.js → index.es-IXkdxZEy.js} +2 -2
- package/dist/sign-constructor.es.js +1 -1
- package/dist/sign-constructor.iife.js +56 -56
- package/package.json +1 -1
- package/src/components/layers/layer-forms/material-form.tsx +2 -1
- package/src/components/layers/layer-forms/template-form.tsx +6 -1
- package/src/lib/asset-url.ts +1 -1
- package/src/lib/config.ts +49 -31
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getTemplateById, getTemplateMaterial } from "../../../lib/config"
|
|
2
|
+
import { resolveAssetUrl } from "../../../lib/asset-url"
|
|
2
3
|
import { useLayersStore } from "../../../store/layers-store"
|
|
3
4
|
|
|
4
5
|
export default function MaterialLayerForm() {
|
|
@@ -34,7 +35,7 @@ export default function MaterialLayerForm() {
|
|
|
34
35
|
>
|
|
35
36
|
{material.previewImage ? (
|
|
36
37
|
<img
|
|
37
|
-
src={material.previewImage}
|
|
38
|
+
src={resolveAssetUrl(material.previewImage)}
|
|
38
39
|
alt={material.label}
|
|
39
40
|
className="h-[72px] w-[72px] rounded-[8px] object-cover"
|
|
40
41
|
/>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getTemplateById, templateCatalog } from "../../../lib/config"
|
|
2
|
+
import { resolveAssetUrl } from "../../../lib/asset-url"
|
|
2
3
|
import { useLayersStore } from "../../../store/layers-store"
|
|
3
4
|
|
|
4
5
|
export default function TemplateLayerForm() {
|
|
@@ -23,7 +24,11 @@ export default function TemplateLayerForm() {
|
|
|
23
24
|
}`}
|
|
24
25
|
>
|
|
25
26
|
<div className="aspect-square w-full bg-[#EFEFEF]">
|
|
26
|
-
<img
|
|
27
|
+
<img
|
|
28
|
+
src={resolveAssetUrl(template.image)}
|
|
29
|
+
alt={template.name}
|
|
30
|
+
className="h-full w-full object-cover"
|
|
31
|
+
/>
|
|
27
32
|
</div>
|
|
28
33
|
<div className="space-y-1 px-3 py-2">
|
|
29
34
|
<p className="text-[14px] font-semibold text-[#111111]">{template.name}</p>
|
package/src/lib/asset-url.ts
CHANGED
|
@@ -6,7 +6,7 @@ const SPECIAL_PROTOCOL_PATTERN = /^(?:data|blob):/i
|
|
|
6
6
|
* Must be set explicitly from widget mount props:
|
|
7
7
|
* mountConstructorWidget(..., { assetBaseUrl: "https://your-cdn/path/to/dist/" })
|
|
8
8
|
*/
|
|
9
|
-
const DEFAULT_ASSET_BASE_URL = "/"
|
|
9
|
+
const DEFAULT_ASSET_BASE_URL = "http://localhost:5173/"
|
|
10
10
|
|
|
11
11
|
function toBaseUrl(url: string): string | undefined {
|
|
12
12
|
try {
|
package/src/lib/config.ts
CHANGED
|
@@ -86,12 +86,12 @@ export const getSizeLimitScale = (size: Pick<TSize, "cm">): number => {
|
|
|
86
86
|
|
|
87
87
|
const MODERN_BACKGROUND_ASSETS = {
|
|
88
88
|
rectangle: {
|
|
89
|
-
black:
|
|
90
|
-
white:
|
|
89
|
+
black: "/templates/assets/modern/rectangle-black.webp",
|
|
90
|
+
white: "/templates/assets/modern/rectangle-white.webp",
|
|
91
91
|
},
|
|
92
92
|
square: {
|
|
93
|
-
black:
|
|
94
|
-
white:
|
|
93
|
+
black: "/templates/assets/modern/square-black.webp",
|
|
94
|
+
white: "/templates/assets/modern/square-white.webp",
|
|
95
95
|
},
|
|
96
96
|
} as const;
|
|
97
97
|
|
|
@@ -200,38 +200,38 @@ const WAVE_MATERIALS = [
|
|
|
200
200
|
{
|
|
201
201
|
id: "anthracite-gray",
|
|
202
202
|
label: "Anthracite Gray",
|
|
203
|
-
previewImage:
|
|
204
|
-
image:
|
|
203
|
+
previewImage: "/colors/anthracite-gray_50x50.png",
|
|
204
|
+
image: "/colors/anthracite-gray.webp",
|
|
205
205
|
},
|
|
206
206
|
{
|
|
207
207
|
id: "indian-rosewood",
|
|
208
208
|
label: "Indian Rosewood",
|
|
209
|
-
previewImage:
|
|
210
|
-
image:
|
|
209
|
+
previewImage: "/colors/indian-rosewood_50x50.png",
|
|
210
|
+
image: "/colors/indian-rosewood.webp",
|
|
211
211
|
},
|
|
212
212
|
{
|
|
213
213
|
id: "natural-wood",
|
|
214
214
|
label: "Natural Wood",
|
|
215
|
-
previewImage:
|
|
216
|
-
image:
|
|
215
|
+
previewImage: "/colors/natural-wood_50x50.png",
|
|
216
|
+
image: "/colors/natural-wood.webp",
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
id: "walnut",
|
|
220
220
|
label: "Walnut",
|
|
221
|
-
previewImage:
|
|
222
|
-
image:
|
|
221
|
+
previewImage: "/colors/walnut_50x50.png",
|
|
222
|
+
image: "/colors/walnut.webp",
|
|
223
223
|
},
|
|
224
224
|
{
|
|
225
225
|
id: "redwood",
|
|
226
226
|
label: "Redwood",
|
|
227
|
-
previewImage:
|
|
228
|
-
image:
|
|
227
|
+
previewImage: "/colors/redwood_50x50.png",
|
|
228
|
+
image: "/colors/redwood.webp",
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
id: "dark-wenge",
|
|
232
232
|
label: "Dark Wenge",
|
|
233
|
-
previewImage:
|
|
234
|
-
image:
|
|
233
|
+
previewImage: "/colors/dark-wenge_50x50.png",
|
|
234
|
+
image: "/colors/dark-wenge.webp",
|
|
235
235
|
},
|
|
236
236
|
] as const;
|
|
237
237
|
|
|
@@ -243,8 +243,12 @@ export const colors: Array<{
|
|
|
243
243
|
}> = WAVE_MATERIALS.map((material) => ({
|
|
244
244
|
id: material.id,
|
|
245
245
|
label: material.label,
|
|
246
|
-
smallImage
|
|
247
|
-
|
|
246
|
+
get smallImage() {
|
|
247
|
+
return resolveAssetUrl(material.previewImage);
|
|
248
|
+
},
|
|
249
|
+
get image() {
|
|
250
|
+
return resolveAssetUrl(material.image);
|
|
251
|
+
},
|
|
248
252
|
}));
|
|
249
253
|
|
|
250
254
|
const getSignCenter = (size: TSize) => ({
|
|
@@ -261,13 +265,23 @@ const getMaterialBackground = ({
|
|
|
261
265
|
shapeId: string;
|
|
262
266
|
size: TSize;
|
|
263
267
|
}): string => {
|
|
264
|
-
|
|
265
|
-
|
|
268
|
+
const backgroundPath = material.getBackgroundSrc
|
|
269
|
+
? material.getBackgroundSrc({ shapeId, size })
|
|
270
|
+
: material.backgroundByShape[shapeId];
|
|
271
|
+
|
|
272
|
+
if (!backgroundPath) {
|
|
273
|
+
return backgroundPath;
|
|
266
274
|
}
|
|
267
275
|
|
|
268
|
-
return
|
|
276
|
+
return resolveAssetUrl(backgroundPath);
|
|
269
277
|
};
|
|
270
278
|
|
|
279
|
+
const getTemplateImage = (template: TemplateDefinition): string =>
|
|
280
|
+
resolveAssetUrl(template.image);
|
|
281
|
+
|
|
282
|
+
const getShapePreviewImage = (shape: TemplateShape): string | undefined =>
|
|
283
|
+
shape.previewImage ? resolveAssetUrl(shape.previewImage) : undefined;
|
|
284
|
+
|
|
271
285
|
const createTextLayers = ({
|
|
272
286
|
size,
|
|
273
287
|
textColor,
|
|
@@ -401,7 +415,7 @@ const modernTemplate: TemplateDefinition = {
|
|
|
401
415
|
const waveTemplate: TemplateDefinition = {
|
|
402
416
|
id: "wave",
|
|
403
417
|
name: "Wave",
|
|
404
|
-
image:
|
|
418
|
+
image: "/templates/wave.webp",
|
|
405
419
|
textFont: "font-bebasneue",
|
|
406
420
|
defaultShapeId: "square",
|
|
407
421
|
defaultMaterialId: "anthracite-gray",
|
|
@@ -411,7 +425,7 @@ const waveTemplate: TemplateDefinition = {
|
|
|
411
425
|
id: "square",
|
|
412
426
|
label: "Square",
|
|
413
427
|
sizes: SQUARE_SIZES,
|
|
414
|
-
previewImage:
|
|
428
|
+
previewImage: "/templates/wave.webp",
|
|
415
429
|
},
|
|
416
430
|
],
|
|
417
431
|
materials: WAVE_MATERIALS.map((material) => ({
|
|
@@ -584,7 +598,7 @@ export const getTemplateShapePreview = ({
|
|
|
584
598
|
material,
|
|
585
599
|
shapeId: shape.id,
|
|
586
600
|
size,
|
|
587
|
-
}) ?? shape
|
|
601
|
+
}) ?? getShapePreviewImage(shape);
|
|
588
602
|
};
|
|
589
603
|
|
|
590
604
|
export const resolveTemplateSelection = ({
|
|
@@ -714,13 +728,17 @@ export const templates: Array<{
|
|
|
714
728
|
return {
|
|
715
729
|
id: template.id,
|
|
716
730
|
name: template.name,
|
|
717
|
-
image
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
731
|
+
get image() {
|
|
732
|
+
return getTemplateImage(template);
|
|
733
|
+
},
|
|
734
|
+
get layers() {
|
|
735
|
+
return createTemplateLayers({
|
|
736
|
+
templateId: defaults.selectedTemplateId,
|
|
737
|
+
shapeId: defaults.selectedShapeId,
|
|
738
|
+
materialId: defaults.selectedMaterialId,
|
|
739
|
+
preferredSizeId: defaults.selectedSize.id,
|
|
740
|
+
});
|
|
741
|
+
},
|
|
724
742
|
};
|
|
725
743
|
});
|
|
726
744
|
|