@nordicsemiconductor/pc-nrfconnect-shared 60.0.0-pre1
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/.github/ISSUE_TEMPLATE/custom.md +10 -0
- package/.husky/pre-push +3 -0
- package/.renovaterc.json +10 -0
- package/Changelog.md +2973 -0
- package/LICENSE +35 -0
- package/README.md +11 -0
- package/azure-pipelines.yml +34 -0
- package/config/eslintrc.js +190 -0
- package/config/jest.config.js +41 -0
- package/config/prettier.config.js +13 -0
- package/config/tsconfig.json +15 -0
- package/fw/bootloader/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip +0 -0
- package/jest.config.js +7 -0
- package/main/index.ts +32 -0
- package/mocks/deviceLibMock.ts +21 -0
- package/mocks/electronMock.ts +15 -0
- package/mocks/electronStoreMock.ts +19 -0
- package/mocks/emptyMock.ts +7 -0
- package/mocks/fileMock.ts +13 -0
- package/mocks/gaMock.ts +9 -0
- package/mocks/mockTests.test.ts +15 -0
- package/mocks/packageJsonMock.ts +10 -0
- package/mocks/remoteMock.ts +17 -0
- package/package.json +132 -0
- package/scripts/check-app-properties.ts +197 -0
- package/scripts/check-for-typescript.ts +41 -0
- package/scripts/esbuild-bootstrap.js +15 -0
- package/scripts/esbuild-renderer.js +131 -0
- package/scripts/esbuild.js +57 -0
- package/scripts/installHusky.ts +17 -0
- package/scripts/nordic-publish.ts +485 -0
- package/scripts/nrfconnect-license.ts +277 -0
- package/scripts/prepare-shared-release.ts +122 -0
- package/scripts/release-shared.test.ts +132 -0
- package/scripts/release-shared.ts +207 -0
- package/src/About/About.tsx +25 -0
- package/src/About/AboutButton.tsx +28 -0
- package/src/About/ApplicationCard.tsx +83 -0
- package/src/About/DeviceCard.tsx +74 -0
- package/src/About/DocumentationCard.tsx +18 -0
- package/src/About/DocumentationSection.tsx +24 -0
- package/src/About/Section.tsx +21 -0
- package/src/About/ShortcutButton.tsx +41 -0
- package/src/About/SupportCard.tsx +97 -0
- package/src/About/about.scss +40 -0
- package/src/About/documentationSlice.ts +41 -0
- package/src/About/section.scss +15 -0
- package/src/About/shortcutSlice.ts +52 -0
- package/src/Alert/Alert.module.scss +29 -0
- package/src/Alert/Alert.tsx +37 -0
- package/src/App/App.test.tsx +47 -0
- package/src/App/App.tsx +227 -0
- package/src/App/ConnectedToStore.tsx +19 -0
- package/src/App/VisibilityBar.tsx +103 -0
- package/src/App/app.scss +83 -0
- package/src/App/appLayout.ts +95 -0
- package/src/App/shared.scss +49 -0
- package/src/App/visibility-bar.scss +55 -0
- package/src/Button/Button.tsx +66 -0
- package/src/Button/button.module.scss +154 -0
- package/src/Card/Card.tsx +26 -0
- package/src/Card/card.module.scss +28 -0
- package/src/Device/BrokenDeviceDialog/BrokenDeviceDialog.tsx +58 -0
- package/src/Device/BrokenDeviceDialog/broken-device-dialog.scss +18 -0
- package/src/Device/BrokenDeviceDialog/brokenDeviceDialogSlice.tsx +48 -0
- package/src/Device/DeviceSelector/BasicDeviceInfo.tsx +115 -0
- package/src/Device/DeviceSelector/DeviceIcon.tsx +27 -0
- package/src/Device/DeviceSelector/DeviceList/AnimatedList.tsx +62 -0
- package/src/Device/DeviceSelector/DeviceList/BrokenDevice.tsx +34 -0
- package/src/Device/DeviceSelector/DeviceList/Device.tsx +84 -0
- package/src/Device/DeviceSelector/DeviceList/DeviceList.tsx +113 -0
- package/src/Device/DeviceSelector/DeviceList/EditDeviceButtons.tsx +28 -0
- package/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.tsx +65 -0
- package/src/Device/DeviceSelector/DeviceList/RenameDevice.tsx +22 -0
- package/src/Device/DeviceSelector/DeviceList/broken-device.scss +32 -0
- package/src/Device/DeviceSelector/DeviceList/device-list.scss +64 -0
- package/src/Device/DeviceSelector/DeviceList/device.scss +28 -0
- package/src/Device/DeviceSelector/DeviceList/edit-device-buttons.scss +31 -0
- package/src/Device/DeviceSelector/DeviceList/more-device-info.scss +33 -0
- package/src/Device/DeviceSelector/DeviceList/rename-device.scss +13 -0
- package/src/Device/DeviceSelector/DeviceSelector.test.tsx +342 -0
- package/src/Device/DeviceSelector/DeviceSelector.tsx +173 -0
- package/src/Device/DeviceSelector/Favorite.tsx +49 -0
- package/src/Device/DeviceSelector/SelectDevice.tsx +36 -0
- package/src/Device/DeviceSelector/SelectedDevice.tsx +65 -0
- package/src/Device/DeviceSelector/arrow-down.svg +1 -0
- package/src/Device/DeviceSelector/basic-device-info.scss +62 -0
- package/src/Device/DeviceSelector/device-icon.scss +27 -0
- package/src/Device/DeviceSelector/favorite.scss +17 -0
- package/src/Device/DeviceSelector/select-device.scss +38 -0
- package/src/Device/DeviceSelector/selected-device.scss +57 -0
- package/src/Device/DeviceSetup/DeviceSetupView.tsx +102 -0
- package/src/Device/deviceAutoSelectSlice.ts +144 -0
- package/src/Device/deviceInfo/deviceInfo.ts +254 -0
- package/src/Device/deviceInfo/nRF51-Series-logo.svg +1 -0
- package/src/Device/deviceInfo/nRF52-Series-logo.svg +1 -0
- package/src/Device/deviceInfo/nRF53-Series-logo.svg +1 -0
- package/src/Device/deviceInfo/nRF70-Series_no-background_RGB.svg +36 -0
- package/src/Device/deviceInfo/nRF91-Series-logo.svg +1 -0
- package/src/Device/deviceInfo/ppk-logo.svg +1 -0
- package/src/Device/deviceInfo/unknown-logo.svg +30 -0
- package/src/Device/deviceInfo/unknown-nordic-logo.svg +25 -0
- package/src/Device/deviceLibWrapper.test.ts +97 -0
- package/src/Device/deviceLibWrapper.ts +133 -0
- package/src/Device/deviceLister.test.ts +89 -0
- package/src/Device/deviceLister.ts +396 -0
- package/src/Device/deviceSetup.ts +264 -0
- package/src/Device/deviceSetupSlice.ts +94 -0
- package/src/Device/deviceSlice.ts +248 -0
- package/src/Device/dfu-cc.ts +162 -0
- package/src/Device/initPacket.ts +402 -0
- package/src/Device/jprogOperations.ts +206 -0
- package/src/Device/sdfuOperations.ts +601 -0
- package/src/Dialog/Dialog.test.tsx +134 -0
- package/src/Dialog/Dialog.tsx +236 -0
- package/src/Dialog/dialog.scss +60 -0
- package/src/Dropdown/Dropdown.module.scss +83 -0
- package/src/Dropdown/Dropdown.test.tsx +62 -0
- package/src/Dropdown/Dropdown.tsx +106 -0
- package/src/ErrorBoundary/ErrorBoundary.test.tsx +105 -0
- package/src/ErrorBoundary/ErrorBoundary.tsx +186 -0
- package/src/ErrorBoundary/bug.svg +1 -0
- package/src/ErrorBoundary/error-boundary.scss +102 -0
- package/src/ErrorDialog/ErrorDialog.test.tsx +70 -0
- package/src/ErrorDialog/ErrorDialog.tsx +94 -0
- package/src/ErrorDialog/error.scss +14 -0
- package/src/ErrorDialog/errorDialogSlice.test.ts +64 -0
- package/src/ErrorDialog/errorDialogSlice.ts +80 -0
- package/src/FactoryReset/FactoryResetButton.test.tsx +46 -0
- package/src/FactoryReset/FactoryResetButton.tsx +81 -0
- package/src/InlineInput/InlineInput.tsx +170 -0
- package/src/InlineInput/NumberInlineInput.tsx +107 -0
- package/src/InlineInput/inline-input.scss +38 -0
- package/src/InlineInput/number-inline-input.scss +15 -0
- package/src/Log/LogEntry.tsx +62 -0
- package/src/Log/LogViewer.tsx +54 -0
- package/src/Log/log-entry.scss +30 -0
- package/src/Log/log-viewer.scss +24 -0
- package/src/Log/logSlice.ts +73 -0
- package/src/Log/syncLogToStore.ts +36 -0
- package/src/Logo/Logo.tsx +48 -0
- package/src/Logo/logo.scss +11 -0
- package/src/Logo/nordic-logo-blue-icon-only.png +0 -0
- package/src/Logo/nordic-logo-gray-icon-only.png +0 -0
- package/src/Logo/nordic-logo-white-icon-only.png +0 -0
- package/src/Main/Main.tsx +13 -0
- package/src/Main/main.scss +13 -0
- package/src/MasonryLayout/MasonryLayout.tsx +234 -0
- package/src/MasonryLayout/masonryLayout.module.scss +46 -0
- package/src/NavBar/NavBar.tsx +22 -0
- package/src/NavBar/NavMenu.test.tsx +41 -0
- package/src/NavBar/NavMenu.tsx +53 -0
- package/src/NavBar/NavMenuItem.tsx +41 -0
- package/src/NavBar/nav-bar.scss +26 -0
- package/src/NavBar/nav-menu-item.scss +34 -0
- package/src/OpenApp/openApp.ts +18 -0
- package/src/Panes/FeedbackPane.tsx +149 -0
- package/src/PseudoButton/PseudoButton.tsx +56 -0
- package/src/PseudoButton/pseudo-button.scss +11 -0
- package/src/SerialPort/ConflictingSettingsDialog.tsx +242 -0
- package/src/SerialPort/SerialPort.test.ts +54 -0
- package/src/SerialPort/SerialPort.ts +202 -0
- package/src/Shortcuts/Shortcut-item.scss +33 -0
- package/src/Shortcuts/Shortcut-modal.scss +20 -0
- package/src/Shortcuts/ShortcutItem.tsx +48 -0
- package/src/Shortcuts/ShortcutModal.tsx +67 -0
- package/src/SidePanel/Group.tsx +106 -0
- package/src/SidePanel/SidePanel.tsx +19 -0
- package/src/SidePanel/group.scss +42 -0
- package/src/SidePanel/sidepanel.scss +20 -0
- package/src/Slider/Bar.tsx +24 -0
- package/src/Slider/Factor.test.ts +48 -0
- package/src/Slider/Handle.tsx +121 -0
- package/src/Slider/Slider.test.tsx +25 -0
- package/src/Slider/Slider.tsx +91 -0
- package/src/Slider/Ticks.tsx +54 -0
- package/src/Slider/__snapshots__/Slider.test.tsx.snap +50 -0
- package/src/Slider/bar.scss +24 -0
- package/src/Slider/factor.ts +24 -0
- package/src/Slider/handle.scss +32 -0
- package/src/Slider/percentage.ts +67 -0
- package/src/Slider/range.ts +92 -0
- package/src/Slider/slider.scss +14 -0
- package/src/Slider/ticks.scss +28 -0
- package/src/Slider/variables.scss +16 -0
- package/src/StartStopButton/StartStopButton.tsx +60 -0
- package/src/StartStopButton/play-circle.svg +1 -0
- package/src/StartStopButton/start-stop-button.scss +47 -0
- package/src/StartStopButton/stop-circle.svg +1 -0
- package/src/StateSelector/StateSelector.tsx +64 -0
- package/src/StateSelector/state-selector.scss +38 -0
- package/src/Stepper/Stepper.tsx +139 -0
- package/src/Stepper/stepper.scss +127 -0
- package/src/Toggle/Toggle.tsx +120 -0
- package/src/Toggle/toggle.scss +109 -0
- package/src/bootstrap.scss +14 -0
- package/src/index.ts +146 -0
- package/src/logging/appTransport.test.ts +78 -0
- package/src/logging/appTransport.ts +41 -0
- package/src/logging/describeError.test.ts +38 -0
- package/src/logging/describeError.ts +56 -0
- package/src/logging/index.ts +103 -0
- package/src/logging/logBuffer.test.ts +41 -0
- package/src/logging/logBuffer.ts +24 -0
- package/src/logging/sendInitialLogMessages.ts +64 -0
- package/src/store.ts +60 -0
- package/src/svg.d.ts +15 -0
- package/src/utils/AppTypes.ts +60 -0
- package/src/utils/appDirs.ts +78 -0
- package/src/utils/bleChannels.ts +16 -0
- package/src/utils/classNames.test.ts +29 -0
- package/src/utils/classNames.ts +25 -0
- package/src/utils/colors.scss +46 -0
- package/src/utils/colors.ts +38 -0
- package/src/utils/describeVersion.ts +21 -0
- package/src/utils/environment.ts +6 -0
- package/src/utils/logLibVersions.ts +103 -0
- package/src/utils/open.ts +46 -0
- package/src/utils/packageJson.ts +60 -0
- package/src/utils/persistentStore.ts +144 -0
- package/src/utils/systemReport.ts +160 -0
- package/src/utils/truncateMiddle.test.ts +21 -0
- package/src/utils/truncateMiddle.ts +20 -0
- package/src/utils/usageData.ts +189 -0
- package/src/utils/useHotKey.ts +62 -0
- package/src/utils/useStopwatch.test.tsx +311 -0
- package/src/utils/useStopwatch.ts +140 -0
- package/src/variables.scss +820 -0
- package/styles.scss +88 -0
- package/test/dispatchTo.ts +23 -0
- package/test/index.ts +7 -0
- package/test/jestResolver.js +28 -0
- package/test/setupTests.ts +27 -0
- package/test/testUtil.ts +20 -0
- package/test/testrenderer.tsx +39 -0
- package/tsconfig.json +9 -0
- package/typings/externals.d.ts +31 -0
- package/typings/generated/main/index.d.ts +25 -0
- package/typings/generated/src/About/About.d.ts +4 -0
- package/typings/generated/src/About/AboutButton.d.ts +8 -0
- package/typings/generated/src/About/ApplicationCard.d.ts +3 -0
- package/typings/generated/src/About/DeviceCard.d.ts +3 -0
- package/typings/generated/src/About/DocumentationCard.d.ts +3 -0
- package/typings/generated/src/About/DocumentationSection.d.ts +9 -0
- package/typings/generated/src/About/Section.d.ts +8 -0
- package/typings/generated/src/About/ShortcutButton.d.ts +6 -0
- package/typings/generated/src/About/SupportCard.d.ts +3 -0
- package/typings/generated/src/About/documentationSlice.d.ts +12 -0
- package/typings/generated/src/About/shortcutSlice.d.ts +11 -0
- package/typings/generated/src/Alert/Alert.d.ts +10 -0
- package/typings/generated/src/App/App.d.ts +27 -0
- package/typings/generated/src/App/App.test.d.ts +1 -0
- package/typings/generated/src/App/ConnectedToStore.d.ts +7 -0
- package/typings/generated/src/App/VisibilityBar.d.ts +6 -0
- package/typings/generated/src/App/appLayout.d.ts +17 -0
- package/typings/generated/src/Button/Button.d.ts +13 -0
- package/typings/generated/src/Card/Card.d.ts +7 -0
- package/typings/generated/src/Device/BrokenDeviceDialog/BrokenDeviceDialog.d.ts +4 -0
- package/typings/generated/src/Device/BrokenDeviceDialog/brokenDeviceDialogSlice.d.ts +12 -0
- package/typings/generated/src/Device/DeviceSelector/BasicDeviceInfo.d.ts +11 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceIcon.d.ts +7 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/AnimatedList.d.ts +10 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/BrokenDevice.d.ts +7 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/Device.d.ts +10 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/DeviceList.d.ts +10 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/EditDeviceButtons.d.ts +9 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.d.ts +7 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceList/RenameDevice.d.ts +6 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceSelector.d.ts +20 -0
- package/typings/generated/src/Device/DeviceSelector/DeviceSelector.test.d.ts +1 -0
- package/typings/generated/src/Device/DeviceSelector/Favorite.d.ts +9 -0
- package/typings/generated/src/Device/DeviceSelector/SelectDevice.d.ts +8 -0
- package/typings/generated/src/Device/DeviceSelector/SelectedDevice.d.ts +7 -0
- package/typings/generated/src/Device/DeviceSetup/DeviceSetupView.d.ts +3 -0
- package/typings/generated/src/Device/deviceAutoSelectSlice.d.ts +28 -0
- package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts +18 -0
- package/typings/generated/src/Device/deviceLibWrapper.d.ts +8 -0
- package/typings/generated/src/Device/deviceLibWrapper.test.d.ts +1 -0
- package/typings/generated/src/Device/deviceLister.d.ts +25 -0
- package/typings/generated/src/Device/deviceLister.test.d.ts +2 -0
- package/typings/generated/src/Device/deviceSetup.d.ts +40 -0
- package/typings/generated/src/Device/deviceSetupSlice.d.ts +20 -0
- package/typings/generated/src/Device/deviceSlice.d.ts +30 -0
- package/typings/generated/src/Device/dfu-cc.d.ts +3 -0
- package/typings/generated/src/Device/initPacket.d.ts +109 -0
- package/typings/generated/src/Device/jprogOperations.d.ts +2 -0
- package/typings/generated/src/Device/sdfuOperations.d.ts +14 -0
- package/typings/generated/src/Dialog/Dialog.d.ts +64 -0
- package/typings/generated/src/Dialog/Dialog.test.d.ts +1 -0
- package/typings/generated/src/Dropdown/Dropdown.d.ts +16 -0
- package/typings/generated/src/Dropdown/Dropdown.test.d.ts +1 -0
- package/typings/generated/src/ErrorBoundary/ErrorBoundary.d.ts +26 -0
- package/typings/generated/src/ErrorBoundary/ErrorBoundary.test.d.ts +1 -0
- package/typings/generated/src/ErrorDialog/ErrorDialog.d.ts +4 -0
- package/typings/generated/src/ErrorDialog/ErrorDialog.test.d.ts +1 -0
- package/typings/generated/src/ErrorDialog/errorDialogSlice.d.ts +23 -0
- package/typings/generated/src/ErrorDialog/errorDialogSlice.test.d.ts +1 -0
- package/typings/generated/src/FactoryReset/FactoryResetButton.d.ts +12 -0
- package/typings/generated/src/FactoryReset/FactoryResetButton.test.d.ts +1 -0
- package/typings/generated/src/InlineInput/InlineInput.d.ts +14 -0
- package/typings/generated/src/InlineInput/NumberInlineInput.d.ts +12 -0
- package/typings/generated/src/Log/LogEntry.d.ts +7 -0
- package/typings/generated/src/Log/LogViewer.d.ts +5 -0
- package/typings/generated/src/Log/logSlice.d.ts +12 -0
- package/typings/generated/src/Log/syncLogToStore.d.ts +11 -0
- package/typings/generated/src/Logo/Logo.d.ts +6 -0
- package/typings/generated/src/Main/Main.d.ts +6 -0
- package/typings/generated/src/MasonryLayout/MasonryLayout.d.ts +14 -0
- package/typings/generated/src/NavBar/NavBar.d.ts +6 -0
- package/typings/generated/src/NavBar/NavMenu.d.ts +3 -0
- package/typings/generated/src/NavBar/NavMenu.test.d.ts +1 -0
- package/typings/generated/src/NavBar/NavMenuItem.d.ts +10 -0
- package/typings/generated/src/OpenApp/openApp.d.ts +7 -0
- package/typings/generated/src/Panes/FeedbackPane.d.ts +3 -0
- package/typings/generated/src/PseudoButton/PseudoButton.d.ts +10 -0
- package/typings/generated/src/SerialPort/ConflictingSettingsDialog.d.ts +13 -0
- package/typings/generated/src/SerialPort/SerialPort.d.ts +21 -0
- package/typings/generated/src/SerialPort/SerialPort.test.d.ts +1 -0
- package/typings/generated/src/Shortcuts/ShortcutItem.d.ts +8 -0
- package/typings/generated/src/Shortcuts/ShortcutModal.d.ts +8 -0
- package/typings/generated/src/SidePanel/Group.d.ts +16 -0
- package/typings/generated/src/SidePanel/SidePanel.d.ts +7 -0
- package/typings/generated/src/Slider/Bar.d.ts +7 -0
- package/typings/generated/src/Slider/Factor.test.d.ts +1 -0
- package/typings/generated/src/Slider/Handle.d.ts +13 -0
- package/typings/generated/src/Slider/Slider.d.ts +15 -0
- package/typings/generated/src/Slider/Slider.test.d.ts +1 -0
- package/typings/generated/src/Slider/Ticks.d.ts +12 -0
- package/typings/generated/src/Slider/factor.d.ts +1 -0
- package/typings/generated/src/Slider/percentage.d.ts +4 -0
- package/typings/generated/src/Slider/range.d.ts +13 -0
- package/typings/generated/src/StartStopButton/StartStopButton.d.ts +16 -0
- package/typings/generated/src/StateSelector/StateSelector.d.ts +15 -0
- package/typings/generated/src/Stepper/Stepper.d.ts +26 -0
- package/typings/generated/src/Toggle/Toggle.d.ts +19 -0
- package/typings/generated/src/index.d.ts +69 -0
- package/typings/generated/src/logging/appTransport.d.ts +12 -0
- package/typings/generated/src/logging/appTransport.test.d.ts +1 -0
- package/typings/generated/src/logging/describeError.d.ts +2 -0
- package/typings/generated/src/logging/describeError.test.d.ts +1 -0
- package/typings/generated/src/logging/index.d.ts +9 -0
- package/typings/generated/src/logging/logBuffer.d.ts +9 -0
- package/typings/generated/src/logging/logBuffer.test.d.ts +1 -0
- package/typings/generated/src/logging/sendInitialLogMessages.d.ts +2 -0
- package/typings/generated/src/store.d.ts +65 -0
- package/typings/generated/src/utils/AppTypes.d.ts +49 -0
- package/typings/generated/src/utils/appDirs.d.ts +35 -0
- package/typings/generated/src/utils/bleChannels.d.ts +6 -0
- package/typings/generated/src/utils/classNames.d.ts +17 -0
- package/typings/generated/src/utils/classNames.test.d.ts +1 -0
- package/typings/generated/src/utils/colors.d.ts +31 -0
- package/typings/generated/src/utils/describeVersion.d.ts +3 -0
- package/typings/generated/src/utils/environment.d.ts +1 -0
- package/typings/generated/src/utils/logLibVersions.d.ts +2 -0
- package/typings/generated/src/utils/open.d.ts +15 -0
- package/typings/generated/src/utils/packageJson.d.ts +4 -0
- package/typings/generated/src/utils/persistentStore.d.ts +35 -0
- package/typings/generated/src/utils/systemReport.d.ts +4 -0
- package/typings/generated/src/utils/truncateMiddle.d.ts +2 -0
- package/typings/generated/src/utils/truncateMiddle.test.d.ts +1 -0
- package/typings/generated/src/utils/usageData.d.ts +63 -0
- package/typings/generated/src/utils/useHotKey.d.ts +6 -0
- package/typings/generated/src/utils/useStopwatch.d.ts +22 -0
- package/typings/generated/src/utils/useStopwatch.test.d.ts +1 -0
- package/typings/generated/test/dispatchTo.d.ts +3 -0
- package/typings/generated/test/testrenderer.d.ts +5 -0
- package/typings/nrf-intel-hex.d.ts +58 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface SourceJson {
|
|
8
|
+
name: string;
|
|
9
|
+
apps: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type AppVersions = {
|
|
13
|
+
[version: string]: {
|
|
14
|
+
shasum?: string;
|
|
15
|
+
tarballUrl: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export interface AppInfo {
|
|
20
|
+
name: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
description: string;
|
|
23
|
+
homepage?: string;
|
|
24
|
+
iconUrl: string;
|
|
25
|
+
releaseNotesUrl: string;
|
|
26
|
+
latestVersion: string;
|
|
27
|
+
versions: AppVersions;
|
|
28
|
+
installed?: {
|
|
29
|
+
path: string;
|
|
30
|
+
shasum?: string;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface ObjectContainingOptionalStrings {
|
|
35
|
+
[index: string]: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface PackageJson {
|
|
39
|
+
name: string;
|
|
40
|
+
version: string;
|
|
41
|
+
|
|
42
|
+
// Several optional properties
|
|
43
|
+
author?: string;
|
|
44
|
+
bin?: ObjectContainingOptionalStrings | string;
|
|
45
|
+
dependencies?: ObjectContainingOptionalStrings;
|
|
46
|
+
description?: string;
|
|
47
|
+
homepage?: string;
|
|
48
|
+
devDependencies?: ObjectContainingOptionalStrings;
|
|
49
|
+
displayName?: string;
|
|
50
|
+
engines?: ObjectContainingOptionalStrings;
|
|
51
|
+
files?: readonly string[];
|
|
52
|
+
license?: string;
|
|
53
|
+
main?: string;
|
|
54
|
+
peerDependencies?: ObjectContainingOptionalStrings;
|
|
55
|
+
repository?: {
|
|
56
|
+
type: string;
|
|
57
|
+
url: string;
|
|
58
|
+
};
|
|
59
|
+
scripts?: ObjectContainingOptionalStrings;
|
|
60
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { getGlobal } from '@electron/remote';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
|
|
10
|
+
import { loadPackageJson } from './packageJson';
|
|
11
|
+
|
|
12
|
+
const getUserDataDir = () => getGlobal('userDataDir');
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface Window {
|
|
16
|
+
appDir: string;
|
|
17
|
+
appDataDir: string;
|
|
18
|
+
appLogDir: string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function setAppDirs(
|
|
23
|
+
newAppDir: string,
|
|
24
|
+
newAppDataDir: string,
|
|
25
|
+
newAppLogDir: string
|
|
26
|
+
) {
|
|
27
|
+
window.appDir = newAppDir;
|
|
28
|
+
window.appDataDir = newAppDataDir;
|
|
29
|
+
window.appLogDir = newAppLogDir;
|
|
30
|
+
|
|
31
|
+
loadPackageJson(getAppFile('package.json'));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Get the filesystem path of the currently loaded app.
|
|
36
|
+
*
|
|
37
|
+
* @returns {string|undefined} Absolute path of current app.
|
|
38
|
+
*/
|
|
39
|
+
function getAppDir() {
|
|
40
|
+
return window.appDir;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get the filesystem path of a file for the currently loaded app.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} filename relative name of file in the app directory
|
|
47
|
+
* @returns {string|undefined} Absolute path of file.
|
|
48
|
+
*/
|
|
49
|
+
function getAppFile(filename: string) {
|
|
50
|
+
return path.resolve(getAppDir(), filename);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Get the filesystem path of the data directory of currently loaded app.
|
|
55
|
+
*
|
|
56
|
+
* @returns {string|undefined} Absolute path of data directory of the current app.
|
|
57
|
+
*/
|
|
58
|
+
function getAppDataDir() {
|
|
59
|
+
return window.appDataDir;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Get the filesystem path of the log directory of currently loaded app.
|
|
64
|
+
*
|
|
65
|
+
* @returns {string|undefined} Absolute path of data directory of the current app.
|
|
66
|
+
*/
|
|
67
|
+
function getAppLogDir() {
|
|
68
|
+
return window.appLogDir;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
setAppDirs,
|
|
73
|
+
getAppDir,
|
|
74
|
+
getAppFile,
|
|
75
|
+
getAppDataDir,
|
|
76
|
+
getAppLogDir,
|
|
77
|
+
getUserDataDir,
|
|
78
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const bleChannels = [
|
|
8
|
+
37, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 38, 11, 12, 13, 14, 15, 16, 17, 18,
|
|
9
|
+
19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 39,
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
export default Object.assign(bleChannels, {
|
|
13
|
+
min: Math.min(...bleChannels),
|
|
14
|
+
max: Math.max(...bleChannels),
|
|
15
|
+
isAdvertisement: (channel: number) => channel >= 37,
|
|
16
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import classNames from './classNames';
|
|
8
|
+
|
|
9
|
+
describe('classNames', () => {
|
|
10
|
+
it('combines multiple class names with a space', () => {
|
|
11
|
+
expect(classNames('button', 'important')).toBe('button important');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('filters out non strings', () => {
|
|
15
|
+
expect(
|
|
16
|
+
classNames(
|
|
17
|
+
'button',
|
|
18
|
+
true,
|
|
19
|
+
false,
|
|
20
|
+
null,
|
|
21
|
+
undefined,
|
|
22
|
+
[],
|
|
23
|
+
{},
|
|
24
|
+
() => {},
|
|
25
|
+
'important'
|
|
26
|
+
)
|
|
27
|
+
).toBe('button important');
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
const isString = (o: unknown) => typeof o === 'string';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Combine a list of class names into a space separated strings.
|
|
11
|
+
* Filters out all values that are not strings. The idea of this function is
|
|
12
|
+
* to use it with conditionals and potentially unset values like this:
|
|
13
|
+
*
|
|
14
|
+
* classNames(
|
|
15
|
+
* 'fixed-class-name',
|
|
16
|
+
* isVisible && 'visible',
|
|
17
|
+
* isEnabled ? 'enabled' : 'disabled',
|
|
18
|
+
* potentiallyUndefined,
|
|
19
|
+
* )
|
|
20
|
+
*
|
|
21
|
+
* @param {...unknown} className - An arbitrary list of class names or other objects
|
|
22
|
+
* @returns {string} the combined class name
|
|
23
|
+
*/
|
|
24
|
+
export default (...className: unknown[]) =>
|
|
25
|
+
className.filter(isString).join(' ');
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
@use "sass:color";
|
|
8
|
+
@import "../variables";
|
|
9
|
+
|
|
10
|
+
// Remember: When changing any entries here, they also must be
|
|
11
|
+
// changed at the corresponding place in colors.ts
|
|
12
|
+
:export {
|
|
13
|
+
nordicBlue: $nordic-blue;
|
|
14
|
+
blueSlate: $blue-slate;
|
|
15
|
+
|
|
16
|
+
white: $white;
|
|
17
|
+
black: $black;
|
|
18
|
+
|
|
19
|
+
primary: $primary;
|
|
20
|
+
primaryDarkened: $primary-darkened;
|
|
21
|
+
secondary: $secondary;
|
|
22
|
+
accent: $accent;
|
|
23
|
+
gray50: $gray-50;
|
|
24
|
+
gray100: $gray-100;
|
|
25
|
+
gray200: $gray-200;
|
|
26
|
+
gray300: $gray-300;
|
|
27
|
+
gray400: $gray-400;
|
|
28
|
+
gray500: $gray-500;
|
|
29
|
+
gray600: $gray-600;
|
|
30
|
+
gray700: $gray-700;
|
|
31
|
+
gray800: $gray-800;
|
|
32
|
+
gray900: $gray-900;
|
|
33
|
+
|
|
34
|
+
red: $red;
|
|
35
|
+
indigo: $indigo;
|
|
36
|
+
amber: $amber;
|
|
37
|
+
purple: $purple;
|
|
38
|
+
green: $green;
|
|
39
|
+
deepPurple: $deep-purple;
|
|
40
|
+
orange: $orange;
|
|
41
|
+
lime: $lime;
|
|
42
|
+
pink: $pink;
|
|
43
|
+
|
|
44
|
+
blueSlateLighter: color.scale($blue-slate, $lightness: 50%, $saturation: -50%);
|
|
45
|
+
greenLighter: color.scale($green, $lightness: 50%, $saturation: -50%);
|
|
46
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2021 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// Keep this file in sync with colors.scss
|
|
8
|
+
export const colors = {
|
|
9
|
+
nordicBlue: '#00a9ce',
|
|
10
|
+
blueSlate: '#0033a0',
|
|
11
|
+
white: 'white',
|
|
12
|
+
black: 'black',
|
|
13
|
+
primary: '#00a9ce',
|
|
14
|
+
primaryDarkened: '#0098b9',
|
|
15
|
+
secondary: 'white',
|
|
16
|
+
accent: '#0033a0',
|
|
17
|
+
gray50: '#eceff1',
|
|
18
|
+
gray100: '#cfd8dc',
|
|
19
|
+
gray200: '#b0bec5',
|
|
20
|
+
gray300: '#90a4ae',
|
|
21
|
+
gray400: '#78909c',
|
|
22
|
+
gray500: '#607d8b',
|
|
23
|
+
gray600: '#546e7a',
|
|
24
|
+
gray700: '#455a64',
|
|
25
|
+
gray800: '#37474f',
|
|
26
|
+
gray900: '#263238',
|
|
27
|
+
red: '#f44336',
|
|
28
|
+
indigo: '#3f51b5',
|
|
29
|
+
amber: '#ffc107',
|
|
30
|
+
purple: '#9c27b0',
|
|
31
|
+
green: '#4caf50',
|
|
32
|
+
deepPurple: '#673ab7',
|
|
33
|
+
orange: '#ff9800',
|
|
34
|
+
lime: '#cddc39',
|
|
35
|
+
pink: '#e91e63',
|
|
36
|
+
blueSlateLighter: '#7c98d3',
|
|
37
|
+
greenLighter: '#b1cbb3',
|
|
38
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { ModuleVersion } from '@nordicsemiconductor/nrf-device-lib-js';
|
|
8
|
+
|
|
9
|
+
export default (version?: ModuleVersion) => {
|
|
10
|
+
if (version == null) {
|
|
11
|
+
return 'Unknown';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
switch (version.versionFormat) {
|
|
15
|
+
case 'incremental':
|
|
16
|
+
case 'string':
|
|
17
|
+
return String(version.version);
|
|
18
|
+
case 'semantic':
|
|
19
|
+
return `${version.version.major}.${version.version.minor}.${version.version.patch}`;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
getModuleVersions,
|
|
9
|
+
ModuleVersion,
|
|
10
|
+
} from '@nordicsemiconductor/nrf-device-lib-js';
|
|
11
|
+
import { spawn } from 'child_process';
|
|
12
|
+
import os from 'os';
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
getDeviceLibContext,
|
|
16
|
+
getModuleVersion,
|
|
17
|
+
} from '../Device/deviceLibWrapper';
|
|
18
|
+
import logger from '../logging';
|
|
19
|
+
import describeVersion from './describeVersion';
|
|
20
|
+
|
|
21
|
+
const log = (description: string, moduleVersion?: ModuleVersion) => {
|
|
22
|
+
if (moduleVersion == null) {
|
|
23
|
+
logger.warn(`Unable to detect version of ${description}.`);
|
|
24
|
+
} else {
|
|
25
|
+
logger.info(
|
|
26
|
+
`Using ${description} version: ${describeVersion(moduleVersion)}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const pathEnvVariable = () => {
|
|
32
|
+
if (process.platform !== 'darwin') return process.env;
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
...process.env,
|
|
36
|
+
PATH: `/bin:/usr/bin:/usr/local/bin:${process.env.PATH}`,
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const spawnAsync = (cmd: string, params?: string[]) =>
|
|
41
|
+
new Promise<string>((resolve, reject) => {
|
|
42
|
+
const codeProcess = spawn(cmd, params, {
|
|
43
|
+
shell: true,
|
|
44
|
+
env: pathEnvVariable(),
|
|
45
|
+
});
|
|
46
|
+
let stdout = '';
|
|
47
|
+
let stderr = '';
|
|
48
|
+
codeProcess.stdout.on('data', data => {
|
|
49
|
+
stdout += data;
|
|
50
|
+
});
|
|
51
|
+
codeProcess.stderr.on('data', data => {
|
|
52
|
+
stderr += data;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
codeProcess.on('close', (code, signal) => {
|
|
56
|
+
if (stderr) console.log(stderr);
|
|
57
|
+
if (code === 0 && signal === null) {
|
|
58
|
+
return resolve(stdout);
|
|
59
|
+
}
|
|
60
|
+
return reject();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const checkJLinkArchitectureOnDarwin = async () => {
|
|
65
|
+
const stdout = await spawnAsync('file $(which JLinkExe)');
|
|
66
|
+
const universalMatch = 'Mach-O universal binary with 2 architectures';
|
|
67
|
+
const intelMatch = 'Mach-O 64-bit executable x86_64';
|
|
68
|
+
if (stdout.includes(universalMatch)) return 'universal';
|
|
69
|
+
if (stdout.includes(intelMatch)) return 'x86_64';
|
|
70
|
+
return 'arm';
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default async () => {
|
|
74
|
+
try {
|
|
75
|
+
const versions = await getModuleVersions(getDeviceLibContext());
|
|
76
|
+
|
|
77
|
+
log('nrf-device-lib-js', getModuleVersion('nrfdl-js', versions));
|
|
78
|
+
log('nrf-device-lib', getModuleVersion('nrfdl', versions));
|
|
79
|
+
log('nrfjprog DLL', getModuleVersion('jprog', versions));
|
|
80
|
+
log('JLink', getModuleVersion('JlinkARM', versions));
|
|
81
|
+
if (
|
|
82
|
+
process.platform === 'darwin' &&
|
|
83
|
+
os.cpus()[0].model.includes('Apple')
|
|
84
|
+
) {
|
|
85
|
+
const JLinkArchOnDarwin = await checkJLinkArchitectureOnDarwin();
|
|
86
|
+
|
|
87
|
+
if (JLinkArchOnDarwin && JLinkArchOnDarwin !== 'universal') {
|
|
88
|
+
const JLinkInstallerVersion =
|
|
89
|
+
JLinkArchOnDarwin === 'arm'
|
|
90
|
+
? '64-bit Apple M1 Installer'
|
|
91
|
+
: '64-bit Intel Installer';
|
|
92
|
+
logger.warn(
|
|
93
|
+
`It looks like you have installed JLink using ${JLinkInstallerVersion}, but currently we only support their Universal Installer for your system.`
|
|
94
|
+
);
|
|
95
|
+
logger.warn(
|
|
96
|
+
`Please install JLink: https://www.segger.com/downloads/jlink/JLink_MacOSX_V780c_universal.pkg`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch (error) {
|
|
101
|
+
logger.logError('Failed to get the library versions', error);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import childProcess from 'child_process';
|
|
8
|
+
import { shell } from 'electron';
|
|
9
|
+
import fs from 'fs';
|
|
10
|
+
import os from 'os';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Open a file in the default text application, depending on the user's OS.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} filePath path to the file to open.
|
|
16
|
+
* @returns {void}
|
|
17
|
+
*/
|
|
18
|
+
function openFile(filePath: string) {
|
|
19
|
+
const exists = fs.existsSync(filePath);
|
|
20
|
+
if (!exists) {
|
|
21
|
+
throw new Error(`Could not find file at path: ${filePath}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const escapedPath = filePath.replace(/ /g, '\\ ');
|
|
25
|
+
|
|
26
|
+
// Could not find a method that works on all three platforms:
|
|
27
|
+
// * shell.openItem works on Windows and Linux but not on OSX
|
|
28
|
+
// * childProcess.execSync works on OSX but not on Windows
|
|
29
|
+
if (os.type() === 'Darwin') {
|
|
30
|
+
childProcess.execSync(`open ${escapedPath}`);
|
|
31
|
+
} else {
|
|
32
|
+
shell.openPath(escapedPath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Open a URL in the user's default web browser.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} url The URL to open.
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
42
|
+
function openUrl(url: string) {
|
|
43
|
+
shell.openExternal(url);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { openFile, openUrl };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { readFileSync } from 'fs';
|
|
8
|
+
|
|
9
|
+
/* Explanation for that cascade of eslint-disable-next-line and @ts-ignore:
|
|
10
|
+
'../../../../package.json' will resolve correctly when `shared` is used in
|
|
11
|
+
a real app, so it is fine.
|
|
12
|
+
|
|
13
|
+
When checking `shared` '../../../../package.json' will not be there, so we
|
|
14
|
+
need to disable the errors that occur in that case. That is done by the
|
|
15
|
+
second and third statement:
|
|
16
|
+
// @ts-ignore This will be available when the app uses it.
|
|
17
|
+
// eslint-disable-next-line import/no-unresolved
|
|
18
|
+
|
|
19
|
+
Usually we would not use `@ts-ignore` but rather `@ts-expect-error`. But
|
|
20
|
+
the latter is not possible for a different reason: When we type-check an
|
|
21
|
+
app that uses shared, that line will now be type-checked too and now
|
|
22
|
+
'../../../../package.json' actually is there, so `ts-expect-error` would
|
|
23
|
+
lead to an error, telling us that contrary to our expectation there is no
|
|
24
|
+
error there.
|
|
25
|
+
|
|
26
|
+
Because of that we have to use `@ts-ignore`. But that is usually forbidden
|
|
27
|
+
by the linting rules, so additionally we have to add that first line
|
|
28
|
+
eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
29
|
+
|
|
30
|
+
Phew!
|
|
31
|
+
*/
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
33
|
+
// @ts-ignore This will be available when the app uses it.
|
|
34
|
+
// eslint-disable-next-line import/no-unresolved
|
|
35
|
+
import packageJsons from '../../../../package.json';
|
|
36
|
+
import type { PackageJson } from './AppTypes';
|
|
37
|
+
|
|
38
|
+
let packageJson: PackageJson = packageJsons;
|
|
39
|
+
|
|
40
|
+
export const loadPackageJson = (packageJsonPath: string) => {
|
|
41
|
+
try {
|
|
42
|
+
packageJson = JSON.parse(
|
|
43
|
+
readFileSync(packageJsonPath, 'utf8')
|
|
44
|
+
) as PackageJson;
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(
|
|
47
|
+
'Failed to read "package.json" of the app. Please tell the app developer to package it correctly.'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default () => {
|
|
53
|
+
if (packageJson == null) {
|
|
54
|
+
throw new Error(`package.json was not read. This can be caused by one of two things:
|
|
55
|
+
- Either a programming error in the app that tries to use the content of package.json very early before it was loaded.
|
|
56
|
+
- Or if the app was packaged without a package.json, but in that case the launcher should not even launch this app.`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return packageJson;
|
|
60
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
+
*
|
|
4
|
+
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { AutoDetectTypes } from '@serialport/bindings-cpp';
|
|
8
|
+
import Store from 'electron-store';
|
|
9
|
+
import { SerialPortOpenOptions } from 'serialport';
|
|
10
|
+
import { v4 as uuid } from 'uuid';
|
|
11
|
+
|
|
12
|
+
import logger from '../logging';
|
|
13
|
+
import packageJson from './packageJson';
|
|
14
|
+
|
|
15
|
+
export interface SerialSettings {
|
|
16
|
+
serialPortOptions: Omit<SerialPortOpenOptions<AutoDetectTypes>, 'path'>;
|
|
17
|
+
lastUpdated: number;
|
|
18
|
+
vComIndex: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TerminalSettings {
|
|
22
|
+
lineMode: boolean;
|
|
23
|
+
echoOnShell: boolean;
|
|
24
|
+
lineEnding: string;
|
|
25
|
+
clearOnSend: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const sharedStore = new Store<{
|
|
29
|
+
verboseLogging: boolean;
|
|
30
|
+
isSendingUsageData: boolean | undefined;
|
|
31
|
+
clientId?: string;
|
|
32
|
+
}>({
|
|
33
|
+
name: 'pc-nrfconnect-shared',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/* These nicknames are also read by the VS Code extension,
|
|
37
|
+
so changing e.g. the keys here would break the usage there. */
|
|
38
|
+
export const persistNickname = (serialNumber: string, nickname: string) =>
|
|
39
|
+
sharedStore.set(`${serialNumber}.name`, nickname);
|
|
40
|
+
export const getPersistedNickname = (serialNumber: string) =>
|
|
41
|
+
sharedStore.get(`${serialNumber}.name`, '') as string;
|
|
42
|
+
|
|
43
|
+
export const persistIsFavorite = (serialNumber: string, value: boolean) =>
|
|
44
|
+
sharedStore.set(`${serialNumber}.fav`, value);
|
|
45
|
+
export const getPersistedIsFavorite = (serialNumber: string) =>
|
|
46
|
+
sharedStore.get(`${serialNumber}.fav`, false) as boolean;
|
|
47
|
+
|
|
48
|
+
export const persistSerialPortSettings = (
|
|
49
|
+
serialNumber: string,
|
|
50
|
+
serialPortSettings: Omit<SerialSettings, 'lastUpdated'>
|
|
51
|
+
) =>
|
|
52
|
+
sharedStore.set(`${serialNumber}.${packageJson().name}`, {
|
|
53
|
+
...serialPortSettings,
|
|
54
|
+
lastUpdated: Date.now(),
|
|
55
|
+
});
|
|
56
|
+
export const getPersistedSerialPortSettings = (
|
|
57
|
+
serialNumber: string
|
|
58
|
+
): SerialSettings | undefined => {
|
|
59
|
+
const appName = packageJson().name;
|
|
60
|
+
logger.info(
|
|
61
|
+
`Getting serialport options from persistent store ${serialNumber}.${appName}`
|
|
62
|
+
);
|
|
63
|
+
return sharedStore.get(`${serialNumber}.${appName}`);
|
|
64
|
+
};
|
|
65
|
+
export const persistTerminalSettings = (
|
|
66
|
+
serialNumber: string,
|
|
67
|
+
vComIndex: number,
|
|
68
|
+
terminalSettings: TerminalSettings
|
|
69
|
+
) =>
|
|
70
|
+
sharedStore.set(
|
|
71
|
+
`${serialNumber}.vCom-${vComIndex}.TerminalSettings`,
|
|
72
|
+
terminalSettings
|
|
73
|
+
);
|
|
74
|
+
export const getPersistedTerminalSettings = (
|
|
75
|
+
serialNumber: string,
|
|
76
|
+
vComIndex: number
|
|
77
|
+
): TerminalSettings | undefined => {
|
|
78
|
+
logger.info(
|
|
79
|
+
`Get terminal settings from persistent store ${serialNumber}.vCom-${vComIndex}.TerminalSettings`
|
|
80
|
+
);
|
|
81
|
+
return sharedStore.get(
|
|
82
|
+
`${serialNumber}.vCom-${vComIndex}.TerminalSettings`
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const persistIsSendingUsageData = (value: boolean) =>
|
|
87
|
+
sharedStore.set('isSendingUsageData', value);
|
|
88
|
+
export const getIsSendingUsageData = () =>
|
|
89
|
+
sharedStore.get('isSendingUsageData', undefined) as boolean | undefined;
|
|
90
|
+
export const deleteIsSendingUsageData = () =>
|
|
91
|
+
sharedStore.delete('isSendingUsageData');
|
|
92
|
+
|
|
93
|
+
const existingUsageDataClientId = () => sharedStore.get('clientId');
|
|
94
|
+
const newUsageDataClientId = () => {
|
|
95
|
+
const clientId = uuid();
|
|
96
|
+
sharedStore.set('clientId', clientId);
|
|
97
|
+
|
|
98
|
+
return clientId;
|
|
99
|
+
};
|
|
100
|
+
export const getUsageDataClientId = () =>
|
|
101
|
+
existingUsageDataClientId() ?? newUsageDataClientId();
|
|
102
|
+
|
|
103
|
+
export const persistIsLoggingVerbose = (value: boolean) =>
|
|
104
|
+
sharedStore.set('isLoggingVerbose', value);
|
|
105
|
+
export const getIsLoggingVerbose = () =>
|
|
106
|
+
sharedStore.get('isLoggingVerbose', false);
|
|
107
|
+
|
|
108
|
+
// This one must be initialised lazily, because the package.json is not read yet when this module is initialised.
|
|
109
|
+
// This can probably be changed when we bundle shared with the apps.
|
|
110
|
+
let appSpecificStore: Store | undefined;
|
|
111
|
+
|
|
112
|
+
interface SharedAppSpecificStoreSchema {
|
|
113
|
+
currentPane?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const getAppSpecificStore = <
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
|
+
StoreSchema extends Record<string, any>
|
|
119
|
+
>(
|
|
120
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
121
|
+
options?: Store.Options<any>
|
|
122
|
+
) => {
|
|
123
|
+
if (appSpecificStore == null) {
|
|
124
|
+
appSpecificStore = new Store({
|
|
125
|
+
name: packageJson().name,
|
|
126
|
+
clearInvalidConfig: true,
|
|
127
|
+
// @ts-expect-error `electron-store` assumes the app is the version of the launcher, override this to be the same as the app version
|
|
128
|
+
projectVersion: packageJson().version,
|
|
129
|
+
...options,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return appSpecificStore as Store<
|
|
134
|
+
StoreSchema & SharedAppSpecificStoreSchema
|
|
135
|
+
>;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export const persistCurrentPane = (currentPane: number) =>
|
|
139
|
+
getAppSpecificStore<SharedAppSpecificStoreSchema>().set(
|
|
140
|
+
`currentPane`,
|
|
141
|
+
currentPane
|
|
142
|
+
);
|
|
143
|
+
export const getPersistedCurrentPane = () =>
|
|
144
|
+
getAppSpecificStore<SharedAppSpecificStoreSchema>().get(`currentPane`);
|