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