@feugene/granularity-media 0.2.1 → 0.4.0
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/README.md +23 -6
- package/dist/chunks/{config-CZ4ZDG0_.js → config-DHLlFslI.js} +1 -1
- package/dist/chunks/config-DfJkKtIh.js +27 -0
- package/dist/chunks/{en-C-Wc5fTB.js → en-BugobSAO.js} +12 -4
- package/dist/chunks/{es-BUPtE9_0.js → es-B7iA-ExH.js} +12 -4
- package/dist/chunks/outputSize-D2FU4CbB.js +23 -0
- package/dist/chunks/ru-DSjpFh8N.js +4 -0
- package/dist/chunks/{ru-BqNILj54.js → ru-DpiW6Vax.js} +12 -4
- package/dist/chunks/useCameraStream-CPdm3r90.js +86 -0
- package/dist/components/GrCameraCapture/chunks/GrCameraCapture-t-uFTD9s.js +134 -0
- package/dist/components/GrCameraCapture/index.js +4 -3
- package/dist/components/GrCodeScanner/chunks/GrCodeScanner-BX147Gct.js +162 -0
- package/dist/components/GrCodeScanner/index.js +3 -0
- package/dist/components/GrImageCrop/chunks/{GrImageCrop-Fo2qrX2n.js → GrImageCrop-g1StRUis.js} +85 -84
- package/dist/components/GrImageCrop/index.js +1 -1
- package/dist/granular-provider.js +14 -12
- package/dist/i18n/all.js +1 -1
- package/dist/i18n/index.js +4 -4
- package/dist/index.js +8 -5
- package/dist/resolver.js +5 -1
- package/dist/types/componentNames.d.ts +1 -1
- package/dist/types/components/GrCameraCapture/GrCameraCapture.vue.d.ts +13 -9
- package/dist/types/components/GrCameraCapture/cameraState.d.ts +0 -17
- package/dist/types/components/GrCameraCapture/grCameraCaptureStyles.d.ts +6 -2
- package/dist/types/components/GrCameraCapture/index.d.ts +2 -2
- package/dist/types/components/GrCodeScanner/GrCodeScanner.vue.d.ts +121 -0
- package/dist/types/components/GrCodeScanner/__tests__/GrCodeScanner.test.d.ts +1 -0
- package/dist/types/components/GrCodeScanner/__tests__/codeDetection.test.d.ts +1 -0
- package/dist/types/components/GrCodeScanner/codeDetection.d.ts +42 -0
- package/dist/types/components/GrCodeScanner/config.d.ts +5 -0
- package/dist/types/components/GrCodeScanner/defaults.d.ts +16 -0
- package/dist/types/components/GrCodeScanner/grCodeScannerStyles.d.ts +19 -0
- package/dist/types/components/GrCodeScanner/index.d.ts +9 -0
- package/dist/types/granular-provider/shared.d.ts +1 -0
- package/dist/types/i18n/index.d.ts +21 -0
- package/dist/types/i18n/messages/en.d.ts +14 -0
- package/dist/types/i18n/messages/es.d.ts +14 -0
- package/dist/types/i18n/messages/ru.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/internal/__tests__/outputSize.test.d.ts +1 -0
- package/dist/types/internal/outputSize.d.ts +26 -0
- package/dist/types/internal/useCameraStream.d.ts +30 -0
- package/package.json +5 -1
- package/dist/chunks/ru-DN_wJDkP.js +0 -4
- package/dist/components/GrCameraCapture/chunks/GrCameraCapture-B9EPXm7r.js +0 -201
package/dist/components/GrImageCrop/chunks/{GrImageCrop-Fo2qrX2n.js → GrImageCrop-g1StRUis.js}
RENAMED
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { t as e } from "../../../chunks/outputSize-D2FU4CbB.js";
|
|
2
|
+
import { c as t, d as n, f as r, i, l as a, n as o, o as ee, r as te, s, u as ne } from "../../../chunks/config-Be_Mh801.js";
|
|
3
|
+
import { Fragment as c, computed as l, createCommentVNode as re, createElementBlock as u, createElementVNode as d, createVNode as ie, defineComponent as f, normalizeClass as p, normalizeStyle as m, onBeforeUnmount as ae, onMounted as oe, openBlock as h, ref as g, renderSlot as _, shallowRef as se, toDisplayString as v, unref as y, watch as ce } from "vue";
|
|
4
|
+
import { useGrComponentSize as le } from "@feugene/granularity/composables/useGrComponentConfig";
|
|
5
|
+
import { useGranularityTranslations as ue } from "@feugene/granularity/composables/useGranularityTranslations";
|
|
6
|
+
import b from "@feugene/granularity/components/GrSlider";
|
|
7
|
+
import { useDragGesture as de } from "@feugene/granularity/composables/useDragGesture";
|
|
7
8
|
//#region src/components/GrImageCrop/cropGeometry.ts
|
|
8
|
-
function
|
|
9
|
+
function x(e, t) {
|
|
9
10
|
return e.width <= 0 || e.height <= 0 ? 1 : Math.max(t.width / e.width, t.height / e.height);
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
let r =
|
|
12
|
+
function S(e, t, n) {
|
|
13
|
+
let r = x(e, t) * n;
|
|
13
14
|
return {
|
|
14
15
|
width: e.width * r,
|
|
15
16
|
height: e.height * r
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
let r =
|
|
19
|
+
function C(e, t, n) {
|
|
20
|
+
let r = S(e, t, n);
|
|
20
21
|
return {
|
|
21
22
|
x: Math.max(0, (r.width - t.width) / 2),
|
|
22
23
|
y: Math.max(0, (r.height - t.height) / 2)
|
|
23
24
|
};
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
-
let i =
|
|
26
|
+
function w(e, t, n, r) {
|
|
27
|
+
let i = C(t, n, r);
|
|
27
28
|
return {
|
|
28
29
|
x: Math.min(i.x, Math.max(-i.x, e.x)),
|
|
29
30
|
y: Math.min(i.y, Math.max(-i.y, e.y))
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
let i =
|
|
33
|
+
function T(e, t, n, r) {
|
|
34
|
+
let i = x(e, t) * n;
|
|
34
35
|
if (i <= 0) return {
|
|
35
36
|
sx: 0,
|
|
36
37
|
sy: 0,
|
|
37
38
|
sw: 0,
|
|
38
39
|
sh: 0
|
|
39
40
|
};
|
|
40
|
-
let a =
|
|
41
|
+
let a = w(r, e, t, n), o = S(e, t, n);
|
|
41
42
|
return {
|
|
42
43
|
sx: (o.width - t.width) / 2 / i - a.x / i,
|
|
43
44
|
sy: (o.height - t.height) / 2 / i - a.y / i,
|
|
@@ -45,7 +46,7 @@ function D(e, t, n, r) {
|
|
|
45
46
|
sh: t.height / i
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function E(e, t) {
|
|
49
50
|
return {
|
|
50
51
|
width: e,
|
|
51
52
|
height: e / (t > 0 ? t : 1)
|
|
@@ -53,11 +54,11 @@ function O(e, t) {
|
|
|
53
54
|
}
|
|
54
55
|
//#endregion
|
|
55
56
|
//#region src/components/GrImageCrop/GrImageCrop.vue?vue&type=script&setup=true&lang.ts
|
|
56
|
-
var
|
|
57
|
+
var D = ["aria-label"], O = [
|
|
57
58
|
"tabindex",
|
|
58
59
|
"aria-label",
|
|
59
60
|
"aria-disabled"
|
|
60
|
-
],
|
|
61
|
+
], fe = ["src"], k = 12, A = .15, j = /* @__PURE__ */ f({
|
|
61
62
|
__name: "GrImageCrop",
|
|
62
63
|
props: {
|
|
63
64
|
src: { default: null },
|
|
@@ -79,14 +80,14 @@ var le = ["aria-label"], ue = [
|
|
|
79
80
|
"load",
|
|
80
81
|
"error"
|
|
81
82
|
],
|
|
82
|
-
setup(
|
|
83
|
-
let
|
|
83
|
+
setup(f, { expose: x, emit: S }) {
|
|
84
|
+
let C = f, j = S, { t: M } = ue(), N = le(() => C.size, { component: "GrImageCrop" }), P = g(null), F = se(null), I = g({
|
|
84
85
|
width: 0,
|
|
85
86
|
height: 0
|
|
86
|
-
}), L =
|
|
87
|
+
}), L = g(0), R = g({
|
|
87
88
|
x: 0,
|
|
88
89
|
y: 0
|
|
89
|
-
}), z =
|
|
90
|
+
}), z = g(null), B = l(() => E(L.value, C.aspectRatio)), V = l(() => F.value !== null && I.value.width > 0), H = l(() => Math.min(C.maxZoom, Math.max(1, C.zoom))), pe = l(() => {
|
|
90
91
|
let e = B.value.width > 0 && I.value.width > 0 ? Math.max(B.value.width / I.value.width, B.value.height / I.value.height) * H.value : 1;
|
|
91
92
|
return {
|
|
92
93
|
width: `${I.value.width}px`,
|
|
@@ -95,21 +96,21 @@ var le = ["aria-label"], ue = [
|
|
|
95
96
|
};
|
|
96
97
|
});
|
|
97
98
|
function U() {
|
|
98
|
-
return
|
|
99
|
+
return T(I.value, B.value, H.value, R.value);
|
|
99
100
|
}
|
|
100
101
|
function W() {
|
|
101
102
|
V.value && j("change", U());
|
|
102
103
|
}
|
|
103
104
|
function G(e, t) {
|
|
104
|
-
|
|
105
|
+
C.disabled || !V.value || (R.value = w({
|
|
105
106
|
x: R.value.x + e,
|
|
106
107
|
y: R.value.y + t
|
|
107
108
|
}, I.value, B.value, H.value), W());
|
|
108
109
|
}
|
|
109
110
|
function K(e) {
|
|
110
|
-
if (
|
|
111
|
-
let t = Math.min(
|
|
112
|
-
j("update:zoom", t), R.value =
|
|
111
|
+
if (C.disabled) return;
|
|
112
|
+
let t = Math.min(C.maxZoom, Math.max(1, e));
|
|
113
|
+
j("update:zoom", t), R.value = w(R.value, I.value, B.value, t), W();
|
|
113
114
|
}
|
|
114
115
|
function q() {
|
|
115
116
|
R.value = {
|
|
@@ -117,14 +118,14 @@ var le = ["aria-label"], ue = [
|
|
|
117
118
|
y: 0
|
|
118
119
|
}, j("update:zoom", 1), W();
|
|
119
120
|
}
|
|
120
|
-
let J =
|
|
121
|
+
let J = g({
|
|
121
122
|
x: 0,
|
|
122
123
|
y: 0
|
|
123
|
-
}), Y =
|
|
124
|
+
}), Y = g({
|
|
124
125
|
x: 0,
|
|
125
126
|
y: 0
|
|
126
|
-
}), X =
|
|
127
|
-
disabled: () =>
|
|
127
|
+
}), X = de({
|
|
128
|
+
disabled: () => C.disabled || !V.value,
|
|
128
129
|
onStart: (e) => {
|
|
129
130
|
J.value = {
|
|
130
131
|
x: e.clientX,
|
|
@@ -132,7 +133,7 @@ var le = ["aria-label"], ue = [
|
|
|
132
133
|
}, Y.value = { ...R.value };
|
|
133
134
|
},
|
|
134
135
|
onMove: (e) => {
|
|
135
|
-
R.value =
|
|
136
|
+
R.value = w({
|
|
136
137
|
x: Y.value.x + (e.clientX - J.value.x),
|
|
137
138
|
y: Y.value.y + (e.clientY - J.value.y)
|
|
138
139
|
}, I.value, B.value, H.value);
|
|
@@ -142,10 +143,10 @@ var le = ["aria-label"], ue = [
|
|
|
142
143
|
R.value = Y.value;
|
|
143
144
|
}
|
|
144
145
|
});
|
|
145
|
-
function pe(e) {
|
|
146
|
-
T.disabled || !V.value || (e.preventDefault(), K(H.value + (e.deltaY < 0 ? A : -.15)));
|
|
147
|
-
}
|
|
148
146
|
function me(e) {
|
|
147
|
+
C.disabled || !V.value || (e.preventDefault(), K(H.value + (e.deltaY < 0 ? A : -.15)));
|
|
148
|
+
}
|
|
149
|
+
function he(e) {
|
|
149
150
|
let t = {
|
|
150
151
|
ArrowLeft: () => G(k, 0),
|
|
151
152
|
ArrowRight: () => G(-12, 0),
|
|
@@ -161,7 +162,7 @@ var le = ["aria-label"], ue = [
|
|
|
161
162
|
function Z() {
|
|
162
163
|
z.value &&= (URL.revokeObjectURL(z.value), null);
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
+
function ge(e) {
|
|
165
166
|
if (!e) return null;
|
|
166
167
|
if (typeof e == "string") return e;
|
|
167
168
|
let t = URL.createObjectURL(e);
|
|
@@ -169,7 +170,7 @@ var le = ["aria-label"], ue = [
|
|
|
169
170
|
}
|
|
170
171
|
function Q(e) {
|
|
171
172
|
Z();
|
|
172
|
-
let t =
|
|
173
|
+
let t = ge(e);
|
|
173
174
|
if (!t) {
|
|
174
175
|
F.value = null, I.value = {
|
|
175
176
|
width: 0,
|
|
@@ -189,83 +190,83 @@ var le = ["aria-label"], ue = [
|
|
|
189
190
|
}), n.addEventListener("error", (e) => j("error", e)), n.src = t;
|
|
190
191
|
}
|
|
191
192
|
let $ = null;
|
|
192
|
-
|
|
193
|
+
oe(() => {
|
|
193
194
|
P.value && (L.value = P.value.clientWidth, $ = new ResizeObserver(([e]) => {
|
|
194
|
-
L.value = e?.contentRect.width ?? 0, R.value =
|
|
195
|
-
}), $.observe(P.value)), Q(
|
|
196
|
-
}),
|
|
195
|
+
L.value = e?.contentRect.width ?? 0, R.value = w(R.value, I.value, B.value, H.value);
|
|
196
|
+
}), $.observe(P.value)), Q(C.src);
|
|
197
|
+
}), ae(() => {
|
|
197
198
|
$?.disconnect(), $ = null, Z();
|
|
198
|
-
}),
|
|
199
|
-
async function
|
|
200
|
-
let
|
|
201
|
-
if (!
|
|
202
|
-
let
|
|
203
|
-
|
|
204
|
-
let
|
|
205
|
-
if (!
|
|
206
|
-
|
|
199
|
+
}), ce(() => C.src, (e) => Q(e));
|
|
200
|
+
async function _e() {
|
|
201
|
+
let t = F.value;
|
|
202
|
+
if (!t || !V.value) return null;
|
|
203
|
+
let n = U(), r = document.createElement("canvas"), i = e(n, C.output);
|
|
204
|
+
r.width = i.width, r.height = i.height;
|
|
205
|
+
let a = r.getContext("2d");
|
|
206
|
+
if (!a) return null;
|
|
207
|
+
a.drawImage(t, n.sx, n.sy, n.sw, n.sh, 0, 0, r.width, r.height);
|
|
207
208
|
try {
|
|
208
209
|
return await new Promise((e) => {
|
|
209
|
-
|
|
210
|
+
r.toBlob(e, C.output?.type ?? "image/png", C.output?.quality);
|
|
210
211
|
});
|
|
211
212
|
} catch (e) {
|
|
212
213
|
return typeof process < "u" && process.env.NODE_ENV !== "production" && console.warn("[granularity-media] GrImageCrop: экспорт кадра запрещён политикой источника. Картинка приехала с другого домена без заголовка `Access-Control-Allow-Origin`, и холст стал непригоден для чтения."), j("error", e), null;
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
|
-
return
|
|
216
|
-
crop:
|
|
216
|
+
return x({
|
|
217
|
+
crop: _e,
|
|
217
218
|
reset: q,
|
|
218
219
|
rect: U
|
|
219
|
-
}), (
|
|
220
|
-
class:
|
|
220
|
+
}), (e, l) => (h(), u("div", {
|
|
221
|
+
class: p(y(a)),
|
|
221
222
|
role: "group",
|
|
222
|
-
"aria-label":
|
|
223
|
-
}, [
|
|
223
|
+
"aria-label": f.ariaLabel ?? y(M)("grMedia.imageCrop.label", "Image crop")
|
|
224
|
+
}, [d("div", {
|
|
224
225
|
ref_key: "viewportEl",
|
|
225
226
|
ref: P,
|
|
226
227
|
role: "application",
|
|
227
|
-
class:
|
|
228
|
-
style:
|
|
229
|
-
tabindex:
|
|
230
|
-
"aria-label":
|
|
231
|
-
"aria-disabled":
|
|
232
|
-
onPointerdown:
|
|
233
|
-
onWheel:
|
|
234
|
-
onKeydown:
|
|
235
|
-
}, [V.value ? (
|
|
228
|
+
class: p([y(r), V.value ? "" : [y(i), y(ne)[y(N)]]]),
|
|
229
|
+
style: m(V.value ? { aspectRatio: String(f.aspectRatio) } : void 0),
|
|
230
|
+
tabindex: f.disabled || !V.value ? -1 : 0,
|
|
231
|
+
"aria-label": y(M)("grMedia.imageCrop.frame", "Frame: arrow keys move the image, plus and minus zoom"),
|
|
232
|
+
"aria-disabled": f.disabled || void 0,
|
|
233
|
+
onPointerdown: l[0] ||= (...e) => y(X).start && y(X).start(...e),
|
|
234
|
+
onWheel: me,
|
|
235
|
+
onKeydown: he
|
|
236
|
+
}, [V.value ? (h(), u(c, { key: 0 }, [d("img", {
|
|
236
237
|
src: F.value.src,
|
|
237
238
|
alt: "",
|
|
238
|
-
class:
|
|
239
|
-
style:
|
|
240
|
-
}, null, 14,
|
|
239
|
+
class: p([y(ee), y(X).isDragging.value ? "" : y(s)]),
|
|
240
|
+
style: m(pe.value)
|
|
241
|
+
}, null, 14, fe), f.shape === "circle" ? (h(), u("div", {
|
|
241
242
|
key: 0,
|
|
242
|
-
class:
|
|
243
|
-
}, null, 2)) : (
|
|
243
|
+
class: p(y(o))
|
|
244
|
+
}, null, 2)) : (h(), u("div", {
|
|
244
245
|
key: 1,
|
|
245
|
-
class:
|
|
246
|
-
}, null, 2))], 64)) :
|
|
246
|
+
class: p(y(t))
|
|
247
|
+
}, null, 2))], 64)) : _(e.$slots, "empty", {}, () => [d("span", { class: p(y(n)[y(N)]) }, v(y(M)("grMedia.imageCrop.empty", "No image selected")), 3)], void 0, 1)], 46, O), V.value ? (h(), u("div", {
|
|
247
248
|
key: 0,
|
|
248
|
-
class:
|
|
249
|
-
}, [
|
|
249
|
+
class: p(y(te))
|
|
250
|
+
}, [_(e.$slots, "controls", {
|
|
250
251
|
zoom: H.value,
|
|
251
252
|
setZoom: K
|
|
252
|
-
}, () => [
|
|
253
|
+
}, () => [ie(y(b), {
|
|
253
254
|
"model-value": H.value,
|
|
254
255
|
min: 1,
|
|
255
|
-
max:
|
|
256
|
+
max: f.maxZoom,
|
|
256
257
|
step: .01,
|
|
257
|
-
size:
|
|
258
|
-
disabled:
|
|
259
|
-
"aria-label":
|
|
260
|
-
"onUpdate:modelValue":
|
|
258
|
+
size: y(N),
|
|
259
|
+
disabled: f.disabled,
|
|
260
|
+
"aria-label": y(M)("grMedia.imageCrop.zoom", "Zoom"),
|
|
261
|
+
"onUpdate:modelValue": l[1] ||= (e) => K(Number(e))
|
|
261
262
|
}, null, 8, [
|
|
262
263
|
"model-value",
|
|
263
264
|
"max",
|
|
264
265
|
"size",
|
|
265
266
|
"disabled",
|
|
266
267
|
"aria-label"
|
|
267
|
-
])])], 2)) :
|
|
268
|
+
])])], 2)) : re("", !0)], 10, D));
|
|
268
269
|
}
|
|
269
270
|
});
|
|
270
271
|
//#endregion
|
|
271
|
-
export {
|
|
272
|
+
export { S as a, T as i, w as n, C as o, x as r, E as s, j as t };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./chunks/GrImageCrop-
|
|
1
|
+
import { a as e, i as t, n, o as r, r as i, s as a, t as o } from "./chunks/GrImageCrop-g1StRUis.js";
|
|
2
2
|
import { a as s, t as c } from "../../chunks/config-Be_Mh801.js";
|
|
3
3
|
export { o as GrImageCrop, o as default, n as clampOffset, i as coverScale, t as cropRect, e as displaySize, c as grImageCropConfig, s as grImageCropSafelist, r as offsetBounds, a as viewportFor };
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { t as e } from "./chunks/config-
|
|
2
|
-
import { t } from "./chunks/config-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { t as e } from "./chunks/config-DHLlFslI.js";
|
|
2
|
+
import { t } from "./chunks/config-DfJkKtIh.js";
|
|
3
|
+
import { t as n } from "./chunks/config-Be_Mh801.js";
|
|
4
|
+
import { defineGranularProvider as r, resolvePackageBaseUrl as i } from "@feugene/unocss-preset-granular/contract";
|
|
5
|
+
import { granularityProvider as a } from "@feugene/granularity/granular-provider";
|
|
5
6
|
//#region src/granular-provider/shared.ts
|
|
6
|
-
var
|
|
7
|
+
var o = "@feugene/granularity-media", s = {
|
|
7
8
|
GrCameraCapture: e,
|
|
8
|
-
|
|
9
|
+
GrCodeScanner: t,
|
|
10
|
+
GrImageCrop: n
|
|
9
11
|
};
|
|
10
|
-
function
|
|
11
|
-
return
|
|
12
|
-
id:
|
|
12
|
+
function c(e, t) {
|
|
13
|
+
return r({
|
|
14
|
+
id: o,
|
|
13
15
|
contractVersion: 1,
|
|
14
16
|
packageBaseUrl: t,
|
|
15
|
-
components: Object.values(
|
|
17
|
+
components: Object.values(s),
|
|
16
18
|
dependencies: [e]
|
|
17
19
|
});
|
|
18
20
|
}
|
|
19
|
-
var
|
|
21
|
+
var l = c(a, i(import.meta.url, 0));
|
|
20
22
|
//#endregion
|
|
21
|
-
export {
|
|
23
|
+
export { o as GRANULARITY_MEDIA_PROVIDER_ID, c as createGranularityMediaProvider, l as default, l as granularityMediaProvider, s as granularityMediaComponentConfigs };
|
package/dist/i18n/all.js
CHANGED
package/dist/i18n/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as e } from "../chunks/en-
|
|
2
|
-
import { t } from "../chunks/es-
|
|
3
|
-
import { t as n } from "../chunks/ru-
|
|
4
|
-
import { i as r, n as i, r as a, t as o } from "../chunks/ru-
|
|
1
|
+
import { t as e } from "../chunks/en-BugobSAO.js";
|
|
2
|
+
import { t } from "../chunks/es-B7iA-ExH.js";
|
|
3
|
+
import { t as n } from "../chunks/ru-DpiW6Vax.js";
|
|
4
|
+
import { i as r, n as i, r as a, t as o } from "../chunks/ru-DSjpFh8N.js";
|
|
5
5
|
//#region src/i18n/index.ts
|
|
6
6
|
var s = {
|
|
7
7
|
en: e,
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { i as e, n as t, r as n } from "./chunks/useCameraStream-CPdm3r90.js";
|
|
2
|
+
import { i as r, t as i } from "./chunks/config-DHLlFslI.js";
|
|
3
|
+
import { t as a } from "./components/GrCameraCapture/chunks/GrCameraCapture-t-uFTD9s.js";
|
|
4
|
+
import { i as o, n as s, r as c, t as l } from "./components/GrCodeScanner/chunks/GrCodeScanner-BX147Gct.js";
|
|
5
|
+
import { i as u, t as d } from "./chunks/config-DfJkKtIh.js";
|
|
6
|
+
import { a as f, i as p, n as m, o as h, r as g, s as _, t as v } from "./components/GrImageCrop/chunks/GrImageCrop-g1StRUis.js";
|
|
7
|
+
import { a as y, t as b } from "./chunks/config-Be_Mh801.js";
|
|
8
|
+
export { a as GrCameraCapture, l as GrCodeScanner, v as GrImageCrop, t as cameraStatusFromError, n as cameraSupported, m as clampOffset, g as coverScale, s as createNativeDetector, p as cropRect, f as displaySize, c as freshCodes, i as grCameraCaptureConfig, r as grCameraCaptureSafelist, d as grCodeScannerConfig, u as grCodeScannerSafelist, b as grImageCropConfig, y as grImageCropSafelist, o as nativeDetectorSupported, h as offsetBounds, e as shouldMirrorPreview, _ as viewportFor };
|
package/dist/resolver.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createGranularResolver as e } from "@feugene/unplugin-granularity";
|
|
2
2
|
//#region src/componentNames.ts
|
|
3
|
-
var t = [
|
|
3
|
+
var t = [
|
|
4
|
+
"GrCameraCapture",
|
|
5
|
+
"GrCodeScanner",
|
|
6
|
+
"GrImageCrop"
|
|
7
|
+
], n = "@feugene/granularity-media";
|
|
4
8
|
function r() {
|
|
5
9
|
return e({
|
|
6
10
|
packageName: n,
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Список генерируется `yarn generate:registry` — руками не писать.
|
|
10
10
|
*/
|
|
11
|
-
export declare const GRANULARITY_MEDIA_COMPONENTS: readonly ["GrCameraCapture", "GrImageCrop"];
|
|
11
|
+
export declare const GRANULARITY_MEDIA_COMPONENTS: readonly ["GrCameraCapture", "GrCodeScanner", "GrImageCrop"];
|
|
12
12
|
export type GranularityMediaComponentName = typeof GRANULARITY_MEDIA_COMPONENTS[number];
|
|
@@ -12,10 +12,11 @@ export interface GrCameraCaptureProps {
|
|
|
12
12
|
/** Конкретное устройство, если приложение его уже выбрало. */
|
|
13
13
|
deviceId?: string;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Пожелание камере: какое соотношение сторон запросить у устройства.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
17
|
+
* Это **не обрезка**. Камера, которая умеет запрошенное, отдаст его сама;
|
|
18
|
+
* та, что не умеет, отдаст своё — и показан, и снят будет её настоящий кадр.
|
|
19
|
+
* Нужен ровно квадрат — это `GrImageCrop` после съёмки.
|
|
19
20
|
*/
|
|
20
21
|
aspectRatio?: number;
|
|
21
22
|
/**
|
|
@@ -47,10 +48,13 @@ type __VLS_Slots = {
|
|
|
47
48
|
capture: () => Promise<Blob | null>;
|
|
48
49
|
}) => unknown;
|
|
49
50
|
};
|
|
50
|
-
declare function start(): Promise<void>;
|
|
51
|
-
declare function stop(): void;
|
|
52
51
|
/**
|
|
53
|
-
* Снимок текущего
|
|
52
|
+
* Снимок текущего кадра — целиком, без среза.
|
|
53
|
+
*
|
|
54
|
+
* Камеры на разных устройствах отдают разные размеры и соотношения, поэтому
|
|
55
|
+
* подгонять кадр под окно бессмысленно: на одном телефоне срезалось бы одно, на
|
|
56
|
+
* другом другое. Снимок повторяет то, что показывало превью, а обрезка под
|
|
57
|
+
* нужное место — работа `GrImageCrop`.
|
|
54
58
|
*
|
|
55
59
|
* Зеркало превью сюда **не переносится**: на снимке оказывается то, что было
|
|
56
60
|
* перед камерой. Иначе текст на визитке или в документе уехал бы в зазеркалье —
|
|
@@ -68,8 +72,8 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
68
72
|
disabled: boolean;
|
|
69
73
|
ariaLabel: undefined;
|
|
70
74
|
}>>, {
|
|
71
|
-
start:
|
|
72
|
-
stop:
|
|
75
|
+
start: () => Promise<void>;
|
|
76
|
+
stop: () => void;
|
|
73
77
|
capture: typeof capture;
|
|
74
78
|
status: import("vue").Ref<GrCameraStatus, GrCameraStatus>;
|
|
75
79
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
@@ -93,9 +97,9 @@ declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPro
|
|
|
93
97
|
onStop?: (() => any) | undefined;
|
|
94
98
|
onStatusChange?: ((status: GrCameraStatus) => any) | undefined;
|
|
95
99
|
}>, {
|
|
96
|
-
facing: GrCameraFacing;
|
|
97
100
|
deviceId: string;
|
|
98
101
|
aspectRatio: number;
|
|
102
|
+
facing: GrCameraFacing;
|
|
99
103
|
autoStart: boolean;
|
|
100
104
|
mirror: boolean;
|
|
101
105
|
output: GrCameraCaptureOutput;
|
|
@@ -48,20 +48,3 @@ export declare function cameraSupported(navigatorLike: Pick<Navigator, 'mediaDev
|
|
|
48
48
|
* уедет в зазеркалье — а снимают ими ровно это.
|
|
49
49
|
*/
|
|
50
50
|
export declare function shouldMirrorPreview(facing: 'user' | 'environment', mirror: boolean | undefined): boolean;
|
|
51
|
-
export interface GrCameraFrameRect {
|
|
52
|
-
sx: number;
|
|
53
|
-
sy: number;
|
|
54
|
-
sw: number;
|
|
55
|
-
sh: number;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Какая часть кадра камеры попадёт в снимок при заданном соотношении сторон.
|
|
59
|
-
*
|
|
60
|
-
* Камера отдаёт своё соотношение (обычно 4:3 или 16:9), а приложению нужно
|
|
61
|
-
* своё. Лишнее срезается по центру — так же, как это делает `object-fit: cover`
|
|
62
|
-
* в превью: снимок обязан совпасть с тем, что пользователь видел.
|
|
63
|
-
*/
|
|
64
|
-
export declare function cameraFrameRect(frame: {
|
|
65
|
-
width: number;
|
|
66
|
-
height: number;
|
|
67
|
-
}, aspectRatio: number): GrCameraFrameRect;
|
|
@@ -2,8 +2,12 @@ export type GrCameraCaptureSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
|
2
2
|
export type GrCameraFacing = 'user' | 'environment';
|
|
3
3
|
export declare const rootClass = "grid gap-2";
|
|
4
4
|
export declare const frameClass = "relative w-full overflow-hidden rounded-[var(--gr-radius-md)] border border-[var(--gr-brd)] bg-[var(--gr-muted)]";
|
|
5
|
-
/**
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Превью **вписывается**, а не покрывает: кадр показывается целиком, в своих
|
|
7
|
+
* пропорциях. При совпадающей рамке разницы нет, но между стартом и первым
|
|
8
|
+
* кадром рамка ещё держит запасные 4:3 — и `cover` срезал бы картинку.
|
|
9
|
+
*/
|
|
10
|
+
export declare const videoClass = "h-full w-full object-contain";
|
|
7
11
|
export declare const mirroredClass = "scale-x-[-1]";
|
|
8
12
|
/**
|
|
9
13
|
* Подложка состояния поверх рамки. Появление плавное: отказ и ошибка приходят
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default } from './GrCameraCapture.vue';
|
|
2
2
|
export { default as GrCameraCapture } from './GrCameraCapture.vue';
|
|
3
|
-
export type {
|
|
4
|
-
export {
|
|
3
|
+
export type { GrCameraStatus } from './cameraState';
|
|
4
|
+
export { cameraStatusFromError, cameraSupported, shouldMirrorPreview } from './cameraState';
|
|
5
5
|
export { grCameraCaptureConfig } from './config';
|
|
6
6
|
export type { GrCameraCaptureConfigurableProps } from './defaults';
|
|
7
7
|
export type { GrCameraCaptureEmits, GrCameraCaptureOutput, GrCameraCaptureProps } from './GrCameraCapture.vue';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { GrCameraStatus } from '../GrCameraCapture/cameraState';
|
|
2
|
+
import type { GrCodeDetector, GrCodeResult } from './codeDetection';
|
|
3
|
+
import type { GrCodeScannerSize } from './grCodeScannerStyles';
|
|
4
|
+
export interface GrCodeScannerProps {
|
|
5
|
+
/** Какая камера: `environment` — тыловая, ей и сканируют. */
|
|
6
|
+
facing?: 'user' | 'environment';
|
|
7
|
+
deviceId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Включать камеру сразу.
|
|
10
|
+
*
|
|
11
|
+
* По умолчанию `false`: запрос разрешения без действия пользователя
|
|
12
|
+
* отклоняют не глядя, а второй раз браузер уже не спросит.
|
|
13
|
+
*/
|
|
14
|
+
autoStart?: boolean;
|
|
15
|
+
/** Символики: `qr_code`, `ean_13`, `code_128`, … Без списка — все, что умеет браузер. */
|
|
16
|
+
formats?: readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* Детектор для браузеров без `BarcodeDetector` — Safari и Firefox.
|
|
19
|
+
*
|
|
20
|
+
* Пакет своего декодера не несёт: у него нет ни одной зависимости, и ради
|
|
21
|
+
* одного компонента появилась бы самая тяжёлая. Рецепт подключения готовой
|
|
22
|
+
* библиотеки — на странице компонента.
|
|
23
|
+
*/
|
|
24
|
+
detector?: GrCodeDetector;
|
|
25
|
+
/** Как часто разбирать кадр, мс. Чаще — горячее устройство, реже — вялый отклик. */
|
|
26
|
+
interval?: number;
|
|
27
|
+
/** Сообщать один и тот же код повторно: приёмка сканирует подряд. */
|
|
28
|
+
continuous?: boolean;
|
|
29
|
+
size?: GrCodeScannerSize;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
ariaLabel?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface GrCodeScannerEmits {
|
|
34
|
+
(e: 'detect', codes: GrCodeResult[]): void;
|
|
35
|
+
(e: 'start'): void;
|
|
36
|
+
(e: 'stop'): void;
|
|
37
|
+
(e: 'statusChange', status: GrCameraStatus): void;
|
|
38
|
+
}
|
|
39
|
+
type __VLS_Slots = {
|
|
40
|
+
/** Своя панель управления вместо встроенной. */
|
|
41
|
+
controls?: (props: {
|
|
42
|
+
status: GrCameraStatus;
|
|
43
|
+
start: () => void;
|
|
44
|
+
stop: () => void;
|
|
45
|
+
}) => unknown;
|
|
46
|
+
};
|
|
47
|
+
declare function stopAll(): void;
|
|
48
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<GrCodeScannerProps>, {
|
|
49
|
+
facing: string;
|
|
50
|
+
deviceId: undefined;
|
|
51
|
+
autoStart: boolean;
|
|
52
|
+
formats: undefined;
|
|
53
|
+
detector: undefined;
|
|
54
|
+
interval: number;
|
|
55
|
+
continuous: boolean;
|
|
56
|
+
size: undefined;
|
|
57
|
+
disabled: boolean;
|
|
58
|
+
ariaLabel: undefined;
|
|
59
|
+
}>>, {
|
|
60
|
+
start: () => Promise<void>;
|
|
61
|
+
stop: typeof stopAll;
|
|
62
|
+
status: import("vue").Ref<GrCameraStatus, GrCameraStatus>;
|
|
63
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
64
|
+
detect: (codes: GrCodeResult[]) => void;
|
|
65
|
+
start: () => void;
|
|
66
|
+
stop: () => void;
|
|
67
|
+
statusChange: (status: GrCameraStatus) => void;
|
|
68
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<GrCodeScannerProps>, {
|
|
69
|
+
facing: string;
|
|
70
|
+
deviceId: undefined;
|
|
71
|
+
autoStart: boolean;
|
|
72
|
+
formats: undefined;
|
|
73
|
+
detector: undefined;
|
|
74
|
+
interval: number;
|
|
75
|
+
continuous: boolean;
|
|
76
|
+
size: undefined;
|
|
77
|
+
disabled: boolean;
|
|
78
|
+
ariaLabel: undefined;
|
|
79
|
+
}>>> & Readonly<{
|
|
80
|
+
onStart?: (() => any) | undefined;
|
|
81
|
+
onStop?: (() => any) | undefined;
|
|
82
|
+
onStatusChange?: ((status: GrCameraStatus) => any) | undefined;
|
|
83
|
+
onDetect?: ((codes: GrCodeResult[]) => any) | undefined;
|
|
84
|
+
}>, {
|
|
85
|
+
deviceId: string;
|
|
86
|
+
facing: "user" | "environment";
|
|
87
|
+
autoStart: boolean;
|
|
88
|
+
size: GrCodeScannerSize;
|
|
89
|
+
disabled: boolean;
|
|
90
|
+
ariaLabel: string;
|
|
91
|
+
formats: readonly string[];
|
|
92
|
+
detector: GrCodeDetector;
|
|
93
|
+
interval: number;
|
|
94
|
+
continuous: boolean;
|
|
95
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
96
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
97
|
+
declare const _default: typeof __VLS_export;
|
|
98
|
+
export default _default;
|
|
99
|
+
type __VLS_TypePropsToOption<T> = {
|
|
100
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
101
|
+
type: import('vue').PropType<Required<T>[K]>;
|
|
102
|
+
} : {
|
|
103
|
+
type: import('vue').PropType<T[K]>;
|
|
104
|
+
required: true;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
type __VLS_WithDefaults<P, D> = {
|
|
108
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_PrettifyLocal<P[K] & {
|
|
109
|
+
default: D[K];
|
|
110
|
+
}> : P[K];
|
|
111
|
+
};
|
|
112
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
113
|
+
new (): {
|
|
114
|
+
$slots: S;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
type __VLS_PrettifyLocal<T> = (T extends any ? {
|
|
118
|
+
[K in keyof T]: T[K];
|
|
119
|
+
} : {
|
|
120
|
+
[K in keyof T as K]: T[K];
|
|
121
|
+
}) & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|