@octane-xplat/barcode-scanner 0.19.0 → 0.20.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.
@@ -2,137 +2,177 @@
2
2
  // VNDetectBarcodesRequest; live camera scanning is not available on macOS,
3
3
  // so ensure() reports 'unsupported'.
4
4
  import {
5
- CGImageGetHeight,
6
- CGImageGetWidth,
7
- NSImage,
8
- NSURL,
9
- VNDetectBarcodesRequest,
10
- VNImageRequestHandler,
5
+ CGImageGetHeight,
6
+ CGImageGetWidth,
7
+ NSImage,
8
+ NSURL,
9
+ VNDetectBarcodesRequest,
10
+ VNImageRequestHandler,
11
11
  } from '@octane-xplat/platform/macos'
12
+
12
13
  import type { BarcodeFormat, BarcodeScannerService, PermissionResult, ScannedCode } from './types'
13
14
 
14
15
  // String literals, not the bound constants — the generated metadata targets
15
16
  // macOS 11 and omits VNBarcodeSymbologyCodabar.
16
17
  const VISION_PREFIX = 'VNBarcodeSymbology'
17
18
  const SYMBOLOGIES: Record<BarcodeFormat, readonly string[]> = {
18
- qr: ['QR'],
19
- ean13: ['EAN13'],
20
- ean8: ['EAN8'],
21
- upc_a: ['EAN13'],
22
- upc_e: ['UPCE'],
23
- code128: ['Code128'],
24
- code39: ['Code39', 'Code39Checksum', 'Code39FullASCII', 'Code39FullASCIIChecksum'],
25
- code93: ['Code93', 'Code93i'],
26
- codabar: ['Codabar'],
27
- itf: ['I2of5', 'I2of5Checksum', 'ITF14'],
28
- datamatrix: ['DataMatrix'],
29
- pdf417: ['PDF417'],
30
- aztec: ['Aztec'],
19
+ qr: ['QR'],
20
+ ean13: ['EAN13'],
21
+ ean8: ['EAN8'],
22
+ upc_a: ['EAN13'],
23
+ upc_e: ['UPCE'],
24
+ code128: ['Code128'],
25
+ code39: ['Code39', 'Code39Checksum', 'Code39FullASCII', 'Code39FullASCIIChecksum'],
26
+ code93: ['Code93', 'Code93i'],
27
+ codabar: ['Codabar'],
28
+ itf: ['I2of5', 'I2of5Checksum', 'ITF14'],
29
+ datamatrix: ['DataMatrix'],
30
+ pdf417: ['PDF417'],
31
+ aztec: ['Aztec'],
31
32
  }
32
33
 
33
34
  // Vision → our vocabulary. EAN13 resolves to ean13; UPC-A is an EAN-13 with
34
35
  // a leading 0 and is rewritten on the payload (see below).
35
36
  const FORMATS: Record<string, string> = {}
37
+
36
38
  for (const [format, names] of Object.entries(SYMBOLOGIES)) {
37
- for (const name of names) {FORMATS[VISION_PREFIX + name] ??= format}
39
+ for (const name of names) {
40
+ FORMATS[VISION_PREFIX + name] ??= format
41
+ }
38
42
  }
39
43
 
40
44
  /** The deduplicated, prefixed union for the requested formats — every entry
41
45
  * when `formats` is missing or empty, so results stay inside our vocabulary. */
42
46
  function symbologiesFor(formats?: BarcodeFormat[]): string[] {
43
- const wanted = formats?.length ? formats : (Object.keys(SYMBOLOGIES) as BarcodeFormat[])
44
- const out = new Set<string>()
45
- for (const format of wanted) {
46
- for (const name of SYMBOLOGIES[format] ?? []) {out.add(VISION_PREFIX + name)}
47
- }
48
- return [...out]
47
+ const wanted = formats?.length ? formats : (Object.keys(SYMBOLOGIES) as BarcodeFormat[])
48
+ const out = new Set<string>()
49
+
50
+ for (const format of wanted) {
51
+ for (const name of SYMBOLOGIES[format] ?? []) {
52
+ out.add(VISION_PREFIX + name)
53
+ }
54
+ }
55
+
56
+ return [...out]
49
57
  }
50
58
 
51
59
  /** request.results may be a JS array or an NSArray — count/objectAtIndex. */
