{"version":3,"sources":["jsdelivr-header.js","/npm/@domir/react-native-nordic-dfu@3.5.0/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OCNS,cAAe,mBAAoB,aAAgB,eAC5D,MAAM,YAAE,aAAgB,cAClB,UAAY,CAAE,kBAAU,mBAE9B,SAAS,cAAc,GACrB,OAAO,IAAI,SAAQ,CAAC,EAAS,KAC3B,EAAO,IAAI,MAAM,uBAAyB,GAAS,GAEvD,CAiCA,SAAS,UAAS,cAChB,EAAa,WACb,EAAa,KAAI,SACjB,EAAQ,kCACR,GAAoC,EAAI,mCACxC,EAAqC,EAAC,QACtC,EAAU,KAAI,OACd,EAAS,KAAI,mCACb,EAAqC,OAErC,GAAqB,MAAjB,EACF,OAAO,cAAc,4BAEvB,GAAgB,MAAZ,EACF,OAAO,cAAc,uBAEvB,MAAM,EAAqB,EAAc,cACzC,GAAoB,QAAhB,SAAS,GACX,OAAO,YAAY,SACjB,EACA,EACA,EACA,EACA,GAEG,GAAoB,YAAhB,SAAS,GAClB,OAAO,YAAY,SACjB,EACA,EACA,EACA,EACA,CACE,UACA,SACA,uCAIJ,MAAM,IAAI,MAAM,8CAEpB,CAOA,SAAS,WACP,OAAO,YAAY,UACrB,CAkBA,MAAM,WAAa,IAAI,mBAAmB,oBAEjC,UAAW","file":"/npm/@domir/react-native-nordic-dfu@3.5.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@domir/react-native-nordic-dfu@3.5.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import { NativeModules, NativeEventEmitter, Platform } from \"react-native\";\nconst { RNNordicDfu } = NativeModules;\nconst NordicDFU = { startDFU, abortDFU };\n\nfunction rejectPromise(message) {\n  return new Promise((resolve, reject) => {\n    reject(new Error(\"NordicDFU.startDFU: \" + message));\n  });\n}\n\n/**\n *\n * Starts the DFU process\n *\n * Observe: The peripheral must have been discovered by the native BLE side so that the\n * bluetooth stack knows about it. This library will not do a scan but only\n * the actual connect and then the transfer. See the example project to see how it can be\n * done in React Native.\n *\n * For `alternativeAdvertisingNameEnabled` option below, see:\n * https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library/blob/master/iOSDFULibrary/Classes/Implementation/DFUServiceInitiator.swift#L191\n *\n * @param {Object} obj\n * @param {string} obj.deviceAddress The MAC address for the device that should be updated\n * @param {string} [obj.deviceName = null] The name of the device in the update notification\n * @param {string} obj.filePath The file system path to the zip-file used for updating\n * @param {Boolean} obj.alternativeAdvertisingNameEnabled Send unique name to device before it is switched into bootloader mode (iOS only)\n * @param {number} obj.packetReceiptNotificationParameter set number of packets of firmware data to be received by the DFU target before sending a new Packet Receipt Notification\n * @returns {Promise} A promise that resolves or rejects with the `deviceAddress` in the return value\n *\n * @example\n * import { NordicDFU, DFUEmitter } from \"react-native-nordic-dfu\";\n *\n * NordicDFU.startDFU({\n *   deviceAddress: \"C3:53:C0:39:2F:99\",\n *   deviceName: \"Pilloxa Pillbox\",\n *   filePath: \"/data/user/0/com.nordicdfuexample/files/RNFetchBlobTmp4of.zip\"\n * })\n *   .then(res => console.log(\"Transfer done:\", res))\n *   .catch(console.log);\n */\nfunction startDFU({\n  deviceAddress,\n  deviceName = null,\n  filePath,\n  alternativeAdvertisingNameEnabled = true, //iOS only\n  packetReceiptNotificationParameter = 0,\n  retries = null, // Android only\n  maxMtu = null, // Android only\n  packetsReceiptNotificationsEnabled = null, // Android only\n}) {\n  if (deviceAddress == undefined) {\n    return rejectPromise(\"No deviceAddress defined\");\n  }\n  if (filePath == undefined) {\n    return rejectPromise(\"No filePath defined\");\n  }\n  const upperDeviceAddress = deviceAddress.toUpperCase();\n  if (Platform.OS === \"ios\") {\n    return RNNordicDfu.startDFU(\n      upperDeviceAddress,\n      deviceName,\n      filePath,\n      packetReceiptNotificationParameter,\n      alternativeAdvertisingNameEnabled\n    );\n  } else if (Platform.OS === \"android\") {\n    return RNNordicDfu.startDFU(\n      upperDeviceAddress,\n      deviceName,\n      filePath,\n      packetReceiptNotificationParameter,\n      {\n        retries,\n        maxMtu,\n        packetsReceiptNotificationsEnabled\n      }\n    );\n  } else {\n    throw new Error(\"Platform not supported (not android or ios)\");\n  }\n}\n\n/**\n * Abort the DFU process\n *\n * @returns {Promise} A promise that resolves with a boolean that indicates if the controller was aborted\n */\nfunction abortDFU() {\n  return RNNordicDfu.abortDFU();\n}\n\n/**\n * Event emitter for DFU state and progress events\n *\n * @const DFUEmitter\n *\n * @example\n * import { NordicDFU, DFUEmitter } from \"react-native-nordic-dfu\";\n *\n * DFUEmitter.addlistener(\"DFUProgress\",({percent, currentPart, partsTotal, avgSpeed, speed}) => {\n *   console.log(\"DFU progress: \" + percent +\"%\");\n * });\n *\n * DFUEmitter.addListener(\"DFUStateChanged\", ({state}) => {\n *   console.log(\"DFU State:\", state);\n * })\n */\nconst DFUEmitter = new NativeEventEmitter(RNNordicDfu);\n\nexport { NordicDFU, DFUEmitter };\n"]}