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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CameraDevice, CameraErrorCode, Facing, StartOptions } from './types';
|
|
2
|
+
export interface ChainStep {
|
|
3
|
+
label: string;
|
|
4
|
+
constraints: MediaStreamConstraints;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Progressive fallback chain. Samsung Internet / Android Chrome throw
|
|
8
|
+
* OverconstrainedError for ideal dims and facingMode, so each attempt drops
|
|
9
|
+
* one requirement. deviceId and facingMode are never combined: Samsung honors
|
|
10
|
+
* deviceId, and facingMode is only a hint for the very first start.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildFallbackChain(opts: StartOptions & {
|
|
13
|
+
strictDevice?: boolean;
|
|
14
|
+
}): ChainStep[];
|
|
15
|
+
export declare function errorName(err: unknown): string;
|
|
16
|
+
/** Errors where walking further down the chain cannot help. */
|
|
17
|
+
export declare function isFatalGumError(err: unknown): boolean;
|
|
18
|
+
/** Hardware still held by a previous stream (Android release lag) — worth one retry. */
|
|
19
|
+
export declare function isTransientGumError(err: unknown): boolean;
|
|
20
|
+
export declare function toErrorCode(err: unknown): CameraErrorCode;
|
|
21
|
+
export declare function classifyFacingFromLabel(label: string): Facing | null;
|
|
22
|
+
export declare function normalizeFacing(value: unknown): Facing | null;
|
|
23
|
+
/**
|
|
24
|
+
* One device per known facing (prefers the active id, then probed, then first),
|
|
25
|
+
* devices with unknown facing are kept so elimination switching still works.
|
|
26
|
+
*/
|
|
27
|
+
export declare function dedupeByFacing(devices: CameraDevice[], activeDeviceId?: string | null): CameraDevice[];
|
|
28
|
+
/** Opposite facing when both known, otherwise next device ≠ active (cyclic). */
|
|
29
|
+
export declare function pickSwitchTarget(devices: CameraDevice[], activeDeviceId: string | null, activeFacing: Facing | null): CameraDevice | null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
//#region src/utilities/camera/constraints.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
let { deviceId: n, facing: r, resolution: i } = e, a = i ? t(i) : null, o = [];
|
|
4
|
+
return n && (a && o.push({
|
|
5
|
+
label: "device+dims",
|
|
6
|
+
constraints: { video: {
|
|
7
|
+
deviceId: { exact: n },
|
|
8
|
+
...a
|
|
9
|
+
} }
|
|
10
|
+
}), o.push({
|
|
11
|
+
label: "device",
|
|
12
|
+
constraints: { video: { deviceId: { exact: n } } }
|
|
13
|
+
}), e.strictDevice) ? o : (r && (a && o.push({
|
|
14
|
+
label: "facing+dims",
|
|
15
|
+
constraints: { video: {
|
|
16
|
+
facingMode: { ideal: r },
|
|
17
|
+
...a
|
|
18
|
+
} }
|
|
19
|
+
}), o.push({
|
|
20
|
+
label: "facing",
|
|
21
|
+
constraints: { video: { facingMode: { ideal: r } } }
|
|
22
|
+
})), a && o.push({
|
|
23
|
+
label: "dims",
|
|
24
|
+
constraints: { video: { ...a } }
|
|
25
|
+
}), o.push({
|
|
26
|
+
label: "any",
|
|
27
|
+
constraints: { video: !0 }
|
|
28
|
+
}), o);
|
|
29
|
+
}
|
|
30
|
+
function t(e) {
|
|
31
|
+
return {
|
|
32
|
+
width: { ideal: e.width },
|
|
33
|
+
height: { ideal: e.height }
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function n(e) {
|
|
37
|
+
return e && typeof e == "object" && "name" in e && typeof e.name == "string" ? e.name : "";
|
|
38
|
+
}
|
|
39
|
+
function r(e) {
|
|
40
|
+
let t = n(e);
|
|
41
|
+
return t === "NotAllowedError" || t === "PermissionDeniedError" || t === "SecurityError" || t === "NotFoundError";
|
|
42
|
+
}
|
|
43
|
+
function i(e) {
|
|
44
|
+
let t = n(e);
|
|
45
|
+
return t === "NotReadableError" || t === "AbortError" || t === "TrackStartError";
|
|
46
|
+
}
|
|
47
|
+
function a(e) {
|
|
48
|
+
switch (n(e)) {
|
|
49
|
+
case "NotAllowedError":
|
|
50
|
+
case "PermissionDeniedError":
|
|
51
|
+
case "SecurityError": return "not-allowed";
|
|
52
|
+
case "NotFoundError": return "not-found";
|
|
53
|
+
case "NotReadableError":
|
|
54
|
+
case "AbortError":
|
|
55
|
+
case "TrackStartError": return "not-readable";
|
|
56
|
+
case "OverconstrainedError":
|
|
57
|
+
case "ConstraintNotSatisfiedError": return "overconstrained";
|
|
58
|
+
default: return "unknown";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
var o = /\b(front|face|user|selfie|facetime)\b/i, s = /\b(back|rear|environment|main|world)\b/i;
|
|
62
|
+
function c(e) {
|
|
63
|
+
return e ? o.test(e) ? "user" : s.test(e) ? "environment" : null : null;
|
|
64
|
+
}
|
|
65
|
+
function l(e) {
|
|
66
|
+
return e === "user" || e === "environment" ? e : e === "front" ? "user" : e === "back" || e === "rear" ? "environment" : null;
|
|
67
|
+
}
|
|
68
|
+
function u(e, t) {
|
|
69
|
+
let n = /* @__PURE__ */ new Map(), r = [];
|
|
70
|
+
for (let i of e) {
|
|
71
|
+
if (!i.facing) {
|
|
72
|
+
r.push(i);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
let e = n.get(i.facing);
|
|
76
|
+
(!e || d(i, t) > d(e, t)) && n.set(i.facing, i);
|
|
77
|
+
}
|
|
78
|
+
let i = [...n.values()];
|
|
79
|
+
return i.sort((e, t) => (e.facing === "user" ? -1 : 1) - (t.facing === "user" ? -1 : 1)), [...i, ...r];
|
|
80
|
+
}
|
|
81
|
+
function d(e, t) {
|
|
82
|
+
let n = 0;
|
|
83
|
+
return e.deviceId === t && (n += 2), e.probed && (n += 1), n;
|
|
84
|
+
}
|
|
85
|
+
function f(e, t, n) {
|
|
86
|
+
let r = e.filter((e) => e.deviceId !== t);
|
|
87
|
+
if (r.length === 0) return null;
|
|
88
|
+
if (n) {
|
|
89
|
+
let e = r.find((e) => e.facing && e.facing !== n);
|
|
90
|
+
if (e) return e;
|
|
91
|
+
}
|
|
92
|
+
let i = e.findIndex((e) => e.deviceId === t);
|
|
93
|
+
return i === -1 ? r[0] ?? null : e[(i + 1) % e.length] ?? null;
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { e as buildFallbackChain, c as classifyFacingFromLabel, u as dedupeByFacing, n as errorName, r as isFatalGumError, i as isTransientGumError, l as normalizeFacing, f as pickSwitchTarget, a as toErrorCode };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface PlatformHints {
|
|
2
|
+
userAgent: string;
|
|
3
|
+
platform: string;
|
|
4
|
+
maxTouchPoints: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function detectIOS(h?: PlatformHints | null): boolean;
|
|
7
|
+
export declare function detectAndroid(h?: PlatformHints | null): boolean;
|
|
8
|
+
export declare function detectSamsungInternet(h?: PlatformHints | null): boolean;
|
|
9
|
+
export declare const isIOS: () => boolean;
|
|
10
|
+
export declare const isAndroid: () => boolean;
|
|
11
|
+
export declare function supportsRVFC(video: HTMLVideoElement): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/utilities/camera/platform.ts
|
|
2
|
+
function e() {
|
|
3
|
+
return typeof navigator > "u" ? null : {
|
|
4
|
+
userAgent: navigator.userAgent ?? "",
|
|
5
|
+
platform: navigator.platform ?? "",
|
|
6
|
+
maxTouchPoints: navigator.maxTouchPoints ?? 0
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
function t(t = e()) {
|
|
10
|
+
return t ? /iPhone|iPad|iPod/i.test(t.userAgent) ? !0 : t.platform === "MacIntel" && t.maxTouchPoints > 1 : !1;
|
|
11
|
+
}
|
|
12
|
+
function n(t = e()) {
|
|
13
|
+
return !!t && /Android/i.test(t.userAgent);
|
|
14
|
+
}
|
|
15
|
+
var r = () => t(), i = () => n();
|
|
16
|
+
function a(e) {
|
|
17
|
+
return typeof e.requestVideoFrameCallback == "function";
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { n as detectAndroid, t as detectIOS, i as isAndroid, r as isIOS, a as supportsRVFC };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type Facing = 'user' | 'environment';
|
|
2
|
+
export type CameraState = 'idle' | 'starting' | 'live' | 'paused' | 'error';
|
|
3
|
+
/** What the user asked for, independent of what the hardware is currently doing. */
|
|
4
|
+
export type CameraIntent = 'live' | 'paused' | 'stopped';
|
|
5
|
+
export type CameraPermission = 'granted' | 'denied' | 'prompt' | 'unknown';
|
|
6
|
+
export type Filter = 'none' | 'grayscale' | 'sepia';
|
|
7
|
+
export interface Resolution {
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}
|
|
11
|
+
export interface CameraDevice {
|
|
12
|
+
deviceId: string;
|
|
13
|
+
label: string;
|
|
14
|
+
/** null when neither probing nor label keywords could classify it. */
|
|
15
|
+
facing: Facing | null;
|
|
16
|
+
/** True when facing was confirmed by an actual getUserMedia probe. */
|
|
17
|
+
probed: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface StartOptions {
|
|
20
|
+
deviceId?: string;
|
|
21
|
+
facing?: Facing;
|
|
22
|
+
resolution?: Resolution;
|
|
23
|
+
}
|
|
24
|
+
export interface ZoomCapability {
|
|
25
|
+
min: number;
|
|
26
|
+
max: number;
|
|
27
|
+
step: number;
|
|
28
|
+
}
|
|
29
|
+
export type CameraErrorCode = 'not-allowed' | 'not-found' | 'not-readable' | 'overconstrained' | 'first-frame' | 'unsupported' | 'unknown';
|
|
30
|
+
export declare class CameraError extends Error {
|
|
31
|
+
readonly code: CameraErrorCode;
|
|
32
|
+
constructor(code: CameraErrorCode, message: string, cause?: unknown);
|
|
33
|
+
}
|
|
34
|
+
declare global {
|
|
35
|
+
interface MediaTrackCapabilities {
|
|
36
|
+
zoom?: {
|
|
37
|
+
min: number;
|
|
38
|
+
max: number;
|
|
39
|
+
step?: number;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
interface MediaTrackConstraintSet {
|
|
43
|
+
zoom?: ConstrainDouble;
|
|
44
|
+
}
|
|
45
|
+
interface MediaTrackSettings {
|
|
46
|
+
zoom?: number;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -9,11 +9,6 @@ async function t(e) {
|
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
function n(e) {
|
|
12
|
-
let t = atob(e.split(",")[1]), n = new ArrayBuffer(t.length), r = new Uint8Array(n);
|
|
13
|
-
for (let e = 0; e < t.length; e++) r[e] = t.charCodeAt(e);
|
|
14
|
-
return new Blob([n], { type: "image/png" });
|
|
15
|
-
}
|
|
16
|
-
function r(e) {
|
|
17
12
|
return {
|
|
18
13
|
"image/jpeg": "jpg",
|
|
19
14
|
"image/jpg": "jpg",
|
|
@@ -29,36 +24,36 @@ function r(e) {
|
|
|
29
24
|
"video/ogg": "ogg"
|
|
30
25
|
}[e] || "bin";
|
|
31
26
|
}
|
|
32
|
-
async function
|
|
33
|
-
let i = r
|
|
27
|
+
async function r(e, t, r) {
|
|
28
|
+
let i = n(r), a = t.includes(".") ? t : `${t}.${i}`;
|
|
34
29
|
return fetch(e).then(function(e) {
|
|
35
30
|
return e.arrayBuffer();
|
|
36
31
|
}).then(function(e) {
|
|
37
|
-
return new File([e], a, { type:
|
|
32
|
+
return new File([e], a, { type: r });
|
|
38
33
|
});
|
|
39
34
|
}
|
|
40
|
-
async function
|
|
35
|
+
async function i(e) {
|
|
41
36
|
return await new Promise((t, n) => {
|
|
42
37
|
let r = new Image();
|
|
43
38
|
r.onload = () => t(r), r.onerror = (e) => n(e), r.src = e;
|
|
44
39
|
});
|
|
45
40
|
}
|
|
46
|
-
function
|
|
41
|
+
function a(e, t, n, r = "image/png", i) {
|
|
47
42
|
let a = document.createElement("canvas");
|
|
48
43
|
a.width = t, a.height = n;
|
|
49
44
|
let o = a.getContext("2d");
|
|
50
45
|
return o ? (o.drawImage(e, 0, 0, t, n), a.toDataURL(r, i)) : e.src;
|
|
51
46
|
}
|
|
52
|
-
async function
|
|
47
|
+
async function o(e, n, o) {
|
|
53
48
|
let s = (e.type || "").toLowerCase();
|
|
54
49
|
if (!(s.startsWith("image/") && s !== "image/svg+xml")) return e;
|
|
55
|
-
let c = await
|
|
50
|
+
let c = await i(await t(e)), l = c.naturalWidth, u = c.naturalHeight;
|
|
56
51
|
if (!l || l <= n) return e;
|
|
57
52
|
let d = Math.round(n), f = u / l;
|
|
58
|
-
return await
|
|
53
|
+
return await r(a(c, d, Math.round(d * f), e.type || "image/png", o), e.name, e.type || "image/png");
|
|
59
54
|
}
|
|
60
|
-
function
|
|
55
|
+
function s(e) {
|
|
61
56
|
return !e || typeof e != "string" ? "" : e.replace(/\0/g, "").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").replace(/on\w+\s*=\s*["'][^"']*["']/gi, "").replace(/on\w+\s*=\s*[^\s>]*/gi, "").replace(/javascript:/gi, "").replace(/data:text\/html/gi, "");
|
|
62
57
|
}
|
|
63
58
|
//#endregion
|
|
64
|
-
export {
|
|
59
|
+
export { t as fileToDataUrl, n as getExtensionFromMimeType, i as loadImageFromDataUrl, a as resizeImageElementToDataUrl, o as resizeImageFileByMaxWidth, s as sanitizeInput, r as srcToFile, e as uniqueId };
|