52
60
  function observations(results: any): any[] {
53
- if (!results) {return []}
54
- if (Array.isArray(results)) {return results}
55
- const out: any[] = []
56
- for (let i = 0, count = Number(results.count ?? 0); i < count; i++) {
57
- out.push(results.objectAtIndex(i))
58
- }
59
- return out
61
+ if (!results) {
62
+ return []
63
+ }
64
+
65
+ if (Array.isArray(results)) {
66
+ return results
67
+ }
68
+
69
+ const out: any[] = []
70
+
71
+ for (let i = 0, count = Number(results.count ?? 0); i < count; i++) {
72
+ out.push(results.objectAtIndex(i))
73
+ }
74
+
75
+ return out
60
76
  }
61
77
 
62
78
  /** Headless barcode service — permission + still-image decode. See BarcodeScannerService. */
63
79
  export const barcodeScanner: BarcodeScannerService = {
64
- supported: true,
65
- ensure: async (): Promise<PermissionResult> => 'unsupported',
66
- scanImage: async (image: unknown, formats?: BarcodeFormat[]): Promise<ScannedCode[]> => {
67
- let source: any
68
- if (typeof image === 'string' || (image != null && typeof (image as any).uri === 'string')) {
69
- const input = typeof image === 'string' ? image : (image as any).uri
70
- if (/^file:/i.test(input)) {
71
- source = NSImage.alloc().initWithContentsOfURL(NSURL.URLWithString(input))
72
- } else if (/^[a-z][a-z0-9+.-]*:/i.test(input)) {
73
- throw new Error('barcodeScanner.scanImage: macOS decodes local files; download remote images first')
74
- } else {
75
- source = NSImage.alloc().initWithContentsOfURL(NSURL.fileURLWithPath(input))
76
- }
77
- } else if (image != null && typeof (image as any).CGImageForProposedRectContextHints === 'function') {
78
- source = image
79
- } else {
80
- throw new Error('barcodeScanner.scanImage: expected a file path, file URL, {uri} ref, or NSImage')
81
- }
82
-
83
- const cg = source?.CGImageForProposedRectContextHints?.(null, null, null)
84
- if (!cg) {
85
- throw new Error('barcodeScanner.scanImage: could not read the image')
86
- }
87
-
88
- const request = VNDetectBarcodesRequest.alloc().init()
89
- request.symbologies = symbologiesFor(formats)
90
- const handler = VNImageRequestHandler.alloc().initWithCGImageOptions(cg, {})
91
- if (!handler.performRequestsError([request], null)) {
92
- throw new Error('barcodeScanner.scanImage: Vision could not process the image')
93
- }
94
-
95
- // Vision reports UPC-A as EAN-13 with a leading 0.
96
- const wantsUpcA = !formats?.length || formats.includes('upc_a')
97
- const wantsEan13 = !formats?.length || formats.includes('ean13')
98
- const W = Number(CGImageGetWidth(cg))
99
- const H = Number(CGImageGetHeight(cg))
100
- const codes: ScannedCode[] = []
101
- for (const observation of observations(request.results)) {
102
- const symbology = String(observation?.symbology ?? '')
103
- let type =
104
- FORMATS[symbology] ??
105
- (symbology.startsWith(VISION_PREFIX) ? symbology.slice(VISION_PREFIX.length) : symbology)
106
- let data = String(observation?.payloadStringValue ?? '')
107
- if (type === 'ean13') {
108
- if (data.length === 13 && data.startsWith('0') && wantsUpcA) {
109
- type = 'upc_a'
110
- data = data.slice(1)
111
- } else if (!wantsEan13) {
112
- continue
113
- }
114
- }
115
-
116
- const code: ScannedCode = { type, data }
117
- const box = observation?.boundingBox
118
- if (box) {
119
- const ox = Number(box.origin?.x)
120
- const oy = Number(box.origin?.y)
121
- const width = Number(box.size?.width)
122
- const height = Number(box.size?.height)
123
- if (Number.isFinite(ox) && Number.isFinite(oy) && Number.isFinite(width) && Number.isFinite(height)) {
124
- // Vision bounds are normalized with a bottom-left origin.
125
- code.bounds = {
126
- x: ox * W,
127
- y: (1 - oy - height) * H,
128
- width: width * W,
129
- height: height * H,
130
- }
131
- }
132
- }
133
-
134
- codes.push(code)
135
- }
136
- return codes
137
- },
80
+ supported: true,
81
+ ensure: async (): Promise<PermissionResult> => 'unsupported',
82
+ scanImage: async (image: unknown, formats?: BarcodeFormat[]): Promise<ScannedCode[]> => {
83
+ let source: any
84
+
85
+ if (typeof image === 'string' || (image != null && typeof (image as any).uri === 'string')) {
86
+ const input = typeof image === 'string' ? image : (image as any).uri
87
+
88
+ if (/^file:/i.test(input)) {
89
+ source = NSImage.alloc().initWithContentsOfURL(NSURL.URLWithString(input))
90
+ } else if (/^[a-z][a-z0-9+.-]*:/i.test(input)) {
91
+ throw new Error(
92
+ 'barcodeScanner.scanImage: macOS decodes local files; download remote images first',
93
+ )
94
+ } else {
95
+ source = NSImage.alloc().initWithContentsOfURL(NSURL.fileURLWithPath(input))
96
+ }
97
+ } else if (
98
+ image != null &&
99
+ typeof (image as any).CGImageForProposedRectContextHints === 'function'
100
+ ) {
101
+ source = image
102
+ } else {
103
+ throw new Error(
104
+ 'barcodeScanner.scanImage: expected a file path, file URL, {uri} ref, or NSImage',
105
+ )
106
+ }
107
+
108
+ const cg = source?.CGImageForProposedRectContextHints?.(null, null, null)
109
+
110
+ if (!cg) {
111
+ throw new Error('barcodeScanner.scanImage: could not read the image')
112
+ }
113
+
114
+ const request = VNDetectBarcodesRequest.alloc().init()
115
+
116
+ request.symbologies = symbologiesFor(formats)
117
+
118
+ const handler = VNImageRequestHandler.alloc().initWithCGImageOptions(cg, {})
119
+
120
+ if (!handler.performRequestsError([request], null)) {
121
+ throw new Error('barcodeScanner.scanImage: Vision could not process the image')
122
+ }
123
+
124
+ // Vision reports UPC-A as EAN-13 with a leading 0.
125
+ const wantsUpcA = !formats?.length || formats.includes('upc_a')
126
+ const wantsEan13 = !formats?.length || formats.includes('ean13')
127
+ const W = Number(CGImageGetWidth(cg))
128
+ const H = Number(CGImageGetHeight(cg))
129
+ const codes: ScannedCode[] = []
130
+
131
+ for (const observation of observations(request.results)) {
132
+ const symbology = String(observation?.symbology ?? '')
133
+ let type =
134
+ FORMATS[symbology] ??
135
+ (symbology.startsWith(VISION_PREFIX) ? symbology.slice(VISION_PREFIX.length) : symbology)
136
+
137
+ let data = String(observation?.payloadStringValue ?? '')
138
+
139
+ if (type === 'ean13') {
140
+ if (data.length === 13 && data.startsWith('0') && wantsUpcA) {
141
+ type = 'upc_a'
142
+ data = data.slice(1)
143
+ } else if (!wantsEan13) {
144
+ continue
145
+ }
146
+ }
147
+
148
+ const code: ScannedCode = { type, data }
149
+ const box = observation?.boundingBox
150
+
151
+ if (box) {
152
+ const ox = Number(box.origin?.x)
153
+ const oy = Number(box.origin?.y)
154
+ const width = Number(box.size?.width)
155
+ const height = Number(box.size?.height)
156
+
157
+ if (
158
+ Number.isFinite(ox) &&
159
+ Number.isFinite(oy) &&
160
+ Number.isFinite(width) &&
161
+ Number.isFinite(height)
162
+ ) {
163
+ // Vision bounds are normalized with a bottom-left origin.
164
+ code.bounds = {
165
+ x: ox * W,
166
+ y: (1 - oy - height) * H,
167
+ width: width * W,
168
+ height: height * H,
169
+ }
170
+ }
171
+ }
172
+
173
+ codes.push(code)
174
+ }
175
+
176
+ return codes
177
+ },
138
178
  }
