@microblink/camera-manager 7.1.0 → 7.2.1
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/camera-manager.js +2157 -1364
- package/dist/camera-manager.js.map +1 -0
- package/package.json +1 -1
- package/types/core/cameraUtils.d.ts +9 -0
- package/types/core/cameraUtils.d.ts.map +1 -1
- package/types/core/cameraUtils.test.d.ts +5 -0
- package/types/core/cameraUtils.test.d.ts.map +1 -0
- package/types/index.rollup.d.ts +18 -1
- package/types/media-mock/fake-devices.d.ts.map +1 -1
- package/types/media-mock/fakeDevices/DesktopSingleFrontFacing.d.ts +6 -0
- package/types/media-mock/fakeDevices/DesktopSingleFrontFacing.d.ts.map +1 -0
- package/types/ui/CameraSelector.d.ts.map +1 -1
- package/types/ui/CameraUiStoreContext.d.ts +7 -0
- package/types/ui/CameraUiStoreContext.d.ts.map +1 -1
- package/types/ui/CaptureScreen.d.ts.map +1 -1
- package/types/ui/Header.d.ts.map +1 -1
- package/types/ui/createCameraManagerUi.d.ts +18 -1
- package/types/ui/createCameraManagerUi.d.ts.map +1 -1
package/dist/camera-manager.js
CHANGED
|
@@ -1,53 +1,76 @@
|
|
|
1
|
-
(function(){"use strict";(r=>{window.__mbCameraManagerCssCode=r})("._dialogPositioner_worsp_1{position:fixed;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);display:grid;height:100vh;width:100%;padding:calc(var(--mb-size)*2rem)}@supports (height:100dvh){._dialogPositioner_worsp_1{height:100dvh}}._dialogBackdrop_worsp_5{position:absolute;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);width:100%;height:100%;--un-bg-opacity:1;background-color:rgb(var(--color-black-rgb-value) / var(--un-bg-opacity));--un-bg-opacity:.5;--un-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia)}._dialogContent_worsp_9{position:relative;max-height:calc(100dvh - 4rem);max-width:28rem;display:flex;flex-direction:column;place-self:center;border-radius:.5rem;--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity));padding-left:min(8%,3rem);padding-right:min(8%,3rem);padding-top:min(8%,1.5rem);padding-bottom:min(8%,1.5rem);--un-text-opacity:1;color:rgb(15 15 15 / var(--un-text-opacity));--un-shadow:var(--un-shadow-inset) 0 10px 15px -3px var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 4px 6px -4px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}._dialogContent_worsp_9._large_worsp_13{padding-left:min(8%,4rem);padding-right:min(8%,4rem);padding-top:min(8%,3rem);padding-bottom:min(8%,3rem)}._dialogContent_worsp_9._compact_worsp_16{padding:min(8%,1.5rem)}@media (min-width: 640px){._dialogContent_worsp_9{max-width:36rem}}@media (min-width: 1024px){._dialogContent_worsp_9{max-width:28rem}}._dialogTitle_worsp_30{text-align:center;font-size:calc(var(--mb-size)*1.5rem);line-height:calc(var(--mb-size)*2rem);font-weight:700}._contentOut_worsp_34{overflow-y:auto}._closeButton_worsp_38{position:absolute;top:.625rem;right:.625rem;width:calc(var(--mb-size)*2rem);height:calc(var(--mb-size)*2rem);display:flex;align-items:center;justify-content:center;border-radius:9999px;border-style:none;background-color:transparent;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;transition-duration:.1s}._closeButton_worsp_38:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-100-rgb-value) / var(--un-bg-opacity))}._closeButton_worsp_38:active{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity))}._closeButtonInner_worsp_44{display:flex;--un-translate-y:-2px;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));align-items:center;justify-content:center;font-size:calc(var(--mb-size)*1.875rem);line-height:calc(var(--mb-size)*2.25rem);--un-text-opacity:1;color:rgb(var(--color-black-rgb-value) / var(--un-text-opacity));font-weight:200;line-height:1}._primaryActionButton_worsp_49{height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;--un-bg-opacity:1;background-color:rgb(var(--color-primary) / var(--un-bg-opacity));padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*.25rem);padding-bottom:calc(var(--mb-size)*.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity));transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;transition-duration:.1s}._primaryActionButton_worsp_49[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity));--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}._primaryActionButton_worsp_49[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity))}._primaryActionButton_worsp_49:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-700-rgb-value) / var(--un-bg-opacity))}._primaryActionButton_worsp_49:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-800-rgb-value) / var(--un-bg-opacity))}._primaryActionButton_worsp_49:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity));outline-offset:4px;outline-style:solid}._secondaryActionButton_worsp_53{height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;background-color:transparent;padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*.25rem);padding-bottom:calc(var(--mb-size)*.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-primary) / var(--un-text-opacity));--un-ring-width:1px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow);--un-ring-opacity:1;--un-ring-color:rgb(var(--color-primary) / var(--un-ring-opacity)) ;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s;transition-duration:.1s}._secondaryActionButton_worsp_53[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity));--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}._secondaryActionButton_worsp_53[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity))}._secondaryActionButton_worsp_53:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-25-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-accent-700-rgb-value) / var(--un-text-opacity));--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-700-rgb-value) / var(--un-ring-opacity)) }._secondaryActionButton_worsp_53:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-50-rgb-value) / var(--un-bg-opacity));--un-text-opacity:1;color:rgb(var(--color-accent-800-rgb-value) / var(--un-text-opacity));--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-800-rgb-value) / var(--un-ring-opacity)) }._secondaryActionButton_worsp_53:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity));outline-offset:4px;outline-style:solid}._actions_worsp_57{display:flex;gap:calc(var(--mb-size)*1rem)}._actions_worsp_57 ._primaryActionButton_worsp_49,._actions_worsp_57 ._secondaryActionButton_worsp_53{width:50%}._alertTitle_worsp_64{font-size:calc(var(--mb-size)*1.125rem);line-height:calc(var(--mb-size)*1.75rem);--un-text-opacity:1;color:rgb(var(--color-gray-700-rgb-value) / var(--un-text-opacity));font-weight:400}._alertText_worsp_68{margin-top:calc(var(--mb-size)*1rem);margin-bottom:calc(var(--mb-size)*2rem);padding-left:calc(var(--mb-size)*.5rem);padding-right:calc(var(--mb-size)*.5rem);text-align:center;text-wrap:pretty;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity));font-weight:300;line-height:1.5}*,:before,:after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / .5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: }.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.left-0{left:calc(var(--mb-size)*0rem)}.right-0{right:calc(var(--mb-size)*0rem)}.right-4{right:calc(var(--mb-size)*1rem)}.top-\\[-1px\\]{top:-1px}.top-0{top:calc(var(--mb-size)*0rem)}.has-\\[\\[data-scope\\]\\]\\:z-2:has([data-scope]),.z-2{z-index:2}.z-1{z-index:1}.grid{display:grid}.auto-cols-auto{grid-auto-columns:auto}.grid-cols-\\[1fr_auto_1fr\\]{grid-template-columns:1fr auto 1fr}.block{display:block}.size-12{width:calc(var(--mb-size)*3rem);height:calc(var(--mb-size)*3rem)}.size-6{width:calc(var(--mb-size)*1.5rem);height:calc(var(--mb-size)*1.5rem)}.size-full{width:100%;height:100%}.h-\\[1px\\]{height:1px}.h-full{height:100%}.h-vh{height:100vh}.max-w-\\[100\\%\\]{max-width:100%}.min-h-\\[300px\\]{min-height:300px}.min-w-0{min-width:calc(var(--mb-size)*0rem)}.w-full{width:100%}.flex{display:flex}.shrink-0{flex-shrink:0}.flex-nowrap{flex-wrap:nowrap}.data-\\[state\\=open\\]\\:scale-y-\\[-1\\][data-state=open]{--un-scale-y:-1;transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.transform{transform:translate(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotate(var(--un-rotate-z)) skew(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z))}.cursor-pointer{cursor:pointer}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.select-none{-webkit-user-select:none;user-select:none}.resize{resize:both}.appearance-none{-webkit-appearance:none;appearance:none}.place-items-center{place-items:center}.items-center{align-items:center}.justify-between{justify-content:space-between}.justify-self-start{justify-self:start}.justify-self-end{justify-self:end}.justify-self-center{justify-self:center}.gap-\\[1px\\]{gap:1px}.gap-2{gap:calc(var(--mb-size)*.5rem)}.gap-4{gap:calc(var(--mb-size)*1rem)}.overflow-hidden{overflow:hidden}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-nowrap{white-space:nowrap}.rounded-4{border-radius:calc(var(--mb-size)*1rem)}.rounded-full{border-radius:9999px}.rounded-md{border-radius:.375rem}.border-none{border-style:none}.bg-dark-100\\/50{background-color:#3c3c3c80}.bg-dark-500{--un-bg-opacity:1;background-color:rgb(31 31 31 / var(--un-bg-opacity))}.bg-white{--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity))}.data-\\[highlighted\\]\\:bg-gray-500\\/50[data-highlighted]{background-color:rgb(var(--color-gray-500-rgb-value) / .5)}.bg-opacity-50{--un-bg-opacity:.5}.p-2{padding:calc(var(--mb-size)*.5rem)}.px-4{padding-left:calc(var(--mb-size)*1rem);padding-right:calc(var(--mb-size)*1rem)}.py-2{padding-top:calc(var(--mb-size)*.5rem);padding-bottom:calc(var(--mb-size)*.5rem)}.py-3{padding-top:calc(var(--mb-size)*.75rem);padding-bottom:calc(var(--mb-size)*.75rem)}.py-4{padding-top:calc(var(--mb-size)*1rem);padding-bottom:calc(var(--mb-size)*1rem)}.pl-4{padding-left:calc(var(--mb-size)*1rem)}.pr-12{padding-right:calc(var(--mb-size)*3rem)}.text-align-center{text-align:center}.text-base{font-size:calc(var(--mb-size)*1rem);line-height:calc(var(--mb-size)*1.5rem)}.text-sm{font-size:calc(var(--mb-size)*.875rem);line-height:calc(var(--mb-size)*1.25rem)}.color-white{--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity))}.font-500{font-weight:500}.disabled\\:opacity-50:disabled{opacity:.5}.shadow{--un-shadow:var(--un-shadow-inset) 0 1px 3px 0 var(--un-shadow-color, rgb(0 0 0 / .1)),var(--un-shadow-inset) 0 1px 2px -1px var(--un-shadow-color, rgb(0 0 0 / .1));box-shadow:var(--un-ring-offset-shadow),var(--un-ring-shadow),var(--un-shadow)}.backdrop-blur{--un-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia)}.backdrop-blur-xl{--un-backdrop-blur:blur(24px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia)}.drop-shadow-md{--un-drop-shadow:drop-shadow(0 4px 3px var(--un-drop-shadow-color, rgb(0 0 0 / .07))) drop-shadow(0 2px 2px var(--un-drop-shadow-color, rgb(0 0 0 / .06)));filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia)}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-300{transition-duration:.3s}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.lerp\\:px-3\\@xs\\,8\\@lg{padding-inline:clamp(calc(var(--mb-size)*.75rem),calc(var(--mb-size)*.75rem) + (100vw - 380px) * .031055900621118012,calc(var(--mb-size)*2rem))}@supports (height:100dvh){.supports-\\[\\(height\\:100dvh\\)\\]\\:h-dvh{height:100dvh}}")})();
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { createContext as be, onCleanup as ie, useContext as pe, onMount as Q, createSignal as z, Show as E, Index as qe, createRoot as He, getOwner as ve, splitProps as We, createEffect as Ge } from "solid-js";
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1
|
+
(function() {
|
|
2
|
+
"use strict";
|
|
3
|
+
((cssCode) => {
|
|
4
|
+
window.__mbCameraManagerCssCode = cssCode;
|
|
5
|
+
})("._dialogPositioner_worsp_1 {\n position:fixed;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);display:grid;height:100vh;width:100%;padding:calc(var(--mb-size)*2rem);\n}@supports (height:100dvh){._dialogPositioner_worsp_1{height:100dvh;}}\n\n._dialogBackdrop_worsp_5 {\n position:absolute;top:calc(var(--mb-size)*0rem);left:calc(var(--mb-size)*0rem);width:100%;height:100%;--un-bg-opacity:1;background-color:rgb(var(--color-black-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-black-rgb-value) / <alpha-value>) */;--un-bg-opacity:0.5;--un-backdrop-blur:blur(4px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);\n}\n\n._dialogContent_worsp_9 {\n position:relative;max-height:calc(100dvh - 4rem);max-width:28rem;display:flex;flex-direction:column;place-self:center;border-radius:0.5rem;--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;padding-left:min(8%,3rem);padding-right:min(8%,3rem);padding-top:min(8%,1.5rem);padding-bottom:min(8%,1.5rem);--un-text-opacity:1;color:rgb(15 15 15 / var(--un-text-opacity)) /* #0f0f0f */;--un-shadow:var(--un-shadow-inset) 0 10px 15px -3px var(--un-shadow-color, rgb(0 0 0 / 0.1)),var(--un-shadow-inset) 0 4px 6px -4px var(--un-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);\n}\n._dialogContent_worsp_9._large_worsp_13 {\n padding-left:min(8%,4rem);padding-right:min(8%,4rem);padding-top:min(8%,3rem);padding-bottom:min(8%,3rem);\n}\n._dialogContent_worsp_9._compact_worsp_16 {\n padding:min(8%,1.5rem);\n}\n@media (min-width: 640px){\n ._dialogContent_worsp_9 {\n max-width:36rem;\n }\n}\n@media (min-width: 1024px){\n ._dialogContent_worsp_9 {\n max-width:28rem;\n }\n}\n\n._dialogTitle_worsp_30 {\n text-align:center;font-size:calc(var(--mb-size)*1.5rem);line-height:calc(var(--mb-size)*2rem);font-weight:700;\n}\n\n._contentOut_worsp_34 {\n overflow-y:auto;\n}\n\n._closeButton_worsp_38 {\n position:absolute;top:0.625rem;right:0.625rem;width:calc(var(--mb-size)*2rem);height:calc(var(--mb-size)*2rem);display:flex;align-items:center;justify-content:center;border-radius:9999px;border-style:none;background-color:transparent /* transparent */;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-duration:100ms;\n}._closeButton_worsp_38:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-100-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-100-rgb-value) / <alpha-value>) */;}._closeButton_worsp_38:active{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;}\n\n._closeButtonInner_worsp_44 {\n display:flex;--un-translate-y:-2px;transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));align-items:center;justify-content:center;font-size:calc(var(--mb-size)*1.875rem);line-height:calc(var(--mb-size)*2.25rem);--un-text-opacity:1;color:rgb(var(--color-black-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-black-rgb-value) / <alpha-value>) */;font-weight:200;line-height:1;\n}\n\n._primaryActionButton_worsp_49 {\n height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;--un-bg-opacity:1;background-color:rgb(var(--color-primary) / var(--un-bg-opacity)) /* rgb(var(--color-primary) / <alpha-value>) */;padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*0.25rem);padding-bottom:calc(var(--mb-size)*0.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*0.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-duration:100ms;\n}._primaryActionButton_worsp_49[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}._primaryActionButton_worsp_49[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;}._primaryActionButton_worsp_49:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-700-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-700-rgb-value) / <alpha-value>) */;}._primaryActionButton_worsp_49:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-800-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-800-rgb-value) / <alpha-value>) */;}._primaryActionButton_worsp_49:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity)) /* rgb(var(--color-accent-400-rgb-value) / <alpha-value>) */;outline-offset:4px;outline-style:solid;}\n\n._secondaryActionButton_worsp_53 {\n height:2.5rem;-webkit-appearance:none;appearance:none;border-radius:calc(var(--mb-size)*2.5rem);border-style:none;background-color:transparent /* transparent */;padding-left:calc(var(--mb-size)*1.25rem);padding-right:calc(var(--mb-size)*1.25rem);padding-top:calc(var(--mb-size)*0.25rem);padding-bottom:calc(var(--mb-size)*0.25rem);text-wrap:nowrap;font-size:calc(var(--mb-size)*0.875rem);line-height:calc(var(--mb-size)*1.25rem);--un-text-opacity:1;color:rgb(var(--color-primary) / var(--un-text-opacity)) /* rgb(var(--color-primary) / <alpha-value>) */;--un-ring-width:1px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);--un-ring-opacity:1;--un-ring-color:rgb(var(--color-primary) / var(--un-ring-opacity)) /* rgb(var(--color-primary) / <alpha-value>) */;transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;transition-duration:100ms;\n}._secondaryActionButton_worsp_53[disabled]{cursor:not-allowed;--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;--un-ring-width:0px;--un-ring-offset-shadow:var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color);--un-ring-shadow:var(--un-ring-inset) 0 0 0 calc(var(--un-ring-width) + var(--un-ring-offset-width)) var(--un-ring-color);box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}._secondaryActionButton_worsp_53[disabled]:hover{--un-bg-opacity:1;background-color:rgb(var(--color-gray-200-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-gray-200-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;}._secondaryActionButton_worsp_53:hover{--un-bg-opacity:1;background-color:rgb(var(--color-accent-25-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-25-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-accent-700-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-accent-700-rgb-value) / <alpha-value>) */;--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-700-rgb-value) / var(--un-ring-opacity)) /* rgb(var(--color-accent-700-rgb-value) / <alpha-value>) */;}._secondaryActionButton_worsp_53:active{--un-bg-opacity:1;background-color:rgb(var(--color-accent-50-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-accent-50-rgb-value) / <alpha-value>) */;--un-text-opacity:1;color:rgb(var(--color-accent-800-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-accent-800-rgb-value) / <alpha-value>) */;--un-ring-opacity:1;--un-ring-color:rgb(var(--color-accent-800-rgb-value) / var(--un-ring-opacity)) /* rgb(var(--color-accent-800-rgb-value) / <alpha-value>) */;}._secondaryActionButton_worsp_53:focus{outline-width:2px;--un-outline-color-opacity:1;outline-color:rgb(var(--color-accent-400-rgb-value) / var(--un-outline-color-opacity)) /* rgb(var(--color-accent-400-rgb-value) / <alpha-value>) */;outline-offset:4px;outline-style:solid;}\n\n._actions_worsp_57 {\n display:flex;gap:calc(var(--mb-size)*1rem);\n}\n._actions_worsp_57 ._primaryActionButton_worsp_49, ._actions_worsp_57 ._secondaryActionButton_worsp_53 {\n width:50%;\n}\n\n._alertTitle_worsp_64 {\n font-size:calc(var(--mb-size)*1.125rem);line-height:calc(var(--mb-size)*1.75rem);--un-text-opacity:1;color:rgb(var(--color-gray-700-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-700-rgb-value) / <alpha-value>) */;font-weight:400;\n}\n\n._alertText_worsp_68 {\n margin-top:calc(var(--mb-size)*1rem);margin-bottom:calc(var(--mb-size)*2rem);padding-left:calc(var(--mb-size)*0.5rem);padding-right:calc(var(--mb-size)*0.5rem);text-align:center;text-wrap:pretty;--un-text-opacity:1;color:rgb(var(--color-gray-500-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;font-weight:300;line-height:1.5;\n} *,::before,::after{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / 0.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: ;}::backdrop{--un-rotate:0;--un-rotate-x:0;--un-rotate-y:0;--un-rotate-z:0;--un-scale-x:1;--un-scale-y:1;--un-scale-z:1;--un-skew-x:0;--un-skew-y:0;--un-translate-x:0;--un-translate-y:0;--un-translate-z:0;--un-pan-x: ;--un-pan-y: ;--un-pinch-zoom: ;--un-scroll-snap-strictness:proximity;--un-ordinal: ;--un-slashed-zero: ;--un-numeric-figure: ;--un-numeric-spacing: ;--un-numeric-fraction: ;--un-border-spacing-x:0;--un-border-spacing-y:0;--un-ring-offset-shadow:0 0 rgb(0 0 0 / 0);--un-ring-shadow:0 0 rgb(0 0 0 / 0);--un-shadow-inset: ;--un-shadow:0 0 rgb(0 0 0 / 0);--un-ring-inset: ;--un-ring-offset-width:0px;--un-ring-offset-color:#fff;--un-ring-width:0px;--un-ring-color:rgb(147 197 253 / 0.5);--un-blur: ;--un-brightness: ;--un-contrast: ;--un-drop-shadow: ;--un-grayscale: ;--un-hue-rotate: ;--un-invert: ;--un-saturate: ;--un-sepia: ;--un-backdrop-blur: ;--un-backdrop-brightness: ;--un-backdrop-contrast: ;--un-backdrop-grayscale: ;--un-backdrop-hue-rotate: ;--un-backdrop-invert: ;--un-backdrop-opacity: ;--un-backdrop-saturate: ;--un-backdrop-sepia: ;}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0;}.pointer-events-none{pointer-events:none;}.absolute{position:absolute;}.fixed{position:fixed;}.relative{position:relative;}.left-0{left:calc(var(--mb-size)*0rem);}.right-0{right:calc(var(--mb-size)*0rem);}.right-4{right:calc(var(--mb-size)*1rem);}.top-\\[-1px\\]{top:-1px;}.top-0{top:calc(var(--mb-size)*0rem);}.z-1{z-index:1;}.has-\\[\\[data-scope\\]\\]\\:z-2:has([data-scope]),.z-2{z-index:2;}.grid{display:grid;}.auto-cols-auto{grid-auto-columns:auto;}.grid-cols-\\[1fr_auto_1fr\\]{grid-template-columns:1fr auto 1fr;}.block{display:block;}.size-12{width:calc(var(--mb-size)*3rem);height:calc(var(--mb-size)*3rem);}.size-6{width:calc(var(--mb-size)*1.5rem);height:calc(var(--mb-size)*1.5rem);}.size-full{width:100%;height:100%;}.h-\\[1px\\]{height:1px;}.h-full{height:100%;}.h-vh{height:100vh;}.max-w-\\[100\\%\\]{max-width:100%;}.min-h-\\[300px\\]{min-height:300px;}.min-w-0{min-width:calc(var(--mb-size)*0rem);}.w-full{width:100%;}.flex{display:flex;}.shrink-0{flex-shrink:0;}.flex-nowrap{flex-wrap:nowrap;}.data-\\[state\\=open\\]\\:scale-y-\\[-1\\][data-state=open]{--un-scale-y:-1;transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}.transform{transform:translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z)) rotate(var(--un-rotate)) rotateX(var(--un-rotate-x)) rotateY(var(--un-rotate-y)) rotateZ(var(--un-rotate-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z));}.cursor-pointer{cursor:pointer;}.disabled\\:cursor-not-allowed:disabled{cursor:not-allowed;}.select-none{-webkit-user-select:none;user-select:none;}.resize{resize:both;}.appearance-none{-webkit-appearance:none;appearance:none;}.place-items-center{place-items:center;}.items-center{align-items:center;}.justify-between{justify-content:space-between;}.justify-self-start{justify-self:start;}.justify-self-end{justify-self:end;}.justify-self-center{justify-self:center;}.gap-\\[1px\\]{gap:1px;}.gap-2{gap:calc(var(--mb-size)*0.5rem);}.gap-4{gap:calc(var(--mb-size)*1rem);}.overflow-hidden{overflow:hidden;}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.whitespace-nowrap{white-space:nowrap;}.rounded-4{border-radius:calc(var(--mb-size)*1rem);}.rounded-full{border-radius:9999px;}.rounded-md{border-radius:0.375rem;}.border-none{border-style:none;}.bg-dark-100\\/50{background-color:rgb(60 60 60 / 0.5) /* #3c3c3c */;}.bg-dark-500{--un-bg-opacity:1;background-color:rgb(31 31 31 / var(--un-bg-opacity)) /* #1f1f1f */;}.data-\\[highlighted\\]\\:bg-gray-500\\/50[data-highlighted]{background-color:rgb(var(--color-gray-500-rgb-value) / 0.5) /* rgb(var(--color-gray-500-rgb-value) / <alpha-value>) */;}.bg-white{--un-bg-opacity:1;background-color:rgb(var(--color-white-rgb-value) / var(--un-bg-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;}.bg-opacity-50{--un-bg-opacity:0.5;}.p-2{padding:calc(var(--mb-size)*0.5rem);}.px-4{padding-left:calc(var(--mb-size)*1rem);padding-right:calc(var(--mb-size)*1rem);}.py-2{padding-top:calc(var(--mb-size)*0.5rem);padding-bottom:calc(var(--mb-size)*0.5rem);}.py-3{padding-top:calc(var(--mb-size)*0.75rem);padding-bottom:calc(var(--mb-size)*0.75rem);}.py-4{padding-top:calc(var(--mb-size)*1rem);padding-bottom:calc(var(--mb-size)*1rem);}.pl-4{padding-left:calc(var(--mb-size)*1rem);}.pr-12{padding-right:calc(var(--mb-size)*3rem);}.text-align-center{text-align:center;}.text-base{font-size:calc(var(--mb-size)*1rem);line-height:calc(var(--mb-size)*1.5rem);}.text-sm{font-size:calc(var(--mb-size)*0.875rem);line-height:calc(var(--mb-size)*1.25rem);}.color-white{--un-text-opacity:1;color:rgb(var(--color-white-rgb-value) / var(--un-text-opacity)) /* rgb(var(--color-white-rgb-value) / <alpha-value>) */;}.font-500{font-weight:500;}.disabled\\:opacity-50:disabled{opacity:0.5;}.shadow{--un-shadow:var(--un-shadow-inset) 0 1px 3px 0 var(--un-shadow-color, rgb(0 0 0 / 0.1)),var(--un-shadow-inset) 0 1px 2px -1px var(--un-shadow-color, rgb(0 0 0 / 0.1));box-shadow:var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow);}.backdrop-blur{--un-backdrop-blur:blur(8px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);}.backdrop-blur-xl{--un-backdrop-blur:blur(24px);-webkit-backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);backdrop-filter:var(--un-backdrop-blur) var(--un-backdrop-brightness) var(--un-backdrop-contrast) var(--un-backdrop-grayscale) var(--un-backdrop-hue-rotate) var(--un-backdrop-invert) var(--un-backdrop-opacity) var(--un-backdrop-saturate) var(--un-backdrop-sepia);}.drop-shadow-md{--un-drop-shadow:drop-shadow(0 4px 3px var(--un-drop-shadow-color, rgb(0 0 0 / 0.07))) drop-shadow(0 2px 2px var(--un-drop-shadow-color, rgb(0 0 0 / 0.06)));filter:var(--un-blur) var(--un-brightness) var(--un-contrast) var(--un-drop-shadow) var(--un-grayscale) var(--un-hue-rotate) var(--un-invert) var(--un-saturate) var(--un-sepia);}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms;}.duration-300{transition-duration:300ms;}.ease-in-out{transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);}@keyframes __un_qm{0%{box-shadow:inset 4px 4px #ff1e90, inset -4px -4px #ff1e90}100%{box-shadow:inset 8px 8px #3399ff, inset -8px -8px #3399ff}} .\\?{animation:__un_qm 0.5s ease-in-out alternate infinite;}.lerp\\:px-3\\@xs\\,8\\@lg{padding-inline:clamp(calc(var(--mb-size)*0.75rem), calc(var(--mb-size)*0.75rem) + (100vw - 380px) * 0.031055900621118012, calc(var(--mb-size)*2rem));}@supports (height:100dvh){.supports-\\[\\(height\\:100dvh\\)\\]\\:h-dvh{height:100dvh;}}");
|
|
6
|
+
})();
|
|
7
|
+
import { subscribeWithSelector } from "zustand/middleware";
|
|
8
|
+
import { createStore } from "zustand/vanilla";
|
|
9
|
+
import { createComponent, use, template, spread, mergeProps, insert, memo, isServer, delegateEvents, effect, className, Portal, Dynamic, render } from "solid-js/web";
|
|
10
|
+
import { createContext, onCleanup, useContext, onMount, createSignal, Show, Index, createRoot, getOwner, splitProps, createEffect } from "solid-js";
|
|
11
|
+
import { createWithSignal } from "solid-zustand";
|
|
12
|
+
import { createStore as createStore$1 } from "solid-js/store";
|
|
13
|
+
import { EnvironmentProvider } from "@ark-ui/solid/environment";
|
|
14
|
+
import { Dialog } from "@ark-ui/solid/dialog";
|
|
15
|
+
import { Select, createListCollection } from "@ark-ui/solid/select";
|
|
16
|
+
import { Tooltip } from "@ark-ui/solid/tooltip";
|
|
17
|
+
if (typeof HTMLVideoElement !== "undefined" && !("requestVideoFrameCallback" in HTMLVideoElement.prototype) && "getVideoPlaybackQuality" in HTMLVideoElement.prototype) {
|
|
18
|
+
HTMLVideoElement.prototype._rvfcpolyfillmap = {};
|
|
19
|
+
HTMLVideoElement.prototype.requestVideoFrameCallback = function(callback) {
|
|
20
|
+
const handle = performance.now();
|
|
21
|
+
const quality = this.getVideoPlaybackQuality();
|
|
22
|
+
const baseline = this.mozPresentedFrames || this.mozPaintedFrames || quality.totalVideoFrames - quality.droppedVideoFrames;
|
|
23
|
+
const check = (old, now) => {
|
|
24
|
+
const newquality = this.getVideoPlaybackQuality();
|
|
25
|
+
const presentedFrames = this.mozPresentedFrames || this.mozPaintedFrames || newquality.totalVideoFrames - newquality.droppedVideoFrames;
|
|
26
|
+
if (presentedFrames > baseline) {
|
|
27
|
+
const processingDuration = this.mozFrameDelay || newquality.totalFrameDelay - quality.totalFrameDelay || 0;
|
|
28
|
+
const timediff = now - old;
|
|
29
|
+
callback(now, {
|
|
30
|
+
presentationTime: now + processingDuration * 1e3,
|
|
31
|
+
expectedDisplayTime: now + timediff,
|
|
32
|
+
width: this.videoWidth,
|
|
33
|
+
height: this.videoHeight,
|
|
34
|
+
mediaTime: Math.max(0, this.currentTime || 0) + timediff / 1e3,
|
|
35
|
+
presentedFrames,
|
|
36
|
+
processingDuration
|
|
37
|
+
});
|
|
38
|
+
delete this._rvfcpolyfillmap[handle];
|
|
39
|
+
} else {
|
|
40
|
+
this._rvfcpolyfillmap[handle] = requestAnimationFrame((newer) => check(now, newer));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
this._rvfcpolyfillmap[handle] = requestAnimationFrame((newer) => check(handle, newer));
|
|
44
|
+
return handle;
|
|
28
45
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
46
|
+
HTMLVideoElement.prototype.cancelVideoFrameCallback = function(handle) {
|
|
47
|
+
cancelAnimationFrame(this._rvfcpolyfillmap[handle]);
|
|
48
|
+
delete this._rvfcpolyfillmap[handle];
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
const initialState$1 = {
|
|
34
52
|
cameras: [],
|
|
35
53
|
facingFilter: void 0,
|
|
36
54
|
videoElement: void 0,
|
|
37
55
|
playbackState: "idle",
|
|
38
56
|
selectedCamera: void 0,
|
|
39
|
-
isSwappingCamera:
|
|
40
|
-
isQueryingCameras:
|
|
41
|
-
mirrorX:
|
|
57
|
+
isSwappingCamera: false,
|
|
58
|
+
isQueryingCameras: false,
|
|
59
|
+
mirrorX: false,
|
|
42
60
|
errorState: void 0
|
|
43
|
-
}
|
|
61
|
+
};
|
|
62
|
+
const cameraManagerStore = createStore()(
|
|
44
63
|
// this is important! Otherwise solid-zustand will start mutating the initial state
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
64
|
+
subscribeWithSelector(() => structuredClone(initialState$1))
|
|
65
|
+
);
|
|
66
|
+
const resetCameraManagerStore = () => {
|
|
67
|
+
console.debug("Stopping all cameras and resetting the `cameraManagerStore`.");
|
|
68
|
+
cameraManagerStore.getState().cameras.forEach((camera) => {
|
|
69
|
+
camera.stopStream();
|
|
70
|
+
});
|
|
71
|
+
cameraManagerStore.setState(structuredClone(initialState$1));
|
|
72
|
+
};
|
|
73
|
+
const backCameraKeywords = [
|
|
51
74
|
// English
|
|
52
75
|
"back",
|
|
53
76
|
"rear",
|
|
@@ -118,7 +141,8 @@ const ye = {
|
|
|
118
141
|
"बैक",
|
|
119
142
|
// Latin American Spanish
|
|
120
143
|
"posterior"
|
|
121
|
-
]
|
|
144
|
+
];
|
|
145
|
+
const frontCameraKeywords = [
|
|
122
146
|
// English
|
|
123
147
|
"front",
|
|
124
148
|
// German
|
|
@@ -185,38 +209,66 @@ const ye = {
|
|
|
185
209
|
"फ्रंट",
|
|
186
210
|
// Latin American Spanish
|
|
187
211
|
"frontal"
|
|
188
|
-
]
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
212
|
+
];
|
|
213
|
+
const containsKeyword = (string, keywords) => {
|
|
214
|
+
return keywords.some((keyword) => string.toLowerCase().includes(keyword));
|
|
215
|
+
};
|
|
216
|
+
const isBackCameraName = (string) => containsKeyword(string, backCameraKeywords);
|
|
217
|
+
const isFrontCameraName = (string) => containsKeyword(string, frontCameraKeywords);
|
|
218
|
+
var _createClass = /* @__PURE__ */ function() {
|
|
219
|
+
function defineProperties(target, props) {
|
|
220
|
+
for (var i = 0; i < props.length; i++) {
|
|
221
|
+
var descriptor = props[i];
|
|
222
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
223
|
+
descriptor.configurable = true;
|
|
224
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
225
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
194
226
|
}
|
|
195
227
|
}
|
|
196
|
-
return function(
|
|
197
|
-
|
|
228
|
+
return function(Constructor, protoProps, staticProps) {
|
|
229
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
230
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
231
|
+
return Constructor;
|
|
198
232
|
};
|
|
199
|
-
}()
|
|
200
|
-
|
|
201
|
-
|
|
233
|
+
}();
|
|
234
|
+
var _templateObject = _taggedTemplateLiteral(["", ""], ["", ""]);
|
|
235
|
+
function _taggedTemplateLiteral(strings, raw) {
|
|
236
|
+
return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } }));
|
|
202
237
|
}
|
|
203
|
-
function
|
|
204
|
-
if (!(
|
|
238
|
+
function _classCallCheck(instance, Constructor) {
|
|
239
|
+
if (!(instance instanceof Constructor)) {
|
|
205
240
|
throw new TypeError("Cannot call a class as a function");
|
|
241
|
+
}
|
|
206
242
|
}
|
|
207
|
-
var
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
243
|
+
var TemplateTag = function() {
|
|
244
|
+
function TemplateTag2() {
|
|
245
|
+
var _this = this;
|
|
246
|
+
for (var _len = arguments.length, transformers = Array(_len), _key = 0; _key < _len; _key++) {
|
|
247
|
+
transformers[_key] = arguments[_key];
|
|
248
|
+
}
|
|
249
|
+
_classCallCheck(this, TemplateTag2);
|
|
250
|
+
this.tag = function(strings) {
|
|
251
|
+
for (var _len2 = arguments.length, expressions = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
252
|
+
expressions[_key2 - 1] = arguments[_key2];
|
|
253
|
+
}
|
|
254
|
+
if (typeof strings === "function") {
|
|
255
|
+
return _this.interimTag.bind(_this, strings);
|
|
256
|
+
}
|
|
257
|
+
if (typeof strings === "string") {
|
|
258
|
+
return _this.transformEndResult(strings);
|
|
259
|
+
}
|
|
260
|
+
strings = strings.map(_this.transformString.bind(_this));
|
|
261
|
+
return _this.transformEndResult(strings.reduce(_this.processSubstitutions.bind(_this, expressions)));
|
|
262
|
+
};
|
|
263
|
+
if (transformers.length > 0 && Array.isArray(transformers[0])) {
|
|
264
|
+
transformers = transformers[0];
|
|
265
|
+
}
|
|
266
|
+
this.transformers = transformers.map(function(transformer) {
|
|
267
|
+
return typeof transformer === "function" ? transformer() : transformer;
|
|
268
|
+
});
|
|
269
|
+
return this.tag;
|
|
270
|
+
}
|
|
271
|
+
_createClass(TemplateTag2, [{
|
|
220
272
|
key: "interimTag",
|
|
221
273
|
/**
|
|
222
274
|
* An intermediary template tag that receives a template tag and passes the result of calling the template with the received
|
|
@@ -226,10 +278,11 @@ var _ = function() {
|
|
|
226
278
|
* @param {...*} ...substitutions - `substitutions` is an array of all substitutions in the template
|
|
227
279
|
* @return {*} - the final processed value
|
|
228
280
|
*/
|
|
229
|
-
value: function(
|
|
230
|
-
for (var
|
|
231
|
-
|
|
232
|
-
|
|
281
|
+
value: function interimTag(previousTag, template2) {
|
|
282
|
+
for (var _len3 = arguments.length, substitutions = Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
283
|
+
substitutions[_key3 - 2] = arguments[_key3];
|
|
284
|
+
}
|
|
285
|
+
return this.tag(_templateObject, previousTag.apply(void 0, [template2].concat(substitutions)));
|
|
233
286
|
}
|
|
234
287
|
/**
|
|
235
288
|
* Performs bulk processing on the tagged template, transforming each substitution and then
|
|
@@ -241,9 +294,9 @@ var _ = function() {
|
|
|
241
294
|
*/
|
|
242
295
|
}, {
|
|
243
296
|
key: "processSubstitutions",
|
|
244
|
-
value: function(
|
|
245
|
-
var
|
|
246
|
-
return "".concat(
|
|
297
|
+
value: function processSubstitutions(substitutions, resultSoFar, remainingPart) {
|
|
298
|
+
var substitution = this.transformSubstitution(substitutions.shift(), resultSoFar);
|
|
299
|
+
return "".concat(resultSoFar, substitution, remainingPart);
|
|
247
300
|
}
|
|
248
301
|
/**
|
|
249
302
|
* Iterate through each transformer, applying the transformer's `onString` method to the template
|
|
@@ -253,11 +306,11 @@ var _ = function() {
|
|
|
253
306
|
*/
|
|
254
307
|
}, {
|
|
255
308
|
key: "transformString",
|
|
256
|
-
value: function(
|
|
257
|
-
var
|
|
258
|
-
return
|
|
309
|
+
value: function transformString(str) {
|
|
310
|
+
var cb = function cb2(res, transform) {
|
|
311
|
+
return transform.onString ? transform.onString(res) : res;
|
|
259
312
|
};
|
|
260
|
-
return this.transformers.reduce(
|
|
313
|
+
return this.transformers.reduce(cb, str);
|
|
261
314
|
}
|
|
262
315
|
/**
|
|
263
316
|
* When a substitution is encountered, iterates through each transformer and applies the transformer's
|
|
@@ -268,11 +321,11 @@ var _ = function() {
|
|
|
268
321
|
*/
|
|
269
322
|
}, {
|
|
270
323
|
key: "transformSubstitution",
|
|
271
|
-
value: function(
|
|
272
|
-
var
|
|
273
|
-
return
|
|
324
|
+
value: function transformSubstitution(substitution, resultSoFar) {
|
|
325
|
+
var cb = function cb2(res, transform) {
|
|
326
|
+
return transform.onSubstitution ? transform.onSubstitution(res, resultSoFar) : res;
|
|
274
327
|
};
|
|
275
|
-
return this.transformers.reduce(
|
|
328
|
+
return this.transformers.reduce(cb, substitution);
|
|
276
329
|
}
|
|
277
330
|
/**
|
|
278
331
|
* Iterates through each transformer, applying the transformer's `onEndResult` method to the
|
|
@@ -282,120 +335,161 @@ var _ = function() {
|
|
|
282
335
|
*/
|
|
283
336
|
}, {
|
|
284
337
|
key: "transformEndResult",
|
|
285
|
-
value: function(
|
|
286
|
-
var
|
|
287
|
-
return
|
|
338
|
+
value: function transformEndResult(endResult) {
|
|
339
|
+
var cb = function cb2(res, transform) {
|
|
340
|
+
return transform.onEndResult ? transform.onEndResult(res) : res;
|
|
288
341
|
};
|
|
289
|
-
return this.transformers.reduce(
|
|
342
|
+
return this.transformers.reduce(cb, endResult);
|
|
290
343
|
}
|
|
291
|
-
}])
|
|
292
|
-
|
|
293
|
-
|
|
344
|
+
}]);
|
|
345
|
+
return TemplateTag2;
|
|
346
|
+
}();
|
|
347
|
+
var trimResultTransformer = function trimResultTransformer2() {
|
|
348
|
+
var side = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
294
349
|
return {
|
|
295
|
-
onEndResult: function(
|
|
296
|
-
if (
|
|
297
|
-
return
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
if (
|
|
301
|
-
return
|
|
302
|
-
|
|
350
|
+
onEndResult: function onEndResult(endResult) {
|
|
351
|
+
if (side === "") {
|
|
352
|
+
return endResult.trim();
|
|
353
|
+
}
|
|
354
|
+
side = side.toLowerCase();
|
|
355
|
+
if (side === "start" || side === "left") {
|
|
356
|
+
return endResult.replace(/^\s*/, "");
|
|
357
|
+
}
|
|
358
|
+
if (side === "end" || side === "right") {
|
|
359
|
+
return endResult.replace(/\s*$/, "");
|
|
360
|
+
}
|
|
361
|
+
throw new Error("Side not supported: " + side);
|
|
303
362
|
}
|
|
304
363
|
};
|
|
305
364
|
};
|
|
306
|
-
function
|
|
307
|
-
if (Array.isArray(
|
|
308
|
-
for (var
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
365
|
+
function _toConsumableArray(arr) {
|
|
366
|
+
if (Array.isArray(arr)) {
|
|
367
|
+
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
|
368
|
+
arr2[i] = arr[i];
|
|
369
|
+
}
|
|
370
|
+
return arr2;
|
|
371
|
+
} else {
|
|
372
|
+
return Array.from(arr);
|
|
373
|
+
}
|
|
313
374
|
}
|
|
314
|
-
var
|
|
315
|
-
var
|
|
375
|
+
var stripIndentTransformer = function stripIndentTransformer2() {
|
|
376
|
+
var type = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "initial";
|
|
316
377
|
return {
|
|
317
|
-
onEndResult: function(
|
|
318
|
-
if (
|
|
319
|
-
var
|
|
320
|
-
|
|
378
|
+
onEndResult: function onEndResult(endResult) {
|
|
379
|
+
if (type === "initial") {
|
|
380
|
+
var match = endResult.match(/^[^\S\n]*(?=\S)/gm);
|
|
381
|
+
var indent = match && Math.min.apply(Math, _toConsumableArray(match.map(function(el) {
|
|
382
|
+
return el.length;
|
|
321
383
|
})));
|
|
322
|
-
if (
|
|
323
|
-
var
|
|
324
|
-
return
|
|
384
|
+
if (indent) {
|
|
385
|
+
var regexp = new RegExp("^.{" + indent + "}", "gm");
|
|
386
|
+
return endResult.replace(regexp, "");
|
|
325
387
|
}
|
|
326
|
-
return
|
|
388
|
+
return endResult;
|
|
389
|
+
}
|
|
390
|
+
if (type === "all") {
|
|
391
|
+
return endResult.replace(/^[^\S\n]+/gm, "");
|
|
327
392
|
}
|
|
328
|
-
|
|
329
|
-
return a.replace(/^[^\S\n]+/gm, "");
|
|
330
|
-
throw new Error("Unknown type: " + e);
|
|
393
|
+
throw new Error("Unknown type: " + type);
|
|
331
394
|
}
|
|
332
395
|
};
|
|
333
|
-
}
|
|
396
|
+
};
|
|
397
|
+
var replaceResultTransformer = function replaceResultTransformer2(replaceWhat, replaceWith) {
|
|
334
398
|
return {
|
|
335
|
-
onEndResult: function(
|
|
336
|
-
if (
|
|
399
|
+
onEndResult: function onEndResult(endResult) {
|
|
400
|
+
if (replaceWhat == null || replaceWith == null) {
|
|
337
401
|
throw new Error("replaceResultTransformer requires at least 2 arguments.");
|
|
338
|
-
|
|
402
|
+
}
|
|
403
|
+
return endResult.replace(replaceWhat, replaceWith);
|
|
339
404
|
}
|
|
340
405
|
};
|
|
341
|
-
}
|
|
406
|
+
};
|
|
407
|
+
var replaceSubstitutionTransformer = function replaceSubstitutionTransformer2(replaceWhat, replaceWith) {
|
|
342
408
|
return {
|
|
343
|
-
onSubstitution: function(
|
|
344
|
-
if (
|
|
409
|
+
onSubstitution: function onSubstitution(substitution, resultSoFar) {
|
|
410
|
+
if (replaceWhat == null || replaceWith == null) {
|
|
345
411
|
throw new Error("replaceSubstitutionTransformer requires at least 2 arguments.");
|
|
346
|
-
|
|
412
|
+
}
|
|
413
|
+
if (substitution == null) {
|
|
414
|
+
return substitution;
|
|
415
|
+
} else {
|
|
416
|
+
return substitution.toString().replace(replaceWhat, replaceWith);
|
|
417
|
+
}
|
|
347
418
|
}
|
|
348
419
|
};
|
|
349
|
-
}
|
|
420
|
+
};
|
|
421
|
+
var defaults = {
|
|
350
422
|
separator: "",
|
|
351
423
|
conjunction: "",
|
|
352
|
-
serial:
|
|
353
|
-
}
|
|
354
|
-
|
|
424
|
+
serial: false
|
|
425
|
+
};
|
|
426
|
+
var inlineArrayTransformer = function inlineArrayTransformer2() {
|
|
427
|
+
var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaults;
|
|
355
428
|
return {
|
|
356
|
-
onSubstitution: function(
|
|
357
|
-
if (Array.isArray(
|
|
358
|
-
var
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
429
|
+
onSubstitution: function onSubstitution(substitution, resultSoFar) {
|
|
430
|
+
if (Array.isArray(substitution)) {
|
|
431
|
+
var arrayLength = substitution.length;
|
|
432
|
+
var separator = opts.separator;
|
|
433
|
+
var conjunction = opts.conjunction;
|
|
434
|
+
var serial = opts.serial;
|
|
435
|
+
var indent = resultSoFar.match(/(\n?[^\S\n]+)$/);
|
|
436
|
+
if (indent) {
|
|
437
|
+
substitution = substitution.join(separator + indent[1]);
|
|
438
|
+
} else {
|
|
439
|
+
substitution = substitution.join(separator + " ");
|
|
440
|
+
}
|
|
441
|
+
if (conjunction && arrayLength > 1) {
|
|
442
|
+
var separatorIndex = substitution.lastIndexOf(separator);
|
|
443
|
+
substitution = substitution.slice(0, separatorIndex) + (serial ? separator : "") + " " + conjunction + substitution.slice(separatorIndex + 1);
|
|
362
444
|
}
|
|
363
445
|
}
|
|
364
|
-
return
|
|
446
|
+
return substitution;
|
|
365
447
|
}
|
|
366
448
|
};
|
|
367
|
-
}
|
|
449
|
+
};
|
|
450
|
+
var splitStringTransformer = function splitStringTransformer2(splitBy) {
|
|
368
451
|
return {
|
|
369
|
-
onSubstitution: function(
|
|
370
|
-
|
|
452
|
+
onSubstitution: function onSubstitution(substitution, resultSoFar) {
|
|
453
|
+
{
|
|
454
|
+
if (typeof substitution === "string" && substitution.includes(splitBy)) {
|
|
455
|
+
substitution = substitution.split(splitBy);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
return substitution;
|
|
371
459
|
}
|
|
372
460
|
};
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
|
|
461
|
+
};
|
|
462
|
+
var isValidValue = function isValidValue2(x) {
|
|
463
|
+
return x != null && !Number.isNaN(x) && typeof x !== "boolean";
|
|
464
|
+
};
|
|
465
|
+
var removeNonPrintingValuesTransformer = function removeNonPrintingValuesTransformer2() {
|
|
376
466
|
return {
|
|
377
|
-
onSubstitution: function(
|
|
378
|
-
|
|
467
|
+
onSubstitution: function onSubstitution(substitution) {
|
|
468
|
+
if (Array.isArray(substitution)) {
|
|
469
|
+
return substitution.filter(isValidValue);
|
|
470
|
+
}
|
|
471
|
+
if (isValidValue(substitution)) {
|
|
472
|
+
return substitution;
|
|
473
|
+
}
|
|
474
|
+
return "";
|
|
379
475
|
}
|
|
380
476
|
};
|
|
381
477
|
};
|
|
382
|
-
new
|
|
383
|
-
new
|
|
384
|
-
new
|
|
385
|
-
new
|
|
386
|
-
|
|
387
|
-
new
|
|
388
|
-
|
|
389
|
-
new
|
|
390
|
-
new
|
|
391
|
-
new
|
|
392
|
-
new
|
|
393
|
-
new
|
|
394
|
-
new
|
|
395
|
-
new
|
|
396
|
-
|
|
397
|
-
var _e = new _(L("all"), T);
|
|
398
|
-
const st = [
|
|
478
|
+
new TemplateTag(inlineArrayTransformer({ separator: "," }), stripIndentTransformer, trimResultTransformer);
|
|
479
|
+
new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "and" }), stripIndentTransformer, trimResultTransformer);
|
|
480
|
+
new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "or" }), stripIndentTransformer, trimResultTransformer);
|
|
481
|
+
new TemplateTag(splitStringTransformer("\n"), removeNonPrintingValuesTransformer, inlineArrayTransformer, stripIndentTransformer, trimResultTransformer);
|
|
482
|
+
new TemplateTag(splitStringTransformer("\n"), inlineArrayTransformer, stripIndentTransformer, trimResultTransformer, replaceSubstitutionTransformer(/&/g, "&"), replaceSubstitutionTransformer(/</g, "<"), replaceSubstitutionTransformer(/>/g, ">"), replaceSubstitutionTransformer(/"/g, """), replaceSubstitutionTransformer(/'/g, "'"), replaceSubstitutionTransformer(/`/g, "`"));
|
|
483
|
+
new TemplateTag(replaceResultTransformer(/(?:\n(?:\s*))+/g, " "), trimResultTransformer);
|
|
484
|
+
new TemplateTag(replaceResultTransformer(/(?:\n\s*)/g, ""), trimResultTransformer);
|
|
485
|
+
new TemplateTag(inlineArrayTransformer({ separator: "," }), replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
|
|
486
|
+
new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "or" }), replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
|
|
487
|
+
new TemplateTag(inlineArrayTransformer({ separator: ",", conjunction: "and" }), replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
|
|
488
|
+
new TemplateTag(inlineArrayTransformer, stripIndentTransformer, trimResultTransformer);
|
|
489
|
+
new TemplateTag(inlineArrayTransformer, replaceResultTransformer(/(?:\s+)/g, " "), trimResultTransformer);
|
|
490
|
+
new TemplateTag(stripIndentTransformer, trimResultTransformer);
|
|
491
|
+
var stripIndents = new TemplateTag(stripIndentTransformer("all"), trimResultTransformer);
|
|
492
|
+
const backDualWideCameraLocalizations = [
|
|
399
493
|
"Cameră dublă cu obiectiv superangular spate",
|
|
400
494
|
"מצלמה כפולה רחבה אחורית",
|
|
401
495
|
"Артқы қос кең бұрышты камера",
|
|
@@ -433,145 +527,220 @@ const st = [
|
|
|
433
527
|
"Cámara trasera dual con gran angular",
|
|
434
528
|
"背面デュアル広角カメラ",
|
|
435
529
|
"Stražnja dvostruka široka kamera"
|
|
436
|
-
]
|
|
437
|
-
|
|
530
|
+
];
|
|
531
|
+
const asError = (thrown) => {
|
|
532
|
+
if (thrown instanceof Error) return thrown;
|
|
438
533
|
try {
|
|
439
|
-
return new Error(JSON.stringify(
|
|
534
|
+
return new Error(JSON.stringify(thrown));
|
|
440
535
|
} catch {
|
|
441
|
-
return new Error(String(
|
|
536
|
+
return new Error(String(thrown));
|
|
442
537
|
}
|
|
443
538
|
};
|
|
444
|
-
class
|
|
539
|
+
class CameraError extends Error {
|
|
445
540
|
code;
|
|
446
|
-
constructor(
|
|
447
|
-
super(
|
|
541
|
+
constructor(message, code, cause) {
|
|
542
|
+
super(message);
|
|
543
|
+
this.code = code;
|
|
544
|
+
this.cause = cause;
|
|
448
545
|
}
|
|
449
546
|
}
|
|
450
|
-
const
|
|
547
|
+
const askForCameraPermission = async () => {
|
|
451
548
|
try {
|
|
452
|
-
const
|
|
453
|
-
video:
|
|
549
|
+
const mediaStream = await navigator.mediaDevices.getUserMedia({
|
|
550
|
+
video: true
|
|
454
551
|
});
|
|
455
|
-
|
|
456
|
-
} catch (
|
|
457
|
-
|
|
552
|
+
closeStreamTracks(mediaStream);
|
|
553
|
+
} catch (error) {
|
|
554
|
+
console.log(error);
|
|
555
|
+
const newError = new CameraError(
|
|
458
556
|
"Camera permission not given",
|
|
459
557
|
"PERMISSION_DENIED",
|
|
460
|
-
|
|
558
|
+
asError(error)
|
|
461
559
|
);
|
|
560
|
+
throw newError;
|
|
462
561
|
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
|
|
562
|
+
};
|
|
563
|
+
const obtainVideoInputDevices = async () => {
|
|
564
|
+
if (!isSecureContext) {
|
|
565
|
+
throw new Error(stripIndents`
|
|
466
566
|
Cameras can only be used in a secure context:
|
|
467
567
|
https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts
|
|
468
568
|
`);
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
const
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
569
|
+
}
|
|
570
|
+
await askForCameraPermission();
|
|
571
|
+
const allDevices = await navigator.mediaDevices.enumerateDevices();
|
|
572
|
+
const cameraDevices = allDevices.filter((device) => {
|
|
573
|
+
return device.kind === "videoinput";
|
|
574
|
+
});
|
|
575
|
+
return cameraDevices;
|
|
576
|
+
};
|
|
577
|
+
const closeStreamTracks = (stream) => {
|
|
578
|
+
const tracks = stream.getTracks();
|
|
579
|
+
for (const track of tracks) {
|
|
580
|
+
track.stop();
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
const createConstraints = (resolution, facing, id) => {
|
|
584
|
+
const constraints = {
|
|
585
|
+
video: {
|
|
586
|
+
deviceId: id ? { exact: id } : void 0,
|
|
587
|
+
frameRate: 30,
|
|
588
|
+
aspectRatio: {
|
|
589
|
+
exact: videoResolutions[resolution].width / videoResolutions[resolution].height
|
|
590
|
+
},
|
|
591
|
+
width: {
|
|
592
|
+
ideal: videoResolutions[resolution].width
|
|
593
|
+
},
|
|
594
|
+
height: {
|
|
595
|
+
ideal: videoResolutions[resolution].height
|
|
596
|
+
},
|
|
597
|
+
facingMode: facing
|
|
486
598
|
},
|
|
487
|
-
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
}
|
|
491
|
-
|
|
599
|
+
audio: false
|
|
600
|
+
};
|
|
601
|
+
return constraints;
|
|
602
|
+
};
|
|
603
|
+
function scoreCameraCapabilities(camera) {
|
|
604
|
+
let score = 0;
|
|
605
|
+
if (camera.torchSupported) score += 1;
|
|
606
|
+
if (camera.singleShotSupported) score += 1;
|
|
607
|
+
return score;
|
|
608
|
+
}
|
|
609
|
+
function filterCamerasByFacing(cameras, requestedFacing) {
|
|
610
|
+
return cameras.filter((camera) => {
|
|
611
|
+
if (requestedFacing === "back" || requestedFacing === void 0) {
|
|
612
|
+
return isBackCameraName(camera.name);
|
|
613
|
+
} else {
|
|
614
|
+
return isFrontCameraName(camera.name);
|
|
615
|
+
}
|
|
616
|
+
});
|
|
617
|
+
}
|
|
618
|
+
const findIdealCamera = async (cameras, resolution = "4k", requestedFacing = "back") => {
|
|
619
|
+
if (cameras.length === 0) {
|
|
492
620
|
throw new Error("No cameras found");
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
621
|
+
}
|
|
622
|
+
if (cameras.length === 1) {
|
|
623
|
+
await cameras[0].startStream(resolution);
|
|
624
|
+
return cameras[0];
|
|
625
|
+
}
|
|
626
|
+
let cameraPool = filterCamerasByFacing(cameras, requestedFacing);
|
|
627
|
+
if (cameraPool.length === 1) {
|
|
628
|
+
await cameraPool[0].startStream(resolution);
|
|
629
|
+
return cameraPool[0];
|
|
630
|
+
}
|
|
631
|
+
if (cameraPool.length === 0) {
|
|
632
|
+
console.debug("No camera found with requested facing, using all cameras");
|
|
633
|
+
cameraPool = cameras;
|
|
634
|
+
}
|
|
635
|
+
if (requestedFacing === "back") {
|
|
636
|
+
const dualWideCamera = cameraPool.find(
|
|
637
|
+
(camera) => backDualWideCameraLocalizations.includes(camera.name)
|
|
496
638
|
);
|
|
497
|
-
if (
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
const a = r.filter((o) => t === "back" || t === void 0 ? Ce(o.name) : ke(o.name));
|
|
501
|
-
if (a.length === 1 && a[0].facingMode === t)
|
|
502
|
-
return await a[0].startStream(e), a[0];
|
|
503
|
-
if (a.length > 0 && t === "front") {
|
|
504
|
-
const o = a[a.length - 1];
|
|
505
|
-
return await o.startStream(e), o;
|
|
506
|
-
}
|
|
507
|
-
a.length === 0 && (console.debug("No camera found with requested facing, using all cameras"), a.push(...r));
|
|
508
|
-
const n = /* @__PURE__ */ new Map();
|
|
509
|
-
r.forEach((o) => n.set(o, 0));
|
|
510
|
-
for (let o = a.length - 1; o >= 0; o--) {
|
|
511
|
-
const i = a[o];
|
|
512
|
-
if (await i.startStream(e), !i.facingMode)
|
|
513
|
-
return console.debug("No facing mode, returning last camera"), i;
|
|
514
|
-
if (i.facingMode && i.facingMode !== t) {
|
|
515
|
-
console.debug("Mismatched facing mode, moving on to the next camera"), i.stopStream();
|
|
516
|
-
continue;
|
|
639
|
+
if (dualWideCamera) {
|
|
640
|
+
await dualWideCamera.startStream(resolution);
|
|
641
|
+
return dualWideCamera;
|
|
517
642
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
643
|
+
}
|
|
644
|
+
if (requestedFacing === "front") {
|
|
645
|
+
const lastCamera = cameraPool[cameraPool.length - 1];
|
|
646
|
+
await lastCamera.startStream(resolution);
|
|
647
|
+
return lastCamera;
|
|
648
|
+
}
|
|
649
|
+
const cameraScores = /* @__PURE__ */ new Map();
|
|
650
|
+
let bestCamera;
|
|
651
|
+
let maxScore = -Infinity;
|
|
652
|
+
for (let i = cameraPool.length - 1; i >= 0; i--) {
|
|
653
|
+
const camera = cameraPool[i];
|
|
654
|
+
try {
|
|
655
|
+
await camera.startStream(resolution);
|
|
656
|
+
const score = scoreCameraCapabilities(camera);
|
|
657
|
+
cameraScores.set(camera, score);
|
|
658
|
+
if (score > maxScore) {
|
|
659
|
+
if (bestCamera && bestCamera !== camera) {
|
|
660
|
+
bestCamera.stopStream();
|
|
661
|
+
}
|
|
662
|
+
maxScore = score;
|
|
663
|
+
bestCamera = camera;
|
|
664
|
+
} else {
|
|
665
|
+
camera.stopStream();
|
|
666
|
+
}
|
|
667
|
+
if (score === 2) {
|
|
668
|
+
console.debug("Found camera with all capabilities, returning early");
|
|
669
|
+
return camera;
|
|
670
|
+
}
|
|
671
|
+
} catch (error) {
|
|
672
|
+
console.warn(`Failed to test camera ${camera.name}:`, error);
|
|
673
|
+
camera.stopStream();
|
|
526
674
|
}
|
|
527
|
-
i.stopStream();
|
|
528
675
|
}
|
|
529
|
-
|
|
676
|
+
if (bestCamera) {
|
|
677
|
+
return bestCamera;
|
|
678
|
+
}
|
|
679
|
+
const firstCamera = cameraPool[0];
|
|
680
|
+
await firstCamera.startStream(resolution);
|
|
681
|
+
return firstCamera;
|
|
530
682
|
};
|
|
531
|
-
function
|
|
532
|
-
const
|
|
533
|
-
for (const
|
|
534
|
-
const
|
|
535
|
-
|
|
683
|
+
function createCameras(cameras) {
|
|
684
|
+
const camerasWithStream = [];
|
|
685
|
+
for (const device of cameras) {
|
|
686
|
+
const camera = new Camera(device);
|
|
687
|
+
if (camera !== null) {
|
|
688
|
+
camerasWithStream.push(camera);
|
|
689
|
+
}
|
|
536
690
|
}
|
|
537
|
-
return
|
|
691
|
+
return camerasWithStream;
|
|
538
692
|
}
|
|
539
|
-
const
|
|
693
|
+
const videoResolutions = {
|
|
540
694
|
"720p": { width: 1280, height: 720 },
|
|
541
695
|
"1080p": { width: 1920, height: 1080 },
|
|
542
696
|
"4k": { width: 3840, height: 2160 }
|
|
543
697
|
};
|
|
544
|
-
function
|
|
545
|
-
return Math.max(
|
|
698
|
+
function returnLongerSide(resolution) {
|
|
699
|
+
return Math.max(resolution.width, resolution.height);
|
|
546
700
|
}
|
|
547
|
-
function
|
|
548
|
-
const
|
|
549
|
-
width: Math.max(
|
|
550
|
-
height: Math.min(
|
|
701
|
+
function getNormalizedResolution(resolution) {
|
|
702
|
+
const normalized = {
|
|
703
|
+
width: Math.max(resolution.width, resolution.height),
|
|
704
|
+
height: Math.min(resolution.width, resolution.height)
|
|
551
705
|
};
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
706
|
+
const epsilon = 1e-4;
|
|
707
|
+
if (Math.abs(normalized.width / normalized.height - 16 / 9) > epsilon) {
|
|
708
|
+
console.warn(
|
|
709
|
+
`Resolution ${JSON.stringify(
|
|
710
|
+
resolution
|
|
711
|
+
)} is not 16:9, may cause issues with some video players.`
|
|
712
|
+
);
|
|
713
|
+
}
|
|
714
|
+
return normalized;
|
|
557
715
|
}
|
|
558
|
-
function
|
|
559
|
-
const
|
|
560
|
-
|
|
716
|
+
function matchClosestResolution(resolution) {
|
|
717
|
+
const actualWidth = returnLongerSide(resolution);
|
|
718
|
+
if (actualWidth > 1920) {
|
|
719
|
+
return "4k";
|
|
720
|
+
} else if (actualWidth > 1280) {
|
|
721
|
+
return "1080p";
|
|
722
|
+
} else {
|
|
723
|
+
return "720p";
|
|
724
|
+
}
|
|
561
725
|
}
|
|
562
|
-
function
|
|
563
|
-
const
|
|
564
|
-
|
|
726
|
+
function findResolutionKey(videoTrackResolution) {
|
|
727
|
+
const normalizedResolution = getNormalizedResolution(videoTrackResolution);
|
|
728
|
+
const resolutionMatch = Object.entries(videoResolutions).find(
|
|
729
|
+
([key, value]) => {
|
|
730
|
+
return value.width === normalizedResolution.width && value.height === normalizedResolution.height;
|
|
731
|
+
}
|
|
565
732
|
);
|
|
566
|
-
if (!
|
|
567
|
-
const
|
|
568
|
-
|
|
569
|
-
`No exact resolution match found for ${JSON.stringify(
|
|
570
|
-
)
|
|
733
|
+
if (!resolutionMatch) {
|
|
734
|
+
const closestMatch = matchClosestResolution(videoTrackResolution);
|
|
735
|
+
console.warn(
|
|
736
|
+
`No exact resolution match found for ${JSON.stringify(videoTrackResolution)}, categorizing as ${closestMatch}`
|
|
737
|
+
);
|
|
738
|
+
return closestMatch;
|
|
571
739
|
}
|
|
572
|
-
|
|
740
|
+
const resolutionKey = resolutionMatch[0];
|
|
741
|
+
return resolutionKey;
|
|
573
742
|
}
|
|
574
|
-
class
|
|
743
|
+
class Camera {
|
|
575
744
|
deviceInfo;
|
|
576
745
|
/**
|
|
577
746
|
* Stream capabilities as reported by the stream.
|
|
@@ -585,9 +754,9 @@ class Me {
|
|
|
585
754
|
activeStream;
|
|
586
755
|
name;
|
|
587
756
|
facingMode;
|
|
588
|
-
torchSupported =
|
|
589
|
-
torchEnabled =
|
|
590
|
-
singleShotSupported =
|
|
757
|
+
torchSupported = false;
|
|
758
|
+
torchEnabled = false;
|
|
759
|
+
singleShotSupported = false;
|
|
591
760
|
maxSupportedResolution;
|
|
592
761
|
/**
|
|
593
762
|
* Reference to the original instance before it was proxied.
|
|
@@ -604,100 +773,158 @@ class Me {
|
|
|
604
773
|
*
|
|
605
774
|
* @deprecated Not used. Reconsider using once Firefox and Chrome align on this.
|
|
606
775
|
*/
|
|
607
|
-
#
|
|
608
|
-
constructor(
|
|
609
|
-
if (
|
|
776
|
+
#deviceCapabilities;
|
|
777
|
+
constructor(deviceInfo) {
|
|
778
|
+
if (deviceInfo.kind !== "videoinput") {
|
|
610
779
|
throw new Error("Device is not a video input device");
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
780
|
+
}
|
|
781
|
+
this.deviceInfo = deviceInfo;
|
|
782
|
+
this.name = deviceInfo.label;
|
|
783
|
+
if (isFrontCameraName(deviceInfo.label)) {
|
|
784
|
+
this.facingMode = "front";
|
|
785
|
+
}
|
|
786
|
+
if (isBackCameraName(deviceInfo.label)) {
|
|
787
|
+
this.facingMode = "back";
|
|
788
|
+
}
|
|
789
|
+
const originalRef = this;
|
|
790
|
+
const proxy = new Proxy(this, {
|
|
791
|
+
set(target, property, value, receiver) {
|
|
792
|
+
const oldValue = Reflect.get(target, property, receiver);
|
|
793
|
+
const change = {
|
|
794
|
+
property,
|
|
795
|
+
oldValue,
|
|
796
|
+
value
|
|
618
797
|
};
|
|
619
|
-
|
|
798
|
+
originalRef.notify(change);
|
|
799
|
+
return Reflect.set(target, property, value, receiver);
|
|
620
800
|
}
|
|
621
801
|
});
|
|
622
|
-
|
|
623
|
-
this.notifyStateChange?.(
|
|
624
|
-
}
|
|
802
|
+
this.notify = (reason) => {
|
|
803
|
+
this.notifyStateChange?.(proxy, reason);
|
|
804
|
+
};
|
|
805
|
+
return proxy;
|
|
625
806
|
}
|
|
626
|
-
async startStream(
|
|
627
|
-
if (this.activeStream)
|
|
807
|
+
async startStream(resolution) {
|
|
808
|
+
if (this.activeStream) {
|
|
628
809
|
return this.activeStream;
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
810
|
+
}
|
|
811
|
+
if (this.maxSupportedResolution) {
|
|
812
|
+
resolution = this.maxSupportedResolution;
|
|
813
|
+
}
|
|
814
|
+
const stream = await this.acquireStreamWithFallback(resolution);
|
|
815
|
+
this.populateCapabilities(stream);
|
|
816
|
+
this.activeStream = stream;
|
|
817
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
818
|
+
videoTrack.onended = (e) => {
|
|
819
|
+
this.stopStream();
|
|
820
|
+
this.notify({
|
|
821
|
+
event: e,
|
|
636
822
|
payload: "TRACK_END"
|
|
637
823
|
});
|
|
638
|
-
}
|
|
824
|
+
};
|
|
825
|
+
return stream;
|
|
639
826
|
}
|
|
640
827
|
/**
|
|
641
828
|
* Acquires a camera stream with the specified resolution.
|
|
642
829
|
* If acquisition fails, it tries a lower resolution as fallback.
|
|
643
830
|
*/
|
|
644
|
-
async acquireStreamWithFallback(
|
|
831
|
+
async acquireStreamWithFallback(resolution) {
|
|
645
832
|
try {
|
|
646
|
-
const
|
|
647
|
-
|
|
833
|
+
const constraints = createConstraints(
|
|
834
|
+
resolution,
|
|
648
835
|
this.facingMode,
|
|
649
836
|
this.deviceInfo.deviceId
|
|
650
837
|
);
|
|
651
|
-
return await navigator.mediaDevices.getUserMedia(
|
|
652
|
-
} catch (
|
|
838
|
+
return await navigator.mediaDevices.getUserMedia(constraints);
|
|
839
|
+
} catch (error) {
|
|
653
840
|
console.warn(
|
|
654
|
-
`Can't get camera stream for ${this.name} at ${
|
|
655
|
-
|
|
841
|
+
`Can't get camera stream for ${this.name} at ${resolution}`,
|
|
842
|
+
error
|
|
656
843
|
);
|
|
657
|
-
let
|
|
658
|
-
if (
|
|
844
|
+
let currentResolutionIndex = Object.keys(videoResolutions).indexOf(resolution);
|
|
845
|
+
if (currentResolutionIndex === 0) {
|
|
659
846
|
throw new Error("Failed to get camera stream");
|
|
660
|
-
|
|
661
|
-
|
|
847
|
+
}
|
|
848
|
+
const fallbackResolution = Object.keys(videoResolutions)[currentResolutionIndex - 1];
|
|
849
|
+
return await this.acquireStreamWithFallback(fallbackResolution);
|
|
662
850
|
}
|
|
663
851
|
}
|
|
664
852
|
/**
|
|
665
853
|
* Populates the camera instance with capabilities from the stream.
|
|
666
854
|
*/
|
|
667
|
-
populateCapabilities(
|
|
668
|
-
this.streamCapabilities =
|
|
669
|
-
const
|
|
670
|
-
|
|
855
|
+
populateCapabilities(stream) {
|
|
856
|
+
this.streamCapabilities = stream.getVideoTracks()[0].getCapabilities();
|
|
857
|
+
const videoTrack = stream.getVideoTracks()[0];
|
|
858
|
+
const trackSettings = videoTrack.getSettings();
|
|
859
|
+
if (!trackSettings.width || !trackSettings.height) {
|
|
671
860
|
throw new Error(
|
|
672
861
|
"Video track resolution not available. Should not happen."
|
|
673
862
|
);
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
863
|
+
}
|
|
864
|
+
const videoTrackResolution = {
|
|
865
|
+
width: trackSettings.width,
|
|
866
|
+
height: trackSettings.height
|
|
867
|
+
};
|
|
868
|
+
const resolutionKey = findResolutionKey(videoTrackResolution);
|
|
869
|
+
if (!this.maxSupportedResolution && resolutionKey) {
|
|
870
|
+
this.maxSupportedResolution = resolutionKey;
|
|
871
|
+
}
|
|
872
|
+
if ("torch" in this.streamCapabilities) {
|
|
873
|
+
this.torchSupported = true;
|
|
874
|
+
}
|
|
875
|
+
if ("focusMode" in this.streamCapabilities && this.streamCapabilities.focusMode?.includes("single-shot")) {
|
|
876
|
+
this.singleShotSupported = true;
|
|
877
|
+
}
|
|
878
|
+
if (this.facingMode === "front" && this.streamCapabilities.facingMode?.includes("environment")) {
|
|
879
|
+
this.facingMode = "back";
|
|
880
|
+
console.warn("Front camera selected, but facingMode is environment");
|
|
881
|
+
}
|
|
882
|
+
if (this.facingMode === "back" && this.streamCapabilities.facingMode?.includes("user")) {
|
|
883
|
+
this.facingMode = "front";
|
|
884
|
+
console.warn("Back camera selected, but facingMode is user");
|
|
885
|
+
}
|
|
886
|
+
if (!this.facingMode) {
|
|
887
|
+
if (this.streamCapabilities.facingMode?.includes("environment")) {
|
|
888
|
+
this.facingMode = "back";
|
|
889
|
+
}
|
|
890
|
+
if (this.streamCapabilities.facingMode?.includes("user")) {
|
|
891
|
+
this.facingMode = "front";
|
|
892
|
+
}
|
|
893
|
+
}
|
|
679
894
|
}
|
|
680
895
|
async toggleTorch() {
|
|
681
|
-
const
|
|
682
|
-
if (!
|
|
896
|
+
const videoTrack = this.getVideoTrack();
|
|
897
|
+
if (!videoTrack) {
|
|
683
898
|
throw new Error("No active stream on Camera instance.");
|
|
684
|
-
|
|
899
|
+
}
|
|
900
|
+
if (!this.torchSupported) {
|
|
685
901
|
throw new Error("Torch not supported on this device.");
|
|
902
|
+
}
|
|
686
903
|
try {
|
|
687
|
-
await
|
|
904
|
+
await videoTrack.applyConstraints({
|
|
688
905
|
advanced: [
|
|
689
906
|
{
|
|
690
907
|
torch: !this.torchEnabled
|
|
691
908
|
}
|
|
692
909
|
]
|
|
693
|
-
})
|
|
694
|
-
|
|
695
|
-
|
|
910
|
+
});
|
|
911
|
+
this.torchEnabled = !this.torchEnabled;
|
|
912
|
+
} catch (error) {
|
|
913
|
+
console.error("Failed to toggle torch", error);
|
|
914
|
+
this.torchEnabled = false;
|
|
915
|
+
this.torchSupported = false;
|
|
916
|
+
throw new Error("Failed to toggle torch", { cause: error });
|
|
696
917
|
}
|
|
697
918
|
return this.torchEnabled;
|
|
698
919
|
}
|
|
699
920
|
stopStream() {
|
|
700
|
-
|
|
921
|
+
if (this.activeStream) {
|
|
922
|
+
console.debug(`Stopping active stream on ${this.name}`);
|
|
923
|
+
closeStreamTracks(this.activeStream);
|
|
924
|
+
this.activeStream = void 0;
|
|
925
|
+
this.streamCapabilities = void 0;
|
|
926
|
+
this.torchEnabled = false;
|
|
927
|
+
}
|
|
701
928
|
}
|
|
702
929
|
getVideoTrack() {
|
|
703
930
|
if (!this.activeStream) {
|
|
@@ -707,149 +934,241 @@ class Me {
|
|
|
707
934
|
return this.activeStream.getVideoTracks()[0];
|
|
708
935
|
}
|
|
709
936
|
}
|
|
710
|
-
const
|
|
711
|
-
function
|
|
712
|
-
return typeof window.ShadyDOM
|
|
937
|
+
const ORIGINAL_ATTACH_SHADOW = Element.prototype.attachShadow;
|
|
938
|
+
function isShady() {
|
|
939
|
+
return typeof window.ShadyDOM !== "undefined" && typeof ShadowRoot !== "undefined";
|
|
713
940
|
}
|
|
714
|
-
function
|
|
715
|
-
return typeof ShadowRoot
|
|
941
|
+
function supportsShadowRoots() {
|
|
942
|
+
return typeof ShadowRoot !== "undefined";
|
|
716
943
|
}
|
|
717
|
-
function
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
944
|
+
function patchElementPrototypeAttachShadow(callback) {
|
|
945
|
+
if (ORIGINAL_ATTACH_SHADOW == null || isShady())
|
|
946
|
+
return;
|
|
947
|
+
Element.prototype.attachShadow = function(shadowRootInitDict) {
|
|
948
|
+
const shadowRoot = ORIGINAL_ATTACH_SHADOW.call(this, shadowRootInitDict);
|
|
949
|
+
callback(shadowRoot);
|
|
950
|
+
return shadowRoot;
|
|
951
|
+
};
|
|
722
952
|
}
|
|
723
|
-
function
|
|
724
|
-
const
|
|
725
|
-
let
|
|
726
|
-
const
|
|
727
|
-
for (const
|
|
728
|
-
|
|
729
|
-
|
|
953
|
+
function createPausableQueue(job, ...queueItems) {
|
|
954
|
+
const queue = new Set(queueItems);
|
|
955
|
+
let running = false;
|
|
956
|
+
const flush = () => {
|
|
957
|
+
for (const queuedNode of queue) {
|
|
958
|
+
job(queuedNode);
|
|
959
|
+
}
|
|
960
|
+
queue.clear();
|
|
730
961
|
};
|
|
731
962
|
return {
|
|
732
963
|
isRunning() {
|
|
733
|
-
return
|
|
964
|
+
return running;
|
|
734
965
|
},
|
|
735
|
-
schedule(
|
|
736
|
-
|
|
966
|
+
schedule(node) {
|
|
967
|
+
queue.add(node);
|
|
968
|
+
if (running) {
|
|
969
|
+
flush();
|
|
970
|
+
}
|
|
737
971
|
},
|
|
738
972
|
stop() {
|
|
739
|
-
|
|
973
|
+
running = false;
|
|
740
974
|
},
|
|
741
975
|
run() {
|
|
742
|
-
|
|
976
|
+
if (running)
|
|
977
|
+
return;
|
|
978
|
+
running = true;
|
|
979
|
+
flush();
|
|
743
980
|
}
|
|
744
981
|
};
|
|
745
982
|
}
|
|
746
|
-
const
|
|
747
|
-
childList:
|
|
748
|
-
subtree:
|
|
749
|
-
}
|
|
750
|
-
|
|
983
|
+
const MUTATION_OBSERVER_INIT = {
|
|
984
|
+
childList: true,
|
|
985
|
+
subtree: true
|
|
986
|
+
};
|
|
987
|
+
const nextMicrotask = (func) => {
|
|
988
|
+
if (typeof queueMicrotask !== "undefined")
|
|
989
|
+
queueMicrotask(func);
|
|
990
|
+
else if (typeof Promise !== "undefined")
|
|
991
|
+
Promise.resolve().then(() => func());
|
|
992
|
+
else
|
|
993
|
+
setTimeout(() => func(), 0);
|
|
751
994
|
};
|
|
752
|
-
function
|
|
753
|
-
if (typeof Symbol
|
|
754
|
-
return [...
|
|
755
|
-
{
|
|
756
|
-
const
|
|
757
|
-
for (let
|
|
758
|
-
|
|
759
|
-
|
|
995
|
+
function nodeListToArray(nodeList) {
|
|
996
|
+
if (typeof Symbol !== "undefined" && nodeList[Symbol.iterator] != null) {
|
|
997
|
+
return [...nodeList];
|
|
998
|
+
} else {
|
|
999
|
+
const arr = [];
|
|
1000
|
+
for (let i = 0; i < nodeList.length; i++) {
|
|
1001
|
+
arr[i] = nodeList[i];
|
|
1002
|
+
}
|
|
1003
|
+
return arr;
|
|
760
1004
|
}
|
|
761
1005
|
}
|
|
762
|
-
function
|
|
763
|
-
|
|
1006
|
+
function queryRoot(root, query) {
|
|
1007
|
+
if (isShady()) {
|
|
1008
|
+
return new Set(nodeListToArray(window.ShadyDOM.nativeMethods.querySelectorAll.call(document.documentElement, query)));
|
|
1009
|
+
}
|
|
1010
|
+
return new Set(!("querySelectorAll" in root) ? [] : nodeListToArray(root.querySelectorAll(query)));
|
|
764
1011
|
}
|
|
765
|
-
function
|
|
766
|
-
return /* @__PURE__ */ new Set([...
|
|
1012
|
+
function mergeNodes(a, b) {
|
|
1013
|
+
return /* @__PURE__ */ new Set([...a == null ? [] : a, ...b == null ? [] : b]);
|
|
767
1014
|
}
|
|
768
|
-
function
|
|
769
|
-
return "activeElement" in
|
|
1015
|
+
function isDocumentOrShadowRoot(root) {
|
|
1016
|
+
return "activeElement" in root;
|
|
770
1017
|
}
|
|
771
|
-
function
|
|
772
|
-
if (
|
|
1018
|
+
function observeMissingRoots(root = document.documentElement) {
|
|
1019
|
+
if (isDocumentOrShadowRoot(root)) {
|
|
1020
|
+
observeRoot(root);
|
|
1021
|
+
}
|
|
1022
|
+
if (isShady() && root instanceof ShadowRoot)
|
|
1023
|
+
return;
|
|
1024
|
+
if (!supportsShadowRoots())
|
|
773
1025
|
return;
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
|
|
1026
|
+
const childNodes = root.childNodes;
|
|
1027
|
+
const shadowRoot = "shadowRoot" in root && root.shadowRoot != null ? [root.shadowRoot] : [];
|
|
1028
|
+
for (const node of [...childNodes, ...shadowRoot]) {
|
|
1029
|
+
observeMissingRoots(node);
|
|
1030
|
+
}
|
|
777
1031
|
}
|
|
778
|
-
function
|
|
779
|
-
|
|
1032
|
+
function isConnected(node) {
|
|
1033
|
+
if ("isConnected" in Node.prototype)
|
|
1034
|
+
return node.isConnected;
|
|
1035
|
+
return node.ownerDocument == null || !(node.ownerDocument.compareDocumentPosition(node) & node.DOCUMENT_POSITION_DISCONNECTED);
|
|
780
1036
|
}
|
|
781
|
-
const
|
|
782
|
-
function
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return t.clear(), v;
|
|
796
|
-
}, h = () => {
|
|
797
|
-
a.clear();
|
|
798
|
-
}, p = (v, x) => {
|
|
799
|
-
let R = n.get(v);
|
|
800
|
-
const F = Ct(v, x), M = R?.get(x), Pe = kt(F, M);
|
|
801
|
-
C(Pe), R == null && (R = /* @__PURE__ */ new Map(), n.set(v, R)), R.set(x, F);
|
|
802
|
-
}, C = (v) => {
|
|
803
|
-
for (const x of v) {
|
|
804
|
-
const R = o.get(x), F = _t(x);
|
|
805
|
-
R !== F && (o.set(x, F), y({
|
|
806
|
-
connected: F,
|
|
807
|
-
target: x
|
|
808
|
-
}));
|
|
1037
|
+
const CONNECTION_OBSERVER_INTERNALS_MAP = /* @__PURE__ */ new Map();
|
|
1038
|
+
function initializeConnectionObserver(observer, callback) {
|
|
1039
|
+
const queue = /* @__PURE__ */ new Set();
|
|
1040
|
+
const observedTargets = /* @__PURE__ */ new Set();
|
|
1041
|
+
const rootToQuerySelectorToMatchedNodesMap = /* @__PURE__ */ new Map();
|
|
1042
|
+
const nodeToLastConnectionValueMap = /* @__PURE__ */ new WeakMap();
|
|
1043
|
+
let scheduled = false;
|
|
1044
|
+
let flushing = false;
|
|
1045
|
+
let hasFoundMissingRoots = false;
|
|
1046
|
+
const flush = () => {
|
|
1047
|
+
flushing = true;
|
|
1048
|
+
const arr = [...queue];
|
|
1049
|
+
if (arr.length > 0) {
|
|
1050
|
+
callback(arr, observer);
|
|
809
1051
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
1052
|
+
queue.clear();
|
|
1053
|
+
scheduled = false;
|
|
1054
|
+
flushing = false;
|
|
1055
|
+
};
|
|
1056
|
+
const scheduleFlush = () => {
|
|
1057
|
+
if (!scheduled) {
|
|
1058
|
+
scheduled = true;
|
|
1059
|
+
nextMicrotask(flush);
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
const addToQueue = (entry) => {
|
|
1063
|
+
queue.add(entry);
|
|
1064
|
+
if (!flushing) {
|
|
1065
|
+
scheduleFlush();
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
const clearQueue = () => {
|
|
1069
|
+
const items = [...queue];
|
|
1070
|
+
queue.clear();
|
|
1071
|
+
return items;
|
|
823
1072
|
};
|
|
824
|
-
|
|
1073
|
+
const clearObservedTargets = () => {
|
|
1074
|
+
observedTargets.clear();
|
|
1075
|
+
};
|
|
1076
|
+
const queryRootAndHandleMutationChanges = (root, query) => {
|
|
1077
|
+
let oldQuerySelectorMap = rootToQuerySelectorToMatchedNodesMap.get(root);
|
|
1078
|
+
const currentNodes = queryRoot(root, query);
|
|
1079
|
+
const oldNodes = oldQuerySelectorMap == null ? void 0 : oldQuerySelectorMap.get(query);
|
|
1080
|
+
const mergedNodes = mergeNodes(currentNodes, oldNodes);
|
|
1081
|
+
handleMutationChange(mergedNodes);
|
|
1082
|
+
if (oldQuerySelectorMap == null) {
|
|
1083
|
+
oldQuerySelectorMap = /* @__PURE__ */ new Map();
|
|
1084
|
+
rootToQuerySelectorToMatchedNodesMap.set(root, oldQuerySelectorMap);
|
|
1085
|
+
}
|
|
1086
|
+
oldQuerySelectorMap.set(query, currentNodes);
|
|
1087
|
+
};
|
|
1088
|
+
const handleMutationChange = (targetNodes) => {
|
|
1089
|
+
for (const targetNode of targetNodes) {
|
|
1090
|
+
const lastValue = nodeToLastConnectionValueMap.get(targetNode);
|
|
1091
|
+
const isTargetNodeConnected = isConnected(targetNode);
|
|
1092
|
+
if (lastValue !== isTargetNodeConnected) {
|
|
1093
|
+
nodeToLastConnectionValueMap.set(targetNode, isTargetNodeConnected);
|
|
1094
|
+
addToQueue({
|
|
1095
|
+
connected: isTargetNodeConnected,
|
|
1096
|
+
target: targetNode
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
const addObservedTarget = (target) => {
|
|
1102
|
+
rootObserverQueue.run();
|
|
1103
|
+
if (!hasFoundMissingRoots) {
|
|
1104
|
+
hasFoundMissingRoots = true;
|
|
1105
|
+
observeMissingRoots();
|
|
1106
|
+
}
|
|
1107
|
+
observedTargets.add(target);
|
|
1108
|
+
if (typeof target !== "string") {
|
|
1109
|
+
handleMutationChange([target]);
|
|
1110
|
+
} else {
|
|
1111
|
+
for (const root of OBSERVED_ROOTS) {
|
|
1112
|
+
queryRootAndHandleMutationChanges(root, target);
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
const internals = {
|
|
1117
|
+
observedTargets,
|
|
1118
|
+
queryRootAndHandleMutationChanges,
|
|
1119
|
+
handleMutationChange,
|
|
1120
|
+
addObservedTarget,
|
|
1121
|
+
clearObservedTargets,
|
|
1122
|
+
clearQueue
|
|
1123
|
+
};
|
|
1124
|
+
CONNECTION_OBSERVER_INTERNALS_MAP.set(observer, internals);
|
|
825
1125
|
}
|
|
826
|
-
const
|
|
827
|
-
for (const
|
|
828
|
-
if (
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
1126
|
+
const mutationCallback = (mutations) => {
|
|
1127
|
+
for (const mutation of mutations) {
|
|
1128
|
+
if (mutation.type !== "childList")
|
|
1129
|
+
continue;
|
|
1130
|
+
for (const observer of CONNECTION_OBSERVER_INTERNALS_MAP.values()) {
|
|
1131
|
+
for (const target of observer.observedTargets) {
|
|
1132
|
+
if (typeof target === "string") {
|
|
1133
|
+
observer.queryRootAndHandleMutationChanges(mutation.target, target);
|
|
1134
|
+
} else {
|
|
1135
|
+
observer.handleMutationChange([target]);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
const OBSERVED_ROOTS = /* @__PURE__ */ new Set();
|
|
1142
|
+
const observeRoot = /* @__PURE__ */ (() => {
|
|
1143
|
+
let instance;
|
|
1144
|
+
return function(root) {
|
|
1145
|
+
if (OBSERVED_ROOTS.has(root))
|
|
1146
|
+
return;
|
|
1147
|
+
OBSERVED_ROOTS.add(root);
|
|
1148
|
+
if (instance == null) {
|
|
1149
|
+
instance = new MutationObserver(mutationCallback);
|
|
1150
|
+
}
|
|
1151
|
+
instance.observe(root, MUTATION_OBSERVER_INIT);
|
|
836
1152
|
};
|
|
837
|
-
})()
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
if (
|
|
845
|
-
throw new
|
|
846
|
-
|
|
1153
|
+
})();
|
|
1154
|
+
const rootObserverQueue = createPausableQueue(observeRoot, document.documentElement);
|
|
1155
|
+
class ConnectionObserver {
|
|
1156
|
+
constructor(callback) {
|
|
1157
|
+
if (new.target === void 0) {
|
|
1158
|
+
throw new TypeError(`Constructor ${ConnectionObserver.name} requires 'new'`);
|
|
1159
|
+
}
|
|
1160
|
+
if (callback === void 0) {
|
|
1161
|
+
throw new ReferenceError(`Failed to construct '${ConnectionObserver.name}': 1 argument required, but only 0 present.`);
|
|
1162
|
+
} else if (typeof callback !== "function") {
|
|
1163
|
+
throw new TypeError(`Failed to construct '${ConnectionObserver.name}': The callback provided as parameter 1 is not a function.`);
|
|
1164
|
+
}
|
|
1165
|
+
initializeConnectionObserver(this, callback);
|
|
847
1166
|
}
|
|
848
1167
|
/**
|
|
849
1168
|
* The Symbol.@@toStringTag value
|
|
850
1169
|
*/
|
|
851
1170
|
get [Symbol.toStringTag]() {
|
|
852
|
-
return
|
|
1171
|
+
return `ConnectionObserver`;
|
|
853
1172
|
}
|
|
854
1173
|
/**
|
|
855
1174
|
* Observe the given node or query selector for connections/disconnections.
|
|
@@ -857,121 +1176,148 @@ class N {
|
|
|
857
1176
|
* as for example "img[data-some-attr]", for each new MutationRecord, the query selector
|
|
858
1177
|
* will be executed and the matched nodes will be observed for connections/disconnections
|
|
859
1178
|
*/
|
|
860
|
-
observe(
|
|
861
|
-
if (
|
|
862
|
-
throw new ReferenceError(`Failed to execute '${this.observe.name}' on '${
|
|
863
|
-
if (typeof
|
|
864
|
-
throw new TypeError(`Failed to execute '${this.observe.name}' on '${
|
|
865
|
-
|
|
866
|
-
|
|
1179
|
+
observe(target) {
|
|
1180
|
+
if (target === void 0) {
|
|
1181
|
+
throw new ReferenceError(`Failed to execute '${this.observe.name}' on '${ConnectionObserver.name}': 1 argument required, but only 0 present.`);
|
|
1182
|
+
} else if (typeof target !== "string" && !(target instanceof Node)) {
|
|
1183
|
+
throw new TypeError(`Failed to execute '${this.observe.name}' on '${ConnectionObserver.name}': parameter 1 is not of type 'Node' or a DOMString.`);
|
|
1184
|
+
}
|
|
1185
|
+
const internals = CONNECTION_OBSERVER_INTERNALS_MAP.get(this);
|
|
1186
|
+
if (internals == null)
|
|
1187
|
+
return;
|
|
1188
|
+
internals.addObservedTarget(target);
|
|
867
1189
|
}
|
|
868
1190
|
/**
|
|
869
1191
|
* Takes the records immediately (instead of waiting for the next flush)
|
|
870
1192
|
*/
|
|
871
1193
|
takeRecords() {
|
|
872
|
-
const
|
|
873
|
-
|
|
1194
|
+
const internals = CONNECTION_OBSERVER_INTERNALS_MAP.get(this);
|
|
1195
|
+
if (internals == null)
|
|
1196
|
+
return [];
|
|
1197
|
+
return internals.clearQueue();
|
|
874
1198
|
}
|
|
875
1199
|
/**
|
|
876
1200
|
* Disconnects the ConnectionObserver such that none of its callbacks will be invoked any longer
|
|
877
1201
|
*/
|
|
878
1202
|
disconnect() {
|
|
879
|
-
const
|
|
880
|
-
|
|
1203
|
+
const internals = CONNECTION_OBSERVER_INTERNALS_MAP.get(this);
|
|
1204
|
+
if (internals == null)
|
|
1205
|
+
return;
|
|
1206
|
+
internals.clearObservedTargets();
|
|
881
1207
|
}
|
|
882
1208
|
}
|
|
883
|
-
|
|
884
|
-
function
|
|
885
|
-
|
|
886
|
-
|
|
1209
|
+
patchElementPrototypeAttachShadow(rootObserverQueue.schedule.bind(rootObserverQueue));
|
|
1210
|
+
function radEventListener(element, ...args) {
|
|
1211
|
+
element.addEventListener(...args);
|
|
1212
|
+
return () => {
|
|
1213
|
+
element.removeEventListener(...args);
|
|
887
1214
|
};
|
|
888
1215
|
}
|
|
889
|
-
function
|
|
890
|
-
let
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1216
|
+
function rad(element, gen) {
|
|
1217
|
+
let cleanup;
|
|
1218
|
+
gen((listener, options) => {
|
|
1219
|
+
element.addEventListener(listener, options);
|
|
1220
|
+
cleanup = () => element.removeEventListener(listener, options);
|
|
1221
|
+
});
|
|
1222
|
+
if (!cleanup) {
|
|
894
1223
|
throw new Error("you forgot to add event listener");
|
|
895
|
-
|
|
1224
|
+
}
|
|
1225
|
+
return cleanup;
|
|
896
1226
|
}
|
|
897
|
-
function
|
|
898
|
-
const
|
|
899
|
-
if ("detached" in
|
|
900
|
-
|
|
1227
|
+
function isBufferDetached(buffer) {
|
|
1228
|
+
const actualBuffer = getBuffer(buffer);
|
|
1229
|
+
if ("detached" in actualBuffer) {
|
|
1230
|
+
const detached = actualBuffer.detached;
|
|
1231
|
+
return detached;
|
|
1232
|
+
}
|
|
901
1233
|
try {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
1234
|
+
new Uint8Array(actualBuffer);
|
|
1235
|
+
return false;
|
|
1236
|
+
} catch (e) {
|
|
1237
|
+
return true;
|
|
905
1238
|
}
|
|
906
1239
|
}
|
|
907
|
-
class
|
|
908
|
-
#
|
|
909
|
-
#
|
|
910
|
-
#
|
|
911
|
-
#
|
|
912
|
-
#
|
|
913
|
-
#
|
|
914
|
-
#
|
|
915
|
-
#
|
|
916
|
-
#
|
|
917
|
-
#
|
|
918
|
-
constructor(
|
|
919
|
-
const { canvasRenderingMode
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
1240
|
+
class VideoFrameProcessor {
|
|
1241
|
+
#canvas;
|
|
1242
|
+
#context2d = null;
|
|
1243
|
+
#contextWebGl2 = null;
|
|
1244
|
+
#webGl2Texture = null;
|
|
1245
|
+
#webGl2Framebuffer = null;
|
|
1246
|
+
#buffer = null;
|
|
1247
|
+
#cachedWidth = 0;
|
|
1248
|
+
#cachedHeight = 0;
|
|
1249
|
+
#canvasRenderingMode;
|
|
1250
|
+
#requiredPackAlignment = 4;
|
|
1251
|
+
constructor(options = {}) {
|
|
1252
|
+
const { canvasRenderingMode = "webgl2", fallbackWebGlTo2d = true } = options;
|
|
1253
|
+
this.#canvasRenderingMode = canvasRenderingMode;
|
|
1254
|
+
this.#canvas = document.createElement("canvas");
|
|
1255
|
+
if (canvasRenderingMode === "2d") {
|
|
1256
|
+
this.#initialize2dContext();
|
|
1257
|
+
} else if (canvasRenderingMode === "webgl2") {
|
|
923
1258
|
try {
|
|
924
|
-
this.#
|
|
925
|
-
} catch (
|
|
926
|
-
if (
|
|
1259
|
+
this.#initializeWebGl2Context();
|
|
1260
|
+
} catch (error) {
|
|
1261
|
+
if (fallbackWebGlTo2d) {
|
|
927
1262
|
console.warn(
|
|
928
1263
|
"Failed to create WebGL2 context, falling back to 2D canvas"
|
|
929
|
-
)
|
|
930
|
-
|
|
931
|
-
|
|
1264
|
+
);
|
|
1265
|
+
this.#canvasRenderingMode = "2d";
|
|
1266
|
+
this.#initialize2dContext();
|
|
1267
|
+
} else {
|
|
1268
|
+
throw error;
|
|
1269
|
+
}
|
|
932
1270
|
}
|
|
933
|
-
else
|
|
1271
|
+
} else {
|
|
934
1272
|
throw new Error(
|
|
935
|
-
`Unsupported rendering context: ${
|
|
1273
|
+
`Unsupported rendering context: ${canvasRenderingMode}`
|
|
936
1274
|
);
|
|
1275
|
+
}
|
|
937
1276
|
}
|
|
938
1277
|
/**
|
|
939
1278
|
* Initializes the 2D canvas context
|
|
940
1279
|
*/
|
|
941
|
-
#
|
|
942
|
-
const
|
|
943
|
-
alpha:
|
|
944
|
-
willReadFrequently:
|
|
1280
|
+
#initialize2dContext() {
|
|
1281
|
+
const ctx = this.#canvas.getContext("2d", {
|
|
1282
|
+
alpha: false,
|
|
1283
|
+
willReadFrequently: true
|
|
945
1284
|
});
|
|
946
|
-
if (!
|
|
947
|
-
this.#
|
|
1285
|
+
if (!ctx) throw new Error("CanvasRenderingContext2D is missing!");
|
|
1286
|
+
this.#context2d = ctx;
|
|
948
1287
|
}
|
|
949
1288
|
/**
|
|
950
1289
|
* Initializes the WebGL2 context and resources
|
|
951
1290
|
*/
|
|
952
|
-
#
|
|
953
|
-
const
|
|
954
|
-
alpha:
|
|
955
|
-
depth:
|
|
956
|
-
stencil:
|
|
957
|
-
antialias:
|
|
958
|
-
premultipliedAlpha:
|
|
959
|
-
preserveDrawingBuffer:
|
|
960
|
-
desynchronized:
|
|
1291
|
+
#initializeWebGl2Context() {
|
|
1292
|
+
const ctx = this.#canvas.getContext("webgl2", {
|
|
1293
|
+
alpha: false,
|
|
1294
|
+
depth: false,
|
|
1295
|
+
stencil: false,
|
|
1296
|
+
antialias: false,
|
|
1297
|
+
premultipliedAlpha: false,
|
|
1298
|
+
preserveDrawingBuffer: false,
|
|
1299
|
+
desynchronized: false,
|
|
961
1300
|
powerPreference: "high-performance"
|
|
962
1301
|
});
|
|
963
|
-
if (!
|
|
964
|
-
this.#
|
|
965
|
-
const
|
|
966
|
-
if (!
|
|
967
|
-
this.#
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1302
|
+
if (!ctx) throw new Error("WebGL2RenderingContext is missing!");
|
|
1303
|
+
this.#contextWebGl2 = ctx;
|
|
1304
|
+
const texture = ctx.createTexture();
|
|
1305
|
+
if (!texture) throw new Error("Failed to create WebGL texture");
|
|
1306
|
+
this.#webGl2Texture = texture;
|
|
1307
|
+
ctx.bindTexture(ctx.TEXTURE_2D, texture);
|
|
1308
|
+
ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_S, ctx.CLAMP_TO_EDGE);
|
|
1309
|
+
ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_WRAP_T, ctx.CLAMP_TO_EDGE);
|
|
1310
|
+
ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MIN_FILTER, ctx.NEAREST);
|
|
1311
|
+
ctx.texParameteri(ctx.TEXTURE_2D, ctx.TEXTURE_MAG_FILTER, ctx.NEAREST);
|
|
1312
|
+
const framebuffer = ctx.createFramebuffer();
|
|
1313
|
+
if (!framebuffer) throw new Error("Failed to create framebuffer");
|
|
1314
|
+
this.#webGl2Framebuffer = framebuffer;
|
|
1315
|
+
ctx.bindFramebuffer(ctx.FRAMEBUFFER, framebuffer);
|
|
1316
|
+
ctx.framebufferTexture2D(
|
|
1317
|
+
ctx.FRAMEBUFFER,
|
|
1318
|
+
ctx.COLOR_ATTACHMENT0,
|
|
1319
|
+
ctx.TEXTURE_2D,
|
|
1320
|
+
texture,
|
|
975
1321
|
0
|
|
976
1322
|
);
|
|
977
1323
|
}
|
|
@@ -980,31 +1326,34 @@ class At {
|
|
|
980
1326
|
* This should only be called with ArrayBuffers that were originally from this processor
|
|
981
1327
|
* Typically used after transferring the buffer to/from a worker
|
|
982
1328
|
*/
|
|
983
|
-
reattachArrayBuffer(
|
|
984
|
-
const
|
|
985
|
-
if (
|
|
1329
|
+
reattachArrayBuffer(arrayBuffer) {
|
|
1330
|
+
const actualBuffer = getBuffer(arrayBuffer);
|
|
1331
|
+
if (isBufferDetached(actualBuffer)) {
|
|
986
1332
|
throw new Error("Can't use a detached array buffer!");
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1333
|
+
}
|
|
1334
|
+
const requiredSize = this.#cachedWidth * this.#cachedHeight * 4;
|
|
1335
|
+
if (actualBuffer.byteLength === requiredSize) {
|
|
1336
|
+
this.#buffer = new Uint8ClampedArray(actualBuffer);
|
|
1337
|
+
} else {
|
|
991
1338
|
throw new Error(
|
|
992
|
-
`ArrayBuffer size mismatch: expected ${
|
|
1339
|
+
`ArrayBuffer size mismatch: expected ${requiredSize}, got ${actualBuffer.byteLength}`
|
|
993
1340
|
);
|
|
1341
|
+
}
|
|
994
1342
|
}
|
|
995
1343
|
/**
|
|
996
1344
|
* Used to check if the processor owns the buffer
|
|
997
1345
|
*/
|
|
998
1346
|
isBufferDetached() {
|
|
999
|
-
if (!this.#
|
|
1347
|
+
if (!this.#buffer) {
|
|
1000
1348
|
throw new Error("Buffer is missing!");
|
|
1001
|
-
|
|
1349
|
+
}
|
|
1350
|
+
return isBufferDetached(this.#buffer.buffer);
|
|
1002
1351
|
}
|
|
1003
1352
|
/**
|
|
1004
1353
|
* Extracts image data from a source element
|
|
1005
1354
|
*/
|
|
1006
|
-
getImageData(
|
|
1007
|
-
return this.#
|
|
1355
|
+
getImageData(source, area) {
|
|
1356
|
+
return this.#canvasRenderingMode === "2d" ? this.#getImageData2d(source, area) : this.#getImageDataWebGl2(source, area);
|
|
1008
1357
|
}
|
|
1009
1358
|
/**
|
|
1010
1359
|
* Used to get the current ImageData object with the current buffer. Useful
|
|
@@ -1013,126 +1362,178 @@ class At {
|
|
|
1013
1362
|
* @returns ImageData object with the current buffer
|
|
1014
1363
|
*/
|
|
1015
1364
|
getCurrentImageData() {
|
|
1016
|
-
if (!this.#
|
|
1365
|
+
if (!this.#buffer) {
|
|
1017
1366
|
throw new Error("Buffer is missing!");
|
|
1018
|
-
|
|
1367
|
+
}
|
|
1368
|
+
return new ImageData(this.#buffer, this.#cachedWidth, this.#cachedHeight);
|
|
1019
1369
|
}
|
|
1020
1370
|
/**
|
|
1021
1371
|
* Extract image data using 2D canvas
|
|
1022
1372
|
*/
|
|
1023
|
-
#
|
|
1024
|
-
if (!this.#
|
|
1373
|
+
#getImageData2d(source, area) {
|
|
1374
|
+
if (!this.#context2d)
|
|
1025
1375
|
throw new Error("CanvasRenderingContext2D is missing!");
|
|
1026
|
-
const
|
|
1027
|
-
|
|
1376
|
+
const fullWidth = "videoWidth" in source ? source.videoWidth : source.width;
|
|
1377
|
+
const fullHeight = "videoHeight" in source ? source.videoHeight : source.height;
|
|
1378
|
+
const x = area?.x ?? 0;
|
|
1379
|
+
const y = area?.y ?? 0;
|
|
1380
|
+
const w = area?.width ?? fullWidth;
|
|
1381
|
+
const h = area?.height ?? fullHeight;
|
|
1382
|
+
this.#updateCanvasSize(w, h);
|
|
1383
|
+
this.#context2d.drawImage(source, x, y, w, h);
|
|
1384
|
+
return this.#context2d.getImageData(0, 0, w, h);
|
|
1028
1385
|
}
|
|
1029
1386
|
/**
|
|
1030
1387
|
* Extract image data using WebGL2
|
|
1031
1388
|
*/
|
|
1032
|
-
#
|
|
1033
|
-
if (!this.#
|
|
1389
|
+
#getImageDataWebGl2(source, area) {
|
|
1390
|
+
if (!this.#contextWebGl2 || !this.#webGl2Texture || !this.#webGl2Framebuffer) {
|
|
1034
1391
|
throw new Error("WebGL2 context or resources are missing!");
|
|
1035
|
-
|
|
1036
|
-
|
|
1392
|
+
}
|
|
1393
|
+
const fullWidth = "videoWidth" in source ? source.videoWidth : source.width;
|
|
1394
|
+
const fullHeight = "videoHeight" in source ? source.videoHeight : source.height;
|
|
1395
|
+
const x = area?.x ?? 0;
|
|
1396
|
+
const y = area?.y ?? 0;
|
|
1397
|
+
const w = area?.width ?? fullWidth;
|
|
1398
|
+
const h = area?.height ?? fullHeight;
|
|
1399
|
+
const requiredSize = w * h * 4;
|
|
1400
|
+
this.#updateCanvasSize(w, h);
|
|
1401
|
+
if (this.isBufferDetached()) {
|
|
1037
1402
|
throw new Error("Buffer is detached!");
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1403
|
+
}
|
|
1404
|
+
if (!this.#buffer || this.#buffer.length !== requiredSize) {
|
|
1405
|
+
this.#buffer = new Uint8ClampedArray(requiredSize);
|
|
1406
|
+
}
|
|
1407
|
+
const gl = this.#contextWebGl2;
|
|
1408
|
+
gl.bindTexture(gl.TEXTURE_2D, this.#webGl2Texture);
|
|
1409
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, source);
|
|
1410
|
+
gl.bindFramebuffer(gl.FRAMEBUFFER, this.#webGl2Framebuffer);
|
|
1041
1411
|
try {
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1412
|
+
gl.pixelStorei(gl.PACK_ALIGNMENT, this.#requiredPackAlignment);
|
|
1413
|
+
gl.readPixels(x, y, w, h, gl.RGBA, gl.UNSIGNED_BYTE, this.#buffer);
|
|
1414
|
+
} catch (error) {
|
|
1415
|
+
if (this.#requiredPackAlignment !== 1) {
|
|
1416
|
+
this.#requiredPackAlignment = 1;
|
|
1417
|
+
gl.pixelStorei(gl.PACK_ALIGNMENT, 1);
|
|
1418
|
+
const newBuffer = new Uint8ClampedArray(requiredSize);
|
|
1419
|
+
gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, newBuffer);
|
|
1420
|
+
this.#buffer = newBuffer;
|
|
1421
|
+
return new ImageData(newBuffer, w, h);
|
|
1048
1422
|
}
|
|
1049
|
-
throw
|
|
1423
|
+
throw error;
|
|
1050
1424
|
}
|
|
1051
|
-
return new ImageData(this.#
|
|
1425
|
+
return new ImageData(this.#buffer, w, h);
|
|
1052
1426
|
}
|
|
1053
1427
|
/**
|
|
1054
1428
|
* Update canvas dimensions if needed
|
|
1055
1429
|
*
|
|
1056
1430
|
* This canvas is the orientation-aware
|
|
1057
1431
|
*/
|
|
1058
|
-
#
|
|
1059
|
-
if (this.#
|
|
1060
|
-
this.#
|
|
1061
|
-
|
|
1062
|
-
this.#
|
|
1432
|
+
#updateCanvasSize(width, height) {
|
|
1433
|
+
if (this.#cachedWidth !== width || this.#cachedHeight !== height) {
|
|
1434
|
+
this.#canvas.width = width;
|
|
1435
|
+
this.#canvas.height = height;
|
|
1436
|
+
this.#cachedWidth = width;
|
|
1437
|
+
this.#cachedHeight = height;
|
|
1438
|
+
const requiredSize = width * height * 4;
|
|
1439
|
+
this.#buffer = new Uint8ClampedArray(requiredSize);
|
|
1063
1440
|
}
|
|
1064
1441
|
}
|
|
1065
1442
|
/**
|
|
1066
1443
|
* Clean up resources
|
|
1067
1444
|
*/
|
|
1068
1445
|
dispose() {
|
|
1069
|
-
|
|
1446
|
+
if (this.#contextWebGl2) {
|
|
1447
|
+
if (this.#webGl2Texture) {
|
|
1448
|
+
this.#contextWebGl2.deleteTexture(this.#webGl2Texture);
|
|
1449
|
+
this.#webGl2Texture = null;
|
|
1450
|
+
}
|
|
1451
|
+
if (this.#webGl2Framebuffer) {
|
|
1452
|
+
this.#contextWebGl2.deleteFramebuffer(this.#webGl2Framebuffer);
|
|
1453
|
+
this.#webGl2Framebuffer = null;
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
this.#context2d = null;
|
|
1457
|
+
this.#contextWebGl2 = null;
|
|
1458
|
+
this.#buffer = null;
|
|
1070
1459
|
}
|
|
1071
1460
|
}
|
|
1072
|
-
const
|
|
1073
|
-
|
|
1461
|
+
const getBuffer = (buffer) => {
|
|
1462
|
+
if (ArrayBuffer.isView(buffer)) {
|
|
1463
|
+
return buffer.buffer;
|
|
1464
|
+
} else {
|
|
1465
|
+
return buffer;
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
const defaultCameraManagerOptions = {
|
|
1469
|
+
mirrorFrontCameras: true
|
|
1074
1470
|
};
|
|
1075
|
-
class
|
|
1076
|
-
#
|
|
1077
|
-
#
|
|
1078
|
-
#
|
|
1079
|
-
#
|
|
1080
|
-
#
|
|
1081
|
-
#
|
|
1082
|
-
#
|
|
1471
|
+
class CameraManager {
|
|
1472
|
+
#resumeRequest;
|
|
1473
|
+
#resolution = "4k";
|
|
1474
|
+
#extractionArea;
|
|
1475
|
+
#videoFrameRequestId;
|
|
1476
|
+
#videoFrameProcessor;
|
|
1477
|
+
#mirrorFrontCameras;
|
|
1478
|
+
#eventListenerCleanup;
|
|
1083
1479
|
/**
|
|
1084
1480
|
* If true, the user has initiated an abort. This will prevent the
|
|
1085
1481
|
* CameraManager from throwing errors when the user interrupts the process.
|
|
1086
1482
|
*/
|
|
1087
|
-
#
|
|
1483
|
+
#userInitiatedAbort = false;
|
|
1088
1484
|
get userInitiatedAbort() {
|
|
1089
|
-
return this.#
|
|
1485
|
+
return this.#userInitiatedAbort;
|
|
1090
1486
|
}
|
|
1091
|
-
set userInitiatedAbort(
|
|
1092
|
-
this.#
|
|
1487
|
+
set userInitiatedAbort(value) {
|
|
1488
|
+
this.#userInitiatedAbort = value;
|
|
1093
1489
|
}
|
|
1094
1490
|
/**
|
|
1095
1491
|
* Sets the area of the video frame that will be extracted.
|
|
1096
1492
|
* @param extractionArea The area of the video frame that will be extracted.
|
|
1097
1493
|
*/
|
|
1098
|
-
setExtractionArea(
|
|
1099
|
-
this.#
|
|
1494
|
+
setExtractionArea(extractionArea) {
|
|
1495
|
+
this.#extractionArea = extractionArea;
|
|
1100
1496
|
}
|
|
1101
1497
|
/**
|
|
1102
1498
|
* Callbacks that will be triggered on each frame when the playback state is
|
|
1103
1499
|
* "capturing".
|
|
1104
1500
|
*/
|
|
1105
|
-
#
|
|
1106
|
-
constructor(
|
|
1107
|
-
const { mirrorFrontCameras
|
|
1108
|
-
|
|
1109
|
-
...
|
|
1501
|
+
#frameCaptureCallbacks = /* @__PURE__ */ new Set();
|
|
1502
|
+
constructor(options = {}, videoFrameProcessorOptions) {
|
|
1503
|
+
const { mirrorFrontCameras } = {
|
|
1504
|
+
...defaultCameraManagerOptions,
|
|
1505
|
+
...options
|
|
1110
1506
|
};
|
|
1111
|
-
this.#
|
|
1112
|
-
|
|
1113
|
-
)
|
|
1507
|
+
this.#videoFrameProcessor = new VideoFrameProcessor(
|
|
1508
|
+
videoFrameProcessorOptions
|
|
1509
|
+
);
|
|
1510
|
+
this.#mirrorFrontCameras = mirrorFrontCameras;
|
|
1114
1511
|
}
|
|
1115
1512
|
/**
|
|
1116
1513
|
* Sets the resolution of the camera stream
|
|
1117
1514
|
*/
|
|
1118
|
-
setResolution = async (
|
|
1119
|
-
this.#
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1515
|
+
setResolution = async (resolution) => {
|
|
1516
|
+
this.#resolution = resolution;
|
|
1517
|
+
const playbackState = this.getState().playbackState;
|
|
1518
|
+
if (playbackState !== "idle") {
|
|
1519
|
+
this.#resumeRequest = playbackState;
|
|
1520
|
+
this.stopStream();
|
|
1521
|
+
await this.startCameraStream();
|
|
1522
|
+
}
|
|
1122
1523
|
};
|
|
1123
1524
|
get resolution() {
|
|
1124
|
-
return this.#
|
|
1525
|
+
return this.#resolution;
|
|
1125
1526
|
}
|
|
1126
1527
|
/**
|
|
1127
1528
|
* True if there is a video playing or capturing
|
|
1128
1529
|
* TODO: see if we can simplify this, by observing the video playback state
|
|
1129
1530
|
*/
|
|
1130
1531
|
get isActive() {
|
|
1131
|
-
return
|
|
1532
|
+
return cameraManagerStore.getState().playbackState !== "idle";
|
|
1132
1533
|
}
|
|
1133
|
-
setFacingFilter(
|
|
1134
|
-
|
|
1135
|
-
facingFilter
|
|
1534
|
+
setFacingFilter(facingFilter) {
|
|
1535
|
+
cameraManagerStore.setState({
|
|
1536
|
+
facingFilter
|
|
1136
1537
|
});
|
|
1137
1538
|
}
|
|
1138
1539
|
/**
|
|
@@ -1140,28 +1541,37 @@ class Qr {
|
|
|
1140
1541
|
* If no facing mode is set, all cameras are returned.
|
|
1141
1542
|
*/
|
|
1142
1543
|
async getCameraDevices() {
|
|
1143
|
-
let
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1544
|
+
let allCameras = cameraManagerStore.getState().cameras;
|
|
1545
|
+
const facingFilter = cameraManagerStore.getState().facingFilter;
|
|
1546
|
+
if (!allCameras.length) {
|
|
1547
|
+
await this.refreshCameraDevices();
|
|
1548
|
+
}
|
|
1549
|
+
allCameras = cameraManagerStore.getState().cameras;
|
|
1550
|
+
if (!facingFilter) {
|
|
1551
|
+
return allCameras;
|
|
1552
|
+
}
|
|
1553
|
+
const filteredCameras = allCameras.filter(
|
|
1554
|
+
(camera) => facingFilter.includes(camera.facingMode)
|
|
1555
|
+
);
|
|
1556
|
+
return filteredCameras;
|
|
1148
1557
|
}
|
|
1149
1558
|
/**
|
|
1150
1559
|
* Single-time setup for a video element
|
|
1151
1560
|
*/
|
|
1152
|
-
#
|
|
1153
|
-
if (!(
|
|
1561
|
+
#initVideoElement(videoElement) {
|
|
1562
|
+
if (!(videoElement instanceof HTMLVideoElement)) {
|
|
1154
1563
|
throw new Error(
|
|
1155
|
-
`Expected an HTMLVideoElement, got ${typeof
|
|
1564
|
+
`Expected an HTMLVideoElement, got ${typeof videoElement}`,
|
|
1156
1565
|
{
|
|
1157
|
-
cause:
|
|
1566
|
+
cause: videoElement
|
|
1158
1567
|
}
|
|
1159
1568
|
);
|
|
1160
|
-
|
|
1161
|
-
|
|
1569
|
+
}
|
|
1570
|
+
cameraManagerStore.setState({
|
|
1571
|
+
videoElement
|
|
1162
1572
|
});
|
|
1163
|
-
const
|
|
1164
|
-
[
|
|
1573
|
+
const videoEventCleanup = rad(videoElement, (add) => {
|
|
1574
|
+
const events = [
|
|
1165
1575
|
"abort"
|
|
1166
1576
|
// "error",
|
|
1167
1577
|
// "canplay",
|
|
@@ -1180,49 +1590,62 @@ class Qr {
|
|
|
1180
1590
|
// "timeupdate",
|
|
1181
1591
|
// "ratechange",
|
|
1182
1592
|
// "durationchange",
|
|
1183
|
-
]
|
|
1184
|
-
|
|
1185
|
-
|
|
1593
|
+
];
|
|
1594
|
+
events.forEach((event) => {
|
|
1595
|
+
add(event, () => {
|
|
1596
|
+
console.debug(`Video event: ${event}`);
|
|
1186
1597
|
});
|
|
1187
1598
|
});
|
|
1188
1599
|
});
|
|
1189
|
-
new
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1600
|
+
const connectionObserver = new ConnectionObserver((entries) => {
|
|
1601
|
+
if (!entries[0].connected) {
|
|
1602
|
+
this.releaseVideoElement();
|
|
1603
|
+
}
|
|
1604
|
+
});
|
|
1605
|
+
connectionObserver.observe(videoElement);
|
|
1606
|
+
videoElement.setAttribute("playsInline", "");
|
|
1607
|
+
videoElement.setAttribute("muted", "");
|
|
1608
|
+
videoElement.controls = false;
|
|
1609
|
+
let previousPlaybackState = "idle";
|
|
1610
|
+
const cleanupVisibilityListener = radEventListener(
|
|
1194
1611
|
document,
|
|
1195
1612
|
"visibilitychange",
|
|
1196
1613
|
async () => {
|
|
1197
|
-
|
|
1198
|
-
|
|
1614
|
+
const isHidden = document.hidden;
|
|
1615
|
+
if (isHidden) {
|
|
1616
|
+
previousPlaybackState = cameraManagerStore.getState().playbackState;
|
|
1617
|
+
this.stopStream();
|
|
1199
1618
|
return;
|
|
1200
1619
|
}
|
|
1201
|
-
switch (
|
|
1620
|
+
switch (previousPlaybackState) {
|
|
1202
1621
|
case "playback":
|
|
1203
|
-
await this.startCameraStream()
|
|
1622
|
+
await this.startCameraStream();
|
|
1623
|
+
await this.startPlayback();
|
|
1204
1624
|
break;
|
|
1205
1625
|
case "capturing":
|
|
1206
|
-
await this.startCameraStream()
|
|
1626
|
+
await this.startCameraStream();
|
|
1627
|
+
await this.startFrameCapture();
|
|
1207
1628
|
break;
|
|
1208
1629
|
}
|
|
1209
1630
|
}
|
|
1210
1631
|
);
|
|
1211
|
-
this.#
|
|
1212
|
-
|
|
1632
|
+
this.#eventListenerCleanup = () => {
|
|
1633
|
+
cleanupVisibilityListener();
|
|
1634
|
+
videoEventCleanup();
|
|
1213
1635
|
};
|
|
1214
1636
|
}
|
|
1215
1637
|
/**
|
|
1216
1638
|
* Initializes the CameraManager with a video element.
|
|
1217
1639
|
*/
|
|
1218
|
-
initVideoElement(
|
|
1640
|
+
initVideoElement(videoElement) {
|
|
1219
1641
|
try {
|
|
1220
|
-
this.#
|
|
1221
|
-
} catch (
|
|
1222
|
-
if (this.userInitiatedAbort)
|
|
1642
|
+
this.#initVideoElement(videoElement);
|
|
1643
|
+
} catch (error) {
|
|
1644
|
+
if (this.userInitiatedAbort) {
|
|
1223
1645
|
this.reset();
|
|
1224
|
-
else
|
|
1225
|
-
throw
|
|
1646
|
+
} else {
|
|
1647
|
+
throw error;
|
|
1648
|
+
}
|
|
1226
1649
|
}
|
|
1227
1650
|
}
|
|
1228
1651
|
/**
|
|
@@ -1232,74 +1655,108 @@ class Qr {
|
|
|
1232
1655
|
* @param frameCaptureCallback
|
|
1233
1656
|
* @returns a cleanup function to remove the callback
|
|
1234
1657
|
*/
|
|
1235
|
-
addFrameCaptureCallback(
|
|
1236
|
-
|
|
1658
|
+
addFrameCaptureCallback(frameCaptureCallback) {
|
|
1659
|
+
this.#frameCaptureCallbacks.add(frameCaptureCallback);
|
|
1660
|
+
return () => this.#frameCaptureCallbacks.delete(frameCaptureCallback);
|
|
1237
1661
|
}
|
|
1238
1662
|
releaseVideoElement() {
|
|
1239
|
-
this.#
|
|
1663
|
+
this.#eventListenerCleanup?.();
|
|
1664
|
+
cameraManagerStore.setState({
|
|
1240
1665
|
videoElement: void 0
|
|
1241
|
-
})
|
|
1666
|
+
});
|
|
1667
|
+
this.stopStream();
|
|
1242
1668
|
}
|
|
1243
1669
|
/**
|
|
1244
1670
|
* Select a camera device from available ones.
|
|
1245
1671
|
*
|
|
1246
1672
|
* TODO: might become a private method in the future as an implementation detail of `startStream`
|
|
1247
1673
|
*/
|
|
1248
|
-
async selectCamera(
|
|
1249
|
-
const
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1674
|
+
async selectCamera(camera) {
|
|
1675
|
+
const playbackState = cameraManagerStore.getState().playbackState;
|
|
1676
|
+
if (playbackState !== "idle") {
|
|
1677
|
+
this.#resumeRequest = playbackState;
|
|
1678
|
+
}
|
|
1679
|
+
const state = cameraManagerStore.getState();
|
|
1680
|
+
if (state.selectedCamera === camera) {
|
|
1253
1681
|
console.debug("Already selected");
|
|
1254
1682
|
return;
|
|
1255
1683
|
}
|
|
1256
|
-
if (
|
|
1684
|
+
if (state.isSwappingCamera) {
|
|
1257
1685
|
console.debug("Already swapping");
|
|
1258
1686
|
return;
|
|
1259
1687
|
}
|
|
1260
|
-
|
|
1261
|
-
isSwappingCamera:
|
|
1262
|
-
})
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1688
|
+
cameraManagerStore.setState({
|
|
1689
|
+
isSwappingCamera: true
|
|
1690
|
+
});
|
|
1691
|
+
if (state.selectedCamera?.activeStream) {
|
|
1692
|
+
console.debug("Stopping previous stream");
|
|
1693
|
+
state.selectedCamera.stopStream();
|
|
1694
|
+
}
|
|
1695
|
+
if (state.videoElement) {
|
|
1696
|
+
state.videoElement.srcObject = null;
|
|
1697
|
+
}
|
|
1698
|
+
cameraManagerStore.setState({
|
|
1699
|
+
selectedCamera: camera,
|
|
1700
|
+
isSwappingCamera: false
|
|
1701
|
+
});
|
|
1702
|
+
if (this.#resumeRequest === "playback") {
|
|
1703
|
+
console.debug("Starting new stream");
|
|
1704
|
+
await this.startPlayback();
|
|
1705
|
+
}
|
|
1706
|
+
if (this.#resumeRequest === "capturing") {
|
|
1707
|
+
console.debug("Resuming frame capture");
|
|
1708
|
+
await this.startFrameCapture();
|
|
1709
|
+
}
|
|
1710
|
+
this.#resumeRequest = void 0;
|
|
1266
1711
|
}
|
|
1267
1712
|
/**
|
|
1268
1713
|
* Refreshes available devices on the system and updates the state.
|
|
1269
1714
|
*/
|
|
1270
1715
|
async refreshCameraDevices() {
|
|
1271
|
-
if (
|
|
1716
|
+
if (cameraManagerStore.getState().isQueryingCameras || cameraManagerStore.getState().isSwappingCamera) {
|
|
1272
1717
|
console.debug("Already querying cameras");
|
|
1273
1718
|
return;
|
|
1274
1719
|
}
|
|
1275
|
-
|
|
1276
|
-
isQueryingCameras:
|
|
1720
|
+
cameraManagerStore.setState({
|
|
1721
|
+
isQueryingCameras: true
|
|
1277
1722
|
});
|
|
1278
|
-
const
|
|
1279
|
-
|
|
1280
|
-
errorState:
|
|
1281
|
-
isQueryingCameras:
|
|
1282
|
-
})
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1723
|
+
const availableCameras = await obtainVideoInputDevices().catch((err) => {
|
|
1724
|
+
cameraManagerStore.setState({
|
|
1725
|
+
errorState: asError(err),
|
|
1726
|
+
isQueryingCameras: false
|
|
1727
|
+
});
|
|
1728
|
+
throw err;
|
|
1729
|
+
});
|
|
1730
|
+
const cameras = createCameras(availableCameras);
|
|
1731
|
+
cameras.forEach((camera) => {
|
|
1732
|
+
if (camera.notifyStateChange) {
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
camera.notifyStateChange = (camInstance, reason) => {
|
|
1286
1736
|
window.queueMicrotask(() => {
|
|
1287
|
-
|
|
1288
|
-
cameras: [...
|
|
1737
|
+
cameraManagerStore.setState({
|
|
1738
|
+
cameras: [...cameraManagerStore.getState().cameras]
|
|
1289
1739
|
});
|
|
1290
|
-
const
|
|
1291
|
-
if (!
|
|
1740
|
+
const selectedCamera = cameraManagerStore.getState().selectedCamera;
|
|
1741
|
+
if (!selectedCamera) {
|
|
1292
1742
|
return;
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
}
|
|
1743
|
+
}
|
|
1744
|
+
let streamError;
|
|
1745
|
+
if (typeof reason === "object" && reason !== null && "payload" in reason && reason.payload === "TRACK_END") {
|
|
1746
|
+
streamError = new Error("Camera stream ended unexpectedly");
|
|
1747
|
+
}
|
|
1748
|
+
if (camInstance === selectedCamera) {
|
|
1749
|
+
cameraManagerStore.setState({
|
|
1750
|
+
selectedCamera,
|
|
1751
|
+
errorState: streamError
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1298
1754
|
});
|
|
1299
|
-
}
|
|
1300
|
-
})
|
|
1301
|
-
|
|
1302
|
-
|
|
1755
|
+
};
|
|
1756
|
+
});
|
|
1757
|
+
cameraManagerStore.setState({
|
|
1758
|
+
cameras,
|
|
1759
|
+
isQueryingCameras: false
|
|
1303
1760
|
});
|
|
1304
1761
|
}
|
|
1305
1762
|
/**
|
|
@@ -1308,140 +1765,181 @@ class Qr {
|
|
|
1308
1765
|
* @returns resolves when playback starts
|
|
1309
1766
|
*/
|
|
1310
1767
|
async startPlayback() {
|
|
1311
|
-
const
|
|
1312
|
-
if (
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1768
|
+
const state = cameraManagerStore.getState();
|
|
1769
|
+
if (this.isActive && !this.#resumeRequest) {
|
|
1770
|
+
return;
|
|
1771
|
+
}
|
|
1772
|
+
if (!state.videoElement) {
|
|
1773
|
+
console.warn("Starting playback - no video element present.");
|
|
1774
|
+
return;
|
|
1775
|
+
}
|
|
1776
|
+
if (!state.selectedCamera) {
|
|
1777
|
+
console.warn("Select a camera first.");
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
if (!state.selectedCamera.activeStream) {
|
|
1781
|
+
const stream = await state.selectedCamera.startStream(this.resolution);
|
|
1782
|
+
state.videoElement.srcObject = stream;
|
|
1783
|
+
}
|
|
1784
|
+
try {
|
|
1785
|
+
this.#applyMirrorIfNeeded();
|
|
1786
|
+
await state.videoElement.play();
|
|
1787
|
+
cameraManagerStore.setState({
|
|
1788
|
+
playbackState: "playback"
|
|
1789
|
+
});
|
|
1790
|
+
} catch (error) {
|
|
1791
|
+
console.error("Failed to start playback", error);
|
|
1792
|
+
cameraManagerStore.setState({
|
|
1793
|
+
errorState: asError(error)
|
|
1794
|
+
});
|
|
1795
|
+
throw error;
|
|
1334
1796
|
}
|
|
1335
1797
|
}
|
|
1336
1798
|
/**
|
|
1337
1799
|
* Starts playback and frame capturing.
|
|
1338
1800
|
*/
|
|
1339
|
-
async #
|
|
1340
|
-
const
|
|
1341
|
-
if (
|
|
1342
|
-
|
|
1343
|
-
console.warn(
|
|
1344
|
-
"Missing video element. Setup a video element first using `initVideoElement`"
|
|
1345
|
-
);
|
|
1346
|
-
return;
|
|
1347
|
-
}
|
|
1348
|
-
if (!e.selectedCamera) {
|
|
1349
|
-
console.warn(
|
|
1350
|
-
"No active camera! Select a camera first, or use `startCameraStream`"
|
|
1351
|
-
);
|
|
1352
|
-
return;
|
|
1353
|
-
}
|
|
1354
|
-
await this.startPlayback(), d.setState({
|
|
1355
|
-
playbackState: "capturing"
|
|
1356
|
-
}), this.#c(), this.#e = void 0;
|
|
1801
|
+
async #startFrameCapture() {
|
|
1802
|
+
const state = cameraManagerStore.getState();
|
|
1803
|
+
if (this.userInitiatedAbort) {
|
|
1804
|
+
return;
|
|
1357
1805
|
}
|
|
1806
|
+
if (state.playbackState === "capturing" && this.#resumeRequest !== "capturing") {
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
if (!state.videoElement) {
|
|
1810
|
+
console.warn(
|
|
1811
|
+
"Missing video element. Setup a video element first using `initVideoElement`"
|
|
1812
|
+
);
|
|
1813
|
+
return;
|
|
1814
|
+
}
|
|
1815
|
+
if (!state.selectedCamera) {
|
|
1816
|
+
console.warn(
|
|
1817
|
+
"No active camera! Select a camera first, or use `startCameraStream`"
|
|
1818
|
+
);
|
|
1819
|
+
return;
|
|
1820
|
+
}
|
|
1821
|
+
await this.startPlayback();
|
|
1822
|
+
cameraManagerStore.setState({
|
|
1823
|
+
playbackState: "capturing"
|
|
1824
|
+
});
|
|
1825
|
+
this.#queueFrame();
|
|
1826
|
+
this.#resumeRequest = void 0;
|
|
1358
1827
|
}
|
|
1359
1828
|
/**
|
|
1360
1829
|
* Starts capturing frames from the video element.
|
|
1361
1830
|
*/
|
|
1362
1831
|
startFrameCapture = async () => {
|
|
1363
1832
|
try {
|
|
1364
|
-
await this.#
|
|
1365
|
-
} catch (
|
|
1366
|
-
if (this.userInitiatedAbort)
|
|
1833
|
+
await this.#startFrameCapture();
|
|
1834
|
+
} catch (error) {
|
|
1835
|
+
if (this.userInitiatedAbort) {
|
|
1367
1836
|
this.reset();
|
|
1368
|
-
else
|
|
1369
|
-
throw
|
|
1837
|
+
} else {
|
|
1838
|
+
throw error;
|
|
1839
|
+
}
|
|
1370
1840
|
}
|
|
1371
1841
|
};
|
|
1372
|
-
async #
|
|
1373
|
-
autoplay
|
|
1374
|
-
preferredCamera
|
|
1375
|
-
preferredFacing
|
|
1842
|
+
async #startCameraStream({
|
|
1843
|
+
autoplay = true,
|
|
1844
|
+
preferredCamera,
|
|
1845
|
+
preferredFacing
|
|
1376
1846
|
} = {}) {
|
|
1377
|
-
const
|
|
1378
|
-
if (!
|
|
1847
|
+
const videoElement = cameraManagerStore.getState().videoElement;
|
|
1848
|
+
if (!videoElement) {
|
|
1379
1849
|
console.warn("Can't start stream without a video element");
|
|
1380
1850
|
return;
|
|
1381
1851
|
}
|
|
1382
|
-
if (this.isActive && !this.#
|
|
1852
|
+
if (this.isActive && !this.#resumeRequest) {
|
|
1383
1853
|
console.warn("Already streaming");
|
|
1384
1854
|
return;
|
|
1385
1855
|
}
|
|
1386
|
-
if (
|
|
1856
|
+
if (preferredCamera instanceof Camera) {
|
|
1857
|
+
await this.selectCamera(preferredCamera);
|
|
1858
|
+
}
|
|
1859
|
+
if (!cameraManagerStore.getState().selectedCamera) {
|
|
1387
1860
|
try {
|
|
1388
|
-
const
|
|
1389
|
-
let
|
|
1390
|
-
if (!
|
|
1391
|
-
|
|
1392
|
-
|
|
1861
|
+
const cameras = await this.getCameraDevices();
|
|
1862
|
+
let selectedCamera2;
|
|
1863
|
+
if (!cameras.length) {
|
|
1864
|
+
console.log("Camera list is empty");
|
|
1865
|
+
throw new Error(
|
|
1866
|
+
`No cameras found matching the filter ${preferredFacing}`
|
|
1393
1867
|
);
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1868
|
+
}
|
|
1869
|
+
if (typeof preferredCamera === "function") {
|
|
1870
|
+
selectedCamera2 = preferredCamera(cameras);
|
|
1871
|
+
if (!selectedCamera2) {
|
|
1872
|
+
console.warn(
|
|
1873
|
+
`No camera found matching the preferred camera function, falling back to facing mode`
|
|
1874
|
+
);
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
if (!selectedCamera2) {
|
|
1878
|
+
selectedCamera2 = await findIdealCamera(
|
|
1879
|
+
cameras,
|
|
1880
|
+
this.resolution,
|
|
1881
|
+
preferredFacing
|
|
1882
|
+
);
|
|
1883
|
+
}
|
|
1884
|
+
if (!selectedCamera2) {
|
|
1401
1885
|
throw new Error(
|
|
1402
|
-
`No cameras found matching the filter ${
|
|
1886
|
+
`No cameras found matching the filter ${preferredFacing}`
|
|
1403
1887
|
);
|
|
1404
|
-
|
|
1405
|
-
|
|
1888
|
+
}
|
|
1889
|
+
await this.selectCamera(selectedCamera2);
|
|
1890
|
+
if (this.#hasPermissionError()) {
|
|
1891
|
+
cameraManagerStore.setState({
|
|
1892
|
+
errorState: void 0
|
|
1893
|
+
});
|
|
1894
|
+
}
|
|
1895
|
+
} catch (error) {
|
|
1896
|
+
cameraManagerStore.setState({
|
|
1897
|
+
errorState: asError(error)
|
|
1406
1898
|
});
|
|
1407
|
-
|
|
1408
|
-
throw d.setState({
|
|
1409
|
-
errorState: X(l)
|
|
1410
|
-
}), l;
|
|
1899
|
+
throw error;
|
|
1411
1900
|
}
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1901
|
+
}
|
|
1902
|
+
const selectedCamera = cameraManagerStore.getState().selectedCamera;
|
|
1903
|
+
if (!selectedCamera) {
|
|
1904
|
+
console.warn("No selected camera!");
|
|
1905
|
+
throw new Error("No selected camera");
|
|
1906
|
+
}
|
|
1907
|
+
const stream = await selectedCamera.startStream(this.#resolution);
|
|
1908
|
+
if (!videoElement.isConnected) {
|
|
1417
1909
|
throw new Error("Video element needs to be in the document!");
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1910
|
+
}
|
|
1911
|
+
videoElement.srcObject = stream;
|
|
1912
|
+
cameraManagerStore.setState({
|
|
1913
|
+
videoElement
|
|
1914
|
+
});
|
|
1915
|
+
if (autoplay) {
|
|
1916
|
+
await this.startPlayback();
|
|
1917
|
+
}
|
|
1421
1918
|
}
|
|
1422
1919
|
/**
|
|
1423
1920
|
* Starts a best-effort camera stream. Will pick a camera automatically if
|
|
1424
1921
|
* none is selected.
|
|
1425
1922
|
*/
|
|
1426
|
-
async startCameraStream(
|
|
1923
|
+
async startCameraStream(params = {}) {
|
|
1427
1924
|
try {
|
|
1428
|
-
await this.#
|
|
1429
|
-
} catch (
|
|
1430
|
-
if (this.userInitiatedAbort)
|
|
1925
|
+
await this.#startCameraStream(params);
|
|
1926
|
+
} catch (error) {
|
|
1927
|
+
if (this.userInitiatedAbort) {
|
|
1431
1928
|
this.reset();
|
|
1432
|
-
else
|
|
1433
|
-
throw
|
|
1929
|
+
} else {
|
|
1930
|
+
throw error;
|
|
1931
|
+
}
|
|
1434
1932
|
}
|
|
1435
1933
|
}
|
|
1436
|
-
#
|
|
1437
|
-
const
|
|
1438
|
-
return
|
|
1934
|
+
#hasPermissionError = () => {
|
|
1935
|
+
const errorState = cameraManagerStore.getState().errorState;
|
|
1936
|
+
return errorState instanceof CameraError && errorState.code === "PERMISSION_DENIED";
|
|
1439
1937
|
};
|
|
1440
1938
|
/**
|
|
1441
1939
|
* Pauses capturing frames without pausing playback.
|
|
1442
1940
|
*/
|
|
1443
1941
|
stopFrameCapture() {
|
|
1444
|
-
|
|
1942
|
+
cameraManagerStore.setState({
|
|
1445
1943
|
playbackState: "playback"
|
|
1446
1944
|
});
|
|
1447
1945
|
}
|
|
@@ -1450,92 +1948,128 @@ class Qr {
|
|
|
1450
1948
|
*/
|
|
1451
1949
|
stopStream() {
|
|
1452
1950
|
console.debug("stopStream called");
|
|
1453
|
-
const
|
|
1454
|
-
this.pausePlayback()
|
|
1951
|
+
const state = cameraManagerStore.getState();
|
|
1952
|
+
this.pausePlayback();
|
|
1953
|
+
state.selectedCamera?.stopStream();
|
|
1954
|
+
if (state.videoElement) {
|
|
1955
|
+
state.videoElement.srcObject = null;
|
|
1956
|
+
}
|
|
1455
1957
|
}
|
|
1456
1958
|
/**
|
|
1457
1959
|
* Pauses the video playback. This will also stop the capturing process.
|
|
1458
1960
|
*/
|
|
1459
1961
|
pausePlayback() {
|
|
1460
1962
|
console.debug("pausePlayback called");
|
|
1461
|
-
const
|
|
1462
|
-
|
|
1963
|
+
const video = cameraManagerStore.getState().videoElement;
|
|
1964
|
+
cameraManagerStore.setState({
|
|
1463
1965
|
playbackState: "idle"
|
|
1464
|
-
})
|
|
1966
|
+
});
|
|
1967
|
+
if (!video) {
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
if (this.#videoFrameRequestId) {
|
|
1971
|
+
video.cancelVideoFrameCallback(this.#videoFrameRequestId);
|
|
1972
|
+
}
|
|
1973
|
+
video.pause();
|
|
1465
1974
|
}
|
|
1466
1975
|
/**
|
|
1467
1976
|
* The main recognition loop. Do not call this method directly, use #queueFrame instead.
|
|
1468
1977
|
*/
|
|
1469
|
-
async #
|
|
1470
|
-
const
|
|
1471
|
-
if (this.#
|
|
1978
|
+
async #loop() {
|
|
1979
|
+
const state = cameraManagerStore.getState();
|
|
1980
|
+
if (this.#videoFrameRequestId === void 0) {
|
|
1472
1981
|
console.error("Missing request ID");
|
|
1473
1982
|
return;
|
|
1474
1983
|
}
|
|
1475
|
-
if (!
|
|
1984
|
+
if (!state.videoElement) {
|
|
1476
1985
|
console.warn("Missing video element, should not happen");
|
|
1477
1986
|
return;
|
|
1478
1987
|
}
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1988
|
+
const isSameOrientation = state.videoElement.videoHeight >= state.videoElement.videoWidth === this.#extractionArea.height >= this.#extractionArea.width;
|
|
1989
|
+
if (!isSameOrientation) {
|
|
1990
|
+
return this.#queueFrame();
|
|
1991
|
+
}
|
|
1992
|
+
if (this.#frameCaptureCallbacks.size !== 0) {
|
|
1993
|
+
const capturedFrame = this.#videoFrameProcessor.getImageData(
|
|
1994
|
+
state.videoElement,
|
|
1995
|
+
this.#extractionArea
|
|
1485
1996
|
);
|
|
1486
|
-
for (const
|
|
1487
|
-
const
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1997
|
+
for (const callback of this.#frameCaptureCallbacks) {
|
|
1998
|
+
const workingFrame = isBufferDetached(capturedFrame.data) ? this.#videoFrameProcessor.getCurrentImageData() : capturedFrame;
|
|
1999
|
+
const returnedBuffer = await callback(workingFrame);
|
|
2000
|
+
if (!returnedBuffer) {
|
|
2001
|
+
continue;
|
|
2002
|
+
}
|
|
2003
|
+
if (!(returnedBuffer instanceof ArrayBuffer)) {
|
|
2004
|
+
throw new Error(
|
|
2005
|
+
stripIndents`
|
|
1492
2006
|
Frame capture callback did not return an ArrayBuffer.
|
|
1493
2007
|
Make sure to return the underlying buffer, not the view.
|
|
1494
2008
|
`
|
|
1495
|
-
|
|
1496
|
-
this.#n.reattachArrayBuffer(i);
|
|
2009
|
+
);
|
|
1497
2010
|
}
|
|
2011
|
+
this.#videoFrameProcessor.reattachArrayBuffer(returnedBuffer);
|
|
1498
2012
|
}
|
|
1499
2013
|
}
|
|
1500
|
-
this.#
|
|
2014
|
+
this.#queueFrame();
|
|
1501
2015
|
}
|
|
1502
2016
|
/**
|
|
1503
2017
|
* Queues the next frame to be processed
|
|
1504
2018
|
*/
|
|
1505
|
-
#
|
|
1506
|
-
const
|
|
1507
|
-
if (
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
() => void this.#g()
|
|
1514
|
-
);
|
|
2019
|
+
#queueFrame() {
|
|
2020
|
+
const state = cameraManagerStore.getState();
|
|
2021
|
+
if (state.playbackState !== "capturing") {
|
|
2022
|
+
return;
|
|
2023
|
+
}
|
|
2024
|
+
if (!state.videoElement) {
|
|
2025
|
+
console.warn("Missing video element, should not happen");
|
|
2026
|
+
return;
|
|
1515
2027
|
}
|
|
2028
|
+
if (this.#videoFrameRequestId) {
|
|
2029
|
+
state.videoElement.cancelVideoFrameCallback(this.#videoFrameRequestId);
|
|
2030
|
+
}
|
|
2031
|
+
this.#videoFrameRequestId = state.videoElement.requestVideoFrameCallback(
|
|
2032
|
+
() => void this.#loop()
|
|
2033
|
+
);
|
|
1516
2034
|
}
|
|
1517
2035
|
/**
|
|
1518
2036
|
* Applies a mirror effect to the video if the camera is front-facing.
|
|
1519
2037
|
* Assumes that desktop devices don't return a facing mode and that they are front-facing.
|
|
1520
2038
|
*/
|
|
1521
|
-
#
|
|
1522
|
-
const
|
|
1523
|
-
if (!
|
|
2039
|
+
#applyMirrorIfNeeded() {
|
|
2040
|
+
const camera = cameraManagerStore.getState().selectedCamera;
|
|
2041
|
+
if (!camera) {
|
|
1524
2042
|
console.warn("No camera selected");
|
|
1525
2043
|
return;
|
|
1526
2044
|
}
|
|
1527
|
-
|
|
2045
|
+
if (!this.#mirrorFrontCameras) {
|
|
2046
|
+
return;
|
|
2047
|
+
}
|
|
2048
|
+
if (camera.facingMode !== "back") {
|
|
2049
|
+
this.setCameraMirrorX(true);
|
|
2050
|
+
} else {
|
|
2051
|
+
this.setCameraMirrorX(false);
|
|
2052
|
+
}
|
|
1528
2053
|
}
|
|
1529
2054
|
/**
|
|
1530
2055
|
* If true, the video and captured frames will be mirrored horizontally.
|
|
1531
2056
|
*/
|
|
1532
|
-
setCameraMirrorX(
|
|
1533
|
-
const
|
|
1534
|
-
|
|
2057
|
+
setCameraMirrorX(mirrorX) {
|
|
2058
|
+
const currentState = cameraManagerStore.getState();
|
|
2059
|
+
const videoElement = currentState.videoElement;
|
|
2060
|
+
if (!videoElement) {
|
|
1535
2061
|
console.warn("Mirror video - no video element present.");
|
|
1536
2062
|
return;
|
|
1537
2063
|
}
|
|
1538
|
-
|
|
2064
|
+
if (currentState.mirrorX === mirrorX) {
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
if (mirrorX) {
|
|
2068
|
+
videoElement.style.scale = "-1 1";
|
|
2069
|
+
} else {
|
|
2070
|
+
videoElement.style.removeProperty("scale");
|
|
2071
|
+
}
|
|
2072
|
+
cameraManagerStore.setState({ mirrorX });
|
|
1539
2073
|
}
|
|
1540
2074
|
// The "typeof" is necessary to avoid a circular dependency when resolving types
|
|
1541
2075
|
/**
|
|
@@ -1543,54 +2077,64 @@ class Qr {
|
|
|
1543
2077
|
* Implemented using Zustand. For usage information, see
|
|
1544
2078
|
* {@link https://github.com/pmndrs/zustand#using-subscribe-with-selector}
|
|
1545
2079
|
*/
|
|
1546
|
-
subscribe =
|
|
2080
|
+
subscribe = cameraManagerStore.subscribe;
|
|
1547
2081
|
/**
|
|
1548
2082
|
* Gets the current internal state of the CameraManager.
|
|
1549
2083
|
*/
|
|
1550
|
-
getState =
|
|
2084
|
+
getState = cameraManagerStore.getState;
|
|
1551
2085
|
/**
|
|
1552
2086
|
* Resets the CameraManager and stop all streams
|
|
1553
2087
|
*/
|
|
1554
2088
|
reset() {
|
|
1555
|
-
console.debug("Resetting camera manager")
|
|
2089
|
+
console.debug("Resetting camera manager");
|
|
2090
|
+
this.#frameCaptureCallbacks.clear();
|
|
2091
|
+
this.stopStream();
|
|
2092
|
+
resetCameraManagerStore();
|
|
1556
2093
|
}
|
|
1557
2094
|
}
|
|
1558
|
-
const
|
|
1559
|
-
function
|
|
1560
|
-
return
|
|
2095
|
+
const CameraUiStoreContext = createContext();
|
|
2096
|
+
function createCameraManagerSolidStore() {
|
|
2097
|
+
return createWithSignal(cameraManagerStore);
|
|
1561
2098
|
}
|
|
1562
|
-
const
|
|
1563
|
-
const
|
|
1564
|
-
cameraManagerSolidStore:
|
|
2099
|
+
const CameraUiStoreProvider = (props) => {
|
|
2100
|
+
const contextValue = {
|
|
2101
|
+
cameraManagerSolidStore: createCameraManagerSolidStore(),
|
|
1565
2102
|
// eslint-disable-next-line solid/reactivity
|
|
1566
|
-
cameraManager:
|
|
2103
|
+
cameraManager: props.cameraManager,
|
|
1567
2104
|
// eslint-disable-next-line solid/reactivity
|
|
1568
2105
|
dismountCameraUi: () => {
|
|
1569
|
-
|
|
2106
|
+
props.cameraManager.userInitiatedAbort = true;
|
|
2107
|
+
props.dismountCameraUi();
|
|
1570
2108
|
},
|
|
1571
2109
|
// eslint-disable-next-line solid/reactivity
|
|
1572
|
-
addOnDismountCallback:
|
|
2110
|
+
addOnDismountCallback: props.addOnDismountCallback,
|
|
2111
|
+
// eslint-disable-next-line solid/reactivity
|
|
2112
|
+
mountTarget: props.mountTarget,
|
|
1573
2113
|
// eslint-disable-next-line solid/reactivity
|
|
1574
|
-
|
|
2114
|
+
showMirrorCameraButton: props.showMirrorCameraButton,
|
|
1575
2115
|
// eslint-disable-next-line solid/reactivity
|
|
1576
|
-
|
|
2116
|
+
showTorchButton: props.showTorchButton,
|
|
2117
|
+
// eslint-disable-next-line solid/reactivity
|
|
2118
|
+
showCloseButton: props.showCloseButton
|
|
1577
2119
|
};
|
|
1578
|
-
|
|
2120
|
+
onCleanup(() => {
|
|
1579
2121
|
console.debug("CameraUiStoreProvider cleanup");
|
|
1580
|
-
})
|
|
1581
|
-
|
|
2122
|
+
});
|
|
2123
|
+
return createComponent(CameraUiStoreContext.Provider, {
|
|
2124
|
+
value: contextValue,
|
|
1582
2125
|
get children() {
|
|
1583
|
-
return
|
|
2126
|
+
return props.children;
|
|
1584
2127
|
}
|
|
1585
2128
|
});
|
|
1586
2129
|
};
|
|
1587
|
-
function
|
|
1588
|
-
const
|
|
1589
|
-
if (!
|
|
2130
|
+
function useCameraUiStore() {
|
|
2131
|
+
const ctx = useContext(CameraUiStoreContext);
|
|
2132
|
+
if (!ctx) {
|
|
1590
2133
|
throw new Error("StoreContext.Provider not in scope");
|
|
1591
|
-
|
|
2134
|
+
}
|
|
2135
|
+
return ctx;
|
|
1592
2136
|
}
|
|
1593
|
-
const
|
|
2137
|
+
const enLocaleStrings = {
|
|
1594
2138
|
selected_camera: "Selected camera",
|
|
1595
2139
|
loading_cameras: "Loading cameras...",
|
|
1596
2140
|
select_a_camera: "Select a camera",
|
|
@@ -1603,229 +2147,277 @@ const It = {
|
|
|
1603
2147
|
camera_error_details: "Please allow camera access in your browser and try again.",
|
|
1604
2148
|
camera_error_cancel_btn: "Cancel",
|
|
1605
2149
|
camera_error_primary_btn: "Retry"
|
|
1606
|
-
}
|
|
1607
|
-
|
|
2150
|
+
};
|
|
2151
|
+
const LocalizationContext = createContext();
|
|
2152
|
+
const LocalizationProvider = (props) => {
|
|
2153
|
+
const [localizationStore, updateLocalizationStore] = createStore$1(
|
|
1608
2154
|
// we structure clone to avoid proxying to the original object
|
|
1609
2155
|
structuredClone({
|
|
1610
|
-
...
|
|
2156
|
+
...enLocaleStrings,
|
|
1611
2157
|
// we don't care on init
|
|
1612
2158
|
// eslint-disable-next-line solid/reactivity
|
|
1613
|
-
...
|
|
2159
|
+
...props.userStrings
|
|
1614
2160
|
})
|
|
1615
2161
|
);
|
|
1616
|
-
|
|
1617
|
-
|
|
2162
|
+
onMount(() => {
|
|
2163
|
+
props.setLocalizationRef(updateLocalizationStore);
|
|
1618
2164
|
});
|
|
1619
|
-
const
|
|
1620
|
-
t:
|
|
1621
|
-
updateLocalization:
|
|
2165
|
+
const contextValue = {
|
|
2166
|
+
t: localizationStore,
|
|
2167
|
+
updateLocalization: updateLocalizationStore
|
|
1622
2168
|
};
|
|
1623
|
-
return
|
|
1624
|
-
value:
|
|
2169
|
+
return createComponent(LocalizationContext.Provider, {
|
|
2170
|
+
value: contextValue,
|
|
1625
2171
|
get children() {
|
|
1626
|
-
return
|
|
2172
|
+
return props.children;
|
|
1627
2173
|
}
|
|
1628
2174
|
});
|
|
1629
2175
|
};
|
|
1630
|
-
function
|
|
1631
|
-
const
|
|
1632
|
-
if (!
|
|
2176
|
+
function useLocalization() {
|
|
2177
|
+
const ctx = useContext(LocalizationContext);
|
|
2178
|
+
if (!ctx) {
|
|
1633
2179
|
throw new Error("LocalizationContext.Provider not in scope.");
|
|
1634
|
-
|
|
2180
|
+
}
|
|
2181
|
+
return ctx;
|
|
1635
2182
|
}
|
|
1636
|
-
var
|
|
1637
|
-
const
|
|
1638
|
-
const [
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
2183
|
+
var _tmpl$$c = /* @__PURE__ */ template(`<span>`);
|
|
2184
|
+
const SmartEnvironmentProvider = (props) => {
|
|
2185
|
+
const [rootNode, setRootNode] = createSignal();
|
|
2186
|
+
const [ref, setRef] = createSignal();
|
|
2187
|
+
onMount(() => {
|
|
2188
|
+
const spanRef = ref();
|
|
2189
|
+
if (!spanRef) {
|
|
2190
|
+
return;
|
|
2191
|
+
}
|
|
2192
|
+
setRootNode(spanRef.getRootNode());
|
|
2193
|
+
});
|
|
2194
|
+
return createComponent(Show, {
|
|
1643
2195
|
get when() {
|
|
1644
|
-
return
|
|
2196
|
+
return rootNode();
|
|
1645
2197
|
},
|
|
1646
2198
|
get fallback() {
|
|
1647
2199
|
return (() => {
|
|
1648
|
-
var
|
|
1649
|
-
|
|
2200
|
+
var _el$ = _tmpl$$c();
|
|
2201
|
+
use(setRef, _el$);
|
|
2202
|
+
return _el$;
|
|
1650
2203
|
})();
|
|
1651
2204
|
},
|
|
1652
|
-
children: (
|
|
1653
|
-
value: () =>
|
|
2205
|
+
children: (rootNode2) => createComponent(EnvironmentProvider, {
|
|
2206
|
+
value: () => rootNode2(),
|
|
1654
2207
|
get children() {
|
|
1655
|
-
return
|
|
2208
|
+
return props.children(rootNode2());
|
|
1656
2209
|
}
|
|
1657
2210
|
})
|
|
1658
2211
|
});
|
|
1659
2212
|
};
|
|
1660
|
-
var
|
|
1661
|
-
const
|
|
1662
|
-
var
|
|
1663
|
-
|
|
2213
|
+
var _tmpl$$b = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M6.4 19L5 17.6l5.6-5.6L5 6.4L6.4 5l5.6 5.6L17.6 5L19 6.4L13.4 12l5.6 5.6l-1.4 1.4l-5.6-5.6z">`);
|
|
2214
|
+
const CloseIcon = (props = {}) => (() => {
|
|
2215
|
+
var _el$ = _tmpl$$b();
|
|
2216
|
+
spread(_el$, props, true, true);
|
|
2217
|
+
return _el$;
|
|
1664
2218
|
})();
|
|
1665
|
-
var
|
|
1666
|
-
const
|
|
1667
|
-
var
|
|
1668
|
-
|
|
2219
|
+
var _tmpl$$a = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M7 2h10l-2 7h4l-2.925 4.225L7 4.15zm3 20v-8H7V9.85L1.375 4.225L2.8 2.8l18.4 18.4l-1.425 1.425L13.75 16.6z">`);
|
|
2220
|
+
const FlashOff = (props = {}) => (() => {
|
|
2221
|
+
var _el$ = _tmpl$$a();
|
|
2222
|
+
spread(_el$, props, true, true);
|
|
2223
|
+
return _el$;
|
|
1669
2224
|
})();
|
|
1670
|
-
var
|
|
1671
|
-
const
|
|
1672
|
-
var
|
|
1673
|
-
|
|
2225
|
+
var _tmpl$$9 = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M10 22v-8H7V2h10l-2 7h4z">`);
|
|
2226
|
+
const FlashOn = (props = {}) => (() => {
|
|
2227
|
+
var _el$ = _tmpl$$9();
|
|
2228
|
+
spread(_el$, props, true, true);
|
|
2229
|
+
return _el$;
|
|
1674
2230
|
})();
|
|
1675
|
-
var
|
|
1676
|
-
const
|
|
1677
|
-
var
|
|
1678
|
-
|
|
2231
|
+
var _tmpl$$8 = /* @__PURE__ */ template(`<svg viewBox="0 0 24 24"width=1.2em height=1.2em><path fill=currentColor d="M9 21H5q-.825 0-1.412-.587T3 19V5q0-.825.588-1.412T5 3h4v2H5v14h4zm2 2V1h2v22zm4-2v-2h2v2zm0-16V3h2v2zm4 16v-2h2q0 .825-.587 1.413T19 21m0-4v-2h2v2zm0-4v-2h2v2zm0-4V7h2v2zm0-4V3q.825 0 1.413.588T21 5z">`);
|
|
2232
|
+
const MirrorIcon = (props = {}) => (() => {
|
|
2233
|
+
var _el$ = _tmpl$$8();
|
|
2234
|
+
spread(_el$, props, true, true);
|
|
2235
|
+
return _el$;
|
|
1679
2236
|
})();
|
|
1680
|
-
function
|
|
1681
|
-
const
|
|
1682
|
-
|
|
1683
|
-
const
|
|
1684
|
-
let
|
|
1685
|
-
if (
|
|
1686
|
-
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1689
|
-
} else
|
|
1690
|
-
|
|
1691
|
-
|
|
2237
|
+
function eventFixer(props) {
|
|
2238
|
+
const newObj = {};
|
|
2239
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
2240
|
+
const lowerCaseKey = key.toLowerCase();
|
|
2241
|
+
let trimmedKey = lowerCaseKey;
|
|
2242
|
+
if (lowerCaseKey.startsWith("on")) {
|
|
2243
|
+
trimmedKey = lowerCaseKey.slice(2);
|
|
2244
|
+
const newKey = `on:${trimmedKey}`;
|
|
2245
|
+
newObj[newKey] = value;
|
|
2246
|
+
} else {
|
|
2247
|
+
newObj[trimmedKey] = value;
|
|
2248
|
+
}
|
|
2249
|
+
});
|
|
2250
|
+
return newObj;
|
|
1692
2251
|
}
|
|
1693
|
-
var
|
|
1694
|
-
const
|
|
1695
|
-
var
|
|
1696
|
-
|
|
2252
|
+
var _tmpl$$7 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><g fill=#fff fill-rule=evenodd clip-rule=evenodd><path d="M6.322 2.988A1.67 1.67 0 0 1 7.5 2.5h5a1.667 1.667 0 0 1 1.667 1.667A.833.833 0 0 0 15 5h.833a2.5 2.5 0 0 1 2.5 2.5V15a2.5 2.5 0 0 1-2.5 2.5H4.167a2.5 2.5 0 0 1-2.5-2.5V7.5a2.5 2.5 0 0 1 2.5-2.5H5a.833.833 0 0 0 .833-.833c0-.442.176-.866.489-1.179M4.167 6.667a.833.833 0 0 0-.834.833V15a.833.833 0 0 0 .834.833h11.666a.834.834 0 0 0 .834-.833V7.5a.833.833 0 0 0-.834-.833H15a2.5 2.5 0 0 1-2.5-2.5h-5a2.5 2.5 0 0 1-2.5 2.5z"></path><path d="M10 9.167a1.667 1.667 0 1 0 0 3.333 1.667 1.667 0 0 0 0-3.333m-3.333 1.666a3.333 3.333 0 1 1 6.666 0 3.333 3.333 0 0 1-6.666 0">`);
|
|
2253
|
+
const IconCamera = (props = {}) => (() => {
|
|
2254
|
+
var _el$ = _tmpl$$7();
|
|
2255
|
+
spread(_el$, props, true, true);
|
|
2256
|
+
return _el$;
|
|
1697
2257
|
})();
|
|
1698
|
-
var
|
|
1699
|
-
const
|
|
1700
|
-
var
|
|
1701
|
-
|
|
2258
|
+
var _tmpl$$6 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><path stroke=#fff stroke-linecap=round stroke-linejoin=round stroke-width=2 d="M4.167 10.833 7.5 14.167l8.333-8.334">`);
|
|
2259
|
+
const IconCheck = (props = {}) => (() => {
|
|
2260
|
+
var _el$ = _tmpl$$6();
|
|
2261
|
+
spread(_el$, props, true, true);
|
|
2262
|
+
return _el$;
|
|
1702
2263
|
})();
|
|
1703
|
-
var
|
|
1704
|
-
const
|
|
1705
|
-
var
|
|
1706
|
-
|
|
2264
|
+
var _tmpl$$5 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none viewBox="0 0 20 20"><path fill=#fff fill-rule=evenodd d="M4.41 6.91a.833.833 0 0 1 1.18 0L10 11.323l4.41-4.411a.833.833 0 1 1 1.18 1.178l-5 5a.833.833 0 0 1-1.18 0l-5-5a.833.833 0 0 1 0-1.178"clip-rule=evenodd>`);
|
|
2265
|
+
const IconChevronDown = (props = {}) => (() => {
|
|
2266
|
+
var _el$ = _tmpl$$5();
|
|
2267
|
+
spread(_el$, props, true, true);
|
|
2268
|
+
return _el$;
|
|
1707
2269
|
})();
|
|
1708
|
-
var
|
|
1709
|
-
const
|
|
2270
|
+
var _tmpl$$4 = /* @__PURE__ */ template(`<button>`), _tmpl$2$3 = /* @__PURE__ */ template(`<div class="h-[1px] absolute left-0 right-0 top-[-1px] bg-white pointer-events-none">`);
|
|
2271
|
+
const CameraSelector = () => {
|
|
2272
|
+
const {
|
|
2273
|
+
cameraManagerSolidStore,
|
|
2274
|
+
cameraManager
|
|
2275
|
+
} = useCameraUiStore();
|
|
1710
2276
|
const {
|
|
1711
|
-
cameraManagerSolidStore: r,
|
|
1712
|
-
cameraManager: e
|
|
1713
|
-
} = q(), {
|
|
1714
2277
|
t
|
|
1715
|
-
} =
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
2278
|
+
} = useLocalization();
|
|
2279
|
+
const cameras = cameraManagerSolidStore((x) => x.cameras);
|
|
2280
|
+
const selectedCamera = cameraManagerSolidStore((x) => x.selectedCamera);
|
|
2281
|
+
const isQueryingCameras = cameraManagerSolidStore((x) => x.isQueryingCameras);
|
|
2282
|
+
const facingFilter = cameraManagerSolidStore((x) => x.facingFilter);
|
|
2283
|
+
const [isSwapping, setIsSwapping] = createSignal(false);
|
|
2284
|
+
const isDisabled = () => isQueryingCameras() || isSwapping();
|
|
2285
|
+
const camerasWithFacingFilter = () => {
|
|
2286
|
+
const $facingFilter = facingFilter();
|
|
2287
|
+
if (!$facingFilter) {
|
|
2288
|
+
return cameras();
|
|
2289
|
+
}
|
|
2290
|
+
return cameras().filter((camera) => $facingFilter.includes(camera.facingMode));
|
|
2291
|
+
};
|
|
2292
|
+
const createCameraOptions = () => [...camerasWithFacingFilter().map((camera) => ({
|
|
2293
|
+
value: camera.deviceInfo.deviceId,
|
|
2294
|
+
label: camera.name
|
|
2295
|
+
}))];
|
|
2296
|
+
const cameraCollection = () => createListCollection({
|
|
2297
|
+
items: [...createCameraOptions()]
|
|
2298
|
+
});
|
|
2299
|
+
const selectedCameraInCollection = () => {
|
|
2300
|
+
const $selectedCamera = selectedCamera();
|
|
2301
|
+
if (!$selectedCamera) {
|
|
2302
|
+
return;
|
|
2303
|
+
}
|
|
2304
|
+
const foundCamera = cameraCollection().find($selectedCamera.deviceInfo.deviceId);
|
|
2305
|
+
if (!foundCamera) {
|
|
1726
2306
|
return;
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
2307
|
+
}
|
|
2308
|
+
return [foundCamera.value];
|
|
2309
|
+
};
|
|
2310
|
+
const isFakeCamera = (value) => {
|
|
2311
|
+
return fakeCameras.some((fakeCamera) => fakeCamera.value === value);
|
|
2312
|
+
};
|
|
2313
|
+
const selectCameraById = async (id) => {
|
|
2314
|
+
setIsSwapping(true);
|
|
2315
|
+
const camera = cameras().find((camera2) => camera2.deviceInfo.deviceId === id);
|
|
2316
|
+
if (!camera) {
|
|
1734
2317
|
console.warn("No camera");
|
|
1735
2318
|
return;
|
|
1736
2319
|
}
|
|
1737
|
-
await
|
|
2320
|
+
await cameraManager.selectCamera(camera);
|
|
2321
|
+
setIsSwapping(false);
|
|
1738
2322
|
};
|
|
1739
|
-
return
|
|
1740
|
-
children: () =>
|
|
2323
|
+
return createComponent(SmartEnvironmentProvider, {
|
|
2324
|
+
children: () => createComponent(Select.Root, {
|
|
2325
|
+
part: "camera-select-part",
|
|
1741
2326
|
get collection() {
|
|
1742
|
-
return
|
|
2327
|
+
return cameraCollection();
|
|
1743
2328
|
},
|
|
1744
2329
|
get value() {
|
|
1745
|
-
return
|
|
2330
|
+
return selectedCameraInCollection();
|
|
1746
2331
|
},
|
|
1747
2332
|
positioning: {
|
|
1748
2333
|
placement: "top"
|
|
1749
2334
|
},
|
|
1750
|
-
lazyMount:
|
|
2335
|
+
lazyMount: true,
|
|
1751
2336
|
get disabled() {
|
|
1752
|
-
return
|
|
2337
|
+
return isDisabled();
|
|
1753
2338
|
},
|
|
1754
|
-
onValueChange: (
|
|
1755
|
-
if (
|
|
2339
|
+
onValueChange: (details) => {
|
|
2340
|
+
if (isFakeCamera(details.value[0])) {
|
|
1756
2341
|
console.warn("Fake camera, skipping");
|
|
1757
2342
|
return;
|
|
1758
2343
|
}
|
|
1759
|
-
|
|
2344
|
+
void selectCameraById(details.value[0]);
|
|
1760
2345
|
},
|
|
1761
2346
|
get children() {
|
|
1762
|
-
return [
|
|
1763
|
-
class: "sr-only",
|
|
2347
|
+
return [createComponent(Select.Label, {
|
|
2348
|
+
"class": "sr-only",
|
|
1764
2349
|
get children() {
|
|
1765
2350
|
return t.selected_camera;
|
|
1766
2351
|
}
|
|
1767
|
-
}),
|
|
1768
|
-
asChild: (
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
2352
|
+
}), createComponent(Select.Trigger, {
|
|
2353
|
+
asChild: (selectProps) => {
|
|
2354
|
+
return (() => {
|
|
2355
|
+
var _el$ = _tmpl$$4();
|
|
2356
|
+
spread(_el$, mergeProps(() => eventFixer(selectProps()), {
|
|
2357
|
+
"class": `flex px-4 py-2 items-center gap-2 rounded-full bg-dark-100/50 backdrop-blur-xl
|
|
1772
2358
|
whitespace-nowrap text-base color-white font-500 cursor-pointer appearance-none
|
|
1773
2359
|
border-none disabled:opacity-50 disabled:cursor-not-allowed max-w-[100%]`
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
2360
|
+
}), false, true);
|
|
2361
|
+
insert(_el$, createComponent(IconCamera, {
|
|
2362
|
+
"class": "size-6 shrink-0",
|
|
2363
|
+
"aria-hidden": true
|
|
2364
|
+
}), null);
|
|
2365
|
+
insert(_el$, createComponent(Select.ValueText, {
|
|
2366
|
+
"class": "truncate",
|
|
2367
|
+
get placeholder() {
|
|
2368
|
+
return isQueryingCameras() ? t.loading_cameras : t.select_a_camera;
|
|
2369
|
+
}
|
|
2370
|
+
}), null);
|
|
2371
|
+
insert(_el$, createComponent(Select.Indicator, {
|
|
2372
|
+
"class": "shrink-0 data-[state=open]:scale-y-[-1]",
|
|
2373
|
+
get children() {
|
|
2374
|
+
return createComponent(IconChevronDown, {
|
|
2375
|
+
"class": "size-6 shrink-0"
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
}), null);
|
|
2379
|
+
return _el$;
|
|
2380
|
+
})();
|
|
2381
|
+
}
|
|
2382
|
+
}), createComponent(Select.Positioner, {
|
|
1792
2383
|
get children() {
|
|
1793
|
-
return
|
|
2384
|
+
return createComponent(Select.Content, {
|
|
1794
2385
|
get children() {
|
|
1795
|
-
return
|
|
1796
|
-
class: "rounded-4 overflow-hidden text-base color-white",
|
|
2386
|
+
return createComponent(Select.ItemGroup, {
|
|
2387
|
+
"class": "rounded-4 overflow-hidden text-base color-white",
|
|
1797
2388
|
get children() {
|
|
1798
|
-
return
|
|
2389
|
+
return createComponent(Index, {
|
|
1799
2390
|
get each() {
|
|
1800
|
-
return
|
|
2391
|
+
return cameraCollection().items;
|
|
1801
2392
|
},
|
|
1802
|
-
children: (
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
bg-dark-100/50 backdrop-blur-xl data-[highlighted]:bg-gray-500/50
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2393
|
+
children: (camera, index) => {
|
|
2394
|
+
return createComponent(Select.Item, {
|
|
2395
|
+
get item() {
|
|
2396
|
+
return camera();
|
|
2397
|
+
},
|
|
2398
|
+
"class": "flex py-3 pl-4 pr-12 cursor-pointer select-none relative gap-[1px]\n bg-dark-100/50 backdrop-blur-xl data-[highlighted]:bg-gray-500/50",
|
|
2399
|
+
get children() {
|
|
2400
|
+
return [createComponent(Select.ItemText, {
|
|
2401
|
+
"class": "truncate",
|
|
2402
|
+
get children() {
|
|
2403
|
+
return camera().label;
|
|
2404
|
+
}
|
|
2405
|
+
}), createComponent(Select.ItemIndicator, {
|
|
2406
|
+
"class": "absolute right-4",
|
|
2407
|
+
get children() {
|
|
2408
|
+
return createComponent(IconCheck, {
|
|
2409
|
+
"class": "size-6 shrink-0"
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
}), createComponent(Show, {
|
|
2413
|
+
when: index !== 0,
|
|
2414
|
+
get children() {
|
|
2415
|
+
return _tmpl$2$3();
|
|
2416
|
+
}
|
|
2417
|
+
})];
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
}
|
|
1829
2421
|
});
|
|
1830
2422
|
}
|
|
1831
2423
|
});
|
|
@@ -1836,7 +2428,8 @@ const Zt = () => {
|
|
|
1836
2428
|
}
|
|
1837
2429
|
})
|
|
1838
2430
|
});
|
|
1839
|
-
}
|
|
2431
|
+
};
|
|
2432
|
+
const fakeCameras = [{
|
|
1840
2433
|
value: "5",
|
|
1841
2434
|
label: "Back Camera 2"
|
|
1842
2435
|
}, {
|
|
@@ -1852,307 +2445,389 @@ const Zt = () => {
|
|
|
1852
2445
|
value: "4",
|
|
1853
2446
|
label: "Some random desktop camera"
|
|
1854
2447
|
}];
|
|
1855
|
-
var
|
|
1856
|
-
const
|
|
2448
|
+
var _tmpl$$3 = /* @__PURE__ */ template(`<span class=sr-only>`), _tmpl$2$2 = /* @__PURE__ */ template(`<div class=justify-self-end>`), _tmpl$3$2 = /* @__PURE__ */ template(`<div class="z-2 relative gap-2 grid justify-between items-center grid-cols-[1fr_auto_1fr] py-4 color-white lerp:px-3@xs,8@lg"><div class="justify-self-start flex flex-nowrap gap-4 auto-cols-auto"></div><div class="justify-self-center min-w-0 w-full">`), _tmpl$4$1 = /* @__PURE__ */ template(`<button>`);
|
|
2449
|
+
const Header = () => {
|
|
1857
2450
|
const {
|
|
1858
|
-
dismountCameraUi
|
|
1859
|
-
cameraManagerSolidStore
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
} =
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
}
|
|
1868
|
-
|
|
2451
|
+
dismountCameraUi,
|
|
2452
|
+
cameraManagerSolidStore,
|
|
2453
|
+
cameraManager,
|
|
2454
|
+
showMirrorCameraButton,
|
|
2455
|
+
showTorchButton,
|
|
2456
|
+
showCloseButton
|
|
2457
|
+
} = useCameraUiStore();
|
|
2458
|
+
const {
|
|
2459
|
+
t
|
|
2460
|
+
} = useLocalization();
|
|
2461
|
+
const isMirrored = cameraManagerSolidStore((s) => s.mirrorX);
|
|
2462
|
+
const selectedCamera = cameraManagerSolidStore((s) => s.selectedCamera);
|
|
2463
|
+
const cameras = cameraManagerSolidStore((s) => s.cameras);
|
|
2464
|
+
const isActive = cameraManagerSolidStore((s) => s.playbackState !== "idle");
|
|
2465
|
+
const torchEnabled = cameraManagerSolidStore((s) => s.selectedCamera?.torchEnabled);
|
|
2466
|
+
const hasTorch = () => selectedCamera()?.torchSupported;
|
|
2467
|
+
const toggleTorch = () => {
|
|
2468
|
+
const camera = selectedCamera();
|
|
2469
|
+
if (!camera) {
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
void camera.toggleTorch();
|
|
2473
|
+
};
|
|
2474
|
+
const toggleMirrorX = () => {
|
|
2475
|
+
cameraManager.setCameraMirrorX(!cameraManagerSolidStore.getState().mirrorX);
|
|
1869
2476
|
};
|
|
1870
|
-
return
|
|
2477
|
+
return createComponent(SmartEnvironmentProvider, {
|
|
1871
2478
|
children: () => (() => {
|
|
1872
|
-
var
|
|
1873
|
-
|
|
2479
|
+
var _el$ = _tmpl$3$2(), _el$2 = _el$.firstChild, _el$5 = _el$2.nextSibling;
|
|
2480
|
+
insert(_el$2, createComponent(Show, {
|
|
1874
2481
|
get when() {
|
|
1875
|
-
return
|
|
2482
|
+
return showMirrorCameraButton && isActive();
|
|
1876
2483
|
},
|
|
1877
2484
|
get children() {
|
|
1878
|
-
return
|
|
2485
|
+
return createComponent(ToolbarButton, {
|
|
2486
|
+
part: "mirror-camera-button-part",
|
|
1879
2487
|
get tooltipLabel() {
|
|
1880
|
-
return
|
|
2488
|
+
return t.mirror_camera;
|
|
1881
2489
|
},
|
|
1882
|
-
onClick: () =>
|
|
2490
|
+
onClick: () => toggleMirrorX(),
|
|
1883
2491
|
get children() {
|
|
1884
2492
|
return [(() => {
|
|
1885
|
-
var
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
2493
|
+
var _el$3 = _tmpl$$3();
|
|
2494
|
+
insert(_el$3, () => t.mirror_camera);
|
|
2495
|
+
return _el$3;
|
|
2496
|
+
})(), createComponent(MirrorIcon, {
|
|
2497
|
+
"class": "size-6 shrink-0 transition-transform duration-300 ease-in-out",
|
|
1889
2498
|
get style() {
|
|
1890
2499
|
return {
|
|
1891
|
-
transform:
|
|
2500
|
+
transform: isMirrored() ? "scaleX(-1)" : "scaleX(1)"
|
|
1892
2501
|
};
|
|
1893
2502
|
}
|
|
1894
2503
|
})];
|
|
1895
2504
|
}
|
|
1896
2505
|
});
|
|
1897
2506
|
}
|
|
1898
|
-
}), null)
|
|
2507
|
+
}), null);
|
|
2508
|
+
insert(_el$2, createComponent(Show, {
|
|
1899
2509
|
get when() {
|
|
1900
|
-
return
|
|
2510
|
+
return memo(() => !!(showTorchButton && hasTorch()))() && isActive();
|
|
1901
2511
|
},
|
|
1902
2512
|
get children() {
|
|
1903
|
-
return
|
|
1904
|
-
|
|
2513
|
+
return createComponent(ToolbarButton, {
|
|
2514
|
+
part: "torch-button-part",
|
|
2515
|
+
onClick: () => toggleTorch(),
|
|
1905
2516
|
get tooltipLabel() {
|
|
1906
|
-
return
|
|
2517
|
+
return t.torch;
|
|
1907
2518
|
},
|
|
1908
2519
|
get children() {
|
|
1909
|
-
return [
|
|
2520
|
+
return [createComponent(Show, {
|
|
1910
2521
|
get when() {
|
|
1911
|
-
return !
|
|
2522
|
+
return !torchEnabled();
|
|
1912
2523
|
},
|
|
1913
2524
|
get children() {
|
|
1914
2525
|
return [(() => {
|
|
1915
|
-
var
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
2526
|
+
var _el$4 = _tmpl$$3();
|
|
2527
|
+
insert(_el$4, () => t.torch);
|
|
2528
|
+
return _el$4;
|
|
2529
|
+
})(), createComponent(FlashOn, {
|
|
2530
|
+
"class": "size-6 shrink-0"
|
|
1919
2531
|
})];
|
|
1920
2532
|
}
|
|
1921
|
-
}),
|
|
2533
|
+
}), createComponent(Show, {
|
|
1922
2534
|
get when() {
|
|
1923
|
-
return
|
|
2535
|
+
return torchEnabled();
|
|
1924
2536
|
},
|
|
1925
2537
|
get children() {
|
|
1926
|
-
return
|
|
1927
|
-
class: "size-6 shrink-0"
|
|
2538
|
+
return createComponent(FlashOff, {
|
|
2539
|
+
"class": "size-6 shrink-0"
|
|
1928
2540
|
});
|
|
1929
2541
|
}
|
|
1930
2542
|
})];
|
|
1931
2543
|
}
|
|
1932
2544
|
});
|
|
1933
2545
|
}
|
|
1934
|
-
}), null)
|
|
2546
|
+
}), null);
|
|
2547
|
+
insert(_el$5, createComponent(Show, {
|
|
1935
2548
|
get when() {
|
|
1936
|
-
return
|
|
2549
|
+
return cameras().length > 1;
|
|
1937
2550
|
},
|
|
1938
2551
|
get children() {
|
|
1939
|
-
return
|
|
2552
|
+
return createComponent(CameraSelector, {});
|
|
1940
2553
|
}
|
|
1941
|
-
}))
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
return n.close;
|
|
1945
|
-
},
|
|
2554
|
+
}));
|
|
2555
|
+
insert(_el$, createComponent(Show, {
|
|
2556
|
+
when: showCloseButton,
|
|
1946
2557
|
get children() {
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
2558
|
+
var _el$6 = _tmpl$2$2();
|
|
2559
|
+
insert(_el$6, createComponent(ToolbarButton, {
|
|
2560
|
+
part: "close-button-part",
|
|
2561
|
+
onClick: () => dismountCameraUi(),
|
|
2562
|
+
get tooltipLabel() {
|
|
2563
|
+
return t.close;
|
|
2564
|
+
},
|
|
2565
|
+
get children() {
|
|
2566
|
+
return [(() => {
|
|
2567
|
+
var _el$7 = _tmpl$$3();
|
|
2568
|
+
insert(_el$7, () => t.close);
|
|
2569
|
+
return _el$7;
|
|
2570
|
+
})(), createComponent(CloseIcon, {
|
|
2571
|
+
"class": "size-6 shrink-0"
|
|
2572
|
+
})];
|
|
2573
|
+
}
|
|
2574
|
+
}));
|
|
2575
|
+
return _el$6;
|
|
1953
2576
|
}
|
|
1954
|
-
})
|
|
2577
|
+
}), null);
|
|
2578
|
+
return _el$;
|
|
1955
2579
|
})()
|
|
1956
2580
|
});
|
|
1957
|
-
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
2581
|
+
};
|
|
2582
|
+
const ToolbarButton = (props) => {
|
|
2583
|
+
return createComponent(Tooltip.Root, {
|
|
2584
|
+
get children() {
|
|
2585
|
+
return [createComponent(Tooltip.Trigger, mergeProps(props, {
|
|
2586
|
+
asChild: (tooltipProps) => {
|
|
2587
|
+
return (() => {
|
|
2588
|
+
var _el$8 = _tmpl$4$1();
|
|
2589
|
+
spread(_el$8, mergeProps(() => eventFixer(tooltipProps()), {
|
|
2590
|
+
"class": `rounded-full bg-dark-500 bg-opacity-50 backdrop-blur grid place-items-center
|
|
1964
2591
|
size-12 appearance-none border-none cursor-pointer`
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
2592
|
+
}), false, true);
|
|
2593
|
+
insert(_el$8, () => props.children);
|
|
2594
|
+
return _el$8;
|
|
2595
|
+
})();
|
|
2596
|
+
}
|
|
2597
|
+
})), createComponent(Tooltip.Positioner, {
|
|
2598
|
+
get children() {
|
|
2599
|
+
return createComponent(Tooltip.Content, {
|
|
2600
|
+
"class": `bg-dark-500 bg-opacity-50 backdrop-blur color-white text-align-center p-2
|
|
1971
2601
|
rounded-md text-sm drop-shadow-md`,
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
})
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2602
|
+
get children() {
|
|
2603
|
+
return props.tooltipLabel;
|
|
2604
|
+
}
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
})];
|
|
2608
|
+
}
|
|
2609
|
+
});
|
|
2610
|
+
};
|
|
2611
|
+
const renderWithOwner = (code, element, owner) => {
|
|
2612
|
+
return createRoot((dispose) => {
|
|
2613
|
+
insert(element, code(), element.firstChild ? null : void 0);
|
|
2614
|
+
return () => {
|
|
2615
|
+
dispose();
|
|
2616
|
+
element.textContent = "";
|
|
2617
|
+
};
|
|
2618
|
+
}, owner);
|
|
2619
|
+
};
|
|
2620
|
+
var _tmpl$$2 = /* @__PURE__ */ template(`<div>`);
|
|
2621
|
+
const SolidShadowRoot = (props) => {
|
|
2622
|
+
const owner = getOwner();
|
|
2623
|
+
const [local, others] = splitProps(props, ["children", "disableShadowRoot", "getRef"]);
|
|
1985
2624
|
return (() => {
|
|
1986
|
-
var
|
|
1987
|
-
|
|
1988
|
-
if (
|
|
2625
|
+
var _el$ = _tmpl$$2();
|
|
2626
|
+
use((ref) => {
|
|
2627
|
+
if (local.disableShadowRoot) {
|
|
1989
2628
|
return;
|
|
1990
|
-
|
|
2629
|
+
}
|
|
2630
|
+
const shadowRoot = ref.attachShadow({
|
|
1991
2631
|
mode: "open"
|
|
1992
2632
|
});
|
|
1993
|
-
|
|
1994
|
-
},
|
|
2633
|
+
renderWithOwner(() => memo(() => local.children), shadowRoot, owner);
|
|
2634
|
+
}, _el$);
|
|
2635
|
+
spread(_el$, others, false, true);
|
|
2636
|
+
insert(_el$, createComponent(Show, {
|
|
1995
2637
|
get when() {
|
|
1996
|
-
return
|
|
2638
|
+
return local.disableShadowRoot;
|
|
1997
2639
|
},
|
|
1998
2640
|
get children() {
|
|
1999
|
-
return
|
|
2641
|
+
return local.children;
|
|
2000
2642
|
}
|
|
2001
|
-
}))
|
|
2643
|
+
}));
|
|
2644
|
+
return _el$;
|
|
2002
2645
|
})();
|
|
2003
|
-
}
|
|
2646
|
+
};
|
|
2647
|
+
const normalize = '/* Document\n * ========================================================================== */\n\n/**\n * 1. Correct the line height in all browsers.\n * 2. Prevent adjustments of font size after orientation changes in iOS.\n */\n\n:where(html) {\n line-height: 1.15; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n text-size-adjust: 100%; /* 2 */\n}\n\n/* Sections\n * ========================================================================== */\n\n/**\n * Correct the font size and margin on `h1` elements within `section` and\n * `article` contexts in Chrome, Edge, Firefox, and Safari.\n */\n\n:where(h1) {\n font-size: 2em;\n margin-block-end: 0.67em;\n margin-block-start: 0.67em;\n}\n\n/* Grouping content\n * ========================================================================== */\n\n/**\n * Remove the margin on nested lists in Chrome, Edge, and Safari.\n */\n\n:where(dl, ol, ul) :where(dl, ol, ul) {\n margin-block-end: 0;\n margin-block-start: 0;\n}\n\n/**\n * 1. Add the correct box sizing in Firefox.\n * 2. Correct the inheritance of border color in Firefox.\n */\n\n:where(hr) {\n box-sizing: content-box; /* 1 */\n color: inherit; /* 2 */\n height: 0; /* 1 */\n}\n\n/* Text-level semantics\n * ========================================================================== */\n\n/**\n * Add the correct text decoration in Safari.\n */\n\n:where(abbr[title]) {\n text-decoration: underline;\n text-decoration: underline dotted;\n}\n\n/**\n * Add the correct font weight in Chrome, Edge, and Safari.\n */\n\n:where(b, strong) {\n font-weight: bolder;\n}\n\n/**\n * 1. Correct the inheritance and scaling of font size in all browsers.\n * 2. Correct the odd `em` font sizing in all browsers.\n */\n\n:where(code, kbd, pre, samp) {\n font-family: monospace, monospace; /* 1 */\n font-size: 1em; /* 2 */\n}\n\n/**\n * Add the correct font size in all browsers.\n */\n\n:where(small) {\n font-size: 80%;\n}\n\n/* Tabular data\n * ========================================================================== */\n\n/**\n * 1. Correct table border color in Chrome, Edge, and Safari.\n * 2. Remove text indentation from table contents in Chrome, Edge, and Safari.\n */\n\n:where(table) {\n border-color: currentColor; /* 1 */\n text-indent: 0; /* 2 */\n}\n\n/* Forms\n * ========================================================================== */\n\n/**\n * Remove the margin on controls in Safari.\n */\n\n:where(button, input, select) {\n margin: 0;\n}\n\n/**\n * Remove the inheritance of text transform in Firefox.\n */\n\n:where(button) {\n text-transform: none;\n}\n\n/**\n * Correct the inability to style buttons in iOS and Safari.\n */\n\n:where(button, input:is([type="button" i], [type="reset" i], [type="submit" i])) {\n -webkit-appearance: button;\n}\n\n/**\n * Add the correct vertical alignment in Chrome, Edge, and Firefox.\n */\n\n:where(progress) {\n vertical-align: baseline;\n}\n\n/**\n * Remove the inheritance of text transform in Firefox.\n */\n\n:where(select) {\n text-transform: none;\n}\n\n/**\n * Remove the margin in Firefox and Safari.\n */\n\n:where(textarea) {\n margin: 0;\n}\n\n/**\n * 1. Correct the odd appearance in Chrome, Edge, and Safari.\n * 2. Correct the outline style in Safari.\n */\n\n:where(input[type="search" i]) {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/**\n * Correct the cursor style of increment and decrement buttons in Safari.\n */\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/**\n * Correct the text style of placeholders in Chrome, Edge, and Safari.\n */\n\n::-webkit-input-placeholder {\n color: inherit;\n opacity: 0.54;\n}\n\n/**\n * Remove the inner padding in Chrome, Edge, and Safari on macOS.\n */\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/**\n * 1. Correct the inability to style upload buttons in iOS and Safari.\n * 2. Change font properties to `inherit` in Safari.\n */\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/**\n * Remove the inner border and padding of focus outlines in Firefox.\n */\n\n:where(button, input:is([type="button" i], [type="color" i], [type="reset" i], [type="submit" i]))::-moz-focus-inner {\n border-style: none;\n padding: 0;\n}\n\n/**\n * Restore the focus outline styles unset by the previous rule in Firefox.\n */\n\n:where(button, input:is([type="button" i], [type="color" i], [type="reset" i], [type="submit" i]))::-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\n/**\n * Remove the additional :invalid styles in Firefox.\n */\n\n:where(:-moz-ui-invalid) {\n box-shadow: none;\n}\n\n/* Interactive\n * ========================================================================== */\n\n/*\n * Add the correct styles in Safari.\n */\n\n:where(dialog) {\n background-color: white;\n border: solid;\n color: black;\n height: -moz-fit-content;\n height: fit-content;\n left: 0;\n margin: auto;\n padding: 1em;\n position: absolute;\n right: 0;\n width: -moz-fit-content;\n width: fit-content;\n}\n\n:where(dialog:not([open])) {\n display: none;\n}\n\n/*\n * Add the correct display in all browsers.\n */\n\n:where(summary) {\n display: list-item;\n}\n';
|
|
2648
|
+
const rootStyles = ":host {\n font-family: var(--mb-ui-font);\n line-height: 1.15;\n isolation: isolate;\n box-sizing: border-box;\n}\n\n*,\n*::before,\n*::after {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n}\n\np,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n overflow-wrap: break-word;\n}\n\ncode {\n font-family: var(--mb-monospace-font-stack);\n}\n\npre {\n font-family: var(--mb-monospace-font-stack);\n}\n\nsvg path {\n pointer-events: none;\n}\n\nimg,\npicture,\nvideo,\ncanvas,\nsvg {\n display: block;\n max-width: 100%;\n}\n\nimg {\n pointer-events: none;\n user-select: none;\n}\n\n:where(input, button, textarea, select) {\n font: inherit;\n}\n\n:where(button, select) {\n cursor: pointer;\n color: inherit;\n font: inherit;\n}\n\n:where(p, h1, h2, h3, h4, h5, h6) {\n overflow-wrap: break-word;\n}";
|
|
2649
|
+
const variables = ':host {\n --mb-system-font-stack:\n -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu",\n "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n --mb-monospace-font-stack:\n Menlo, Consolas, "Ubuntu Mono", "Roboto Mono", "DejaVu Sans Mono", monospace;\n --mb-ui-font: var(--mb-system-font-stack);\n --mb-size: 1;\n /***************************************/\n /* MB COLORS */\n /***************************************/\n --color-accent-25-rgb-value: 242 247 255; /* #F2F7FF */\n --color-accent-50-rgb-value: 231 240 255; /* #E7F0FF */\n --color-accent-100-rgb-value: 220 234 255; /* #DCEAFF */\n --color-accent-200-rgb-value: 198 221 255; /* #C6DDFF */\n --color-accent-300-rgb-value: 158 197 255; /* #9EC5FF */\n --color-accent-400-rgb-value: 111 169 255; /* #6FA9FF */\n --color-accent-500-rgb-value: 58 137 253; /* #3A89FD */\n --color-accent-600-rgb-value: 0 98 242; /* #0062F2 */\n --color-accent-700-rgb-value: 0 80 197; /* #0050C5 */\n --color-accent-800-rgb-value: 0 64 157; /* #00409D */\n --color-accent-900-rgb-value: 0 54 133; /* #003685 */\n --color-error-25-rgb-value: 255 248 249; /* #FFF8F9 */\n --color-error-50-rgb-value: 255 241 242; /* #FFF1F2 */\n --color-error-100-rgb-value: 255 228 230; /* #FFE4E6 */\n --color-error-200-rgb-value: 254 205 211; /* #FECDD3 */\n --color-error-300-rgb-value: 253 164 175; /* #FDA4AF */\n --color-error-400-rgb-value: 251 113 133; /* #FB7185 */\n --color-error-500-rgb-value: 244 63 94; /* #F43F5E */\n --color-error-600-rgb-value: 225 29 72; /* #E11D48 */\n --color-error-700-rgb-value: 190 18 60; /* #BE123C */\n --color-error-800-rgb-value: 136 19 39; /* #881337 */\n --color-error-900-rgb-value: 89 13 40; /* #590D28 */\n --color-success-25-rgb-value: 245 254 250; /* #F5FEFA */\n --color-success-50-rgb-value: 236 253 245; /* #ECFDF5 */\n --color-success-100-rgb-value: 209 250 229; /* #D1FAE5 */\n --color-success-200-rgb-value: 167 243 208; /* #A7F3D0 */\n --color-success-300-rgb-value: 110 231 183; /* #6EE7B7 */\n --color-success-400-rgb-value: 52 211 153; /* #34D399 */\n --color-success-500-rgb-value: 16 185 144; /* #10B990 */\n --color-success-600-rgb-value: 22 163 138; /* #16A38A */\n --color-success-700-rgb-value: 39 121 106; /* #27796A */\n --color-success-800-rgb-value: 23 92 79; /* #175C4F */\n --color-success-900-rgb-value: 12 59 50; /* #0C3B32 */\n --color-warning-25-rgb-value: 255 253 243; /* #FFFDF3 */\n --color-warning-50-rgb-value: 254 252 232; /* #FEFCE8 */\n --color-warning-100-rgb-value: 254 249 195; /* #FEF9C3 */\n --color-warning-200-rgb-value: 254 240 138; /* #FEF08A */\n --color-warning-300-rgb-value: 253 229 99; /* #FDE563 */\n --color-warning-400-rgb-value: 252 218 59; /* #FCDA3B */\n --color-warning-500-rgb-value: 250 204 21; /* #FACC15 */\n --color-warning-600-rgb-value: 234 179 8; /* #EAB308 */\n --color-warning-700-rgb-value: 190 142 48; /* #BE8E30 */\n --color-warning-800-rgb-value: 132 83 28; /* #84531C */\n --color-warning-900-rgb-value: 80 29 10; /* #501D0A */\n --color-deep-blue-25-rgb-value: 249 252 255; /* #F9FCFF */\n --color-deep-blue-50-rgb-value: 243 249 254; /* #F3F9FE */\n --color-deep-blue-100-rgb-value: 231 242 251; /* #E7F2FB */\n --color-deep-blue-200-rgb-value: 201 218 241; /* #C9DAF1 */\n --color-deep-blue-300-rgb-value: 162 185 216; /* #A2B9D8 */\n --color-deep-blue-400-rgb-value: 93 128 182; /* #5D80B6 */\n --color-deep-blue-500-rgb-value: 60 100 161; /* #3C64A1 */\n --color-deep-blue-600-rgb-value: 28 68 129; /* #1C4481 */\n --color-deep-blue-700-rgb-value: 24 53 97; /* #183561 */\n --color-deep-blue-800-rgb-value: 20 38 65; /* #142641 */\n --color-deep-blue-900-rgb-value: 6 23 49; /* #061731 */\n --color-light-blue-25-rgb-value: 248 251 253; /* #F8FBFD */\n --color-light-blue-50-rgb-value: 240 247 251; /* #F0F7FB */\n --color-light-blue-100-rgb-value: 228 238 244; /* #E4EEF4 */\n --color-light-blue-200-rgb-value: 215 229 238; /* #D7E5EE */\n --color-light-blue-300-rgb-value: 190 218 237; /* #BEDAED */\n --color-light-blue-400-rgb-value: 159 202 232; /* #9FCAE8 */\n --color-light-blue-500-rgb-value: 135 180 211; /* #87B4D3 */\n --color-light-blue-600-rgb-value: 104 157 193; /* #689DC1 */\n --color-light-blue-700-rgb-value: 78 129 164; /* #4E81A4 */\n --color-light-blue-800-rgb-value: 67 109 138; /* #436D8A */\n --color-light-blue-900-rgb-value: 55 84 104; /* #375468 */\n --color-gray-50-rgb-value: 249 250 251; /* #FAFAFA */\n --color-gray-100-rgb-value: 243 244 246; /* #F5F5F5 */\n --color-gray-200-rgb-value: 229 231 235; /* #F0F0F0 */\n --color-gray-300-rgb-value: 209 213 219; /* #D9D9D9 */\n --color-gray-400-rgb-value: 156 163 175; /* #BFBFBF */\n --color-gray-500-rgb-value: 107 114 128; /* #8C8C8C */\n --color-gray-600-rgb-value: 75 85 99; /* #595959 */\n --color-gray-700-rgb-value: 55 65 81; /* #434343 */\n --color-gray-800-rgb-value: 31 41 55; /* #262626 */\n --color-blue-gray-50-rgb-value: 74 74 74; /* #F9FAFB */\n --color-blue-gray-100-rgb-value: 60 60 60; /* #F3F4F6 */\n --color-blue-gray-200-rgb-value: 50 50 50; /* #E5E7EB */\n --color-blue-gray-300-rgb-value: 45 45 45; /* #D1D5DB */\n --color-blue-gray-400-rgb-value: 34 34 34; /* #9CA3AF */\n --color-blue-gray-500-rgb-value: 31 31 31; /* #6B7280 */\n --color-blue-gray-600-rgb-value: 28 28 30; /* #4B5563 */\n --color-blue-gray-700-rgb-value: 27 27 27; /* #374151 */\n --color-blue-gray-800-rgb-value: 24 24 24; /* #1F2937 */\n --color-blue-gray-900-rgb-value: 15 15 15; /* #111827 */\n --color-black-rgb-value: 0 0 0; /* #000000 */\n --color-white-rgb-value: 255 255 255; /* #FFFFFF */\n --color-primary: var(--color-accent-600-rgb-value);\n --color-error: var(--color-error-500-rgb-value);\n --color-success: var(--color-success-500-rgb-value);\n --color-warning: var(--color-warning-500-rgb-value);\n --color-deep-blue: var(--color-deep-blue-800-rgb-value);\n --color-light-blue: var(--color-light-blue-200-rgb-value);\n accent-color: var(--color-primary);\n caret-color: red;\n}';
|
|
2650
|
+
const initialState = {
|
|
2004
2651
|
feedbackLayer: null,
|
|
2005
2652
|
overlayLayer: null,
|
|
2006
2653
|
owner: null
|
|
2007
|
-
}, U = me()(
|
|
2008
|
-
// this is important! Otherwise, solid-zustand will start mutating the initial state
|
|
2009
|
-
he(() => structuredClone(ur))
|
|
2010
|
-
), oe = we(U), de = () => {
|
|
2011
2654
|
};
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2655
|
+
const cameraUiRefStore = createStore()(
|
|
2656
|
+
// this is important! Otherwise, solid-zustand will start mutating the initial state
|
|
2657
|
+
subscribeWithSelector(() => structuredClone(initialState))
|
|
2658
|
+
);
|
|
2659
|
+
const cameraUiRefSignalStore = createWithSignal(cameraUiRefStore);
|
|
2660
|
+
const noop = () => void 0;
|
|
2661
|
+
function makeResizeObserver(callback, options) {
|
|
2662
|
+
if (isServer) {
|
|
2663
|
+
return { observe: noop, unobserve: noop };
|
|
2664
|
+
}
|
|
2665
|
+
const observer = new ResizeObserver(callback);
|
|
2666
|
+
onCleanup(observer.disconnect.bind(observer));
|
|
2667
|
+
return {
|
|
2668
|
+
observe: (ref) => observer.observe(ref, options),
|
|
2669
|
+
unobserve: observer.unobserve.bind(observer)
|
|
2019
2670
|
};
|
|
2020
2671
|
}
|
|
2021
|
-
const
|
|
2022
|
-
const
|
|
2023
|
-
let
|
|
2024
|
-
if (
|
|
2025
|
-
const
|
|
2026
|
-
|
|
2672
|
+
const determineFitMode = (Cw, Ch, Vw, Vh) => {
|
|
2673
|
+
const scaleCover = Math.max(Cw / Vw, Ch / Vh);
|
|
2674
|
+
let croppedFraction = 0;
|
|
2675
|
+
if (Cw / Vw > Ch / Vh) {
|
|
2676
|
+
const visible = scaleCover * Vh;
|
|
2677
|
+
croppedFraction = 1 - Ch / visible;
|
|
2027
2678
|
} else {
|
|
2028
|
-
const
|
|
2029
|
-
|
|
2679
|
+
const visible = scaleCover * Vw;
|
|
2680
|
+
croppedFraction = 1 - Cw / visible;
|
|
2681
|
+
}
|
|
2682
|
+
if (croppedFraction < 0.1) {
|
|
2683
|
+
return "cover";
|
|
2684
|
+
} else {
|
|
2685
|
+
return "contain";
|
|
2030
2686
|
}
|
|
2031
|
-
return o < 0.1 ? "cover" : "contain";
|
|
2032
2687
|
};
|
|
2033
|
-
function
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2688
|
+
function getVisibleVideoArea(containerWidth, containerHeight, videoWidth, videoHeight) {
|
|
2689
|
+
const scaleX = containerWidth / videoWidth;
|
|
2690
|
+
const scaleY = containerHeight / videoHeight;
|
|
2691
|
+
const s = Math.max(scaleX, scaleY);
|
|
2692
|
+
if (scaleX >= scaleY) {
|
|
2693
|
+
const visibleNaturalHeight = Math.round(containerHeight / s);
|
|
2694
|
+
const y = Math.round((videoHeight - visibleNaturalHeight) / 2);
|
|
2695
|
+
return { x: 0, y, width: videoWidth, height: visibleNaturalHeight };
|
|
2038
2696
|
} else {
|
|
2039
|
-
const
|
|
2040
|
-
|
|
2697
|
+
const visibleNaturalWidth = Math.round(containerWidth / s);
|
|
2698
|
+
const x = Math.round((videoWidth - visibleNaturalWidth) / 2);
|
|
2699
|
+
return { x, y: 0, width: visibleNaturalWidth, height: videoHeight };
|
|
2041
2700
|
}
|
|
2042
2701
|
}
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2702
|
+
const dialogPositioner = "_dialogPositioner_worsp_1";
|
|
2703
|
+
const dialogBackdrop = "_dialogBackdrop_worsp_5";
|
|
2704
|
+
const dialogContent = "_dialogContent_worsp_9";
|
|
2705
|
+
const large = "_large_worsp_13";
|
|
2706
|
+
const compact = "_compact_worsp_16";
|
|
2707
|
+
const dialogTitle = "_dialogTitle_worsp_30";
|
|
2708
|
+
const contentOut = "_contentOut_worsp_34";
|
|
2709
|
+
const closeButton = "_closeButton_worsp_38";
|
|
2710
|
+
const closeButtonInner = "_closeButtonInner_worsp_44";
|
|
2711
|
+
const primaryActionButton = "_primaryActionButton_worsp_49";
|
|
2712
|
+
const secondaryActionButton = "_secondaryActionButton_worsp_53";
|
|
2713
|
+
const actions = "_actions_worsp_57";
|
|
2714
|
+
const alertTitle = "_alertTitle_worsp_64";
|
|
2715
|
+
const alertText = "_alertText_worsp_68";
|
|
2716
|
+
const styles = {
|
|
2717
|
+
dialogPositioner,
|
|
2718
|
+
dialogBackdrop,
|
|
2719
|
+
dialogContent,
|
|
2720
|
+
large,
|
|
2721
|
+
compact,
|
|
2722
|
+
dialogTitle,
|
|
2723
|
+
contentOut,
|
|
2724
|
+
closeButton,
|
|
2725
|
+
closeButtonInner,
|
|
2726
|
+
primaryActionButton,
|
|
2727
|
+
secondaryActionButton,
|
|
2728
|
+
actions,
|
|
2729
|
+
alertTitle,
|
|
2730
|
+
alertText
|
|
2058
2731
|
};
|
|
2059
|
-
var
|
|
2060
|
-
const
|
|
2061
|
-
const
|
|
2062
|
-
switch (
|
|
2732
|
+
var _tmpl$$1 = /* @__PURE__ */ template(`<span>×`), _tmpl$2$1 = /* @__PURE__ */ template(`<div>`), _tmpl$3$1 = /* @__PURE__ */ template(`<p>`), _tmpl$4 = /* @__PURE__ */ template(`<span>`), _tmpl$5 = /* @__PURE__ */ template(`<div><button></button><button>`);
|
|
2733
|
+
const Modal = (props) => {
|
|
2734
|
+
const getPaddingClass = () => {
|
|
2735
|
+
switch (props.modalStyle) {
|
|
2063
2736
|
case "compact":
|
|
2064
|
-
return
|
|
2737
|
+
return styles.compact;
|
|
2065
2738
|
case "large":
|
|
2066
|
-
return
|
|
2739
|
+
return styles.compact;
|
|
2067
2740
|
case "default":
|
|
2068
2741
|
default:
|
|
2069
|
-
return;
|
|
2742
|
+
return void 0;
|
|
2070
2743
|
}
|
|
2071
2744
|
};
|
|
2072
|
-
return
|
|
2073
|
-
children: () =>
|
|
2074
|
-
onFocusOutside: (
|
|
2075
|
-
onInteractOutside: (
|
|
2076
|
-
restoreFocus:
|
|
2077
|
-
unmountOnExit:
|
|
2078
|
-
lazyMount:
|
|
2079
|
-
},
|
|
2745
|
+
return createComponent(SmartEnvironmentProvider, {
|
|
2746
|
+
children: () => createComponent(Dialog.Root, mergeProps({
|
|
2747
|
+
onFocusOutside: (e) => e.preventDefault(),
|
|
2748
|
+
onInteractOutside: (e) => e.preventDefault(),
|
|
2749
|
+
restoreFocus: true,
|
|
2750
|
+
unmountOnExit: true,
|
|
2751
|
+
lazyMount: true
|
|
2752
|
+
}, props, {
|
|
2080
2753
|
get children() {
|
|
2081
|
-
return
|
|
2754
|
+
return createComponent(Show, {
|
|
2082
2755
|
get when() {
|
|
2083
|
-
return
|
|
2756
|
+
return props.open;
|
|
2084
2757
|
},
|
|
2085
2758
|
get children() {
|
|
2086
|
-
return
|
|
2759
|
+
return createComponent(Portal, {
|
|
2087
2760
|
get mount() {
|
|
2088
|
-
return
|
|
2761
|
+
return props.mountTarget;
|
|
2089
2762
|
},
|
|
2090
2763
|
get children() {
|
|
2091
|
-
return
|
|
2092
|
-
get class() {
|
|
2093
|
-
return
|
|
2764
|
+
return createComponent(Dialog.Positioner, {
|
|
2765
|
+
get ["class"]() {
|
|
2766
|
+
return styles.dialogPositioner;
|
|
2094
2767
|
},
|
|
2095
2768
|
get children() {
|
|
2096
|
-
return [
|
|
2097
|
-
get class() {
|
|
2098
|
-
return
|
|
2769
|
+
return [createComponent(Dialog.Backdrop, {
|
|
2770
|
+
get ["class"]() {
|
|
2771
|
+
return styles.dialogBackdrop;
|
|
2099
2772
|
}
|
|
2100
|
-
}),
|
|
2101
|
-
get class() {
|
|
2102
|
-
return `${
|
|
2773
|
+
}), createComponent(Dialog.Content, {
|
|
2774
|
+
get ["class"]() {
|
|
2775
|
+
return `${styles.dialogContent} ${getPaddingClass()}`;
|
|
2103
2776
|
},
|
|
2104
2777
|
get children() {
|
|
2105
|
-
return [
|
|
2778
|
+
return [createComponent(Show, {
|
|
2106
2779
|
get when() {
|
|
2107
|
-
return
|
|
2780
|
+
return props.showCloseButton;
|
|
2108
2781
|
},
|
|
2109
2782
|
get children() {
|
|
2110
|
-
return
|
|
2111
|
-
get class() {
|
|
2112
|
-
return
|
|
2783
|
+
return createComponent(Dialog.CloseTrigger, {
|
|
2784
|
+
get ["class"]() {
|
|
2785
|
+
return styles.closeButton;
|
|
2113
2786
|
},
|
|
2114
2787
|
get onClick() {
|
|
2115
|
-
return
|
|
2788
|
+
return props.onCloseClicked;
|
|
2116
2789
|
},
|
|
2117
2790
|
get children() {
|
|
2118
|
-
var
|
|
2119
|
-
|
|
2791
|
+
var _el$ = _tmpl$$1();
|
|
2792
|
+
effect(() => className(_el$, styles.closeButtonInner));
|
|
2793
|
+
return _el$;
|
|
2120
2794
|
}
|
|
2121
2795
|
});
|
|
2122
2796
|
}
|
|
2123
|
-
}),
|
|
2797
|
+
}), createComponent(Show, {
|
|
2124
2798
|
get when() {
|
|
2125
|
-
return
|
|
2799
|
+
return props.headerImage;
|
|
2126
2800
|
},
|
|
2127
2801
|
get children() {
|
|
2128
|
-
return
|
|
2802
|
+
return props.headerImage;
|
|
2129
2803
|
}
|
|
2130
|
-
}),
|
|
2804
|
+
}), createComponent(Show, {
|
|
2131
2805
|
get when() {
|
|
2132
|
-
return
|
|
2806
|
+
return props.header;
|
|
2133
2807
|
},
|
|
2134
|
-
children: (
|
|
2135
|
-
get class() {
|
|
2136
|
-
return
|
|
2808
|
+
children: (header) => createComponent(Dialog.Title, {
|
|
2809
|
+
get ["class"]() {
|
|
2810
|
+
return styles.dialogTitle;
|
|
2137
2811
|
},
|
|
2138
2812
|
get children() {
|
|
2139
|
-
return
|
|
2813
|
+
return header();
|
|
2140
2814
|
}
|
|
2141
2815
|
})
|
|
2142
|
-
}),
|
|
2143
|
-
get class() {
|
|
2144
|
-
return
|
|
2816
|
+
}), createComponent(Dialog.Description, {
|
|
2817
|
+
get ["class"]() {
|
|
2818
|
+
return styles.contentOut;
|
|
2145
2819
|
},
|
|
2146
2820
|
get children() {
|
|
2147
|
-
return
|
|
2821
|
+
return props.children;
|
|
2148
2822
|
}
|
|
2149
|
-
}),
|
|
2823
|
+
}), createComponent(Show, {
|
|
2150
2824
|
get when() {
|
|
2151
|
-
return
|
|
2825
|
+
return props.actions;
|
|
2152
2826
|
},
|
|
2153
2827
|
get children() {
|
|
2154
|
-
var
|
|
2155
|
-
|
|
2828
|
+
var _el$2 = _tmpl$2$1();
|
|
2829
|
+
insert(_el$2, () => props.actions);
|
|
2830
|
+
return _el$2;
|
|
2156
2831
|
}
|
|
2157
2832
|
})];
|
|
2158
2833
|
}
|
|
@@ -2166,205 +2841,275 @@ const Dr = (r) => {
|
|
|
2166
2841
|
}
|
|
2167
2842
|
}))
|
|
2168
2843
|
});
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2844
|
+
};
|
|
2845
|
+
const AlertModal = ({
|
|
2846
|
+
mountTarget,
|
|
2847
|
+
header,
|
|
2848
|
+
text,
|
|
2849
|
+
open,
|
|
2850
|
+
onPrimaryClick,
|
|
2851
|
+
onSecondaryClick,
|
|
2852
|
+
primaryButtonText = "Retry",
|
|
2853
|
+
secondaryButtonText = "Cancel"
|
|
2178
2854
|
}) => {
|
|
2179
|
-
let
|
|
2180
|
-
return
|
|
2181
|
-
mountTarget
|
|
2855
|
+
let primaryButtonEl;
|
|
2856
|
+
return createComponent(Modal, {
|
|
2857
|
+
mountTarget,
|
|
2182
2858
|
get header() {
|
|
2183
2859
|
return (() => {
|
|
2184
|
-
var
|
|
2185
|
-
|
|
2860
|
+
var _el$4 = _tmpl$4();
|
|
2861
|
+
insert(_el$4, header);
|
|
2862
|
+
effect(() => className(_el$4, styles.alertTitle));
|
|
2863
|
+
return _el$4;
|
|
2186
2864
|
})();
|
|
2187
2865
|
},
|
|
2188
|
-
initialFocusEl: () =>
|
|
2189
|
-
open
|
|
2866
|
+
initialFocusEl: () => primaryButtonEl,
|
|
2867
|
+
open,
|
|
2190
2868
|
get actions() {
|
|
2191
2869
|
return (() => {
|
|
2192
|
-
var
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2870
|
+
var _el$5 = _tmpl$5(), _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling;
|
|
2871
|
+
_el$6.$$click = () => onSecondaryClick();
|
|
2872
|
+
insert(_el$6, secondaryButtonText);
|
|
2873
|
+
_el$7.$$click = () => onPrimaryClick();
|
|
2874
|
+
var _ref$ = primaryButtonEl;
|
|
2875
|
+
typeof _ref$ === "function" ? use(_ref$, _el$7) : primaryButtonEl = _el$7;
|
|
2876
|
+
insert(_el$7, primaryButtonText);
|
|
2877
|
+
effect((_p$) => {
|
|
2878
|
+
var _v$ = styles.actions, _v$2 = styles.secondaryActionButton, _v$3 = styles.primaryActionButton;
|
|
2879
|
+
_v$ !== _p$.e && className(_el$5, _p$.e = _v$);
|
|
2880
|
+
_v$2 !== _p$.t && className(_el$6, _p$.t = _v$2);
|
|
2881
|
+
_v$3 !== _p$.a && className(_el$7, _p$.a = _v$3);
|
|
2882
|
+
return _p$;
|
|
2198
2883
|
}, {
|
|
2199
2884
|
e: void 0,
|
|
2200
2885
|
t: void 0,
|
|
2201
2886
|
a: void 0
|
|
2202
|
-
})
|
|
2887
|
+
});
|
|
2888
|
+
return _el$5;
|
|
2203
2889
|
})();
|
|
2204
2890
|
},
|
|
2205
2891
|
modalStyle: "compact",
|
|
2206
2892
|
get children() {
|
|
2207
|
-
var
|
|
2208
|
-
|
|
2893
|
+
var _el$3 = _tmpl$3$1();
|
|
2894
|
+
insert(_el$3, text);
|
|
2895
|
+
effect(() => className(_el$3, styles.alertText));
|
|
2896
|
+
return _el$3;
|
|
2209
2897
|
}
|
|
2210
2898
|
});
|
|
2211
2899
|
};
|
|
2212
|
-
|
|
2213
|
-
const
|
|
2900
|
+
delegateEvents(["click"]);
|
|
2901
|
+
const CameraErrorModal = () => {
|
|
2902
|
+
const {
|
|
2903
|
+
t
|
|
2904
|
+
} = useLocalization();
|
|
2214
2905
|
const {
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
return
|
|
2906
|
+
cameraManagerSolidStore,
|
|
2907
|
+
cameraManager,
|
|
2908
|
+
dismountCameraUi
|
|
2909
|
+
} = useCameraUiStore();
|
|
2910
|
+
const errorState = cameraManagerSolidStore((x) => x.errorState);
|
|
2911
|
+
const overlayLayer = cameraUiRefSignalStore((x) => x.overlayLayer);
|
|
2912
|
+
return createComponent(Show, {
|
|
2222
2913
|
get when() {
|
|
2223
|
-
return
|
|
2914
|
+
return errorState();
|
|
2224
2915
|
},
|
|
2225
2916
|
get children() {
|
|
2226
|
-
return
|
|
2917
|
+
return createComponent(AlertModal, {
|
|
2227
2918
|
get mountTarget() {
|
|
2228
|
-
return
|
|
2919
|
+
return overlayLayer();
|
|
2229
2920
|
},
|
|
2230
2921
|
get header() {
|
|
2231
|
-
return
|
|
2922
|
+
return t.camera_error_title;
|
|
2232
2923
|
},
|
|
2233
|
-
open:
|
|
2234
|
-
onPrimaryClick: () => void
|
|
2235
|
-
onSecondaryClick: () =>
|
|
2924
|
+
open: true,
|
|
2925
|
+
onPrimaryClick: () => void cameraManager.startCameraStream(),
|
|
2926
|
+
onSecondaryClick: () => dismountCameraUi(),
|
|
2236
2927
|
get primaryButtonText() {
|
|
2237
|
-
return
|
|
2928
|
+
return t.camera_error_primary_btn;
|
|
2238
2929
|
},
|
|
2239
2930
|
get secondaryButtonText() {
|
|
2240
|
-
return
|
|
2931
|
+
return t.camera_error_cancel_btn;
|
|
2241
2932
|
},
|
|
2242
2933
|
get text() {
|
|
2243
|
-
return
|
|
2934
|
+
return t.camera_error_details;
|
|
2244
2935
|
}
|
|
2245
2936
|
});
|
|
2246
2937
|
}
|
|
2247
2938
|
});
|
|
2248
2939
|
};
|
|
2249
|
-
var
|
|
2250
|
-
const
|
|
2940
|
+
var _tmpl$ = /* @__PURE__ */ template(`<style>`), _tmpl$2 = /* @__PURE__ */ template(`<style id=camera-manager-style>`), _tmpl$3 = /* @__PURE__ */ template(`<div class="bg-dark-500 color-white size-full relative min-h-[300px]"part=capture-screen-part><video part=video-element-part class="block absolute top-0 left-0 size-full"></video><div class="absolute top-0 left-0 w-full h-full z-1"id=feedback-layer></div><div class="absolute top-0 left-0 w-full h-full has-[[data-scope]]:z-2"id=overlay-layer>`);
|
|
2941
|
+
const CAPTURE_SCREEN_SHADOW_ROOT_HOST_ID = "capture-screen-host";
|
|
2942
|
+
const CaptureScreen = () => {
|
|
2251
2943
|
const {
|
|
2252
|
-
cameraManager
|
|
2253
|
-
mountTarget
|
|
2254
|
-
} =
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2944
|
+
cameraManager,
|
|
2945
|
+
mountTarget
|
|
2946
|
+
} = useCameraUiStore();
|
|
2947
|
+
const [videoRef, setVideoRef] = createSignal();
|
|
2948
|
+
const [feedbackRef, setFeedbackRef] = createSignal();
|
|
2949
|
+
const [overlayLayerRef, setOverlayLayerRef] = createSignal();
|
|
2950
|
+
const isPortalled = () => mountTarget.parentNode === document.body;
|
|
2951
|
+
const [fitMode, setFitMode] = createSignal("contain");
|
|
2952
|
+
function adjustVideoFit() {
|
|
2953
|
+
const video = videoRef();
|
|
2954
|
+
if (!video) {
|
|
2258
2955
|
return;
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2956
|
+
}
|
|
2957
|
+
const Cw = video.clientWidth;
|
|
2958
|
+
const Ch = video.clientHeight;
|
|
2959
|
+
const Vw = video.videoWidth;
|
|
2960
|
+
const Vh = video.videoHeight;
|
|
2961
|
+
const newFitMode = determineFitMode(Cw, Ch, Vw, Vh);
|
|
2962
|
+
setFitMode(newFitMode);
|
|
2963
|
+
if (newFitMode === "cover") {
|
|
2964
|
+
const visibleArea = getVisibleVideoArea(Cw, Ch, Vw, Vh);
|
|
2965
|
+
cameraManager.setExtractionArea(visibleArea);
|
|
2966
|
+
} else {
|
|
2967
|
+
cameraManager.setExtractionArea({
|
|
2265
2968
|
x: 0,
|
|
2266
2969
|
y: 0,
|
|
2267
|
-
width:
|
|
2268
|
-
height:
|
|
2970
|
+
width: Vw,
|
|
2971
|
+
height: Vh
|
|
2269
2972
|
});
|
|
2973
|
+
}
|
|
2270
2974
|
}
|
|
2271
|
-
|
|
2272
|
-
const
|
|
2273
|
-
if (!
|
|
2975
|
+
onMount(() => {
|
|
2976
|
+
const video = videoRef();
|
|
2977
|
+
if (!video) {
|
|
2274
2978
|
return;
|
|
2979
|
+
}
|
|
2275
2980
|
const {
|
|
2276
|
-
observe
|
|
2277
|
-
unobserve
|
|
2278
|
-
} =
|
|
2279
|
-
|
|
2280
|
-
|
|
2981
|
+
observe,
|
|
2982
|
+
unobserve
|
|
2983
|
+
} = makeResizeObserver(adjustVideoFit);
|
|
2984
|
+
observe(video);
|
|
2985
|
+
video.addEventListener("loadedmetadata", adjustVideoFit);
|
|
2986
|
+
onCleanup(() => {
|
|
2987
|
+
unobserve(video);
|
|
2988
|
+
video.removeEventListener("loadedmetadata", adjustVideoFit);
|
|
2281
2989
|
});
|
|
2282
|
-
})
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2990
|
+
});
|
|
2991
|
+
onMount(() => {
|
|
2992
|
+
const owner = getOwner();
|
|
2993
|
+
if (!owner) {
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
cameraUiRefSignalStore.setState({
|
|
2997
|
+
owner
|
|
2998
|
+
});
|
|
2999
|
+
});
|
|
3000
|
+
createEffect(() => {
|
|
3001
|
+
const $videoRef = videoRef();
|
|
3002
|
+
const $feedbackRef = feedbackRef();
|
|
3003
|
+
const $overlayLayerRef = overlayLayerRef();
|
|
3004
|
+
if (!$videoRef || !$feedbackRef || !$overlayLayerRef) {
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
cameraUiRefSignalStore.setState({
|
|
3008
|
+
feedbackLayer: $feedbackRef,
|
|
3009
|
+
overlayLayer: $overlayLayerRef
|
|
2286
3010
|
});
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
feedbackLayer: h,
|
|
2291
|
-
overlayLayer: p
|
|
2292
|
-
}), r.initVideoElement(u));
|
|
2293
|
-
}), s(ir, {
|
|
3011
|
+
cameraManager.initVideoElement($videoRef);
|
|
3012
|
+
});
|
|
3013
|
+
return createComponent(SolidShadowRoot, {
|
|
2294
3014
|
get id() {
|
|
2295
|
-
return
|
|
3015
|
+
return !isPortalled() ? CAPTURE_SCREEN_SHADOW_ROOT_HOST_ID : void 0;
|
|
2296
3016
|
},
|
|
2297
3017
|
get disableShadowRoot() {
|
|
2298
|
-
return
|
|
3018
|
+
return isPortalled();
|
|
2299
3019
|
},
|
|
2300
3020
|
get style() {
|
|
2301
|
-
return
|
|
3021
|
+
return isPortalled() ? {
|
|
2302
3022
|
height: "100%"
|
|
2303
3023
|
} : void 0;
|
|
2304
3024
|
},
|
|
2305
3025
|
get children() {
|
|
2306
3026
|
return [(() => {
|
|
2307
|
-
var
|
|
2308
|
-
|
|
3027
|
+
var _el$ = _tmpl$();
|
|
3028
|
+
insert(_el$, variables);
|
|
3029
|
+
return _el$;
|
|
2309
3030
|
})(), (() => {
|
|
2310
|
-
var
|
|
2311
|
-
|
|
3031
|
+
var _el$2 = _tmpl$();
|
|
3032
|
+
insert(_el$2, normalize);
|
|
3033
|
+
return _el$2;
|
|
2312
3034
|
})(), (() => {
|
|
2313
|
-
var
|
|
2314
|
-
|
|
3035
|
+
var _el$3 = _tmpl$();
|
|
3036
|
+
insert(_el$3, rootStyles);
|
|
3037
|
+
return _el$3;
|
|
2315
3038
|
})(), (() => {
|
|
2316
|
-
var
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
3039
|
+
var _el$4 = _tmpl$2();
|
|
3040
|
+
use((ref) => {
|
|
3041
|
+
if (window.__mbCameraManagerCssCode) {
|
|
3042
|
+
ref.innerHTML = window.__mbCameraManagerCssCode;
|
|
3043
|
+
}
|
|
3044
|
+
}, _el$4);
|
|
3045
|
+
return _el$4;
|
|
2320
3046
|
})(), (() => {
|
|
2321
|
-
var
|
|
2322
|
-
|
|
3047
|
+
var _el$5 = _tmpl$3(), _el$6 = _el$5.firstChild, _el$7 = _el$6.nextSibling, _el$8 = _el$7.nextSibling;
|
|
3048
|
+
insert(_el$5, createComponent(Header, {}), _el$6);
|
|
3049
|
+
use(setVideoRef, _el$6);
|
|
3050
|
+
use(setFeedbackRef, _el$7);
|
|
3051
|
+
use(setOverlayLayerRef, _el$8);
|
|
3052
|
+
insert(_el$5, createComponent(CameraErrorModal, {}), null);
|
|
3053
|
+
effect((_$p) => (_$p = fitMode()) != null ? _el$6.style.setProperty("object-fit", _$p) : _el$6.style.removeProperty("object-fit"));
|
|
3054
|
+
return _el$5;
|
|
2323
3055
|
})()];
|
|
2324
3056
|
}
|
|
2325
3057
|
});
|
|
2326
|
-
}
|
|
3058
|
+
};
|
|
3059
|
+
const CaptureScreenPortalled = () => {
|
|
3060
|
+
const {
|
|
3061
|
+
t
|
|
3062
|
+
} = useLocalization();
|
|
3063
|
+
const [isOpen, setIsOpen] = createSignal(true);
|
|
2327
3064
|
const {
|
|
2328
|
-
|
|
2329
|
-
} =
|
|
2330
|
-
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
useShadow: !0,
|
|
3065
|
+
addOnDismountCallback
|
|
3066
|
+
} = useCameraUiStore();
|
|
3067
|
+
addOnDismountCallback(() => {
|
|
3068
|
+
setIsOpen(false);
|
|
3069
|
+
});
|
|
3070
|
+
return createComponent(Portal, {
|
|
3071
|
+
useShadow: true,
|
|
2336
3072
|
get mount() {
|
|
2337
|
-
return document.getElementById(
|
|
3073
|
+
return document.getElementById(MOUNT_POINT_ID);
|
|
3074
|
+
},
|
|
3075
|
+
ref: (ref) => {
|
|
3076
|
+
ref.id = CAPTURE_SCREEN_SHADOW_ROOT_HOST_ID;
|
|
3077
|
+
ref.style.zIndex = "1000";
|
|
3078
|
+
ref.style.position = "fixed";
|
|
3079
|
+
ref.id = "mb-camera-host";
|
|
3080
|
+
return ref;
|
|
2338
3081
|
},
|
|
2339
|
-
ref: (n) => (n.id = ze, n.style.zIndex = "1000", n.style.position = "fixed", n.id = "mb-camera-host", n),
|
|
2340
3082
|
get children() {
|
|
2341
|
-
return
|
|
2342
|
-
children: (
|
|
3083
|
+
return createComponent(SmartEnvironmentProvider, {
|
|
3084
|
+
children: (rootNode) => createComponent(Dialog.Root, {
|
|
2343
3085
|
get open() {
|
|
2344
|
-
return
|
|
3086
|
+
return isOpen();
|
|
2345
3087
|
},
|
|
2346
|
-
lazyMount:
|
|
2347
|
-
unmountOnExit:
|
|
3088
|
+
lazyMount: true,
|
|
3089
|
+
unmountOnExit: true,
|
|
2348
3090
|
initialFocusEl: () => {
|
|
2349
|
-
const
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
3091
|
+
const dummyNode = document.createElement("div");
|
|
3092
|
+
dummyNode.tabIndex = -1;
|
|
3093
|
+
rootNode.appendChild(dummyNode);
|
|
3094
|
+
setTimeout(() => {
|
|
3095
|
+
dummyNode.remove();
|
|
3096
|
+
}, 0);
|
|
3097
|
+
return dummyNode;
|
|
2353
3098
|
},
|
|
2354
3099
|
get children() {
|
|
2355
|
-
return
|
|
3100
|
+
return createComponent(Dialog.Positioner, {
|
|
2356
3101
|
get children() {
|
|
2357
|
-
return
|
|
3102
|
+
return createComponent(Dialog.Content, {
|
|
2358
3103
|
"aria-labelledby": "dialog-title",
|
|
2359
|
-
class: "h-vh supports-[(height:100dvh)]:h-dvh top-0 left-0 w-full fixed",
|
|
3104
|
+
"class": "h-vh supports-[(height:100dvh)]:h-dvh top-0 left-0 w-full fixed",
|
|
2360
3105
|
get children() {
|
|
2361
|
-
return [
|
|
2362
|
-
class: "sr-only",
|
|
3106
|
+
return [createComponent(Dialog.Title, {
|
|
3107
|
+
"class": "sr-only",
|
|
2363
3108
|
id: "dialog-title",
|
|
2364
3109
|
get children() {
|
|
2365
|
-
return
|
|
3110
|
+
return t.scan_document;
|
|
2366
3111
|
}
|
|
2367
|
-
}),
|
|
3112
|
+
}), createComponent(CaptureScreen, {})];
|
|
2368
3113
|
}
|
|
2369
3114
|
});
|
|
2370
3115
|
}
|
|
@@ -2374,65 +3119,89 @@ const ze = "capture-screen-host", Le = () => {
|
|
|
2374
3119
|
});
|
|
2375
3120
|
}
|
|
2376
3121
|
});
|
|
2377
|
-
}
|
|
3122
|
+
};
|
|
3123
|
+
const RootComponent = () => {
|
|
2378
3124
|
const {
|
|
2379
|
-
mountTarget
|
|
2380
|
-
} =
|
|
2381
|
-
return
|
|
3125
|
+
mountTarget
|
|
3126
|
+
} = useCameraUiStore();
|
|
3127
|
+
return createComponent(Dynamic, {
|
|
2382
3128
|
get component() {
|
|
2383
|
-
return
|
|
3129
|
+
return mountTarget.parentNode === document.body ? CaptureScreenPortalled : CaptureScreen;
|
|
2384
3130
|
}
|
|
2385
3131
|
});
|
|
2386
|
-
}
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
3132
|
+
};
|
|
3133
|
+
const MOUNT_POINT_ID = "camera-manager-mount-point";
|
|
3134
|
+
function createCameraManagerUi(cameraManager, target, {
|
|
3135
|
+
localizationStrings,
|
|
3136
|
+
showMirrorCameraButton = false,
|
|
3137
|
+
showTorchButton = true,
|
|
3138
|
+
showCloseButton = true
|
|
2390
3139
|
} = {}) {
|
|
2391
|
-
let
|
|
2392
|
-
const
|
|
2393
|
-
let
|
|
2394
|
-
const
|
|
2395
|
-
|
|
2396
|
-
}, c = () => {
|
|
2397
|
-
r.reset();
|
|
3140
|
+
let mountTarget;
|
|
3141
|
+
const dismountCallbacks = /* @__PURE__ */ new Set();
|
|
3142
|
+
let updateLocalizationRef;
|
|
3143
|
+
const setLocalizationRef = (setter) => {
|
|
3144
|
+
updateLocalizationRef = setter;
|
|
2398
3145
|
};
|
|
2399
|
-
|
|
2400
|
-
|
|
3146
|
+
const cleanupCameraManager = () => {
|
|
3147
|
+
cameraManager.reset();
|
|
3148
|
+
};
|
|
3149
|
+
let dismountRef;
|
|
3150
|
+
const dismountCameraManagerUi = () => {
|
|
2401
3151
|
try {
|
|
2402
3152
|
console.debug("🧱 Dismounting camera manager UI");
|
|
2403
|
-
for (const
|
|
2404
|
-
|
|
2405
|
-
|
|
3153
|
+
for (const callback of dismountCallbacks) {
|
|
3154
|
+
callback();
|
|
3155
|
+
}
|
|
3156
|
+
dismountCallbacks.clear();
|
|
3157
|
+
cleanupCameraManager();
|
|
3158
|
+
requestAnimationFrame(() => {
|
|
2406
3159
|
requestAnimationFrame(() => {
|
|
2407
|
-
|
|
3160
|
+
if (dismountRef) {
|
|
3161
|
+
dismountRef();
|
|
3162
|
+
}
|
|
3163
|
+
mountTarget.remove();
|
|
3164
|
+
cleanupCameraManager();
|
|
2408
3165
|
});
|
|
2409
3166
|
});
|
|
2410
|
-
} catch (
|
|
2411
|
-
console.warn("Error while dismounting camera manager UI",
|
|
3167
|
+
} catch (e) {
|
|
3168
|
+
console.warn("Error while dismounting camera manager UI", e);
|
|
2412
3169
|
}
|
|
2413
|
-
}
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
3170
|
+
};
|
|
3171
|
+
const newMountTarget = document.createElement("div");
|
|
3172
|
+
newMountTarget.id = MOUNT_POINT_ID;
|
|
3173
|
+
mountTarget = newMountTarget;
|
|
3174
|
+
if (target) {
|
|
3175
|
+
target.appendChild(newMountTarget);
|
|
3176
|
+
} else {
|
|
3177
|
+
document.body.appendChild(newMountTarget);
|
|
3178
|
+
}
|
|
3179
|
+
const addOnDismountCallback = (fn) => {
|
|
3180
|
+
dismountCallbacks.add(fn);
|
|
3181
|
+
return () => {
|
|
3182
|
+
dismountCallbacks.delete(fn);
|
|
3183
|
+
};
|
|
3184
|
+
};
|
|
3185
|
+
dismountRef = render(() => createComponent(LocalizationProvider, {
|
|
3186
|
+
userStrings: localizationStrings,
|
|
3187
|
+
setLocalizationRef,
|
|
2421
3188
|
get children() {
|
|
2422
|
-
return
|
|
2423
|
-
addOnDismountCallback
|
|
2424
|
-
dismountCameraUi:
|
|
2425
|
-
cameraManager
|
|
2426
|
-
showMirrorCameraButton
|
|
2427
|
-
|
|
3189
|
+
return createComponent(CameraUiStoreProvider, {
|
|
3190
|
+
addOnDismountCallback,
|
|
3191
|
+
dismountCameraUi: dismountCameraManagerUi,
|
|
3192
|
+
cameraManager,
|
|
3193
|
+
showMirrorCameraButton,
|
|
3194
|
+
showTorchButton,
|
|
3195
|
+
showCloseButton,
|
|
3196
|
+
mountTarget,
|
|
2428
3197
|
get children() {
|
|
2429
|
-
return
|
|
3198
|
+
return createComponent(RootComponent, {});
|
|
2430
3199
|
}
|
|
2431
3200
|
});
|
|
2432
3201
|
}
|
|
2433
|
-
}),
|
|
2434
|
-
const
|
|
2435
|
-
updateLocalization:
|
|
3202
|
+
}), mountTarget);
|
|
3203
|
+
const exposedComponentApi = {
|
|
3204
|
+
updateLocalization: updateLocalizationRef,
|
|
2436
3205
|
/**
|
|
2437
3206
|
* Adds a callback to be called when the component is unmounted.
|
|
2438
3207
|
* Returns a cleanup function that removes the callback when called.
|
|
@@ -2440,64 +3209,88 @@ function Yr(r, e, {
|
|
|
2440
3209
|
* @param fn - The callback function to be called when the component is unmounted
|
|
2441
3210
|
* @returns A cleanup function that removes the callback when called
|
|
2442
3211
|
*/
|
|
2443
|
-
addOnDismountCallback
|
|
2444
|
-
cameraManager
|
|
3212
|
+
addOnDismountCallback,
|
|
3213
|
+
cameraManager,
|
|
2445
3214
|
// we know these are defined because `createCameraManagerUi` resolves when they are defined
|
|
2446
3215
|
// TODO: maybe don't use getters but make sure they are defined
|
|
2447
3216
|
get feedbackLayerNode() {
|
|
2448
|
-
return
|
|
3217
|
+
return cameraUiRefStore.getState().feedbackLayer;
|
|
2449
3218
|
},
|
|
2450
3219
|
get overlayLayerNode() {
|
|
2451
|
-
return
|
|
3220
|
+
return cameraUiRefStore.getState().overlayLayer;
|
|
2452
3221
|
},
|
|
2453
3222
|
get owner() {
|
|
2454
|
-
return
|
|
3223
|
+
return cameraUiRefStore.getState().owner;
|
|
2455
3224
|
},
|
|
2456
|
-
dismount:
|
|
3225
|
+
dismount: dismountCameraManagerUi
|
|
2457
3226
|
};
|
|
2458
|
-
return new Promise((
|
|
2459
|
-
let
|
|
2460
|
-
|
|
2461
|
-
|
|
3227
|
+
return new Promise((resolve) => {
|
|
3228
|
+
let videoExists = false;
|
|
3229
|
+
let feedbackExists = false;
|
|
3230
|
+
let overlayExists = false;
|
|
3231
|
+
let unsubscribeFeedbackLayer = () => {
|
|
3232
|
+
};
|
|
3233
|
+
let unsubscribeOverlayLayer = () => {
|
|
3234
|
+
};
|
|
3235
|
+
let unsubscribeVideo = () => {
|
|
2462
3236
|
};
|
|
2463
|
-
const
|
|
2464
|
-
|
|
3237
|
+
const checkReady = () => {
|
|
3238
|
+
if (videoExists && feedbackExists && overlayExists) {
|
|
3239
|
+
unsubscribeFeedbackLayer();
|
|
3240
|
+
unsubscribeOverlayLayer();
|
|
3241
|
+
unsubscribeVideo();
|
|
3242
|
+
resolve(exposedComponentApi);
|
|
3243
|
+
}
|
|
2465
3244
|
};
|
|
2466
|
-
|
|
2467
|
-
|
|
3245
|
+
unsubscribeFeedbackLayer = cameraUiRefStore.subscribe((x) => x.feedbackLayer, (feedbackLayer) => {
|
|
3246
|
+
if (feedbackLayer) {
|
|
3247
|
+
feedbackExists = true;
|
|
3248
|
+
}
|
|
3249
|
+
checkReady();
|
|
2468
3250
|
}, {
|
|
2469
|
-
fireImmediately:
|
|
2470
|
-
})
|
|
2471
|
-
|
|
3251
|
+
fireImmediately: true
|
|
3252
|
+
});
|
|
3253
|
+
unsubscribeOverlayLayer = cameraUiRefStore.subscribe((x) => x.overlayLayer, (overlayLayer) => {
|
|
3254
|
+
if (overlayLayer) {
|
|
3255
|
+
overlayExists = true;
|
|
3256
|
+
}
|
|
3257
|
+
checkReady();
|
|
2472
3258
|
}, {
|
|
2473
|
-
fireImmediately:
|
|
2474
|
-
})
|
|
2475
|
-
|
|
3259
|
+
fireImmediately: true
|
|
3260
|
+
});
|
|
3261
|
+
unsubscribeVideo = cameraManager.subscribe((state) => state.videoElement, (videoElement) => {
|
|
3262
|
+
if (videoElement) {
|
|
3263
|
+
videoExists = true;
|
|
3264
|
+
checkReady();
|
|
3265
|
+
}
|
|
2476
3266
|
}, {
|
|
2477
|
-
fireImmediately:
|
|
3267
|
+
fireImmediately: true
|
|
2478
3268
|
});
|
|
2479
3269
|
});
|
|
2480
3270
|
}
|
|
2481
|
-
const
|
|
2482
|
-
globalThis.__CAMERA_MANAGER__ ||=
|
|
2483
|
-
globalThis.__CAMERA_MANAGER__ !==
|
|
2484
|
-
|
|
2485
|
-
|
|
3271
|
+
const testSymbol = Symbol();
|
|
3272
|
+
globalThis.__CAMERA_MANAGER__ ||= testSymbol;
|
|
3273
|
+
if (globalThis.__CAMERA_MANAGER__ !== testSymbol) {
|
|
3274
|
+
console.warn(
|
|
3275
|
+
"Detected multiple instances of @microblink/camera-manager. This can lead to unexpected behavior."
|
|
3276
|
+
);
|
|
3277
|
+
}
|
|
2486
3278
|
export {
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
3279
|
+
Camera,
|
|
3280
|
+
CameraManager,
|
|
3281
|
+
MOUNT_POINT_ID,
|
|
3282
|
+
VideoFrameProcessor,
|
|
3283
|
+
cameraManagerStore,
|
|
3284
|
+
cameraUiRefStore,
|
|
3285
|
+
createCameraManagerUi,
|
|
3286
|
+
defaultCameraManagerOptions,
|
|
3287
|
+
findResolutionKey,
|
|
3288
|
+
getBuffer,
|
|
3289
|
+
getNormalizedResolution,
|
|
3290
|
+
isBufferDetached,
|
|
3291
|
+
matchClosestResolution,
|
|
3292
|
+
resetCameraManagerStore,
|
|
3293
|
+
returnLongerSide,
|
|
3294
|
+
videoResolutions
|
|
2503
3295
|
};
|
|
3296
|
+
//# sourceMappingURL=camera-manager.js.map
|