@stonecrop/beam 0.13.14 → 0.14.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/beam",
3
- "version": "0.13.14",
3
+ "version": "0.14.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -58,6 +58,7 @@
58
58
  "vitest": "^4.1.5",
59
59
  "vue": "^3.5.33",
60
60
  "vue-router": "^5.0.6",
61
+ "vue-tsc": "^3.3.6",
61
62
  "stonecrop-rig": "0.7.0"
62
63
  },
63
64
  "publishConfig": {
@@ -75,6 +76,7 @@
75
76
  "lint:fix": "oxlint --fix",
76
77
  "preview": "vite preview",
77
78
  "test": "vitest run --coverage.enabled false",
79
+ "test:types": "vue-tsc --noEmit",
78
80
  "test:watch": "vitest watch",
79
81
  "test:coverage": "vitest run --coverage",
80
82
  "test:ui": "vitest --ui"
@@ -4,9 +4,10 @@
4
4
 
5
5
  <script setup lang="ts">
6
6
  import onScan from 'onscan.js'
7
+ import type { OnScan } from 'onscan.js'
7
8
  import { onMounted, onUnmounted } from 'vue'
8
9
 
9
- const emit = defineEmits<{ scanInstance: [instance: onScan] }>()
10
+ const emit = defineEmits<{ scanInstance: [instance: OnScan] }>()
10
11
  const props = defineProps<{
11
12
  scanHandler: (barcode: string, qty: number) => void
12
13
  }>()
@@ -0,0 +1,45 @@
1
+ // onscan.js ships no typings and has no @types package, so its import was implicitly `any` —
2
+ // which also made `onScan` unusable as a type. Declared here against the library's actual public
3
+ // surface (v1.5.2); the chainable methods return the singleton itself, which is why `attachTo`
4
+ // hands back something you can call `simulate` on.
5
+ declare module 'onscan.js' {
6
+ export interface OnScanOptions {
7
+ onScan?: (scanned: string, qty: number) => void
8
+ onScanError?: (debug: { message: string }) => void
9
+ onKeyProcess?: (char: string, event: KeyboardEvent) => void
10
+ onKeyDetect?: (keyCode: number, event: KeyboardEvent) => void
11
+ onPaste?: (pasted: string, event: ClipboardEvent) => void
12
+ keyCodeMapper?: (event: KeyboardEvent) => string | null
13
+ onScanButtonLongPress?: () => void
14
+ scanButtonKeyCode?: number | false
15
+ scanButtonLongPressTime?: number
16
+ timeBeforeScanTest?: number
17
+ avgTimeByChar?: number
18
+ minLength?: number
19
+ suffixKeyCodes?: number[]
20
+ prefixKeyCodes?: number[]
21
+ ignoreIfFocusOn?: boolean | string | Element | Element[]
22
+ stopPropagation?: boolean
23
+ preventDefault?: boolean
24
+ captureEvents?: boolean
25
+ reactToKeydown?: boolean
26
+ reactToPaste?: boolean
27
+ singleScanQty?: number
28
+ }
29
+
30
+ export interface OnScan {
31
+ /** Attaches the scanner listeners to `target`. Throws if it is already attached. */
32
+ attachTo(target: EventTarget, options?: OnScanOptions): OnScan
33
+ detachFrom(target: EventTarget): void
34
+ getOptions(target: EventTarget): OnScanOptions
35
+ setOptions(target: EventTarget, options: OnScanOptions): OnScan
36
+ /** Feeds a scan through as if a scanner produced it. */
37
+ simulate(target: EventTarget, code: string | number[]): OnScan
38
+ isScanInProgressFor(target: EventTarget): boolean
39
+ isAttachedTo(target: EventTarget): boolean
40
+ decodeKeyEvent(event: KeyboardEvent): string | null
41
+ }
42
+
43
+ const onScan: OnScan
44
+ export default onScan
45
+ }