Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lilregie/svelte-scanner

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lilregie/svelte-scanner - npm Package Compare versions

Comparing version 0.3.0 to 0.4.0

.svelte-kit/__package__/BarcodeDetector.d.ts

8

.svelte-kit/ambient.d.ts

@@ -76,3 +76,2 @@

export const XDG_SESSION_DESKTOP: string;
export const QT_QPA_PLATFORMTHEME: string;
export const XDG_SESSION_TYPE: string;

@@ -152,4 +151,5 @@ export const BUNDLER_EDITOR: string;

export const npm_package_json: string;
export const npm_package_dependencies_esm_env: string;
export const npm_package_scripts_dev: string;
export const QT_AUTO_SCREEN_SCALE_FACTOR: string;
export const GTK3_MODULES: string;
export const XDG_DATA_DIRS: string;

@@ -254,3 +254,2 @@ export const npm_package_scripts_check: string;

XDG_SESSION_DESKTOP: string;
QT_QPA_PLATFORMTHEME: string;
XDG_SESSION_TYPE: string;

@@ -330,4 +329,5 @@ BUNDLER_EDITOR: string;

npm_package_json: string;
npm_package_dependencies_esm_env: string;
npm_package_scripts_dev: string;
QT_AUTO_SCREEN_SCALE_FACTOR: string;
GTK3_MODULES: string;
XDG_DATA_DIRS: string;

@@ -334,0 +334,0 @@ npm_package_scripts_check: string;

@@ -13,3 +13,3 @@ export const manifest = (() => {

_: {
client: {"start":"_app/immutable/entry/start.c049c1e6.js","app":"_app/immutable/entry/app.9a0a056d.js","imports":["_app/immutable/entry/start.c049c1e6.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.61e526f0.js","_app/immutable/chunks/index.80931a4d.js","_app/immutable/entry/app.9a0a056d.js","_app/immutable/chunks/preload-helper.cf010ec4.js","_app/immutable/chunks/index.2ff190cb.js"],"stylesheets":[],"fonts":[]},
client: {"start":"_app/immutable/entry/start.a5edc127.js","app":"_app/immutable/entry/app.f33ac3b1.js","imports":["_app/immutable/entry/start.a5edc127.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.8c56ca7e.js","_app/immutable/chunks/index.80931a4d.js","_app/immutable/entry/app.f33ac3b1.js","_app/immutable/chunks/preload-helper.a4192956.js","_app/immutable/chunks/index.2ff190cb.js"],"stylesheets":[],"fonts":[]},
nodes: [

@@ -16,0 +16,0 @@ __memo(() => import('../output/server/nodes/0.js')),

@@ -1,1 +0,1 @@

{"version":"1689213455724"}
{"version":"1694052905402"}

@@ -23,3 +23,3 @@

},
version_hash: "zsb5va"
version_hash: "1gu6ktu"
};

@@ -26,0 +26,0 @@

@@ -1,1 +0,1 @@

{"version":"1689213455724"}
{"version":"1694052905402"}

@@ -174,3 +174,3 @@ import { c as create_ssr_component, s as setContext, v as validate_component, m as missing_component } from "./index2.js";

},
version_hash: "zsb5va"
version_hash: "1gu6ktu"
};

