@nordicsemiconductor/pc-nrfconnect-shared 60.0.0-pre1 → 60.0.0-pre2
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/dist/bootstrap.css +8951 -0
- package/dist/index.css +1451 -0
- package/dist/index.js +122119 -0
- package/{src/Logo/nordic-logo-blue-icon-only.png → dist/nordic-logo-blue-icon-only-H7BABN6D.png} +0 -0
- package/{src/Logo/nordic-logo-gray-icon-only.png → dist/nordic-logo-gray-icon-only-GATOTR3L.png} +0 -0
- package/package.json +12 -3
- package/typings/generated/src/Device/deviceInfo/deviceInfo.d.ts +1 -2
- package/.github/ISSUE_TEMPLATE/custom.md +0 -10
- package/.husky/pre-push +0 -3
- package/.renovaterc.json +0 -10
- package/Changelog.md +0 -2973
- package/azure-pipelines.yml +0 -34
- package/config/eslintrc.js +0 -190
- package/config/jest.config.js +0 -41
- package/config/prettier.config.js +0 -13
- package/config/tsconfig.json +0 -15
- package/fw/bootloader/graviton_bootloader_v1.0.1-[nRF5_SDK_15.0.1-1.alpha_f76d012].zip +0 -0
- package/jest.config.js +0 -7
- package/main/index.ts +0 -32
- package/mocks/deviceLibMock.ts +0 -21
- package/mocks/electronMock.ts +0 -15
- package/mocks/electronStoreMock.ts +0 -19
- package/mocks/emptyMock.ts +0 -7
- package/mocks/fileMock.ts +0 -13
- package/mocks/gaMock.ts +0 -9
- package/mocks/mockTests.test.ts +0 -15
- package/mocks/packageJsonMock.ts +0 -10
- package/mocks/remoteMock.ts +0 -17
- package/scripts/esbuild-bootstrap.js +0 -15
- package/scripts/esbuild-renderer.js +0 -131
- package/scripts/installHusky.ts +0 -17
- package/scripts/prepare-shared-release.ts +0 -122
- package/scripts/release-shared.test.ts +0 -132
- package/scripts/release-shared.ts +0 -207
- package/src/About/About.tsx +0 -25
- package/src/About/AboutButton.tsx +0 -28
- package/src/About/ApplicationCard.tsx +0 -83
- package/src/About/DeviceCard.tsx +0 -74
- package/src/About/DocumentationCard.tsx +0 -18
- package/src/About/DocumentationSection.tsx +0 -24
- package/src/About/Section.tsx +0 -21
- package/src/About/ShortcutButton.tsx +0 -41
- package/src/About/SupportCard.tsx +0 -97
- package/src/About/about.scss +0 -40
- package/src/About/documentationSlice.ts +0 -41
- package/src/About/section.scss +0 -15
- package/src/About/shortcutSlice.ts +0 -52
- package/src/Alert/Alert.module.scss +0 -29
- package/src/Alert/Alert.tsx +0 -37
- package/src/App/App.test.tsx +0 -47
- package/src/App/App.tsx +0 -227
- package/src/App/ConnectedToStore.tsx +0 -19
- package/src/App/VisibilityBar.tsx +0 -103
- package/src/App/app.scss +0 -83
- package/src/App/appLayout.ts +0 -95
- package/src/App/shared.scss +0 -49
- package/src/App/visibility-bar.scss +0 -55
- package/src/Button/Button.tsx +0 -66
- package/src/Button/button.module.scss +0 -154
- package/src/Card/Card.tsx +0 -26
- package/src/Card/card.module.scss +0 -28
- package/src/Device/BrokenDeviceDialog/BrokenDeviceDialog.tsx +0 -58
- package/src/Device/BrokenDeviceDialog/broken-device-dialog.scss +0 -18
- package/src/Device/BrokenDeviceDialog/brokenDeviceDialogSlice.tsx +0 -48
- package/src/Device/DeviceSelector/BasicDeviceInfo.tsx +0 -115
- package/src/Device/DeviceSelector/DeviceIcon.tsx +0 -27
- package/src/Device/DeviceSelector/DeviceList/AnimatedList.tsx +0 -62
- package/src/Device/DeviceSelector/DeviceList/BrokenDevice.tsx +0 -34
- package/src/Device/DeviceSelector/DeviceList/Device.tsx +0 -84
- package/src/Device/DeviceSelector/DeviceList/DeviceList.tsx +0 -113
- package/src/Device/DeviceSelector/DeviceList/EditDeviceButtons.tsx +0 -28
- package/src/Device/DeviceSelector/DeviceList/MoreDeviceInfo.tsx +0 -65
- package/src/Device/DeviceSelector/DeviceList/RenameDevice.tsx +0 -22
- package/src/Device/DeviceSelector/DeviceList/broken-device.scss +0 -32
- package/src/Device/DeviceSelector/DeviceList/device-list.scss +0 -64
- package/src/Device/DeviceSelector/DeviceList/device.scss +0 -28
- package/src/Device/DeviceSelector/DeviceList/edit-device-buttons.scss +0 -31
- package/src/Device/DeviceSelector/DeviceList/more-device-info.scss +0 -33
- package/src/Device/DeviceSelector/DeviceList/rename-device.scss +0 -13
- package/src/Device/DeviceSelector/DeviceSelector.test.tsx +0 -342
- package/src/Device/DeviceSelector/DeviceSelector.tsx +0 -173
- package/src/Device/DeviceSelector/Favorite.tsx +0 -49
- package/src/Device/DeviceSelector/SelectDevice.tsx +0 -36
- package/src/Device/DeviceSelector/SelectedDevice.tsx +0 -65
- package/src/Device/DeviceSelector/arrow-down.svg +0 -1
- package/src/Device/DeviceSelector/basic-device-info.scss +0 -62
- package/src/Device/DeviceSelector/device-icon.scss +0 -27
- package/src/Device/DeviceSelector/favorite.scss +0 -17
- package/src/Device/DeviceSelector/select-device.scss +0 -38
- package/src/Device/DeviceSelector/selected-device.scss +0 -57
- package/src/Device/DeviceSetup/DeviceSetupView.tsx +0 -102
- package/src/Device/deviceAutoSelectSlice.ts +0 -144
- package/src/Device/deviceInfo/deviceInfo.ts +0 -254
- package/src/Device/deviceInfo/nRF51-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/nRF52-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/nRF53-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/nRF70-Series_no-background_RGB.svg +0 -36
- package/src/Device/deviceInfo/nRF91-Series-logo.svg +0 -1
- package/src/Device/deviceInfo/ppk-logo.svg +0 -1
- package/src/Device/deviceInfo/unknown-logo.svg +0 -30
- package/src/Device/deviceInfo/unknown-nordic-logo.svg +0 -25
- package/src/Device/deviceLibWrapper.test.ts +0 -97
- package/src/Device/deviceLibWrapper.ts +0 -133
- package/src/Device/deviceLister.test.ts +0 -89
- package/src/Device/deviceLister.ts +0 -396
- package/src/Device/deviceSetup.ts +0 -264
- package/src/Device/deviceSetupSlice.ts +0 -94
- package/src/Device/deviceSlice.ts +0 -248
- package/src/Device/dfu-cc.ts +0 -162
- package/src/Device/initPacket.ts +0 -402
- package/src/Device/jprogOperations.ts +0 -206
- package/src/Device/sdfuOperations.ts +0 -601
- package/src/Dialog/Dialog.test.tsx +0 -134
- package/src/Dialog/Dialog.tsx +0 -236
- package/src/Dialog/dialog.scss +0 -60
- package/src/Dropdown/Dropdown.module.scss +0 -83
- package/src/Dropdown/Dropdown.test.tsx +0 -62
- package/src/Dropdown/Dropdown.tsx +0 -106
- package/src/ErrorBoundary/ErrorBoundary.test.tsx +0 -105
- package/src/ErrorBoundary/ErrorBoundary.tsx +0 -186
- package/src/ErrorBoundary/bug.svg +0 -1
- package/src/ErrorBoundary/error-boundary.scss +0 -102
- package/src/ErrorDialog/ErrorDialog.test.tsx +0 -70
- package/src/ErrorDialog/ErrorDialog.tsx +0 -94
- package/src/ErrorDialog/error.scss +0 -14
- package/src/ErrorDialog/errorDialogSlice.test.ts +0 -64
- package/src/ErrorDialog/errorDialogSlice.ts +0 -80
- package/src/FactoryReset/FactoryResetButton.test.tsx +0 -46
- package/src/FactoryReset/FactoryResetButton.tsx +0 -81
- package/src/InlineInput/InlineInput.tsx +0 -170
- package/src/InlineInput/NumberInlineInput.tsx +0 -107
- package/src/InlineInput/inline-input.scss +0 -38
- package/src/InlineInput/number-inline-input.scss +0 -15
- package/src/Log/LogEntry.tsx +0 -62
- package/src/Log/LogViewer.tsx +0 -54
- package/src/Log/log-entry.scss +0 -30
- package/src/Log/log-viewer.scss +0 -24
- package/src/Log/logSlice.ts +0 -73
- package/src/Log/syncLogToStore.ts +0 -36
- package/src/Logo/Logo.tsx +0 -48
- package/src/Logo/logo.scss +0 -11
- package/src/Main/Main.tsx +0 -13
- package/src/Main/main.scss +0 -13
- package/src/MasonryLayout/MasonryLayout.tsx +0 -234
- package/src/MasonryLayout/masonryLayout.module.scss +0 -46
- package/src/NavBar/NavBar.tsx +0 -22
- package/src/NavBar/NavMenu.test.tsx +0 -41
- package/src/NavBar/NavMenu.tsx +0 -53
- package/src/NavBar/NavMenuItem.tsx +0 -41
- package/src/NavBar/nav-bar.scss +0 -26
- package/src/NavBar/nav-menu-item.scss +0 -34
- package/src/OpenApp/openApp.ts +0 -18
- package/src/Panes/FeedbackPane.tsx +0 -149
- package/src/PseudoButton/PseudoButton.tsx +0 -56
- package/src/PseudoButton/pseudo-button.scss +0 -11
- package/src/SerialPort/ConflictingSettingsDialog.tsx +0 -242
- package/src/SerialPort/SerialPort.test.ts +0 -54
- package/src/SerialPort/SerialPort.ts +0 -202
- package/src/Shortcuts/Shortcut-item.scss +0 -33
- package/src/Shortcuts/Shortcut-modal.scss +0 -20
- package/src/Shortcuts/ShortcutItem.tsx +0 -48
- package/src/Shortcuts/ShortcutModal.tsx +0 -67
- package/src/SidePanel/Group.tsx +0 -106
- package/src/SidePanel/SidePanel.tsx +0 -19
- package/src/SidePanel/group.scss +0 -42
- package/src/SidePanel/sidepanel.scss +0 -20
- package/src/Slider/Bar.tsx +0 -24
- package/src/Slider/Factor.test.ts +0 -48
- package/src/Slider/Handle.tsx +0 -121
- package/src/Slider/Slider.test.tsx +0 -25
- package/src/Slider/Slider.tsx +0 -91
- package/src/Slider/Ticks.tsx +0 -54
- package/src/Slider/__snapshots__/Slider.test.tsx.snap +0 -50
- package/src/Slider/bar.scss +0 -24
- package/src/Slider/factor.ts +0 -24
- package/src/Slider/handle.scss +0 -32
- package/src/Slider/percentage.ts +0 -67
- package/src/Slider/range.ts +0 -92
- package/src/Slider/slider.scss +0 -14
- package/src/Slider/ticks.scss +0 -28
- package/src/Slider/variables.scss +0 -16
- package/src/StartStopButton/StartStopButton.tsx +0 -60
- package/src/StartStopButton/play-circle.svg +0 -1
- package/src/StartStopButton/start-stop-button.scss +0 -47
- package/src/StartStopButton/stop-circle.svg +0 -1
- package/src/StateSelector/StateSelector.tsx +0 -64
- package/src/StateSelector/state-selector.scss +0 -38
- package/src/Stepper/Stepper.tsx +0 -139
- package/src/Stepper/stepper.scss +0 -127
- package/src/Toggle/Toggle.tsx +0 -120
- package/src/Toggle/toggle.scss +0 -109
- package/src/bootstrap.scss +0 -14
- package/src/index.ts +0 -146
- package/src/logging/appTransport.test.ts +0 -78
- package/src/logging/appTransport.ts +0 -41
- package/src/logging/describeError.test.ts +0 -38
- package/src/logging/describeError.ts +0 -56
- package/src/logging/index.ts +0 -103
- package/src/logging/logBuffer.test.ts +0 -41
- package/src/logging/logBuffer.ts +0 -24
- package/src/logging/sendInitialLogMessages.ts +0 -64
- package/src/store.ts +0 -60
- package/src/svg.d.ts +0 -15
- package/src/utils/AppTypes.ts +0 -60
- package/src/utils/appDirs.ts +0 -78
- package/src/utils/bleChannels.ts +0 -16
- package/src/utils/classNames.test.ts +0 -29
- package/src/utils/classNames.ts +0 -25
- package/src/utils/colors.scss +0 -46
- package/src/utils/colors.ts +0 -38
- package/src/utils/describeVersion.ts +0 -21
- package/src/utils/environment.ts +0 -6
- package/src/utils/logLibVersions.ts +0 -103
- package/src/utils/open.ts +0 -46
- package/src/utils/packageJson.ts +0 -60
- package/src/utils/persistentStore.ts +0 -144
- package/src/utils/systemReport.ts +0 -160
- package/src/utils/truncateMiddle.test.ts +0 -21
- package/src/utils/truncateMiddle.ts +0 -20
- package/src/utils/usageData.ts +0 -189
- package/src/utils/useHotKey.ts +0 -62
- package/src/utils/useStopwatch.test.tsx +0 -311
- package/src/utils/useStopwatch.ts +0 -140
- package/src/variables.scss +0 -820
- package/styles.scss +0 -88
- package/test/dispatchTo.ts +0 -23
- package/test/index.ts +0 -7
- package/test/jestResolver.js +0 -28
- package/test/setupTests.ts +0 -27
- package/test/testUtil.ts +0 -20
- package/test/testrenderer.tsx +0 -39
- /package/{src/Logo/nordic-logo-white-icon-only.png → dist/nordic-logo-white-icon-only-XIZBW537.png} +0 -0
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2105 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import nrfDeviceLib from '@nordicsemiconductor/nrf-device-lib-js';
|
|
8
|
-
import fs from 'fs';
|
|
9
|
-
import { EOL } from 'os';
|
|
10
|
-
import path from 'path';
|
|
11
|
-
import pretty from 'prettysize';
|
|
12
|
-
import type Systeminformation from 'systeminformation';
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
deviceInfo as getDeviceInfo,
|
|
16
|
-
productPageUrl,
|
|
17
|
-
} from '../Device/deviceInfo/deviceInfo';
|
|
18
|
-
import {
|
|
19
|
-
getDeviceLibContext,
|
|
20
|
-
getModuleVersion,
|
|
21
|
-
} from '../Device/deviceLibWrapper';
|
|
22
|
-
import { Device } from '../Device/deviceSlice';
|
|
23
|
-
import logger from '../logging';
|
|
24
|
-
import { getAppDataDir } from './appDirs';
|
|
25
|
-
import describeVersion from './describeVersion';
|
|
26
|
-
import { openFile } from './open';
|
|
27
|
-
|
|
28
|
-
const generalInfoReport = async () => {
|
|
29
|
-
// eslint-disable-next-line global-require
|
|
30
|
-
const si = require('systeminformation') as typeof Systeminformation;
|
|
31
|
-
const [
|
|
32
|
-
{ manufacturer, model },
|
|
33
|
-
{ vendor, version },
|
|
34
|
-
{ platform, distro, release, arch },
|
|
35
|
-
{ kernel, git, node, python, python3 },
|
|
36
|
-
{
|
|
37
|
-
manufacturer: cpuManufacturer,
|
|
38
|
-
brand,
|
|
39
|
-
speed,
|
|
40
|
-
cores,
|
|
41
|
-
physicalCores,
|
|
42
|
-
processors,
|
|
43
|
-
},
|
|
44
|
-
{ total, free },
|
|
45
|
-
fsSize,
|
|
46
|
-
] = await Promise.all([
|
|
47
|
-
si.system(),
|
|
48
|
-
si.bios(),
|
|
49
|
-
si.osInfo(),
|
|
50
|
-
si.versions(),
|
|
51
|
-
si.cpu(),
|
|
52
|
-
si.mem(),
|
|
53
|
-
si.fsSize(),
|
|
54
|
-
]);
|
|
55
|
-
|
|
56
|
-
const versions = await nrfDeviceLib.getModuleVersions(
|
|
57
|
-
getDeviceLibContext()
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
return [
|
|
61
|
-
`- System: ${manufacturer} ${model}`,
|
|
62
|
-
`- BIOS: ${vendor} ${version}`,
|
|
63
|
-
`- CPU: ${processors} x ${cpuManufacturer} ${brand} ${speed} GHz` +
|
|
64
|
-
` ${cores} cores (${physicalCores} physical)`,
|
|
65
|
-
`- Memory: ${pretty(free)} free of ${pretty(total)} total`,
|
|
66
|
-
`- Filesystem: ${fsSize[0].fs} (${fsSize[0].type})` +
|
|
67
|
-
` ${pretty(Number(fsSize[0].size) || 0)}` +
|
|
68
|
-
` ${fsSize[0].use.toFixed(1)}% used`,
|
|
69
|
-
'',
|
|
70
|
-
`- OS: ${distro} (${release}) ${platform} ${arch}`,
|
|
71
|
-
'',
|
|
72
|
-
'- Versions',
|
|
73
|
-
` - kernel: ${kernel}`,
|
|
74
|
-
` - git: ${git}`,
|
|
75
|
-
` - node: ${node}`,
|
|
76
|
-
` - python: ${python}`,
|
|
77
|
-
` - python3: ${python3}`,
|
|
78
|
-
` - nrf-device-lib-js: ${describeVersion(
|
|
79
|
-
getModuleVersion('nrfdl-js', versions)
|
|
80
|
-
)}`,
|
|
81
|
-
` - nrf-device-lib: ${describeVersion(
|
|
82
|
-
getModuleVersion('nrfdl', versions)
|
|
83
|
-
)}`,
|
|
84
|
-
` - nrfjprog DLL: ${describeVersion(
|
|
85
|
-
getModuleVersion('jprog', versions)
|
|
86
|
-
)}`,
|
|
87
|
-
` - JLink: ${describeVersion(
|
|
88
|
-
getModuleVersion('JlinkARM', versions)
|
|
89
|
-
)}`,
|
|
90
|
-
'',
|
|
91
|
-
];
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
const allDevicesReport = (allDevices: Device[] = []) => [
|
|
95
|
-
'- Connected devices:',
|
|
96
|
-
...allDevices.map(
|
|
97
|
-
d =>
|
|
98
|
-
` - ${d.serialNumber} ${d.boardVersion || ''}: ${d.serialPorts
|
|
99
|
-
?.map(s => s.comName)
|
|
100
|
-
.join(', ')}`
|
|
101
|
-
),
|
|
102
|
-
'',
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
const currentDeviceReport = (device?: Device, currentSerialNumber?: string) => {
|
|
106
|
-
if (device == null) {
|
|
107
|
-
return [];
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const deviceInfo = getDeviceInfo(device);
|
|
111
|
-
|
|
112
|
-
return [
|
|
113
|
-
'- Current device:',
|
|
114
|
-
` - name: ${deviceInfo.name}`,
|
|
115
|
-
` - serialNumber: ${currentSerialNumber}`,
|
|
116
|
-
` - cores: ${deviceInfo.cores ?? 'Unknown'}`,
|
|
117
|
-
` - website: ${productPageUrl(device) ?? 'Unknown'}`,
|
|
118
|
-
'',
|
|
119
|
-
];
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const generateSystemReport = async (
|
|
123
|
-
timestamp: string,
|
|
124
|
-
allDevices?: Device[],
|
|
125
|
-
currentDevice?: Device,
|
|
126
|
-
currentSerialNumber?: string
|
|
127
|
-
) =>
|
|
128
|
-
[
|
|
129
|
-
`# nRFConnect System Report - ${timestamp}`,
|
|
130
|
-
'',
|
|
131
|
-
...(await generalInfoReport()),
|
|
132
|
-
...allDevicesReport(allDevices),
|
|
133
|
-
...currentDeviceReport(currentDevice, currentSerialNumber),
|
|
134
|
-
].join(EOL);
|
|
135
|
-
|
|
136
|
-
export default async (
|
|
137
|
-
allDevices: Device[],
|
|
138
|
-
currentSerialNumber: string,
|
|
139
|
-
currentDevice: Device | null
|
|
140
|
-
) => {
|
|
141
|
-
logger.info('Generating system report...');
|
|
142
|
-
const timestamp = new Date().toISOString().replace(/:/g, '-');
|
|
143
|
-
const report = await generateSystemReport(
|
|
144
|
-
timestamp,
|
|
145
|
-
allDevices,
|
|
146
|
-
currentDevice ?? undefined,
|
|
147
|
-
currentSerialNumber
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
const fileName = `nrfconnect-system-report-${timestamp}.txt`;
|
|
151
|
-
const filePath = path.resolve(getAppDataDir(), fileName);
|
|
152
|
-
|
|
153
|
-
try {
|
|
154
|
-
fs.writeFileSync(filePath, report);
|
|
155
|
-
logger.info(`System report: ${filePath}`);
|
|
156
|
-
openFile(filePath);
|
|
157
|
-
} catch (error) {
|
|
158
|
-
logger.logError('Failed to generate system report', error);
|
|
159
|
-
}
|
|
160
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { truncateMiddle } from './truncateMiddle';
|
|
8
|
-
|
|
9
|
-
test('truncate strings when necessary', () => {
|
|
10
|
-
expect(
|
|
11
|
-
truncateMiddle('some long string with more than 36 characters')
|
|
12
|
-
).toBe('some long string wit...36 characters');
|
|
13
|
-
|
|
14
|
-
expect(truncateMiddle('short string')).toBe('short string');
|
|
15
|
-
|
|
16
|
-
expect(truncateMiddle('string with 20 chars')).toBe('string with 20 chars');
|
|
17
|
-
|
|
18
|
-
expect(truncateMiddle('abc123def', 3, 3)).toBe('abc123def');
|
|
19
|
-
|
|
20
|
-
expect(truncateMiddle('abc1234efg', 3, 3)).toBe('abc...efg');
|
|
21
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const truncateMiddle = (str: string, clipStart = 20, clipEnd = 13) => {
|
|
8
|
-
const clipStartWithEllipsis = clipStart + 3;
|
|
9
|
-
if (str.length <= clipStartWithEllipsis + clipEnd) {
|
|
10
|
-
return str;
|
|
11
|
-
}
|
|
12
|
-
const rightHandStartingPoint =
|
|
13
|
-
str.length - Math.min(clipEnd, str.length - clipStartWithEllipsis);
|
|
14
|
-
return `${str.substring(0, clipStart)}...${str.substring(
|
|
15
|
-
rightHandStartingPoint,
|
|
16
|
-
str.length
|
|
17
|
-
)}`;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { truncateMiddle };
|
package/src/utils/usageData.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2105 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import reactGA from 'react-ga';
|
|
8
|
-
import type Systeminformation from 'systeminformation';
|
|
9
|
-
|
|
10
|
-
import logger from '../logging';
|
|
11
|
-
import { PackageJson } from './AppTypes';
|
|
12
|
-
import { isDevelopment } from './environment';
|
|
13
|
-
import {
|
|
14
|
-
deleteIsSendingUsageData,
|
|
15
|
-
getIsSendingUsageData,
|
|
16
|
-
getUsageDataClientId,
|
|
17
|
-
persistIsSendingUsageData,
|
|
18
|
-
} from './persistentStore';
|
|
19
|
-
|
|
20
|
-
const trackId = 'UA-22498474-5';
|
|
21
|
-
const categoryName = () =>
|
|
22
|
-
isDevelopment ? `${appJson.name}-dev` : appJson.name;
|
|
23
|
-
|
|
24
|
-
interface EventAction {
|
|
25
|
-
action: string;
|
|
26
|
-
label?: string;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let initialized = false;
|
|
30
|
-
let appJson: PackageJson;
|
|
31
|
-
let eventQueue: EventAction[] = [];
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Initialize instance to send user data
|
|
35
|
-
* @param {*} packageJson the app's package json
|
|
36
|
-
*
|
|
37
|
-
* @returns {Promise<void>} void
|
|
38
|
-
*/
|
|
39
|
-
export const init = (packageJson: PackageJson) => {
|
|
40
|
-
appJson = packageJson;
|
|
41
|
-
|
|
42
|
-
if (!getIsSendingUsageData()) return;
|
|
43
|
-
|
|
44
|
-
setTimeout(async () => {
|
|
45
|
-
const clientId = getUsageDataClientId();
|
|
46
|
-
|
|
47
|
-
logger.debug(`Client Id: ${clientId}`);
|
|
48
|
-
|
|
49
|
-
reactGA.initialize(trackId, {
|
|
50
|
-
debug: false,
|
|
51
|
-
titleCase: false,
|
|
52
|
-
gaOptions: {
|
|
53
|
-
storage: 'none',
|
|
54
|
-
storeGac: false,
|
|
55
|
-
clientId,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
reactGA.set({
|
|
60
|
-
checkProtocolTask: null,
|
|
61
|
-
// According to Nordic Personal Data Processing Protocol for nRF Connect for Desktop
|
|
62
|
-
// https://projecttools.nordicsemi.no/confluence/display/ISMS/nRF+Connect+for+Desktop
|
|
63
|
-
// we set ip as anonymized in Google Analytics as described on page
|
|
64
|
-
// https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#anonymizeIp
|
|
65
|
-
anonymizeIp: true,
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
reactGA.pageview(appJson.name);
|
|
69
|
-
|
|
70
|
-
// eslint-disable-next-line global-require
|
|
71
|
-
const si = require('systeminformation') as typeof Systeminformation;
|
|
72
|
-
sendUsageData('architecture', (await si.osInfo()).arch);
|
|
73
|
-
|
|
74
|
-
initialized = true;
|
|
75
|
-
logger.debug(
|
|
76
|
-
`Google Analytics for category ${categoryName()} has initialized`
|
|
77
|
-
);
|
|
78
|
-
}, 5000); // Add 5 second delay to prevent inital rendering from beeing frozen.
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Checks if usage report instance is initialized and ready to be sent
|
|
83
|
-
*
|
|
84
|
-
* @returns {Boolean} returns whether the setting is on, off or undefined
|
|
85
|
-
*/
|
|
86
|
-
export const isInitialized = () => {
|
|
87
|
-
logger.debug(
|
|
88
|
-
`Usage report instance is${initialized ? '' : ' not'} initialized`
|
|
89
|
-
);
|
|
90
|
-
return initialized;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Check the status of usage data
|
|
95
|
-
*
|
|
96
|
-
* @returns {Boolean | undefined} returns whether the setting is on, off or undefined
|
|
97
|
-
*/
|
|
98
|
-
export const isEnabled = () => {
|
|
99
|
-
const isSendingUsageData = getIsSendingUsageData();
|
|
100
|
-
logger.debug(`Usage data is ${isSendingUsageData}`);
|
|
101
|
-
return isSendingUsageData;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Enable sending usage data
|
|
106
|
-
*
|
|
107
|
-
* @returns {void}
|
|
108
|
-
*/
|
|
109
|
-
export const enable = () => {
|
|
110
|
-
persistIsSendingUsageData(true);
|
|
111
|
-
logger.debug('Usage data has enabled');
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Disable sending usage data
|
|
116
|
-
*
|
|
117
|
-
* @returns {void}
|
|
118
|
-
*/
|
|
119
|
-
export const disable = () => {
|
|
120
|
-
persistIsSendingUsageData(false);
|
|
121
|
-
logger.debug('Usage data has disabled');
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Reset settings so that launcher is able to
|
|
126
|
-
* ask the user to enable or disable sending usage data
|
|
127
|
-
*
|
|
128
|
-
* @returns {void}
|
|
129
|
-
*/
|
|
130
|
-
export const reset = () => {
|
|
131
|
-
deleteIsSendingUsageData();
|
|
132
|
-
logger.debug('Usage data has reset');
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Send event
|
|
137
|
-
* @param {EventAction} event the event to send
|
|
138
|
-
*
|
|
139
|
-
* @returns {void}
|
|
140
|
-
*/
|
|
141
|
-
const sendEvent = ({ action, label }: EventAction) => {
|
|
142
|
-
const isSendingUsageData = getIsSendingUsageData();
|
|
143
|
-
const category = categoryName();
|
|
144
|
-
|
|
145
|
-
if (isSendingUsageData) {
|
|
146
|
-
const data = JSON.stringify({ category, action, label });
|
|
147
|
-
logger.debug(`Sending usage data ${data}`);
|
|
148
|
-
reactGA.event({ category, action, label });
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Send usage data event to Google Analytics
|
|
154
|
-
* @param {string} action The event action
|
|
155
|
-
* @param {string} label The event label
|
|
156
|
-
* @returns {void}
|
|
157
|
-
*/
|
|
158
|
-
export const sendUsageData = <T extends string>(action: T, label?: string) => {
|
|
159
|
-
eventQueue.push({ action, label });
|
|
160
|
-
if (!initialized) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
eventQueue.forEach(sendEvent);
|
|
164
|
-
eventQueue = [];
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Send error usage data event to Google Analytics and also show it in the logger view
|
|
169
|
-
* @param {string} error The event action
|
|
170
|
-
* @returns {void}
|
|
171
|
-
*/
|
|
172
|
-
export const sendErrorReport = (error: string) => {
|
|
173
|
-
logger.error(error);
|
|
174
|
-
sendUsageData(
|
|
175
|
-
'Report error',
|
|
176
|
-
`${process.platform}; ${process.arch}; v${appJson?.version}; ${error}`
|
|
177
|
-
);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default {
|
|
181
|
-
disable,
|
|
182
|
-
enable,
|
|
183
|
-
init,
|
|
184
|
-
isEnabled,
|
|
185
|
-
isInitialized,
|
|
186
|
-
reset,
|
|
187
|
-
sendErrorReport,
|
|
188
|
-
sendUsageData,
|
|
189
|
-
};
|
package/src/utils/useHotKey.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2015 Nordic Semiconductor ASA
|
|
3
|
-
*
|
|
4
|
-
* SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { DependencyList, useEffect } from 'react';
|
|
8
|
-
import { useDispatch } from 'react-redux';
|
|
9
|
-
import Mousetrap from 'mousetrap';
|
|
10
|
-
|
|
11
|
-
import { addShortcut, removeShortcut, Shortcut } from '../About/shortcutSlice';
|
|
12
|
-
import { sendUsageData } from './usageData';
|
|
13
|
-
|
|
14
|
-
const useNewHotKey = (shortcut: Shortcut, deps: DependencyList = []) => {
|
|
15
|
-
const dispatch = useDispatch();
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
dispatch(addShortcut(shortcut));
|
|
18
|
-
|
|
19
|
-
Mousetrap.bind(shortcut.hotKey, (_e, combo) => {
|
|
20
|
-
shortcut.action();
|
|
21
|
-
sendUsageData('Pressed hotkey', combo);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return () => {
|
|
25
|
-
dispatch(removeShortcut(shortcut));
|
|
26
|
-
|
|
27
|
-
Mousetrap.unbind(shortcut.hotKey);
|
|
28
|
-
};
|
|
29
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
-
}, deps);
|
|
31
|
-
};
|
|
32
|
-
const useLegacyHotKey = (hotKey: string | string[], action: () => void) => {
|
|
33
|
-
console.warn(
|
|
34
|
-
`Defining a hot key for '${hotKey}' using a legacy API. ` +
|
|
35
|
-
'Please update the app (or tell the app author to update it to ' +
|
|
36
|
-
'the latest API).'
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
useNewHotKey({
|
|
40
|
-
hotKey,
|
|
41
|
-
title: 'Legacy shortcut',
|
|
42
|
-
isGlobal: false,
|
|
43
|
-
action,
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const isUsingLegacyHotkey = (
|
|
48
|
-
args: unknown[]
|
|
49
|
-
): args is Parameters<typeof useLegacyHotKey> =>
|
|
50
|
-
args.length === 2 && typeof args[1] === 'function';
|
|
51
|
-
|
|
52
|
-
export default (
|
|
53
|
-
...args:
|
|
54
|
-
| Parameters<typeof useNewHotKey>
|
|
55
|
-
| Parameters<typeof useLegacyHotKey>
|
|
56
|
-
) => {
|
|
57
|
-
if (isUsingLegacyHotkey(args)) {
|
|
58
|
-
useLegacyHotKey(...args);
|
|
59
|
-
} else {
|
|
60
|
-
useNewHotKey(...args);
|
|
61
|
-
}
|
|
62
|
-
};
|