ablok-photobooth 0.2.39 → 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.
Files changed (31) hide show
  1. package/dist/ablok-photobooth.js +12 -0
  2. package/dist/chunks/color-booth.vue_vue_type_style_index_0_lang-Cxo8ZMRt.js +98 -0
  3. package/dist/chunks/creative-booth.vue_vue_type_style_index_0_lang-BUDOTH0K.js +210 -0
  4. package/dist/chunks/fabric-canvas.vue_vue_type_style_index_0_lang-B-D65X2t.js +318 -0
  5. package/dist/chunks/face-swap.vue_vue_type_style_index_0_lang-B0EJ4Q3T.js +229 -0
  6. package/dist/chunks/media-api-DcCOqndv.js +164 -0
  7. package/dist/chunks/photo-app.vue_vue_type_style_index_0_lang-CQsO0T0U.js +569 -0
  8. package/dist/color-booth.js +4 -0
  9. package/dist/creative-booth.js +6 -0
  10. package/dist/fabric-canvas.js +4 -0
  11. package/dist/face-swap.js +6 -0
  12. package/dist/photo-app.js +4 -0
  13. package/dist/{components → types/components}/photo-app.vue.d.ts +2 -2
  14. package/package.json +50 -11
  15. package/dist/App.vue.d.ts +0 -2
  16. package/dist/ablok-photobooth.es.js +0 -1545
  17. package/dist/ablok-photobooth.umd.js +0 -1
  18. package/dist/histoire.setup.d.ts +0 -1
  19. package/dist/i18n.d.ts +0 -77
  20. package/dist/main.d.ts +0 -0
  21. /package/dist/{api → types/api}/media-api.d.ts +0 -0
  22. /package/dist/{components → types/components}/color-booth.vue.d.ts +0 -0
  23. /package/dist/{components → types/components}/creative-booth.vue.d.ts +0 -0
  24. /package/dist/{components → types/components}/fabric-canvas.vue.d.ts +0 -0
  25. /package/dist/{components → types/components}/face-swap.vue.d.ts +0 -0
  26. /package/dist/{components → types/components}/svg-canvas.vue.d.ts +0 -0
  27. /package/dist/{index.d.ts → types/index.d.ts} +0 -0
  28. /package/dist/{locales → types/locales}/en.d.ts +0 -0
  29. /package/dist/{utilities → types/utilities}/idb-keyval.d.ts +0 -0
  30. /package/dist/{utilities → types/utilities}/indexed-db-api.d.ts +0 -0
  31. /package/dist/{utilities → types/utilities}/media-helpers.d.ts +0 -0
