ablok-components 0.3.127 → 0.3.128
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/molecules/base-camera/base-camera.vue_vue_type_script_async_true_setup_true_lang.js +277 -238
- package/package.json +1 -1
- package/dist/composables/useCameraCapture.d.ts +0 -34
- package/dist/composables/useCameraCapture.js +0 -53
- package/dist/composables/useOrientationCorrection.d.ts +0 -27
- package/dist/composables/useOrientationCorrection.js +0 -66
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import e from "../../atoms/svg-icon/svg-icon.js";
|
|
2
2
|
import t from "../../atoms/loading-spinner/loading-spinner.js";
|
|
3
|
-
import n from "
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import c from "
|
|
9
|
-
import { computed as l, createBlock as ee, createCommentVNode as u, createElementBlock as d, createElementVNode as f, createVNode as p, defineComponent as te, normalizeClass as m, normalizeStyle as h, onBeforeUnmount as ne, onMounted as re, openBlock as g, ref as _, toDisplayString as v, unref as ie, vShow as ae, watch as y, withCtx as oe, withDirectives as se, withModifiers as ce } from "vue";
|
|
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";
|
|
10
9
|
import le from "lodash";
|
|
11
10
|
//#region src/components/molecules/base-camera/base-camera.vue?vue&type=script&async=true&setup=true&lang.ts
|
|
12
11
|
var ue = { class: "camera__preview" }, de = {
|
|
@@ -61,7 +60,7 @@ var ue = { class: "camera__preview" }, de = {
|
|
|
61
60
|
width: 720,
|
|
62
61
|
height: 1280
|
|
63
62
|
}
|
|
64
|
-
}, Ae = /*@__PURE__*/
|
|
63
|
+
}, Ae = /*@__PURE__*/ p({
|
|
65
64
|
...Oe,
|
|
66
65
|
props: {
|
|
67
66
|
modelValue: { type: null },
|
|
@@ -83,7 +82,7 @@ var ue = { class: "camera__preview" }, de = {
|
|
|
83
82
|
},
|
|
84
83
|
guideSrc: {
|
|
85
84
|
type: String,
|
|
86
|
-
default: () =>
|
|
85
|
+
default: () => o
|
|
87
86
|
},
|
|
88
87
|
countdown: {
|
|
89
88
|
type: Number,
|
|
@@ -140,69 +139,64 @@ var ue = { class: "camera__preview" }, de = {
|
|
|
140
139
|
}
|
|
141
140
|
},
|
|
142
141
|
emits: ["update:modelValue"],
|
|
143
|
-
setup(
|
|
144
|
-
let { debounce: Ae } = le,
|
|
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
|
+
}
|
|
145
150
|
function L() {
|
|
146
|
-
|
|
151
|
+
Fe.value = !0, P &&= (clearTimeout(P), void 0), Re();
|
|
147
152
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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);
|
|
161
166
|
}
|
|
162
|
-
|
|
163
|
-
e.videoWidth > 0 && i();
|
|
164
|
-
}, 200), r = setTimeout(() => {
|
|
165
|
-
if (r = void 0, t || !x.value) return;
|
|
166
|
-
let e = x.value.srcObject;
|
|
167
|
-
e && (x.value.srcObject = null, setTimeout(() => {
|
|
168
|
-
t || !x.value || (x.value.srcObject = e, x.value.play?.().catch(() => {}), at(Be()));
|
|
169
|
-
}, 100));
|
|
170
|
-
}, 600);
|
|
171
|
-
let a = setTimeout(() => {
|
|
172
|
-
if (t || !x.value) return;
|
|
173
|
-
let e = x.value, n = e.style.display;
|
|
174
|
-
e.style.display = "none", e.offsetHeight, e.style.display = n, x.value.play?.().catch(() => {});
|
|
175
|
-
}, 2500), o = setTimeout(() => {
|
|
176
|
-
t || !x.value || x.value.play?.().catch(() => {});
|
|
177
|
-
}, 1500);
|
|
178
|
-
I = () => {
|
|
179
|
-
n && clearInterval(n), r && clearTimeout(r), a && clearTimeout(a), o && clearTimeout(o);
|
|
180
|
-
};
|
|
167
|
+
Fe.value || L();
|
|
181
168
|
}
|
|
182
|
-
|
|
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(() => ({
|
|
183
182
|
...ke,
|
|
184
|
-
...
|
|
185
|
-
})),
|
|
186
|
-
function
|
|
183
|
+
...v.resolutions
|
|
184
|
+
})), Ve = s(() => Object.values(z.value)[0]);
|
|
185
|
+
function He(e) {
|
|
187
186
|
return String(e || "").trim().toLowerCase().replace(/\s+/g, "").replace(/[:/]/g, "x");
|
|
188
187
|
}
|
|
189
|
-
let B =
|
|
190
|
-
if (z.value[
|
|
191
|
-
let e =
|
|
188
|
+
let B = s(() => {
|
|
189
|
+
if (z.value[v.ratio]) return v.ratio;
|
|
190
|
+
let e = He(v.ratio);
|
|
192
191
|
if (z.value[e]) return e;
|
|
193
|
-
}), V =
|
|
192
|
+
}), V = s(() => B.value ? z.value[B.value] : Ve.value), Ue = s(() => {
|
|
194
193
|
let e = B.value ? z.value[B.value] : void 0;
|
|
195
194
|
return e ? `${e.width} / ${e.height}` : void 0;
|
|
196
|
-
}), H =
|
|
197
|
-
|
|
198
|
-
if (e.length <= 2) return e;
|
|
199
|
-
let t = e.length - 1;
|
|
200
|
-
return e.filter((e, n) => n <= 1 || n === t);
|
|
201
|
-
});
|
|
202
|
-
function Je(e) {
|
|
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) {
|
|
203
197
|
e && !U.value.includes(e) && (U.value = [...U.value, e]);
|
|
204
198
|
}
|
|
205
|
-
function
|
|
199
|
+
function Ke(e) {
|
|
206
200
|
let t = H.value;
|
|
207
201
|
if (!t.length) return;
|
|
208
202
|
let n = t.findIndex((t) => t.deviceId === e);
|
|
@@ -211,38 +205,38 @@ var ue = { class: "camera__preview" }, de = {
|
|
|
211
205
|
if (r && !U.value.includes(r.deviceId)) return r;
|
|
212
206
|
}
|
|
213
207
|
}
|
|
214
|
-
let
|
|
208
|
+
let qe = s(() => W.value.map((e, t) => ({
|
|
215
209
|
text: e.label.slice(0, e.label.indexOf("(")) || `Camera ${t + 1}`,
|
|
216
210
|
value: e.deviceId
|
|
217
|
-
}))),
|
|
211
|
+
}))), Je = s({
|
|
218
212
|
get() {
|
|
219
|
-
return
|
|
213
|
+
return S.value && S.value.deviceId;
|
|
220
214
|
},
|
|
221
215
|
set(e) {
|
|
222
|
-
|
|
216
|
+
S.value = H.value.find((t) => t.deviceId === e), w.value = void 0;
|
|
223
217
|
}
|
|
224
218
|
});
|
|
225
|
-
|
|
219
|
+
s({
|
|
226
220
|
get() {
|
|
227
|
-
return
|
|
221
|
+
return C.value && C.value.deviceId;
|
|
228
222
|
},
|
|
229
223
|
set(e) {
|
|
230
|
-
|
|
224
|
+
C.value = We.value.find((t) => t.deviceId === e);
|
|
231
225
|
}
|
|
232
226
|
});
|
|
233
|
-
let G =
|
|
234
|
-
let e =
|
|
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);
|
|
235
229
|
return G.value ? `${G.value} mirror-device-${e}` : "";
|
|
236
|
-
}), { tintRgb:
|
|
237
|
-
function
|
|
230
|
+
}), { tintRgb: Xe, applyFilterToCanvas: Ze } = i(v);
|
|
231
|
+
function Qe() {
|
|
238
232
|
if (B.value && V.value) {
|
|
239
|
-
|
|
233
|
+
k.value = V.value.width, A.value = V.value.height;
|
|
240
234
|
return;
|
|
241
235
|
}
|
|
242
|
-
|
|
236
|
+
k.value = y.value.parentElement && y.value.parentElement.clientWidth, A.value = y.value.parentElement && y.value.parentElement.clientHeight;
|
|
243
237
|
}
|
|
244
|
-
let
|
|
245
|
-
|
|
238
|
+
let $e = Ae(() => {
|
|
239
|
+
Qe();
|
|
246
240
|
}, 300, {
|
|
247
241
|
trailing: !0,
|
|
248
242
|
leading: !1
|
|
@@ -250,11 +244,11 @@ var ue = { class: "camera__preview" }, de = {
|
|
|
250
244
|
function K(e) {
|
|
251
245
|
return new Promise((t) => setTimeout(t, e));
|
|
252
246
|
}
|
|
253
|
-
async function
|
|
247
|
+
async function et() {
|
|
254
248
|
let e = V.value ? {
|
|
255
249
|
width: V.value.width,
|
|
256
250
|
height: V.value.height
|
|
257
|
-
} : void 0, t = e ? Math.max(e.width, e.height) : void 0, n = e ? Math.min(e.width, e.height) : void 0, r =
|
|
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 = [];
|
|
258
252
|
i ? (t && n && o.push({
|
|
259
253
|
deviceId: { exact: i },
|
|
260
254
|
width: { ideal: t },
|
|
@@ -270,227 +264,272 @@ var ue = { class: "camera__preview" }, de = {
|
|
|
270
264
|
width: { ideal: t },
|
|
271
265
|
height: { ideal: n }
|
|
272
266
|
}), o.push({}));
|
|
273
|
-
let
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
let n = e && e.name;
|
|
284
|
-
if (n === "NotReadableError" || n === "AbortError") {
|
|
285
|
-
await K(t ? 250 : 500);
|
|
286
|
-
continue;
|
|
287
|
-
}
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
if (t && s?.name === "NotReadableError") {
|
|
291
|
-
let t = e.deviceId?.exact;
|
|
292
|
-
t && Je(t);
|
|
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;
|
|
293
277
|
}
|
|
278
|
+
break;
|
|
294
279
|
}
|
|
295
|
-
throw s;
|
|
296
280
|
}
|
|
297
281
|
function q() {
|
|
298
|
-
|
|
282
|
+
y.value && y.value.srcObject && (y.value.srcObject.getTracks().forEach((e) => {
|
|
299
283
|
e.stop();
|
|
300
|
-
}),
|
|
284
|
+
}), y.value.srcObject = null);
|
|
301
285
|
}
|
|
302
|
-
let J = 0, Y,
|
|
303
|
-
function
|
|
304
|
-
Y &&= (clearTimeout(Y), void 0);
|
|
286
|
+
let J = 0, Y, tt;
|
|
287
|
+
function X() {
|
|
288
|
+
Y &&= (clearTimeout(Y), void 0), tt &&= (tt(), void 0);
|
|
305
289
|
}
|
|
306
|
-
function
|
|
307
|
-
|
|
308
|
-
let t =
|
|
309
|
-
t && t.deviceId !== e && (
|
|
290
|
+
function nt(e) {
|
|
291
|
+
Ge(e);
|
|
292
|
+
let t = Ke(e);
|
|
293
|
+
t && t.deviceId !== e && (S.value = t);
|
|
310
294
|
}
|
|
311
|
-
function
|
|
312
|
-
|
|
313
|
-
let t =
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
322
|
return;
|
|
323
|
+
} catch {
|
|
324
|
+
t < 2 && await K(300);
|
|
323
325
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
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 $();
|
|
327
348
|
}
|
|
328
|
-
|
|
349
|
+
function st() {
|
|
350
|
+
document.visibilityState !== "visible" || !D.value || !y.value || (y.value.paused || y.value.videoWidth === 0) && Z(J);
|
|
351
|
+
}
|
|
352
|
+
async function $() {
|
|
329
353
|
let e = ++J;
|
|
330
|
-
|
|
331
|
-
let t = !!(
|
|
332
|
-
if (q(),
|
|
333
|
-
let n;
|
|
334
|
-
try {
|
|
335
|
-
n = await rt();
|
|
336
|
-
} catch {
|
|
337
|
-
n = void 0;
|
|
338
|
-
}
|
|
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();
|
|
339
358
|
if (e !== J) {
|
|
340
359
|
n?.getTracks?.().forEach((e) => e.stop());
|
|
341
360
|
return;
|
|
342
361
|
}
|
|
343
|
-
if (n &&
|
|
344
|
-
|
|
362
|
+
if (n && y.value) {
|
|
363
|
+
it = 0, y.value.srcObject = n;
|
|
345
364
|
let t = n.getVideoTracks?.()[0]?.getSettings?.();
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
} catch {
|
|
350
|
-
await K(300), await x.value.play?.().catch(() => {});
|
|
351
|
-
}
|
|
352
|
-
at(e);
|
|
353
|
-
} else if (!n && w.value) {
|
|
354
|
-
q(), it(w.value.deviceId), e === J && w.value && await Q();
|
|
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 $());
|
|
355
368
|
return;
|
|
356
369
|
}
|
|
357
|
-
return
|
|
358
|
-
stream:
|
|
359
|
-
devices:
|
|
370
|
+
return x.value = await navigator.mediaDevices.enumerateDevices(), {
|
|
371
|
+
stream: y.value && y.value.srcObject,
|
|
372
|
+
devices: x.value
|
|
360
373
|
};
|
|
361
374
|
}
|
|
362
|
-
function ot() {
|
|
363
|
-
document.visibilityState !== "visible" || !k.value || !x.value || x.value.paused && x.value.play?.().catch(() => {});
|
|
364
|
-
}
|
|
365
|
-
function st() {
|
|
366
|
-
k.value ? (k.value = !1, A.value = !1, q()) : (k.value = !0, Q());
|
|
367
|
-
}
|
|
368
375
|
function ct() {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
w.value = n, E.value = void 0;
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
w.value = void 0, E.value = E.value === "user" ? "environment" : "user", Q();
|
|
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", $();
|
|
378
380
|
}
|
|
379
|
-
async function
|
|
380
|
-
e && e.deviceId ===
|
|
381
|
+
async function ut(e, t) {
|
|
382
|
+
e && e.deviceId === E.value || e && (!t || e.deviceId !== t.deviceId) && await $();
|
|
381
383
|
}
|
|
382
|
-
|
|
383
|
-
function
|
|
384
|
-
|
|
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();
|
|
385
387
|
}
|
|
386
|
-
|
|
387
|
-
onCapture:
|
|
388
|
-
enableMotion:
|
|
389
|
-
camera:
|
|
390
|
-
zoom:
|
|
388
|
+
p({
|
|
389
|
+
onCapture: dt,
|
|
390
|
+
enableMotion: R,
|
|
391
|
+
camera: y.value,
|
|
392
|
+
zoom: M
|
|
391
393
|
});
|
|
392
|
-
function
|
|
393
|
-
|
|
394
|
-
let e =
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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"));
|
|
404
432
|
}
|
|
405
|
-
function
|
|
406
|
-
|
|
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
|
+
});
|
|
407
441
|
}
|
|
408
442
|
return re(async () => {
|
|
409
|
-
|
|
410
|
-
let e = H.value.find((e) => e.deviceId ===
|
|
411
|
-
|
|
412
|
-
await
|
|
413
|
-
}), document.addEventListener("visibilitychange",
|
|
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;
|
|
414
453
|
}), ne(() => {
|
|
415
|
-
|
|
416
|
-
}), (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
default: oe(() => [
|
|
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", {
|
|
420
459
|
class: m("d-block text-center"),
|
|
421
|
-
innerHTML:
|
|
460
|
+
innerHTML: n.$t("camera.waitForCameraNotification")
|
|
422
461
|
}, null, 8, fe)]),
|
|
423
462
|
_: 1
|
|
424
463
|
})])),
|
|
425
|
-
|
|
464
|
+
se(d("div", {
|
|
426
465
|
class: m(["camera__video-wrapper", B.value ? `aspect-ratio--${B.value}` : ""]),
|
|
427
|
-
style:
|
|
428
|
-
aspectRatio:
|
|
429
|
-
transform:
|
|
466
|
+
style: te({
|
|
467
|
+
aspectRatio: Ue.value || void 0,
|
|
468
|
+
transform: M.value === 1 ? void 0 : `scale(${M.value})`
|
|
430
469
|
})
|
|
431
|
-
}, [
|
|
470
|
+
}, [d("video", {
|
|
432
471
|
ref_key: "camera",
|
|
433
|
-
ref:
|
|
472
|
+
ref: y,
|
|
434
473
|
class: "camera__video",
|
|
435
|
-
style:
|
|
436
|
-
filter:
|
|
437
|
-
transform:
|
|
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
|
|
438
477
|
}),
|
|
439
478
|
autoplay: "",
|
|
440
479
|
muted: "",
|
|
441
480
|
playsinline: ""
|
|
442
|
-
}, null, 4),
|
|
481
|
+
}, null, 4), o.tintColor ? (h(), u("div", {
|
|
443
482
|
key: 0,
|
|
444
483
|
class: "camera__tint-overlay",
|
|
445
|
-
style:
|
|
446
|
-
backgroundColor:
|
|
447
|
-
opacity:
|
|
484
|
+
style: te({
|
|
485
|
+
backgroundColor: o.tintColor,
|
|
486
|
+
opacity: o.tintIntensity,
|
|
448
487
|
mixBlendMode: "multiply"
|
|
449
488
|
})
|
|
450
|
-
}, null, 4)) :
|
|
451
|
-
se(
|
|
489
|
+
}, null, 4)) : l("", !0)], 6), [[ie, I.value]]),
|
|
490
|
+
se(d("canvas", {
|
|
452
491
|
ref_key: "canvas",
|
|
453
|
-
ref:
|
|
492
|
+
ref: b,
|
|
454
493
|
class: "camera__canvas",
|
|
455
|
-
width:
|
|
456
|
-
height:
|
|
457
|
-
}, null, 8, pe), [[
|
|
458
|
-
|
|
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", {
|
|
459
498
|
class: "countdown",
|
|
460
|
-
key:
|
|
461
|
-
innerHTML:
|
|
462
|
-
"data-countdown":
|
|
463
|
-
}, null, 8, he))])) :
|
|
464
|
-
|
|
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", {
|
|
465
504
|
key: 2,
|
|
466
505
|
class: "camera__guide",
|
|
467
|
-
src:
|
|
468
|
-
}, null, 8, ge)) :
|
|
469
|
-
|
|
470
|
-
modelValue:
|
|
471
|
-
"onUpdate:modelValue": i[0] ||= (e) =>
|
|
472
|
-
}, null, 8, ["modelValue"])])) :
|
|
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)
|
|
473
512
|
]),
|
|
474
|
-
|
|
513
|
+
d("div", ve, [d("div", ye, [d("div", be, [d("div", xe, [d("div", Se, [d("button", {
|
|
475
514
|
type: "button",
|
|
476
515
|
class: "camera__toggle btn btn-primary",
|
|
477
|
-
onClick:
|
|
478
|
-
}, [
|
|
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", {
|
|
479
518
|
type: "button",
|
|
480
519
|
class: "camera__capture btn btn-primary",
|
|
481
|
-
onClick:
|
|
482
|
-
},
|
|
483
|
-
(
|
|
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, {
|
|
484
523
|
key: 0,
|
|
485
|
-
modelValue:
|
|
486
|
-
"onUpdate:modelValue": i[1] ||= (e) =>
|
|
487
|
-
options:
|
|
524
|
+
modelValue: Je.value,
|
|
525
|
+
"onUpdate:modelValue": i[1] ||= (e) => Je.value = e,
|
|
526
|
+
options: qe.value,
|
|
488
527
|
class: "w-100"
|
|
489
|
-
}, null, 8, ["modelValue", "options"])) :
|
|
528
|
+
}, null, 8, ["modelValue", "options"])) : l("", !0)]), d("div", De, [o.enableSwitchCamera ? (h(), u("button", {
|
|
490
529
|
key: 0,
|
|
491
530
|
class: "btn",
|
|
492
|
-
onClick: ce(
|
|
493
|
-
}, [
|
|
531
|
+
onClick: ce(lt, ["prevent"])
|
|
532
|
+
}, [f(e, { symbol: "switch-camera" })])) : l("", !0)])])) : l("", !0)
|
|
494
533
|
], 2));
|
|
495
534
|
}
|
|
496
535
|
});
|