@nordicsemiconductor/pc-nrfconnect-shared 263.0.0 → 265.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.
Files changed (46) hide show
  1. package/Changelog.md +72 -25
  2. package/config/eslintrc.js +2 -1
  3. package/config/jest.config.js +1 -1
  4. package/config/tsconfig.json +2 -2
  5. package/config/versions.test.ts +115 -0
  6. package/config/versions.ts +53 -0
  7. package/dist/scripts/nordic-publish.js +21 -19
  8. package/dist/typings/config/versions.d.ts +17 -0
  9. package/dist/typings/config/versions.d.ts.map +1 -0
  10. package/dist/typings/ipc/device.d.ts +1 -1
  11. package/dist/typings/ipc/schema/packageJson.d.ts +9 -9
  12. package/dist/typings/nrfutil/fs.d.ts +1 -1
  13. package/dist/typings/nrfutil/fs.d.ts.map +1 -1
  14. package/dist/typings/scripts/check-app-properties.d.ts.map +1 -1
  15. package/dist/typings/scripts/esbuild-renderer.d.ts +2 -1
  16. package/dist/typings/scripts/esbuild-renderer.d.ts.map +1 -1
  17. package/dist/typings/scripts/set-minimal-launcher.d.ts +3 -0
  18. package/dist/typings/scripts/set-minimal-launcher.d.ts.map +1 -0
  19. package/dist/typings/src/utils/packageJson.d.ts +2 -2
  20. package/ipc/device.ts +1 -1
  21. package/nrfutil/fs.ts +3 -3
  22. package/nrfutil/sandbox.ts +4 -4
  23. package/package.json +9 -4
  24. package/release_notes.md +8 -1
  25. package/scripts/build-app.ts +16 -3
  26. package/scripts/build-shared.ts +2 -1
  27. package/scripts/check-app-properties.ts +40 -6
  28. package/scripts/check-for-typescript.ts +2 -2
  29. package/scripts/check-versions.ts +53 -39
  30. package/scripts/esbuild-renderer.ts +10 -4
  31. package/scripts/installHusky.ts +1 -1
  32. package/scripts/nordic-publish.ts +2 -2
  33. package/scripts/nrfconnect-license.ts +1 -1
  34. package/scripts/set-minimal-launcher.ts +153 -0
  35. package/src/Device/deviceInfo/deviceInfo.ts +2 -2
  36. package/src/Device/sdfuOperations.ts +2 -2
  37. package/src/Parsers/shellParser.ts +1 -1
  38. package/src/SerialPort/SerialPort.ts +1 -1
  39. package/src/logging/index.ts +1 -1
  40. package/src/utils/appDirs.ts +1 -1
  41. package/src/utils/systemReport.ts +3 -3
  42. package/src/utils/udevInstalled.ts +1 -1
  43. package/test/setupTests.ts +1 -1
  44. package/dist/typings/scripts/versions.d.ts +0 -5
  45. package/dist/typings/scripts/versions.d.ts.map +0 -1
  46. package/scripts/versions.ts +0 -12
@@ -12,9 +12,10 @@ import postCssPlugin from 'esbuild-style-plugin';
12
12
  import * as fs from 'node:fs';
13
13
  import * as module from 'node:module';
14
14
  import * as path from 'node:path';
15
+ import { type SemVer } from 'semver';
15
16
  import tailwindcss from 'tailwindcss';
16
17
 
17
- import { chromeToBuildFor } from './versions';
18
+ import { versionsForLauncherVersion } from '../config/versions';
18
19
 
19
20
  const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
20
21
 
@@ -32,12 +33,13 @@ const tailwindConfig = () =>
32
33
  type AdditionalOptions = Partial<BuildOptions>;
33
34
 
34
35
  const options = (
36
+ targetLauncherVersion: string | SemVer,
35
37
  additionalOptions: AdditionalOptions,
36
38
  externalReact: boolean,
37
39
  ) =>