@@ -177,0 +177,0 @@ function get_hooks() {

@@ -175,3 +175,3 @@ import { o as onDestroy, c as create_ssr_component, b as createEventDispatcher, e as escape, d as add_attribute, f as each, h as spread, i as escape_object, j as escape_attribute_value, v as validate_component, k as compute_slots, a as subscribe } from "../../chunks/index2.js";

const css$4 = {
code: ".svelte-select.svelte-apvs86.svelte-apvs86.svelte-apvs86{--borderRadius:var(--border-radius);--clearSelectColor:var(--clear-select-color);--clearSelectWidth:var(--clear-select-width);--disabledBackground:var(--disabled-background);--disabledBorderColor:var(--disabled-border-color);--disabledColor:var(--disabled-color);--disabledPlaceholderColor:var(--disabled-placeholder-color);--disabledPlaceholderOpacity:var(--disabled-placeholder-opacity);--errorBackground:var(--error-background);--errorBorder:var(--error-border);--groupItemPaddingLeft:var(--group-item-padding-left);--groupTitleColor:var(--group-title-color);--groupTitleFontSize:var(--group-title-font-size);--groupTitleFontWeight:var(--group-title-font-weight);--groupTitlePadding:var(--group-title-padding);--groupTitleTextTransform:var(--group-title-text-transform);--indicatorColor:var(--chevron-color);--indicatorHeight:var(--chevron-height);--indicatorWidth:var(--chevron-width);--inputColor:var(--input-color);--inputLeft:var(--input-left);--inputLetterSpacing:var(--input-letter-spacing);--inputMargin:var(--input-margin);--inputPadding:var(--input-padding);--itemActiveBackground:var(--item-active-background);--itemColor:var(--item-color);--itemFirstBorderRadius:var(--item-first-border-radius);--itemHoverBG:var(--item-hover-bg);--itemHoverColor:var(--item-hover-color);--itemIsActiveBG:var(--item-is-active-bg);--itemIsActiveColor:var(--item-is-active-color);--itemIsNotSelectableColor:var(--item-is-not-selectable-color);--itemPadding:var(--item-padding);--listBackground:var(--list-background);--listBorder:var(--list-border);--listBorderRadius:var(--list-border-radius);--listEmptyColor:var(--list-empty-color);--listEmptyPadding:var(--list-empty-padding);--listEmptyTextAlign:var(--list-empty-text-align);--listMaxHeight:var(--list-max-height);--listPosition:var(--list-position);--listShadow:var(--list-shadow);--listZIndex:var(--list-z-index);--multiItemBG:var(--multi-item-bg);--multiItemBorderRadius:var(--multi-item-border-radius);--multiItemDisabledHoverBg:var(--multi-item-disabled-hover-bg);--multiItemDisabledHoverColor:var(--multi-item-disabled-hover-color);--multiItemHeight:var(--multi-item-height);--multiItemMargin:var(--multi-item-margin);--multiItemPadding:var(--multi-item-padding);--multiSelectInputMargin:var(--multi-select-input-margin);--multiSelectInputPadding:var(--multi-select-input-padding);--multiSelectPadding:var(--multi-select-padding);--placeholderColor:var(--placeholder-color);--placeholderOpacity:var(--placeholder-opacity);--selectedItemPadding:var(--selected-item-padding);--spinnerColor:var(--spinner-color);--spinnerHeight:var(--spinner-height);--spinnerWidth:var(--spinner-width);--internal-padding:0 0 0 16px;border:var(--border, 1px solid #d8dbdf);border-radius:var(--border-radius, 6px);min-height:var(--height, 42px);position:relative;display:flex;align-items:stretch;padding:var(--padding, var(--internal-padding));background:var(--background, #fff);margin:var(--margin, 0);width:var(--width, 100%);font-size:var(--font-size, 16px);max-height:var(--max-height)}.svelte-apvs86.svelte-apvs86.svelte-apvs86{box-sizing:var(--box-sizing, border-box)}.svelte-select.svelte-apvs86.svelte-apvs86.svelte-apvs86:hover{border:var(--border-hover, 1px solid #b2b8bf)}.value-container.svelte-apvs86.svelte-apvs86.svelte-apvs86{display:flex;flex:1 1 0%;flex-wrap:wrap;align-items:center;gap:5px 10px;padding:var(--value-container-padding, 5px 0);position:relative;overflow:var(--value-container-overflow, hidden);align-self:stretch}.prepend.svelte-apvs86.svelte-apvs86.svelte-apvs86,.indicators.svelte-apvs86.svelte-apvs86.svelte-apvs86{display:flex;flex-shrink:0;align-items:center}.indicators.svelte-apvs86.svelte-apvs86.svelte-apvs86{position:var(--indicators-position);top:var(--indicators-top);right:var(--indicators-right);bottom:var(--indicators-bottom)}input.svelte-apvs86.svelte-apvs86.svelte-apvs86{position:absolute;cursor:default;border:none;color:var(--input-color, var(--item-color));padding:var(--input-padding, 0);letter-spacing:var(--input-letter-spacing, inherit);margin:var(--input-margin, 0);min-width:10px;top:0;right:0;bottom:0;left:0;background:transparent;font-size:var(--font-size, 16px)}.svelte-apvs86:not(.multi)>.value-container.svelte-apvs86>input.svelte-apvs86{width:100%;height:100%}input.svelte-apvs86.svelte-apvs86.svelte-apvs86::placeholder{color:var(--placeholder-color, #78848f);opacity:var(--placeholder-opacity, 1)}input.svelte-apvs86.svelte-apvs86.svelte-apvs86:focus{outline:none}.svelte-select.focused.svelte-apvs86.svelte-apvs86.svelte-apvs86{border:var(--border-focused, 1px solid #006fe8);border-radius:var(--border-radius-focused, var(--border-radius, 6px))}.disabled.svelte-apvs86.svelte-apvs86.svelte-apvs86{background:var(--disabled-background, #ebedef);border-color:var(--disabled-border-color, #ebedef);color:var(--disabled-color, #c1c6cc)}.disabled.svelte-apvs86 input.svelte-apvs86.svelte-apvs86::placeholder{color:var(--disabled-placeholder-color, #c1c6cc);opacity:var(--disabled-placeholder-opacity, 1)}.selected-item.svelte-apvs86.svelte-apvs86.svelte-apvs86{position:relative;overflow:var(--selected-item-overflow, hidden);padding:var(--selected-item-padding, 0 20px 0 0);text-overflow:ellipsis;white-space:nowrap;color:var(--selected-item-color, inherit);font-size:var(--font-size, 16px)}.multi.svelte-apvs86 .selected-item.svelte-apvs86.svelte-apvs86{position:absolute;line-height:var(--height, 42px);height:var(--height, 42px)}.selected-item.svelte-apvs86.svelte-apvs86.svelte-apvs86:focus{outline:none}.hide-selected-item.svelte-apvs86.svelte-apvs86.svelte-apvs86{opacity:0}.icon.svelte-apvs86.svelte-apvs86.svelte-apvs86{display:flex;align-items:center;justify-content:center}.clear-select.svelte-apvs86.svelte-apvs86.svelte-apvs86{all:unset;display:flex;align-items:center;justify-content:center;width:var(--clear-select-width, 40px);height:var(--clear-select-height, 100%);color:var(--clear-select-color, var(--icons-color));margin:var(--clear-select-margin, 0);pointer-events:all;flex-shrink:0}.clear-select.svelte-apvs86.svelte-apvs86.svelte-apvs86:focus{outline:var(--clear-select-focus-outline, 1px solid #006fe8)}.loading.svelte-apvs86.svelte-apvs86.svelte-apvs86{width:var(--loading-width, 40px);height:var(--loading-height);color:var(--loading-color, var(--icons-color));margin:var(--loading--margin, 0);flex-shrink:0}.chevron.svelte-apvs86.svelte-apvs86.svelte-apvs86{width:var(--chevron-width, 40px);height:var(--chevron-height, 40px);background:var(--chevron-background, transparent);pointer-events:var(--chevron-pointer-events, none);color:var(--chevron-color, var(--icons-color));border:var(--chevron-border, 0 0 0 1px solid #d8dbdf);flex-shrink:0}.multi.svelte-apvs86.svelte-apvs86.svelte-apvs86{padding:var(--multi-select-padding, var(--internal-padding))}.multi.svelte-apvs86 input.svelte-apvs86.svelte-apvs86{padding:var(--multi-select-input-padding, 0);position:relative;margin:var(--multi-select-input-margin, 5px 0);flex:1 1 40px}.svelte-select.error.svelte-apvs86.svelte-apvs86.svelte-apvs86{border:var(--error-border, 1px solid #ff2d55);background:var(--error-background, #fff)}.a11y-text.svelte-apvs86.svelte-apvs86.svelte-apvs86{z-index:9999;border:0px;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0px;white-space:nowrap}.multi-item.svelte-apvs86.svelte-apvs86.svelte-apvs86{background:var(--multi-item-bg, #ebedef);margin:var(--multi-item-margin, 0);outline:var(--multi-item-outline, 1px solid #ddd);border-radius:var(--multi-item-border-radius, 4px);height:var(--multi-item-height, 25px);line-height:var(--multi-item-height, 25px);display:flex;cursor:default;padding:var(--multi-item-padding, 0 5px);overflow:hidden;gap:var(--multi-item-gap, 4px);outline-offset:-1px;max-width:var(--multi-max-width, none);color:var(--multi-item-color, var(--item-color))}.multi-item.disabled.svelte-apvs86.svelte-apvs86.svelte-apvs86:hover{background:var(--multi-item-disabled-hover-bg, #ebedef);color:var(--multi-item-disabled-hover-color, #c1c6cc)}.multi-item-text.svelte-apvs86.svelte-apvs86.svelte-apvs86{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.multi-item-clear.svelte-apvs86.svelte-apvs86.svelte-apvs86{display:flex;align-items:center;justify-content:center;--clear-icon-color:var(--multi-item-clear-icon-color, #000)}.multi-item.active.svelte-apvs86.svelte-apvs86.svelte-apvs86{outline:var(--multi-item-active-outline, 1px solid #006fe8)}.svelte-select-list.svelte-apvs86.svelte-apvs86.svelte-apvs86{box-shadow:var(--list-shadow, 0 2px 3px 0 rgba(44, 62, 80, 0.24));border-radius:var(--list-border-radius, 4px);max-height:var(--list-max-height, 252px);overflow-y:auto;background:var(--list-background, #fff);position:var(--list-position, absolute);z-index:var(--list-z-index, 2);border:var(--list-border)}.prefloat.svelte-apvs86.svelte-apvs86.svelte-apvs86{opacity:0;pointer-events:none}.list-group-title.svelte-apvs86.svelte-apvs86.svelte-apvs86{color:var(--group-title-color, #8f8f8f);cursor:default;font-size:var(--group-title-font-size, 16px);font-weight:var(--group-title-font-weight, 600);height:var(--height, 42px);line-height:var(--height, 42px);padding:var(--group-title-padding, 0 20px);text-overflow:ellipsis;overflow-x:hidden;white-space:nowrap;text-transform:var(--group-title-text-transform, uppercase)}.empty.svelte-apvs86.svelte-apvs86.svelte-apvs86{text-align:var(--list-empty-text-align, center);padding:var(--list-empty-padding, 20px 0);color:var(--list-empty-color, #78848f)}.item.svelte-apvs86.svelte-apvs86.svelte-apvs86{cursor:default;height:var(--item-height, var(--height, 42px));line-height:var(--item-line-height, var(--height, 42px));padding:var(--item-padding, 0 20px);color:var(--item-color, inherit);text-overflow:ellipsis;overflow:hidden;white-space:nowrap;transition:var(--item-transition, all 0.2s);align-items:center;width:100%}.item.group-item.svelte-apvs86.svelte-apvs86.svelte-apvs86{padding-left:var(--group-item-padding-left, 40px)}.item.svelte-apvs86.svelte-apvs86.svelte-apvs86:active{background:var(--item-active-background, #b9daff)}.item.active.svelte-apvs86.svelte-apvs86.svelte-apvs86{background:var(--item-is-active-bg, #007aff);color:var(--item-is-active-color, #fff)}.item.first.svelte-apvs86.svelte-apvs86.svelte-apvs86{border-radius:var(--item-first-border-radius, 4px 4px 0 0)}.item.hover.svelte-apvs86.svelte-apvs86.svelte-apvs86:not(.active){background:var(--item-hover-bg, #e7f2ff);color:var(--item-hover-color, inherit)}.item.not-selectable.svelte-apvs86.svelte-apvs86.svelte-apvs86,.item.hover.item.not-selectable.svelte-apvs86.svelte-apvs86.svelte-apvs86,.item.active.item.not-selectable.svelte-apvs86.svelte-apvs86.svelte-apvs86,.item.not-selectable.svelte-apvs86.svelte-apvs86.svelte-apvs86:active{color:var(--item-is-not-selectable-color, #999);background:transparent}.required.svelte-apvs86.svelte-apvs86.svelte-apvs86{opacity:0;z-index:-1;position:absolute;top:0;left:0;bottom:0;right:0}",
code: ".svelte-select.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{--borderRadius:var(--border-radius);--clearSelectColor:var(--clear-select-color);--clearSelectWidth:var(--clear-select-width);--disabledBackground:var(--disabled-background);--disabledBorderColor:var(--disabled-border-color);--disabledColor:var(--disabled-color);--disabledPlaceholderColor:var(--disabled-placeholder-color);--disabledPlaceholderOpacity:var(--disabled-placeholder-opacity);--errorBackground:var(--error-background);--errorBorder:var(--error-border);--groupItemPaddingLeft:var(--group-item-padding-left);--groupTitleColor:var(--group-title-color);--groupTitleFontSize:var(--group-title-font-size);--groupTitleFontWeight:var(--group-title-font-weight);--groupTitlePadding:var(--group-title-padding);--groupTitleTextTransform:var(--group-title-text-transform);--groupTitleBorderColor:var(--group-title-border-color);--groupTitleBorderWidth:var(--group-title-border-width);--groupTitleBorderStyle:var(--group-title-border-style);--indicatorColor:var(--chevron-color);--indicatorHeight:var(--chevron-height);--indicatorWidth:var(--chevron-width);--inputColor:var(--input-color);--inputLeft:var(--input-left);--inputLetterSpacing:var(--input-letter-spacing);--inputMargin:var(--input-margin);--inputPadding:var(--input-padding);--itemActiveBackground:var(--item-active-background);--itemColor:var(--item-color);--itemFirstBorderRadius:var(--item-first-border-radius);--itemHoverBG:var(--item-hover-bg);--itemHoverColor:var(--item-hover-color);--itemIsActiveBG:var(--item-is-active-bg);--itemIsActiveColor:var(--item-is-active-color);--itemIsNotSelectableColor:var(--item-is-not-selectable-color);--itemPadding:var(--item-padding);--listBackground:var(--list-background);--listBorder:var(--list-border);--listBorderRadius:var(--list-border-radius);--listEmptyColor:var(--list-empty-color);--listEmptyPadding:var(--list-empty-padding);--listEmptyTextAlign:var(--list-empty-text-align);--listMaxHeight:var(--list-max-height);--listPosition:var(--list-position);--listShadow:var(--list-shadow);--listZIndex:var(--list-z-index);--multiItemBG:var(--multi-item-bg);--multiItemBorderRadius:var(--multi-item-border-radius);--multiItemDisabledHoverBg:var(--multi-item-disabled-hover-bg);--multiItemDisabledHoverColor:var(--multi-item-disabled-hover-color);--multiItemHeight:var(--multi-item-height);--multiItemMargin:var(--multi-item-margin);--multiItemPadding:var(--multi-item-padding);--multiSelectInputMargin:var(--multi-select-input-margin);--multiSelectInputPadding:var(--multi-select-input-padding);--multiSelectPadding:var(--multi-select-padding);--placeholderColor:var(--placeholder-color);--placeholderOpacity:var(--placeholder-opacity);--selectedItemPadding:var(--selected-item-padding);--spinnerColor:var(--spinner-color);--spinnerHeight:var(--spinner-height);--spinnerWidth:var(--spinner-width);--internal-padding:0 0 0 16px;border:var(--border, 1px solid #d8dbdf);border-radius:var(--border-radius, 6px);min-height:var(--height, 42px);position:relative;display:flex;align-items:stretch;padding:var(--padding, var(--internal-padding));background:var(--background, #fff);margin:var(--margin, 0);width:var(--width, 100%);font-size:var(--font-size, 16px);max-height:var(--max-height)}.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{box-sizing:var(--box-sizing, border-box)}.svelte-select.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:hover{border:var(--border-hover, 1px solid #b2b8bf)}.value-container.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{display:flex;flex:1 1 0%;flex-wrap:wrap;align-items:center;gap:5px 10px;padding:var(--value-container-padding, 5px 0);position:relative;overflow:var(--value-container-overflow, hidden);align-self:stretch}.prepend.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8,.indicators.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{display:flex;flex-shrink:0;align-items:center}.indicators.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{position:var(--indicators-position);top:var(--indicators-top);right:var(--indicators-right);bottom:var(--indicators-bottom)}input.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{position:absolute;cursor:default;border:none;color:var(--input-color, var(--item-color));padding:var(--input-padding, 0);letter-spacing:var(--input-letter-spacing, inherit);margin:var(--input-margin, 0);min-width:10px;top:0;right:0;bottom:0;left:0;background:transparent;font-size:var(--font-size, 16px)}.svelte-82qwg8:not(.multi)>.value-container.svelte-82qwg8>input.svelte-82qwg8{width:100%;height:100%}input.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8::placeholder{color:var(--placeholder-color, #78848f);opacity:var(--placeholder-opacity, 1)}input.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:focus{outline:none}.svelte-select.focused.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{border:var(--border-focused, 1px solid #006fe8);border-radius:var(--border-radius-focused, var(--border-radius, 6px))}.disabled.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{background:var(--disabled-background, #ebedef);border-color:var(--disabled-border-color, #ebedef);color:var(--disabled-color, #c1c6cc)}.disabled.svelte-82qwg8 input.svelte-82qwg8.svelte-82qwg8::placeholder{color:var(--disabled-placeholder-color, #c1c6cc);opacity:var(--disabled-placeholder-opacity, 1)}.selected-item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{position:relative;overflow:var(--selected-item-overflow, hidden);padding:var(--selected-item-padding, 0 20px 0 0);text-overflow:ellipsis;white-space:nowrap;color:var(--selected-item-color, inherit);font-size:var(--font-size, 16px)}.multi.svelte-82qwg8 .selected-item.svelte-82qwg8.svelte-82qwg8{position:absolute;line-height:var(--height, 42px);height:var(--height, 42px)}.selected-item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:focus{outline:none}.hide-selected-item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{opacity:0}.icon.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{display:flex;align-items:center;justify-content:center}.clear-select.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{all:unset;display:flex;align-items:center;justify-content:center;width:var(--clear-select-width, 40px);height:var(--clear-select-height, 100%);color:var(--clear-select-color, var(--icons-color));margin:var(--clear-select-margin, 0);pointer-events:all;flex-shrink:0}.clear-select.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:focus{outline:var(--clear-select-focus-outline, 1px solid #006fe8)}.loading.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{width:var(--loading-width, 40px);height:var(--loading-height);color:var(--loading-color, var(--icons-color));margin:var(--loading--margin, 0);flex-shrink:0}.chevron.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{width:var(--chevron-width, 40px);height:var(--chevron-height, 40px);background:var(--chevron-background, transparent);pointer-events:var(--chevron-pointer-events, none);color:var(--chevron-color, var(--icons-color));border:var(--chevron-border, 0 0 0 1px solid #d8dbdf);flex-shrink:0}.multi.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{padding:var(--multi-select-padding, var(--internal-padding))}.multi.svelte-82qwg8 input.svelte-82qwg8.svelte-82qwg8{padding:var(--multi-select-input-padding, 0);position:relative;margin:var(--multi-select-input-margin, 5px 0);flex:1 1 40px}.svelte-select.error.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{border:var(--error-border, 1px solid #ff2d55);background:var(--error-background, #fff)}.a11y-text.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{z-index:9999;border:0px;clip:rect(1px, 1px, 1px, 1px);height:1px;width:1px;position:absolute;overflow:hidden;padding:0px;white-space:nowrap}.multi-item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{background:var(--multi-item-bg, #ebedef);margin:var(--multi-item-margin, 0);outline:var(--multi-item-outline, 1px solid #ddd);border-radius:var(--multi-item-border-radius, 4px);height:var(--multi-item-height, 25px);line-height:var(--multi-item-height, 25px);display:flex;cursor:default;padding:var(--multi-item-padding, 0 5px);overflow:hidden;gap:var(--multi-item-gap, 4px);outline-offset:-1px;max-width:var(--multi-max-width, none);color:var(--multi-item-color, var(--item-color))}.multi-item.disabled.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:hover{background:var(--multi-item-disabled-hover-bg, #ebedef);color:var(--multi-item-disabled-hover-color, #c1c6cc)}.multi-item-text.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.multi-item-clear.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{display:flex;align-items:center;justify-content:center;--clear-icon-color:var(--multi-item-clear-icon-color, #000)}.multi-item.active.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{outline:var(--multi-item-active-outline, 1px solid #006fe8)}.svelte-select-list.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{box-shadow:var(--list-shadow, 0 2px 3px 0 rgba(44, 62, 80, 0.24));border-radius:var(--list-border-radius, 4px);max-height:var(--list-max-height, 252px);overflow-y:auto;background:var(--list-background, #fff);position:var(--list-position, absolute);z-index:var(--list-z-index, 2);border:var(--list-border)}.prefloat.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{opacity:0;pointer-events:none}.list-group-title.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{color:var(--group-title-color, #8f8f8f);cursor:default;font-size:var(--group-title-font-size, 16px);font-weight:var(--group-title-font-weight, 600);height:var(--height, 42px);line-height:var(--height, 42px);padding:var(--group-title-padding, 0 20px);text-overflow:ellipsis;overflow-x:hidden;white-space:nowrap;text-transform:var(--group-title-text-transform, uppercase);border-width:var(--group-title-border-width, medium);border-style:var(--group-title-border-style, none);border-color:var(--group-title-border-color, color)}.empty.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{text-align:var(--list-empty-text-align, center);padding:var(--list-empty-padding, 20px 0);color:var(--list-empty-color, #78848f)}.item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{cursor:default;height:var(--item-height, var(--height, 42px));line-height:var(--item-line-height, var(--height, 42px));padding:var(--item-padding, 0 20px);color:var(--item-color, inherit);text-overflow:ellipsis;overflow:hidden;white-space:nowrap;transition:var(--item-transition, all 0.2s);align-items:center;width:100%}.item.group-item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{padding-left:var(--group-item-padding-left, 40px)}.item.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:active{background:var(--item-active-background, #b9daff)}.item.active.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{background:var(--item-is-active-bg, #007aff);color:var(--item-is-active-color, #fff)}.item.first.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{border-radius:var(--item-first-border-radius, 4px 4px 0 0)}.item.hover.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:not(.active){background:var(--item-hover-bg, #e7f2ff);color:var(--item-hover-color, inherit)}.item.not-selectable.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8,.item.hover.item.not-selectable.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8,.item.active.item.not-selectable.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8,.item.not-selectable.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8:active{color:var(--item-is-not-selectable-color, #999);background:transparent}.required.svelte-82qwg8.svelte-82qwg8.svelte-82qwg8{opacity:0;z-index:-1;position:absolute;top:0;left:0;bottom:0;right:0}",
map: null

@@ -719,8 +719,8 @@ };

<div class="${[
"svelte-select " + escape(containerClasses, true) + " svelte-apvs86",
"svelte-select " + escape(containerClasses, true) + " svelte-82qwg8",
(multiple ? "multi" : "") + " " + (disabled ? "disabled" : "") + " " + (focused ? "focused" : "") + " " + (listOpen ? "list-open" : "") + " " + (showChevron ? "show-chevron" : "") + " " + (hasError ? "error" : "")
].join(" ").trim()}"${add_attribute("style", containerStyles, 0)}${add_attribute("this", container, 0)}>${listOpen ? `<div class="${["svelte-select-list svelte-apvs86", prefloat ? "prefloat" : ""].join(" ").trim()}"${add_attribute("this", list, 0)}>${$$slots["list-prepend"] ? `${slots["list-prepend"] ? slots["list-prepend"]({}) : ``}` : ``}
].join(" ").trim()}"${add_attribute("style", containerStyles, 0)} role="none"${add_attribute("this", container, 0)}>${listOpen ? `<div class="${["svelte-select-list svelte-82qwg8", prefloat ? "prefloat" : ""].join(" ").trim()}"${add_attribute("this", list, 0)}>${$$slots["list-prepend"] ? `${slots["list-prepend"] ? slots["list-prepend"]({}) : ``}` : ``}
${$$slots.list ? `${slots.list ? slots.list({ filteredItems }) : ``}` : `${filteredItems.length > 0 ? `${each(filteredItems, (item, i) => {
return `<div class="list-item svelte-apvs86" tabindex="-1"><div class="${[
"item svelte-apvs86",
return `<div class="list-item svelte-82qwg8" tabindex="-1" role="none"><div class="${[
"item svelte-82qwg8",
(item.groupHeader ? "list-group-title" : "") + " " + (isItemActive(item, value, itemId) ? "active" : "") + " " + (isItemFirst(i) ? "first" : "") + " " + (hoverItemIndex === i ? "hover" : "") + " " + (item.groupItem ? "group-item" : "") + " " + (item?.selectable === false ? "not-selectable" : "")

@@ -732,20 +732,20 @@ ].join(" ").trim()}">${slots.item ? slots.item({ item, index: i }) : `

})}` : `${!hideEmptyState ? `${slots.empty ? slots.empty({}) : `
<div class="empty svelte-apvs86">No options</div>
<div class="empty svelte-82qwg8">No options</div>
`}` : ``}`}`}
${$$slots["list-append"] ? `${slots["list-append"] ? slots["list-append"]({}) : ``}` : ``}</div>` : ``}
<span aria-live="polite" aria-atomic="false" aria-relevant="additions text" class="a11y-text svelte-apvs86">${focused ? `<span id="aria-selection" class="svelte-apvs86">${escape(ariaSelection)}</span>
<span id="aria-context" class="svelte-apvs86">${escape(ariaContext)}</span>` : ``}</span>
<span aria-live="polite" aria-atomic="false" aria-relevant="additions text" class="a11y-text svelte-82qwg8">${focused ? `<span id="aria-selection" class="svelte-82qwg8">${escape(ariaSelection)}</span>
<span id="aria-context" class="svelte-82qwg8">${escape(ariaContext)}</span>` : ``}</span>
<div class="prepend svelte-apvs86">${slots.prepend ? slots.prepend({}) : ``}</div>
<div class="prepend svelte-82qwg8">${slots.prepend ? slots.prepend({}) : ``}</div>
<div class="value-container svelte-apvs86">${hasValue ? `${multiple ? `${each(value, (item, i) => {
<div class="value-container svelte-82qwg8">${hasValue ? `${multiple ? `${each(value, (item, i) => {
return `<div class="${[
"multi-item svelte-apvs86",
"multi-item svelte-82qwg8",
(activeValue === i ? "active" : "") + " " + (disabled ? "disabled" : "")
].join(" ").trim()}"><span class="multi-item-text svelte-apvs86">${slots.selection ? slots.selection({ selection: item, index: i }) : `
].join(" ").trim()}" role="none"><span class="multi-item-text svelte-82qwg8">${slots.selection ? slots.selection({ selection: item, index: i }) : `
${escape(item[label])}
`}</span>
${!disabled && !multiFullItemClearable && ClearIcon ? `<div class="multi-item-clear svelte-apvs86">${slots["multi-clear-icon"] ? slots["multi-clear-icon"]({}) : `
${!disabled && !multiFullItemClearable && ClearIcon ? `<div class="multi-item-clear svelte-82qwg8">${slots["multi-clear-icon"] ? slots["multi-clear-icon"]({}) : `
${validate_component(ClearIcon, "ClearIcon").$$render($$result, {}, {}, {})}

@@ -756,3 +756,3 @@ `}

})}` : `<div class="${[
"selected-item svelte-apvs86",
"selected-item svelte-82qwg8",
hideSelectedItem ? "hide-selected-item" : ""

