ablok-photobooth 0.2.38 → 0.2.40
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/ablok-photobooth.js +12 -0
- package/dist/chunks/color-booth.vue_vue_type_style_index_0_lang-Cxo8ZMRt.js +98 -0
- package/dist/chunks/creative-booth.vue_vue_type_style_index_0_lang-BUDOTH0K.js +210 -0
- package/dist/chunks/fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js +318 -0
- package/dist/chunks/face-swap.vue_vue_type_style_index_0_lang-B0EJ4Q3T.js +229 -0
- package/dist/chunks/media-api-DcCOqndv.js +164 -0
- package/dist/chunks/photo-app.vue_vue_type_style_index_0_lang-CQsO0T0U.js +569 -0
- package/dist/color-booth.js +4 -0
- package/dist/creative-booth.js +6 -0
- package/dist/fabric-canvas.js +4 -0
- package/dist/face-swap.js +6 -0
- package/dist/photo-app.js +4 -0
- package/dist/{components → types/components}/photo-app.vue.d.ts +2 -2
- package/package.json +50 -11
- package/dist/App.vue.d.ts +0 -2
- package/dist/ablok-photobooth.es.js +0 -1545
- package/dist/ablok-photobooth.umd.js +0 -1
- package/dist/histoire.setup.d.ts +0 -1
- package/dist/i18n.d.ts +0 -77
- package/dist/main.d.ts +0 -0
- /package/dist/{api → types/api}/media-api.d.ts +0 -0
- /package/dist/{components → types/components}/color-booth.vue.d.ts +0 -0
- /package/dist/{components → types/components}/creative-booth.vue.d.ts +0 -0
- /package/dist/{components → types/components}/fabric-canvas.vue.d.ts +0 -0
- /package/dist/{components → types/components}/face-swap.vue.d.ts +0 -0
- /package/dist/{components → types/components}/svg-canvas.vue.d.ts +0 -0
- /package/dist/{index.d.ts → types/index.d.ts} +0 -0
- /package/dist/{locales → types/locales}/en.d.ts +0 -0
- /package/dist/{utilities → types/utilities}/idb-keyval.d.ts +0 -0
- /package/dist/{utilities → types/utilities}/indexed-db-api.d.ts +0 -0
- /package/dist/{utilities → types/utilities}/media-helpers.d.ts +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { _ as a } from "./chunks/photo-app.vue_vue_type_style_index_0_lang-CQsO0T0U.js";
|
|
2
|
+
import { _ as e } from "./chunks/fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js";
|
|
3
|
+
import { _ as s } from "./chunks/creative-booth.vue_vue_type_style_index_0_lang-BUDOTH0K.js";
|
|
4
|
+
import { _ as m } from "./chunks/face-swap.vue_vue_type_style_index_0_lang-B0EJ4Q3T.js";
|
|
5
|
+
import { _ } from "./chunks/color-booth.vue_vue_type_style_index_0_lang-Cxo8ZMRt.js";
|
|
6
|
+
export {
|
|
7
|
+
_ as ColorBooth,
|
|
8
|
+
s as CreativeBooth,
|
|
9
|
+
e as FabricCanvas,
|
|
10
|
+
m as FaceSwap,
|
|
11
|
+
a as PhotoApp
|
|
12
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { defineComponent as g, ref as d, openBlock as p, createElementBlock as v, normalizeClass as S, createElementVNode as V, normalizeStyle as w, computed as A, onBeforeMount as b, createVNode as c, withCtx as x } from "vue";
|
|
2
|
+
import B from "ablok-components/components/molecules/color-palette/color-palette.vue";
|
|
3
|
+
import E from "ablok-components/components/templates/touch-wrapper/touch-wrapper.vue";
|
|
4
|
+
const F = ["innerHTML"], _ = /* @__PURE__ */ g({
|
|
5
|
+
__name: "svg-canvas",
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: {
|
|
8
|
+
default: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg"/>',
|
|
9
|
+
type: String
|
|
10
|
+
},
|
|
11
|
+
scale: {
|
|
12
|
+
type: Number,
|
|
13
|
+
default: 1
|
|
14
|
+
},
|
|
15
|
+
fillColor: String,
|
|
16
|
+
groupedFill: Boolean
|
|
17
|
+
},
|
|
18
|
+
emits: ["update:modelValue"],
|
|
19
|
+
setup(t, { emit: u }) {
|
|
20
|
+
const l = t, i = u, s = d();
|
|
21
|
+
function a(n) {
|
|
22
|
+
const e = n.target;
|
|
23
|
+
if (!e.closest(".read-only")) {
|
|
24
|
+
if (l.groupedFill && l.fillColor) {
|
|
25
|
+
const y = e.closest("[data-group-class]").dataset.groupClass, m = e.closest("svg")?.querySelectorAll(`.${y}`);
|
|
26
|
+
m && Array.from(m).forEach((f) => {
|
|
27
|
+
f.setAttribute("fill", l.fillColor), f.setAttribute("fill-opacity", "1");
|
|
28
|
+
});
|
|
29
|
+
} else l.fillColor && (e.setAttribute("fill", l.fillColor), e.setAttribute("fill-opacity", "1"));
|
|
30
|
+
const C = e.closest(".svg-canvas").querySelector("svg").outerHTML;
|
|
31
|
+
i("update:modelValue", C);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return (n, e) => (p(), v("div", {
|
|
35
|
+
class: S(["svg-canvas", `${t.scale > 1 ? "overflow-scroll" : ""}`])
|
|
36
|
+
}, [
|
|
37
|
+
V("div", {
|
|
38
|
+
ref_key: "svg",
|
|
39
|
+
ref: s,
|
|
40
|
+
class: "svg-wrapper",
|
|
41
|
+
innerHTML: t.modelValue,
|
|
42
|
+
style: w({ transform: `scale(${t.scale})` }),
|
|
43
|
+
onClick: e[0] || (e[0] = (o) => a(o))
|
|
44
|
+
}, null, 12, F)
|
|
45
|
+
], 2));
|
|
46
|
+
}
|
|
47
|
+
}), $ = { class: "svg-editor" }, k = { class: "svg-editor__frame" }, H = /* @__PURE__ */ g({
|
|
48
|
+
__name: "color-booth",
|
|
49
|
+
props: {
|
|
50
|
+
modelValue: String,
|
|
51
|
+
name: String,
|
|
52
|
+
src: String,
|
|
53
|
+
required: Boolean,
|
|
54
|
+
colors: Array,
|
|
55
|
+
groupedFill: Boolean
|
|
56
|
+
},
|
|
57
|
+
emits: ["update:modelValue"],
|
|
58
|
+
setup(t, { emit: u }) {
|
|
59
|
+
const l = t, i = u, s = d(""), a = d(1), n = A({
|
|
60
|
+
get() {
|
|
61
|
+
return l.modelValue;
|
|
62
|
+
},
|
|
63
|
+
set(e) {
|
|
64
|
+
i("update:modelValue", e);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
return b(() => {
|
|
68
|
+
s.value = l.colors?.length ? l.colors[0] : "";
|
|
69
|
+
}), (e, o) => (p(), v("div", $, [
|
|
70
|
+
V("div", k, [
|
|
71
|
+
c(E, {
|
|
72
|
+
modelValue: a.value,
|
|
73
|
+
"onUpdate:modelValue": o[1] || (o[1] = (r) => a.value = r)
|
|
74
|
+
}, {
|
|
75
|
+
default: x(() => [
|
|
76
|
+
c(_, {
|
|
77
|
+
modelValue: n.value,
|
|
78
|
+
"onUpdate:modelValue": o[0] || (o[0] = (r) => n.value = r),
|
|
79
|
+
fillColor: s.value,
|
|
80
|
+
scale: a.value,
|
|
81
|
+
"grouped-fill": t.groupedFill
|
|
82
|
+
}, null, 8, ["modelValue", "fillColor", "scale", "grouped-fill"])
|
|
83
|
+
]),
|
|
84
|
+
_: 1
|
|
85
|
+
}, 8, ["modelValue"]),
|
|
86
|
+
c(B, {
|
|
87
|
+
modelValue: s.value,
|
|
88
|
+
"onUpdate:modelValue": o[2] || (o[2] = (r) => s.value = r),
|
|
89
|
+
colors: t.colors,
|
|
90
|
+
class: "mt-2"
|
|
91
|
+
}, null, 8, ["modelValue", "colors"])
|
|
92
|
+
])
|
|
93
|
+
]));
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
export {
|
|
97
|
+
H as _
|
|
98
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { defineComponent as S, ref as d, computed as l, watch as T, openBlock as u, createElementBlock as g, createElementVNode as v, createVNode as M, normalizeClass as V, createCommentVNode as h, createBlock as B } from "vue";
|
|
2
|
+
import x from "ablok-components/components/molecules/media-thumbnails/media-thumbnails.vue";
|
|
3
|
+
import { _ as D } from "./fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js";
|
|
4
|
+
const A = { class: "creative-booth" }, O = { class: "media-container" }, w = ["innerHTML"], C = { class: "creative-booth__thumbnails" }, F = [
|
|
5
|
+
{
|
|
6
|
+
type: "background",
|
|
7
|
+
thumbnail: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
|
|
8
|
+
src: "/themes/corp/backgrounds/corporate-your-background-1024x1024.jpg",
|
|
9
|
+
mediaType: "image",
|
|
10
|
+
filters: ["asset-01", "asset-02"]
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
type: "background",
|
|
14
|
+
thumbnail: "/themes/corp/backgrounds/corp-background-09-white.jpg",
|
|
15
|
+
src: "/themes/corp/backgrounds/corp-background-09-white.jpg",
|
|
16
|
+
mediaType: "image",
|
|
17
|
+
filters: ["asset-01", "asset-02"]
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
type: "overlay",
|
|
21
|
+
src: "/themes/corp/overlays/corporate-your-overlay-1024x1024.png",
|
|
22
|
+
mediaType: "image",
|
|
23
|
+
filters: ["asset-01"]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: "overlay",
|
|
27
|
+
src: "/themes/corp/overlays/corp-overlay-02-white.png",
|
|
28
|
+
mediaType: "image",
|
|
29
|
+
filters: ["asset-01"]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: "object",
|
|
33
|
+
src: "/themes/corp/stickers/corporate-your-sticker-512x512.svg",
|
|
34
|
+
mediaType: "svg",
|
|
35
|
+
filters: ["asset-02"]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: "object",
|
|
39
|
+
src: "/themes/corp/stickers/corp-sticker-01.svg",
|
|
40
|
+
mediaType: "svg"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "object",
|
|
44
|
+
src: "/themes/corp/stickers/corp-sticker-02.svg",
|
|
45
|
+
mediaType: "svg",
|
|
46
|
+
filters: ["asset-01", "asset-02"]
|
|
47
|
+
}
|
|
48
|
+
], U = /* @__PURE__ */ S({
|
|
49
|
+
__name: "creative-booth",
|
|
50
|
+
props: {
|
|
51
|
+
modelValue: {
|
|
52
|
+
default: null
|
|
53
|
+
},
|
|
54
|
+
jsonModel: {
|
|
55
|
+
type: null,
|
|
56
|
+
default: void 0
|
|
57
|
+
},
|
|
58
|
+
config: {
|
|
59
|
+
type: Object,
|
|
60
|
+
default: null
|
|
61
|
+
},
|
|
62
|
+
feature: {
|
|
63
|
+
type: String,
|
|
64
|
+
default: ""
|
|
65
|
+
},
|
|
66
|
+
required: {
|
|
67
|
+
type: Boolean,
|
|
68
|
+
default: !1
|
|
69
|
+
},
|
|
70
|
+
variant: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: "light"
|
|
73
|
+
},
|
|
74
|
+
messages: {
|
|
75
|
+
type: Object,
|
|
76
|
+
default: {}
|
|
77
|
+
},
|
|
78
|
+
assets: {
|
|
79
|
+
type: Array,
|
|
80
|
+
default: () => F
|
|
81
|
+
},
|
|
82
|
+
assetFilters: {
|
|
83
|
+
type: Array,
|
|
84
|
+
default: () => []
|
|
85
|
+
},
|
|
86
|
+
exportToSvg: {
|
|
87
|
+
type: Boolean,
|
|
88
|
+
default: !1
|
|
89
|
+
},
|
|
90
|
+
resetState: {
|
|
91
|
+
type: Boolean,
|
|
92
|
+
default: !1
|
|
93
|
+
},
|
|
94
|
+
ratio: {
|
|
95
|
+
type: String,
|
|
96
|
+
default: "4x3"
|
|
97
|
+
},
|
|
98
|
+
themeData: {
|
|
99
|
+
type: Object,
|
|
100
|
+
default: () => ({})
|
|
101
|
+
},
|
|
102
|
+
autoSelect: Number,
|
|
103
|
+
ready: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: !1
|
|
106
|
+
},
|
|
107
|
+
pending: {
|
|
108
|
+
type: Boolean,
|
|
109
|
+
default: !1
|
|
110
|
+
},
|
|
111
|
+
emitPending: {
|
|
112
|
+
type: Boolean,
|
|
113
|
+
default: !1
|
|
114
|
+
},
|
|
115
|
+
animationDuration: {
|
|
116
|
+
type: Number,
|
|
117
|
+
default: 320
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
emits: ["update:modelValue", "update:jsonModel", "update:ready", "update:pending"],
|
|
121
|
+
setup(s, { emit: b }) {
|
|
122
|
+
const a = s, o = b, r = d(), k = d(), c = d(!1), i = l(
|
|
123
|
+
() => a.assetFilters && a.assetFilters.length > 0 ? a.assets.filter((e) => !e.filters || e.filters.length == 0 || a.assetFilters.some((t) => e.filters.includes(t))) : a.assets
|
|
124
|
+
), m = l({
|
|
125
|
+
get() {
|
|
126
|
+
return a.modelValue;
|
|
127
|
+
},
|
|
128
|
+
set(e) {
|
|
129
|
+
o("update:modelValue", e);
|
|
130
|
+
}
|
|
131
|
+
}), p = l({
|
|
132
|
+
get() {
|
|
133
|
+
return a.jsonModel;
|
|
134
|
+
},
|
|
135
|
+
set(e) {
|
|
136
|
+
o("update:jsonModel", e);
|
|
137
|
+
}
|
|
138
|
+
}), f = l({
|
|
139
|
+
get() {
|
|
140
|
+
return a.pending;
|
|
141
|
+
},
|
|
142
|
+
set(e) {
|
|
143
|
+
a.ready && o("update:pending", e);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
T(k, async (e, t) => {
|
|
147
|
+
e && e !== t && o("update:modelValue", e);
|
|
148
|
+
}, { deep: !0 });
|
|
149
|
+
function y(e) {
|
|
150
|
+
if (typeof e < "u") {
|
|
151
|
+
const t = i.value[e];
|
|
152
|
+
switch (t.type) {
|
|
153
|
+
case "background":
|
|
154
|
+
r.value?.setBackgroundImage(t);
|
|
155
|
+
break;
|
|
156
|
+
case "overlay":
|
|
157
|
+
r.value.setOverlayImage(t);
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
r.value.addCanvasObject(t);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const j = (async () => {
|
|
165
|
+
if (c.value = !0, a.autoSelect !== void 0) {
|
|
166
|
+
const e = a.autoSelect >= 0 ? a.autoSelect : Math.floor(Math.random() * i.value.length);
|
|
167
|
+
y(e);
|
|
168
|
+
}
|
|
169
|
+
o("update:ready", !0);
|
|
170
|
+
});
|
|
171
|
+
return (e, t) => (u(), g("div", A, [
|
|
172
|
+
v("div", O, [
|
|
173
|
+
M(D, {
|
|
174
|
+
modelValue: m.value,
|
|
175
|
+
"onUpdate:modelValue": t[0] || (t[0] = (n) => m.value = n),
|
|
176
|
+
"json-model": p.value,
|
|
177
|
+
"onUpdate:jsonModel": t[1] || (t[1] = (n) => p.value = n),
|
|
178
|
+
pending: f.value,
|
|
179
|
+
"onUpdate:pending": t[2] || (t[2] = (n) => f.value = n),
|
|
180
|
+
ref_key: "canvas",
|
|
181
|
+
ref: r,
|
|
182
|
+
"reset-state": s.resetState,
|
|
183
|
+
options: { themeData: s.themeData },
|
|
184
|
+
feature: s.feature,
|
|
185
|
+
required: s.required,
|
|
186
|
+
class: V(`${s.ratio ? `aspect-ratio aspect-ratio--${s.ratio}` : ""}`),
|
|
187
|
+
onOnReady: j,
|
|
188
|
+
"emit-pending": s.emitPending,
|
|
189
|
+
"animation-duration": s.animationDuration
|
|
190
|
+
}, null, 8, ["modelValue", "json-model", "pending", "reset-state", "options", "feature", "required", "class", "emit-pending", "animation-duration"])
|
|
191
|
+
]),
|
|
192
|
+
s.messages.headline ? (u(), g("p", {
|
|
193
|
+
key: 0,
|
|
194
|
+
class: "headline",
|
|
195
|
+
innerHTML: s.messages.headline
|
|
196
|
+
}, null, 8, w)) : h("", !0),
|
|
197
|
+
v("div", C, [
|
|
198
|
+
c.value ? (u(), B(x, {
|
|
199
|
+
key: 0,
|
|
200
|
+
assets: i.value,
|
|
201
|
+
onSelect: y
|
|
202
|
+
}, null, 8, ["assets"])) : h("", !0)
|
|
203
|
+
])
|
|
204
|
+
]));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
export {
|
|
208
|
+
F as D,
|
|
209
|
+
U as _
|
|
210
|
+
};
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { defineComponent as Q, ref as j, watch as Z, onMounted as ee, openBlock as te, createElementBlock as ae, createElementVNode as B, renderSlot as oe } from "vue";
|
|
2
|
+
import { debounce as ne } from "lodash";
|
|
3
|
+
function C(s) {
|
|
4
|
+
return new Promise((c, l) => {
|
|
5
|
+
s.oncomplete = s.onsuccess = () => c(s.result), s.onabort = s.onerror = () => l(s.error);
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
function re(s, c) {
|
|
9
|
+
const l = indexedDB.open(s);
|
|
10
|
+
l.onupgradeneeded = () => l.result.createObjectStore(c);
|
|
11
|
+
const f = C(l);
|
|
12
|
+
return (p, y) => f.then(
|
|
13
|
+
(g) => y(g.transaction(c, p).objectStore(c))
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
let D;
|
|
17
|
+
function _() {
|
|
18
|
+
return D || (D = re("keyval-store", "keyval")), D;
|
|
19
|
+
}
|
|
20
|
+
function ie(s, c = _()) {
|
|
21
|
+
return c("readonly", (l) => C(l.get(s)));
|
|
22
|
+
}
|
|
23
|
+
function se(s, c, l = _()) {
|
|
24
|
+
return l("readwrite", (f) => (f.put(c, s), C(f.transaction)));
|
|
25
|
+
}
|
|
26
|
+
function le(s, c = _()) {
|
|
27
|
+
return c("readwrite", (l) => (l.delete(s), C(l.transaction)));
|
|
28
|
+
}
|
|
29
|
+
const ce = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23ffffffCC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='feather%20feather-rotate-cw'%3e%3cpolyline%20points='23%204%2023%2010%2017%2010'%3e%3c/polyline%3e%3cpath%20d='M20.49%2015a9%209%200%201%201-2.12-9.36L23%2010'%3e%3c/path%3e%3c/svg%3e", de = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='%23ffffffCC'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='feather%20feather-x-circle'%3e%3ccircle%20cx='12'%20cy='12'%20r='10'%20fill='none'%3e%3c/circle%3e%3cline%20x1='15'%20y1='9'%20x2='9'%20y2='15'%20fill='none'%3e%3c/line%3e%3cline%20x1='9'%20y1='9'%20x2='15'%20y2='15'%20fill='none'%3e%3c/line%3e%3c/svg%3e", ue = { class: "fabric-canvas__canvas" }, fe = {
|
|
30
|
+
id: "fabricCanvas",
|
|
31
|
+
ref: "canvasRef"
|
|
32
|
+
}, pe = /* @__PURE__ */ Q({
|
|
33
|
+
__name: "fabric-canvas",
|
|
34
|
+
props: {
|
|
35
|
+
modelValue: {
|
|
36
|
+
type: String,
|
|
37
|
+
default: ""
|
|
38
|
+
},
|
|
39
|
+
jsonModel: {
|
|
40
|
+
type: null,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
exportToSvg: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: !1
|
|
46
|
+
},
|
|
47
|
+
resetState: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: !1
|
|
50
|
+
},
|
|
51
|
+
options: {
|
|
52
|
+
type: Object,
|
|
53
|
+
default: () => ({})
|
|
54
|
+
},
|
|
55
|
+
feature: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: ""
|
|
58
|
+
},
|
|
59
|
+
required: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: !1
|
|
62
|
+
},
|
|
63
|
+
pending: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: !1
|
|
66
|
+
},
|
|
67
|
+
emitPending: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: !1
|
|
70
|
+
},
|
|
71
|
+
animationDuration: {
|
|
72
|
+
type: Number,
|
|
73
|
+
default: 0
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
emits: ["update:modelValue", "update:jsonModel", "update:pending", "on-ready"],
|
|
77
|
+
setup(s, { expose: c, emit: l }) {
|
|
78
|
+
let f, p, y, g, A, F, x, O;
|
|
79
|
+
const h = l;
|
|
80
|
+
c({ setBackgroundImage: M, setOverlayImage: Y, addCanvasObject: G });
|
|
81
|
+
const n = s, w = j(), d = j(0), u = j(0);
|
|
82
|
+
let a, R = !1;
|
|
83
|
+
const T = j();
|
|
84
|
+
async function H(e, t) {
|
|
85
|
+
return new Promise(async (o) => {
|
|
86
|
+
const r = JSON.parse(t);
|
|
87
|
+
if (r.backgroundImage) {
|
|
88
|
+
const i = await b(r.backgroundImage.src || r.backgroundImage.filename);
|
|
89
|
+
i.set({
|
|
90
|
+
opacity: 1
|
|
91
|
+
}), e.backgroundImage = i, e.centerObject(i);
|
|
92
|
+
}
|
|
93
|
+
if (r.overlayImage) {
|
|
94
|
+
const i = await b(r.overlayImage.src || r.overlayImage.filename);
|
|
95
|
+
i.set({
|
|
96
|
+
opacity: 1,
|
|
97
|
+
left: d.value / 2,
|
|
98
|
+
top: u.value / 2,
|
|
99
|
+
scaleX: d.value / i.width,
|
|
100
|
+
scaleY: u.value / i.height
|
|
101
|
+
}), e.overlayImage = i;
|
|
102
|
+
}
|
|
103
|
+
(await g.enlivenObjects(r.objects, {
|
|
104
|
+
reviver: void 0
|
|
105
|
+
})).forEach((i) => {
|
|
106
|
+
e.add(i);
|
|
107
|
+
}), o(e);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
async function b(e) {
|
|
111
|
+
const t = await U(e);
|
|
112
|
+
e.includes("data:image") || (t.filename = e);
|
|
113
|
+
const o = g.findScaleToCover(t, a), r = t instanceof p;
|
|
114
|
+
return t.set({
|
|
115
|
+
left: 0,
|
|
116
|
+
top: 0,
|
|
117
|
+
opacity: r && n.animationDuration > 0 ? 0 : 1,
|
|
118
|
+
scaleX: o,
|
|
119
|
+
scaleY: o,
|
|
120
|
+
src: e
|
|
121
|
+
}), t;
|
|
122
|
+
}
|
|
123
|
+
async function k(e) {
|
|
124
|
+
!(e instanceof p) || n.animationDuration === 0 || (n.emitPending && h("update:pending", !0), await new Promise((o) => {
|
|
125
|
+
const r = n.animationDuration, S = Date.now(), i = () => {
|
|
126
|
+
const I = Date.now() - S, m = Math.min(I / r, 1);
|
|
127
|
+
e.set("opacity", m), a.renderAll(), m < 1 ? requestAnimationFrame(i) : (n.emitPending && h("update:pending", !1), o());
|
|
128
|
+
};
|
|
129
|
+
requestAnimationFrame(i);
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
function V(e) {
|
|
133
|
+
const t = g.findScaleToCover(e, a);
|
|
134
|
+
return e.set({
|
|
135
|
+
scaleX: t,
|
|
136
|
+
scaleY: t
|
|
137
|
+
}), e;
|
|
138
|
+
}
|
|
139
|
+
async function M(e) {
|
|
140
|
+
const t = await b(e.src);
|
|
141
|
+
a.backgroundImage = t, a.centerObject(t), a.renderAll(), await k(t), v();
|
|
142
|
+
}
|
|
143
|
+
async function X(e) {
|
|
144
|
+
const t = await b(e.src);
|
|
145
|
+
t.selectable = !1, t.assetType = "foreground", a.add(t), a.centerObject(t), a.renderAll(), await k(t), v();
|
|
146
|
+
}
|
|
147
|
+
async function Y(e) {
|
|
148
|
+
const t = await b(e.src);
|
|
149
|
+
t.set({
|
|
150
|
+
left: d.value / 2,
|
|
151
|
+
top: u.value / 2,
|
|
152
|
+
scaleX: d.value / t.width,
|
|
153
|
+
scaleY: u.value / t.height
|
|
154
|
+
}), a.overlayImage = t, a.renderAll(), await k(t), v();
|
|
155
|
+
}
|
|
156
|
+
async function G(e) {
|
|
157
|
+
a.discardActiveObject();
|
|
158
|
+
const t = await U(e.src);
|
|
159
|
+
t.filename = e.src;
|
|
160
|
+
const o = d.value / 3, r = u.value / 3, S = o / t.width, i = r / t.height, I = Math.min(S, i);
|
|
161
|
+
t.set({
|
|
162
|
+
scaleX: I,
|
|
163
|
+
scaleY: I,
|
|
164
|
+
left: d.value / 2,
|
|
165
|
+
top: u.value / 2
|
|
166
|
+
}), t.id = e.id, t.padding = 8, a.add(t), a.setActiveObject(t), await k(t), a.renderAll();
|
|
167
|
+
}
|
|
168
|
+
function N(e, t) {
|
|
169
|
+
t.target.id;
|
|
170
|
+
const o = t.target;
|
|
171
|
+
return a.remove(o), a.requestRenderAll(), !0;
|
|
172
|
+
}
|
|
173
|
+
function P() {
|
|
174
|
+
if (d.value = w.value.offsetWidth, u.value = w.value.offsetHeight, a.setDimensions({ width: d.value, height: u.value }), a.backgroundImage && (a.backgroundImage = V(a.backgroundImage), a.centerObject(a.backgroundImage)), a.overlayImage) {
|
|
175
|
+
const e = a.overlayImage;
|
|
176
|
+
e.set({
|
|
177
|
+
scaleX: d.value / e.width,
|
|
178
|
+
scaleY: u.value / e.height
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
a.getObjects().forEach((e) => {
|
|
182
|
+
e.assetType === "foreground" && (e = V(e), a.centerObject(e));
|
|
183
|
+
}), a.renderAll();
|
|
184
|
+
}
|
|
185
|
+
const L = ne(() => {
|
|
186
|
+
P();
|
|
187
|
+
}, 200, { trailing: !0, leading: !1 });
|
|
188
|
+
function E(e) {
|
|
189
|
+
return (t, o, r, S, i) => {
|
|
190
|
+
t.save(), t.translate(o, r), t.rotate(g.degreesToRadians(i.angle)), t.fillStyle = n.options.themeData?.colors?.primary, t.fillRect(-24 / 2, -24 / 2, 24, 24);
|
|
191
|
+
const m = 20;
|
|
192
|
+
t.drawImage(e, -m / 2, -m / 2, m, m), t.restore();
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function W() {
|
|
196
|
+
const e = document.createElement("img");
|
|
197
|
+
e.src = ce;
|
|
198
|
+
const t = document.createElement("img");
|
|
199
|
+
t.src = de, a.on("object:added", (o) => {
|
|
200
|
+
o.target && o.target.controls && (o.target.set({
|
|
201
|
+
transparentCorners: !1,
|
|
202
|
+
cornerSize: 16,
|
|
203
|
+
cornerStyle: "circle",
|
|
204
|
+
...n.options.themeData?.colors?.primary ? {
|
|
205
|
+
cornerColor: n.options.themeData?.colors?.primary,
|
|
206
|
+
cornerStrokeColor: n.options.themeData?.colors?.primary,
|
|
207
|
+
borderColor: n.options.themeData?.colors?.primary
|
|
208
|
+
} : {}
|
|
209
|
+
}), o.target.controls.ml.visible = !1, o.target.controls.mr.visible = !1, o.target.controls.mb.visible = !1, o.target.controls.mt.visible = !1, o.target.controls.mtr.visible = !1, o.target.controls.rotate = new y({
|
|
210
|
+
x: 0.5,
|
|
211
|
+
y: -0.5,
|
|
212
|
+
offsetX: 32,
|
|
213
|
+
offsetY: 0,
|
|
214
|
+
cursorStyle: "pointer",
|
|
215
|
+
actionName: "rotate",
|
|
216
|
+
actionHandler: O.rotationWithSnapping,
|
|
217
|
+
cursorStyleHandler: O.rotationStyleHandler,
|
|
218
|
+
render: E(e)
|
|
219
|
+
}), o.target.controls.delete = new y({
|
|
220
|
+
x: 0.5,
|
|
221
|
+
y: -0.5,
|
|
222
|
+
offsetX: 32,
|
|
223
|
+
offsetY: 32,
|
|
224
|
+
cursorStyle: "pointer",
|
|
225
|
+
mouseUpHandler: N,
|
|
226
|
+
render: E(t)
|
|
227
|
+
}));
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
async function q() {
|
|
231
|
+
return await new Promise((e) => {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
const t = n.exportToSvg ? a.toSVG() : a.toDataURL({ multiplier: 2 });
|
|
234
|
+
e(t);
|
|
235
|
+
}, 200);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
function v() {
|
|
239
|
+
setTimeout(async () => {
|
|
240
|
+
const e = a.toDatalessJSON(["selectable", "assetType", "filename"]);
|
|
241
|
+
await se("fabric-canvas", JSON.stringify(e));
|
|
242
|
+
let t = !0;
|
|
243
|
+
if (n.required)
|
|
244
|
+
switch (t = !1, n.feature) {
|
|
245
|
+
case "overlay":
|
|
246
|
+
e.overlayImage && (t = !0);
|
|
247
|
+
break;
|
|
248
|
+
case "background":
|
|
249
|
+
e.backgroundImage && (t = !0);
|
|
250
|
+
break;
|
|
251
|
+
case "stickers":
|
|
252
|
+
e.objects.length > 1 && (t = !0);
|
|
253
|
+
break;
|
|
254
|
+
default:
|
|
255
|
+
(e.objects.length > 1 || e.backgroundImage || e.overlayImage) && (t = !0);
|
|
256
|
+
}
|
|
257
|
+
if (t) {
|
|
258
|
+
R = !0;
|
|
259
|
+
const o = await q();
|
|
260
|
+
h("update:modelValue", o), h("update:jsonModel", e);
|
|
261
|
+
}
|
|
262
|
+
}, 120);
|
|
263
|
+
}
|
|
264
|
+
async function J(e) {
|
|
265
|
+
try {
|
|
266
|
+
return await p.fromURL(e);
|
|
267
|
+
} catch (t) {
|
|
268
|
+
throw console.error("Error loading image:", t), t;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async function $(e) {
|
|
272
|
+
const { objects: t, options: o } = await A(e);
|
|
273
|
+
return g.groupSVGElements(t, o);
|
|
274
|
+
}
|
|
275
|
+
async function K(e) {
|
|
276
|
+
const { objects: t, options: o } = await F(e);
|
|
277
|
+
return g.groupSVGElements(t, o);
|
|
278
|
+
}
|
|
279
|
+
async function U(e) {
|
|
280
|
+
return e && typeof e == "string" && e.trim().startsWith("<") ? await K(e) : e && new RegExp(/([\w_/-]*\.svg$)|(image\/svg\+xml)/gi).test(e) ? await $(e) : await J(e);
|
|
281
|
+
}
|
|
282
|
+
async function z(e, t) {
|
|
283
|
+
e && !t && !R && X({ src: e });
|
|
284
|
+
}
|
|
285
|
+
return Z(() => n.modelValue, async (e, t) => {
|
|
286
|
+
z(e, t);
|
|
287
|
+
}), ee(async () => {
|
|
288
|
+
({ Canvas: f, FabricImage: p, Control: y, util: g, loadSVGFromURL: A, loadSVGFromString: F, config: x, controlsUtils: O } = await import("fabric")), d.value = w.value.offsetWidth, u.value = w.value.offsetHeight, window.addEventListener("resize", L), x.NUM_FRACTION_DIGITS = 8;
|
|
289
|
+
const e = f.prototype._onTouchStart;
|
|
290
|
+
f.prototype._onTouchStart = function(t) {
|
|
291
|
+
const o = this.findTarget(t);
|
|
292
|
+
this.allowTouchScrolling && o.assetType && !this.isDrawingMode || e.call(this, t);
|
|
293
|
+
}, a = new f("fabricCanvas", {
|
|
294
|
+
width: d.value,
|
|
295
|
+
height: u.value,
|
|
296
|
+
// enableRetinaScaling: false,
|
|
297
|
+
skipOffscreen: !0,
|
|
298
|
+
// devicePixelRatio: 4,
|
|
299
|
+
allowTouchScrolling: !0
|
|
300
|
+
// backstoreOnly: true
|
|
301
|
+
}), n.resetState && await le("fabric-canvas"), T.value = await ie("fabric-canvas"), T.value ? (await H(a, T.value), a.requestRenderAll(), requestAnimationFrame(() => {
|
|
302
|
+
a.renderAll();
|
|
303
|
+
})) : n.modelValue && z(n.modelValue, ""), a.on("object:added", v), a.on("object:removed", v), a.on("object:modified", v), W(), a.renderAll(), h("on-ready", a);
|
|
304
|
+
}), (e, t) => (te(), ae("div", {
|
|
305
|
+
class: "fabric-canvas",
|
|
306
|
+
ref_key: "root",
|
|
307
|
+
ref: w
|
|
308
|
+
}, [
|
|
309
|
+
B("div", ue, [
|
|
310
|
+
B("canvas", fe, null, 512)
|
|
311
|
+
]),
|
|
312
|
+
oe(e.$slots, "default")
|
|
313
|
+
], 512));
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
export {
|
|
317
|
+
pe as _
|
|
318
|
+
};
|