@capacitor-community/bluetooth-le 8.0.0 → 8.0.2

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.
Files changed (32) hide show
  1. package/CapacitorCommunityBluetoothLe.podspec +17 -17
  2. package/LICENSE +21 -21
  3. package/Package.swift +27 -27
  4. package/README.md +4 -2
  5. package/android/build.gradle +73 -73
  6. package/android/src/main/AndroidManifest.xml +22 -22
  7. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/BluetoothLe.kt +1094 -1094
  8. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Conversion.kt +51 -51
  9. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/Device.kt +771 -771
  10. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceList.kt +28 -28
  11. package/android/src/main/java/com/capacitorjs/community/plugins/bluetoothle/DeviceScanner.kt +189 -189
  12. package/dist/esm/bleClient.js.map +1 -1
  13. package/dist/esm/conversion.js.map +1 -1
  14. package/dist/esm/queue.js.map +1 -1
  15. package/dist/esm/validators.js.map +1 -1
  16. package/dist/esm/web.js.map +1 -1
  17. package/dist/plugin.cjs.js +41 -41
  18. package/dist/plugin.cjs.js.map +1 -1
  19. package/dist/plugin.js +41 -41
  20. package/dist/plugin.js.map +1 -1
  21. package/ios/Sources/BluetoothLe/Conversion.swift +83 -83
  22. package/ios/Sources/BluetoothLe/Device.swift +422 -423
  23. package/ios/Sources/BluetoothLe/DeviceListView.swift +121 -121
  24. package/ios/Sources/BluetoothLe/DeviceManager.swift +409 -503
  25. package/ios/Sources/BluetoothLe/Logging.swift +8 -8
  26. package/ios/Sources/BluetoothLe/Plugin.swift +768 -775
  27. package/ios/Sources/BluetoothLe/ScanFilters.swift +114 -0
  28. package/ios/Sources/BluetoothLe/ThreadSafeDictionary.swift +61 -15
  29. package/ios/Tests/BluetoothLeTests/ConversionTests.swift +55 -55
  30. package/ios/Tests/BluetoothLeTests/PluginTests.swift +27 -27
  31. package/ios/Tests/BluetoothLeTests/ScanFiltersTests.swift +153 -0
  32. package/package.json +114 -115