@@ -775,14 +775,14 @@ ].join(" ").trim()}">${slots.selection ? slots.selection({ selection: value }) : `

],
{ classes: "svelte-apvs86" }
{ classes: "svelte-82qwg8" }
)}${add_attribute("this", input, 0)}${add_attribute("value", filterText, 0)}></div>
<div class="indicators svelte-apvs86">${loading ? `<div class="icon loading svelte-apvs86" aria-hidden="true">${slots["loading-icon"] ? slots["loading-icon"]({}) : `
<div class="indicators svelte-82qwg8">${loading ? `<div class="icon loading svelte-82qwg8" aria-hidden="true">${slots["loading-icon"] ? slots["loading-icon"]({}) : `
${validate_component(LoadingIcon, "LoadingIcon").$$render($$result, {}, {}, {})}
`}</div>` : ``}
${showClear ? `<button type="button" class="icon clear-select svelte-apvs86">${slots["clear-icon"] ? slots["clear-icon"]({}) : `
${showClear ? `<button type="button" class="icon clear-select svelte-82qwg8">${slots["clear-icon"] ? slots["clear-icon"]({}) : `
${validate_component(ClearIcon, "ClearIcon").$$render($$result, {}, {}, {})}
`}</button>` : ``}
${showChevron ? `<div class="icon chevron svelte-apvs86" aria-hidden="true">${slots["chevron-icon"] ? slots["chevron-icon"]({ listOpen }) : `
${showChevron ? `<div class="icon chevron svelte-82qwg8" aria-hidden="true">${slots["chevron-icon"] ? slots["chevron-icon"]({ listOpen }) : `
${validate_component(ChevronIcon, "ChevronIcon").$$render($$result, {}, {}, {})}

@@ -792,7 +792,7 @@ `}</div>` : ``}</div>

${slots["input-hidden"] ? slots["input-hidden"]({ value }) : `
<input${add_attribute("name", name, 0)} type="hidden"${add_attribute("value", value ? JSON.stringify(value) : null, 0)} class="svelte-apvs86">
<input${add_attribute("name", name, 0)} type="hidden"${add_attribute("value", value ? JSON.stringify(value) : null, 0)} class="svelte-82qwg8">
`}
${required && (!value || value.length === 0) ? `${slots.required ? slots.required({ value }) : `
<select class="required svelte-apvs86" required tabindex="-1" aria-hidden="true"></select>
<select class="required svelte-82qwg8" required tabindex="-1" aria-hidden="true"></select>
`}` : ``}

@@ -868,3 +868,3 @@ </div>`;

return `<label class="switch svelte-cr81r3" style="${"--switch-scale: " + escape(scale, true)}"><input type="checkbox" class="svelte-cr81r3"${add_attribute("checked", checked, 1)}>
<span class="slider svelte-cr81r3"></span>
<span class="slider svelte-cr81r3"></span>
</label>`;

@@ -920,5 +920,5 @@ });

$$rendered = `${displayCameraSelectionDialog ? `<div class="${["dialog-container svelte-i7kqln", compactMode ? "compact" : ""].join(" ").trim()}"><div class="${["dialog-content svelte-i7kqln", compactMode ? "compact" : ""].join(" ").trim()}"><div class="close-icon svelte-i7kqln">${validate_component(CloseIcon, "CloseIcon").$$render($$result, {}, {}, {})}</div>
<h3 class="svelte-i7kqln">Select a camera</h3>
<div class="svelte-select-container svelte-i7kqln" style="${"--listMaxHeight: " + escape(previewHeight_px / 2, true) + "px; --inputPadding: 0;"}">${validate_component(Select, "Select").$$render(
<h3 class="svelte-i7kqln">Select a camera</h3>
<div class="svelte-select-container svelte-i7kqln" style="${"--listMaxHeight: " + escape(previewHeight_px / 2, true) + "px; --inputPadding: 0;"}">${validate_component(Select, "Select").$$render(
$$result,

@@ -940,4 +940,4 @@ {

<div class="mirror-input svelte-i7kqln"><div class="${["svelte-i7kqln", !mirrorCamera ? "selected" : ""].join(" ").trim()}">Don&#39;t Mirror</div>
<div class="always-display svelte-i7kqln">${validate_component(Switch, "Switch").$$render(
<div class="mirror-input svelte-i7kqln"><div class="${["svelte-i7kqln", !mirrorCamera ? "selected" : ""].join(" ").trim()}">Don&#39;t Mirror</div>
<div class="always-display svelte-i7kqln">${validate_component(Switch, "Switch").$$render(
$$result,

@@ -953,4 +953,4 @@ { checked: mirrorCamera },

)}</div>
<div class="${["always-display key svelte-i7kqln", mirrorCamera ? "selected" : ""].join(" ").trim()}">Mirror Camera</div></div>
${$barcodeEngine !== null ? `<div class="barcode-engine svelte-i7kqln">Barcode Engine: <code class="svelte-i7kqln">${escape($barcodeEngine)}</code></div>` : ``}</div></div>` : ``}`;
<div class="${["always-display key svelte-i7kqln", mirrorCamera ? "selected" : ""].join(" ").trim()}">Mirror Camera</div></div>
${$barcodeEngine !== null ? `<div class="barcode-engine svelte-i7kqln">Barcode Engine: <code class="svelte-i7kqln">${escape($barcodeEngine)}</code></div>` : ``}</div></div>` : ``}`;
} while (!$$settled);

@@ -965,3 +965,3 @@ $$unsubscribe_barcodeEngine();

const css$1 = {
code: ".video-container.svelte-1ezy2iv.svelte-1ezy2iv{width:min-content;height:min-content;box-sizing:border-box;position:relative;width:var(--previewWidth);height:var(--previewHeight);overflow:hidden}.video-container.svelte-1ezy2iv #cam-preview.svelte-1ezy2iv{background:#222222;margin-left:50%;transform:translateX(-50%) scaleX(var(--mirror-enabled))}.video-container.svelte-1ezy2iv .floating-action-button.svelte-1ezy2iv{position:absolute;right:5%;bottom:5%;border:none;background:none;cursor:pointer;z-index:2}.video-container.svelte-1ezy2iv .floating-action-button.svelte-1ezy2iv svg{color:rgba(255, 255, 255, 0.8);filter:drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5))}.video-container.svelte-1ezy2iv .transition-wrapper.svelte-1ezy2iv{height:100%;width:100%}",
code: ".video-container.svelte-djerk.svelte-djerk{box-sizing:border-box;position:relative;overflow:hidden;display:flex;justify-content:center;align-items:center;height:100%;width:100%}.video-container.svelte-djerk #cam-preview.svelte-djerk{background:#222222;object-fit:cover;transform:scaleX(var(--mirror-enabled));height:100%;width:100%}.video-container.svelte-djerk .floating-action-button.svelte-djerk{position:absolute;right:5%;bottom:5%;border:none;background:none;cursor:pointer;z-index:2}.video-container.svelte-djerk .floating-action-button.svelte-djerk svg{color:rgba(255, 255, 255, 0.8);filter:drop-shadow(2px 2px 2px rgba(0, 0, 0, 0.5))}.video-container.svelte-djerk .transition-wrapper.svelte-djerk{height:100%;width:100%}",
map: null

@@ -973,7 +973,5 @@ };

let camerasInitialized = false;
let { backgroundScan = true } = $$props;
let { backgroundScan = false } = $$props;
let { refractoryPeriod = 5e3 } = $$props;
let { scanPeriod = 1 } = $$props;
let { previewWidth_px = 800 } = $$props;
let { previewHeight_px = 450 } = $$props;
let { mediaErrorMessage = "" } = $$props;

@@ -985,13 +983,5 @@ let { smallModalXThreshold = 400 } = $$props;

let videoPreviewElm;
let videoPreviewStyleTags = "";
let mirror;
onDestroy(async () => {
});
function updateVideoAspectRatio() {
videoPreviewStyleTags = `
${"height: var(--previewHeight);"}
${mirror ? "--mirror-enabled: -1" : "--mirror-enabled: 1"}
`;
}
setInterval(updateVideoAspectRatio, 100);
if ($$props.scannerInitialized === void 0 && $$bindings.scannerInitialized && scannerInitialized !== void 0)

@@ -1005,6 +995,2 @@ $$bindings.scannerInitialized(scannerInitialized);

$$bindings.scanPeriod(scanPeriod);
if ($$props.previewWidth_px === void 0 && $$bindings.previewWidth_px && previewWidth_px !== void 0)
$$bindings.previewWidth_px(previewWidth_px);
if ($$props.previewHeight_px === void 0 && $$bindings.previewHeight_px && previewHeight_px !== void 0)
$$bindings.previewHeight_px(previewHeight_px);
if ($$props.mediaErrorMessage === void 0 && $$bindings.mediaErrorMessage && mediaErrorMessage !== void 0)

@@ -1019,5 +1005,4 @@ $$bindings.mediaErrorMessage(mediaErrorMessage);

$$settled = true;
$$rendered = `<div class="video-container svelte-1ezy2iv"${add_attribute("style", `--previewWidth:${previewWidth_px}px;--previewHeight:${previewHeight_px}px;`, 0)}>
<video id="cam-preview" ${!scannerInitialized || !camerasInitialized ? "hidden" : ""}${add_attribute("style", videoPreviewStyleTags, 0)} autoplay muted playsinline class="svelte-1ezy2iv"${add_attribute("this", videoPreviewElm, 0)}></video>
${scannerInitialized ? `<button class="floating-action-button svelte-1ezy2iv">${validate_component(GearIcon, "GearIcon").$$render($$result, {}, {}, {})}</button>` : ``}
$$rendered = `<div class="video-container svelte-djerk"><video id="cam-preview" ${!scannerInitialized || !camerasInitialized ? "hidden" : ""}${add_attribute("style", mirror ? "--mirror-enabled: -1" : "--mirror-enabled: 1", 0)} autoplay muted playsinline class="svelte-djerk"${add_attribute("this", videoPreviewElm, 0)}></video>
${scannerInitialized ? `<button class="floating-action-button svelte-djerk">${validate_component(GearIcon, "GearIcon").$$render($$result, {}, {}, {})}</button>` : ``}

@@ -1058,3 +1043,3 @@ ${validate_component(Dialog, "Dialog").$$render(

${!scannerInitialized ? `<div class="transition-wrapper svelte-1ezy2iv">${slots.loading ? slots.loading({}) : ``}</div>` : `${`<div class="transition-wrapper svelte-1ezy2iv">${slots.failedToInitialize ? slots.failedToInitialize({}) : ``}</div>`}`}
${!scannerInitialized ? `<div class="transition-wrapper svelte-djerk">${slots.loading ? slots.loading({}) : ``}</div>` : `${`<div class="transition-wrapper svelte-djerk">${slots.failedToInitialize ? slots.failedToInitialize({}) : ``}</div>`}`}
</div>`;

@@ -1067,7 +1052,6 @@ } while (!$$settled);

const css = {
code: ".qr-container.svelte-1amr6ko.svelte-1amr6ko{width:100vw;display:flex;justify-content:center}.qr-container.svelte-1amr6ko .qr-wrapper.svelte-1amr6ko{width:100vw;max-width:600px;background:#222222}.qr-container.svelte-1amr6ko .qr-wrapper .loading.svelte-1amr6ko,.qr-container.svelte-1amr6ko .qr-wrapper .failed-to-initialize.svelte-1amr6ko{background:#222222;height:100%;width:100%;display:flex;text-align:center;justify-content:center;align-items:center;color:white;font-size:1.25rem}.qr-container.svelte-1amr6ko .qr-wrapper .loading span.svelte-1amr6ko{animation:svelte-1amr6ko-glow 1s infinite alternate}@keyframes svelte-1amr6ko-glow{100%{text-shadow:0 0 5px white}}",
code: ".qr-container.svelte-1eiwqh7.svelte-1eiwqh7{background:#bc4e9c;background:radial-gradient(circle, #bc4e9c 0%, #f80759 100%);box-sizing:border-box;display:flex;justify-content:center;align-items:center;width:100dvw;height:100dvh;padding:1rem}.qr-container.svelte-1eiwqh7 .qr-wrapper.svelte-1eiwqh7{display:flex;justify-content:center;align-items:center;border-radius:1rem;overflow:hidden;width:600px;max-width:100%;aspect-ratio:1/1}.qr-container.svelte-1eiwqh7 .qr-wrapper .loading.svelte-1eiwqh7,.qr-container.svelte-1eiwqh7 .qr-wrapper .failed-to-initialize.svelte-1eiwqh7{background:#222222;height:100%;width:100%;display:flex;text-align:center;justify-content:center;align-items:center;color:white;font-size:1.25rem}.qr-container.svelte-1eiwqh7 .qr-wrapper .loading span.svelte-1eiwqh7{animation:svelte-1eiwqh7-glow 1s infinite alternate}@keyframes svelte-1eiwqh7-glow{100%{text-shadow:0 0 5px white}}",
map: null
};
const Page = create_ssr_component(($$result, $$props, $$bindings, slots) => {
let w;
let mediaErrorMessage = "";

@@ -1079,10 +1063,6 @@ $$result.css.add(css);

$$settled = true;
$$rendered = `<div class="qr-container svelte-1amr6ko"><div class="qr-wrapper svelte-1amr6ko">${validate_component(QR, "QR").$$render(
$$rendered = `<div class="qr-container svelte-1eiwqh7"><div class="qr-wrapper svelte-1eiwqh7">${validate_component(QR, "QR").$$render(
$$result,
{ mediaErrorMessage },
{
previewWidth_px: w,
previewHeight_px: w,
mediaErrorMessage
},
{
mediaErrorMessage: ($$value) => {

@@ -1095,7 +1075,7 @@ mediaErrorMessage = $$value;

failedToInitialize: () => {
return `<div slot="failedToInitialize" class="failed-to-initialize svelte-1amr6ko">Failed to initialize camera.<br>
return `<div slot="failedToInitialize" class="failed-to-initialize svelte-1eiwqh7">Failed to initialize camera.<br>
${escape(mediaErrorMessage)}</div>`;
},
loading: () => {
return `<div slot="loading" class="loading svelte-1amr6ko"><span class="svelte-1amr6ko">Loading</span></div>`;
return `<div slot="loading" class="loading svelte-1eiwqh7"><span class="svelte-1eiwqh7">Loading</span></div>`;
}

@@ -1102,0 +1082,0 @@ }

@@ -13,3 +13,3 @@ export const manifest = (() => {

_: {
client: {"start":"_app/immutable/entry/start.c049c1e6.js","app":"_app/immutable/entry/app.9a0a056d.js","imports":["_app/immutable/entry/start.c049c1e6.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.61e526f0.js","_app/immutable/chunks/index.80931a4d.js","_app/immutable/entry/app.9a0a056d.js","_app/immutable/chunks/preload-helper.cf010ec4.js","_app/immutable/chunks/index.2ff190cb.js"],"stylesheets":[],"fonts":[]},
client: {"start":"_app/immutable/entry/start.a5edc127.js","app":"_app/immutable/entry/app.f33ac3b1.js","imports":["_app/immutable/entry/start.a5edc127.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.8c56ca7e.js","_app/immutable/chunks/index.80931a4d.js","_app/immutable/entry/app.f33ac3b1.js","_app/immutable/chunks/preload-helper.a4192956.js","_app/immutable/chunks/index.2ff190cb.js"],"stylesheets":[],"fonts":[]},
nodes: [

@@ -16,0 +16,0 @@ __memo(() => import('./nodes/0.js')),

@@ -13,3 +13,3 @@ export const manifest = (() => {

_: {
client: {"start":"_app/immutable/entry/start.c049c1e6.js","app":"_app/immutable/entry/app.9a0a056d.js","imports":["_app/immutable/entry/start.c049c1e6.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.61e526f0.js","_app/immutable/chunks/index.80931a4d.js","_app/immutable/entry/app.9a0a056d.js","_app/immutable/chunks/preload-helper.cf010ec4.js","_app/immutable/chunks/index.2ff190cb.js"],"stylesheets":[],"fonts":[]},
client: {"start":"_app/immutable/entry/start.a5edc127.js","app":"_app/immutable/entry/app.f33ac3b1.js","imports":["_app/immutable/entry/start.a5edc127.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.8c56ca7e.js","_app/immutable/chunks/index.80931a4d.js","_app/immutable/entry/app.f33ac3b1.js","_app/immutable/chunks/preload-helper.a4192956.js","_app/immutable/chunks/index.2ff190cb.js"],"stylesheets":[],"fonts":[]},
nodes: [

@@ -16,0 +16,0 @@ __memo(() => import('./nodes/0.js')),

@@ -6,4 +6,4 @@

export const component = async () => component_cache ??= (await import('../entries/fallbacks/error.svelte.js')).default;
export const imports = ["_app/immutable/nodes/1.e6f3e47a.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.61e526f0.js","_app/immutable/chunks/index.80931a4d.js"];
export const imports = ["_app/immutable/nodes/1.3caaec12.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/singletons.8c56ca7e.js","_app/immutable/chunks/index.80931a4d.js"];
export const stylesheets = [];
export const fonts = [];

@@ -6,4 +6,4 @@

export const component = async () => component_cache ??= (await import('../entries/pages/_page.svelte.js')).default;
export const imports = ["_app/immutable/nodes/2.d67dcfde.js","_app/immutable/chunks/2.aed0594e.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/preload-helper.cf010ec4.js","_app/immutable/chunks/index.80931a4d.js"];
export const stylesheets = ["_app/immutable/assets/2.531edc27.css"];
export const imports = ["_app/immutable/nodes/2.fe357a3d.js","_app/immutable/chunks/2.bfdd105c.js","_app/immutable/chunks/index.2ff190cb.js","_app/immutable/chunks/preload-helper.a4192956.js","_app/immutable/chunks/index.80931a4d.js"];
export const stylesheets = ["_app/immutable/assets/2.ac9010de.css"];
export const fonts = [];
declare module 'barcode' {
global {
class BarcodeDetector {
constructor(barcodeDetectorOptions: {});
static getSupportedFormats(): Promise<BarcodeFormat[]>;
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>;
}
}
type BarcodeFormat = "aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "data_matrix" | "ean_13" | "ean_8" | "itf" | "pdf417" | "qr_code" | "unknown" | "upc_a" | "upc_e";
interface DetectedBarcode {
boundingBox: BarcodeRect;
rawValue: string;
format: BarcodeFormat;
cornerPoints: [Point2D, Point2D, Point2D, Point2D];
}
interface Point2D {
x: number;
y: number;
}
interface BarcodeRect {
x: number;
y: number;
width: number;
height: number;
top: number;
right: number;
bottom: number;
left: number;
}
}
global {
class BarcodeDetector {
constructor(barcodeDetectorOptions: {});
static getSupportedFormats(): Promise<BarcodeFormat[]>;
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>;
}
}
type BarcodeFormat = "aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "data_matrix" | "ean_13" | "ean_8" | "itf" | "pdf417" | "qr_code" | "unknown" | "upc_a" | "upc_e";
interface DetectedBarcode {
boundingBox: BarcodeRect;
rawValue: string;
format: BarcodeFormat;
cornerPoints: [Point2D, Point2D, Point2D, Point2D];
}
interface Point2D {
x: number;
y: number;
}
interface BarcodeRect {
x: number;
y: number;
width: number;
height: number;
top: number;
right: number;
bottom: number;
left: number;
}
}

@@ -13,7 +13,3 @@ export var CameraDirection;

else {
cameras.forEach((camera) => {
if (camera.id === selectedCameraID) {
chosenCamera = camera;
}
});
chosenCamera = cameras.find(camera => camera.id === selectedCameraID);
if (typeof chosenCamera === "undefined") {

@@ -20,0 +16,0 @@ chosenCamera = selectDefault(cameras);

@@ -1,4 +0,4 @@

import { browser } from "$app/environment";
import { BROWSER } from "esm-env";
export async function testCapabilities() {
if (!browser) {
if (!BROWSER) {
return null;

@@ -26,4 +26,3 @@ }

}
catch (e) {
}
catch (e) { }
return false;

@@ -37,3 +36,3 @@ })();

export async function testNativeBarcodeReader() {
if (!browser) {
if (!BROWSER) {
return null;

@@ -40,0 +39,0 @@ }

@@ -8,6 +8,2 @@ import { Scanner } from "./scanner";

import wasmBinaryURL from '../zxingWebWorker/xzingBinary.wasm?url';
export const Instascan = {
Scanner: Scanner,
Camera: Camera,
MediaError: MediaError
};
export const Instascan = { Scanner, Camera, MediaError };

@@ -6,7 +6,7 @@ // Possible Workers

import { writable } from 'svelte/store';
import { browser } from '$app/environment';
import { BROWSER } from 'esm-env';
let worker = null;
export let barcodeEngine = writable(null);
testNativeBarcodeReader().then((nativeBarcodeReaderSupported) => {
if (!browser) {
if (!BROWSER) {
return;

@@ -20,3 +20,2 @@ }

else {
// why must the web be like this?
worker = new zxing_qrScannerWebWorker();

@@ -23,0 +22,0 @@ console.log("Scanning with ZXING Barcode Reader");

@@ -1,2 +0,2 @@

let barcodeDetector = null;
let barcodeDetector;
BarcodeDetector.getSupportedFormats().then((formats) => {

@@ -3,0 +3,0 @@ barcodeDetector = new BarcodeDetector({ formats });

@@ -8,4 +8,2 @@ import { SvelteComponentTyped } from "svelte";

scanPeriod?: number | undefined;
previewWidth_px?: number | undefined;
previewHeight_px?: number | undefined;
mediaErrorMessage?: string | undefined;

@@ -12,0 +10,0 @@ smallModalXThreshold?: number | undefined;

@@ -13,3 +13,3 @@ {

"license": "MIT",
"version": "0.3.0",
"version": "0.4.0",
"publishConfig": {

@@ -32,2 +32,3 @@ "registry": "https://registry.npmjs.org/",

"dependencies": {
"esm-env": "^1.0.0",
"events": "^3.3.0",

@@ -48,3 +49,3 @@ "lodash": "^4.17.21",

"@types/uuid": "^9.0.2",
"publint": "^0.1.12",
"publint": "^0.2.2",
"sass": "^1.63.6",

@@ -51,0 +52,0 @@ "svelte": "^3.59.2",

@@ -40,4 +40,2 @@ # Modern Svelte QR Scanner

on:scan={onQRScan}
previewWidth_px={w}
previewHeight_px={w}
bind:mediaErrorMessage

@@ -72,7 +70,5 @@ >

| scannerInitialized | boolean | false | x | Whether the QR code scanner has loaded yet. |
| backgroundScan | boolean | true | | Whether to actively scan when the tab is not active. When false, this reduces CPU usage when the tab is not active. |
| backgroundScan | boolean | false | | Whether to actively scan when the tab is not active. When false, this reduces CPU usage when the tab is not active. |
| refractoryPeriod | number | 5000 | | The period, in milliseconds, before the same QR code will be recognized in succession. Default 5000 (5 seconds). |
| scanPeriod | number | 1 | | The period, in rendered frames, between scans. A lower scan period increases CPU usage but makes scan response faster. Default 1 (i.e. analyze every frame). |
| previewWidth_px | number | 800 | | The width of the video preview. Bind this value to the width of the parent to make the scanner responsive. |
| previewHeight_px | number | 450 | | The height of the video preview. Bind this value to the width of the parent / wanted_aspect_ratio to make the scanner responsive. |
| mediaErrorMessage | string | "" | x | Human readable error message, updates when there is a new error. Useful displayed in the failedToInitialize slot. |

@@ -79,0 +75,0 @@ | smallModalXThreshold | number | 400 | | The width threshold to move the camera selection from a traditional center of screen modal, to being pined to the top. |

@@ -5,3 +5,6 @@ {

"config:base"
]
],
"patch": {
"enabled": false
}
}
declare module 'barcode' {
global {
class BarcodeDetector {
constructor(barcodeDetectorOptions: {});
static getSupportedFormats(): Promise<BarcodeFormat[]>;
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>;
}
}
type BarcodeFormat = "aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "data_matrix" | "ean_13" | "ean_8" | "itf" | "pdf417" | "qr_code" | "unknown" | "upc_a" | "upc_e";
interface DetectedBarcode {
boundingBox: BarcodeRect;
rawValue: string;
format: BarcodeFormat;
cornerPoints: [Point2D, Point2D, Point2D, Point2D];
}
interface Point2D {
x: number;
y: number;
}
interface BarcodeRect {
x: number;
y: number;
width: number;
height: number;
top: number;
right: number;
bottom: number;
left: number;
}
}
global {
class BarcodeDetector {
constructor(barcodeDetectorOptions: {});
static getSupportedFormats(): Promise<BarcodeFormat[]>;
detect(image: ImageBitmapSource): Promise<DetectedBarcode[]>;
}
}
type BarcodeFormat = "aztec" | "code_128" | "code_39" | "code_93" | "codabar" | "data_matrix" | "ean_13" | "ean_8" | "itf" | "pdf417" | "qr_code" | "unknown" | "upc_a" | "upc_e";
interface DetectedBarcode {
boundingBox: BarcodeRect;
rawValue: string;
format: BarcodeFormat;
cornerPoints: [Point2D, Point2D, Point2D, Point2D];
}
interface Point2D {
x: number;
y: number;
}
interface BarcodeRect {
x: number;
y: number;
width: number;
height: number;
top: number;
right: number;
bottom: number;
left: number;
}
}
import type { Camera } from "./instascan/camera";
export enum CameraDirection {
Front,
Back
Front,
Back
}
export function chooseCamera(cameras: Camera[], selectedCameraID: string): [Camera,boolean] {
let chosenCamera: Camera;
if (typeof selectedCameraID === "undefined") {
chosenCamera = selectDefault(cameras);
console.log(
"Camera not selected, choosing default"
);
} else {
cameras.forEach((camera) => {
if (camera.id === selectedCameraID) {
chosenCamera = camera;
}
});
if (typeof chosenCamera === "undefined") {
chosenCamera = selectDefault(cameras);
console.log("failed to find camera");
}
}
selectedCameraID = chosenCamera.id;
return [chosenCamera,cameraDirectionGuess(chosenCamera)===CameraDirection.Back];
let chosenCamera: Camera | undefined;
if (typeof selectedCameraID === "undefined") {
chosenCamera = selectDefault(cameras);
console.log("Camera not selected, choosing default");
} else {
chosenCamera = cameras.find(camera => camera.id === selectedCameraID)
if (typeof chosenCamera === "undefined") {
chosenCamera = selectDefault(cameras);
console.log("failed to find camera");
}
}
selectedCameraID = chosenCamera.id;
return [chosenCamera, cameraDirectionGuess(chosenCamera) === CameraDirection.Back];
}
function selectDefault(cameras: Camera[]): Camera {
if (detectMobileCameras(cameras)) {
// Mobile, so we should choose the back camera
return mapCameraDirections(cameras)[CameraDirection.Back]
} else {
// Desktop, so we just choose any
return cameras[0]
}
if (detectMobileCameras(cameras)) {
// Mobile, so we should choose the back camera
return mapCameraDirections(cameras)[CameraDirection.Back]
} else {
// Desktop, so we just choose any
return cameras[0]
}
}
export function detectMobileCameras(cameras: Camera[]): boolean {
if (cameras.length === 2) {
if (cameraDirectionGuess(cameras[0])===CameraDirection.Front) {
return cameraDirectionGuess(cameras[1])===CameraDirection.Back
} else if (cameraDirectionGuess(cameras[0])===CameraDirection.Back) {
return cameraDirectionGuess(cameras[1])===CameraDirection.Front
}
}
return false
if (cameras.length === 2) {
if (cameraDirectionGuess(cameras[0]) === CameraDirection.Front) {
return cameraDirectionGuess(cameras[1]) === CameraDirection.Back
} else if (cameraDirectionGuess(cameras[0]) === CameraDirection.Back) {
return cameraDirectionGuess(cameras[1]) === CameraDirection.Front
}
}
return false
}
function mapCameraDirections(cameras: Camera[]) {
let cameraMap = {};
cameraMap[cameraDirectionGuess(cameras[0])] = cameras[0]
cameraMap[cameraDirectionGuess(cameras[1])] = cameras[1]
return cameraMap
let cameraMap = {};
cameraMap[cameraDirectionGuess(cameras[0])] = cameras[0]
cameraMap[cameraDirectionGuess(cameras[1])] = cameras[1]
return cameraMap
}
export function cameraDirectionGuess(camera: Camera): CameraDirection | null {
let normalizedCameraName = camera.name.toLowerCase();
let normalizedCameraName = camera.name.toLowerCase();
if (normalizedCameraName.includes("front")) {
return CameraDirection.Front
} else if (normalizedCameraName.includes("back")) {
return CameraDirection.Back
}
return null
if (normalizedCameraName.includes("front")) {
return CameraDirection.Front
} else if (normalizedCameraName.includes("back")) {
return CameraDirection.Back
}
return null
}

@@ -1,48 +0,50 @@

import { browser } from "$app/environment";
import { BROWSER } from "esm-env";
export async function testCapabilities(): Promise<Error> {
if (!browser) {
return null;
}
if (!BROWSER) {
return null;
}
try {
// Only chrome and old firefox support this
//@ts-ignore
let cameraPermState: string = (await navigator?.permissions?.query({ name: "camera" }))?.state
if (cameraPermState === "denied") {
console.log("Camera Permission denied")
return new Error("Camera Permission denied")
}
} catch(e) {}
try {
// Only chrome and old firefox support this
//@ts-ignore
let cameraPermState: string = (await navigator?.permissions?.query({ name: "camera" }))?.state
if (cameraPermState === "denied") {
console.log("Camera Permission denied")
return new Error("Camera Permission denied")
}
} catch(e) {}
// From https://stackoverflow.com/a/47880734
const WasmSupported = (() => {
try {
if (typeof WebAssembly === "object"
&& typeof WebAssembly.instantiate === "function") {
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
if (module instanceof WebAssembly.Module)
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
}
} catch (e) {
}
return false;
})();
if (!WasmSupported) {
return new Error("WebAssembly Not Supported")
}
// From https://stackoverflow.com/a/47880734
const WasmSupported = (() => {
try {
if (typeof WebAssembly === "object"
&& typeof WebAssembly.instantiate === "function") {
const module = new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00));
if (module instanceof WebAssembly.Module)
return new WebAssembly.Instance(module) instanceof WebAssembly.Instance;
}
} catch (e) {}
return null
return false;
})();
if (!WasmSupported) {
return new Error("WebAssembly Not Supported")
}
return null
}
export async function testNativeBarcodeReader() {
if (!browser) {
return null;
}
if (!BROWSER) {
return null;
}
if ("BarcodeDetector" in window) {
const supportedFormats = await BarcodeDetector.getSupportedFormats();
return supportedFormats.includes("qr_code")
}
return false
if ("BarcodeDetector" in window) {
const supportedFormats = await BarcodeDetector.getSupportedFormats();
return supportedFormats.includes("qr_code")
}
return false
}
interface FsmErrorOptions {
name: string;
from: string;
instanceId?: string;
pending?: boolean;
}
export class FsmError extends Error {
trigger: string;
current: string;
instanceId?: string;
pending?: boolean;
constructor(
message: string,
{ name, from, instanceId, pending }: FsmErrorOptions
) {
super(message);
this.trigger = name;
this.current = from;
if (instanceId) {
this.instanceId = instanceId;
}
if (pending) {
this.pending = pending;
}
}
}
name: string;
from: string;
instanceId?: string;
pending?: boolean;
}
export class FsmError extends Error {
trigger: string;
current: string;
instanceId?: string;
pending?: boolean;
constructor(
message: string,
{ name, from, instanceId, pending }: FsmErrorOptions
) {
super(message);
this.trigger = name;
this.current = from;
if (instanceId) {
this.instanceId = instanceId;
}
if (pending) {
this.pending = pending;
}
}
}

@@ -15,3 +15,3 @@ /*

const defaults = (...args) =>
args.reverse().reduce((acc, obj) => ({ ...acc, ...obj }), {})
args.reverse().reduce((acc, obj) => ({ ...acc, ...obj }), {})

@@ -21,636 +21,636 @@ const identity = a => a

const size = item =>
item.constructor === Object ? Object.keys(item).length : item.length
item.constructor === Object ? Object.keys(item).length : item.length
const AssignFirstArgumentStamp = stampit.compose({
init: function init(opts: StateMachineConfiguration) {
Object.assign(this, opts);
},
init: function init(opts: StateMachineConfiguration) {
Object.assign(this, opts);
},
});
interface StateMachine extends EventEmitter {
/**
* The current state
*/
current: string;
/**
* Determines is the event can be triggered in the current state
*/
can(event: string): boolean;
/**
* Determines is the event can not be triggered in the current state
*/
cannot(event: string): boolean;
is(state: string): boolean;
/**
* Determines if the provided state is final
*/
isFinal(state: string): boolean;
/**
* Determines if the provided state exists in the current state machine
*/
hasState(state: string): boolean;
/**
* The instance id of the state machine
*/
instanceId(): string;
[k: string]: any;
/**
* The current state
*/
current: string;
/**
* Determines is the event can be triggered in the current state
*/
can(event: string): boolean;
/**
* Determines is the event can not be triggered in the current state
*/
cannot(event: string): boolean;
is(state: string): boolean;
/**
* Determines if the provided state is final
*/
isFinal(state: string): boolean;
/**
* Determines if the provided state exists in the current state machine
*/
hasState(state: string): boolean;
/**
* The instance id of the state machine
*/
instanceId(): string;
[k: string]: any;
}
interface EventSpecification {
/**
* The event name
*/
name: string;
/**
* The state in which the event is triggered
*/
from: string | string[];
/**
* The state in which the state machine transitiones when the event completes
*/
to?: string | string[];
/**
* The condition function that determines the state for conditional events
*/
condition?: {
(args: any[]): string | number | Promise<string | number>;
};
/**
* The event name
*/
name: string;
/**
* The state in which the event is triggered
*/
from: string | string[];
/**
* The state in which the state machine transitiones when the event completes
*/
to?: string | string[];
/**
* The condition function that determines the state for conditional events
*/
condition?: {
(args: any[]): string | number | Promise<string | number>;
};
}
interface CallbackOptions {
/**
* Event name
*/
name: string;
from: string;
to: string;
/**
* Event arguments
*/
args: any[];
/**
* Event returned value
*/
res?: any;
/**
* Event name
*/
name: string;
from: string;
to: string;
/**
* Event arguments
*/
args: any[];
/**
* Event returned value
*/
res?: any;
}
interface StateMachineConfiguration {
/**
* The initial state
*/
initial: string;
/**
* The final states
*/
final: string | string[];
/**
* The events
*/
events: EventSpecification[];
/**
* The callbacks
*/
callbacks?: {
[k: string]: {
(options: CallbackOptions): void | Promise<void>;
};
};
/**
* Custom error handler
*/
error?: {
(
message: string,
options: {
name: string;
from: string;
}
): Error;
};
/**
* The initial state
*/
initial: string;
/**
* The final states
*/
final: string | string[];
/**
* The events
*/
events: EventSpecification[];
/**
* The callbacks
*/
callbacks?: {
[k: string]: {
(options: CallbackOptions): void | Promise<void>;
};
};
/**
* Custom error handler
*/
error?: {
(
message: string,
options: {
name: string;
from: string;
}
): Error;
};
}
const StateMachineStamp = stampit.compose<StateMachine>({
props: {
// can be an object or an array
events: [],
pseudoStates: {},
responses: {},
pseudoEvents: {},
callbacks: {},
states: {},
final: null,
initial: 'none',
current: 'none',
},
statics: {
Promise: Promise || require('es6-promise').Promise,
FsmError: FsmError,
callbackPrefix: 'on',
noChoiceFound: 'no-choice',
type: function type(options: { from: string; to: string }) {
var Type = this.Type;
if (options.from === options.to || typeof options.to === 'undefined') {
return Type.NOOP;
} else if (options.from === '*') {
return Type.GENERAL;
}
return Type.INTER;
},
Type: {
NOOP: 0,
INTER: 1,
GENERAL: 2,
},
isConditional: function isConditional(event: EventSpecification) {
return typeof event.condition === "function" && Array.isArray(event.to);
},
pseudoEvent: function pseudoEvent(state: string, name: string) {
return state + '--' + name;
},
},
methods: {
emit: () => undefined,
error: function (msg, options) {
if (this.target) {
options.instanceId = this.target.instanceId();
}
props: {
// can be an object or an array
events: [],
pseudoStates: {},
responses: {},
pseudoEvents: {},
callbacks: {},
states: {},
final: null,
initial: 'none',
current: 'none',
},
statics: {
Promise: Promise || require('es6-promise').Promise,
FsmError: FsmError,
callbackPrefix: 'on',
noChoiceFound: 'no-choice',
type: function type(options: { from: string; to: string }) {
var Type = this.Type;
if (options.from === options.to || typeof options.to === 'undefined') {
return Type.NOOP;
} else if (options.from === '*') {
return Type.GENERAL;
}
return Type.INTER;
},
Type: {
NOOP: 0,
INTER: 1,
GENERAL: 2,
},
isConditional: function isConditional(event: EventSpecification) {
return typeof event.condition === "function" && Array.isArray(event.to);
},
pseudoEvent: function pseudoEvent(state: string, name: string) {
return state + '--' + name;
},
},
methods: {
emit: () => undefined,
error: function (msg, options) {
if (this.target) {
options.instanceId = this.target.instanceId();
}
throw new this.factory.FsmError(msg, options);
},
instanceErrorHandler: function instanceErrorHandler(
err,
instanceId,
action
) {
if (err instanceof this.factory.FsmError) {
if (err.message === 'Invalid event in current state') {
if (err.instanceId !== instanceId) {
action();
}
} else {
action();
}
} else {
action();
}
},
canTransition: function canTransition(options) {
var factory = this.factory;
var Type = factory.Type;
throw new this.factory.FsmError(msg, options);
},
instanceErrorHandler: function instanceErrorHandler(
err,
instanceId,
action
) {
if (err instanceof this.factory.FsmError) {
if (err.message === 'Invalid event in current state') {
if (err.instanceId !== instanceId) {
action();
}
} else {
action();
}
} else {
action();
}
},
canTransition: function canTransition(options) {
var factory = this.factory;
var Type = factory.Type;
switch (factory.type(options)) {
case Type.NOOP:
if (this.inTransition) {
this.error('Previous transition pending', options);
}
break;
case Type.INTER:
if (size(this.states[this.current].noopTransitions) > 0) {
options.pending = clone(
this.states[this.current].noopTransitions
);
this.error('Previous transition pending', options);
}
if (this.inTransition) {
this.error('Previous inter-state transition started', options);
}
this.inTransition = true;
break;
default:
}
switch (factory.type(options)) {
case Type.NOOP:
if (this.inTransition) {
this.error('Previous transition pending', options);
}
break;
case Type.INTER:
if (size(this.states[this.current].noopTransitions) > 0) {
options.pending = clone(
this.states[this.current].noopTransitions
);
this.error('Previous transition pending', options);
}
if (this.inTransition) {
this.error('Previous inter-state transition started', options);
}
this.inTransition = true;
break;
default:
}
return options;
},
can: function can(name) {
return Boolean(this.events[name][this.current]);
},
cannot: function cannot(name) {
return !this.can(name);
},
hasState: function hasState(state) {
return Boolean(this.states[state]);
},
is: function is(state) {
return state == this.current;
},
isFinal: function isFinal(state) {
state = state || this.current;
if (Array.isArray(this.final)) {
return includes(this.final, state);
}
return this.final === state;
},
isValidEvent: function isValidEvent(options) {
if (this.cannot(options.name)) {
this.error('Invalid event in current state', options);
}
return options;
},
can: function can(name) {
return Boolean(this.events[name][this.current]);
},
cannot: function cannot(name) {
return !this.can(name);
},
hasState: function hasState(state) {
return Boolean(this.states[state]);
},
is: function is(state) {
return state == this.current;
},
isFinal: function isFinal(state) {
state = state || this.current;
if (Array.isArray(this.final)) {
return includes(this.final, state);
}
return this.final === state;
},
isValidEvent: function isValidEvent(options) {
if (this.cannot(options.name)) {
this.error('Invalid event in current state', options);
}
return options;
},
// internal callbacks
onenterstate: function onenterstate(options) {
const factory = this.factory;
const Type = this.factory.Type;
return options;
},
// internal callbacks
onenterstate: function onenterstate(options) {
const factory = this.factory;
const Type = this.factory.Type;
switch (factory.type(options)) {
case Type.NOOP:
delete this.states[this.current].noopTransitions[options.id];
break;
default:
this.inTransition = false;
this.current = options.to;
if (!this.pseudoStates[this.current]) {
this.emit('state', this.current);
}
}
switch (factory.type(options)) {
case Type.NOOP:
delete this.states[this.current].noopTransitions[options.id];
break;
default:
this.inTransition = false;
this.current = options.to;
if (!this.pseudoStates[this.current]) {
this.emit('state', this.current);
}
}
return options;
},
onleavestate: function onleavestate(options) {
var factory = this.factory;
var Type = this.factory.Type;
return options;
},
onleavestate: function onleavestate(options) {
var factory = this.factory;
var Type = this.factory.Type;
switch (factory.type(options)) {
case Type.NOOP:
this.states[this.current].noopTransitions[options.id] = options;
break;
default:
}
switch (factory.type(options)) {
case Type.NOOP:
this.states[this.current].noopTransitions[options.id] = options;
break;
default:
}
return options;
},
returnValue: function returnValue(options) {
return options.res || options;
},
revert: function (options) {
return function revert(err: Error) {
var factory = this.factory;
var Type = this.factory.Type;
var instanceId = this.target.instanceId();
return options;
},
returnValue: function returnValue(options) {
return options.res || options;
},
revert: function (options) {
return function revert(err: Error) {
var factory = this.factory;
var Type = this.factory.Type;
var instanceId = this.target.instanceId();
switch (factory.type(options)) {
case Type.INTER:
this.instanceErrorHandler(err, instanceId, () => {
this.inTransition = false;
});
break;
case Type.NOOP:
this.instanceErrorHandler(err, instanceId, () => {
delete this.states[this.current].noopTransitions[options.id];
});
break;
default:
}
switch (factory.type(options)) {
case Type.INTER:
this.instanceErrorHandler(err, instanceId, () => {
this.inTransition = false;
});
break;
case Type.NOOP:
this.instanceErrorHandler(err, instanceId, () => {
delete this.states[this.current].noopTransitions[options.id];
});
break;
default:
}
throw err;
};
},
throw err;
};
},
// configure methods
addEvents: function addEvents(events) {
events.foreach((event: EventSpecification) => {
this.addEvent(event);
})
},
addEvent: function addEvent(event: EventSpecification) {
this.events[event.name] = this.events[event.name] || {};
// configure methods
addEvents: function addEvents(events) {
events.foreach((event: EventSpecification) => {
this.addEvent(event);
})
},
addEvent: function addEvent(event: EventSpecification) {
this.events[event.name] = this.events[event.name] || {};
//NOTE: Add the choice pseudo-state for conditional transition
if (this.factory.isConditional(event)) {
return this.addConditionalEvent(event);
}
this.addBasicEvent(event);
},
addBasicEvent: function addBasicEvent(event: EventSpecification) {
if (Array.isArray(event.to)) {
this.error('Ambigous transition', event);
}
//NOTE: Add the choice pseudo-state for conditional transition
if (this.factory.isConditional(event)) {
return this.addConditionalEvent(event);
}
this.addBasicEvent(event);
},
addBasicEvent: function addBasicEvent(event: EventSpecification) {
if (Array.isArray(event.to)) {
this.error('Ambigous transition', event);
}
event.from = [].concat(event.from || []);
event.from = [].concat(event.from || []);
event.from.forEach((from: string) => {
this.events[event.name][from] = event.to || from;
}
);
},
addConditionalEvent: function addConditionalEvent(event) {
var pseudoState: string;
var factory = this.factory;
var callbackPrefix = factory.callbackPrefix;
var noChoiceFound = factory.noChoiceFound;
var pseudoEvent = factory.pseudoEvent;
var Promise = factory.Promise;
event.from.forEach((from: string) => {
this.events[event.name][from] = event.to || from;
}
);
},
addConditionalEvent: function addConditionalEvent(event) {
var pseudoState: string;
var factory = this.factory;
var callbackPrefix = factory.callbackPrefix;
var noChoiceFound = factory.noChoiceFound;
var pseudoEvent = factory.pseudoEvent;
var Promise = factory.Promise;
if (Array.isArray(event.from)) {
return event.from.forEach((from: string) => {
this.addConditionalEvent({
name: event.name,
from: from,
to: event.to,
condition: event.condition,
});
if (Array.isArray(event.from)) {
return event.from.forEach((from: string) => {
this.addConditionalEvent({
name: event.name,
from: from,
to: event.to,
condition: event.condition,
});
});
}
pseudoState = event.from + '__' + event.name;
});
}
pseudoState = event.from + '__' + event.name;
this.pseudoStates[pseudoState] = event.from;
this.pseudoStates[pseudoState] = event.from;
this.addState(pseudoState);
this.addState(pseudoState);
this.addEvent({
name: event.name,
from: event.from,
to: pseudoState,
});
this.addEvent({
name: event.name,
from: event.from,
to: pseudoState,
});
this.addEvent({
name: pseudoEvent(pseudoState, noChoiceFound),
from: pseudoState,
to: event.from,
});
this.addEvent({
name: pseudoEvent(pseudoState, noChoiceFound),
from: pseudoState,
to: event.from,
});
this.pseudoEvents[pseudoEvent(pseudoState, noChoiceFound)] = event.name;
this.pseudoEvents[pseudoEvent(pseudoState, noChoiceFound)] = event.name;
event.to.forEach((toState: string) => {
this.addEvent({
name: pseudoEvent(pseudoState, toState),
from: pseudoState,
to: toState,
});
event.to.forEach((toState: string) => {
this.addEvent({
name: pseudoEvent(pseudoState, toState),
from: pseudoState,
to: toState,
});
this.pseudoEvents[pseudoEvent(pseudoState, toState)] = event.name;
this.pseudoEvents[pseudoEvent(pseudoState, toState)] = event.name;
});
});
this.callbacks[
callbackPrefix + 'entered' + pseudoState
] = function (options: {
name: string;
from: string;
to: string;
args: any[];
}) {
var target = this.target;
defaults(options, {
args: [],
});
this.callbacks[
callbackPrefix + 'entered' + pseudoState
] = function (options: {
name: string;
from: string;
to: string;
args: any[];
}) {
var target = this.target;
defaults(options, {
args: [],
});
return new Promise(function (resolve: Function) {
resolve(event.condition.call(target, options));
}).then(
function (index: number) {
var toState;
return new Promise(function (resolve: Function) {
resolve(event.condition.call(target, options));
}).then(
function (index: number) {
var toState;
if (typeof index === "number") {
toState = event.to[index];
} else if (event.to.includes(index)) {
toState = index;
}
if (typeof toState === "undefined") {
return target[pseudoEvent(pseudoState, noChoiceFound)]().then(
this.error.bind(this, 'Choice index out of range', event)
);
} else {
return target[pseudoEvent(pseudoState, toState)].apply(
target,
options.args
);
}
}.bind(this)
);
}.bind(this);
},
addState: function addState(state) {
var states = this.states;
state = [].concat(state || []);
state.forEach(function (name: string) {
states[name] = states[name] || {
noopTransitions: {},
};
});
},
preprocessPseudoState: function preprocessPseudoState(name, options) {
var responses = this.responses;
if (typeof index === "number") {
toState = event.to[index];
} else if (event.to.includes(index)) {
toState = index;
}
if (typeof toState === "undefined") {
return target[pseudoEvent(pseudoState, noChoiceFound)]().then(
this.error.bind(this, 'Choice index out of range', event)
);
} else {
return target[pseudoEvent(pseudoState, toState)].apply(
target,
options.args
);
}
}.bind(this)
);
}.bind(this);
},
addState: function addState(state) {
var states = this.states;
state = [].concat(state || []);
state.forEach(function (name: string) {
states[name] = states[name] || {
noopTransitions: {},
};
});
},
preprocessPseudoState: function preprocessPseudoState(name, options) {
var responses = this.responses;
// transition to choice state in a conditional event
Object.defineProperty(options, 'res', {
get: function getRes() {
return responses[name];
},
set: function setRes(value) {
responses[name] = value;
},
});
// transition to choice state in a conditional event
Object.defineProperty(options, 'res', {
get: function getRes() {
return responses[name];
},
set: function setRes(value) {
responses[name] = value;
},
});
// reset previous results
delete responses[name];
// reset previous results
delete responses[name];
return options;
},
preprocessPseudoEvent: function preprocessPseudoEvent(name, options) {
// transition from choice state in a conditional event
var pseudoEvent = this.pseudoEvents[name];
var responses = this.responses;
var pseudoStates = this.pseudoStates;
var pOptions = {
name: pseudoEvent,
from: pseudoStates[this.current],
to: options.to,
args: options.args,
};
return options;
},
preprocessPseudoEvent: function preprocessPseudoEvent(name, options) {
// transition from choice state in a conditional event
var pseudoEvent = this.pseudoEvents[name];
var responses = this.responses;
var pseudoStates = this.pseudoStates;
var pOptions = {
name: pseudoEvent,
from: pseudoStates[this.current],
to: options.to,
args: options.args,
};
Object.defineProperties(pOptions, {
res: {
get: function () {
return responses[pseudoEvent];
},
set: function (val) {
responses[pseudoEvent] = val;
},
},
});
Object.defineProperties(pOptions, {
res: {
get: function () {
return responses[pseudoEvent];
},
set: function (val) {
responses[pseudoEvent] = val;
},
},
});
return pOptions;
},
buildEvent: function buildEvent(name) {
var callbacks = this.callbacks;
var pseudoEvents = this.pseudoEvents;
var pseudoStates = this.pseudoStates;
var events = this.events;
var Type = this.factory.Type;
var callbackPrefix = this.factory.callbackPrefix;
return pOptions;
},
buildEvent: function buildEvent(name) {
var callbacks = this.callbacks;
var pseudoEvents = this.pseudoEvents;
var pseudoStates = this.pseudoStates;
var events = this.events;
var Type = this.factory.Type;
var callbackPrefix = this.factory.callbackPrefix;
return function triggerEvent() {
var args = toArray(arguments);
var current = this.current;
var target = this.target;
var options: {
name: string;
from: string;
to: string;
args: any[];
id?: string;
} = {
name: name,
from: current,
to: events[name][current],
args: args,
};
var pOptions;
var isPseudo = pseudoEvents[name];
return function triggerEvent() {
var args = toArray(arguments);
var current = this.current;
var target = this.target;
var options: {
name: string;
from: string;
to: string;
args: any[];
id?: string;
} = {
name: name,
from: current,
to: events[name][current],
args: args,
};
var pOptions;
var isPseudo = pseudoEvents[name];
if (options.from === options.to) {
options.id = v4();
}
if (options.from === options.to) {
options.id = v4();
}
if (pseudoStates[options.to]) {
options = this.preprocessPseudoState(name, options);
}
if (pseudoStates[options.to]) {
options = this.preprocessPseudoState(name, options);
}
if (isPseudo) {
pOptions = this.preprocessPseudoEvent(name, options);
}
if (isPseudo) {
pOptions = this.preprocessPseudoEvent(name, options);
}
return (
new this.factory.Promise(function (resolve: Function) {
resolve(options);
})
.then(this.isValidEvent.bind(this))
.then(this.canTransition.bind(this))
.then(
callbacks[callbackPrefix + 'leave' + current]
? callbacks[callbackPrefix + 'leave' + current].bind(
target,
options
)
: identity
)
.then(
callbacks.onleave
? callbacks.onleave.bind(target, options)
: identity
)
.then(this.onleavestate.bind(this, options))
.then(
callbacks[callbackPrefix + name]
? callbacks[callbackPrefix + name].bind(target, options)
: identity
)
//in the case of the transition from choice pseudostate we provide
// the options of the original transition
.then(
callbacks[callbackPrefix + 'enter' + events[name][current]]
? callbacks[
callbackPrefix + 'enter' + events[name][current]
].bind(target, isPseudo ? pOptions : options)
: identity
)
.then(
callbacks.onenter && !pseudoStates[options.to]
? callbacks.onenter.bind(target, isPseudo ? pOptions : options)
: identity
)
.then(this.onenterstate.bind(this, options))
.then(
callbacks[callbackPrefix + 'entered' + events[name][current]]
? callbacks[
callbackPrefix + 'entered' + events[name][current]
].bind(target, isPseudo ? pOptions : options)
: identity
)
.then(
callbacks.onentered && !pseudoStates[options.to]
? callbacks.onentered.bind(
target,
isPseudo ? pOptions : options
)
: identity
)
.then(this.returnValue.bind(this, options))
.catch(this.revert(options).bind(this))
);
}.bind(this);
},
initTarget: function initTarget(target) {
var mixin;
const id = v4();
return (
new this.factory.Promise(function (resolve: Function) {
resolve(options);
})
.then(this.isValidEvent.bind(this))
.then(this.canTransition.bind(this))
.then(
callbacks[callbackPrefix + 'leave' + current]
? callbacks[callbackPrefix + 'leave' + current].bind(
target,
options
)
: identity
)
.then(
callbacks.onleave
? callbacks.onleave.bind(target, options)
: identity
)
.then(this.onleavestate.bind(this, options))
.then(
callbacks[callbackPrefix + name]
? callbacks[callbackPrefix + name].bind(target, options)
: identity
)
//in the case of the transition from choice pseudostate we provide
// the options of the original transition
.then(
callbacks[callbackPrefix + 'enter' + events[name][current]]
? callbacks[
callbackPrefix + 'enter' + events[name][current]
].bind(target, isPseudo ? pOptions : options)
: identity
)
.then(
callbacks.onenter && !pseudoStates[options.to]
? callbacks.onenter.bind(target, isPseudo ? pOptions : options)
: identity
)
.then(this.onenterstate.bind(this, options))
.then(
callbacks[callbackPrefix + 'entered' + events[name][current]]
? callbacks[
callbackPrefix + 'entered' + events[name][current]
].bind(target, isPseudo ? pOptions : options)
: identity
)
.then(
callbacks.onentered && !pseudoStates[options.to]
? callbacks.onentered.bind(
target,
isPseudo ? pOptions : options
)
: identity
)
.then(this.returnValue.bind(this, options))
.catch(this.revert(options).bind(this))
);
}.bind(this);
},
initTarget: function initTarget(target) {
var mixin;
const id = v4();
if (!(typeof target === "object")) {
target = new EventEmitter();
}
if (!(typeof target === "object")) {
target = new EventEmitter();
}
if (typeof target.emit === "function") {
this.emit = function emit() {
return target.emit.apply(target, arguments);
};
}
if (typeof target.emit === "function") {
this.emit = function emit() {
return target.emit.apply(target, arguments);
};
}
mixin = mapValues(
this.events,
function (event: EventSpecification, name: string) {
return this.buildEvent(name);
}.bind(this)
);
mixin = mapValues(
this.events,
function (event: EventSpecification, name: string) {
return this.buildEvent(name);
}.bind(this)
);
assign(target, mixin, {
can: this.can.bind(this),
cannot: this.cannot.bind(this),
is: this.is.bind(this),
hasState: this.hasState.bind(this),
isFinal: this.isFinal.bind(this),
instanceId: () => id,
});
assign(target, mixin, {
can: this.can.bind(this),
cannot: this.cannot.bind(this),
is: this.is.bind(this),
hasState: this.hasState.bind(this),
isFinal: this.isFinal.bind(this),
instanceId: () => id,
});
Object.defineProperty(target, 'current', {
get: function getCurrent() {
return this.current;
}.bind(this),
});
Object.defineProperty(target, 'current', {
get: function getCurrent() {
return this.current;
}.bind(this),
});
this.target = target;
this.target = target;
return target;
},
},
init: function init(
opts,
{ stamp, args }: { stamp: StateMachineConfiguration; args: any[] }
) {
this.factory = stamp;
return target;
},
},
init: function init(
opts,
{ stamp, args }: { stamp: StateMachineConfiguration; args: any[] }
) {
this.factory = stamp;
this.states = {};
this.states = {};
var events = this.events;
this.events = {};
events.forEach((event: EventSpecification, name: string) => {
if (typeof name === "string") {
event.name = name;
}
var events = this.events;
this.events = {};
events.forEach((event: EventSpecification, name: string) => {
if (typeof name === "string") {
event.name = name;
}
this.addEvent(event);
this.addEvent(event);
//NOTE: Add states
this.addState(event.from);
this.addState(event.to);
//NOTE: Add states
this.addState(event.from);
this.addState(event.to);
});
});
this.current = this.initial;
const target = this.initTarget(args[1]);
this.current = this.initial;
const target = this.initTarget(args[1]);
return target;
},
return target;
},
});
interface StateMachineFactory {
(configuration: StateMachineConfiguration, target?: object): StateMachine;
(configuration: StateMachineConfiguration, target?: object): StateMachine;
}
const StateMachine: StateMachineFactory = stampit
.compose(AssignFirstArgumentStamp)
.compose<StateMachine>(StateMachineStamp);
.compose(AssignFirstArgumentStamp)
.compose<StateMachine>(StateMachineStamp);
export default StateMachine;
export let mediaErrorCallback: CallableFunction = null;
function cameraName(label) {
let clean = label.replace(/\s*\([0-9a-f]+(:[0-9a-f]+)?\)\s*$/, '');
return clean || label || null;
let clean = label.replace(/\s*\([0-9a-f]+(:[0-9a-f]+)?\)\s*$/, '');
return clean || label || null;
}
export class MediaError extends Error {
type: any;
constructor(type) {
super(`Cannot access video stream (${type}).`);
this.type = type;
}
type: any;
constructor(type) {
super(`Cannot access video stream (${type}).`);
this.type = type;
}
}
export class Camera {
id: string;
name: string;
aspectRatio: number;
_stream: MediaStream;
id: string;
name: string;
aspectRatio: number;
_stream: MediaStream;
constructor(id: string, name: string) {
this.id = id;
this.name = name;
this.aspectRatio = 1;
this._stream = null;
}
constructor(id: string, name: string) {
this.id = id;
this.name = name;
this.aspectRatio = 1;
this._stream = null;
}
async start() {
let constraints = {
audio: false,
video: {
deviceId: this.id,
}
};
async start() {
let constraints = {
audio: false,
video: {
deviceId: this.id,
}
};
this._stream = await Camera._wrapErrors(async () => {
return await navigator.mediaDevices.getUserMedia(constraints);
});
this._stream = await Camera._wrapErrors(async () => {
return await navigator.mediaDevices.getUserMedia(constraints);
});
return this._stream;
}
return this._stream;
}
stop() {
if (!this._stream) {
return;
}
stop() {
if (!this._stream) {
return;
}
for (let stream of this._stream.getVideoTracks()) {
stream.stop();
}
for (let stream of this._stream.getVideoTracks()) {
stream.stop();
}
this._stream = null;
}
this._stream = null;
}
static async getCameras() {
await this._ensureAccess();
let devices = await navigator.mediaDevices.enumerateDevices();
return devices
.filter(d => d.kind === 'videoinput')
.map(d => new Camera(d.deviceId, cameraName(d.label)));
}
static async getCameras() {
await this._ensureAccess();
let devices = await navigator.mediaDevices.enumerateDevices();
return devices
.filter(d => d.kind === 'videoinput')
.map(d => new Camera(d.deviceId, cameraName(d.label)));
}
static async _ensureAccess() {
return await this._wrapErrors(async () => {
static async _ensureAccess() {
return await this._wrapErrors(async () => {
let access = await navigator.mediaDevices.getUserMedia({ video: true });
let access = await navigator.mediaDevices.getUserMedia({ video: true });
for (let stream of access.getVideoTracks()) {
stream.stop();
}
for (let stream of access.getVideoTracks()) {
// https://stackoverflow.com/a/69468263
// Firefox requires getting media devices after stopping all streams
await navigator.mediaDevices.getUserMedia({ video: true });
});
}
stream.stop();
}
static setMediaErrorCallback(callback: CallableFunction) {
mediaErrorCallback = callback
}
// https://stackoverflow.com/a/69468263
// Firefox requires getting media devices after stopping all streams
await navigator.mediaDevices.getUserMedia({ video: true });
});
}
static setMediaErrorCallback(callback: CallableFunction) {
mediaErrorCallback = callback
}
static async _wrapErrors(fn) {
try {
return await fn();
} catch (e) {
if (e.name) {
if (mediaErrorCallback !== null) {
mediaErrorCallback(new MediaError(e.name))
} else {
console.log("Media Error Callback not found");
throw new MediaError(e.name);
}
} else {
throw e;
}
}
}
static async _wrapErrors(fn) {
try {
return await fn();
} catch (e) {
if (e.name) {
if (mediaErrorCallback !== null) {
mediaErrorCallback(new MediaError(e.name))
} else {
console.log("Media Error Callback not found");
throw new MediaError(e.name);
}
} else {
throw e;
}
}
}
}

@@ -11,6 +11,2 @@ import { Scanner } from "./scanner";

export const Instascan = {
Scanner: Scanner,
Camera: Camera,
MediaError: MediaError
};
export const Instascan = { Scanner, Camera, MediaError };

@@ -10,3 +10,3 @@ // Possible Workers

import { browser } from '$app/environment';
import { BROWSER } from 'esm-env';
let worker: Worker | null = null;

@@ -17,38 +17,36 @@

testNativeBarcodeReader().then((nativeBarcodeReaderSupported)=>{
if (!browser) {
return;
}
if (!BROWSER) {
return;
}
if (nativeBarcodeReaderSupported) {
worker = new native_qrScannerWebWorker();
console.log("Scanning with native barcode reader");
barcodeEngine.set("native");
} else {
// why must the web be like this?
worker = new zxing_qrScannerWebWorker();
console.log("Scanning with ZXING Barcode Reader");
barcodeEngine.set("zxing");
}
if (nativeBarcodeReaderSupported) {
worker = new native_qrScannerWebWorker();
console.log("Scanning with native barcode reader");
barcodeEngine.set("native");
} else {
worker = new zxing_qrScannerWebWorker();
console.log("Scanning with ZXING Barcode Reader");
barcodeEngine.set("zxing");
}
})
export async function scanData(data: Uint8ClampedArray, width: number, height: number): Promise<ScanResult> {
let promise = new Promise<ScanResult>((resolve, reject) => {
if (worker) {
worker.onmessage = (e) => {
resolve({ result: e.data, error: null});
}
worker.postMessage({data, width, height} as DataInput);
} else {
// Worker Not Ready Yet
setTimeout(()=>{resolve({ result: null, error: null});}, 50)
}
})
let promise = new Promise<ScanResult>((resolve, reject) => {
if (worker) {
worker.onmessage = (e) => {
resolve({ result: e.data, error: null});
}
worker.postMessage({data, width, height} as DataInput);
} else {
// Worker Not Ready Yet
setTimeout(()=>{resolve({ result: null, error: null});}, 50)
}
})
return await promise
return await promise
}
export interface ScanResult {
result: string | null,
error: string | null
result: string | null,
error: string | null
}
import Visibility from 'visibilityjs';
import {EventEmitter} from 'events'
import { EventEmitter } from 'events'
import StateMachine from "../fsm-as-promised/index"

@@ -8,376 +8,374 @@ import { scanData } from './scanAdapter';

class ScanProvider {
scanPeriod: any;
captureImage: any;
refractoryPeriod: any;
refractoryTimeout: any;
_emitter: any;
_frameCount: number;
_analyzer: any;
_lastResult: any;
_active: any;
_video: HTMLVideoElement;
scanPeriod: any;
captureImage: any;
refractoryPeriod: any;
refractoryTimeout: any;
_emitter: any;
_frameCount: number;
_analyzer: any;
_lastResult: any;
_active: any;
_video: HTMLVideoElement;
constructor(emitter, analyzer, captureImage, scanPeriod, refractoryPeriod, videoElm: HTMLVideoElement) {
this.scanPeriod = scanPeriod;
this.captureImage = captureImage;
this.refractoryPeriod = refractoryPeriod;
this._emitter = emitter;
this._frameCount = 0;
this._analyzer = analyzer;
this._lastResult = null;
this._active = false;
this._video = videoElm;
}
constructor(emitter, analyzer, captureImage, scanPeriod, refractoryPeriod, videoElm: HTMLVideoElement) {
this.scanPeriod = scanPeriod;
this.captureImage = captureImage;
this.refractoryPeriod = refractoryPeriod;
this._emitter = emitter;
this._frameCount = 0;
this._analyzer = analyzer;
this._lastResult = null;
this._active = false;
this._video = videoElm;
}
start() {
this._active = true;
setTimeout(() => {this._scan()}, 0);
start() {
this._active = true;
}
setTimeout(() => { this._scan() }, 0);
stop() {
this._active = false;
}
}
async scan() {
return await this._analyze(false);
}
stop() {
this._active = false;
}
async _analyze(skipDups): Promise<{content: { result: string,error: string}, image?: string}> {
let analysis: {result: { result: string,error: string}, canvas: HTMLCanvasElement} = await this._analyzer.analyze();
if (!analysis) {
return null;
}
async scan() {
return await this._analyze(false);
}
let { result, canvas } = analysis;
if (!result) {
return null;
}
async _analyze(skipDups): Promise<{ content: { result: string, error: string }, image?: string }> {
let analysis: { result: { result: string, error: string }, canvas: HTMLCanvasElement } = await this._analyzer.analyze();
if (!analysis) {
return null;
}
if (skipDups && result === this._lastResult) {
return null;
}
let { result, canvas } = analysis;
if (!result) {
return null;
}
clearTimeout(this.refractoryTimeout);
this.refractoryTimeout = setTimeout(() => {
this._lastResult = null;
}, this.refractoryPeriod);
if (skipDups && result === this._lastResult) {
return null;
}
let image = this.captureImage ? canvas.toDataURL('image/webp', 0.8) : null;
clearTimeout(this.refractoryTimeout);
this.refractoryTimeout = setTimeout(() => {
this._lastResult = null;
}, this.refractoryPeriod);
this._lastResult = result;
let image = this.captureImage ? canvas.toDataURL('image/webp', 0.8) : null;
let payload = { content: result };
if (image) {
payload["image"] = image;
}
this._lastResult = result;
return payload;
}
let payload = { content: result };
if (image) {
payload["image"] = image;
}
async _scan() {
while (true) {
if (!this._active || !this._video.videoWidth) {
// Camera feed not loaded yet
await new Promise(resolve => setTimeout(resolve, 250));
continue;
}
return payload;
}
if (++this._frameCount !== this.scanPeriod) {
return;
} else {
this._frameCount = 0;
}
let result = await this._analyze(true);
if (result) {
setTimeout(() => {
this._emitter.emit('scan', result.content, result.image || null);
}, 0);
}
}
async _scan() {
while (true) {
if (!this._active || !this._video.videoWidth) {
// Camera feed not loaded yet
await new Promise(resolve => setTimeout(resolve, 250));
continue;
}
}
if (++this._frameCount !== this.scanPeriod) {
return;
} else {
this._frameCount = 0;
}
let result = await this._analyze(true);
if (result) {
setTimeout(() => {
this._emitter.emit('scan', result.content, result.image || null);
}, 0);
}
}
}
}
class Analyzer {
video: HTMLVideoElement;
imageDetailsLoaded: any;
sensorLeft: number;
sensorTop: number;
sensorWidth: number;
sensorHeight: number;
canvas: any = 'none';
canvasContext: CanvasRenderingContext2D;
decodeCallback: any;
constructor(video) {
this.video = video;
video: HTMLVideoElement;
imageDetailsLoaded: any;
sensorLeft: number;
sensorTop: number;
sensorWidth: number;
sensorHeight: number;
canvas: any = 'none';
canvasContext: CanvasRenderingContext2D;
decodeCallback: any;
this.sensorLeft = null;
this.sensorTop = null;
this.sensorWidth = null;
this.sensorHeight = null;
constructor(video) {
this.video = video;
this.canvas = document.createElement('canvas');
this.canvas.style.display = 'none';
this.canvasContext = this.canvas.getContext('2d');
}
this.sensorLeft = null;
this.sensorTop = null;
this.sensorWidth = null;
this.sensorHeight = null;
async analyze() {
if (!this.video.videoWidth) {
// video not loaded yet
return null;
}
this.canvas = document.createElement('canvas');
this.canvas.style.display = 'none';
this.canvasContext = this.canvas.getContext('2d');
}
let videoWidth = this.video.videoWidth;
let videoHeight = this.video.videoHeight;
async analyze() {
if (!this.video.videoWidth) {
// video not loaded yet
return null;
}
this.sensorWidth = videoWidth;
this.sensorHeight = videoHeight;
this.sensorLeft = Math.floor((videoWidth / 2) - (this.sensorWidth / 2));
this.sensorTop = Math.floor((videoHeight / 2) - (this.sensorHeight / 2));
let videoWidth = this.video.videoWidth;
let videoHeight = this.video.videoHeight;
this.canvas.width = this.sensorWidth;
this.canvas.height = this.sensorHeight;
this.sensorWidth = videoWidth;
this.sensorHeight = videoHeight;
this.sensorLeft = Math.floor((videoWidth / 2) - (this.sensorWidth / 2));
this.sensorTop = Math.floor((videoHeight / 2) - (this.sensorHeight / 2));
this.canvasContext.drawImage(
this.video,
this.sensorLeft,
this.sensorTop,
this.sensorWidth,
this.sensorHeight
);
this.canvas.width = this.sensorWidth;
this.canvas.height = this.sensorHeight;
let data = this.canvasContext.getImageData(0, 0, this.sensorWidth, this.sensorHeight).data;
this.canvasContext.drawImage(
this.video,
this.sensorLeft,
this.sensorTop,
this.sensorWidth,
this.sensorHeight
);
return {...await scanData(data, this.sensorWidth, this.sensorHeight), canvas: this.canvas}
let data = this.canvasContext.getImageData(0, 0, this.sensorWidth, this.sensorHeight).data;
}
return { ...await scanData(data, this.sensorWidth, this.sensorHeight), canvas: this.canvas }
}
}
export class Scanner extends EventEmitter {
video: any;
backgroundScan: any;
_continuous: any;
_analyzer: any;
_camera: Camera;
_scanner: any;
_mirror: boolean;
_fsm: any;
video: any;
backgroundScan: any;
_continuous: any;
_analyzer: any;
_camera: Camera;
_scanner: any;
_mirror: boolean;
_fsm: any;
constructor(opts) {
super();
constructor(opts) {
super();
this.video = this._configureVideo(opts);
this.mirror = (opts.mirror !== false);
this.backgroundScan = (opts.backgroundScan !== false);
this._continuous = (opts.continuous !== false);
this._analyzer = new Analyzer(this.video);
this._camera = null;
this.video = this._configureVideo(opts);
this.mirror = (opts.mirror !== false);
this.backgroundScan = (opts.backgroundScan !== false);
this._continuous = (opts.continuous !== false);
this._analyzer = new Analyzer(this.video);
this._camera = null;
let captureImage = opts.captureImage || false;
let scanPeriod = opts.scanPeriod || 1;
let refractoryPeriod = opts.refractoryPeriod || (5 * 1000);
let captureImage = opts.captureImage || false;
let scanPeriod = opts.scanPeriod || 1;
let refractoryPeriod = opts.refractoryPeriod || (5 * 1000);
this._scanner = new ScanProvider(this, this._analyzer, captureImage, scanPeriod, refractoryPeriod, this.video);
this._scanner = new ScanProvider(this, this._analyzer, captureImage, scanPeriod, refractoryPeriod, this.video);
Visibility.change((e, state) => {
if (state === 'visible') {
setTimeout(() => {
if (this._fsm.can('activate')) {
this._fsm.activate();
}
}, 0);
} else {
if (!this.backgroundScan && this._fsm.can('deactivate')) {
this._fsm.deactivate();
}
}
});
Visibility.change((e, state) => {
if (state === 'visible') {
setTimeout(() => {
if (this._fsm.can('activate')) {
this._fsm.activate();
}
}, 0);
} else {
if (!this.backgroundScan && this._fsm.can('deactivate')) {
this._fsm.deactivate();
}
}
});
this.addListener('active', () => {
this.video.classList.remove('inactive');
this.video.classList.add('active');
});
this.addListener('active', () => {
this.video.classList.remove('inactive');
this.video.classList.add('active');
});
this.addListener('inactive', () => {
this.video.classList.remove('active');
this.video.classList.add('inactive');
});
this.addListener('inactive', () => {
this.video.classList.remove('active');
this.video.classList.add('inactive');
});
this.emit('inactive');
}
this.emit('inactive');
}
scan() {
return this._scanner.scan();
}
scan() {
return this._scanner.scan();
}
async start(camera: Camera = null) {
this._fsm = await this._createStateMachine();
if (this._fsm.can('start')) {
await this._fsm.start(camera);
} else {
await this._fsm.stop();
await this._fsm.start(camera);
}
}
async start(camera: Camera = null) {
this._fsm = await this._createStateMachine();
if (this._fsm.can('start')) {
await this._fsm.start(camera);
} else {
await this._fsm.stop();
await this._fsm.start(camera);
}
}
async stop() {
if (this._fsm.can('stop')) {
await this._fsm.stop();
}
}
async stop() {
if (this._fsm.can('stop')) {
await this._fsm.stop();
}
}
set captureImage(capture) {
this._scanner.captureImage = capture;
}
set captureImage(capture) {
this._scanner.captureImage = capture;
}
get captureImage() {
return this._scanner.captureImage;
}
get captureImage() {
return this._scanner.captureImage;
}
set scanPeriod(period) {
this._scanner.scanPeriod = period;
}
set scanPeriod(period) {
this._scanner.scanPeriod = period;
}
get scanPeriod() {
return this._scanner.scanPeriod;
}
get scanPeriod() {
return this._scanner.scanPeriod;
}
set refractoryPeriod(period) {
this._scanner.refractoryPeriod = period;
}
set refractoryPeriod(period) {
this._scanner.refractoryPeriod = period;
}
get refractoryPeriod() {
return this._scanner.refractoryPeriod;
}
get refractoryPeriod() {
return this._scanner.refractoryPeriod;
}
set continuous(continuous) {
this._continuous = continuous;
set continuous(continuous) {
this._continuous = continuous;
if (continuous && this._fsm.current === 'active') {
this._scanner.start();
} else {
this._scanner.stop();
}
}
if (continuous && this._fsm.current === 'active') {
this._scanner.start();
} else {
this._scanner.stop();
}
}
get continuous() {
return this._continuous;
}
get continuous() {
return this._continuous;
}
set mirror(mirror) {
this._mirror = mirror;
set mirror(mirror) {
this._mirror = mirror;
if (mirror) {
this.video.style.MozTransform = 'scaleX(-1)';
this.video.style.webkitTransform = 'scaleX(-1)';
this.video.style.OTransform = 'scaleX(-1)';
this.video.style.msFilter = 'FlipH';
this.video.style.filter = 'FlipH';
this.video.style.transform = 'scaleX(-1)';
} else {
this.video.style.MozTransform = null;
this.video.style.webkitTransform = null;
this.video.style.OTransform = null;
this.video.style.msFilter = null;
this.video.style.filter = null;
this.video.style.transform = null;
}
}
if (mirror) {
this.video.style.MozTransform = 'scaleX(-1)';
this.video.style.webkitTransform = 'scaleX(-1)';
this.video.style.OTransform = 'scaleX(-1)';
this.video.style.msFilter = 'FlipH';
this.video.style.filter = 'FlipH';
this.video.style.transform = 'scaleX(-1)';
} else {
this.video.style.MozTransform = null;
this.video.style.webkitTransform = null;
this.video.style.OTransform = null;
this.video.style.msFilter = null;
this.video.style.filter = null;
this.video.style.transform = null;
}
}
get mirror() {
return this._mirror;
}
get mirror() {
return this._mirror;
}
async _enableScan(camera: Camera) {
this._camera = camera || this._camera;
if (!this._camera) {
throw new Error('Camera is not defined.');
}
async _enableScan(camera: Camera) {
this._camera = camera || this._camera;
if (!this._camera) {
throw new Error('Camera is not defined.');
}
let stream = await this._camera.start();
console.log("new Camera Stream", stream, ", Camera:", this._camera);
this.video.srcObject = stream;
let stream = await this._camera.start();
console.log("new Camera Stream",stream, ", Camera:", this._camera);
this.video.srcObject = stream;
if (this._continuous) {
this._scanner.start();
}
}
if (this._continuous) {
this._scanner.start();
}
}
_disableScan() {
this.video.src = '';
_disableScan() {
this.video.src = '';
if (this._scanner) {
this._scanner.stop();
}
if (this._scanner) {
this._scanner.stop();
}
if (this._camera) {
this._camera.stop();
}
}
if (this._camera) {
this._camera.stop();
}
}
_configureVideo(opts) {
if (opts.video) {
if (opts.video.tagName !== 'VIDEO') {
throw new Error('Video must be a <video> element.');
}
}
_configureVideo(opts) {
if (opts.video) {
if (opts.video.tagName !== 'VIDEO') {
throw new Error('Video must be a <video> element.');
}
}
let video = opts.video || document.createElement('video');
video.setAttribute('autoplay', 'autoplay');
let video = opts.video || document.createElement('video');
video.setAttribute('autoplay', 'autoplay');
return video;
}
return video;
}
async _createStateMachine() {
return StateMachine.create({
initial: 'stopped',
events: [
{
name: 'start',
from: 'stopped',
to: 'started'
},
{
name: 'stop',
from: ['started', 'active', 'inactive'],
to: 'stopped'
},
{
name: 'activate',
from: ['started', 'inactive'],
to: ['active', 'inactive'],
condition: function (options) {
if (Visibility.state() === 'visible' || this.backgroundScan) {
return 'active';
} else {
return 'inactive';
}
}
},
{
name: 'deactivate',
from: ['started', 'active'],
to: 'inactive'
}
],
callbacks: {
onenteractive: async (options: { args: any[]; }) => {
await this._enableScan(options.args[0]);
this.emit('active');
},
onleaveactive: () => {
this._disableScan();
this.emit('inactive');
},
onenteredstarted: async (options) => {
await this._fsm.activate(options.args[0]);
}
}
});
}
async _createStateMachine() {
return StateMachine.create({
initial: 'stopped',
events: [
{
name: 'start',
from: 'stopped',
to: 'started'
},
{
name: 'stop',
from: ['started', 'active', 'inactive'],
to: 'stopped'
},
{
name: 'activate',
from: ['started', 'inactive'],
to: ['active', 'inactive'],
condition: function (options) {
if (Visibility.state() === 'visible' || this.backgroundScan) {
return 'active';
} else {
return 'inactive';
}
}
},
{
name: 'deactivate',
from: ['started', 'active'],
to: 'inactive'
}
],
callbacks: {
onenteractive: async (options: { args: any[]; }) => {
await this._enableScan(options.args[0]);
this.emit('active');
},
onleaveactive: () => {
this._disableScan();
this.emit('inactive');
},
onenteredstarted: async (options) => {
await this._fsm.activate(options.args[0]);
}
}
});
}
}
const errorMap: { [index: string]: string } = {
"Cannot access video stream (NotAllowedError).": "Looks like we don’t have permission to access your camera. Please allow camera access.",
"Cannot access video stream (NotReadableError).": "Looks like we can’t get access to the camera. Try choosing another or quit apps that have exclusive access on the camera.",
"Cannot access video stream (NotFoundError).": "Looks like your device does not have a camera or your browser can’t find it.",
"Camera Permission denied": "Looks like we don’t have permission to access your camera. Please allow camera access.",
"WebAssembly Not Supported": "Your browser does not support WebAssembly. Please use the latest version of Chrome, Firefox or Safari.",
"Cannot access video stream (NotAllowedError).": "Looks like we don’t have permission to access your camera. Please allow camera access.",
"Cannot access video stream (NotReadableError).": "Looks like we can’t get access to the camera. Try choosing another or quit apps that have exclusive access on the camera.",
"Cannot access video stream (NotFoundError).": "Looks like your device does not have a camera or your browser can’t find it.",
"Camera Permission denied": "Looks like we don’t have permission to access your camera. Please allow camera access.",
"WebAssembly Not Supported": "Your browser does not support WebAssembly. Please use the latest version of Chrome, Firefox or Safari.",
}
export function mediaErrorToMessage(err: Error): string {
console.error("Media Error:", err.message)
console.error("Media Error:", err.message)
return errorMap[err.message] ?? `Unknown Error (${err.message})`
return errorMap[err.message] ?? `Unknown Error (${err.message})`
}

@@ -1,26 +0,27 @@

let barcodeDetector: BarcodeDetector = null;
BarcodeDetector.getSupportedFormats().then((formats)=>{
barcodeDetector = new BarcodeDetector({formats});
let barcodeDetector: BarcodeDetector;
BarcodeDetector.getSupportedFormats().then((formats) => {
barcodeDetector = new BarcodeDetector({formats});
});
self.addEventListener("message", e => {
const {data, width, height} = e.data as DataInput;
if (barcodeDetector) {
barcodeDetector.detect(new ImageData(data, width, height)).then(result => {
if (result.length > 0) {
self.postMessage(result[0].rawValue);
} else {
self.postMessage(null);
}
});
} else {
// Barcode API hasn't loaded yet
setTimeout(()=>{self.postMessage(null)}, 50);
}
const { data, width, height } = e.data as DataInput;
if (barcodeDetector) {
barcodeDetector.detect(new ImageData(data, width, height)).then(result => {
if (result.length > 0) {
self.postMessage(result[0].rawValue);
} else {
self.postMessage(null);
}
});
} else {
// Barcode API hasn't loaded yet
setTimeout(() => { self.postMessage(null) }, 50);
}
});
export interface DataInput {
data: Uint8ClampedArray;
width: number;
height: number;
}
data: Uint8ClampedArray;
width: number;
height: number;
}

@@ -5,16 +5,15 @@

export function saveValue(key: string, value: any) {
if (typeof localStorage!=="undefined"){
localStorage.setItem(NAMESPACE+key,JSON.stringify(value))
}
if (typeof localStorage !== "undefined") {
localStorage.setItem(NAMESPACE + key, JSON.stringify(value))
}
}
export function getValue(key: string): any {
if (typeof localStorage!=="undefined"){
try {
return JSON.parse(localStorage.getItem(NAMESPACE+key));
} catch {
return undefined
}
}
if (typeof localStorage !== "undefined") {
try {
return JSON.parse(localStorage.getItem(NAMESPACE + key));
} catch {
return undefined
}
}
}
import ZXingModule from './zxing';
let ZXing = ZXingModule({}).then(function (instance) {
ZXing = instance;
ZXing = instance;
});
self.addEventListener("message", e => {
const {data, width, height} = e.data as DataInput;
const { data, width, height } = e.data as DataInput;
if (ZXing != null) {
var buffer = ZXing._malloc(data.byteLength);
ZXing.HEAPU8.set(data, buffer);
var result = ZXing.readBarcodeFromPixmap(buffer, width, height, true, "");
ZXing._free(buffer);
if (ZXing != null) {
var buffer = ZXing._malloc(data.byteLength);
ZXing.HEAPU8.set(data, buffer);
var result = ZXing.readBarcodeFromPixmap(buffer, width, height, true, "");
ZXing._free(buffer);
self.postMessage(result.text || null);
} else {
console.log("ZXing is not loaded")
self.postMessage(null);
}
self.postMessage(result.text || null);
} else {
console.log("ZXing is not loaded")
self.postMessage(null);
}
});
export interface DataInput {
data: Uint8ClampedArray;
width: number;
height: number;
}
data: Uint8ClampedArray;
width: number;
height: number;
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc