@capacitor/barcode-scanner 2.2.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorBarcodeScanner.podspec +1 -1
- package/Package.swift +2 -2
- package/README.md +8 -2
- package/android/build.gradle +20 -19
- package/dist/docs.json +3 -3
- package/dist/esm/definitions.d.ts +8 -1
- package/dist/esm/definitions.js +1 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +13 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils.js +15 -12
- package/dist/esm/utils.js.map +1 -1
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +42 -35
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +62 -49
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +62 -49
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapacitorBarcodeScannerPlugin/CapacitorBarcodeScannerPlugin.swift +4 -4
- package/ios/Tests/CapacitorBarcodeScannerPluginTests/OSBarcodeTests.swift +0 -9
- package/package.json +19 -19
package/dist/plugin.cjs.js
CHANGED
|
@@ -46,18 +46,21 @@ exports.CapacitorBarcodeScannerAndroidScanningLibrary = void 0;
|
|
|
46
46
|
* Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.
|
|
47
47
|
*/
|
|
48
48
|
const barcodeScannerCss = [
|
|
49
|
-
{ selector:
|
|
49
|
+
{ selector: ".scanner-container-display", css: "display: block;" },
|
|
50
50
|
{
|
|
51
|
-
selector:
|
|
52
|
-
css:
|
|
51
|
+
selector: ".scanner-dialog",
|
|
52
|
+
css: "display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);",
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
selector:
|
|
56
|
-
css:
|
|
55
|
+
selector: ".scanner-dialog-inner",
|
|
56
|
+
css: "background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;",
|
|
57
57
|
},
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
{
|
|
59
|
+
selector: ".close-button",
|
|
60
|
+
css: "color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;",
|
|
61
|
+
},
|
|
62
|
+
{ selector: ".close-button:hover", css: "color: #222;" },
|
|
63
|
+
{ selector: ".scanner-container-full-width", css: "width: 100%;" },
|
|
61
64
|
];
|
|
62
65
|
/**
|
|
63
66
|
* Dynamically applies a set of CSS rules to the document.
|
|
@@ -68,12 +71,12 @@ const barcodeScannerCss = [
|
|
|
68
71
|
* @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.
|
|
69
72
|
*/
|
|
70
73
|
function applyCss(cssRules) {
|
|
71
|
-
const styleId =
|
|
74
|
+
const styleId = "custom-style-os-cap-barcode"; // Unique identifier for the style element.
|
|
72
75
|
let styleElement = document.getElementById(styleId);
|
|
73
76
|
if (!styleElement) {
|
|
74
77
|
// Create and append a new style element if it does not exist.
|
|
75
|
-
styleElement = document.createElement(
|
|
76
|
-
styleElement.type =
|
|
78
|
+
styleElement = document.createElement("style");
|
|
79
|
+
styleElement.type = "text/css";
|
|
77
80
|
styleElement.id = styleId;
|
|
78
81
|
document.head.appendChild(styleElement);
|
|
79
82
|
}
|
|
@@ -89,7 +92,7 @@ function applyCss(cssRules) {
|
|
|
89
92
|
}
|
|
90
93
|
else {
|
|
91
94
|
// Fallback for older browsers using textContent.
|
|
92
|
-
styleElement.textContent =
|
|
95
|
+
styleElement.textContent = "";
|
|
93
96
|
for (const { selector, css } of cssRules) {
|
|
94
97
|
styleElement.textContent += `${selector} { ${css} }`;
|
|
95
98
|
}
|
|
@@ -101,7 +104,7 @@ function applyCss(cssRules) {
|
|
|
101
104
|
* For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.
|
|
102
105
|
* This allows for lazy loading of the web code only when needed, optimizing overall bundle size.
|
|
103
106
|
*/
|
|
104
|
-
const CapacitorBarcodeScannerImpl = core.registerPlugin(
|
|
107
|
+
const CapacitorBarcodeScannerImpl = core.registerPlugin("CapacitorBarcodeScanner", {
|
|
105
108
|
web: () => {
|
|
106
109
|
applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.
|
|
107
110
|
return Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.
|
|
@@ -109,15 +112,19 @@ const CapacitorBarcodeScannerImpl = core.registerPlugin('CapacitorBarcodeScanner
|
|
|
109
112
|
});
|
|
110
113
|
class CapacitorBarcodeScanner {
|
|
111
114
|
static async scanBarcode(options) {
|
|
112
|
-
options.scanInstructions = options.scanInstructions ||
|
|
115
|
+
options.scanInstructions = options.scanInstructions || " "; // Ensure scanInstructions is at least a space.
|
|
113
116
|
options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.
|
|
114
|
-
options.scanText = options.scanText ||
|
|
115
|
-
options.cameraDirection =
|
|
116
|
-
|
|
117
|
+
options.scanText = options.scanText || " "; // Ensure scanText is at least a space.
|
|
118
|
+
options.cameraDirection =
|
|
119
|
+
options.cameraDirection || exports.CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.
|
|
120
|
+
options.scanOrientation =
|
|
121
|
+
options.scanOrientation ||
|
|
122
|
+
exports.CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.
|
|
117
123
|
return CapacitorBarcodeScannerImpl.scanBarcode(options);
|
|
118
124
|
}
|
|
119
125
|
}
|
|
120
126
|
|
|
127
|
+
/* eslint-env browser */
|
|
121
128
|
/**
|
|
122
129
|
* Implements OSBarcodePlugin to provide web functionality for barcode scanning.
|
|
123
130
|
*/
|
|
@@ -133,8 +140,7 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
133
140
|
await window.OSBarcodeWebScanner.stop();
|
|
134
141
|
window.OSBarcodeWebScanner = null;
|
|
135
142
|
}
|
|
136
|
-
|
|
137
|
-
document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';
|
|
143
|
+
document.getElementById("cap-os-barcode-scanner-container-dialog").style.display = "none";
|
|
138
144
|
}
|
|
139
145
|
/**
|
|
140
146
|
* Builds the HTML elements necessary for the barcode scanner UI.
|
|
@@ -143,34 +149,38 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
143
149
|
* @private
|
|
144
150
|
*/
|
|
145
151
|
buildScannerElement() {
|
|
146
|
-
if (document.getElementById(
|
|
147
|
-
|
|
148
|
-
|
|
152
|
+
if (document.getElementById("cap-os-barcode-scanner-container")) {
|
|
153
|
+
document.getElementById("cap-os-barcode-scanner-container").className =
|
|
154
|
+
"scanner-container-display";
|
|
149
155
|
return;
|
|
150
156
|
}
|
|
151
157
|
// Create and configure scanner container elements
|
|
152
|
-
const caposbarcodescannercontainer = document.body.appendChild(document.createElement(
|
|
153
|
-
caposbarcodescannercontainer.id =
|
|
154
|
-
const caposbarcodescannercontainerdialog = document.createElement(
|
|
155
|
-
caposbarcodescannercontainerdialog.id =
|
|
156
|
-
|
|
158
|
+
const caposbarcodescannercontainer = document.body.appendChild(document.createElement("div"));
|
|
159
|
+
caposbarcodescannercontainer.id = "cap-os-barcode-scanner-container";
|
|
160
|
+
const caposbarcodescannercontainerdialog = document.createElement("div");
|
|
161
|
+
caposbarcodescannercontainerdialog.id =
|
|
162
|
+
"cap-os-barcode-scanner-container-dialog";
|
|
163
|
+
caposbarcodescannercontainerdialog.className = "scanner-dialog";
|
|
157
164
|
// Inner dialog elements including the close button and scanner view
|
|
158
|
-
const caposbarcodescannercontainerdialoginner = document.createElement(
|
|
159
|
-
caposbarcodescannercontainerdialoginner.className =
|
|
160
|
-
const caposbarcodescannercontainerdialoginnerclose = document.createElement(
|
|
161
|
-
caposbarcodescannercontainerdialoginnerclose.className =
|
|
162
|
-
caposbarcodescannercontainerdialoginnerclose.innerHTML =
|
|
165
|
+
const caposbarcodescannercontainerdialoginner = document.createElement("div");
|
|
166
|
+
caposbarcodescannercontainerdialoginner.className = "scanner-dialog-inner";
|
|
167
|
+
const caposbarcodescannercontainerdialoginnerclose = document.createElement("span");
|
|
168
|
+
caposbarcodescannercontainerdialoginnerclose.className = "close-button";
|
|
169
|
+
caposbarcodescannercontainerdialoginnerclose.innerHTML = "×";
|
|
163
170
|
caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);
|
|
164
|
-
const caposbarcodescannercontainerdialoginnercontainerp = document.createElement(
|
|
165
|
-
caposbarcodescannercontainerdialoginnercontainerp.innerHTML =
|
|
171
|
+
const caposbarcodescannercontainerdialoginnercontainerp = document.createElement("p");
|
|
172
|
+
caposbarcodescannercontainerdialoginnercontainerp.innerHTML = " ";
|
|
166
173
|
caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);
|
|
167
|
-
const caposbarcodescannercontainerdialoginnercontainer = document.createElement(
|
|
168
|
-
caposbarcodescannercontainerdialoginnercontainer.className =
|
|
169
|
-
|
|
174
|
+
const caposbarcodescannercontainerdialoginnercontainer = document.createElement("div");
|
|
175
|
+
caposbarcodescannercontainerdialoginnercontainer.className =
|
|
176
|
+
"scanner-container-full-width";
|
|
177
|
+
caposbarcodescannercontainerdialoginnercontainer.id =
|
|
178
|
+
"cap-os-barcode-scanner-container-scanner";
|
|
170
179
|
caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);
|
|
171
180
|
caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);
|
|
172
181
|
caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);
|
|
173
|
-
caposbarcodescannercontainerdialoginnerclose.onclick =
|
|
182
|
+
caposbarcodescannercontainerdialoginnerclose.onclick =
|
|
183
|
+
this.stopAndHideScanner;
|
|
174
184
|
}
|
|
175
185
|
/**
|
|
176
186
|
* Initiates a barcode scan using the user's camera and HTML5 QR code scanner.
|
|
@@ -180,25 +190,28 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
180
190
|
*/
|
|
181
191
|
async scanBarcode(options) {
|
|
182
192
|
this.buildScannerElement();
|
|
183
|
-
|
|
184
|
-
document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';
|
|
193
|
+
document.getElementById("cap-os-barcode-scanner-container-dialog").style.display = "block";
|
|
185
194
|
return new Promise((resolve, reject) => {
|
|
186
195
|
var _a, _b;
|
|
187
196
|
const param = {
|
|
188
|
-
facingMode: options.cameraDirection === 1 ?
|
|
197
|
+
facingMode: options.cameraDirection === 1 ? "environment" : "user",
|
|
189
198
|
scanButton: options.scanButton === undefined ? false : options.scanButton,
|
|
190
|
-
scanInstructions: options.scanInstructions
|
|
199
|
+
scanInstructions: options.scanInstructions
|
|
200
|
+
? options.scanInstructions
|
|
201
|
+
: "",
|
|
191
202
|
orientation: options.scanOrientation
|
|
192
203
|
? options.scanOrientation
|
|
193
204
|
: exports.CapacitorBarcodeScannerScanOrientation.PORTRAIT,
|
|
194
|
-
showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection)
|
|
205
|
+
showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection)
|
|
206
|
+
? options.web.showCameraSelection
|
|
207
|
+
: false,
|
|
195
208
|
typeHint: options.hint === 17 ? undefined : options.hint,
|
|
196
209
|
scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,
|
|
197
210
|
};
|
|
198
211
|
// Set up and start the scanner
|
|
199
|
-
const scannerElement = document.getElementById(
|
|
212
|
+
const scannerElement = document.getElementById("cap-os-barcode-scanner-container-scanner");
|
|
200
213
|
if (!scannerElement) {
|
|
201
|
-
throw new Error(
|
|
214
|
+
throw new Error("Scanner Element is required for web");
|
|
202
215
|
}
|
|
203
216
|
window.OSBarcodeWebScanner = new html5Qrcode.Html5Qrcode(scannerElement.id, {
|
|
204
217
|
formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,
|
|
@@ -209,7 +222,7 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
209
222
|
qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,
|
|
210
223
|
aspectRatio: 16 / 9,
|
|
211
224
|
videoConstraints: {
|
|
212
|
-
focusMode:
|
|
225
|
+
focusMode: "continuous",
|
|
213
226
|
height: { min: 576, ideal: 1920 },
|
|
214
227
|
deviceId: undefined,
|
|
215
228
|
facingMode: param.facingMode,
|
|
@@ -226,9 +239,9 @@ class CapacitorBarcodeScannerWeb extends core.WebPlugin {
|
|
|
226
239
|
};
|
|
227
240
|
const OSBarcodeWebScannerErrorCallback = (error) => {
|
|
228
241
|
const allowedErrors = [
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
242
|
+
"NotFoundException",
|
|
243
|
+
"No barcode or QR code detected",
|
|
244
|
+
"No MultiFormat Readers were able to detect the code",
|
|
232
245
|
];
|
|
233
246
|
if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {
|
|
234
247
|
this.stopAndHideScanner();
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/utils.js","esm/index.js","esm/web.js"],"sourcesContent":["import { Html5QrcodeSupportedFormats } from 'html5-qrcode';\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport var CapacitorBarcodeScannerScanOrientation;\n(function (CapacitorBarcodeScannerScanOrientation) {\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"PORTRAIT\"] = 1] = \"PORTRAIT\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"LANDSCAPE\"] = 2] = \"LANDSCAPE\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"ADAPTIVE\"] = 3] = \"ADAPTIVE\";\n})(CapacitorBarcodeScannerScanOrientation || (CapacitorBarcodeScannerScanOrientation = {}));\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport var CapacitorBarcodeScannerTypeHintALLOption;\n(function (CapacitorBarcodeScannerTypeHintALLOption) {\n CapacitorBarcodeScannerTypeHintALLOption[CapacitorBarcodeScannerTypeHintALLOption[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHintALLOption || (CapacitorBarcodeScannerTypeHintALLOption = {}));\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = Object.assign(Object.assign({}, Html5QrcodeSupportedFormats), CapacitorBarcodeScannerTypeHintALLOption);\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Predefined CSS rules for styling barcode scanner components.\n * Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.\n */\nexport const barcodeScannerCss = [\n { selector: '.scanner-container-display', css: 'display: block;' },\n {\n selector: '.scanner-dialog',\n css: 'display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);',\n },\n {\n selector: '.scanner-dialog-inner',\n css: 'background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;',\n },\n { selector: '.close-button', css: 'color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;' },\n { selector: '.close-button:hover', css: 'color: #222;' },\n { selector: '.scanner-container-full-width', css: 'width: 100%;' },\n];\n/**\n * Dynamically applies a set of CSS rules to the document.\n * If a custom style element with a specific ID does not exist, it is created and appended to the document's head.\n * Existing rules in the style element are cleared before new ones are applied.\n * This function supports both modern and older browsers by using `CSSStyleSheet.insertRule` and `textContent` respectively.\n *\n * @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.\n */\nexport function applyCss(cssRules) {\n const styleId = 'custom-style-os-cap-barcode'; // Unique identifier for the style element.\n let styleElement = document.getElementById(styleId);\n if (!styleElement) {\n // Create and append a new style element if it does not exist.\n styleElement = document.createElement('style');\n styleElement.type = 'text/css';\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n }\n if (styleElement.sheet) {\n // Clear existing CSS rules.\n while (styleElement.sheet.cssRules.length) {\n styleElement.sheet.deleteRule(0);\n }\n // Insert new CSS rules.\n for (const { selector, css } of cssRules) {\n styleElement.sheet.insertRule(`${selector} { ${css} }`);\n }\n }\n else {\n // Fallback for older browsers using textContent.\n styleElement.textContent = '';\n for (const { selector, css } of cssRules) {\n styleElement.textContent += `${selector} { ${css} }`;\n }\n }\n}\n//# sourceMappingURL=utils.js.map","import { registerPlugin } from '@capacitor/core';\nimport { CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, } from './definitions'; // Importing the interface for type checking.\nimport { applyCss, barcodeScannerCss } from './utils'; // Import utilities for applying CSS.\n/**\n * Registers the `OSBarcode` plugin with Capacitor.\n * For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.\n * This allows for lazy loading of the web code only when needed, optimizing overall bundle size.\n */\nconst CapacitorBarcodeScannerImpl = registerPlugin('CapacitorBarcodeScanner', {\n web: () => {\n applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.\n return import('./web').then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.\n },\n});\nclass CapacitorBarcodeScanner {\n static async scanBarcode(options) {\n options.scanInstructions = options.scanInstructions || ' '; // Ensure scanInstructions is at least a space.\n options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.\n options.scanText = options.scanText || ' '; // Ensure scanText is at least a space.\n options.cameraDirection = options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.\n options.scanOrientation = options.scanOrientation || CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.\n return CapacitorBarcodeScannerImpl.scanBarcode(options);\n }\n}\nexport { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.\nexport * from './definitions'; // Re-export all exports from the definitions file.\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nimport { Html5Qrcode } from 'html5-qrcode';\nimport { CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerTypeHint } from './definitions';\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n async stopAndHideScanner() {\n console.log(window.OSBarcodeWebScanner);\n if (window.OSBarcodeWebScanner) {\n await window.OSBarcodeWebScanner.stop();\n window.OSBarcodeWebScanner = null;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';\n }\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n buildScannerElement() {\n if (document.getElementById('cap-os-barcode-scanner-container')) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container').className = 'scanner-container-display';\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement('div'));\n caposbarcodescannercontainer.id = 'cap-os-barcode-scanner-container';\n const caposbarcodescannercontainerdialog = document.createElement('div');\n caposbarcodescannercontainerdialog.id = 'cap-os-barcode-scanner-container-dialog';\n caposbarcodescannercontainerdialog.className = 'scanner-dialog';\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement('div');\n caposbarcodescannercontainerdialoginner.className = 'scanner-dialog-inner';\n const caposbarcodescannercontainerdialoginnerclose = document.createElement('span');\n caposbarcodescannercontainerdialoginnerclose.className = 'close-button';\n caposbarcodescannercontainerdialoginnerclose.innerHTML = '×';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement('p');\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = ' ';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement('div');\n caposbarcodescannercontainerdialoginnercontainer.className = 'scanner-container-full-width';\n caposbarcodescannercontainerdialoginnercontainer.id = 'cap-os-barcode-scanner-container-scanner';\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n caposbarcodescannercontainerdialoginnerclose.onclick = this.stopAndHideScanner;\n }\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options) {\n this.buildScannerElement();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';\n return new Promise((resolve, reject) => {\n var _a, _b;\n const param = {\n facingMode: options.cameraDirection === 1 ? 'environment' : 'user',\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions ? options.scanInstructions : '',\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection) ? options.web.showCameraSelection : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,\n };\n // Set up and start the scanner\n const scannerElement = document.getElementById('cap-os-barcode-scanner-container-scanner');\n if (!scannerElement) {\n throw new Error('Scanner Element is required for web');\n }\n window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id, {\n formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,\n verbose: undefined,\n });\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: 'continuous',\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {\n var _a, _b;\n this.stopAndHideScanner();\n resolve({\n ScanResult: decodedText,\n format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,\n });\n };\n const OSBarcodeWebScannerErrorCallback = (error) => {\n const allowedErrors = [\n 'NotFoundException',\n 'No barcode or QR code detected',\n 'No MultiFormat Readers were able to detect the code',\n ];\n if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n window.OSBarcodeWebScanner.start({ facingMode: param.facingMode }, Html5QrcodeConfig, OSBarcodeWebScannerSuccessCallback, OSBarcodeWebScannerErrorCallback);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerScanOrientation","CapacitorBarcodeScannerTypeHintALLOption","Html5QrcodeSupportedFormats","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin","WebPlugin","Html5Qrcode"],"mappings":";;;;;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,sCAAsC,EAAE;AACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACvG,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO;AACzG,CAAC,EAAEA,8CAAsC,KAAKA,8CAAsC,GAAG,EAAE,CAAC,CAAC;AAC3F;AACA;AACA;AACWC;AACX,CAAC,UAAU,sCAAsC,EAAE;AACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,GAAG,UAAU;AAC/G,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,WAAW;AACjH,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,CAAC,GAAG,CAAC,C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W;AAC3C,oBAAoB,MAAM,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,MAAM,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,EAAE,GAAG,+BAA+B,CAAC,GAAG;AACzL,iBAAiB,CAAC;AAClB,YAAY,CAAC;AACb,YAAY,MAAM,gCAAgC,GAAG,CAAC,KAAK,KAAK;AAChE,gBAAgB,MAAM,aAAa,GAAG;AACtC,oBAAoB,mBAAmB;AACvC,oBAAoB,gCAAgC;AACpD,oBAAoB,qDAAqD;AACzE,iBAAiB;AACjB,gBAAgB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE;AACzE,oBAAoB,IAAI,CAAC,kBAAkB,EAAE;AAC7C,oBAAoB,OAAO,CAAC,KAAK,CAAC,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC,CAAC;AACjE,oBAAoB,MAAM,CAAC,KAAK,CAAC;AACjC,gBAAgB;AAChB,YAAY,CAAC;AACb,YAAY,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,iBAAiB,EAAE,kCAAkC,EAAE,gCAAgC,CAAC;AACvK,QAAQ,CAAC,CAAC;AACV,IAAI;AACJ;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/utils.js","esm/index.js","esm/web.js"],"sourcesContent":["import { Html5QrcodeSupportedFormats } from \"html5-qrcode\";\n/**\n * Enum representing the direction of the camera to be used for barcode scanning.\n */\nexport var CapacitorBarcodeScannerCameraDirection;\n(function (CapacitorBarcodeScannerCameraDirection) {\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"BACK\"] = 1] = \"BACK\";\n CapacitorBarcodeScannerCameraDirection[CapacitorBarcodeScannerCameraDirection[\"FRONT\"] = 2] = \"FRONT\";\n})(CapacitorBarcodeScannerCameraDirection || (CapacitorBarcodeScannerCameraDirection = {}));\n/**\n * Enum representing the orientation of the scanner during barcode scanning.\n */\nexport var CapacitorBarcodeScannerScanOrientation;\n(function (CapacitorBarcodeScannerScanOrientation) {\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"PORTRAIT\"] = 1] = \"PORTRAIT\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"LANDSCAPE\"] = 2] = \"LANDSCAPE\";\n CapacitorBarcodeScannerScanOrientation[CapacitorBarcodeScannerScanOrientation[\"ADAPTIVE\"] = 3] = \"ADAPTIVE\";\n})(CapacitorBarcodeScannerScanOrientation || (CapacitorBarcodeScannerScanOrientation = {}));\n/**\n * Enum representing a special option to indicate that all barcode types are supported.\n */\nexport var CapacitorBarcodeScannerTypeHintALLOption;\n(function (CapacitorBarcodeScannerTypeHintALLOption) {\n CapacitorBarcodeScannerTypeHintALLOption[CapacitorBarcodeScannerTypeHintALLOption[\"ALL\"] = 17] = \"ALL\";\n})(CapacitorBarcodeScannerTypeHintALLOption || (CapacitorBarcodeScannerTypeHintALLOption = {}));\n/**\n * Extends supported formats from Html5Qrcode with a special 'ALL' option,\n * indicating support for all barcode types.\n */\nexport const CapacitorBarcodeScannerTypeHint = Object.assign(Object.assign({}, Html5QrcodeSupportedFormats), CapacitorBarcodeScannerTypeHintALLOption);\n/**\n * Enum representing the library to be used for barcode scanning on Android devices.\n */\nexport var CapacitorBarcodeScannerAndroidScanningLibrary;\n(function (CapacitorBarcodeScannerAndroidScanningLibrary) {\n CapacitorBarcodeScannerAndroidScanningLibrary[\"ZXING\"] = \"zxing\";\n CapacitorBarcodeScannerAndroidScanningLibrary[\"MLKIT\"] = \"mlkit\";\n})(CapacitorBarcodeScannerAndroidScanningLibrary || (CapacitorBarcodeScannerAndroidScanningLibrary = {}));\n//# sourceMappingURL=definitions.js.map","/**\n * Predefined CSS rules for styling barcode scanner components.\n * Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.\n */\nexport const barcodeScannerCss = [\n { selector: \".scanner-container-display\", css: \"display: block;\" },\n {\n selector: \".scanner-dialog\",\n css: \"display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);\",\n },\n {\n selector: \".scanner-dialog-inner\",\n css: \"background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;\",\n },\n {\n selector: \".close-button\",\n css: \"color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;\",\n },\n { selector: \".close-button:hover\", css: \"color: #222;\" },\n { selector: \".scanner-container-full-width\", css: \"width: 100%;\" },\n];\n/**\n * Dynamically applies a set of CSS rules to the document.\n * If a custom style element with a specific ID does not exist, it is created and appended to the document's head.\n * Existing rules in the style element are cleared before new ones are applied.\n * This function supports both modern and older browsers by using `CSSStyleSheet.insertRule` and `textContent` respectively.\n *\n * @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.\n */\nexport function applyCss(cssRules) {\n const styleId = \"custom-style-os-cap-barcode\"; // Unique identifier for the style element.\n let styleElement = document.getElementById(styleId);\n if (!styleElement) {\n // Create and append a new style element if it does not exist.\n styleElement = document.createElement(\"style\");\n styleElement.type = \"text/css\";\n styleElement.id = styleId;\n document.head.appendChild(styleElement);\n }\n if (styleElement.sheet) {\n // Clear existing CSS rules.\n while (styleElement.sheet.cssRules.length) {\n styleElement.sheet.deleteRule(0);\n }\n // Insert new CSS rules.\n for (const { selector, css } of cssRules) {\n styleElement.sheet.insertRule(`${selector} { ${css} }`);\n }\n }\n else {\n // Fallback for older browsers using textContent.\n styleElement.textContent = \"\";\n for (const { selector, css } of cssRules) {\n styleElement.textContent += `${selector} { ${css} }`;\n }\n }\n}\n//# sourceMappingURL=utils.js.map","import { registerPlugin } from \"@capacitor/core\";\nimport { CapacitorBarcodeScannerCameraDirection, CapacitorBarcodeScannerScanOrientation, } from \"./definitions\"; // Importing the interface for type checking.\nimport { applyCss, barcodeScannerCss } from \"./utils\"; // Import utilities for applying CSS.\n/**\n * Registers the `OSBarcode` plugin with Capacitor.\n * For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.\n * This allows for lazy loading of the web code only when needed, optimizing overall bundle size.\n */\nconst CapacitorBarcodeScannerImpl = registerPlugin(\"CapacitorBarcodeScanner\", {\n web: () => {\n applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.\n return import(\"./web\").then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.\n },\n});\nclass CapacitorBarcodeScanner {\n static async scanBarcode(options) {\n options.scanInstructions = options.scanInstructions || \" \"; // Ensure scanInstructions is at least a space.\n options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.\n options.scanText = options.scanText || \" \"; // Ensure scanText is at least a space.\n options.cameraDirection =\n options.cameraDirection || CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.\n options.scanOrientation =\n options.scanOrientation ||\n CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.\n return CapacitorBarcodeScannerImpl.scanBarcode(options);\n }\n}\nexport { CapacitorBarcodeScanner }; // Export the `CapacitorBarcodeScanner` class.\nexport * from \"./definitions\"; // Re-export all exports from the definitions file.\n//# sourceMappingURL=index.js.map","/* eslint-env browser */\nimport { WebPlugin } from \"@capacitor/core\";\nimport { Html5Qrcode } from \"html5-qrcode\";\nimport { CapacitorBarcodeScannerScanOrientation, CapacitorBarcodeScannerTypeHint, } from \"./definitions\";\n/**\n * Implements OSBarcodePlugin to provide web functionality for barcode scanning.\n */\nexport class CapacitorBarcodeScannerWeb extends WebPlugin {\n /**\n * Stops the barcode scanner and hides its UI.\n * @private\n * @returns {Promise<void>} A promise that resolves when the scanner has stopped and its UI is hidden.\n */\n async stopAndHideScanner() {\n console.log(window.OSBarcodeWebScanner);\n if (window.OSBarcodeWebScanner) {\n await window.OSBarcodeWebScanner.stop();\n window.OSBarcodeWebScanner = null;\n }\n document.getElementById(\"cap-os-barcode-scanner-container-dialog\").style.display = \"none\";\n }\n /**\n * Builds the HTML elements necessary for the barcode scanner UI.\n * This method checks if the scanner container exists before creating it to avoid duplicates.\n * It also sets up the close button to stop and hide the scanner on click.\n * @private\n */\n buildScannerElement() {\n if (document.getElementById(\"cap-os-barcode-scanner-container\")) {\n document.getElementById(\"cap-os-barcode-scanner-container\").className =\n \"scanner-container-display\";\n return;\n }\n // Create and configure scanner container elements\n const caposbarcodescannercontainer = document.body.appendChild(document.createElement(\"div\"));\n caposbarcodescannercontainer.id = \"cap-os-barcode-scanner-container\";\n const caposbarcodescannercontainerdialog = document.createElement(\"div\");\n caposbarcodescannercontainerdialog.id =\n \"cap-os-barcode-scanner-container-dialog\";\n caposbarcodescannercontainerdialog.className = \"scanner-dialog\";\n // Inner dialog elements including the close button and scanner view\n const caposbarcodescannercontainerdialoginner = document.createElement(\"div\");\n caposbarcodescannercontainerdialoginner.className = \"scanner-dialog-inner\";\n const caposbarcodescannercontainerdialoginnerclose = document.createElement(\"span\");\n caposbarcodescannercontainerdialoginnerclose.className = \"close-button\";\n caposbarcodescannercontainerdialoginnerclose.innerHTML = \"×\";\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);\n const caposbarcodescannercontainerdialoginnercontainerp = document.createElement(\"p\");\n caposbarcodescannercontainerdialoginnercontainerp.innerHTML = \" \";\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);\n const caposbarcodescannercontainerdialoginnercontainer = document.createElement(\"div\");\n caposbarcodescannercontainerdialoginnercontainer.className =\n \"scanner-container-full-width\";\n caposbarcodescannercontainerdialoginnercontainer.id =\n \"cap-os-barcode-scanner-container-scanner\";\n caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);\n caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);\n caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);\n caposbarcodescannercontainerdialoginnerclose.onclick =\n this.stopAndHideScanner;\n }\n /**\n * Initiates a barcode scan using the user's camera and HTML5 QR code scanner.\n * Displays the scanner UI and waits for a scan to complete or fail.\n * @param {OSBarcodeScanOptions} options Configuration options for the scan, including camera direction and UI preferences.\n * @returns {Promise<OSBarcodeScanResult>} A promise that resolves with the scan result or rejects with an error.\n */\n async scanBarcode(options) {\n this.buildScannerElement();\n document.getElementById(\"cap-os-barcode-scanner-container-dialog\").style.display = \"block\";\n return new Promise((resolve, reject) => {\n var _a, _b;\n const param = {\n facingMode: options.cameraDirection === 1 ? \"environment\" : \"user\",\n hasScannerButton: false,\n scanButton: options.scanButton === undefined ? false : options.scanButton,\n showScanLine: false,\n scanInstructions: options.scanInstructions\n ? options.scanInstructions\n : \"\",\n orientation: options.scanOrientation\n ? options.scanOrientation\n : CapacitorBarcodeScannerScanOrientation.PORTRAIT,\n showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection)\n ? options.web.showCameraSelection\n : false,\n typeHint: options.hint === 17 ? undefined : options.hint,\n scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,\n };\n // Set up and start the scanner\n const scannerElement = document.getElementById(\"cap-os-barcode-scanner-container-scanner\");\n if (!scannerElement) {\n throw new Error(\"Scanner Element is required for web\");\n }\n window.OSBarcodeWebScanner = new Html5Qrcode(scannerElement.id, {\n formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,\n verbose: undefined,\n });\n const Html5QrcodeConfig = {\n fps: param.scannerFPS,\n qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,\n aspectRatio: 16 / 9,\n videoConstraints: {\n focusMode: \"continuous\",\n height: { min: 576, ideal: 1920 },\n deviceId: undefined,\n facingMode: param.facingMode,\n },\n };\n // Success and error callbacks for the scanner\n const OSBarcodeWebScannerSuccessCallback = (decodedText, decodedResult) => {\n var _a, _b;\n this.stopAndHideScanner();\n resolve({\n ScanResult: decodedText,\n format: (_b = (_a = decodedResult.result.format) === null || _a === void 0 ? void 0 : _a.format) !== null && _b !== void 0 ? _b : CapacitorBarcodeScannerTypeHint.ALL,\n });\n };\n const OSBarcodeWebScannerErrorCallback = (error) => {\n const allowedErrors = [\n \"NotFoundException\",\n \"No barcode or QR code detected\",\n \"No MultiFormat Readers were able to detect the code\",\n ];\n if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {\n this.stopAndHideScanner();\n console.error(`[Scanner Web Error] ${error}`);\n reject(error);\n }\n };\n window.OSBarcodeWebScanner.start({ facingMode: param.facingMode }, Html5QrcodeConfig, OSBarcodeWebScannerSuccessCallback, OSBarcodeWebScannerErrorCallback);\n });\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CapacitorBarcodeScannerCameraDirection","CapacitorBarcodeScannerScanOrientation","CapacitorBarcodeScannerTypeHintALLOption","Html5QrcodeSupportedFormats","CapacitorBarcodeScannerAndroidScanningLibrary","registerPlugin","WebPlugin","Html5Qrcode"],"mappings":";;;;;AACA;AACA;AACA;AACWA;AACX,CAAC,UAAU,sCAAsC,EAAE;AACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM;AACvG,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,OAAO;AACzG,CAAC,EAAEA,8CAAsC,KAAKA,8CAAsC,GAAG,EAAE,CAAC,CAAC;AAC3F;AACA;AACA;AACWC;AACX,CAAC,UAAU,sCAAsC,EAAE;AACnD,IAAI,sCAAsC,CAAC,sCAAsC,CAAC,UAAU,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;"}
|
package/dist/plugin.js
CHANGED
|
@@ -44,18 +44,21 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
44
44
|
* Each object in the array defines a CSS rule, with a selector and the CSS properties to apply.
|
|
45
45
|
*/
|
|
46
46
|
const barcodeScannerCss = [
|
|
47
|
-
{ selector:
|
|
47
|
+
{ selector: ".scanner-container-display", css: "display: block;" },
|
|
48
48
|
{
|
|
49
|
-
selector:
|
|
50
|
-
css:
|
|
49
|
+
selector: ".scanner-dialog",
|
|
50
|
+
css: "display: none; position: fixed; z-index: 999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);",
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
selector:
|
|
54
|
-
css:
|
|
53
|
+
selector: ".scanner-dialog-inner",
|
|
54
|
+
css: "background-color: #fefefe; margin: 2% auto; padding: 20px; border: 1px solid #888; width: 96%;",
|
|
55
55
|
},
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
{
|
|
57
|
+
selector: ".close-button",
|
|
58
|
+
css: "color: #aaa; float: right; font-size: 28px; font-weight: bold; cursor: pointer;",
|
|
59
|
+
},
|
|
60
|
+
{ selector: ".close-button:hover", css: "color: #222;" },
|
|
61
|
+
{ selector: ".scanner-container-full-width", css: "width: 100%;" },
|
|
59
62
|
];
|
|
60
63
|
/**
|
|
61
64
|
* Dynamically applies a set of CSS rules to the document.
|
|
@@ -66,12 +69,12 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
66
69
|
* @param {Array<{selector: string, css: string}>} cssRules - An array of objects containing CSS selectors and styles to apply.
|
|
67
70
|
*/
|
|
68
71
|
function applyCss(cssRules) {
|
|
69
|
-
const styleId =
|
|
72
|
+
const styleId = "custom-style-os-cap-barcode"; // Unique identifier for the style element.
|
|
70
73
|
let styleElement = document.getElementById(styleId);
|
|
71
74
|
if (!styleElement) {
|
|
72
75
|
// Create and append a new style element if it does not exist.
|
|
73
|
-
styleElement = document.createElement(
|
|
74
|
-
styleElement.type =
|
|
76
|
+
styleElement = document.createElement("style");
|
|
77
|
+
styleElement.type = "text/css";
|
|
75
78
|
styleElement.id = styleId;
|
|
76
79
|
document.head.appendChild(styleElement);
|
|
77
80
|
}
|
|
@@ -87,7 +90,7 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
87
90
|
}
|
|
88
91
|
else {
|
|
89
92
|
// Fallback for older browsers using textContent.
|
|
90
|
-
styleElement.textContent =
|
|
93
|
+
styleElement.textContent = "";
|
|
91
94
|
for (const { selector, css } of cssRules) {
|
|
92
95
|
styleElement.textContent += `${selector} { ${css} }`;
|
|
93
96
|
}
|
|
@@ -99,7 +102,7 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
99
102
|
* For web platforms, it applies necessary CSS for the barcode scanner and dynamically imports the web implementation.
|
|
100
103
|
* This allows for lazy loading of the web code only when needed, optimizing overall bundle size.
|
|
101
104
|
*/
|
|
102
|
-
const CapacitorBarcodeScannerImpl = core.registerPlugin(
|
|
105
|
+
const CapacitorBarcodeScannerImpl = core.registerPlugin("CapacitorBarcodeScanner", {
|
|
103
106
|
web: () => {
|
|
104
107
|
applyCss(barcodeScannerCss); // Apply the CSS styles necessary for the web implementation of the barcode scanner.
|
|
105
108
|
return Promise.resolve().then(function () { return web; }).then((m) => new m.CapacitorBarcodeScannerWeb()); // Dynamically import the web implementation and instantiate it.
|
|
@@ -107,15 +110,19 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
107
110
|
});
|
|
108
111
|
class CapacitorBarcodeScanner {
|
|
109
112
|
static async scanBarcode(options) {
|
|
110
|
-
options.scanInstructions = options.scanInstructions ||
|
|
113
|
+
options.scanInstructions = options.scanInstructions || " "; // Ensure scanInstructions is at least a space.
|
|
111
114
|
options.scanButton = options.scanButton || false; // Set scanButton to false if not provided.
|
|
112
|
-
options.scanText = options.scanText ||
|
|
113
|
-
options.cameraDirection =
|
|
114
|
-
|
|
115
|
+
options.scanText = options.scanText || " "; // Ensure scanText is at least a space.
|
|
116
|
+
options.cameraDirection =
|
|
117
|
+
options.cameraDirection || exports.CapacitorBarcodeScannerCameraDirection.BACK; // Set cameraDirection to 'BACK' if not provided.
|
|
118
|
+
options.scanOrientation =
|
|
119
|
+
options.scanOrientation ||
|
|
120
|
+
exports.CapacitorBarcodeScannerScanOrientation.ADAPTIVE; // Set scanOrientation to 'ADAPTIVE' if not provided.
|
|
115
121
|
return CapacitorBarcodeScannerImpl.scanBarcode(options);
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
|
|
125
|
+
/* eslint-env browser */
|
|
119
126
|
/**
|
|
120
127
|
* Implements OSBarcodePlugin to provide web functionality for barcode scanning.
|
|
121
128
|
*/
|
|
@@ -131,8 +138,7 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
131
138
|
await window.OSBarcodeWebScanner.stop();
|
|
132
139
|
window.OSBarcodeWebScanner = null;
|
|
133
140
|
}
|
|
134
|
-
|
|
135
|
-
document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'none';
|
|
141
|
+
document.getElementById("cap-os-barcode-scanner-container-dialog").style.display = "none";
|
|
136
142
|
}
|
|
137
143
|
/**
|
|
138
144
|
* Builds the HTML elements necessary for the barcode scanner UI.
|
|
@@ -141,34 +147,38 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
141
147
|
* @private
|
|
142
148
|
*/
|
|
143
149
|
buildScannerElement() {
|
|
144
|
-
if (document.getElementById(
|
|
145
|
-
|
|
146
|
-
|
|
150
|
+
if (document.getElementById("cap-os-barcode-scanner-container")) {
|
|
151
|
+
document.getElementById("cap-os-barcode-scanner-container").className =
|
|
152
|
+
"scanner-container-display";
|
|
147
153
|
return;
|
|
148
154
|
}
|
|
149
155
|
// Create and configure scanner container elements
|
|
150
|
-
const caposbarcodescannercontainer = document.body.appendChild(document.createElement(
|
|
151
|
-
caposbarcodescannercontainer.id =
|
|
152
|
-
const caposbarcodescannercontainerdialog = document.createElement(
|
|
153
|
-
caposbarcodescannercontainerdialog.id =
|
|
154
|
-
|
|
156
|
+
const caposbarcodescannercontainer = document.body.appendChild(document.createElement("div"));
|
|
157
|
+
caposbarcodescannercontainer.id = "cap-os-barcode-scanner-container";
|
|
158
|
+
const caposbarcodescannercontainerdialog = document.createElement("div");
|
|
159
|
+
caposbarcodescannercontainerdialog.id =
|
|
160
|
+
"cap-os-barcode-scanner-container-dialog";
|
|
161
|
+
caposbarcodescannercontainerdialog.className = "scanner-dialog";
|
|
155
162
|
// Inner dialog elements including the close button and scanner view
|
|
156
|
-
const caposbarcodescannercontainerdialoginner = document.createElement(
|
|
157
|
-
caposbarcodescannercontainerdialoginner.className =
|
|
158
|
-
const caposbarcodescannercontainerdialoginnerclose = document.createElement(
|
|
159
|
-
caposbarcodescannercontainerdialoginnerclose.className =
|
|
160
|
-
caposbarcodescannercontainerdialoginnerclose.innerHTML =
|
|
163
|
+
const caposbarcodescannercontainerdialoginner = document.createElement("div");
|
|
164
|
+
caposbarcodescannercontainerdialoginner.className = "scanner-dialog-inner";
|
|
165
|
+
const caposbarcodescannercontainerdialoginnerclose = document.createElement("span");
|
|
166
|
+
caposbarcodescannercontainerdialoginnerclose.className = "close-button";
|
|
167
|
+
caposbarcodescannercontainerdialoginnerclose.innerHTML = "×";
|
|
161
168
|
caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnerclose);
|
|
162
|
-
const caposbarcodescannercontainerdialoginnercontainerp = document.createElement(
|
|
163
|
-
caposbarcodescannercontainerdialoginnercontainerp.innerHTML =
|
|
169
|
+
const caposbarcodescannercontainerdialoginnercontainerp = document.createElement("p");
|
|
170
|
+
caposbarcodescannercontainerdialoginnercontainerp.innerHTML = " ";
|
|
164
171
|
caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainerp);
|
|
165
|
-
const caposbarcodescannercontainerdialoginnercontainer = document.createElement(
|
|
166
|
-
caposbarcodescannercontainerdialoginnercontainer.className =
|
|
167
|
-
|
|
172
|
+
const caposbarcodescannercontainerdialoginnercontainer = document.createElement("div");
|
|
173
|
+
caposbarcodescannercontainerdialoginnercontainer.className =
|
|
174
|
+
"scanner-container-full-width";
|
|
175
|
+
caposbarcodescannercontainerdialoginnercontainer.id =
|
|
176
|
+
"cap-os-barcode-scanner-container-scanner";
|
|
168
177
|
caposbarcodescannercontainerdialoginner.appendChild(caposbarcodescannercontainerdialoginnercontainer);
|
|
169
178
|
caposbarcodescannercontainerdialog.appendChild(caposbarcodescannercontainerdialoginner);
|
|
170
179
|
caposbarcodescannercontainer.appendChild(caposbarcodescannercontainerdialog);
|
|
171
|
-
caposbarcodescannercontainerdialoginnerclose.onclick =
|
|
180
|
+
caposbarcodescannercontainerdialoginnerclose.onclick =
|
|
181
|
+
this.stopAndHideScanner;
|
|
172
182
|
}
|
|
173
183
|
/**
|
|
174
184
|
* Initiates a barcode scan using the user's camera and HTML5 QR code scanner.
|
|
@@ -178,25 +188,28 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
178
188
|
*/
|
|
179
189
|
async scanBarcode(options) {
|
|
180
190
|
this.buildScannerElement();
|
|
181
|
-
|
|
182
|
-
document.getElementById('cap-os-barcode-scanner-container-dialog').style.display = 'block';
|
|
191
|
+
document.getElementById("cap-os-barcode-scanner-container-dialog").style.display = "block";
|
|
183
192
|
return new Promise((resolve, reject) => {
|
|
184
193
|
var _a, _b;
|
|
185
194
|
const param = {
|
|
186
|
-
facingMode: options.cameraDirection === 1 ?
|
|
195
|
+
facingMode: options.cameraDirection === 1 ? "environment" : "user",
|
|
187
196
|
scanButton: options.scanButton === undefined ? false : options.scanButton,
|
|
188
|
-
scanInstructions: options.scanInstructions
|
|
197
|
+
scanInstructions: options.scanInstructions
|
|
198
|
+
? options.scanInstructions
|
|
199
|
+
: "",
|
|
189
200
|
orientation: options.scanOrientation
|
|
190
201
|
? options.scanOrientation
|
|
191
202
|
: exports.CapacitorBarcodeScannerScanOrientation.PORTRAIT,
|
|
192
|
-
showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection)
|
|
203
|
+
showCameraSelection: ((_a = options.web) === null || _a === void 0 ? void 0 : _a.showCameraSelection)
|
|
204
|
+
? options.web.showCameraSelection
|
|
205
|
+
: false,
|
|
193
206
|
typeHint: options.hint === 17 ? undefined : options.hint,
|
|
194
207
|
scannerFPS: ((_b = options.web) === null || _b === void 0 ? void 0 : _b.scannerFPS) ? options.web.scannerFPS : 50,
|
|
195
208
|
};
|
|
196
209
|
// Set up and start the scanner
|
|
197
|
-
const scannerElement = document.getElementById(
|
|
210
|
+
const scannerElement = document.getElementById("cap-os-barcode-scanner-container-scanner");
|
|
198
211
|
if (!scannerElement) {
|
|
199
|
-
throw new Error(
|
|
212
|
+
throw new Error("Scanner Element is required for web");
|
|
200
213
|
}
|
|
201
214
|
window.OSBarcodeWebScanner = new html5Qrcode.Html5Qrcode(scannerElement.id, {
|
|
202
215
|
formatsToSupport: param.typeHint !== undefined ? [param.typeHint] : undefined,
|
|
@@ -207,7 +220,7 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
207
220
|
qrbox: scannerElement.getBoundingClientRect().width * (9 / 16) - 10,
|
|
208
221
|
aspectRatio: 16 / 9,
|
|
209
222
|
videoConstraints: {
|
|
210
|
-
focusMode:
|
|
223
|
+
focusMode: "continuous",
|
|
211
224
|
height: { min: 576, ideal: 1920 },
|
|
212
225
|
deviceId: undefined,
|
|
213
226
|
facingMode: param.facingMode,
|
|
@@ -224,9 +237,9 @@ var capacitorOSBarcode = (function (exports, core, html5Qrcode) {
|
|
|
224
237
|
};
|
|
225
238
|
const OSBarcodeWebScannerErrorCallback = (error) => {
|
|
226
239
|
const allowedErrors = [
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
240
|
+
"NotFoundException",
|
|
241
|
+
"No barcode or QR code detected",
|
|
242
|
+
"No MultiFormat Readers were able to detect the code",
|
|
230
243
|
];
|
|
231
244
|
if (!allowedErrors.find((e) => error.indexOf(e) !== -1)) {
|
|
232
245
|
this.stopAndHideScanner();
|