@@ -10,116 +10,131 @@ import { fromNativeFormat, toNativeFormats } from './format-map'
10
10
  let scanRequestCode = 7723
11
11
 
12
12
  async function ensure(): Promise<PermissionResult> {
13
- try {
14
- if (Application.ios) {
15
- const av = (globalThis as any).AVCaptureDevice
16
- const video = (globalThis as any).AVMediaTypeVideo
17
- // 0=notDetermined 1=restricted 2=denied 3=authorized
18
- const status = av?.authorizationStatusForMediaType?.(video)
19
- if (status === 3) {
20
- return 'granted'
21
- }
22
-
23
- if (status === 1 || status === 2) {
24
- return 'denied'
25
- }
26
-
27
- if (typeof av?.requestAccessForMediaTypeCompletionHandler !== 'function') {
28
- return 'unsupported'
29
- }
30
-
31
- return await new Promise<PermissionResult>((resolve) => {
32
- av.requestAccessForMediaTypeCompletionHandler(video, (granted: boolean) =>
33
- resolve(granted ? 'granted' : 'denied'),
34
- )
35
- })
36
- }
37
-
38
- const perm = 'android.permission.CAMERA'
39
- const activity = Application.android.foregroundActivity ?? Application.android.startActivity
40
- if (
41
- activity?.checkSelfPermission?.(perm) === android.content.pm.PackageManager.PERMISSION_GRANTED
42
- ) {
43
- return 'granted'
44
- }
45
-
46
- if (!activity) {
47
- return 'denied'
48
- }
49
-
50
- return await new Promise<PermissionResult>((resolve) => {
51
- const requestCode = scanRequestCode++
52
- const event = Application.android.activityRequestPermissionsEvent
53
- const onResult = (args: any) => {
54
- if (args.requestCode !== requestCode) {
55
- return
56
- }
57
- Application.android.off(event, onResult)
58
- resolve(
59
- args.grantResults?.[0] === android.content.pm.PackageManager.PERMISSION_GRANTED
60
- ? 'granted'
61
- : 'denied',
62
- )
63
- }
64
- Application.android.on(event, onResult)
65
- try {
66
- activity.requestPermissions([perm], requestCode)
67
- } catch {
68
- Application.android.off(event, onResult)
69
- resolve('denied')
70
- }
71
- })
72
- } catch {
73
- return 'denied'
74
- }
13
+ try {
14
+ if (Application.ios) {
15
+ const av = (globalThis as any).AVCaptureDevice
16
+ const video = (globalThis as any).AVMediaTypeVideo
17
+ // 0=notDetermined 1=restricted 2=denied 3=authorized
18
+ const status = av?.authorizationStatusForMediaType?.(video)
19
+
20
+ if (status === 3) {
21
+ return 'granted'
22
+ }
23
+
24
+ if (status === 1 || status === 2) {
25
+ return 'denied'
26
+ }
27
+
28
+ if (typeof av?.requestAccessForMediaTypeCompletionHandler !== 'function') {
29
+ return 'unsupported'
30
+ }
31
+
32
+ return await new Promise<PermissionResult>((resolve) => {
33
+ av.requestAccessForMediaTypeCompletionHandler(video, (granted: boolean) =>
34
+ resolve(granted ? 'granted' : 'denied'),
35
+ )
36
+ })
37
+ }
38
+
39
+ const perm = 'android.permission.CAMERA'
40
+ const activity = Application.android.foregroundActivity ?? Application.android.startActivity
41
+
42
+ if (
43
+ activity?.checkSelfPermission?.(perm) === android.content.pm.PackageManager.PERMISSION_GRANTED
44
+ ) {
45
+ return 'granted'
46
+ }
47
+
48
+ if (!activity) {
49
+ return 'denied'
50
+ }
51
+
52
+ return await new Promise<PermissionResult>((resolve) => {
53
+ const requestCode = scanRequestCode++
54
+ const event = Application.android.activityRequestPermissionsEvent
55
+ const onResult = (args: any) => {
56
+ if (args.requestCode !== requestCode) {
57
+ return
58
+ }
59
+
60
+ Application.android.off(event, onResult)
61
+ resolve(
62
+ args.grantResults?.[0] === android.content.pm.PackageManager.PERMISSION_GRANTED
63
+ ? 'granted'
64
+ : 'denied',
65
+ )
66
+ }
67
+
68
+ Application.android.on(event, onResult)
69
+ try {
70
+ activity.requestPermissions([perm], requestCode)
71
+ } catch {
72
+ Application.android.off(event, onResult)
73
+ resolve('denied')
74
+ }
75
+ })
76
+ } catch {
77
+ return 'denied'
78
+ }
75
79
  }
