diff --git a/PLAN.md b/PLAN.md index 7a9a8af..b4d676c 100644 --- a/PLAN.md +++ b/PLAN.md @@ -6,6 +6,7 @@ - Determine which drivers are being using by the public at large to remove the experimental mark; options: - Add a opt-in telemetry feature to see which drivers are being used, should be an ask to send survey sort of thing. - Ask users to submit survey somewhere, likely with a pop-up in the app to the direct them to the survey. + - Add test coverage for stream and updater. - Add test coverage for some rendering process parts. - Import and export. - More drivers. @@ -13,7 +14,7 @@ - v3.0 - (#92) Remote UI support - Need settings toggle to control it's activation. - - Need security or authentication method, preferrably just a PIN code. + - Need security or authentication method, preferably just a PIN code. - Need a means to identify it's URL via the local UI. - May need a way to disable the power-off button in the remote UI. - Possible move to 64-bit ARM. diff --git a/src/core/location.ts b/src/core/location.ts index 278fe3f..13d6d8b 100644 --- a/src/core/location.ts +++ b/src/core/location.ts @@ -30,7 +30,7 @@ export function isValidLocation(value: string, ports: readonly PortInfo[]) { // #region Host and Port -const hostWithOptionalPortPattern = /^((?:\[[A-Fa-f0-9.:]+\])|(?:[\p{N}\p{L}.-]+))(?::([1-9][0-9]*))?$/u +export const hostWithOptionalPortPattern = /^((?:\[[A-Fa-f0-9.:]+\])|(?:[\p{N}\p{L}.-]+))(?::([1-9][0-9]*))?$/u function zodParseHostWithOptionalPort(value: string) { const match = hostWithOptionalPortPattern.exec(value) @@ -85,7 +85,7 @@ export const hostSchema = z.string().refine(isHost) ``` Fully rendered in hostNamePattern, with non-capture groups - to capturing converted for better readibility. + to capturing converted for better readability. */ const hostNamePattern = /^[\p{N}\p{L}]([\p{N}\p{L}-]*[\p{N}\p{L}])?(\.[\p{N}\p{L}]([\p{N}\p{L}-]*[\p{N}\p{L}])?)*$/u /** Determines whether a string is a hostname. */ @@ -95,7 +95,7 @@ export const hostNameSchema = z.string().regex(hostNamePattern) // #region IPv4 /** - Zod's IP pattern allows some invalid address strings, suchs as double-zero, `00`. + Zod's IP pattern allows some invalid address strings, such as double-zero, `00`. These days IPv4 is generally always in decimal, not octal. It seems Zod was aiming for this. With this in mind, the definition is as follows. @@ -118,7 +118,7 @@ export const ipV4AddressSchema = z.string().regex(ipV4Pattern) /** Zod's IPv6 pattern allows a lot of invalid and misses some valid addresses. See {@link https://github.com/colinhacks/zod/issues/2339}. - The RFCs seems indicate the following battern. + The RFCs seems indicate the following pattern. IPv6 @@ -172,7 +172,7 @@ function parsePossibleIpString(value: string) { parts.pop() } - // Split if compact. Will only preduce one or two results. + // Split if compact. Will only produce one or two results. const sep = parts.indexOf('') if (sep >= 0) { // We add a zero to the second array to simply compact form logic. diff --git a/src/main/index.ts b/src/main/index.ts index 05a9864..28ff8f0 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -1,7 +1,7 @@ import { app } from 'electron' import unhandled from 'electron-unhandled' -// Activate the unhandle handler... +// Activate the unhandled handler... unhandled() async function main() { diff --git a/src/main/services/drivers.ts b/src/main/services/drivers.ts index ce187cf..8101d5e 100644 --- a/src/main/services/drivers.ts +++ b/src/main/services/drivers.ts @@ -27,7 +27,7 @@ export type DriverKind = 'monitor' | 'switch' export interface DriverBasicInformation { /** * Indicates whether the driver is enabled, this is to allow partially coded drivers to be - * commited, but not usable to the UI or other code. + * committed, but not usable to the UI or other code. */ readonly enabled: boolean /** Indicates whether the driver is experimental, usually due to lack of testing. */ diff --git a/src/main/services/level.js b/src/main/services/level.js index d6dce22..1723aa1 100644 --- a/src/main/services/level.js +++ b/src/main/services/level.js @@ -80,7 +80,7 @@ export const useLevelAdapter = memo(function useLevelAdapter() { * @param {ErrorCallback} cb */ function MainDown(opts, cb) { - // eslint-disable-next-line -- Eveything is messed up with no typings. + // eslint-disable-next-line -- Everything is messed up with no typings. LevelPouch.call(this, { ...opts, db: leveldown }, cb) } @@ -93,7 +93,7 @@ export const useLevelAdapter = memo(function useLevelAdapter() { /** @type {PouchDB.Plugin} */ const plugin = (pouch) => { // @ts-expect-error -- Not defined in the types. - // eslint-disable-next-line -- Eveything is messed up with no typings. + // eslint-disable-next-line -- Everything is messed up with no typings. pouch.adapter('maindb', MainDown, true) } diff --git a/src/main/services/ports.ts b/src/main/services/ports.ts index bd8443e..c27efe2 100644 --- a/src/main/services/ports.ts +++ b/src/main/services/ports.ts @@ -32,7 +32,7 @@ const useSerialPorts = memo(function useSerialPorts() { // If there is no pnpId; don't cache the name, // it's less costly by avoiding the map // lookup. We will still key on the - // manufacturer for wierd PnP IDs. + // manufacturer for weird PnP IDs. return is.nonEmptyStringAndNotWhitespace(manufacturer) ? manufacturer : path } @@ -82,7 +82,7 @@ const useSerialPorts = memo(function useSerialPorts() { return is.nonEmptyStringAndNotWhitespace(manufacturer) ? manufacturer : path } - // Now, rejoin the label by hypens, in case + // Now, rejoin the label by hyphens, in case // those were in the friendly name, and // replace underscores with spaces. title = labelParts.join('-').replace(/_/gu, ' ') diff --git a/src/main/services/stream.ts b/src/main/services/stream.ts index a1b7663..0f7d968 100644 --- a/src/main/services/stream.ts +++ b/src/main/services/stream.ts @@ -6,6 +6,7 @@ import type { Socket, NetConnectOpts, TcpNetConnectOpts } from 'node:net' import type { Duplex } from 'node:stream' import type { Simplify } from 'type-fest' import { toError } from '@/error-handling' +import { hostWithOptionalPortPattern } from '@/location' export type NetStreamOptions = Omit @@ -84,10 +85,8 @@ async function createSocketStream(options: NetConnectOpts) { return createStream(socket, { close }) } -const kHostWithOptionalPort = /^((?:\[[A-Fa-f0-9.:]+\])|(?:[\p{N}\p{L}.-]+))(?::([1-9][0-9]*))?$/u - async function createNetStream(target: string, options: NetStreamOptions) { - const parts = kHostWithOptionalPort.exec(target) + const parts = hostWithOptionalPortPattern.exec(target) if (parts?.[1] == null) { throw new Error(`target "${target}" is not a valid host or host:port combination`) } @@ -137,5 +136,5 @@ export async function createCommandStream(path: string, options: CommandStreamOp return await createNetStream(path.substring(3), options as NetStreamOptions) } - throw new TypeError('Unsupport stream address') + throw new TypeError('Unsupported stream address') } diff --git a/src/main/services/updater.ts b/src/main/services/updater.ts index 5bdcc81..a024f83 100644 --- a/src/main/services/updater.ts +++ b/src/main/services/updater.ts @@ -38,7 +38,7 @@ const useUpdater = memo(function useUpdater() { class AppUpdater extends EventEmitter { #checkPromise: Promise | undefined = undefined #cancelToken: CancellationToken | undefined = undefined - #donwloadPromise: Promise | undefined = undefined + #downloadPromise: Promise | undefined = undefined constructor() { super() @@ -75,7 +75,7 @@ const useUpdater = memo(function useUpdater() { throw cause } - // If the result is null or the cancel token is null, no update is avilable. + // If the result is null or the cancel token is null, no update is available. if (result?.cancellationToken == null) { return null } @@ -86,7 +86,7 @@ const useUpdater = memo(function useUpdater() { } private async attemptCheckForUpdates() { - if (this.#donwloadPromise != null) { + if (this.#downloadPromise != null) { throw logError(new ReferenceError('Update download already in progress')) } @@ -124,8 +124,8 @@ const useUpdater = memo(function useUpdater() { } try { autoUpdater.on('download-progress', handleProgress) - this.#donwloadPromise = autoUpdater.downloadUpdate(this.#cancelToken) - await this.#donwloadPromise + this.#downloadPromise = autoUpdater.downloadUpdate(this.#cancelToken) + await this.#downloadPromise } finally { autoUpdater.off('download-progress', handleProgress) this.#cancelToken = undefined @@ -133,8 +133,8 @@ const useUpdater = memo(function useUpdater() { } async downloadUpdate() { - if (this.#donwloadPromise != null) { - await this.#donwloadPromise + if (this.#downloadPromise != null) { + await this.#downloadPromise } else { await this.attemptDownloadUpdate() }