ablok-components 0.3.128 → 0.3.131
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-components.css +1 -1
- package/dist/ablok-components.umd.js +2 -2
- package/dist/components/atoms/canvas-confetti/canvas-confetti.vue.d.ts +1 -1
- package/dist/components/molecules/base-camera/base-camera.js +5 -4
- package/dist/components/molecules/base-camera/base-camera.vue.d.ts +204 -66
- package/dist/components/molecules/base-camera/base-camera.vue_vue_type_script_setup_true_lang.js +410 -0
- package/dist/components/molecules/base-map/base-map.vue.d.ts +2 -2
- package/dist/components/molecules/camera-preview/camera-preview.js +7 -0
- package/dist/components/molecules/camera-preview/camera-preview.vue.d.ts +32 -0
- package/dist/components/molecules/camera-preview/camera-preview.vue_vue_type_script_setup_true_lang.js +67 -0
- package/dist/components/molecules/popover-tooltip/popover-tooltip.vue.d.ts +1 -1
- package/dist/composables/useCamera.d.ts +37 -0
- package/dist/composables/useCamera.js +44 -0
- package/dist/index.js +34 -34
- package/dist/symbol-defs.svg +6 -0
- package/dist/utilities/camera/CameraManager.d.ts +91 -0
- package/dist/utilities/camera/CameraManager.js +345 -0
- package/dist/utilities/camera/capture.d.ts +35 -0
- package/dist/utilities/camera/capture.js +82 -0
- package/dist/utilities/camera/constraints.d.ts +29 -0
- package/dist/utilities/camera/constraints.js +96 -0
- package/dist/utilities/camera/platform.d.ts +11 -0
- package/dist/utilities/camera/platform.js +20 -0
- package/dist/utilities/camera/types.d.ts +48 -0
- package/dist/utilities/camera/types.js +9 -0
- package/dist/utilities/helpers.js +10 -15
- package/package.json +1 -1
- package/dist/components/molecules/base-camera/base-camera.vue_vue_type_script_async_true_setup_true_lang.js +0 -537
|
@@ -1,537 +0,0 @@
|
|
|
1
|
-
import e from "../../atoms/svg-icon/svg-icon.js";
|
|
2
|
-
import t from "../../atoms/loading-spinner/loading-spinner.js";
|
|
3
|
-
import { dataURItoBlob as n } from "../../../utilities/helpers.js";
|
|
4
|
-
import r from "../input-dropdown/input-dropdown.js";
|
|
5
|
-
import { useCameraFilter as i } from "../../../composables/useCameraFilter.js";
|
|
6
|
-
import a from "../../atoms/zoom-slider/zoom-slider.js";
|
|
7
|
-
import o from "../../../assets/img/guide.js";
|
|
8
|
-
import { computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createVNode as f, defineComponent as p, nextTick as ee, normalizeClass as m, normalizeStyle as te, onBeforeUnmount as ne, onMounted as re, openBlock as h, ref as g, toDisplayString as _, vShow as ie, watch as ae, withCtx as oe, withDirectives as se, withModifiers as ce } from "vue";
|
|
9
|
-
import le from "lodash";
|
|
10
|
-
//#region src/components/molecules/base-camera/base-camera.vue?vue&type=script&async=true&setup=true&lang.ts
|
|
11
|
-
var ue = { class: "camera__preview" }, de = {
|
|
12
|
-
key: 0,
|
|
13
|
-
class: "camera__bg-notification"
|
|
14
|
-
}, fe = ["innerHTML"], pe = ["width", "height"], me = {
|
|
15
|
-
key: 1,
|
|
16
|
-
class: "camera__countdown-overlay"
|
|
17
|
-
}, he = ["innerHTML", "data-countdown"], ge = ["src"], _e = {
|
|
18
|
-
key: 3,
|
|
19
|
-
class: "camera__zoom-slider"
|
|
20
|
-
}, ve = { class: "camera__controls" }, ye = { class: "container" }, be = { class: "row" }, xe = { class: "col" }, Se = { class: "btn-group" }, Ce = { key: 0 }, we = { key: 1 }, Te = {
|
|
21
|
-
key: 0,
|
|
22
|
-
class: "camera__select-device"
|
|
23
|
-
}, Ee = { class: "col" }, De = { class: "" }, Oe = {
|
|
24
|
-
name: "BaseCamera",
|
|
25
|
-
inheritAttrs: !1
|
|
26
|
-
}, ke = {
|
|
27
|
-
"1x1": {
|
|
28
|
-
width: 720,
|
|
29
|
-
height: 720
|
|
30
|
-
},
|
|
31
|
-
"2x3": {
|
|
32
|
-
width: 720,
|
|
33
|
-
height: 1080
|
|
34
|
-
},
|
|
35
|
-
"3x2": {
|
|
36
|
-
width: 1080,
|
|
37
|
-
height: 720
|
|
38
|
-
},
|
|
39
|
-
"3x4": {
|
|
40
|
-
width: 720,
|
|
41
|
-
height: 960
|
|
42
|
-
},
|
|
43
|
-
"4x3": {
|
|
44
|
-
width: 960,
|
|
45
|
-
height: 720
|
|
46
|
-
},
|
|
47
|
-
"4x5": {
|
|
48
|
-
width: 960,
|
|
49
|
-
height: 1200
|
|
50
|
-
},
|
|
51
|
-
"5x4": {
|
|
52
|
-
width: 1200,
|
|
53
|
-
height: 960
|
|
54
|
-
},
|
|
55
|
-
"16x9": {
|
|
56
|
-
width: 1280,
|
|
57
|
-
height: 720
|
|
58
|
-
},
|
|
59
|
-
"9x16": {
|
|
60
|
-
width: 720,
|
|
61
|
-
height: 1280
|
|
62
|
-
}
|
|
63
|
-
}, Ae = /*@__PURE__*/ p({
|
|
64
|
-
...Oe,
|
|
65
|
-
props: {
|
|
66
|
-
modelValue: { type: null },
|
|
67
|
-
enableSwitchCamera: {
|
|
68
|
-
type: Boolean,
|
|
69
|
-
default: !0
|
|
70
|
-
},
|
|
71
|
-
defaultRearCamera: {
|
|
72
|
-
type: Boolean,
|
|
73
|
-
default: !1
|
|
74
|
-
},
|
|
75
|
-
enableMirrorCamera: {
|
|
76
|
-
type: Boolean,
|
|
77
|
-
default: !1
|
|
78
|
-
},
|
|
79
|
-
enableGuide: {
|
|
80
|
-
type: Boolean,
|
|
81
|
-
default: !0
|
|
82
|
-
},
|
|
83
|
-
guideSrc: {
|
|
84
|
-
type: String,
|
|
85
|
-
default: () => o
|
|
86
|
-
},
|
|
87
|
-
countdown: {
|
|
88
|
-
type: Number,
|
|
89
|
-
default: 0
|
|
90
|
-
},
|
|
91
|
-
ratio: {
|
|
92
|
-
type: String,
|
|
93
|
-
default: ""
|
|
94
|
-
},
|
|
95
|
-
filter: {
|
|
96
|
-
type: String,
|
|
97
|
-
default: "none",
|
|
98
|
-
validator: (e) => [
|
|
99
|
-
"none",
|
|
100
|
-
"grayscale",
|
|
101
|
-
"sepia"
|
|
102
|
-
].includes(e)
|
|
103
|
-
},
|
|
104
|
-
tintColor: {
|
|
105
|
-
type: String,
|
|
106
|
-
default: ""
|
|
107
|
-
},
|
|
108
|
-
tintIntensity: {
|
|
109
|
-
type: Number,
|
|
110
|
-
default: .3
|
|
111
|
-
},
|
|
112
|
-
enableAudio: {
|
|
113
|
-
type: Boolean,
|
|
114
|
-
default: !1
|
|
115
|
-
},
|
|
116
|
-
enableSelectDevice: {
|
|
117
|
-
type: Boolean,
|
|
118
|
-
default: !1
|
|
119
|
-
},
|
|
120
|
-
enableCropImage: {
|
|
121
|
-
type: Boolean,
|
|
122
|
-
default: !0
|
|
123
|
-
},
|
|
124
|
-
resolutions: {
|
|
125
|
-
type: Object,
|
|
126
|
-
default: () => ke
|
|
127
|
-
},
|
|
128
|
-
zoom: {
|
|
129
|
-
type: Number,
|
|
130
|
-
default: 1
|
|
131
|
-
},
|
|
132
|
-
enableZoomSlider: {
|
|
133
|
-
type: Boolean,
|
|
134
|
-
default: !1
|
|
135
|
-
},
|
|
136
|
-
correctOrientation: {
|
|
137
|
-
type: Boolean,
|
|
138
|
-
default: !1
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
emits: ["update:modelValue"],
|
|
142
|
-
setup(o, { expose: p, emit: Oe }) {
|
|
143
|
-
let { debounce: Ae } = le, v = o, je = Oe, y = g(), b = g(), Me = g(!1), x = g([]), S = g(), C = g(), w = g(), T = g(), E = g(), D = g(!1), O = g(!1), k = g(0), A = g(0), j = g(), M = g(v.zoom || 1), Ne = g(!1), N = g(!1), Pe = g(null), Fe = g(!1), P, F, Ie = typeof window < "u" && "DeviceMotionEvent" in window && (window.matchMedia?.("(pointer: coarse)")?.matches || "ontouchstart" in window), Le = s(() => v.correctOrientation && Ie), I = s(() => Me.value && (!Le.value || Fe.value));
|
|
144
|
-
ae(I, (e) => {
|
|
145
|
-
e && Z(J);
|
|
146
|
-
}, { flush: "post" });
|
|
147
|
-
function Re() {
|
|
148
|
-
F &&= (window.removeEventListener("pointerdown", F, !0), window.removeEventListener("touchend", F, !0), void 0);
|
|
149
|
-
}
|
|
150
|
-
function L() {
|
|
151
|
-
Fe.value = !0, P &&= (clearTimeout(P), void 0), Re();
|
|
152
|
-
}
|
|
153
|
-
function ze() {
|
|
154
|
-
F || (F = () => {
|
|
155
|
-
R();
|
|
156
|
-
}, window.addEventListener("pointerdown", F, !0), window.addEventListener("touchend", F, !0));
|
|
157
|
-
}
|
|
158
|
-
function Be(e) {
|
|
159
|
-
let t = e.accelerationIncludingGravity;
|
|
160
|
-
if (!t || t.x == null || t.y == null) return;
|
|
161
|
-
let n = Math.round(Math.atan2(t.x, t.y) * 180 / Math.PI);
|
|
162
|
-
if (Pe.value = n, !(typeof screen < "u" && screen.orientation && screen.orientation.type || "portrait-primary").startsWith("portrait")) N.value = !1;
|
|
163
|
-
else {
|
|
164
|
-
let e = Math.abs(Math.abs(n) - 90);
|
|
165
|
-
!N.value && e < 40 ? N.value = !0 : N.value && e > 50 && (N.value = !1);
|
|
166
|
-
}
|
|
167
|
-
Fe.value || L();
|
|
168
|
-
}
|
|
169
|
-
async function R() {
|
|
170
|
-
if (!(!v.correctOrientation || Ne.value)) try {
|
|
171
|
-
let e = window.DeviceOrientationEvent, t = window.DeviceMotionEvent;
|
|
172
|
-
if (e && typeof e.requestPermission == "function" && await e.requestPermission() !== "granted") {
|
|
173
|
-
L();
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
t && typeof t.requestPermission == "function" && await t.requestPermission().catch(() => {}), window.addEventListener("devicemotion", Be, !0), Ne.value = !0, Re();
|
|
177
|
-
} catch (e) {
|
|
178
|
-
console.error(e, "enableMotion: failed"), L();
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
let z = s(() => ({
|
|
182
|
-
...ke,
|
|
183
|
-
...v.resolutions
|
|
184
|
-
})), Ve = s(() => Object.values(z.value)[0]);
|
|
185
|
-
function He(e) {
|
|
186
|
-
return String(e || "").trim().toLowerCase().replace(/\s+/g, "").replace(/[:/]/g, "x");
|
|
187
|
-
}
|
|
188
|
-
let B = s(() => {
|
|
189
|
-
if (z.value[v.ratio]) return v.ratio;
|
|
190
|
-
let e = He(v.ratio);
|
|
191
|
-
if (z.value[e]) return e;
|
|
192
|
-
}), V = s(() => B.value ? z.value[B.value] : Ve.value), Ue = s(() => {
|
|
193
|
-
let e = B.value ? z.value[B.value] : void 0;
|
|
194
|
-
return e ? `${e.width} / ${e.height}` : void 0;
|
|
195
|
-
}), H = s(() => x.value.filter((e) => e.kind === "videoinput")), We = s(() => x.value.filter((e) => e.kind === "audioinput")), U = g([]), W = s(() => H.value.filter((e) => !U.value.includes(e.deviceId)));
|
|
196
|
-
function Ge(e) {
|
|
197
|
-
e && !U.value.includes(e) && (U.value = [...U.value, e]);
|
|
198
|
-
}
|
|
199
|
-
function Ke(e) {
|
|
200
|
-
let t = H.value;
|
|
201
|
-
if (!t.length) return;
|
|
202
|
-
let n = t.findIndex((t) => t.deviceId === e);
|
|
203
|
-
for (let e = 1; e <= t.length; e++) {
|
|
204
|
-
let r = t[(Math.max(n, 0) + e) % t.length];
|
|
205
|
-
if (r && !U.value.includes(r.deviceId)) return r;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
let qe = s(() => W.value.map((e, t) => ({
|
|
209
|
-
text: e.label.slice(0, e.label.indexOf("(")) || `Camera ${t + 1}`,
|
|
210
|
-
value: e.deviceId
|
|
211
|
-
}))), Je = s({
|
|
212
|
-
get() {
|
|
213
|
-
return S.value && S.value.deviceId;
|
|
214
|
-
},
|
|
215
|
-
set(e) {
|
|
216
|
-
S.value = H.value.find((t) => t.deviceId === e), w.value = void 0;
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
s({
|
|
220
|
-
get() {
|
|
221
|
-
return C.value && C.value.deviceId;
|
|
222
|
-
},
|
|
223
|
-
set(e) {
|
|
224
|
-
C.value = We.value.find((t) => t.deviceId === e);
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
let G = s(() => v.enableMirrorCamera ? T.value ? T.value === "user" ? "mirror-cam" : "" : w.value ? w.value === "user" ? "mirror-cam" : "" : (S.value && H.value.findIndex((e) => e.deviceId === S.value?.deviceId)) === 0 ? "mirror-cam" : "" : ""), Ye = s(() => {
|
|
228
|
-
let e = S.value && x.value.findIndex((e) => e.deviceId === S.value?.deviceId);
|
|
229
|
-
return G.value ? `${G.value} mirror-device-${e}` : "";
|
|
230
|
-
}), { tintRgb: Xe, applyFilterToCanvas: Ze } = i(v);
|
|
231
|
-
function Qe() {
|
|
232
|
-
if (B.value && V.value) {
|
|
233
|
-
k.value = V.value.width, A.value = V.value.height;
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
236
|
-
k.value = y.value.parentElement && y.value.parentElement.clientWidth, A.value = y.value.parentElement && y.value.parentElement.clientHeight;
|
|
237
|
-
}
|
|
238
|
-
let $e = Ae(() => {
|
|
239
|
-
Qe();
|
|
240
|
-
}, 300, {
|
|
241
|
-
trailing: !0,
|
|
242
|
-
leading: !1
|
|
243
|
-
});
|
|
244
|
-
function K(e) {
|
|
245
|
-
return new Promise((t) => setTimeout(t, e));
|
|
246
|
-
}
|
|
247
|
-
async function et() {
|
|
248
|
-
let e = V.value ? {
|
|
249
|
-
width: V.value.width,
|
|
250
|
-
height: V.value.height
|
|
251
|
-
} : void 0, t = e ? Math.max(e.width, e.height) : void 0, n = e ? Math.min(e.width, e.height) : void 0, r = v.enableAudio && { ...C.value ? { deviceId: C.value.deviceId } : {} }, i = S.value && S.value.deviceId, a = w.value, o = [];
|
|
252
|
-
i ? (t && n && o.push({
|
|
253
|
-
deviceId: { exact: i },
|
|
254
|
-
width: { ideal: t },
|
|
255
|
-
height: { ideal: n }
|
|
256
|
-
}), o.push({ deviceId: { exact: i } })) : a ? (t && n && o.push({
|
|
257
|
-
facingMode: { exact: a },
|
|
258
|
-
width: { ideal: t },
|
|
259
|
-
height: { ideal: n }
|
|
260
|
-
}), o.push({ facingMode: { exact: a } }), t && n && o.push({
|
|
261
|
-
width: { ideal: t },
|
|
262
|
-
height: { ideal: n }
|
|
263
|
-
}), o.push({})) : (t && n && o.push({
|
|
264
|
-
width: { ideal: t },
|
|
265
|
-
height: { ideal: n }
|
|
266
|
-
}), o.push({}));
|
|
267
|
-
for (let e of o) for (let t = 0; t < 5; t++) try {
|
|
268
|
-
return await navigator.mediaDevices.getUserMedia({
|
|
269
|
-
audio: r,
|
|
270
|
-
video: e
|
|
271
|
-
});
|
|
272
|
-
} catch (e) {
|
|
273
|
-
let t = e && e.name;
|
|
274
|
-
if (t === "NotReadableError" || t === "AbortError") {
|
|
275
|
-
await K(500);
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
break;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
function q() {
|
|
282
|
-
y.value && y.value.srcObject && (y.value.srcObject.getTracks().forEach((e) => {
|
|
283
|
-
e.stop();
|
|
284
|
-
}), y.value.srcObject = null);
|
|
285
|
-
}
|
|
286
|
-
let J = 0, Y, tt;
|
|
287
|
-
function X() {
|
|
288
|
-
Y &&= (clearTimeout(Y), void 0), tt &&= (tt(), void 0);
|
|
289
|
-
}
|
|
290
|
-
function nt(e) {
|
|
291
|
-
Ge(e);
|
|
292
|
-
let t = Ke(e);
|
|
293
|
-
t && t.deviceId !== e && (S.value = t);
|
|
294
|
-
}
|
|
295
|
-
function rt(e) {
|
|
296
|
-
X();
|
|
297
|
-
let t = S.value && S.value.deviceId, n = y.value;
|
|
298
|
-
if (!t || !n) return;
|
|
299
|
-
let r = n.srcObject && n.srcObject.getVideoTracks?.()[0];
|
|
300
|
-
if (!r || typeof r.addEventListener != "function" || n.videoWidth > 0) return;
|
|
301
|
-
let i = () => {
|
|
302
|
-
if (X(), e !== J || !y.value) return;
|
|
303
|
-
let n = Ke(t);
|
|
304
|
-
n && n.deviceId !== t && (q(), nt(t));
|
|
305
|
-
}, a = () => {
|
|
306
|
-
e === J && y.value && y.value.videoWidth > 0 && X();
|
|
307
|
-
}, o = () => {
|
|
308
|
-
i();
|
|
309
|
-
};
|
|
310
|
-
r.addEventListener("unmute", a), r.addEventListener("ended", o), tt = () => {
|
|
311
|
-
r.removeEventListener("unmute", a), r.removeEventListener("ended", o);
|
|
312
|
-
}, Y = setTimeout(() => {
|
|
313
|
-
Y = void 0, !(e !== J || !y.value) && (y.value.videoWidth === 0 ? i() : X());
|
|
314
|
-
}, 8e3);
|
|
315
|
-
}
|
|
316
|
-
let it = 0;
|
|
317
|
-
async function Z(e) {
|
|
318
|
-
for (let t = 0; t < 3; t++) {
|
|
319
|
-
if (e !== J || !y.value) return;
|
|
320
|
-
try {
|
|
321
|
-
await y.value.play?.();
|
|
322
|
-
return;
|
|
323
|
-
} catch {
|
|
324
|
-
t < 2 && await K(300);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function at() {
|
|
329
|
-
return !!(y.value && y.value.videoWidth > 0);
|
|
330
|
-
}
|
|
331
|
-
function Q(e, t) {
|
|
332
|
-
return new Promise((n) => {
|
|
333
|
-
let r = Date.now(), i = () => {
|
|
334
|
-
if (e !== J || !y.value) return n(!1);
|
|
335
|
-
if (at()) return n(!0);
|
|
336
|
-
if (Date.now() - r >= t) return n(!1);
|
|
337
|
-
setTimeout(i, 100);
|
|
338
|
-
};
|
|
339
|
-
i();
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
async function ot(e) {
|
|
343
|
-
if (typeof (y.value?.srcObject)?.getVideoTracks?.()[0]?.addEventListener != "function" || await Q(e, 800) || e !== J || !y.value || (await Z(e), await Q(e, 800)) || e !== J || !y.value) return;
|
|
344
|
-
let t = y.value, n = t.style.display;
|
|
345
|
-
if (t.style.display = "none", t.offsetHeight, t.style.display = n, await Z(e), await Q(e, 800) || e !== J || !y.value) return;
|
|
346
|
-
let r = y.value.srcObject;
|
|
347
|
-
r && (y.value.srcObject = null, await ee(), e !== J || !y.value || (y.value.srcObject = r, await Z(e), await Q(e, 800))) || e === J && await $();
|
|
348
|
-
}
|
|
349
|
-
function st() {
|
|
350
|
-
document.visibilityState !== "visible" || !D.value || !y.value || (y.value.paused || y.value.videoWidth === 0) && Z(J);
|
|
351
|
-
}
|
|
352
|
-
async function $() {
|
|
353
|
-
let e = ++J;
|
|
354
|
-
X();
|
|
355
|
-
let t = !!(y.value && y.value.srcObject);
|
|
356
|
-
if (q(), E.value = void 0, t && (await K(350), e !== J)) return;
|
|
357
|
-
let n = await et();
|
|
358
|
-
if (e !== J) {
|
|
359
|
-
n?.getTracks?.().forEach((e) => e.stop());
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
if (n && y.value) {
|
|
363
|
-
it = 0, y.value.srcObject = n;
|
|
364
|
-
let t = n.getVideoTracks?.()[0]?.getSettings?.();
|
|
365
|
-
T.value = t?.facingMode, E.value = t?.deviceId, y.value.muted = !0, await Z(e), rt(e), ot(e);
|
|
366
|
-
} else if (!n && S.value) {
|
|
367
|
-
it < 2 && (it++, await K(600), e === J && await $());
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
return x.value = await navigator.mediaDevices.enumerateDevices(), {
|
|
371
|
-
stream: y.value && y.value.srcObject,
|
|
372
|
-
devices: x.value
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
function ct() {
|
|
376
|
-
D.value ? (D.value = !1, O.value = !1, q()) : (D.value = !0, $());
|
|
377
|
-
}
|
|
378
|
-
function lt() {
|
|
379
|
-
S.value = void 0, w.value = w.value === "user" ? "environment" : "user", $();
|
|
380
|
-
}
|
|
381
|
-
async function ut(e, t) {
|
|
382
|
-
e && e.deviceId === E.value || e && (!t || e.deviceId !== t.deviceId) && await $();
|
|
383
|
-
}
|
|
384
|
-
ae(() => S.value, ut), ae(() => C.value, ut);
|
|
385
|
-
function dt() {
|
|
386
|
-
v.countdown ? (j.value = j.value ? j.value - 1 : v.countdown, j.value ? setTimeout(dt, 1e3) : mt()) : mt();
|
|
387
|
-
}
|
|
388
|
-
p({
|
|
389
|
-
onCapture: dt,
|
|
390
|
-
enableMotion: R,
|
|
391
|
-
camera: y.value,
|
|
392
|
-
zoom: M
|
|
393
|
-
});
|
|
394
|
-
function ft() {
|
|
395
|
-
if (!v.correctOrientation || Pe.value == null) return 0;
|
|
396
|
-
let e = ((Pe.value - 180) % 360 + 360) % 360;
|
|
397
|
-
return (-1 * (Math.round(e / 90) * 90 % 360) % 360 + 360) % 360;
|
|
398
|
-
}
|
|
399
|
-
function pt(e, t, n, r, i) {
|
|
400
|
-
let a = b.value.width, o = b.value.height;
|
|
401
|
-
e.translate(a / 2, o / 2), G.value && e.scale(-1, 1), e.rotate(n * Math.PI / 180);
|
|
402
|
-
let s = o, c = a, l = Math.max(s / r, c / i) * (M.value && M.value > 0 ? M.value : 1), u = r * l, d = i * l;
|
|
403
|
-
e.drawImage(t, -u / 2, -d / 2, u, d);
|
|
404
|
-
}
|
|
405
|
-
function mt() {
|
|
406
|
-
O.value = !0;
|
|
407
|
-
let e = b.value.getContext("2d"), t = y.value, n = t && t.srcObject && t.srcObject.getTracks(), { aspectRatio: r, width: i, height: a } = n.length && n[0].getSettings(), o = t?.videoWidth || i || k.value, s = t?.videoHeight || a || A.value, c = o && s ? o / s : r, l = V.value || {
|
|
408
|
-
width: o,
|
|
409
|
-
height: s
|
|
410
|
-
}, u = l?.width || o, d = B.value ? l?.height || s : Math.round(u / c), f = u / d;
|
|
411
|
-
if (b.value.width = u, b.value.height = d, !o || !s || !c) return;
|
|
412
|
-
let p = ft();
|
|
413
|
-
if (e.save(), p === 90 || p === 270) {
|
|
414
|
-
pt(e, t, p, o, s), e.restore(), Ze(e, b.value.width, b.value.height), ht(b.value.toDataURL("image/png"));
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
if (p === 180 && (e.translate(b.value.width, b.value.height), e.scale(-1, -1)), G.value && (e.translate(b.value.width, 0), e.scale(-1, 1)), v.enableCropImage) {
|
|
418
|
-
let n = 0, r = 0, i = o, a = s;
|
|
419
|
-
if (c > f ? (i = s * f, n = (o - i) / 2) : c < f && (a = o / f, r = (s - a) / 2), M.value && M.value !== 1) {
|
|
420
|
-
let e = i / M.value, t = a / M.value;
|
|
421
|
-
n += (i - e) / 2, r += (a - t) / 2, i = e, a = t;
|
|
422
|
-
}
|
|
423
|
-
e.drawImage(t, n, r, i, a, 0, 0, b.value.width, b.value.height);
|
|
424
|
-
} else {
|
|
425
|
-
let n = b.value.width, r = b.value.height, i = 0, a = 0;
|
|
426
|
-
if (c > f ? (r = b.value.width / c, a = (b.value.height - r) / 2) : c < f && (n = b.value.height * c, i = (b.value.width - n) / 2), M.value && M.value !== 1) {
|
|
427
|
-
let c = o / M.value, l = s / M.value, u = (o - c) / 2, d = (s - l) / 2;
|
|
428
|
-
G.value && (i = b.value.width - i - n), e.drawImage(t, u, d, c, l, i, a, n, r);
|
|
429
|
-
} else G.value && (i = b.value.width - i - n), e.drawImage(t, 0, 0, o, s, i, a, n, r);
|
|
430
|
-
}
|
|
431
|
-
e.restore(), Ze(e, b.value.width, b.value.height), ht(b.value.toDataURL("image/png"));
|
|
432
|
-
}
|
|
433
|
-
function ht(e) {
|
|
434
|
-
let t = n(e);
|
|
435
|
-
je("update:modelValue", {
|
|
436
|
-
name: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
437
|
-
id: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
438
|
-
blob: t,
|
|
439
|
-
size: t.size
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
return re(async () => {
|
|
443
|
-
w.value = v.defaultRearCamera ? "environment" : "user", await $(), D.value = !0;
|
|
444
|
-
let e = H.value.find((e) => e.deviceId === E.value), t = v.defaultRearCamera && H.value.length > 1 ? H.value[H.value.length - 1] : e || H.value[0];
|
|
445
|
-
if (S.value = t, v.enableAudio && (C.value = We.value[0]), navigator.mediaDevices.addEventListener("devicechange", async (e) => {
|
|
446
|
-
await $();
|
|
447
|
-
}), document.addEventListener("visibilitychange", st), window.addEventListener("resize", $e), Qe(), Le.value) {
|
|
448
|
-
P = setTimeout(L, 3e3);
|
|
449
|
-
let e = window.DeviceOrientationEvent;
|
|
450
|
-
e && typeof e.requestPermission == "function" ? ze() : R();
|
|
451
|
-
}
|
|
452
|
-
await ee(), Me.value = !0;
|
|
453
|
-
}), ne(() => {
|
|
454
|
-
D.value = !1, O.value = !1, X(), q(), window.removeEventListener("resize", $e), window.removeEventListener("devicemotion", Be, !0), document.removeEventListener("visibilitychange", st), P && clearTimeout(P), Re();
|
|
455
|
-
}), (n, i) => (h(), u("div", { class: m(["camera", Ye.value]) }, [
|
|
456
|
-
d("div", ue, [
|
|
457
|
-
I.value ? l("", !0) : (h(), u("div", de, [f(t, { color: "#000" }, {
|
|
458
|
-
default: oe(() => [d("span", {
|
|
459
|
-
class: m("d-block text-center"),
|
|
460
|
-
innerHTML: n.$t("camera.waitForCameraNotification")
|
|
461
|
-
}, null, 8, fe)]),
|
|
462
|
-
_: 1
|
|
463
|
-
})])),
|
|
464
|
-
se(d("div", {
|
|
465
|
-
class: m(["camera__video-wrapper", B.value ? `aspect-ratio--${B.value}` : ""]),
|
|
466
|
-
style: te({
|
|
467
|
-
aspectRatio: Ue.value || void 0,
|
|
468
|
-
transform: M.value === 1 ? void 0 : `scale(${M.value})`
|
|
469
|
-
})
|
|
470
|
-
}, [d("video", {
|
|
471
|
-
ref_key: "camera",
|
|
472
|
-
ref: y,
|
|
473
|
-
class: "camera__video",
|
|
474
|
-
style: te({
|
|
475
|
-
filter: v.filter === "grayscale" ? "grayscale(100%)" : v.filter === "sepia" ? "sepia(100%)" : "none",
|
|
476
|
-
transform: o.correctOrientation && N.value ? "rotate(180deg)" : void 0
|
|
477
|
-
}),
|
|
478
|
-
autoplay: "",
|
|
479
|
-
muted: "",
|
|
480
|
-
playsinline: ""
|
|
481
|
-
}, null, 4), o.tintColor ? (h(), u("div", {
|
|
482
|
-
key: 0,
|
|
483
|
-
class: "camera__tint-overlay",
|
|
484
|
-
style: te({
|
|
485
|
-
backgroundColor: o.tintColor,
|
|
486
|
-
opacity: o.tintIntensity,
|
|
487
|
-
mixBlendMode: "multiply"
|
|
488
|
-
})
|
|
489
|
-
}, null, 4)) : l("", !0)], 6), [[ie, I.value]]),
|
|
490
|
-
se(d("canvas", {
|
|
491
|
-
ref_key: "canvas",
|
|
492
|
-
ref: b,
|
|
493
|
-
class: "camera__canvas",
|
|
494
|
-
width: k.value,
|
|
495
|
-
height: A.value
|
|
496
|
-
}, null, 8, pe), [[ie, O.value]]),
|
|
497
|
-
j.value ? (h(), u("div", me, [(h(), u("p", {
|
|
498
|
-
class: "countdown",
|
|
499
|
-
key: j.value,
|
|
500
|
-
innerHTML: j.value,
|
|
501
|
-
"data-countdown": j.value
|
|
502
|
-
}, null, 8, he))])) : l("", !0),
|
|
503
|
-
o.enableGuide && D.value && I.value ? (h(), u("img", {
|
|
504
|
-
key: 2,
|
|
505
|
-
class: "camera__guide",
|
|
506
|
-
src: o.guideSrc
|
|
507
|
-
}, null, 8, ge)) : l("", !0),
|
|
508
|
-
o.enableZoomSlider ? (h(), u("div", _e, [f(a, {
|
|
509
|
-
modelValue: M.value,
|
|
510
|
-
"onUpdate:modelValue": i[0] ||= (e) => M.value = e
|
|
511
|
-
}, null, 8, ["modelValue"])])) : l("", !0)
|
|
512
|
-
]),
|
|
513
|
-
d("div", ve, [d("div", ye, [d("div", be, [d("div", xe, [d("div", Se, [d("button", {
|
|
514
|
-
type: "button",
|
|
515
|
-
class: "camera__toggle btn btn-primary",
|
|
516
|
-
onClick: ct
|
|
517
|
-
}, [D.value ? (h(), u("span", we, _(n.$t("common.pause")), 1)) : (h(), u("span", Ce, _(n.$t("common.play")), 1))]), d("button", {
|
|
518
|
-
type: "button",
|
|
519
|
-
class: "camera__capture btn btn-primary",
|
|
520
|
-
onClick: dt
|
|
521
|
-
}, _(n.$t("camera.capture")), 1)])])])])]),
|
|
522
|
-
(o.enableSwitchCamera || o.enableSelectDevice) && W.value && W.value.length > 1 ? (h(), u("div", Te, [d("div", Ee, [o.enableSelectDevice ? (h(), c(r, {
|
|
523
|
-
key: 0,
|
|
524
|
-
modelValue: Je.value,
|
|
525
|
-
"onUpdate:modelValue": i[1] ||= (e) => Je.value = e,
|
|
526
|
-
options: qe.value,
|
|
527
|
-
class: "w-100"
|
|
528
|
-
}, null, 8, ["modelValue", "options"])) : l("", !0)]), d("div", De, [o.enableSwitchCamera ? (h(), u("button", {
|
|
529
|
-
key: 0,
|
|
530
|
-
class: "btn",
|
|
531
|
-
onClick: ce(lt, ["prevent"])
|
|
532
|
-
}, [f(e, { symbol: "switch-camera" })])) : l("", !0)])])) : l("", !0)
|
|
533
|
-
], 2));
|
|
534
|
-
}
|
|
535
|
-
});
|
|
536
|
-
//#endregion
|
|
537
|
-
export { Ae as default };
|