ablok-components 0.3.113 → 0.3.115
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.umd.js +2 -2
- package/dist/components/molecules/base-camera/base-camera.vue_vue_type_script_async_true_setup_true_lang.js +196 -197
- package/dist/components/molecules/dom-renderer/dom-renderer.vue_vue_type_script_setup_true_lang.js +25 -26
- package/dist/components/molecules/image-resize/image-resize.vue_vue_type_script_setup_true_lang.js +38 -39
- package/package.json +1 -1
- package/dist/_virtual/_rolldown/runtime.js +0 -13
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_Symbol.js +0 -9
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_baseGetTag.js +0 -15
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_baseTrim.js +0 -13
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_freeGlobal.js +0 -8
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_getRawTag.js +0 -19
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_objectToString.js +0 -12
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_root.js +0 -10
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/_trimmedEndIndex.js +0 -13
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/debounce.js +0 -55
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/isObject.js +0 -12
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/isObjectLike.js +0 -11
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/isSymbol.js +0 -14
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/now.js +0 -12
- package/dist/node_modules/.pnpm/lodash@4.18.1/node_modules/lodash/toNumber.js +0 -24
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t from "../../atoms/
|
|
3
|
-
import n from "
|
|
4
|
-
import
|
|
5
|
-
import i from "
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import s from "
|
|
9
|
-
import
|
|
10
|
-
import { computed as l, createBlock as u, createCommentVNode as d, createElementBlock as f, createElementVNode as p, createVNode as m, defineComponent as h, nextTick as ee, normalizeClass as g, normalizeStyle as _, onBeforeUnmount as te, onMounted as ne, openBlock as v, ref as y, toDisplayString as b, vShow as re, watch as ie, withCtx as ae, withDirectives as oe, withModifiers as se } from "vue";
|
|
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 h, onBeforeUnmount as te, onMounted as ne, openBlock as g, ref as _, toDisplayString as v, vShow as re, watch as ie, withCtx as ae, withDirectives as oe, withModifiers as se } from "vue";
|
|
9
|
+
import { debounce as ce } from "lodash";
|
|
11
10
|
//#region src/components/molecules/base-camera/base-camera.vue?vue&type=script&async=true&setup=true&lang.ts
|
|
12
|
-
var
|
|
11
|
+
var le = { class: "camera__preview" }, ue = {
|
|
13
12
|
key: 0,
|
|
14
13
|
class: "camera__bg-notification"
|
|
15
14
|
}, de = ["innerHTML"], fe = ["width", "height"], pe = {
|
|
@@ -61,7 +60,7 @@ var ce = /* @__PURE__ */ e(a(), 1), le = { class: "camera__preview" }, ue = {
|
|
|
61
60
|
width: 720,
|
|
62
61
|
height: 1280
|
|
63
62
|
}
|
|
64
|
-
},
|
|
63
|
+
}, y = /*@__PURE__*/ p({
|
|
65
64
|
...De,
|
|
66
65
|
props: {
|
|
67
66
|
modelValue: { type: null },
|
|
@@ -83,7 +82,7 @@ var ce = /* @__PURE__ */ e(a(), 1), le = { class: "camera__preview" }, ue = {
|
|
|
83
82
|
},
|
|
84
83
|
guideSrc: {
|
|
85
84
|
type: String,
|
|
86
|
-
default: () =>
|
|
85
|
+
default: () => o
|
|
87
86
|
},
|
|
88
87
|
countdown: {
|
|
89
88
|
type: Number,
|
|
@@ -140,116 +139,116 @@ var ce = /* @__PURE__ */ e(a(), 1), le = { class: "camera__preview" }, ue = {
|
|
|
140
139
|
}
|
|
141
140
|
},
|
|
142
141
|
emits: ["update:modelValue"],
|
|
143
|
-
setup(
|
|
144
|
-
let
|
|
145
|
-
function
|
|
146
|
-
|
|
142
|
+
setup(o, { expose: p, emit: De }) {
|
|
143
|
+
let y = o, ke = De, b = _(), x = _(), Ae = _(!1), S = _([]), C = _(), w = _(), T = _(), E = _(!1), D = _(!1), O = _(0), k = _(0), A = _(), j = _(y.zoom || 1), je = _(!1), M = _(!1), N = _(null), P = _(!1), F, I, Me = typeof window < "u" && "DeviceMotionEvent" in window && (window.matchMedia?.("(pointer: coarse)")?.matches || "ontouchstart" in window), Ne = s(() => y.correctOrientation && Me), L = s(() => Ae.value && (!Ne.value || P.value));
|
|
144
|
+
function R() {
|
|
145
|
+
I &&= (window.removeEventListener("pointerdown", I, !0), window.removeEventListener("touchend", I, !0), void 0);
|
|
147
146
|
}
|
|
148
|
-
function
|
|
149
|
-
|
|
147
|
+
function z() {
|
|
148
|
+
P.value = !0, F &&= (clearTimeout(F), void 0), R();
|
|
150
149
|
}
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}, window.addEventListener("pointerdown",
|
|
150
|
+
function Pe() {
|
|
151
|
+
I || (I = () => {
|
|
152
|
+
B();
|
|
153
|
+
}, window.addEventListener("pointerdown", I, !0), window.addEventListener("touchend", I, !0));
|
|
155
154
|
}
|
|
156
|
-
function
|
|
155
|
+
function Fe(e) {
|
|
157
156
|
let t = e.accelerationIncludingGravity;
|
|
158
157
|
if (!t || t.x == null || t.y == null) return;
|
|
159
158
|
let n = Math.round(Math.atan2(t.x, t.y) * 180 / Math.PI);
|
|
160
|
-
if (
|
|
159
|
+
if (N.value = n, !(typeof screen < "u" && screen.orientation && screen.orientation.type || "portrait-primary").startsWith("portrait")) M.value = !1;
|
|
161
160
|
else {
|
|
162
161
|
let e = Math.abs(Math.abs(n) - 90);
|
|
163
|
-
!
|
|
162
|
+
!M.value && e < 40 ? M.value = !0 : M.value && e > 50 && (M.value = !1);
|
|
164
163
|
}
|
|
165
|
-
|
|
164
|
+
P.value || z();
|
|
166
165
|
}
|
|
167
|
-
async function
|
|
168
|
-
if (!(!
|
|
166
|
+
async function B() {
|
|
167
|
+
if (!(!y.correctOrientation || je.value)) try {
|
|
169
168
|
let e = window.DeviceOrientationEvent, t = window.DeviceMotionEvent;
|
|
170
169
|
if (e && typeof e.requestPermission == "function" && await e.requestPermission() !== "granted") {
|
|
171
|
-
|
|
170
|
+
z();
|
|
172
171
|
return;
|
|
173
172
|
}
|
|
174
|
-
t && typeof t.requestPermission == "function" && await t.requestPermission().catch(() => {}), window.addEventListener("devicemotion",
|
|
173
|
+
t && typeof t.requestPermission == "function" && await t.requestPermission().catch(() => {}), window.addEventListener("devicemotion", Fe, !0), je.value = !0, R();
|
|
175
174
|
} catch (e) {
|
|
176
|
-
console.error(e, "enableMotion: failed"),
|
|
175
|
+
console.error(e, "enableMotion: failed"), z();
|
|
177
176
|
}
|
|
178
177
|
}
|
|
179
|
-
let
|
|
178
|
+
let V = s(() => ({
|
|
180
179
|
...Oe,
|
|
181
|
-
...
|
|
182
|
-
})),
|
|
183
|
-
function
|
|
180
|
+
...y.resolutions
|
|
181
|
+
})), Ie = s(() => Object.values(V.value)[0]);
|
|
182
|
+
function Le(e) {
|
|
184
183
|
return String(e || "").trim().toLowerCase().replace(/\s+/g, "").replace(/[:/]/g, "x");
|
|
185
184
|
}
|
|
186
|
-
let
|
|
187
|
-
if (
|
|
188
|
-
let e =
|
|
189
|
-
if (
|
|
190
|
-
}),
|
|
191
|
-
let e =
|
|
185
|
+
let H = s(() => {
|
|
186
|
+
if (V.value[y.ratio]) return y.ratio;
|
|
187
|
+
let e = Le(y.ratio);
|
|
188
|
+
if (V.value[e]) return e;
|
|
189
|
+
}), U = s(() => H.value ? V.value[H.value] : Ie.value), Re = s(() => {
|
|
190
|
+
let e = H.value ? V.value[H.value] : void 0;
|
|
192
191
|
return e ? `${e.width} / ${e.height}` : void 0;
|
|
193
|
-
}),
|
|
192
|
+
}), W = s(() => S.value.filter((e) => e.kind === "videoinput")), ze = s(() => S.value.filter((e) => e.kind === "audioinput")), G = _([]), K = s(() => W.value.filter((e) => !G.value.includes(e.deviceId)));
|
|
194
193
|
function Be(e) {
|
|
195
|
-
e && !
|
|
194
|
+
e && !G.value.includes(e) && (G.value = [...G.value, e]);
|
|
196
195
|
}
|
|
197
196
|
function Ve(e) {
|
|
198
|
-
let t =
|
|
197
|
+
let t = W.value;
|
|
199
198
|
if (!t.length) return;
|
|
200
199
|
let n = t.findIndex((t) => t.deviceId === e);
|
|
201
200
|
for (let e = 1; e <= t.length; e++) {
|
|
202
201
|
let r = t[(Math.max(n, 0) + e) % t.length];
|
|
203
|
-
if (r && !
|
|
202
|
+
if (r && !G.value.includes(r.deviceId)) return r;
|
|
204
203
|
}
|
|
205
204
|
}
|
|
206
|
-
let He =
|
|
205
|
+
let He = s(() => K.value.map((e, t) => ({
|
|
207
206
|
text: e.label.slice(0, e.label.indexOf("(")) || `Camera ${t + 1}`,
|
|
208
207
|
value: e.deviceId
|
|
209
|
-
}))), Ue =
|
|
208
|
+
}))), Ue = s({
|
|
210
209
|
get() {
|
|
211
|
-
return
|
|
210
|
+
return C.value && C.value.deviceId;
|
|
212
211
|
},
|
|
213
212
|
set(e) {
|
|
214
|
-
|
|
213
|
+
C.value = W.value.find((t) => t.deviceId === e), T.value = void 0;
|
|
215
214
|
}
|
|
216
215
|
});
|
|
217
|
-
|
|
216
|
+
s({
|
|
218
217
|
get() {
|
|
219
|
-
return
|
|
218
|
+
return w.value && w.value.deviceId;
|
|
220
219
|
},
|
|
221
220
|
set(e) {
|
|
222
|
-
|
|
221
|
+
w.value = ze.value.find((t) => t.deviceId === e);
|
|
223
222
|
}
|
|
224
223
|
});
|
|
225
|
-
let q =
|
|
226
|
-
let e =
|
|
227
|
-
return
|
|
228
|
-
}), We =
|
|
229
|
-
let e =
|
|
224
|
+
let q = s(() => {
|
|
225
|
+
let e = C.value && W.value.findIndex((e) => e.deviceId === C.value?.deviceId);
|
|
226
|
+
return y.enableMirrorCamera && e === 0 ? "mirror-cam" : "";
|
|
227
|
+
}), We = s(() => {
|
|
228
|
+
let e = C.value && S.value.findIndex((e) => e.deviceId === C.value?.deviceId);
|
|
230
229
|
return q.value ? `${q.value} mirror-device-${e}` : "";
|
|
231
|
-
}), { tintRgb: Ge, applyFilterToCanvas: Ke } =
|
|
230
|
+
}), { tintRgb: Ge, applyFilterToCanvas: Ke } = i(y);
|
|
232
231
|
function qe() {
|
|
233
|
-
if (
|
|
234
|
-
|
|
232
|
+
if (H.value && U.value) {
|
|
233
|
+
O.value = U.value.width, k.value = U.value.height;
|
|
235
234
|
return;
|
|
236
235
|
}
|
|
237
|
-
|
|
236
|
+
O.value = b.value.parentElement && b.value.parentElement.clientWidth, k.value = b.value.parentElement && b.value.parentElement.clientHeight;
|
|
238
237
|
}
|
|
239
|
-
let Je =
|
|
238
|
+
let Je = ce(() => {
|
|
240
239
|
qe();
|
|
241
240
|
}, 300, {
|
|
242
241
|
trailing: !0,
|
|
243
242
|
leading: !1
|
|
244
243
|
});
|
|
245
|
-
function
|
|
244
|
+
function J(e) {
|
|
246
245
|
return new Promise((t) => setTimeout(t, e));
|
|
247
246
|
}
|
|
248
|
-
async function
|
|
249
|
-
let e =
|
|
250
|
-
width:
|
|
251
|
-
height:
|
|
252
|
-
} : void 0, t = e ? Math.max(e.width, e.height) : void 0, n = e ? Math.min(e.width, e.height) : void 0, r =
|
|
247
|
+
async function Ye() {
|
|
248
|
+
let e = U.value ? {
|
|
249
|
+
width: U.value.width,
|
|
250
|
+
height: U.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 = y.enableAudio && { ...w.value ? { deviceId: w.value.deviceId } : {} }, i = C.value && C.value.deviceId, a = T.value, o = [];
|
|
253
252
|
i ? (t && n && o.push({
|
|
254
253
|
deviceId: { exact: i },
|
|
255
254
|
width: { ideal: t },
|
|
@@ -273,134 +272,134 @@ var ce = /* @__PURE__ */ e(a(), 1), le = { class: "camera__preview" }, ue = {
|
|
|
273
272
|
} catch (e) {
|
|
274
273
|
let t = e && e.name;
|
|
275
274
|
if (t === "NotReadableError" || t === "AbortError") {
|
|
276
|
-
await
|
|
275
|
+
await J(500);
|
|
277
276
|
continue;
|
|
278
277
|
}
|
|
279
278
|
break;
|
|
280
279
|
}
|
|
281
280
|
}
|
|
282
|
-
function
|
|
283
|
-
|
|
281
|
+
function Y() {
|
|
282
|
+
b.value && b.value.srcObject && (b.value.srcObject.getTracks().forEach((e) => {
|
|
284
283
|
e.stop();
|
|
285
|
-
}),
|
|
284
|
+
}), b.value.srcObject = null);
|
|
286
285
|
}
|
|
287
|
-
let
|
|
288
|
-
function
|
|
289
|
-
|
|
286
|
+
let X = 0, Z, Xe;
|
|
287
|
+
function Q() {
|
|
288
|
+
Z &&= (clearTimeout(Z), void 0), Xe &&= (Xe(), void 0);
|
|
290
289
|
}
|
|
291
|
-
function
|
|
290
|
+
function Ze(e) {
|
|
292
291
|
Be(e);
|
|
293
292
|
let t = Ve(e);
|
|
294
|
-
t && t.deviceId !== e && (
|
|
293
|
+
t && t.deviceId !== e && (C.value = t);
|
|
295
294
|
}
|
|
296
|
-
function
|
|
297
|
-
|
|
298
|
-
let t =
|
|
295
|
+
function Qe(e) {
|
|
296
|
+
Q();
|
|
297
|
+
let t = C.value && C.value.deviceId, n = b.value;
|
|
299
298
|
if (!t || !n) return;
|
|
300
299
|
let r = n.srcObject && n.srcObject.getVideoTracks?.()[0];
|
|
301
300
|
if (!r || typeof r.addEventListener != "function" || n.videoWidth > 0) return;
|
|
302
301
|
let i = () => {
|
|
303
|
-
if (
|
|
302
|
+
if (Q(), e !== X || !b.value) return;
|
|
304
303
|
let n = Ve(t);
|
|
305
|
-
n && n.deviceId !== t && (
|
|
304
|
+
n && n.deviceId !== t && (Y(), Ze(t));
|
|
306
305
|
}, a = () => {
|
|
307
|
-
e ===
|
|
306
|
+
e === X && b.value && b.value.videoWidth > 0 && Q();
|
|
308
307
|
}, o = () => {
|
|
309
308
|
i();
|
|
310
309
|
};
|
|
311
|
-
r.addEventListener("unmute", a), r.addEventListener("ended", o),
|
|
310
|
+
r.addEventListener("unmute", a), r.addEventListener("ended", o), Xe = () => {
|
|
312
311
|
r.removeEventListener("unmute", a), r.removeEventListener("ended", o);
|
|
313
|
-
},
|
|
314
|
-
|
|
312
|
+
}, Z = setTimeout(() => {
|
|
313
|
+
Z = void 0, !(e !== X || !b.value) && (b.value.videoWidth === 0 ? i() : Q());
|
|
315
314
|
}, 8e3);
|
|
316
315
|
}
|
|
317
|
-
let
|
|
318
|
-
async function
|
|
319
|
-
let e = ++
|
|
320
|
-
|
|
321
|
-
let t = !!(
|
|
322
|
-
if (
|
|
323
|
-
let n = await
|
|
324
|
-
if (e !==
|
|
316
|
+
let $e = 0;
|
|
317
|
+
async function $() {
|
|
318
|
+
let e = ++X;
|
|
319
|
+
Q();
|
|
320
|
+
let t = !!(b.value && b.value.srcObject);
|
|
321
|
+
if (Y(), t && (await J(350), e !== X)) return;
|
|
322
|
+
let n = await Ye();
|
|
323
|
+
if (e !== X) {
|
|
325
324
|
n?.getTracks?.().forEach((e) => e.stop());
|
|
326
325
|
return;
|
|
327
326
|
}
|
|
328
|
-
if (n &&
|
|
329
|
-
|
|
327
|
+
if (n && b.value) {
|
|
328
|
+
$e = 0, b.value.srcObject = n, b.value.muted = !0;
|
|
330
329
|
try {
|
|
331
|
-
await
|
|
330
|
+
await b.value.play?.();
|
|
332
331
|
} catch {}
|
|
333
|
-
|
|
334
|
-
} else if (!n &&
|
|
335
|
-
|
|
332
|
+
Qe(e);
|
|
333
|
+
} else if (!n && C.value) {
|
|
334
|
+
$e < 2 && ($e++, await J(600), e === X && await $());
|
|
336
335
|
return;
|
|
337
336
|
}
|
|
338
|
-
return
|
|
339
|
-
stream:
|
|
340
|
-
devices:
|
|
337
|
+
return S.value = await navigator.mediaDevices.enumerateDevices(), {
|
|
338
|
+
stream: b.value && b.value.srcObject,
|
|
339
|
+
devices: S.value
|
|
341
340
|
};
|
|
342
341
|
}
|
|
343
|
-
function
|
|
344
|
-
|
|
342
|
+
function et() {
|
|
343
|
+
E.value ? (E.value = !1, D.value = !1, Y()) : (E.value = !0, $());
|
|
345
344
|
}
|
|
346
|
-
function
|
|
347
|
-
|
|
345
|
+
function tt() {
|
|
346
|
+
C.value = void 0, T.value = T.value === "user" ? "environment" : "user", $();
|
|
348
347
|
}
|
|
349
|
-
async function
|
|
350
|
-
e && (!t || e.deviceId !== t.deviceId) && await
|
|
348
|
+
async function nt(e, t) {
|
|
349
|
+
e && (!t || e.deviceId !== t.deviceId) && await $();
|
|
351
350
|
}
|
|
352
|
-
ie(() =>
|
|
353
|
-
function
|
|
354
|
-
|
|
351
|
+
ie(() => C.value, nt), ie(() => w.value, nt);
|
|
352
|
+
function rt() {
|
|
353
|
+
y.countdown ? (A.value = A.value ? A.value - 1 : y.countdown, A.value ? setTimeout(rt, 1e3) : ot()) : ot();
|
|
355
354
|
}
|
|
356
|
-
|
|
357
|
-
onCapture:
|
|
358
|
-
enableMotion:
|
|
359
|
-
camera:
|
|
360
|
-
zoom:
|
|
355
|
+
p({
|
|
356
|
+
onCapture: rt,
|
|
357
|
+
enableMotion: B,
|
|
358
|
+
camera: b.value,
|
|
359
|
+
zoom: j
|
|
361
360
|
});
|
|
362
361
|
function it() {
|
|
363
|
-
if (!
|
|
364
|
-
let e = ((
|
|
362
|
+
if (!y.correctOrientation || N.value == null) return 0;
|
|
363
|
+
let e = ((N.value - 180) % 360 + 360) % 360;
|
|
365
364
|
return (-1 * (Math.round(e / 90) * 90 % 360) % 360 + 360) % 360;
|
|
366
365
|
}
|
|
367
366
|
function at(e, t, n, r, i) {
|
|
368
|
-
let a =
|
|
367
|
+
let a = x.value.width, o = x.value.height;
|
|
369
368
|
e.translate(a / 2, o / 2), q.value && e.scale(-1, 1), e.rotate(n * Math.PI / 180);
|
|
370
|
-
let s = o, c = a, l = Math.max(s / r, c / i) * (
|
|
369
|
+
let s = o, c = a, l = Math.max(s / r, c / i) * (j.value && j.value > 0 ? j.value : 1), u = r * l, d = i * l;
|
|
371
370
|
e.drawImage(t, -u / 2, -d / 2, u, d);
|
|
372
371
|
}
|
|
373
372
|
function ot() {
|
|
374
|
-
|
|
375
|
-
let e =
|
|
373
|
+
D.value = !0;
|
|
374
|
+
let e = x.value.getContext("2d"), t = b.value, n = t && t.srcObject && t.srcObject.getTracks(), { aspectRatio: r, width: i, height: a } = n.length && n[0].getSettings(), o = t?.videoWidth || i || O.value, s = t?.videoHeight || a || k.value, c = o && s ? o / s : r, l = U.value || {
|
|
376
375
|
width: o,
|
|
377
376
|
height: s
|
|
378
|
-
}, u = l?.width || o, d =
|
|
379
|
-
if (
|
|
377
|
+
}, u = l?.width || o, d = H.value ? l?.height || s : Math.round(u / c), f = u / d;
|
|
378
|
+
if (x.value.width = u, x.value.height = d, !o || !s || !c) return;
|
|
380
379
|
let p = it();
|
|
381
380
|
if (e.save(), p === 90 || p === 270) {
|
|
382
|
-
at(e, t, p, o, s), e.restore(), Ke(e,
|
|
381
|
+
at(e, t, p, o, s), e.restore(), Ke(e, x.value.width, x.value.height), st(x.value.toDataURL("image/png"));
|
|
383
382
|
return;
|
|
384
383
|
}
|
|
385
|
-
if (p === 180 && (e.translate(
|
|
384
|
+
if (p === 180 && (e.translate(x.value.width, x.value.height), e.scale(-1, -1)), q.value && (e.translate(x.value.width, 0), e.scale(-1, 1)), y.enableCropImage) {
|
|
386
385
|
let n = 0, r = 0, i = o, a = s;
|
|
387
|
-
if (c > f ? (i = s * f, n = (o - i) / 2) : c < f && (a = o / f, r = (s - a) / 2),
|
|
388
|
-
let e = i /
|
|
386
|
+
if (c > f ? (i = s * f, n = (o - i) / 2) : c < f && (a = o / f, r = (s - a) / 2), j.value && j.value !== 1) {
|
|
387
|
+
let e = i / j.value, t = a / j.value;
|
|
389
388
|
n += (i - e) / 2, r += (a - t) / 2, i = e, a = t;
|
|
390
389
|
}
|
|
391
|
-
e.drawImage(t, n, r, i, a, 0, 0,
|
|
390
|
+
e.drawImage(t, n, r, i, a, 0, 0, x.value.width, x.value.height);
|
|
392
391
|
} else {
|
|
393
|
-
let n =
|
|
394
|
-
if (c > f ? (r =
|
|
395
|
-
let c = o /
|
|
396
|
-
q.value && (i =
|
|
397
|
-
} else q.value && (i =
|
|
392
|
+
let n = x.value.width, r = x.value.height, i = 0, a = 0;
|
|
393
|
+
if (c > f ? (r = x.value.width / c, a = (x.value.height - r) / 2) : c < f && (n = x.value.height * c, i = (x.value.width - n) / 2), j.value && j.value !== 1) {
|
|
394
|
+
let c = o / j.value, l = s / j.value, u = (o - c) / 2, d = (s - l) / 2;
|
|
395
|
+
q.value && (i = x.value.width - i - n), e.drawImage(t, u, d, c, l, i, a, n, r);
|
|
396
|
+
} else q.value && (i = x.value.width - i - n), e.drawImage(t, 0, 0, o, s, i, a, n, r);
|
|
398
397
|
}
|
|
399
|
-
e.restore(), Ke(e,
|
|
398
|
+
e.restore(), Ke(e, x.value.width, x.value.height), st(x.value.toDataURL("image/png"));
|
|
400
399
|
}
|
|
401
400
|
function st(e) {
|
|
402
|
-
let t =
|
|
403
|
-
|
|
401
|
+
let t = n(e);
|
|
402
|
+
ke("update:modelValue", {
|
|
404
403
|
name: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
405
404
|
id: `cam-pic-${(/* @__PURE__ */ new Date()).toISOString()}`,
|
|
406
405
|
blob: t,
|
|
@@ -408,98 +407,98 @@ var ce = /* @__PURE__ */ e(a(), 1), le = { class: "camera__preview" }, ue = {
|
|
|
408
407
|
});
|
|
409
408
|
}
|
|
410
409
|
return ne(async () => {
|
|
411
|
-
await
|
|
412
|
-
let e =
|
|
413
|
-
if (
|
|
414
|
-
await
|
|
415
|
-
}), window.addEventListener("resize", Je), qe(),
|
|
416
|
-
|
|
410
|
+
await $(), E.value = !0, T.value = y.defaultRearCamera ? "environment" : "user";
|
|
411
|
+
let e = y.defaultRearCamera && W.value.length > 1 ? W.value[W.value.length - 1] : W.value[0];
|
|
412
|
+
if (C.value = e, y.enableAudio && (w.value = ze.value[0]), navigator.mediaDevices.addEventListener("devicechange", async (e) => {
|
|
413
|
+
await $();
|
|
414
|
+
}), window.addEventListener("resize", Je), qe(), Ne.value) {
|
|
415
|
+
F = setTimeout(z, 3e3);
|
|
417
416
|
let e = window.DeviceOrientationEvent;
|
|
418
|
-
e && typeof e.requestPermission == "function" ?
|
|
417
|
+
e && typeof e.requestPermission == "function" ? Pe() : B();
|
|
419
418
|
}
|
|
420
|
-
await ee(),
|
|
419
|
+
await ee(), Ae.value = !0;
|
|
421
420
|
}), te(() => {
|
|
422
|
-
|
|
423
|
-
}), (
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
default: ae(() => [
|
|
427
|
-
class:
|
|
428
|
-
innerHTML:
|
|
421
|
+
E.value = !1, D.value = !1, Q(), Y(), window.removeEventListener("resize", Je), window.removeEventListener("devicemotion", Fe, !0), F && clearTimeout(F), R();
|
|
422
|
+
}), (n, i) => (g(), u("div", { class: m(["camera", We.value]) }, [
|
|
423
|
+
d("div", le, [
|
|
424
|
+
L.value ? l("", !0) : (g(), u("div", ue, [f(t, { color: "#000" }, {
|
|
425
|
+
default: ae(() => [d("span", {
|
|
426
|
+
class: m("d-block text-center"),
|
|
427
|
+
innerHTML: n.$t("camera.waitForCameraNotification")
|
|
429
428
|
}, null, 8, de)]),
|
|
430
429
|
_: 1
|
|
431
430
|
})])),
|
|
432
|
-
oe(
|
|
433
|
-
class:
|
|
434
|
-
style:
|
|
435
|
-
aspectRatio:
|
|
436
|
-
transform:
|
|
431
|
+
oe(d("div", {
|
|
432
|
+
class: m(["camera__video-wrapper", H.value ? `aspect-ratio--${H.value}` : ""]),
|
|
433
|
+
style: h({
|
|
434
|
+
aspectRatio: Re.value || void 0,
|
|
435
|
+
transform: j.value === 1 ? void 0 : `scale(${j.value})`
|
|
437
436
|
})
|
|
438
|
-
}, [
|
|
437
|
+
}, [d("video", {
|
|
439
438
|
ref_key: "camera",
|
|
440
|
-
ref:
|
|
439
|
+
ref: b,
|
|
441
440
|
class: "camera__video",
|
|
442
|
-
style:
|
|
443
|
-
filter:
|
|
444
|
-
transform:
|
|
441
|
+
style: h({
|
|
442
|
+
filter: y.filter === "grayscale" ? "grayscale(100%)" : y.filter === "sepia" ? "sepia(100%)" : "none",
|
|
443
|
+
transform: o.correctOrientation && M.value ? "rotate(180deg)" : void 0
|
|
445
444
|
}),
|
|
446
445
|
autoplay: "",
|
|
447
446
|
muted: "",
|
|
448
447
|
playsinline: ""
|
|
449
|
-
}, null, 4),
|
|
448
|
+
}, null, 4), o.tintColor ? (g(), u("div", {
|
|
450
449
|
key: 0,
|
|
451
450
|
class: "camera__tint-overlay",
|
|
452
|
-
style:
|
|
453
|
-
backgroundColor:
|
|
454
|
-
opacity:
|
|
451
|
+
style: h({
|
|
452
|
+
backgroundColor: o.tintColor,
|
|
453
|
+
opacity: o.tintIntensity,
|
|
455
454
|
mixBlendMode: "multiply"
|
|
456
455
|
})
|
|
457
|
-
}, null, 4)) :
|
|
458
|
-
oe(
|
|
456
|
+
}, null, 4)) : l("", !0)], 6), [[re, L.value]]),
|
|
457
|
+
oe(d("canvas", {
|
|
459
458
|
ref_key: "canvas",
|
|
460
|
-
ref:
|
|
459
|
+
ref: x,
|
|
461
460
|
class: "camera__canvas",
|
|
462
|
-
width:
|
|
463
|
-
height:
|
|
464
|
-
}, null, 8, fe), [[re,
|
|
465
|
-
|
|
461
|
+
width: O.value,
|
|
462
|
+
height: k.value
|
|
463
|
+
}, null, 8, fe), [[re, D.value]]),
|
|
464
|
+
A.value ? (g(), u("div", pe, [(g(), u("p", {
|
|
466
465
|
class: "countdown",
|
|
467
|
-
key:
|
|
468
|
-
innerHTML:
|
|
469
|
-
"data-countdown":
|
|
470
|
-
}, null, 8, me))])) :
|
|
471
|
-
|
|
466
|
+
key: A.value,
|
|
467
|
+
innerHTML: A.value,
|
|
468
|
+
"data-countdown": A.value
|
|
469
|
+
}, null, 8, me))])) : l("", !0),
|
|
470
|
+
o.enableGuide && E.value && L.value ? (g(), u("img", {
|
|
472
471
|
key: 2,
|
|
473
472
|
class: "camera__guide",
|
|
474
|
-
src:
|
|
475
|
-
}, null, 8, he)) :
|
|
476
|
-
|
|
477
|
-
modelValue:
|
|
478
|
-
"onUpdate:modelValue":
|
|
479
|
-
}, null, 8, ["modelValue"])])) :
|
|
473
|
+
src: o.guideSrc
|
|
474
|
+
}, null, 8, he)) : l("", !0),
|
|
475
|
+
o.enableZoomSlider ? (g(), u("div", ge, [f(a, {
|
|
476
|
+
modelValue: j.value,
|
|
477
|
+
"onUpdate:modelValue": i[0] ||= (e) => j.value = e
|
|
478
|
+
}, null, 8, ["modelValue"])])) : l("", !0)
|
|
480
479
|
]),
|
|
481
|
-
|
|
480
|
+
d("div", _e, [d("div", ve, [d("div", ye, [d("div", be, [d("div", xe, [d("button", {
|
|
482
481
|
type: "button",
|
|
483
482
|
class: "camera__toggle btn btn-primary",
|
|
484
|
-
onClick:
|
|
485
|
-
}, [
|
|
483
|
+
onClick: et
|
|
484
|
+
}, [E.value ? (g(), u("span", Ce, v(n.$t("common.pause")), 1)) : (g(), u("span", Se, v(n.$t("common.play")), 1))]), d("button", {
|
|
486
485
|
type: "button",
|
|
487
486
|
class: "camera__capture btn btn-primary",
|
|
488
|
-
onClick:
|
|
489
|
-
},
|
|
490
|
-
(
|
|
487
|
+
onClick: rt
|
|
488
|
+
}, v(n.$t("camera.capture")), 1)])])])])]),
|
|
489
|
+
(o.enableSwitchCamera || o.enableSelectDevice) && K.value && K.value.length > 1 ? (g(), u("div", we, [d("div", Te, [o.enableSelectDevice ? (g(), c(r, {
|
|
491
490
|
key: 0,
|
|
492
491
|
modelValue: Ue.value,
|
|
493
|
-
"onUpdate:modelValue":
|
|
492
|
+
"onUpdate:modelValue": i[1] ||= (e) => Ue.value = e,
|
|
494
493
|
options: He.value,
|
|
495
494
|
class: "w-100"
|
|
496
|
-
}, null, 8, ["modelValue", "options"])) :
|
|
495
|
+
}, null, 8, ["modelValue", "options"])) : l("", !0)]), d("div", Ee, [o.enableSwitchCamera ? (g(), u("button", {
|
|
497
496
|
key: 0,
|
|
498
497
|
class: "btn",
|
|
499
|
-
onClick: se(
|
|
500
|
-
}, [
|
|
498
|
+
onClick: se(tt, ["prevent"])
|
|
499
|
+
}, [f(e, { symbol: "switch-camera" })])) : l("", !0)])])) : l("", !0)
|
|
501
500
|
], 2));
|
|
502
501
|
}
|
|
503
502
|
});
|
|
504
503
|
//#endregion
|
|
505
|
-
export {
|
|
504
|
+
export { y as default };
|