@@ -1 +1 @@
1
- {"version":3,"file":"conversion.js","sourceRoot":"","sources":["../../src/conversion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAe;IAC5C,OAAO,MAAM,CAAC,YAAY,CAAC,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,8BAA8B,CAAC;AAClF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,GAAG,GAAG,EAAE,CAAC;IACf,IAAI,CAAC,EACH,CAAC,EACD,OAAO,GAAG,CAAC,EACX,MAAM,GAAG,CAAC,CAAC;IACb,KAAK,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K,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IACD,aAAa;IACb,OAAO,mBAAmB,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAe;IACnD,IAAI,KAAK,CAAC,MAAM,YAAY,iBAAiB,EAAE,CAAC;QAC9C,wCAAwC;QACxC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;QACzC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAuC,CAAC;IACpE,CAAC;IACD,uCAAuC;IACvC,OAAO,KAA2C,CAAC;AACrD,CAAC","sourcesContent":["/**\n * Convert an array of numbers into a DataView.\n */\nexport function numbersToDataView(value: number[]): DataView {\n return new DataView(Uint8Array.from(value).buffer);\n}\n\n/**\n * Convert a DataView into an array of numbers.\n */\nexport function dataViewToNumbers(value: DataView): number[] {\n return Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n}\n\n/**\n * Convert a string into a DataView.\n */\nexport function textToDataView(value: string): DataView {\n return numbersToDataView(value.split('').map((s) => s.charCodeAt(0)));\n}\n\n/**\n * Convert a DataView into a string.\n */\nexport function dataViewToText(value: DataView): string {\n return String.fromCharCode(...dataViewToNumbers(value));\n}\n\n/**\n * Convert a 16 bit UUID into a 128 bit UUID string\n * @param value number, e.g. 0x180d\n * @return string, e.g. '0000180d-0000-1000-8000-00805f9b34fb'\n */\nexport function numberToUUID(value: number): string {\n return `0000${value.toString(16).padStart(4, '0')}-0000-1000-8000-00805f9b34fb`;\n}\n\n/**\n * Convert a string of hex into a DataView of raw bytes.\n * Note: characters other than [0-9a-fA-F] are ignored\n * @param hex string of values, e.g. \"00 01 02\" or \"000102\"\n * @return DataView of raw bytes\n */\nexport function hexStringToDataView(hex: string): DataView {\n const bin = [];\n let i,\n c,\n isEmpty = 1,\n buffer = 0;\n for (i = 0; i < hex.length; i++) {\n c = hex.charCodeAt(i);\n if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) {\n buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15);\n if ((isEmpty ^= 1)) {\n bin.push(buffer & 0xff);\n }\n }\n }\n return numbersToDataView(bin);\n}\n\nexport function dataViewToHexString(value: DataView): string {\n return dataViewToNumbers(value)\n .map((n) => {\n let s = n.toString(16);\n if (s.length == 1) {\n s = '0' + s;\n }\n return s;\n })\n .join('');\n}\n\nexport function webUUIDToString(uuid: string | number): string {\n if (typeof uuid === 'string') {\n return uuid;\n } else if (typeof uuid === 'number') {\n return numberToUUID(uuid);\n } else {\n throw new Error('Invalid UUID');\n }\n}\n\nexport function mapToObject<V>(map?: Map<string | number, V>): { [key: string]: V } | undefined {\n const obj: { [key: string]: V } = {};\n if (!map) {\n return undefined;\n }\n map.forEach((value, key) => {\n obj[key.toString()] = value;\n });\n return obj;\n}\n\n/**\n * Convert Data or Uint8Array to Uint8Array.\n * @param value DataView, Uint8Array, or undefined\n * @return Uint8Array or undefined\n */\nexport function toUint8Array(value: DataView | Uint8Array | undefined): Uint8Array | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'string') {\n const dataView = hexStringToDataView(value);\n return new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);\n }\n if (value instanceof DataView) {\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n }\n return value; // Already Uint8Array\n}\n\n/**\n * Convert Data, Uint8Array, or string to hex string.\n * @param value DataView, Uint8Array, or undefined\n * @return hex string or undefined\n */\nexport function toHexString(value: DataView | Uint8Array | undefined): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (value instanceof DataView) {\n return dataViewToHexString(value);\n }\n // Uint8Array\n return dataViewToHexString(new DataView(value.buffer, value.byteOffset, value.byteLength));\n}\n\n/**\n * Convert a DataView to a DataView backed by an ArrayBuffer.\n * If the DataView is backed by a SharedArrayBuffer, this creates a copy.\n * Otherwise, returns the original DataView.\n * @param value DataView to convert\n * @return DataView backed by ArrayBuffer\n */\nexport function toArrayBufferDataView(value: DataView): DataView & { buffer: ArrayBuffer } {\n if (value.buffer instanceof SharedArrayBuffer) {\n // Need to copy to a regular ArrayBuffer\n const uint8Array = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n const buffer = uint8Array.slice().buffer;\n return new DataView(buffer) as DataView & { buffer: ArrayBuffer };\n }\n // Already an ArrayBuffer, use directly\n return value as DataView & { buffer: ArrayBuffer };\n}\n"]}
1
+ {"version":3,"file":"conversion.js","sourceRoot":"","sources":["../../src/conversion.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAe;IAC/C,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AACtF,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,OAAO,iBAAiB,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,cAAc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K,YAAY,QAAQ,EAAE;QAC7B,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;KACzE;IACD,OAAO,KAAK,CAAC,CAAC,qBAAqB;AACrC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,KAAwC;IAClE,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,OAAO,SAAS,CAAC;KAClB;IACD,IAAI,KAAK,YAAY,QAAQ,EAAE;QAC7B,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;KACnC;IACD,aAAa;IACb,OAAO,mBAAmB,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAe;IACnD,IAAI,KAAK,CAAC,MAAM,YAAY,iBAAiB,EAAE;QAC7C,wCAAwC;QACxC,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACpF,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC;QACzC,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAuC,CAAC;KACnE;IACD,uCAAuC;IACvC,OAAO,KAA2C,CAAC;AACrD,CAAC","sourcesContent":["/**\n * Convert an array of numbers into a DataView.\n */\nexport function numbersToDataView(value: number[]): DataView {\n return new DataView(Uint8Array.from(value).buffer);\n}\n\n/**\n * Convert a DataView into an array of numbers.\n */\nexport function dataViewToNumbers(value: DataView): number[] {\n return Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n}\n\n/**\n * Convert a string into a DataView.\n */\nexport function textToDataView(value: string): DataView {\n return numbersToDataView(value.split('').map((s) => s.charCodeAt(0)));\n}\n\n/**\n * Convert a DataView into a string.\n */\nexport function dataViewToText(value: DataView): string {\n return String.fromCharCode(...dataViewToNumbers(value));\n}\n\n/**\n * Convert a 16 bit UUID into a 128 bit UUID string\n * @param value number, e.g. 0x180d\n * @return string, e.g. '0000180d-0000-1000-8000-00805f9b34fb'\n */\nexport function numberToUUID(value: number): string {\n return `0000${value.toString(16).padStart(4, '0')}-0000-1000-8000-00805f9b34fb`;\n}\n\n/**\n * Convert a string of hex into a DataView of raw bytes.\n * Note: characters other than [0-9a-fA-F] are ignored\n * @param hex string of values, e.g. \"00 01 02\" or \"000102\"\n * @return DataView of raw bytes\n */\nexport function hexStringToDataView(hex: string): DataView {\n const bin = [];\n let i,\n c,\n isEmpty = 1,\n buffer = 0;\n for (i = 0; i < hex.length; i++) {\n c = hex.charCodeAt(i);\n if ((c > 47 && c < 58) || (c > 64 && c < 71) || (c > 96 && c < 103)) {\n buffer = (buffer << 4) ^ ((c > 64 ? c + 9 : c) & 15);\n if ((isEmpty ^= 1)) {\n bin.push(buffer & 0xff);\n }\n }\n }\n return numbersToDataView(bin);\n}\n\nexport function dataViewToHexString(value: DataView): string {\n return dataViewToNumbers(value)\n .map((n) => {\n let s = n.toString(16);\n if (s.length == 1) {\n s = '0' + s;\n }\n return s;\n })\n .join('');\n}\n\nexport function webUUIDToString(uuid: string | number): string {\n if (typeof uuid === 'string') {\n return uuid;\n } else if (typeof uuid === 'number') {\n return numberToUUID(uuid);\n } else {\n throw new Error('Invalid UUID');\n }\n}\n\nexport function mapToObject<V>(map?: Map<string | number, V>): { [key: string]: V } | undefined {\n const obj: { [key: string]: V } = {};\n if (!map) {\n return undefined;\n }\n map.forEach((value, key) => {\n obj[key.toString()] = value;\n });\n return obj;\n}\n\n/**\n * Convert Data or Uint8Array to Uint8Array.\n * @param value DataView, Uint8Array, or undefined\n * @return Uint8Array or undefined\n */\nexport function toUint8Array(value: DataView | Uint8Array | undefined): Uint8Array | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === 'string') {\n const dataView = hexStringToDataView(value);\n return new Uint8Array(dataView.buffer, dataView.byteOffset, dataView.byteLength);\n }\n if (value instanceof DataView) {\n return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n }\n return value; // Already Uint8Array\n}\n\n/**\n * Convert Data, Uint8Array, or string to hex string.\n * @param value DataView, Uint8Array, or undefined\n * @return hex string or undefined\n */\nexport function toHexString(value: DataView | Uint8Array | undefined): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (value instanceof DataView) {\n return dataViewToHexString(value);\n }\n // Uint8Array\n return dataViewToHexString(new DataView(value.buffer, value.byteOffset, value.byteLength));\n}\n\n/**\n * Convert a DataView to a DataView backed by an ArrayBuffer.\n * If the DataView is backed by a SharedArrayBuffer, this creates a copy.\n * Otherwise, returns the original DataView.\n * @param value DataView to convert\n * @return DataView backed by ArrayBuffer\n */\nexport function toArrayBufferDataView(value: DataView): DataView & { buffer: ArrayBuffer } {\n if (value.buffer instanceof SharedArrayBuffer) {\n // Need to copy to a regular ArrayBuffer\n const uint8Array = new Uint8Array(value.buffer, value.byteOffset, value.byteLength);\n const buffer = uint8Array.slice().buffer;\n return new DataView(buffer) as DataView & { buffer: ArrayBuffer };\n }\n // Already an ArrayBuffer, use directly\n return value as DataView & { buffer: ArrayBuffer };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,GAAU,EAAE;IAC5B,IAAI,WAAW,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IACtD,qDAAqD;IACrD,qDAAqD;IACrD,OAAO,CAAC,EAAE,EAAE,EAAE,CACZ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9B,WAAW,GAAG,WAAW;aACtB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;aAChB,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,SAAS,EAAE,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AACtB,CAAC","sourcesContent":["type Queue = <T>(fn: () => Promise<T>) => Promise<T>;\n\nconst makeQueue = (): Queue => {\n let currentTask: Promise<unknown> = Promise.resolve();\n // create a new promise so that errors can be bubbled\n // up to the caller without being caught by the queue\n return (fn) =>\n new Promise((resolve, reject) => {\n currentTask = currentTask\n .then(() => fn())\n .then(resolve)\n .catch(reject);\n });\n};\n\nexport function getQueue(enabled: boolean): Queue {\n if (enabled) {\n return makeQueue();\n }\n return (fn) => fn();\n}\n"]}
1
+ {"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,SAAS,GAAG,GAAU,EAAE;IAC5B,IAAI,WAAW,GAAqB,OAAO,CAAC,OAAO,EAAE,CAAC;IACtD,qDAAqD;IACrD,qDAAqD;IACrD,OAAO,CAAC,EAAE,EAAE,EAAE,CACZ,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9B,WAAW,GAAG,WAAW;aACtB,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;aAChB,IAAI,CAAC,OAAO,CAAC;aACb,KAAK,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,IAAI,OAAO,EAAE;QACX,OAAO,SAAS,EAAE,CAAC;KACpB;IACD,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;AACtB,CAAC","sourcesContent":["type Queue = <T>(fn: () => Promise<T>) => Promise<T>;\n\nconst makeQueue = (): Queue => {\n let currentTask: Promise<unknown> = Promise.resolve();\n // create a new promise so that errors can be bubbled\n // up to the caller without being caught by the queue\n return (fn) =>\n new Promise((resolve, reject) => {\n currentTask = currentTask\n .then(() => fn())\n .then(resolve)\n .catch(reject);\n });\n};\n\nexport function getQueue(enabled: boolean): Queue {\n if (enabled) {\n return makeQueue();\n }\n return (fn) => fn();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/validators.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAS;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,IAAI,oBAAoB,CAAC,CAAC;IACxE,CAAC;IACD,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,wEAAwE,CAAC,IAAI,CAAC,CAAC;IAChH,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,0EAA0E,CACtG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function parseUUID(uuid: any): string {\n if (typeof uuid !== 'string') {\n throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);\n }\n uuid = uuid.toLowerCase();\n const is128BitUuid = uuid.search(/^[0-9a-f]{8}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{12}$/) >= 0;\n if (!is128BitUuid) {\n throw new Error(\n `Invalid UUID format ${uuid}. Expected 128 bit string (e.g. \"0000180d-0000-1000-8000-00805f9b34fb\").`,\n );\n }\n return uuid;\n}\n"]}
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/validators.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAS;IACjC,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,qBAAqB,OAAO,IAAI,oBAAoB,CAAC,CAAC;KACvE;IACD,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,wEAAwE,CAAC,IAAI,CAAC,CAAC;IAChH,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CACb,uBAAuB,IAAI,0EAA0E,CACtG,CAAC;KACH;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["export function parseUUID(uuid: any): string {\n if (typeof uuid !== 'string') {\n throw new Error(`Invalid UUID type ${typeof uuid}. Expected string.`);\n }\n uuid = uuid.toLowerCase();\n const is128BitUuid = uuid.search(/^[0-9a-f]{8}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{4}\\b-[0-9a-f]{12}$/) >= 0;\n if (!is128BitUuid) {\n throw new Error(\n `Invalid UUID format ${uuid}. Expected 128 bit string (e.g. \"0000180d-0000-1000-8000-00805f9b34fb\").`,\n );\n }\n return uuid;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA0BxG,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAA7C;;QACU,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,sBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,SAAI,GAA2B,IAAI,CAAC;QAEpC,+BAA0B,GAAG,KAAK,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,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;wBACzF,OAAO,GAAG,KAAK,CAAC;wBAChB,MAAM;oBACR,CAAC;gBACH,CAAC;gBACD,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,mCAAmC;gBACnC,IAAI,OAAO,GAAG,IAAI,CAAC;gBACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC;oBAC/C,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;wBACvC,OAAO,GAAG,KAAK,CAAC;wBAChB,MAAM;oBACR,CAAC;gBACH,CAAC;gBACD,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,IAAI,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC,CAAC,oBAAoB;IACpC,CAAC;IAEO,gBAAgB,CAAC,QAAgB;QACvC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC5C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;QACpG,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAuB;;QAC1C,MAAM,SAAS,GAAc;YAC3B,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,yDAAyD;YACzD,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS;SAC/B,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { hexStringToDataView, mapToObject, toArrayBufferDataView, webUUIDToString } from './conversion';\nimport type {\n BleCharacteristic,\n BleCharacteristicProperties,\n BleDescriptor,\n BleService,\n TimeoutOptions,\n BleDevice,\n BleServices,\n BluetoothLePlugin,\n BooleanResult,\n DeviceIdOptions,\n GetConnectedDevicesOptions,\n GetDevicesOptions,\n GetDevicesResult,\n ReadDescriptorOptions,\n ReadOptions,\n ReadResult,\n ReadRssiResult,\n RequestBleDeviceOptions,\n ScanResultInternal,\n WriteOptions,\n WriteDescriptorOptions,\n GetMtuResult,\n RequestConnectionPriorityOptions,\n} from './definitions';\nimport { runWithTimeout } from './timeout';\n\nexport class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {\n private deviceMap = new Map<string, BluetoothDevice>();\n private discoveredDevices = new Map<string, boolean>();\n private scan: BluetoothLEScan | null = null;\n private requestBleDeviceOptions: RequestBleDeviceOptions | undefined;\n private DEFAULT_CONNECTION_TIMEOUT = 10000;\n\n async initialize(): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.bluetooth) {\n throw this.unavailable('Web Bluetooth API not available in this browser.');\n }\n const isAvailable = await navigator.bluetooth.getAvailability();\n if (!isAvailable) {\n throw this.unavailable('No Bluetooth radio available.');\n }\n }\n\n async isEnabled(): Promise<BooleanResult> {\n // not available on web\n return { value: true };\n }\n\n async requestEnable(): Promise<void> {\n throw this.unavailable('requestEnable is not available on web.');\n }\n\n async enable(): Promise<void> {\n throw this.unavailable('enable is not available on web.');\n }\n\n async disable(): Promise<void> {\n throw this.unavailable('disable is not available on web.');\n }\n\n async startEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async stopEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async isLocationEnabled(): Promise<BooleanResult> {\n throw this.unavailable('isLocationEnabled is not available on web.');\n }\n\n async openLocationSettings(): Promise<void> {\n throw this.unavailable('openLocationSettings is not available on web.');\n }\n\n async openBluetoothSettings(): Promise<void> {\n throw this.unavailable('openBluetoothSettings is not available on web.');\n }\n\n async openAppSettings(): Promise<void> {\n throw this.unavailable('openAppSettings is not available on web.');\n }\n\n async setDisplayStrings(): Promise<void> {\n // not available on web\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n const filters = this.getFilters(options);\n const device = await navigator.bluetooth.requestDevice({\n filters: filters.length ? filters : undefined,\n optionalServices: options?.optionalServices,\n acceptAllDevices: filters.length === 0,\n });\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n }\n\n async requestLEScan(options?: RequestBleDeviceOptions): Promise<void> {\n this.requestBleDeviceOptions = options;\n const filters = this.getFilters(options);\n await this.stopLEScan();\n this.discoveredDevices = new Map<string, boolean>();\n navigator.bluetooth.removeEventListener(\n 'advertisementreceived',\n this.onAdvertisementReceivedCallback as EventListener,\n );\n navigator.bluetooth.addEventListener('advertisementreceived', this.onAdvertisementReceivedCallback);\n this.scan = await navigator.bluetooth.requestLEScan({\n filters: filters.length ? filters : undefined,\n acceptAllAdvertisements: filters.length === 0,\n keepRepeatedDevices: options?.allowDuplicates,\n });\n }\n\n private onAdvertisementReceivedCallback = this.onAdvertisementReceived.bind(this);\n\n private onAdvertisementReceived(event: BluetoothAdvertisingEvent): void {\n const deviceId = event.device.id;\n this.deviceMap.set(deviceId, event.device);\n const isNew = !this.discoveredDevices.has(deviceId);\n\n // Apply service data filtering client-side (Web Bluetooth API doesn't support it in scan filters)\n if (this.requestBleDeviceOptions?.serviceData && !this.matchesServiceDataFilter(event)) {\n return;\n }\n\n if (isNew || this.requestBleDeviceOptions?.allowDuplicates) {\n this.discoveredDevices.set(deviceId, true);\n const device = this.getBleDevice(event.device);\n const result: ScanResultInternal = {\n device,\n localName: device.name,\n rssi: event.rssi,\n txPower: event.txPower,\n manufacturerData: mapToObject(event.manufacturerData),\n serviceData: mapToObject(event.serviceData),\n uuids: event.uuids?.map(webUUIDToString),\n };\n this.notifyListeners('onScanResult', result);\n }\n }\n\n async stopLEScan(): Promise<void> {\n if (this.scan?.active) {\n this.scan.stop();\n }\n this.scan = null;\n }\n\n async getDevices(options: GetDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => options.deviceIds.includes(device.id))\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => {\n return device.gatt?.connected;\n })\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getBondedDevices(): Promise<GetDevicesResult> {\n return {} as Promise<GetDevicesResult>;\n }\n\n async connect(options: DeviceIdOptions & TimeoutOptions): Promise<void> {\n const device = this.getDeviceFromMap(options.deviceId);\n device.removeEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n device.addEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n const timeoutError = Symbol();\n if (device.gatt === undefined) {\n throw new Error('No gatt server available.');\n }\n try {\n const timeout = options.timeout ?? this.DEFAULT_CONNECTION_TIMEOUT;\n await runWithTimeout(device.gatt.connect(), timeout, timeoutError);\n } catch (error) {\n // cancel pending connect call, does not work yet in chromium because of a bug:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=684073\n await device.gatt?.disconnect();\n if (error === timeoutError) {\n throw new Error('Connection timeout');\n } else {\n throw error;\n }\n }\n }\n\n private onDisconnectedCallback = this.onDisconnected.bind(this);\n\n private onDisconnected(event: Event): void {\n const deviceId = (event.target as BluetoothDevice).id;\n const key = `disconnected|${deviceId}`;\n this.notifyListeners(key, null);\n }\n\n async createBond(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('createBond is not available on web.');\n }\n\n async isBonded(_options: DeviceIdOptions): Promise<BooleanResult> {\n throw this.unavailable('isBonded is not available on web.');\n }\n\n async disconnect(options: DeviceIdOptions): Promise<void> {\n this.getDeviceFromMap(options.deviceId).gatt?.disconnect();\n }\n\n async getServices(options: DeviceIdOptions): Promise<BleServices> {\n const services = (await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryServices()) ?? [];\n const bleServices: BleService[] = [];\n for (const service of services) {\n const characteristics = await service.getCharacteristics();\n const bleCharacteristics: BleCharacteristic[] = [];\n for (const characteristic of characteristics) {\n bleCharacteristics.push({\n uuid: characteristic.uuid,\n properties: this.getProperties(characteristic),\n descriptors: await this.getDescriptors(characteristic),\n });\n }\n bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics });\n }\n return { services: bleServices };\n }\n\n private async getDescriptors(characteristic: BluetoothRemoteGATTCharacteristic): Promise<BleDescriptor[]> {\n try {\n const descriptors = await characteristic.getDescriptors();\n return descriptors.map((descriptor) => ({\n uuid: descriptor.uuid,\n }));\n } catch {\n return [];\n }\n }\n\n private getProperties(characteristic: BluetoothRemoteGATTCharacteristic): BleCharacteristicProperties {\n return {\n broadcast: characteristic.properties.broadcast,\n read: characteristic.properties.read,\n writeWithoutResponse: characteristic.properties.writeWithoutResponse,\n write: characteristic.properties.write,\n notify: characteristic.properties.notify,\n indicate: characteristic.properties.indicate,\n authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites,\n reliableWrite: characteristic.properties.reliableWrite,\n writableAuxiliaries: characteristic.properties.writableAuxiliaries,\n };\n }\n\n private async getCharacteristic(\n options: ReadOptions | WriteOptions,\n ): Promise<BluetoothRemoteGATTCharacteristic | undefined> {\n const service = await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryService(options?.service);\n return service?.getCharacteristic(options?.characteristic);\n }\n\n private async getDescriptor(\n options: ReadDescriptorOptions | WriteDescriptorOptions,\n ): Promise<BluetoothRemoteGATTDescriptor | undefined> {\n const characteristic = await this.getCharacteristic(options);\n return characteristic?.getDescriptor(options?.descriptor);\n }\n\n async discoverServices(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('discoverServices is not available on web.');\n }\n\n async getMtu(_options: DeviceIdOptions): Promise<GetMtuResult> {\n throw this.unavailable('getMtu is not available on web.');\n }\n\n async requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void> {\n throw this.unavailable('requestConnectionPriority is not available on web.');\n }\n\n async readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult> {\n throw this.unavailable('readRssi is not available on web.');\n }\n\n async read(options: ReadOptions): Promise<ReadResult> {\n const characteristic = await this.getCharacteristic(options);\n const value = await characteristic?.readValue();\n return { value };\n }\n\n async write(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithResponse(toArrayBufferDataView(dataView));\n }\n\n async writeWithoutResponse(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithoutResponse(toArrayBufferDataView(dataView));\n }\n\n async readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult> {\n const descriptor = await this.getDescriptor(options);\n const value = await descriptor?.readValue();\n return { value };\n }\n\n async writeDescriptor(options: WriteDescriptorOptions): Promise<void> {\n const descriptor = await this.getDescriptor(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await descriptor?.writeValue(toArrayBufferDataView(dataView));\n }\n\n async startNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n characteristic?.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n characteristic?.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n await characteristic?.startNotifications();\n }\n\n private onCharacteristicValueChangedCallback = this.onCharacteristicValueChanged.bind(this);\n\n private onCharacteristicValueChanged(event: Event): void {\n const characteristic = event.target as BluetoothRemoteGATTCharacteristic;\n const key = `notification|${characteristic.service?.device.id}|${characteristic.service?.uuid}|${characteristic.uuid}`;\n this.notifyListeners(key, {\n value: characteristic.value,\n });\n }\n\n async stopNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n await characteristic?.stopNotifications();\n }\n\n private getFilters(options?: RequestBleDeviceOptions): BluetoothLEScanFilter[] {\n const filters: BluetoothLEScanFilter[] = [];\n for (const service of options?.services ?? []) {\n filters.push({\n services: [service],\n name: options?.name,\n namePrefix: options?.namePrefix,\n });\n }\n if ((options?.name || options?.namePrefix) && filters.length === 0) {\n filters.push({\n name: options.name,\n namePrefix: options.namePrefix,\n });\n }\n for (const manufacturerData of options?.manufacturerData ?? []) {\n // Cast to any to avoid type incompatibility - conversion is handled in bleClient.ts\n filters.push({\n manufacturerData: [manufacturerData as any],\n });\n }\n // Note: Web Bluetooth API does not support service data in scan filters.\n // Service data filtering will be done client-side in onAdvertisementReceived.\n // We still accept serviceData in options for API consistency across platforms.\n return filters;\n }\n\n private matchesServiceDataFilter(event: BluetoothAdvertisingEvent): boolean {\n const filters = this.requestBleDeviceOptions?.serviceData;\n if (!filters || filters.length === 0) {\n return true; // No filters, accept all\n }\n\n if (!event.serviceData) {\n return false; // No service data in advertisement\n }\n\n // Check if any filter matches (OR logic)\n for (const filter of filters) {\n const serviceData = event.serviceData.get(filter.serviceUuid);\n if (!serviceData) {\n continue; // This filter doesn't match, try next\n }\n\n // If we have service data for this UUID\n if (!filter.dataPrefix) {\n return true; // Filter matched by service UUID alone\n }\n\n // Check data prefix (DataView on web)\n const data = new Uint8Array(serviceData.buffer);\n const prefixView = filter.dataPrefix as DataView;\n\n if (data.length < prefixView.byteLength) {\n continue; // Data too short\n }\n\n // Apply mask if provided\n if (filter.mask) {\n const maskView = filter.mask as DataView;\n let matches = true;\n for (let i = 0; i < prefixView.byteLength; i++) {\n if ((data[i] & maskView.getUint8(i)) !== (prefixView.getUint8(i) & maskView.getUint8(i))) {\n matches = false;\n break;\n }\n }\n if (matches) {\n return true;\n }\n } else {\n // Check if data starts with prefix\n let matches = true;\n for (let i = 0; i < prefixView.byteLength; i++) {\n if (data[i] !== prefixView.getUint8(i)) {\n matches = false;\n break;\n }\n }\n if (matches) {\n return true;\n }\n }\n }\n\n return false; // No filter matched\n }\n\n private getDeviceFromMap(deviceId: string): BluetoothDevice {\n const device = this.deviceMap.get(deviceId);\n if (device === undefined) {\n throw new Error('Device not found. Call \"requestDevice\", \"requestLEScan\" or \"getDevices\" first.');\n }\n return device;\n }\n\n private getBleDevice(device: BluetoothDevice): BleDevice {\n const bleDevice: BleDevice = {\n deviceId: device.id,\n // use undefined instead of null if name is not available\n name: device.name ?? undefined,\n };\n return bleDevice;\n }\n}\n"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AA0BxG,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C,MAAM,OAAO,cAAe,SAAQ,SAAS;IAA7C;;QACU,cAAS,GAAG,IAAI,GAAG,EAA2B,CAAC;QAC/C,sBAAiB,GAAG,IAAI,GAAG,EAAmB,CAAC;QAC/C,SAAI,GAA2B,IAAI,CAAC;QAEpC,+BAA0B,GAAG,KAAK,CAAC;QAsFnC,oCAA+B,GAAG,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAwF1E,2BAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAiJxD,yCAAoC,GAAG,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAuH9F,CAAC;IApbC,KAAK,CAAC,UAAU;QACd,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,C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C5C,IAAI,MAAM,KAAK,SAAS,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAC;SACnG;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,YAAY,CAAC,MAAuB;;QAC1C,MAAM,SAAS,GAAc;YAC3B,QAAQ,EAAE,MAAM,CAAC,EAAE;YACnB,yDAAyD;YACzD,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,SAAS;SAC/B,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport { hexStringToDataView, mapToObject, toArrayBufferDataView, webUUIDToString } from './conversion';\nimport type {\n BleCharacteristic,\n BleCharacteristicProperties,\n BleDescriptor,\n BleService,\n TimeoutOptions,\n BleDevice,\n BleServices,\n BluetoothLePlugin,\n BooleanResult,\n DeviceIdOptions,\n GetConnectedDevicesOptions,\n GetDevicesOptions,\n GetDevicesResult,\n ReadDescriptorOptions,\n ReadOptions,\n ReadResult,\n ReadRssiResult,\n RequestBleDeviceOptions,\n ScanResultInternal,\n WriteOptions,\n WriteDescriptorOptions,\n GetMtuResult,\n RequestConnectionPriorityOptions,\n} from './definitions';\nimport { runWithTimeout } from './timeout';\n\nexport class BluetoothLeWeb extends WebPlugin implements BluetoothLePlugin {\n private deviceMap = new Map<string, BluetoothDevice>();\n private discoveredDevices = new Map<string, boolean>();\n private scan: BluetoothLEScan | null = null;\n private requestBleDeviceOptions: RequestBleDeviceOptions | undefined;\n private DEFAULT_CONNECTION_TIMEOUT = 10000;\n\n async initialize(): Promise<void> {\n if (typeof navigator === 'undefined' || !navigator.bluetooth) {\n throw this.unavailable('Web Bluetooth API not available in this browser.');\n }\n const isAvailable = await navigator.bluetooth.getAvailability();\n if (!isAvailable) {\n throw this.unavailable('No Bluetooth radio available.');\n }\n }\n\n async isEnabled(): Promise<BooleanResult> {\n // not available on web\n return { value: true };\n }\n\n async requestEnable(): Promise<void> {\n throw this.unavailable('requestEnable is not available on web.');\n }\n\n async enable(): Promise<void> {\n throw this.unavailable('enable is not available on web.');\n }\n\n async disable(): Promise<void> {\n throw this.unavailable('disable is not available on web.');\n }\n\n async startEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async stopEnabledNotifications(): Promise<void> {\n // not available on web\n }\n\n async isLocationEnabled(): Promise<BooleanResult> {\n throw this.unavailable('isLocationEnabled is not available on web.');\n }\n\n async openLocationSettings(): Promise<void> {\n throw this.unavailable('openLocationSettings is not available on web.');\n }\n\n async openBluetoothSettings(): Promise<void> {\n throw this.unavailable('openBluetoothSettings is not available on web.');\n }\n\n async openAppSettings(): Promise<void> {\n throw this.unavailable('openAppSettings is not available on web.');\n }\n\n async setDisplayStrings(): Promise<void> {\n // not available on web\n }\n\n async requestDevice(options?: RequestBleDeviceOptions): Promise<BleDevice> {\n const filters = this.getFilters(options);\n const device = await navigator.bluetooth.requestDevice({\n filters: filters.length ? filters : undefined,\n optionalServices: options?.optionalServices,\n acceptAllDevices: filters.length === 0,\n });\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n }\n\n async requestLEScan(options?: RequestBleDeviceOptions): Promise<void> {\n this.requestBleDeviceOptions = options;\n const filters = this.getFilters(options);\n await this.stopLEScan();\n this.discoveredDevices = new Map<string, boolean>();\n navigator.bluetooth.removeEventListener(\n 'advertisementreceived',\n this.onAdvertisementReceivedCallback as EventListener,\n );\n navigator.bluetooth.addEventListener('advertisementreceived', this.onAdvertisementReceivedCallback);\n this.scan = await navigator.bluetooth.requestLEScan({\n filters: filters.length ? filters : undefined,\n acceptAllAdvertisements: filters.length === 0,\n keepRepeatedDevices: options?.allowDuplicates,\n });\n }\n\n private onAdvertisementReceivedCallback = this.onAdvertisementReceived.bind(this);\n\n private onAdvertisementReceived(event: BluetoothAdvertisingEvent): void {\n const deviceId = event.device.id;\n this.deviceMap.set(deviceId, event.device);\n const isNew = !this.discoveredDevices.has(deviceId);\n\n // Apply service data filtering client-side (Web Bluetooth API doesn't support it in scan filters)\n if (this.requestBleDeviceOptions?.serviceData && !this.matchesServiceDataFilter(event)) {\n return;\n }\n\n if (isNew || this.requestBleDeviceOptions?.allowDuplicates) {\n this.discoveredDevices.set(deviceId, true);\n const device = this.getBleDevice(event.device);\n const result: ScanResultInternal = {\n device,\n localName: device.name,\n rssi: event.rssi,\n txPower: event.txPower,\n manufacturerData: mapToObject(event.manufacturerData),\n serviceData: mapToObject(event.serviceData),\n uuids: event.uuids?.map(webUUIDToString),\n };\n this.notifyListeners('onScanResult', result);\n }\n }\n\n async stopLEScan(): Promise<void> {\n if (this.scan?.active) {\n this.scan.stop();\n }\n this.scan = null;\n }\n\n async getDevices(options: GetDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => options.deviceIds.includes(device.id))\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getConnectedDevices(_options: GetConnectedDevicesOptions): Promise<GetDevicesResult> {\n const devices = await navigator.bluetooth.getDevices();\n const bleDevices = devices\n .filter((device) => {\n return device.gatt?.connected;\n })\n .map((device) => {\n this.deviceMap.set(device.id, device);\n const bleDevice = this.getBleDevice(device);\n return bleDevice;\n });\n return { devices: bleDevices };\n }\n\n async getBondedDevices(): Promise<GetDevicesResult> {\n return {} as Promise<GetDevicesResult>;\n }\n\n async connect(options: DeviceIdOptions & TimeoutOptions): Promise<void> {\n const device = this.getDeviceFromMap(options.deviceId);\n device.removeEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n device.addEventListener('gattserverdisconnected', this.onDisconnectedCallback);\n const timeoutError = Symbol();\n if (device.gatt === undefined) {\n throw new Error('No gatt server available.');\n }\n try {\n const timeout = options.timeout ?? this.DEFAULT_CONNECTION_TIMEOUT;\n await runWithTimeout(device.gatt.connect(), timeout, timeoutError);\n } catch (error) {\n // cancel pending connect call, does not work yet in chromium because of a bug:\n // https://bugs.chromium.org/p/chromium/issues/detail?id=684073\n await device.gatt?.disconnect();\n if (error === timeoutError) {\n throw new Error('Connection timeout');\n } else {\n throw error;\n }\n }\n }\n\n private onDisconnectedCallback = this.onDisconnected.bind(this);\n\n private onDisconnected(event: Event): void {\n const deviceId = (event.target as BluetoothDevice).id;\n const key = `disconnected|${deviceId}`;\n this.notifyListeners(key, null);\n }\n\n async createBond(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('createBond is not available on web.');\n }\n\n async isBonded(_options: DeviceIdOptions): Promise<BooleanResult> {\n throw this.unavailable('isBonded is not available on web.');\n }\n\n async disconnect(options: DeviceIdOptions): Promise<void> {\n this.getDeviceFromMap(options.deviceId).gatt?.disconnect();\n }\n\n async getServices(options: DeviceIdOptions): Promise<BleServices> {\n const services = (await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryServices()) ?? [];\n const bleServices: BleService[] = [];\n for (const service of services) {\n const characteristics = await service.getCharacteristics();\n const bleCharacteristics: BleCharacteristic[] = [];\n for (const characteristic of characteristics) {\n bleCharacteristics.push({\n uuid: characteristic.uuid,\n properties: this.getProperties(characteristic),\n descriptors: await this.getDescriptors(characteristic),\n });\n }\n bleServices.push({ uuid: service.uuid, characteristics: bleCharacteristics });\n }\n return { services: bleServices };\n }\n\n private async getDescriptors(characteristic: BluetoothRemoteGATTCharacteristic): Promise<BleDescriptor[]> {\n try {\n const descriptors = await characteristic.getDescriptors();\n return descriptors.map((descriptor) => ({\n uuid: descriptor.uuid,\n }));\n } catch {\n return [];\n }\n }\n\n private getProperties(characteristic: BluetoothRemoteGATTCharacteristic): BleCharacteristicProperties {\n return {\n broadcast: characteristic.properties.broadcast,\n read: characteristic.properties.read,\n writeWithoutResponse: characteristic.properties.writeWithoutResponse,\n write: characteristic.properties.write,\n notify: characteristic.properties.notify,\n indicate: characteristic.properties.indicate,\n authenticatedSignedWrites: characteristic.properties.authenticatedSignedWrites,\n reliableWrite: characteristic.properties.reliableWrite,\n writableAuxiliaries: characteristic.properties.writableAuxiliaries,\n };\n }\n\n private async getCharacteristic(\n options: ReadOptions | WriteOptions,\n ): Promise<BluetoothRemoteGATTCharacteristic | undefined> {\n const service = await this.getDeviceFromMap(options.deviceId).gatt?.getPrimaryService(options?.service);\n return service?.getCharacteristic(options?.characteristic);\n }\n\n private async getDescriptor(\n options: ReadDescriptorOptions | WriteDescriptorOptions,\n ): Promise<BluetoothRemoteGATTDescriptor | undefined> {\n const characteristic = await this.getCharacteristic(options);\n return characteristic?.getDescriptor(options?.descriptor);\n }\n\n async discoverServices(_options: DeviceIdOptions): Promise<void> {\n throw this.unavailable('discoverServices is not available on web.');\n }\n\n async getMtu(_options: DeviceIdOptions): Promise<GetMtuResult> {\n throw this.unavailable('getMtu is not available on web.');\n }\n\n async requestConnectionPriority(_options: RequestConnectionPriorityOptions): Promise<void> {\n throw this.unavailable('requestConnectionPriority is not available on web.');\n }\n\n async readRssi(_options: DeviceIdOptions): Promise<ReadRssiResult> {\n throw this.unavailable('readRssi is not available on web.');\n }\n\n async read(options: ReadOptions): Promise<ReadResult> {\n const characteristic = await this.getCharacteristic(options);\n const value = await characteristic?.readValue();\n return { value };\n }\n\n async write(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithResponse(toArrayBufferDataView(dataView));\n }\n\n async writeWithoutResponse(options: WriteOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await characteristic?.writeValueWithoutResponse(toArrayBufferDataView(dataView));\n }\n\n async readDescriptor(options: ReadDescriptorOptions): Promise<ReadResult> {\n const descriptor = await this.getDescriptor(options);\n const value = await descriptor?.readValue();\n return { value };\n }\n\n async writeDescriptor(options: WriteDescriptorOptions): Promise<void> {\n const descriptor = await this.getDescriptor(options);\n let dataView: DataView;\n if (typeof options.value === 'string') {\n dataView = hexStringToDataView(options.value);\n } else {\n dataView = options.value;\n }\n await descriptor?.writeValue(toArrayBufferDataView(dataView));\n }\n\n async startNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n characteristic?.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n characteristic?.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);\n await characteristic?.startNotifications();\n }\n\n private onCharacteristicValueChangedCallback = this.onCharacteristicValueChanged.bind(this);\n\n private onCharacteristicValueChanged(event: Event): void {\n const characteristic = event.target as BluetoothRemoteGATTCharacteristic;\n const key = `notification|${characteristic.service?.device.id}|${characteristic.service?.uuid}|${characteristic.uuid}`;\n this.notifyListeners(key, {\n value: characteristic.value,\n });\n }\n\n async stopNotifications(options: ReadOptions): Promise<void> {\n const characteristic = await this.getCharacteristic(options);\n await characteristic?.stopNotifications();\n }\n\n private getFilters(options?: RequestBleDeviceOptions): BluetoothLEScanFilter[] {\n const filters: BluetoothLEScanFilter[] = [];\n for (const service of options?.services ?? []) {\n filters.push({\n services: [service],\n name: options?.name,\n namePrefix: options?.namePrefix,\n });\n }\n if ((options?.name || options?.namePrefix) && filters.length === 0) {\n filters.push({\n name: options.name,\n namePrefix: options.namePrefix,\n });\n }\n for (const manufacturerData of options?.manufacturerData ?? []) {\n // Cast to any to avoid type incompatibility - conversion is handled in bleClient.ts\n filters.push({\n manufacturerData: [manufacturerData as any],\n });\n }\n // Note: Web Bluetooth API does not support service data in scan filters.\n // Service data filtering will be done client-side in onAdvertisementReceived.\n // We still accept serviceData in options for API consistency across platforms.\n return filters;\n }\n\n private matchesServiceDataFilter(event: BluetoothAdvertisingEvent): boolean {\n const filters = this.requestBleDeviceOptions?.serviceData;\n if (!filters || filters.length === 0) {\n return true; // No filters, accept all\n }\n\n if (!event.serviceData) {\n return false; // No service data in advertisement\n }\n\n // Check if any filter matches (OR logic)\n for (const filter of filters) {\n const serviceData = event.serviceData.get(filter.serviceUuid);\n if (!serviceData) {\n continue; // This filter doesn't match, try next\n }\n\n // If we have service data for this UUID\n if (!filter.dataPrefix) {\n return true; // Filter matched by service UUID alone\n }\n\n // Check data prefix (DataView on web)\n const data = new Uint8Array(serviceData.buffer);\n const prefixView = filter.dataPrefix as DataView;\n\n if (data.length < prefixView.byteLength) {\n continue; // Data too short\n }\n\n // Apply mask if provided\n if (filter.mask) {\n const maskView = filter.mask as DataView;\n let matches = true;\n for (let i = 0; i < prefixView.byteLength; i++) {\n if ((data[i] & maskView.getUint8(i)) !== (prefixView.getUint8(i) & maskView.getUint8(i))) {\n matches = false;\n break;\n }\n }\n if (matches) {\n return true;\n }\n } else {\n // Check if data starts with prefix\n let matches = true;\n for (let i = 0; i < prefixView.byteLength; i++) {\n if (data[i] !== prefixView.getUint8(i)) {\n matches = false;\n break;\n }\n }\n if (matches) {\n return true;\n }\n }\n }\n\n return false; // No filter matched\n }\n\n private getDeviceFromMap(deviceId: string): BluetoothDevice {\n const device = this.deviceMap.get(deviceId);\n if (device === undefined) {\n throw new Error('Device not found. Call \"requestDevice\", \"requestLEScan\" or \"getDevices\" first.');\n }\n return device;\n }\n\n private getBleDevice(device: BluetoothDevice): BleDevice {\n const bleDevice: BleDevice = {\n deviceId: device.id,\n // use undefined instead of null if name is not available\n name: device.name ?? undefined,\n };\n return bleDevice;\n }\n}\n"]}
@@ -257,7 +257,7 @@ class BleClientClass {
257
257
  await this.queue(async () => {
258
258
  var _a;
259
259
  const key = `onEnabledChanged`;
260
- await ((_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove());
260
+ await ((_a = this.eventListeners.get(key)) === null || _a === undefined ? undefined : _a.remove());
261
261
  const listener = await BluetoothLe.addListener(key, (result) => {
262
262
  callback(result.value);
263
263
  });
@@ -269,7 +269,7 @@ class BleClientClass {
269
269
  await this.queue(async () => {
270
270
  var _a;
271
271
  const key = `onEnabledChanged`;
272
- await ((_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove());
272
+ await ((_a = this.eventListeners.get(key)) === null || _a === undefined ? undefined : _a.remove());
273
273
  this.eventListeners.delete(key);
274
274
  await BluetoothLe.stopEnabledNotifications();
275
275
  });
@@ -313,7 +313,7 @@ class BleClientClass {
313
313
  options = this.validateRequestBleDeviceOptions(options);
314
314
  await this.queue(async () => {
315
315
  var _a;
316
- await ((_a = this.scanListener) === null || _a === void 0 ? void 0 : _a.remove());
316
+ await ((_a = this.scanListener) === null || _a === undefined ? undefined : _a.remove());
317
317
  this.scanListener = await BluetoothLe.addListener('onScanResult', (resultInternal) => {
318
318
  const result = Object.assign(Object.assign({}, resultInternal), { manufacturerData: this.convertObject(resultInternal.manufacturerData), serviceData: this.convertObject(resultInternal.serviceData), rawAdvertisement: resultInternal.rawAdvertisement
319
319
  ? this.convertValue(resultInternal.rawAdvertisement)
@@ -326,7 +326,7 @@ class BleClientClass {
326
326
  async stopLEScan() {
327
327
  await this.queue(async () => {
328
328
  var _a;
329
- await ((_a = this.scanListener) === null || _a === void 0 ? void 0 : _a.remove());
329
+ await ((_a = this.scanListener) === null || _a === undefined ? undefined : _a.remove());
330
330
  this.scanListener = null;
331
331
  await BluetoothLe.stopLEScan();
332
332
  });
@@ -361,7 +361,7 @@ class BleClientClass {
361
361
  var _a;
362
362
  if (onDisconnect) {
363
363
  const key = `disconnected|${deviceId}`;
364
- await ((_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove());
364
+ await ((_a = this.eventListeners.get(key)) === null || _a === undefined ? undefined : _a.remove());
365
365
  const listener = await BluetoothLe.addListener(key, () => {
366
366
  onDisconnect(deviceId);
367
367
  });
@@ -433,7 +433,7 @@ class BleClientClass {
433
433
  service = parseUUID(service);
434
434
  characteristic = parseUUID(characteristic);
435
435
  return this.queue(async () => {
436
- if (!(value === null || value === void 0 ? void 0 : value.buffer)) {
436
+ if (!(value === null || value === undefined ? undefined : value.buffer)) {
437
437
  throw new Error('Invalid data.');
438
438
  }
439
439
  let writeValue = value;
@@ -450,7 +450,7 @@ class BleClientClass {
450
450
  service = parseUUID(service);
451
451
  characteristic = parseUUID(characteristic);
452
452
  await this.queue(async () => {
453
- if (!(value === null || value === void 0 ? void 0 : value.buffer)) {
453
+ if (!(value === null || value === undefined ? undefined : value.buffer)) {
454
454
  throw new Error('Invalid data.');
455
455
  }
456
456
  let writeValue = value;
@@ -481,7 +481,7 @@ class BleClientClass {
481
481
  characteristic = parseUUID(characteristic);
482
482
  descriptor = parseUUID(descriptor);
483
483
  return this.queue(async () => {
484
- if (!(value === null || value === void 0 ? void 0 : value.buffer)) {
484
+ if (!(value === null || value === undefined ? undefined : value.buffer)) {
485
485
  throw new Error('Invalid data.');
486
486
  }
487
487
  let writeValue = value;
@@ -501,9 +501,9 @@ class BleClientClass {
501
501
  await this.queue(async () => {
502
502
  var _a;
503
503
  const key = `notification|${deviceId}|${service}|${characteristic}`;
504
- await ((_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove());
504
+ await ((_a = this.eventListeners.get(key)) === null || _a === undefined ? undefined : _a.remove());
505
505
  const listener = await BluetoothLe.addListener(key, (event) => {
506
- callback(this.convertValue(event === null || event === void 0 ? void 0 : event.value));
506
+ callback(this.convertValue(event === null || event === undefined ? undefined : event.value));
507
507
  });
508
508
  this.eventListeners.set(key, listener);
509
509
  await BluetoothLe.startNotifications(Object.assign({ deviceId,
@@ -517,7 +517,7 @@ class BleClientClass {
517
517
  await this.queue(async () => {
518
518
  var _a;
519
519
  const key = `notification|${deviceId}|${service}|${characteristic}`;
520
- await ((_a = this.eventListeners.get(key)) === null || _a === void 0 ? void 0 : _a.remove());
520
+ await ((_a = this.eventListeners.get(key)) === null || _a === undefined ? undefined : _a.remove());
521
521
  this.eventListeners.delete(key);
522
522
  await BluetoothLe.stopNotifications({
523
523
  deviceId,
@@ -639,7 +639,7 @@ class BluetoothLeWeb extends core.WebPlugin {
639
639
  const filters = this.getFilters(options);
640
640
  const device = await navigator.bluetooth.requestDevice({
641
641
  filters: filters.length ? filters : undefined,
642
- optionalServices: options === null || options === void 0 ? void 0 : options.optionalServices,
642
+ optionalServices: options === null || options === undefined ? undefined : options.optionalServices,
643
643
  acceptAllDevices: filters.length === 0,
644
644
  });
645
645
  this.deviceMap.set(device.id, device);
@@ -656,7 +656,7 @@ class BluetoothLeWeb extends core.WebPlugin {
656
656
  this.scan = await navigator.bluetooth.requestLEScan({
657
657
  filters: filters.length ? filters : undefined,
658
658
  acceptAllAdvertisements: filters.length === 0,
659
- keepRepeatedDevices: options === null || options === void 0 ? void 0 : options.allowDuplicates,
659
+ keepRepeatedDevices: options === null || options === undefined ? undefined : options.allowDuplicates,
660
660
  });
661
661
  }
662
662
  onAdvertisementReceived(event) {
@@ -665,10 +665,10 @@ class BluetoothLeWeb extends core.WebPlugin {
665
665
  this.deviceMap.set(deviceId, event.device);
666
666
  const isNew = !this.discoveredDevices.has(deviceId);
667
667
  // Apply service data filtering client-side (Web Bluetooth API doesn't support it in scan filters)
668
- if (((_a = this.requestBleDeviceOptions) === null || _a === void 0 ? void 0 : _a.serviceData) && !this.matchesServiceDataFilter(event)) {
668
+ if (((_a = this.requestBleDeviceOptions) === null || _a === undefined ? undefined : _a.serviceData) && !this.matchesServiceDataFilter(event)) {
669
669
  return;
670
670
  }
671
- if (isNew || ((_b = this.requestBleDeviceOptions) === null || _b === void 0 ? void 0 : _b.allowDuplicates)) {
671
+ if (isNew || ((_b = this.requestBleDeviceOptions) === null || _b === undefined ? undefined : _b.allowDuplicates)) {
672
672
  this.discoveredDevices.set(deviceId, true);
673
673
  const device = this.getBleDevice(event.device);
674
674
  const result = {
@@ -678,14 +678,14 @@ class BluetoothLeWeb extends core.WebPlugin {
678
678
  txPower: event.txPower,
679
679
  manufacturerData: mapToObject(event.manufacturerData),
680
680
  serviceData: mapToObject(event.serviceData),
681
- uuids: (_c = event.uuids) === null || _c === void 0 ? void 0 : _c.map(webUUIDToString),
681
+ uuids: (_c = event.uuids) === null || _c === undefined ? undefined : _c.map(webUUIDToString),
682
682
  };
683
683
  this.notifyListeners('onScanResult', result);
684
684
  }
685
685
  }
686
686
  async stopLEScan() {
687
687
  var _a;
688
- if ((_a = this.scan) === null || _a === void 0 ? void 0 : _a.active) {
688
+ if ((_a = this.scan) === null || _a === undefined ? undefined : _a.active) {
689
689
  this.scan.stop();
690
690
  }
691
691
  this.scan = null;
@@ -706,7 +706,7 @@ class BluetoothLeWeb extends core.WebPlugin {
706
706
  const bleDevices = devices
707
707
  .filter((device) => {
708
708
  var _a;
709
- return (_a = device.gatt) === null || _a === void 0 ? void 0 : _a.connected;
709
+ return (_a = device.gatt) === null || _a === undefined ? undefined : _a.connected;
710
710
  })
711
711
  .map((device) => {
712
712
  this.deviceMap.set(device.id, device);
@@ -734,7 +734,7 @@ class BluetoothLeWeb extends core.WebPlugin {
734
734
  catch (error) {
735
735
  // cancel pending connect call, does not work yet in chromium because of a bug:
736
736
  // https://bugs.chromium.org/p/chromium/issues/detail?id=684073
737
- await ((_b = device.gatt) === null || _b === void 0 ? void 0 : _b.disconnect());
737
+ await ((_b = device.gatt) === null || _b === undefined ? undefined : _b.disconnect());
738
738
  if (error === timeoutError) {
739
739
  throw new Error('Connection timeout');
740
740
  }
@@ -756,11 +756,11 @@ class BluetoothLeWeb extends core.WebPlugin {
756
756
  }
757
757
  async disconnect(options) {
758
758
  var _a;
759
- (_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.disconnect();
759
+ (_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === undefined ? undefined : _a.disconnect();
760
760
  }
761
761
  async getServices(options) {
762
762
  var _a, _b;
763
- const services = (_b = (await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryServices()))) !== null && _b !== void 0 ? _b : [];
763
+ const services = (_b = (await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === undefined ? undefined : _a.getPrimaryServices()))) !== null && _b !== undefined ? _b : [];
764
764
  const bleServices = [];
765
765
  for (const service of services) {
766
766
  const characteristics = await service.getCharacteristics();
@@ -802,12 +802,12 @@ class BluetoothLeWeb extends core.WebPlugin {
802
802
  }
803
803
  async getCharacteristic(options) {
804
804
  var _a;
805
- const service = await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === void 0 ? void 0 : _a.getPrimaryService(options === null || options === void 0 ? void 0 : options.service));
806
- return service === null || service === void 0 ? void 0 : service.getCharacteristic(options === null || options === void 0 ? void 0 : options.characteristic);
805
+ const service = await ((_a = this.getDeviceFromMap(options.deviceId).gatt) === null || _a === undefined ? undefined : _a.getPrimaryService(options === null || options === undefined ? undefined : options.service));
806
+ return service === null || service === undefined ? undefined : service.getCharacteristic(options === null || options === undefined ? undefined : options.characteristic);
807
807
  }
808
808
  async getDescriptor(options) {
809
809
  const characteristic = await this.getCharacteristic(options);
810
- return characteristic === null || characteristic === void 0 ? void 0 : characteristic.getDescriptor(options === null || options === void 0 ? void 0 : options.descriptor);
810
+ return characteristic === null || characteristic === undefined ? undefined : characteristic.getDescriptor(options === null || options === undefined ? undefined : options.descriptor);
811
811
  }
812
812
  async discoverServices(_options) {
813
813
  throw this.unavailable('discoverServices is not available on web.');
@@ -823,7 +823,7 @@ class BluetoothLeWeb extends core.WebPlugin {
823
823
  }
824
824
  async read(options) {
825
825
  const characteristic = await this.getCharacteristic(options);
826
- const value = await (characteristic === null || characteristic === void 0 ? void 0 : characteristic.readValue());
826
+ const value = await (characteristic === null || characteristic === undefined ? undefined : characteristic.readValue());
827
827
  return { value };
828
828
  }
829
829
  async write(options) {
@@ -835,7 +835,7 @@ class BluetoothLeWeb extends core.WebPlugin {
835
835
  else {
836
836
  dataView = options.value;
837
837
  }
838
- await (characteristic === null || characteristic === void 0 ? void 0 : characteristic.writeValueWithResponse(toArrayBufferDataView(dataView)));
838
+ await (characteristic === null || characteristic === undefined ? undefined : characteristic.writeValueWithResponse(toArrayBufferDataView(dataView)));
839
839
  }
840
840
  async writeWithoutResponse(options) {
841
841
  const characteristic = await this.getCharacteristic(options);
@@ -846,11 +846,11 @@ class BluetoothLeWeb extends core.WebPlugin {
846
846
  else {
847
847
  dataView = options.value;
848
848
  }
849
- await (characteristic === null || characteristic === void 0 ? void 0 : characteristic.writeValueWithoutResponse(toArrayBufferDataView(dataView)));
849
+ await (characteristic === null || characteristic === undefined ? undefined : characteristic.writeValueWithoutResponse(toArrayBufferDataView(dataView)));
850
850
  }
851
851
  async readDescriptor(options) {
852
852
  const descriptor = await this.getDescriptor(options);
853
- const value = await (descriptor === null || descriptor === void 0 ? void 0 : descriptor.readValue());
853
+ const value = await (descriptor === null || descriptor === undefined ? undefined : descriptor.readValue());
854
854
  return { value };
855
855
  }
856
856
  async writeDescriptor(options) {
@@ -862,43 +862,43 @@ class BluetoothLeWeb extends core.WebPlugin {
862
862
  else {
863
863
  dataView = options.value;
864
864
  }
865
- await (descriptor === null || descriptor === void 0 ? void 0 : descriptor.writeValue(toArrayBufferDataView(dataView)));
865
+ await (descriptor === null || descriptor === undefined ? undefined : descriptor.writeValue(toArrayBufferDataView(dataView)));
866
866
  }
867
867
  async startNotifications(options) {
868
868
  const characteristic = await this.getCharacteristic(options);
869
- characteristic === null || characteristic === void 0 ? void 0 : characteristic.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);
870
- characteristic === null || characteristic === void 0 ? void 0 : characteristic.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);
871
- await (characteristic === null || characteristic === void 0 ? void 0 : characteristic.startNotifications());
869
+ characteristic === null || characteristic === undefined ? undefined : characteristic.removeEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);
870
+ characteristic === null || characteristic === undefined ? undefined : characteristic.addEventListener('characteristicvaluechanged', this.onCharacteristicValueChangedCallback);
871
+ await (characteristic === null || characteristic === undefined ? undefined : characteristic.startNotifications());
872
872
  }
873
873
  onCharacteristicValueChanged(event) {
874
874
  var _a, _b;
875
875
  const characteristic = event.target;
876
- const key = `notification|${(_a = characteristic.service) === null || _a === void 0 ? void 0 : _a.device.id}|${(_b = characteristic.service) === null || _b === void 0 ? void 0 : _b.uuid}|${characteristic.uuid}`;
876
+ const key = `notification|${(_a = characteristic.service) === null || _a === undefined ? undefined : _a.device.id}|${(_b = characteristic.service) === null || _b === undefined ? undefined : _b.uuid}|${characteristic.uuid}`;
877
877
  this.notifyListeners(key, {
878
878
  value: characteristic.value,
879
879
  });
880
880
  }
881
881
  async stopNotifications(options) {
882
882
  const characteristic = await this.getCharacteristic(options);
883
- await (characteristic === null || characteristic === void 0 ? void 0 : characteristic.stopNotifications());
883
+ await (characteristic === null || characteristic === undefined ? undefined : characteristic.stopNotifications());
884
884
  }
885
885
  getFilters(options) {
886
886
  var _a, _b;
887
887
  const filters = [];
888
- for (const service of (_a = options === null || options === void 0 ? void 0 : options.services) !== null && _a !== void 0 ? _a : []) {
888
+ for (const service of (_a = options === null || options === undefined ? undefined : options.services) !== null && _a !== undefined ? _a : []) {
889
889
  filters.push({
890
890
  services: [service],
891
- name: options === null || options === void 0 ? void 0 : options.name,
892
- namePrefix: options === null || options === void 0 ? void 0 : options.namePrefix,
891
+ name: options === null || options === undefined ? undefined : options.name,
892
+ namePrefix: options === null || options === undefined ? undefined : options.namePrefix,
893
893
  });
894
894
  }
895
- if (((options === null || options === void 0 ? void 0 : options.name) || (options === null || options === void 0 ? void 0 : options.namePrefix)) && filters.length === 0) {
895
+ if (((options === null || options === undefined ? undefined : options.name) || (options === null || options === undefined ? undefined : options.namePrefix)) && filters.length === 0) {
896
896
  filters.push({
897
897
  name: options.name,
898
898
  namePrefix: options.namePrefix,
899
899
  });
900
900
  }
901
- for (const manufacturerData of (_b = options === null || options === void 0 ? void 0 : options.manufacturerData) !== null && _b !== void 0 ? _b : []) {
901
+ for (const manufacturerData of (_b = options === null || options === undefined ? undefined : options.manufacturerData) !== null && _b !== undefined ? _b : []) {
902
902
  // Cast to any to avoid type incompatibility - conversion is handled in bleClient.ts
903
903
  filters.push({
904
904
  manufacturerData: [manufacturerData],
@@ -911,7 +911,7 @@ class BluetoothLeWeb extends core.WebPlugin {
911
911
  }
912
912
  matchesServiceDataFilter(event) {
913
913
  var _a;
914
- const filters = (_a = this.requestBleDeviceOptions) === null || _a === void 0 ? void 0 : _a.serviceData;
914
+ const filters = (_a = this.requestBleDeviceOptions) === null || _a === undefined ? undefined : _a.serviceData;
915
915
  if (!filters || filters.length === 0) {
916
916
  return true; // No filters, accept all
917
917
  }
@@ -976,7 +976,7 @@ class BluetoothLeWeb extends core.WebPlugin {
976
976
  const bleDevice = {
977
977
  deviceId: device.id,
978
978
  // use undefined instead of null if name is not available
979
- name: (_a = device.name) !== null && _a !== void 0 ? _a : undefined,
979
+ name: (_a = device.name) !== null && _a !== undefined ? _a : undefined,
980
980
  };
981
981
  return bleDevice;
982
982
  }