@getquip/expo-nordic-dfu 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +23 -2
- package/.github/CODEOWNERS +1 -1
- package/.github/workflows/audit.yml +23 -0
- package/.github/workflows/lint.yml +68 -0
- package/.github/workflows/pull_request.yml +27 -0
- package/.github/workflows/test.yml +37 -0
- package/.prettierignore +5 -0
- package/.prettierrc +7 -0
- package/README.md +0 -2
- package/build/ExpoNordicDfu.types.d.ts.map +1 -1
- package/build/ExpoNordicDfu.types.js.map +1 -1
- package/build/ExpoNordicDfuModule.d.ts.map +1 -1
- package/build/ExpoNordicDfuModule.js +5 -2
- package/build/ExpoNordicDfuModule.js.map +1 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js.map +1 -1
- package/ios/ExpoNordicDfuModule.swift +4 -2
- package/package.json +11 -3
- package/src/ExpoNordicDfu.types.ts +21 -22
- package/src/ExpoNordicDfuModule.ts +19 -19
- package/src/index.ts +2 -2
- package/.github/workflows/actionlint.yml +0 -21
package/.eslintrc.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const isCI = process.env.CI === 'true'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
extends: ['expo', 'prettier'],
|
|
5
|
+
parser: '@typescript-eslint/parser',
|
|
6
|
+
parserOptions: {
|
|
7
|
+
project: './tsconfig.json',
|
|
8
|
+
},
|
|
9
|
+
plugins: ['jest', '@typescript-eslint', 'prettier'],
|
|
10
|
+
rules: {
|
|
11
|
+
'jest/no-focused-tests': isCI ? 'error' : 'off',
|
|
12
|
+
'prettier/prettier': 'error',
|
|
13
|
+
},
|
|
14
|
+
ignorePatterns: ['example/**/*', 'build/**/*', '.eslintrc.js'],
|
|
15
|
+
overrides: [
|
|
16
|
+
{
|
|
17
|
+
files: ['*.ts', '*.tsx', '*.d.ts'],
|
|
18
|
+
parserOptions: {
|
|
19
|
+
project: './tsconfig.json',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
}
|
package/.github/CODEOWNERS
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Audit
|
|
2
|
+
on:
|
|
3
|
+
workflow_call:
|
|
4
|
+
inputs:
|
|
5
|
+
sha:
|
|
6
|
+
required: true
|
|
7
|
+
type: string
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
jobs:
|
|
11
|
+
run:
|
|
12
|
+
name: npm Audit
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
-
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
-
|
|
18
|
+
uses: actions/setup-node@v4
|
|
19
|
+
with:
|
|
20
|
+
node-version: 20
|
|
21
|
+
cache: npm
|
|
22
|
+
-
|
|
23
|
+
run: npm audit --audit-level=high
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: Lint
|
|
2
|
+
on:
|
|
3
|
+
workflow_call:
|
|
4
|
+
inputs:
|
|
5
|
+
sha:
|
|
6
|
+
required: true
|
|
7
|
+
type: string
|
|
8
|
+
diff_ref:
|
|
9
|
+
required: true
|
|
10
|
+
type: string
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
jobs:
|
|
14
|
+
actionlint:
|
|
15
|
+
name: Actionlint
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
steps:
|
|
18
|
+
-
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
-
|
|
21
|
+
name: Download actionlint
|
|
22
|
+
id: get_actionlint
|
|
23
|
+
shell: bash
|
|
24
|
+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
25
|
+
-
|
|
26
|
+
name: Check Workflow Files
|
|
27
|
+
shell: bash
|
|
28
|
+
run: ${{ steps.get_actionlint.outputs.executable }} -color -verbose
|
|
29
|
+
|
|
30
|
+
prettier:
|
|
31
|
+
name: Prettier
|
|
32
|
+
runs-on: ubuntu-latest
|
|
33
|
+
steps:
|
|
34
|
+
-
|
|
35
|
+
uses: actions/checkout@v4
|
|
36
|
+
with:
|
|
37
|
+
ref: ${{ inputs.sha }}
|
|
38
|
+
-
|
|
39
|
+
uses: actions/setup-node@v4
|
|
40
|
+
with:
|
|
41
|
+
node-version: 20
|
|
42
|
+
cache: npm
|
|
43
|
+
-
|
|
44
|
+
run: npm install
|
|
45
|
+
-
|
|
46
|
+
name: Check Prettier
|
|
47
|
+
run: npm run prettier:check
|
|
48
|
+
|
|
49
|
+
eslint:
|
|
50
|
+
name: ESLint
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
env:
|
|
53
|
+
ESLINT_PLUGIN_DIFF_COMMIT: ${{ inputs.diff_ref }}
|
|
54
|
+
steps:
|
|
55
|
+
-
|
|
56
|
+
uses: actions/checkout@v4
|
|
57
|
+
with:
|
|
58
|
+
ref: ${{ inputs.sha }}
|
|
59
|
+
-
|
|
60
|
+
uses: actions/setup-node@v4
|
|
61
|
+
with:
|
|
62
|
+
node-version: 20
|
|
63
|
+
cache: npm
|
|
64
|
+
-
|
|
65
|
+
run: npm install
|
|
66
|
+
-
|
|
67
|
+
name: Check ESLint
|
|
68
|
+
run: npm run eslint:check
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: Pull Request
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
concurrency:
|
|
5
|
+
group: pr-${{ github.ref }}
|
|
6
|
+
cancel-in-progress: true
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
jobs:
|
|
10
|
+
lint:
|
|
11
|
+
name: Lint
|
|
12
|
+
uses: ./.github/workflows/lint.yml
|
|
13
|
+
with:
|
|
14
|
+
sha: ${{ github.sha }}
|
|
15
|
+
diff_ref: ${{ github.event.pull_request.base.ref }}
|
|
16
|
+
|
|
17
|
+
test:
|
|
18
|
+
name: Test
|
|
19
|
+
uses: ./.github/workflows/test.yml
|
|
20
|
+
with:
|
|
21
|
+
sha: ${{ github.sha }}
|
|
22
|
+
|
|
23
|
+
audit:
|
|
24
|
+
name: Audit
|
|
25
|
+
uses: ./.github/workflows/audit.yml
|
|
26
|
+
with:
|
|
27
|
+
sha: ${{ github.sha }}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
workflow_call:
|
|
4
|
+
inputs:
|
|
5
|
+
sha:
|
|
6
|
+
required: true
|
|
7
|
+
type: string
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
jobs:
|
|
11
|
+
typescript:
|
|
12
|
+
name: Typescript Compile
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
-
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
with:
|
|
18
|
+
ref: ${{ inputs.sha }}
|
|
19
|
+
-
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: 20
|
|
23
|
+
cache: npm
|
|
24
|
+
-
|
|
25
|
+
run: npm install
|
|
26
|
+
-
|
|
27
|
+
name: Type Check (Compile) TypeScript
|
|
28
|
+
run: |
|
|
29
|
+
set -e
|
|
30
|
+
npx tsc
|
|
31
|
+
git diff
|
|
32
|
+
if ! git diff --quiet; then
|
|
33
|
+
echo "❌ Emitted files found, please compile your TypeScript code before submitting a PR"
|
|
34
|
+
exit 1
|
|
35
|
+
else
|
|
36
|
+
echo "✅No files emitted"
|
|
37
|
+
fi
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Expo Nordic DFU
|
|
2
2
|
|
|
3
|
-
*Note*: First release is not out yet!
|
|
4
|
-
|
|
5
3
|
This project was highly inspired by the original React Native project at [Pilloxa/react-native-nordic-dfu](https://github.com/Pilloxa/react-native-nordic-dfu). We continued the work so it functions with modern [Expo](http://expo.dev/) projects that use [Expo Modules](https://docs.expo.dev/modules/overview/).
|
|
6
4
|
|
|
7
5
|
This module allows you to perform a Secure Device Firmware Update (DFU) for Nordic Semiconductors on Expo React Native bridgeless projects. It wraps the official libraries at [NordicSemiconductor/Android-DFU-Library](https://github.com/NordicSemiconductor/Android-DFU-Library) and [NordicSemiconductor/IOS-DFU-Library](https://github.com/NordicSemiconductor/IOS-DFU-Library). This will not support Legacy DFU out of the box!
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoNordicDfu.types.d.ts","sourceRoot":"","sources":["../src/ExpoNordicDfu.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"ExpoNordicDfu.types.d.ts","sourceRoot":"","sources":["../src/ExpoNordicDfu.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,wBAAwB,GAAG;IACrC,eAAe,EAAE,CAAC,MAAM,EAAE,sBAAsB,KAAK,IAAI,CAAA;IACzD,WAAW,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;CAClD,CAAA;AAED,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,OAAO,EAAE,MAAM,CAAA;IACf,kCAAkC,CAAC,EAAE,MAAM,CAAA;IAC3C,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,EAAE,OAAO,CAAA;QAClB,eAAe,CAAC,EAAE,MAAM,CAAA;KAIzB,CAAA;IACD,GAAG,CAAC,EAAE;QACJ,iBAAiB,CAAC,EAAE,MAAM,CAAA;QAC1B,aAAa,CAAC,EAAE,OAAO,CAAA;KACxB,CAAA;CACF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoNordicDfu.types.js","sourceRoot":"","sources":["../src/ExpoNordicDfu.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ExpoSettingsModuleEvents = {\n DFUStateChanged: (params: DFUStateChangedPayload) => void
|
|
1
|
+
{"version":3,"file":"ExpoNordicDfu.types.js","sourceRoot":"","sources":["../src/ExpoNordicDfu.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ExpoSettingsModuleEvents = {\n DFUStateChanged: (params: DFUStateChangedPayload) => void\n DFUProgress: (params: DFUProgressPayload) => void\n}\n\nexport type DFUStateChangedPayload = {\n state: string\n deviceAddress: string\n}\n\nexport type DFUProgressPayload = {\n deviceAddress: string\n percent: number\n speed: number\n avgSpeed: number\n currentPart: number\n totalParts: number\n}\n\nexport type StartDFUParams = {\n deviceAddress: string\n fileUri: string\n packetReceiptNotificationParameter?: number\n prepareDataObjectDelay?: number\n android?: {\n deviceName?: string\n keepBond?: boolean\n numberOfRetries?: number\n // See android/src/main/java/com/getquip/nordic/ExpoNordicDfuModule.kt\n // rebootTime?: number;\n // restoreBond?: boolean;\n }\n ios?: {\n connectionTimeout?: number\n disableResume?: boolean\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoNordicDfuModule.d.ts","sourceRoot":"","sources":["../src/ExpoNordicDfuModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoNordicDfuModule.d.ts","sourceRoot":"","sources":["../src/ExpoNordicDfuModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAGhF,OAAO,OAAO,mBAAoB,SAAQ,YAAY,CAAC,wBAAwB,CAAC;IAC9E,eAAe,CACb,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,OAAO,EAClB,eAAe,CAAC,EAAE,MAAM,EACxB,kCAAkC,CAAC,EAAE,MAAM,EAC3C,sBAAsB,CAAC,EAAE,MAAM,EAC/B,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,IAAI,CAAC;IAChB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAChC,WAAW,CACT,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,iBAAiB,CAAC,EAAE,MAAM,EAC1B,aAAa,CAAC,EAAE,OAAO,EACvB,kCAAkC,CAAC,EAAE,MAAM,EAC3C,sBAAsB,CAAC,EAAE,MAAM,GAC9B,OAAO,CAAC,IAAI,CAAC;IAChB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;CAC7B;AAID,cAAM,oBAAoB;IACZ,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,mBAAmB;IAElD,IAAI,MAAM,wBAET;IAEK,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA0B/C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAOhC;;AAED,wBAAkD"}
|
|
@@ -14,7 +14,11 @@ class CrossplatformWrapper {
|
|
|
14
14
|
return await this.dfuModule.startIosDfu(params.deviceAddress, params.fileUri, params.ios?.connectionTimeout, params.ios?.disableResume, params.packetReceiptNotificationParameter, params.prepareDataObjectDelay);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
return await this.dfuModule.startAndroidDfu(params.deviceAddress, params.fileUri, params.android?.deviceName, params.android?.keepBond, params.android?.numberOfRetries, params.packetReceiptNotificationParameter, params.prepareDataObjectDelay
|
|
17
|
+
return await this.dfuModule.startAndroidDfu(params.deviceAddress, params.fileUri, params.android?.deviceName, params.android?.keepBond, params.android?.numberOfRetries, params.packetReceiptNotificationParameter, params.prepareDataObjectDelay
|
|
18
|
+
// See android/src/main/java/com/getquip/nordic/ExpoNordicDfuModule.kt
|
|
19
|
+
// params.android?.rebootTime,
|
|
20
|
+
// params.android?.restoreBond,
|
|
21
|
+
);
|
|
18
22
|
}
|
|
19
23
|
}
|
|
20
24
|
async abortDfu() {
|
|
@@ -26,6 +30,5 @@ class CrossplatformWrapper {
|
|
|
26
30
|
}
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
|
-
;
|
|
30
33
|
export default new CrossplatformWrapper(DfuModule);
|
|
31
34
|
//# sourceMappingURL=ExpoNordicDfuModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoNordicDfuModule.js","sourceRoot":"","sources":["../src/ExpoNordicDfuModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ExpoNordicDfuModule.js","sourceRoot":"","sources":["../src/ExpoNordicDfuModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AA0BvC,MAAM,SAAS,GAAG,mBAAmB,CAAsB,qBAAqB,CAAC,CAAA;AAEjF,MAAM,oBAAoB;IACJ;IAApB,YAAoB,SAA8B;QAA9B,cAAS,GAAT,SAAS,CAAqB;IAAG,CAAC;IAEtD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,MAAsB;QACnC,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,CACrC,MAAM,CAAC,aAAa,EACpB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,GAAG,EAAE,iBAAiB,EAC7B,MAAM,CAAC,GAAG,EAAE,aAAa,EACzB,MAAM,CAAC,kCAAkC,EACzC,MAAM,CAAC,sBAAsB,CAC9B,CAAA;QACH,CAAC;aAAM,CAAC;YACN,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,CACzC,MAAM,CAAC,aAAa,EACpB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,OAAO,EAAE,UAAU,EAC1B,MAAM,CAAC,OAAO,EAAE,QAAQ,EACxB,MAAM,CAAC,OAAO,EAAE,eAAe,EAC/B,MAAM,CAAC,kCAAkC,EACzC,MAAM,CAAC,sBAAsB;YAC7B,sEAAsE;YACtE,8BAA8B;YAC9B,+BAA+B;aAChC,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,QAAQ;QACZ,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE,CAAC;YAC1B,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAA;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,eAAe,EAAE,CAAA;QAC/C,CAAC;IACH,CAAC;CACF;AAED,eAAe,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAA","sourcesContent":["import { NativeModule, requireNativeModule } from 'expo'\nimport { ExpoSettingsModuleEvents, StartDFUParams } from './ExpoNordicDfu.types'\nimport { Platform } from 'react-native'\n\ndeclare class ExpoNordicDfuModule extends NativeModule<ExpoSettingsModuleEvents> {\n startAndroidDfu(\n deviceAddress: string,\n fileUri: string,\n deviceName?: string,\n keepBond?: boolean,\n numberOfRetries?: number,\n packetReceiptNotificationParameter?: number,\n prepareDataObjectDelay?: number,\n rebootTime?: number,\n restoreBond?: boolean\n ): Promise<void>\n abortAndroidDfu(): Promise<void>\n startIosDfu(\n deviceAddress: string,\n fileUri: string,\n connectionTimeout?: number,\n disableResume?: boolean,\n packetReceiptNotificationParameter?: number,\n prepareDataObjectDelay?: number\n ): Promise<void>\n abortIosDfu(): Promise<void>\n}\n\nconst DfuModule = requireNativeModule<ExpoNordicDfuModule>('ExpoNordicDfuModule')\n\nclass CrossplatformWrapper {\n constructor(private dfuModule: ExpoNordicDfuModule) {}\n\n get module() {\n return this.dfuModule\n }\n\n async startDfu(params: StartDFUParams): Promise<void> {\n if (Platform.OS === 'ios') {\n return await this.dfuModule.startIosDfu(\n params.deviceAddress,\n params.fileUri,\n params.ios?.connectionTimeout,\n params.ios?.disableResume,\n params.packetReceiptNotificationParameter,\n params.prepareDataObjectDelay\n )\n } else {\n return await this.dfuModule.startAndroidDfu(\n params.deviceAddress,\n params.fileUri,\n params.android?.deviceName,\n params.android?.keepBond,\n params.android?.numberOfRetries,\n params.packetReceiptNotificationParameter,\n params.prepareDataObjectDelay\n // See android/src/main/java/com/getquip/nordic/ExpoNordicDfuModule.kt\n // params.android?.rebootTime,\n // params.android?.restoreBond,\n )\n }\n }\n\n async abortDfu(): Promise<void> {\n if (Platform.OS === 'ios') {\n return await this.dfuModule.abortIosDfu()\n } else {\n return await this.dfuModule.abortAndroidDfu()\n }\n }\n}\n\nexport default new CrossplatformWrapper(DfuModule)\n"]}
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAE/C,cAAc,uBAAuB,CAAA"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,oDAAoD;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAC/C,sEAAsE;AACtE,cAAc,uBAAuB,CAAA","sourcesContent":["// Reexport the native module. On web, it will be resolved to ExpoNordicDfuModule.web.ts\n// and on native platforms to ExpoNordicDfuModule.ts\nexport { default } from './ExpoNordicDfuModule'\n// export { default as ExpoNordicDfuView } from './ExpoNordicDfuView';\nexport * from './ExpoNordicDfu.types'\n"]}
|
|
@@ -49,8 +49,10 @@ public class ExpoNordicDfuModule: Module, DFUProgressDelegate, DFUServiceDelegat
|
|
|
49
49
|
|
|
50
50
|
Self.logger.info("Starting DFU on device \(uuid)")
|
|
51
51
|
|
|
52
|
-
let
|
|
53
|
-
|
|
52
|
+
let filePath = fileUri.replacingOccurrences(of: "file://", with: "")
|
|
53
|
+
// If the file path contains percent encoding, URL will fail to parse it correctly.
|
|
54
|
+
let decodedPath = filePath.removingPercentEncoding ?? filePath
|
|
55
|
+
let url = URL(fileURLWithPath: decodedPath)
|
|
54
56
|
let firmware = try DFUFirmware(urlToZipFile: url)
|
|
55
57
|
let initiator = DFUServiceInitiator().with(firmware: firmware)
|
|
56
58
|
initiator.logger = self
|
package/package.json
CHANGED
|
@@ -6,9 +6,14 @@
|
|
|
6
6
|
"description": "Nordic DFU for Expo",
|
|
7
7
|
"devDependencies": {
|
|
8
8
|
"@types/react": "~18.3.12",
|
|
9
|
+
"eslint-config-expo": "~8.0.1",
|
|
10
|
+
"eslint-config-prettier": "^10.0.1",
|
|
11
|
+
"eslint-plugin-jest": "^28.11.0",
|
|
12
|
+
"eslint-plugin-prettier": "^5.2.3",
|
|
9
13
|
"expo": "~52.0.46",
|
|
14
|
+
"expo-doctor": "^1.12.5",
|
|
10
15
|
"expo-module-scripts": "^4.0.5",
|
|
11
|
-
"prettier": "^
|
|
16
|
+
"prettier": "^3.4.2",
|
|
12
17
|
"react-native": "^0.76.9"
|
|
13
18
|
},
|
|
14
19
|
"expo-module": {
|
|
@@ -51,14 +56,17 @@
|
|
|
51
56
|
"build": "expo-module build",
|
|
52
57
|
"clean": "expo-module clean",
|
|
53
58
|
"expo-module": "expo-module",
|
|
54
|
-
"
|
|
59
|
+
"eslint:check": "eslint . --max-warnings 0",
|
|
60
|
+
"eslint:fix": "eslint . --fix",
|
|
55
61
|
"open:android": "open -a \"Android Studio\" example/android",
|
|
56
62
|
"open:ios": "xed example/ios",
|
|
63
|
+
"prettier:check": "prettier --config .prettierrc --check '**/*.{ts,tsx,js,jsx}'",
|
|
64
|
+
"prettier:fix": "prettier --config .prettierrc --write '**/*.{ts,tsx,js,jsx}'",
|
|
57
65
|
"prepare": "expo-module prepare",
|
|
58
66
|
"prepublishOnly": "expo-module prepublishOnly",
|
|
59
67
|
"test": "expo-module test"
|
|
60
68
|
},
|
|
61
69
|
"types": "build/index.d.ts",
|
|
62
70
|
"url": "https://github.com/getquip/expo-nordic-dfu",
|
|
63
|
-
"version": "
|
|
71
|
+
"version": "1.0.0"
|
|
64
72
|
}
|
|
@@ -1,38 +1,37 @@
|
|
|
1
1
|
export type ExpoSettingsModuleEvents = {
|
|
2
|
-
DFUStateChanged: (params: DFUStateChangedPayload) => void
|
|
3
|
-
DFUProgress: (params: DFUProgressPayload) => void
|
|
4
|
-
}
|
|
2
|
+
DFUStateChanged: (params: DFUStateChangedPayload) => void
|
|
3
|
+
DFUProgress: (params: DFUProgressPayload) => void
|
|
4
|
+
}
|
|
5
5
|
|
|
6
6
|
export type DFUStateChangedPayload = {
|
|
7
|
-
state: string
|
|
8
|
-
deviceAddress: string
|
|
9
|
-
}
|
|
7
|
+
state: string
|
|
8
|
+
deviceAddress: string
|
|
9
|
+
}
|
|
10
10
|
|
|
11
11
|
export type DFUProgressPayload = {
|
|
12
|
-
deviceAddress: string
|
|
13
|
-
percent: number
|
|
14
|
-
speed: number
|
|
15
|
-
avgSpeed: number
|
|
16
|
-
currentPart: number
|
|
17
|
-
totalParts: number
|
|
12
|
+
deviceAddress: string
|
|
13
|
+
percent: number
|
|
14
|
+
speed: number
|
|
15
|
+
avgSpeed: number
|
|
16
|
+
currentPart: number
|
|
17
|
+
totalParts: number
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export type StartDFUParams = {
|
|
21
|
-
deviceAddress: string
|
|
22
|
-
fileUri: string
|
|
23
|
-
packetReceiptNotificationParameter?: number
|
|
24
|
-
prepareDataObjectDelay?: number
|
|
21
|
+
deviceAddress: string
|
|
22
|
+
fileUri: string
|
|
23
|
+
packetReceiptNotificationParameter?: number
|
|
24
|
+
prepareDataObjectDelay?: number
|
|
25
25
|
android?: {
|
|
26
|
-
deviceName?: string
|
|
27
|
-
keepBond?: boolean
|
|
28
|
-
numberOfRetries?: number
|
|
26
|
+
deviceName?: string
|
|
27
|
+
keepBond?: boolean
|
|
28
|
+
numberOfRetries?: number
|
|
29
29
|
// See android/src/main/java/com/getquip/nordic/ExpoNordicDfuModule.kt
|
|
30
30
|
// rebootTime?: number;
|
|
31
31
|
// restoreBond?: boolean;
|
|
32
32
|
}
|
|
33
33
|
ios?: {
|
|
34
|
-
connectionTimeout?: number
|
|
35
|
-
disableResume?: boolean
|
|
34
|
+
connectionTimeout?: number
|
|
35
|
+
disableResume?: boolean
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { NativeModule, requireNativeModule } from 'expo'
|
|
2
|
-
import { ExpoSettingsModuleEvents, StartDFUParams } from './ExpoNordicDfu.types'
|
|
3
|
-
import { Platform } from 'react-native'
|
|
1
|
+
import { NativeModule, requireNativeModule } from 'expo'
|
|
2
|
+
import { ExpoSettingsModuleEvents, StartDFUParams } from './ExpoNordicDfu.types'
|
|
3
|
+
import { Platform } from 'react-native'
|
|
4
4
|
|
|
5
5
|
declare class ExpoNordicDfuModule extends NativeModule<ExpoSettingsModuleEvents> {
|
|
6
6
|
startAndroidDfu(
|
|
@@ -12,27 +12,27 @@ declare class ExpoNordicDfuModule extends NativeModule<ExpoSettingsModuleEvents>
|
|
|
12
12
|
packetReceiptNotificationParameter?: number,
|
|
13
13
|
prepareDataObjectDelay?: number,
|
|
14
14
|
rebootTime?: number,
|
|
15
|
-
restoreBond?: boolean
|
|
16
|
-
): Promise<void
|
|
17
|
-
abortAndroidDfu(): Promise<void
|
|
15
|
+
restoreBond?: boolean
|
|
16
|
+
): Promise<void>
|
|
17
|
+
abortAndroidDfu(): Promise<void>
|
|
18
18
|
startIosDfu(
|
|
19
19
|
deviceAddress: string,
|
|
20
20
|
fileUri: string,
|
|
21
21
|
connectionTimeout?: number,
|
|
22
22
|
disableResume?: boolean,
|
|
23
23
|
packetReceiptNotificationParameter?: number,
|
|
24
|
-
prepareDataObjectDelay?: number
|
|
25
|
-
): Promise<void
|
|
26
|
-
abortIosDfu(): Promise<void
|
|
24
|
+
prepareDataObjectDelay?: number
|
|
25
|
+
): Promise<void>
|
|
26
|
+
abortIosDfu(): Promise<void>
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
const DfuModule = requireNativeModule<ExpoNordicDfuModule>('ExpoNordicDfuModule')
|
|
29
|
+
const DfuModule = requireNativeModule<ExpoNordicDfuModule>('ExpoNordicDfuModule')
|
|
30
30
|
|
|
31
31
|
class CrossplatformWrapper {
|
|
32
32
|
constructor(private dfuModule: ExpoNordicDfuModule) {}
|
|
33
33
|
|
|
34
34
|
get module() {
|
|
35
|
-
return this.dfuModule
|
|
35
|
+
return this.dfuModule
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async startDfu(params: StartDFUParams): Promise<void> {
|
|
@@ -43,8 +43,8 @@ class CrossplatformWrapper {
|
|
|
43
43
|
params.ios?.connectionTimeout,
|
|
44
44
|
params.ios?.disableResume,
|
|
45
45
|
params.packetReceiptNotificationParameter,
|
|
46
|
-
params.prepareDataObjectDelay
|
|
47
|
-
)
|
|
46
|
+
params.prepareDataObjectDelay
|
|
47
|
+
)
|
|
48
48
|
} else {
|
|
49
49
|
return await this.dfuModule.startAndroidDfu(
|
|
50
50
|
params.deviceAddress,
|
|
@@ -53,21 +53,21 @@ class CrossplatformWrapper {
|
|
|
53
53
|
params.android?.keepBond,
|
|
54
54
|
params.android?.numberOfRetries,
|
|
55
55
|
params.packetReceiptNotificationParameter,
|
|
56
|
-
params.prepareDataObjectDelay
|
|
56
|
+
params.prepareDataObjectDelay
|
|
57
57
|
// See android/src/main/java/com/getquip/nordic/ExpoNordicDfuModule.kt
|
|
58
58
|
// params.android?.rebootTime,
|
|
59
59
|
// params.android?.restoreBond,
|
|
60
|
-
)
|
|
60
|
+
)
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
async abortDfu(): Promise<void> {
|
|
65
65
|
if (Platform.OS === 'ios') {
|
|
66
|
-
return await this.dfuModule.abortIosDfu()
|
|
66
|
+
return await this.dfuModule.abortIosDfu()
|
|
67
67
|
} else {
|
|
68
|
-
return await this.dfuModule.abortAndroidDfu()
|
|
68
|
+
return await this.dfuModule.abortAndroidDfu()
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
}
|
|
71
|
+
}
|
|
72
72
|
|
|
73
|
-
export default new CrossplatformWrapper(DfuModule)
|
|
73
|
+
export default new CrossplatformWrapper(DfuModule)
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Reexport the native module. On web, it will be resolved to ExpoNordicDfuModule.web.ts
|
|
2
2
|
// and on native platforms to ExpoNordicDfuModule.ts
|
|
3
|
-
export { default } from './ExpoNordicDfuModule'
|
|
3
|
+
export { default } from './ExpoNordicDfuModule'
|
|
4
4
|
// export { default as ExpoNordicDfuView } from './ExpoNordicDfuView';
|
|
5
|
-
export * from
|
|
5
|
+
export * from './ExpoNordicDfu.types'
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
name: Actionlint
|
|
2
|
-
on:
|
|
3
|
-
pull_request:
|
|
4
|
-
concurrency:
|
|
5
|
-
group: actionlint-${{ github.ref }}
|
|
6
|
-
cancel-in-progress: true
|
|
7
|
-
jobs:
|
|
8
|
-
run:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
-
|
|
12
|
-
uses: actions/checkout@v4
|
|
13
|
-
-
|
|
14
|
-
name: Download actionlint
|
|
15
|
-
id: get_actionlint
|
|
16
|
-
shell: bash
|
|
17
|
-
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
18
|
-
-
|
|
19
|
-
name: Check Workflow Files
|
|
20
|
-
shell: bash
|
|
21
|
-
run: ${{ steps.get_actionlint.outputs.executable }} -color -verbose
|