38
40
  ({
39
41
  format: 'iife',
40
- target: `chrome${chromeToBuildFor}`,
42
+ target: `chrome${versionsForLauncherVersion(targetLauncherVersion).chrome}`,
41
43
  sourcemap: true,
42
44
  metafile: false,
43
45
  minify: process.argv.includes('--prod'),
@@ -45,6 +47,7 @@ const options = (
45
47
  logLevel: 'info',
46
48
  external: [
47
49
  ...module.builtinModules,
50
+ 'node:*',
48
51
 
49
52
  // launcher includes
50
53
  'electron',
@@ -120,17 +123,20 @@ const options = (
120
123
  }) satisfies BuildOptions;
121
124
 
122
125
  export const build = async (
126
+ targetLauncherVersion: string | SemVer,
123
127
  additionalOptions: AdditionalOptions,
124
128
  { externalReact = false } = {},
125
129
  ) => {
126
130
  if (process.argv.includes('--watch')) {
127
131
  const context = await esbuild.context(
128
- options(additionalOptions, externalReact),
132
+ options(targetLauncherVersion, additionalOptions, externalReact),
129
133
  );
130
134
 
131
135
  await context.rebuild();
132
136
  await context.watch();
133
137
  } else {
134
- return esbuild.build(options(additionalOptions, externalReact));
138
+ return esbuild.build(
139
+ options(targetLauncherVersion, additionalOptions, externalReact),
140
+ );
135
141
  }
136
142
  };
@@ -6,8 +6,8 @@
6
6
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
7
7
  */
8
8
 
9
- import { existsSync } from 'fs';
10
9
  import { install as installHusky } from 'husky';
10
+ import { existsSync } from 'node:fs';
11
11
 
12
12
  if (existsSync('.git')) {
13
13
  installHusky();
@@ -8,10 +8,10 @@
8
8
 
9
9
  /* eslint-disable max-classes-per-file, class-methods-use-this */
10
10
 
11
- import { execSync } from 'child_process';
12
11
  import { Option, program } from 'commander';
13
- import fs from 'fs';
14
12
  import LowlevelFtpClient from 'ftp';
13
+ import { execSync } from 'node:child_process';
14
+ import fs from 'node:fs';
15
15
  import semver from 'semver';
16
16
  import calculateShasum from 'shasum';
17
17
 
@@ -7,7 +7,7 @@
7
7
  */
8
8
 
9
9
  import glob from 'fast-glob';
10
- import { existsSync, readFileSync, writeFileSync } from 'fs';
10
+ import { existsSync, readFileSync, writeFileSync } from 'node:fs';
11
11
 
12
12
  const SHEBANG_LINE = /^#!.*?(\r?\n)+/;
13
13
  const SPECIAL_REGEXP_CHARACTERS = /([.*+\\(){}[\]])/g;
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env tsx
2
+
3
+ /*
4
+ * Copyright (c) 2026 Nordic Semiconductor ASA
5
+ *
6
+ * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
7
+ */
8
+
9
+ import { green, red } from 'chalk';
10
+ import { execSync } from 'node:child_process';
11
+ import { readFileSync } from 'node:fs';
12
+ import semver from 'semver';
13
+
14
+ import {
15
+ minimalLauncherVersion,
16
+ versionsForLauncherVersion,
17
+ } from '../config/versions';
18
+ import { type PackageJsonApp } from '../ipc/schema/packageJson';
19
+
20
+ const packageJson: PackageJsonApp = JSON.parse(
21
+ readFileSync('./package.json', 'utf-8'),
22
+ );
23
+
24
+ const info = (message: string) => console.log(`${green('➜')} ${message}`);
25
+
26
+ function fail(message: string): never {
27
+ console.error(`${red('x')} ${message}`);
28
+ process.exit(1);
29
+ }
30
+
31
+ const npm = (args: string, { showOutput = false } = {}) =>
32
+ execSync(`npm ${args}`, {
33
+ encoding: 'utf-8',
34
+ stdio: ['ignore', showOutput ? 'inherit' : 'pipe', 'inherit'],
35
+ });
36
+
37
+ const assertCurrentLauncherVersionIsValid = () => {
38
+ const currentLauncherVersion = packageJson.engines?.nrfconnect;
39
+
40
+ if (currentLauncherVersion == null) {
41
+ fail(
42
+ 'The property `engines.nrfconnect` must already be defined in package.json.',
43
+ );
44
+ }
45
+
46
+ if (semver.minVersion(currentLauncherVersion)?.version == null) {
47
+ fail(
48
+ `Unable to determine a launcher version from \`engines.nrfconnect\` being '${currentLauncherVersion}'.`,
49
+ );
50
+ }
51
+ };
52
+
53
+ const currentLauncherVersion = () => {
54
+ assertCurrentLauncherVersionIsValid();
55
+
56
+ // Type assertion in the next line is safe because we have already validated it above.
57
+ return semver.minVersion(packageJson.engines.nrfconnect)?.version as string;
58
+ };
59
+
60
+ const newLauncherVersion = () =>
61
+ semver.valid(requestedLauncherVersion) ?? currentLauncherVersion();
62
+
63
+ const maybePrintUsageAndExit = () => {
64
+ if (
65
+ requestedLauncherVersion == null ||
66
+ semver.valid(requestedLauncherVersion)
67
+ ) {
68
+ return;
69
+ }
70
+
71
+ console.log(`Usage: set-minimal-launcher [version]
72
+
73
+ Sets the minimal launcher version the app requires and installs the matching
74
+ Electron version as a dev dependency.
75
+
76
+ Arguments:
77
+ version Minimal launcher version, e.g. 5.2.1. Sets \`engines.nrfconnect\`
78
+ in package.json to \`>=<version>\`. If omitted, the version
79
+ already in \`engines.nrfconnect\` is used.
80
+
81
+ Options:
82
+ -h, --help Print this help message.`);
83
+
84
+ const askedForHelp =
85
+ process.argv.includes('-h') || process.argv.includes('--help');
86
+ process.exit(askedForHelp ? 0 : 1);
87
+ };
88
+
89
+ const setLauncherInPackageJson = () => {
90
+ if (semver.lt(newLauncherVersion(), minimalLauncherVersion)) {
91
+ fail(
92
+ `This version of shared requires at least launcher version ${minimalLauncherVersion} but the launcher version ${newLauncherVersion()} was requested.`,
93
+ );
94
+ }
95
+
96
+ if (requestedLauncherVersion == null) {
97
+ info(
98
+ `Using launcher version ${currentLauncherVersion()} from \`engines.nrfconnect\` in package.json.`,
99
+ );
100
+ } else if (currentLauncherVersion() === newLauncherVersion()) {
101
+ info(
102
+ `\`engines.nrfconnect\` in package.json is already '${newLauncherVersion()}'.`,
103
+ );
104
+ } else {
105
+ npm(`pkg set engines.nrfconnect=">=${newLauncherVersion()}"`);
106
+ info(
107
+ `Changed \`engines.nrfconnect\` in package.json from '${currentLauncherVersion()}' to '${newLauncherVersion()}'.`,
108
+ );
109
+ }
110
+ };
111
+
112
+ const currentElectronVersion = () => packageJson.devDependencies?.electron;
113
+
114
+ const newElectronVersion = () => {
115
+ try {
116
+ return versionsForLauncherVersion(newLauncherVersion()).electron;
117
+ } catch {
118
+ fail(
119
+ `Unable to determine Electron version for launcher version '${newLauncherVersion()}'.`,
120
+ );
121
+ }
122
+ };
123
+
124
+ const installElectron = () => {
125
+ if (currentElectronVersion() === newElectronVersion()) {
126
+ info(
127
+ `Electron ${newElectronVersion()} is already installed as a dev dependency.`,
128
+ );
129
+ return;
130
+ }
131
+
132
+ info(
133
+ `Installing Electron ${newElectronVersion()} as a dev dependency (before: ${currentElectronVersion() ?? 'none'}).`,
134
+ );
135
+ npm(`install --save-dev --save-exact electron@${newElectronVersion()}`, {
136
+ showOutput: true,
137
+ });
138
+ };
139
+
140
+ const main = () => {
141
+ maybePrintUsageAndExit();
142
+
143
+ assertCurrentLauncherVersionIsValid();
144
+
145
+ setLauncherInPackageJson();
146
+ installElectron();
147
+ };
148
+
149
+ const requestedLauncherVersion: string | undefined = process.argv[2];
150
+ const isRanAsAScript = require.main === module; // https://nodejs.org/docs/latest/api/modules.html#accessing-the-main-module
151
+ if (isRanAsAScript) {
152
+ main();
153
+ }
@@ -229,7 +229,7 @@ const devicesByPca: { [P in KnownDevicePCA]: DeviceInfo } = {
229
229
  icon: nrf91logo,
230
230
  website: {},
231
231
  },
232
- PCA20049: {
232
+ PCA20065: {
233
233
  name: 'Nordic Thingy:91 X',
234
234
  cores: 1,
235
235
  icon: nrf91logo,
@@ -403,7 +403,7 @@ const deviceByUsb = (device: Device) => {
403
403
  return devicesByPca.PCA20053;
404
404
  }
405
405
  if (device.serialNumber?.startsWith('THINGY91X')) {
406
- return devicesByPca.PCA20049;
406
+ return devicesByPca.PCA20065;
407
407
  }
408
408
  if (device.serialNumber?.startsWith('THINGY91')) {
409
409
  return devicesByPca.PCA20035;
@@ -5,8 +5,8 @@
5
5
  */
6
6
 
7
7
  import AdmZip from 'adm-zip';
8
- import { createHash } from 'crypto';
9
- import fs from 'fs';
8
+ import { createHash } from 'node:crypto';
9
+ import fs from 'node:fs';
10
10
  import MemoryMap from 'nrf-intel-hex';
11
11
 
12
12
  import NrfutilDeviceLib from '../../nrfutil/device/device';
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { type Terminal } from '@xterm/headless';
8
- import EventEmitter from 'events';
8
+ import EventEmitter from 'node:events';
9
9
 
10
10
  import logger from '../logging';
11
11
  import { type SerialPort } from '../SerialPort/SerialPort';
@@ -9,7 +9,7 @@ import type {
9
9
  SetOptions,
10
10
  UpdateOptions,
11
11
  } from '@serialport/bindings-cpp';
12
- import EventEmitter from 'events';
12
+ import EventEmitter from 'node:events';
13
13
  import type { SerialPortOpenOptions } from 'serialport';
14
14
 
15
15
  import { forMain, inMain, type OverwriteOptions } from '../../ipc/serialPort';
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
- import path from 'path';
7
+ import path from 'node:path';
8
8
  import { SPLAT } from 'triple-beam';
9
9
  import {
10
10
  createLogger,
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
- import path from 'path';
7
+ import path from 'node:path';
8
8
 
9
9
  import launcherConfig from './launcherConfig';
10
10
  import { packageJsonApp } from './packageJson';
@@ -4,9 +4,9 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
- import fs from 'fs';
8
- import { EOL } from 'os';
9
- import path from 'path';
7
+ import fs from 'node:fs';
8
+ import { EOL } from 'node:os';
9
+ import path from 'node:path';
10
10
  import pretty from 'prettysize';
11
11
  import si from 'systeminformation';
12
12
 
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
5
  */
6
6
 
7
- import { execSync } from 'child_process';
7
+ import { execSync } from 'node:child_process';
8
8
 
9
9
  export default () => {
10
10
  if (process.platform !== 'linux') {
@@ -23,7 +23,7 @@ if (
23
23
  typeof globalThis.TextDecoder === 'undefined'
24
24
  ) {
25
25
  // eslint-disable-next-line global-require, @typescript-eslint/no-require-imports
26
- const utils = require('util');
26
+ const utils = require('node:util');
27
27
  globalThis.TextEncoder = utils.TextEncoder;
28
28
  globalThis.TextDecoder = utils.TextDecoder;
29
29
  }
@@ -1,5 +0,0 @@
1
- export declare const electron = "43.8.6";
2
- export declare const chrome = "150.0.7871.250";
3
- export declare const node = "24.22.1";
4
- export declare const chromeToBuildFor = "128.0.6613";
5
- //# sourceMappingURL=versions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"versions.d.ts","sourceRoot":"","sources":["../../../scripts/versions.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ,WAAW,CAAC;AACjC,eAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,eAAO,MAAM,IAAI,YAAY,CAAC;AAG9B,eAAO,MAAM,gBAAgB,eAAe,CAAC"}
@@ -1,12 +0,0 @@
1
- /*
2
- * Copyright (c) 2025 Nordic Semiconductor ASA
3
- *
4
- * SPDX-License-Identifier: LicenseRef-Nordic-4-Clause
5
- */
6
-
7
- export const electron = '43.8.6';
8
- export const chrome = '150.0.7871.250';
9
- export const node = '24.22.1';
10
-
11
- // Chrome from Electron 32, used in launcher >=5.1.0, <5.4.0
12
- export const chromeToBuildFor = '128.0.6613';