76
80
 
77
81
  async function toImageSource(image: unknown): Promise<any> {
78
- if (image instanceof ImageSource) {
79
- return image
80
- }
81
- if (typeof image === 'string') {
82
- return ImageSource.fromFile(image)
83
- }
84
- if (image && typeof (image as { uri?: string }).uri === 'string') {
85
- return ImageSource.fromFile((image as { uri: string }).uri)
86
- }
87
- throw new Error('barcodeScanner.scanImage: expected an ImageSource, file path, or {uri} ref')
82
+ if (image instanceof ImageSource) {
83
+ return image
84
+ }
85
+
86
+ if (typeof image === 'string') {
87
+ return ImageSource.fromFile(image)
88
+ }
89
+
90
+ if (
91
+ typeof image === 'object' &&
92
+ image !== null &&
93
+ 'uri' in image &&
94
+ typeof image.uri === 'string'
95
+ ) {
96
+ return ImageSource.fromFile(image.uri)
97
+ }
98
+
99
+ throw new Error('barcodeScanner.scanImage: expected an ImageSource, file path, or {uri} ref')
88
100
  }
89
101
 
90
102
  /** Headless barcode service — permission + still-image decode. See BarcodeScannerService. */
91
103
  export const barcodeScanner: BarcodeScannerService = {
92
- supported: true,
93
-
94
- ensure,
95
-
96
- async scanImage(image: unknown, formats?: BarcodeFormat[]): Promise<ScannedCode[]> {
97
- const source = await toImageSource(image)
98
- const result = await detectWithStillImage(source, {
99
- detectorType: DetectionType.Barcode,
100
- barcodeScanning: { barcodeFormat: toNativeFormats(formats) as [any] },
101
- })
102
- const list = Array.isArray(result) ? result : Object.values(result ?? {})
103
- return list
104
- .flat()
105
- .filter((item: any) => item && (item.rawValue !== undefined || item.format !== undefined))
106
- .map((item: any) => ({
107
- type: fromNativeFormat(item.format),
108
- data: String(item.rawValue ?? item.displayValue ?? ''),
109
- bounds: item.bounds
110
- ? {
111
- x: item.bounds.origin?.x ?? item.bounds.x ?? 0,
112
- y: item.bounds.origin?.y ?? item.bounds.y ?? 0,
113
- width: item.bounds.size?.width ?? item.bounds.width ?? 0,
114
- height: item.bounds.size?.height ?? item.bounds.height ?? 0,
115
- }
116
- : undefined,
117
- }))
118
- },
104
+ supported: true,
105
+
106
+ ensure,
107
+
108
+ async scanImage(image: unknown, formats?: BarcodeFormat[]): Promise<ScannedCode[]> {
109
+ const source = await toImageSource(image)
110
+ const result = await detectWithStillImage(source, {
111
+ detectorType: DetectionType.Barcode,
112
+ barcodeScanning: { barcodeFormat: toNativeFormats(formats) as [any] },
113
+ })
114
+
115
+ const list = Array.isArray(result) ? result : Object.values(result ?? {})
116
+
117
+ return list
118
+ .flat()
119
+ .filter((item: any) => item && (item.rawValue !== undefined || item.format !== undefined))
120
+ .map((item: any) => ({
121
+ type: fromNativeFormat(item.format),
122
+ data: String(item.rawValue ?? item.displayValue ?? ''),
123
+ bounds: item.bounds
124
+ ? {
125
+ x: item.bounds.origin?.x ?? item.bounds.x ?? 0,
126
+ y: item.bounds.origin?.y ?? item.bounds.y ?? 0,
127
+ width: item.bounds.size?.width ?? item.bounds.width ?? 0,
128
+ height: item.bounds.size?.height ?? item.bounds.height ?? 0,
129
+ }
130
+ : undefined,
131
+ }))
132
+ },
119
133
  }
