Skip to content

Commit

Permalink
Updated plan and fixed some spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
6XGate committed Nov 17, 2024
1 parent 1984752 commit 0d5d3d2
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
3 changes: 2 additions & 1 deletion PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
- 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.
- Monoprice Blackbird
- 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.
Expand Down
10 changes: 5 additions & 5 deletions src/core/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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. */
Expand All @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/services/drivers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
4 changes: 2 additions & 2 deletions src/main/services/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -93,7 +93,7 @@ export const useLevelAdapter = memo(function useLevelAdapter() {
/** @type {PouchDB.Plugin<PouchDB.Static>} */
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)
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/services/ports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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, ' ')
Expand Down
7 changes: 3 additions & 4 deletions src/main/services/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<TcpNetConnectOpts, 'host' | 'port'>

Expand Down Expand Up @@ -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`)
}
Expand Down Expand Up @@ -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')
}
14 changes: 7 additions & 7 deletions src/main/services/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const useUpdater = memo(function useUpdater() {
class AppUpdater extends EventEmitter<AppUpdaterEventMap> {
#checkPromise: Promise<UpdateCheckResult | null> | undefined = undefined
#cancelToken: CancellationToken | undefined = undefined
#donwloadPromise: Promise<string[]> | undefined = undefined
#downloadPromise: Promise<string[]> | undefined = undefined

constructor() {
super()
Expand Down Expand Up @@ -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
}
Expand All @@ -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'))
}

Expand Down Expand Up @@ -124,17 +124,17 @@ 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
}
}

async downloadUpdate() {
if (this.#donwloadPromise != null) {
await this.#donwloadPromise
if (this.#downloadPromise != null) {
await this.#downloadPromise
} else {
await this.attemptDownloadUpdate()
}
Expand Down

0 comments on commit 0d5d3d2

Please sign in to comment.