@@ -0,0 +1,229 @@
1
+ import { defineComponent as S, ref as i, computed as u, watch as V, onBeforeMount as j, openBlock as t, createElementBlock as d, createElementVNode as f, normalizeClass as A, createVNode as p, Transition as B, withCtx as M, createBlock as g, createCommentVNode as b } from "vue";
2
+ import y from "ablok-components/components/atoms/base-image/base-image.vue";
3
+ import C from "ablok-components/components/atoms/loading-spinner/loading-spinner.vue";
4
+ import I from "ablok-components/components/molecules/media-thumbnails/media-thumbnails.vue";
5
+ import { r as L, M as U } from "./media-api-DcCOqndv.js";
6
+ const D = { class: "face-swap" }, E = { class: "position-relative" }, N = ["innerHTML"], x = { class: "face-swap__thumbnails" }, q = [
7
+ {
8
+ type: "target",
9
+ thumbnail: "/faceswap/robotroll._avengers_black_widow_fbe3e886-525d-4c8b-b46c-b32856fae2bf.png",
10
+ src: "/faceswap/robotroll._avengers_black_widow_fbe3e886-525d-4c8b-b46c-b32856fae2bf.png",
11
+ mediaType: "image",
12
+ filters: []
13
+ },
14
+ {
15
+ type: "target",
16
+ thumbnail: "/faceswap/robotroll._batmans_joker_04afa7d0-430d-43f2-a7ce-815c6875a793.png",
17
+ src: "/faceswap/robotroll._batmans_joker_04afa7d0-430d-43f2-a7ce-815c6875a793.png",
18
+ mediaType: "image",
19
+ filters: []
20
+ },
21
+ {
22
+ type: "target",
23
+ thumbnail: "/faceswap/robotroll._catwoman_922f1bfa-9197-4e9a-aaeb-bce5d413a9b9.png",
24
+ src: "/faceswap/robotroll._catwoman_922f1bfa-9197-4e9a-aaeb-bce5d413a9b9.png",
25
+ mediaType: "image",
26
+ filters: []
27
+ },
28
+ {
29
+ type: "target",
30
+ thumbnail: "/faceswap/robotroll._christian_bale_as_american_psycho_abe2d5ab-58e8-4f21-94f9-b2b117af3d89.png",
31
+ src: "/faceswap/robotroll._christian_bale_as_american_psycho_abe2d5ab-58e8-4f21-94f9-b2b117af3d89.png",
32
+ mediaType: "image",
33
+ filters: []
34
+ },
35
+ {
36
+ type: "target",
37
+ thumbnail: "/faceswap/robotroll._dirty_harry_7ce45595-edba-4ef8-a513-39b179d94f57.png",
38
+ src: "/faceswap/robotroll._dirty_harry_7ce45595-edba-4ef8-a513-39b179d94f57.png",
39
+ mediaType: "image",
40
+ filters: []
41
+ },
42
+ {
43
+ type: "target",
44
+ thumbnail: "/faceswap/robotroll._evil_santa_claus_pointing_a_double_barrel_shotgun_at_bf603686-4980-449b-ad88-e8f362850aab.png",
45
+ src: "/faceswap/robotroll._evil_santa_claus_pointing_a_double_barrel_shotgun_at_bf603686-4980-449b-ad88-e8f362850aab.png",
46
+ mediaType: "image",
47
+ filters: []
48
+ },
49
+ {
50
+ type: "target",
51
+ thumbnail: "/faceswap/robotroll._homer_simpson_as_real_person_b14628bf-5a5a-45fe-b35a-e56960de4ad4.png",
52
+ src: "/faceswap/robotroll._homer_simpson_as_real_person_b14628bf-5a5a-45fe-b35a-e56960de4ad4.png",
53
+ mediaType: "image",
54
+ filters: []
55
+ },
56
+ {
57
+ type: "target",
58
+ thumbnail: "/faceswap/robotroll._james_bond_caa0af54-16b2-4d15-9e4d-45cc395c021b.png",
59
+ src: "/faceswap/robotroll._james_bond_caa0af54-16b2-4d15-9e4d-45cc395c021b.png",
60
+ mediaType: "image",
61
+ filters: []
62
+ },
63
+ {
64
+ type: "target",
65
+ thumbnail: "/faceswap/robotroll._neil_gaimans_sandman_d3ca51cd-2ef8-46d5-b1db-1474789783a4.png",
66
+ src: "/faceswap/robotroll._neil_gaimans_sandman_d3ca51cd-2ef8-46d5-b1db-1474789783a4.png",
67
+ mediaType: "image",
68
+ filters: []
69
+ },
70
+ {
71
+ type: "target",
72
+ thumbnail: "/faceswap/robotroll._pennywise_3f4c5997-9fd2-43e0-ab9b-17384fb58da9.png",
73
+ src: "/faceswap/robotroll._pennywise_3f4c5997-9fd2-43e0-ab9b-17384fb58da9.png",
74
+ mediaType: "image",
75
+ filters: []
76
+ },
77
+ {
78
+ type: "target",
79
+ thumbnail: "/faceswap/robotroll._queen_of_hearts_8de84ac6-3f61-4981-ac92-c63d90d63890.png",
80
+ src: "/faceswap/robotroll._queen_of_hearts_8de84ac6-3f61-4981-ac92-c63d90d63890.png",
81
+ mediaType: "image",
82
+ filters: []
83
+ },
84
+ {
85
+ type: "target",
86
+ thumbnail: "/faceswap/robotroll._red_dead_redemptions_arthur_morgan_portrait_36f8a066-6c2b-4a23-9c5e-a2a3964b0d3b.png",
87
+ src: "/faceswap/robotroll._red_dead_redemptions_arthur_morgan_portrait_36f8a066-6c2b-4a23-9c5e-a2a3964b0d3b.png",
88
+ mediaType: "image",
89
+ filters: []
90
+ },
91
+ {
92
+ type: "target",
93
+ thumbnail: "/faceswap/robotroll._thanos_38adb80e-08ac-49d4-95e0-d4d11cb5a11d.png",
94
+ src: "/faceswap/robotroll._thanos_38adb80e-08ac-49d4-95e0-d4d11cb5a11d.png",
95
+ mediaType: "image",
96
+ filters: []
97
+ },
98
+ {
99
+ type: "target",
100
+ thumbnail: "/faceswap/robotroll._the_godfather_062db832-61ce-4d18-a09d-045cadd4e281.png",
101
+ src: "/faceswap/robotroll._the_godfather_062db832-61ce-4d18-a09d-045cadd4e281.png",
102
+ mediaType: "image",
103
+ filters: []
104
+ },
105
+ {
106
+ type: "target",
107
+ thumbnail: "/faceswap/robotroll._wolverine_3f9cece6-e490-4be8-a5f9-d6e6abf0440f.png",
108
+ src: "/faceswap/robotroll._wolverine_3f9cece6-e490-4be8-a5f9-d6e6abf0440f.png",
109
+ mediaType: "image",
110
+ filters: []
111
+ }
112
+ ], R = /* @__PURE__ */ S({
113
+ __name: "face-swap",
114
+ props: {
115
+ modelValue: {
116
+ default: null
117
+ },
118
+ config: {
119
+ type: Object,
120
+ default: null
121
+ },
122
+ variant: {
123
+ type: String,
124
+ default: "light"
125
+ },
126
+ messages: {
127
+ type: Object,
128
+ default: {}
129
+ },
130
+ assets: {
131
+ type: Array,
132
+ default: () => q
133
+ },
134
+ resetState: {
135
+ type: Boolean,
136
+ default: !1
137
+ },
138
+ ratio: {
139
+ type: String,
140
+ default: "4x3"
141
+ },
142
+ endpoint: {
143
+ type: String,
144
+ default: "/faceswap-json"
145
+ },
146
+ autoSelect: Number
147
+ },
148
+ emits: ["update:modelValue"],
149
+ setup(a, { emit: w }) {
150
+ const r = a, _ = w, o = i(), n = i(), s = i(), c = i(!1);
151
+ u({
152
+ get() {
153
+ return r.modelValue;
154
+ },
155
+ set(e) {
156
+ _("update:modelValue", e);
157
+ }
158
+ });
159
+ const m = u(() => s.value || o.value && o.value.src || n.value);
160
+ V(s, async (e, l) => {
161
+ e && e !== l && _("update:modelValue", e);
162
+ }, { deep: !0 });
163
+ function h(e) {
164
+ if (typeof e < "u") {
165
+ const l = r.assets[e];
166
+ o.value = l, s.value = null;
167
+ }
168
+ }
169
+ async function v() {
170
+ const e = await L(o.value.src), T = { dataUrl: r.modelValue, targetDataUrl: e };
171
+ c.value = !0;
172
+ const k = U;
173
+ s.value = await k.processImage(
174
+ r.endpoint,
175
+ T,
176
+ ""
177
+ ), c.value = !1;
178
+ }
179
+ return j(() => {
180
+ n.value = r.modelValue;
181
+ }), (e, l) => (t(), d("div", D, [
182
+ f("div", E, [
183
+ f("div", {
184
+ class: A(["media-container", `${a.ratio ? `ratio ratio-${a.ratio}` : ""}`])
185
+ }, [
186
+ p(B, {
187
+ name: "fade",
188
+ mode: "out-in"
189
+ }, {
190
+ default: M(() => [
191
+ (t(), d("div", { key: m.value }, [
192
+ p(y, { src: m.value }, null, 8, ["src"])
193
+ ]))
194
+ ]),
195
+ _: 1
196
+ })
197
+ ], 2),
198
+ o.value ? (t(), d("button", {
199
+ key: 0,
200
+ type: "button",
201
+ class: "btn face-swap__swap-face",
202
+ onClick: v
203
+ }, [
204
+ n.value && !s.value && !c.value ? (t(), g(y, {
205
+ key: 0,
206
+ src: n.value,
207
+ class: "img-thumbnail"
208
+ }, null, 8, ["src"])) : b("", !0)
209
+ ])) : b("", !0),
210
+ c.value ? (t(), g(C, { key: 1 })) : b("", !0)
211
+ ]),
212
+ a.messages.headline ? (t(), d("p", {
213
+ key: 0,
214
+ class: "headline",
215
+ innerHTML: a.messages.headline
216
+ }, null, 8, N)) : b("", !0),
217
+ f("div", x, [
218
+ p(I, {
219
+ assets: a.assets,
220
+ onSelect: h
221
+ }, null, 8, ["assets"])
222
+ ])
223
+ ]));
224
+ }
225
+ });
226
+ export {
227
+ q as D,
228
+ R as _
229
+ };
@@ -0,0 +1,164 @@
1
+ async function f(r) {
2
+ let t = await fetch(r, { mode: "no-cors" }).then((n) => n.blob());
3
+ return await new Promise((n) => {
4
+ let a = new FileReader();
5
+ a.onload = () => n(a.result), a.readAsDataURL(t);
6
+ });
7
+ }
8
+ async function m(r) {
9
+ return await new Promise((t) => {
10
+ let n = new FileReader();
11
+ n.onload = () => t(n.result), n.readAsDataURL(r);
12
+ });
13
+ }
14
+ function l(r) {
15
+ return new Promise((t, n) => {
16
+ const a = new Image();
17
+ a.onload = () => t(a), a.onerror = n, a.src = r;
18
+ });
19
+ }
20
+ function U(r, t = 0, n = 0) {
21
+ return new Promise((a, o) => {
22
+ const e = new Image();
23
+ e.crossOrigin = "anonymous", e.naturalWidth, e.naturalHeight, e.onload = () => {
24
+ const s = document.createElement("canvas"), i = s.getContext("2d");
25
+ s.width = t, s.height = e.height * t / e.width, i.drawImage(e, 0, 0, s.width, s.height);
26
+ const g = s.toDataURL();
27
+ a(g);
28
+ }, e.src = r;
29
+ });
30
+ }
31
+ function I(r, t = 1) {
32
+ return new Promise((n, a) => {
33
+ const o = new Image();
34
+ o.crossOrigin = "anonymous", o.onload = () => {
35
+ const e = o.naturalWidth, s = o.naturalHeight, i = e / s;
36
+ let g = e, h = s;
37
+ i > t ? g = s * t : i < t && (h = e / t);
38
+ const c = document.createElement("canvas");
39
+ c.width = g, c.height = h, c.getContext("2d").drawImage(o, c.width / 2 - o.width / 2, c.height / 2 - o.height / 2), n(c.toDataURL());
40
+ }, o.src = r;
41
+ });
42
+ }
43
+ const u = (r) => {
44
+ const t = new FileReader();
45
+ return new Promise((n) => {
46
+ t.onload = (a) => {
47
+ if (!a.target)
48
+ return n(0);
49
+ const o = a.target, e = new DataView(o.result);
50
+ if (e.getUint16(0, !1) != 65496)
51
+ return n(-2);
52
+ const s = e.byteLength;
53
+ let i = 2;
54
+ for (; i < s; ) {
55
+ if (e.getUint16(i + 2, !1) <= 8) return n(-1);
56
+ let g = e.getUint16(i, !1);
57
+ if (i += 2, g == 65505) {
58
+ if (e.getUint32(i += 2, !1) != 1165519206)
59
+ return n(-1);
60
+ let h = e.getUint16(i += 6, !1) == 18761;
61
+ i += e.getUint32(i + 4, h);
62
+ let c = e.getUint16(i, h);
63
+ i += 2;
64
+ for (let d = 0; d < c; d++)
65
+ if (e.getUint16(i + d * 12, h) == 274)
66
+ return n(e.getUint16(i + d * 12 + 8, h));
67
+ } else {
68
+ if ((g & 65280) != 65280)
69
+ break;
70
+ i += e.getUint16(i, !1);
71
+ }
72
+ }
73
+ return n(-1);
74
+ }, t.readAsArrayBuffer(r);
75
+ });
76
+ };
77
+ function w(r) {
78
+ let t = 0;
79
+ switch (r) {
80
+ // case 1:
81
+ // degree = 0;
82
+ // break;
83
+ // case 2:
84
+ // degree = 0;
85
+ // break;
86
+ // case 3:
87
+ // degree = 180;
88
+ // break;
89
+ // case 4:
90
+ // degree = 180;
91
+ // break;
92
+ // case 5:
93
+ // degree = 90;
94
+ // break;
95
+ // case 6:
96
+ // degree = 90;
97
+ // break;
98
+ // case 7:
99
+ // degree = 270;
100
+ // break;
101
+ // case 8:
102
+ // degree = 270;
103
+ // break;
104
+ case 3:
105
+ t = 180;
106
+ break;
107
+ case 6:
108
+ t = 90;
109
+ break;
110
+ case 8:
111
+ t = 270;
112
+ break;
113
+ default:
114
+ t = 0;
115
+ }
116
+ return t;
117
+ }
118
+ async function b(r) {
119
+ const t = await u(r);
120
+ return await w(t);
121
+ }
122
+ async function p(r, t) {
123
+ const n = await l(r), a = document.createElement("canvas"), o = a.getContext("2d");
124
+ return a.width = n.width, a.height = n.height, o.setTransform(1, 0, 0, 1, a.width / 2, a.height / 2), o.rotate(t), o.drawImage(n, -n.width / 2, -n.height / 2), a.toDataURL();
125
+ }
126
+ const y = {
127
+ // removeBg: async (endpoint: string, file: { dataUrl: string, resolution?: number }, basePath: string = '/media') => {
128
+ // const body = JSON.stringify({
129
+ // dataUrl: file.dataUrl,
130
+ // removeBackground: true
131
+ // });
132
+ // const response = await fetch(endpoint, {
133
+ // headers: {
134
+ // 'Content-Type': 'application/json'
135
+ // },
136
+ // method: 'POST',
137
+ // body
138
+ // })
139
+ // .then((response) => response.json())
140
+ // .catch((error) => [ error ]);
141
+ // return await response.dataUrl;
142
+ // },
143
+ processImage: async (r, t, n = "/media") => {
144
+ const a = JSON.stringify({
145
+ ...t
146
+ });
147
+ return await (await fetch(r, {
148
+ headers: {
149
+ "Content-Type": "application/json"
150
+ },
151
+ method: "POST",
152
+ body: a
153
+ }).then((e) => e.json()).catch((e) => [e])).dataUrl;
154
+ }
155
+ };
156
+ export {
157
+ y as M,
158
+ p as a,
159
+ U as b,
160
+ I as c,
161
+ m as f,
162
+ b as g,
163
+ f as r
164
+ };