120
134
 
121
135
  // Scanning needs camera access — register the kind this leaf owns for the
122
136
  // platform dispatcher (same 'camera' kind media registers; both leafs' owners
123
137
  // run identical ensure logic, and the leaf must work with media absent).
124
138
  const permissionOwners = ((globalThis as any).__xplatPermissionOwners ??= {})
139
+
125
140
  permissionOwners.camera = () => barcodeScanner.ensure()
@@ -5,53 +5,62 @@ import type { BarcodeFormat, BarcodeScannerService, PermissionResult, ScannedCod
5
5
  import { fromDetectorFormat, toDetectorFormats } from './format-map.web'
6
6
 
7
7
  const detector = () => {
8
- const Detector = (globalThis as any).BarcodeDetector
9
- return typeof Detector === 'function' ? Detector : null
8
+ const Detector = (globalThis as any).BarcodeDetector
9
+
10
+ return typeof Detector === 'function' ? Detector : null
10
11
  }
11
12
 
12
13
  async function toImageSource(image: unknown): Promise<any> {
13
- if (typeof image === 'string') {
14
- const response = await fetch(image)
15
- return createImageBitmap(await response.blob())
16
- }
17
- return image
14
+ if (typeof image === 'string') {
15
+ const response = await fetch(image)
16
+
17
+ return createImageBitmap(await response.blob())
18
+ }
19
+
20
+ return image
18
21
  }
19
22
 
20
23
  /** Headless barcode service — permission + still-image decode. See BarcodeScannerService. */
21
24
  export const barcodeScanner: BarcodeScannerService = {
22
- supported: detector() !== null,
23
-
24
- ensure(): Promise<PermissionResult> {
25
- return Promise.resolve(detector() ? 'granted' : 'unsupported')
26
- },
27
-
28
- async scanImage(image: unknown, formats?: BarcodeFormat[]): Promise<ScannedCode[]> {
29
- const Detector = detector()
30
- if (!Detector) {
31
- throw new Error('unsupported: BarcodeDetector is not available')
32
- }
33
- let d: any
34
- try {
35
- d = new Detector({ formats: toDetectorFormats(formats) })
36
- } catch {
37
- d = new Detector()
38
- }
39
- const source = await toImageSource(image)
40
- const codes = await d.detect(source)
41
- return (codes ?? []).map((code: any) => ({
42
- type: fromDetectorFormat(code.format),
43
- data: String(code.rawValue ?? ''),
44
- bounds: code.boundingBox
45
- ? {
46
- x: code.boundingBox.x,
47
- y: code.boundingBox.y,
48
- width: code.boundingBox.width,
49
- height: code.boundingBox.height,
50
- }
51
- : undefined,
52
- }))
53
- },
25
+ supported: detector() !== null,
26
+
27
+ ensure(): Promise<PermissionResult> {
28
+ return Promise.resolve(detector() ? 'granted' : 'unsupported')
29
+ },
30
+
31
+ async scanImage(image: unknown, formats?: BarcodeFormat[]): Promise<ScannedCode[]> {
32
+ const Detector = detector()
33
+
34
+ if (!Detector) {
35
+ throw new Error('unsupported: BarcodeDetector is not available')
36
+ }
37
+
38
+ let d: any
39
+
40
+ try {
41
+ d = new Detector({ formats: toDetectorFormats(formats) })
42
+ } catch {
43
+ d = new Detector()
44
+ }
45
+
46
+ const source = await toImageSource(image)
47
+ const codes = await d.detect(source)
48
+
49
+ return (codes ?? []).map((code: any) => ({
50
+ type: fromDetectorFormat(code.format),
51
+ data: String(code.rawValue ?? ''),
52
+ bounds: code.boundingBox
53
+ ? {
54
+ x: code.boundingBox.x,
55
+ y: code.boundingBox.y,
56
+ width: code.boundingBox.width,
57
+ height: code.boundingBox.height,
58
+ }
59
+ : undefined,
60
+ }))
61
+ },
54
62
  }
55
63
 
56
64
  const permissionOwners = ((globalThis as any).__xplatPermissionOwners ??= {})
65
+
57
66
  permissionOwners.camera = () => barcodeScanner.ensure()
@@ -3,11 +3,12 @@ import type { BarcodeScannerService, PermissionResult } from './types'
3
3
 
4
4
  /** Headless barcode service — permission + still-image decode. See BarcodeScannerService. */
5
5
  export const barcodeScanner: BarcodeScannerService = {
6
- supported: false,
7
- ensure: async (): Promise<PermissionResult> => 'unsupported',
8
- scanImage: () =>
9
- Promise.reject(new Error('unsupported: barcode scanning is not available on windows')),
6
+ supported: false,
7
+ ensure: async (): Promise<PermissionResult> => 'unsupported',
8
+ scanImage: () =>
9
+ Promise.reject(new Error('unsupported: barcode scanning is not available on windows')),
10
10
  }
11
11
 
12
12
  const permissionOwners = ((globalThis as any).__xplatPermissionOwners ??= {})
13
+
13
14
  permissionOwners.camera = () => barcodeScanner.ensure()