Execute oxfmt (#1166)

Ran
pnpm oxfmt .

This should get the web repo aligned so that we can better enforce oxfmt going forward.
This commit is contained in:
Austin
2026-06-16 20:30:08 -04:00
committed by GitHub
parent c5690d1edb
commit d2cb51d489
378 changed files with 5548 additions and 1974 deletions
@@ -28,7 +28,9 @@ export interface MeshClientEvents {
export interface MeshClientPort {
readonly events: MeshClientEvents;
setConfig(config: Protobuf.Config.Config): Promise<number>;
setModuleConfig(moduleConfig: Protobuf.ModuleConfig.ModuleConfig): Promise<number>;
setModuleConfig(
moduleConfig: Protobuf.ModuleConfig.ModuleConfig,
): Promise<number>;
beginEditSettings(): Promise<number>;
commitEditSettings(): Promise<number>;
}
+16 -3
View File
@@ -1,3 +1,16 @@
export type { MeshClientEvents, MeshClientPort, Subscribable } from "./client/MeshClientPort.ts";
export { ConfigCommitError, MeshError, toMeshError } from "./errors/MeshError.ts";
export { createStore, type ReadonlySignal, SignalMap, toReadonly } from "./signals/index.ts";
export type {
MeshClientEvents,
MeshClientPort,
Subscribable,
} from "./client/MeshClientPort.ts";
export {
ConfigCommitError,
MeshError,
toMeshError,
} from "./errors/MeshError.ts";
export {
createStore,
type ReadonlySignal,
SignalMap,
toReadonly,
} from "./signals/index.ts";
@@ -33,7 +33,9 @@ export function createStore<T>(initial: T): {
return { write, read: toReadonly(write) };
}
export function toReadonly<T>(s: Signal<T> | PreactReadonlySignal<T>): ReadonlySignal<T> {
export function toReadonly<T>(
s: Signal<T> | PreactReadonlySignal<T>,
): ReadonlySignal<T> {
return {
get value() {
return s.value;
@@ -1 +1,6 @@
export { createStore, type ReadonlySignal, SignalMap, toReadonly } from "./createStore.ts";
export {
createStore,
type ReadonlySignal,
SignalMap,
toReadonly,
} from "./createStore.ts";
@@ -56,13 +56,19 @@ const loraConfig = (hopLimit: number): Protobuf.Config.Config =>
},
});
const lora = (hopLimit: number) => create(Protobuf.Config.Config_LoRaConfigSchema, { hopLimit });
const lora = (hopLimit: number) =>
create(Protobuf.Config.Config_LoRaConfigSchema, { hopLimit });
const trafficModuleConfig = (enabled: boolean): Protobuf.ModuleConfig.ModuleConfig =>
const trafficModuleConfig = (
enabled: boolean,
): Protobuf.ModuleConfig.ModuleConfig =>
create(Protobuf.ModuleConfig.ModuleConfigSchema, {
payloadVariant: {
case: "trafficManagement",
value: create(Protobuf.ModuleConfig.ModuleConfig_TrafficManagementConfigSchema, { enabled }),
value: create(
Protobuf.ModuleConfig.ModuleConfig_TrafficManagementConfigSchema,
{ enabled },
),
},
});
@@ -122,13 +128,19 @@ describe("ConfigEditor (sdk-preview)", () => {
onModuleConfigPacket.emit(trafficModuleConfig(false));
editor.setModuleSection(
"trafficManagement",
create(Protobuf.ModuleConfig.ModuleConfig_TrafficManagementConfigSchema, { enabled: true }),
create(Protobuf.ModuleConfig.ModuleConfig_TrafficManagementConfigSchema, {
enabled: true,
}),
);
expect(editor.dirtyModuleSections.peek()).toEqual(["trafficManagement"]);
const result = await editor.commit();
expect(Result.isError(result)).toBe(false);
expect(calls).toEqual(["begin", "setModuleConfig:trafficManagement", "commit"]);
expect(calls).toEqual([
"begin",
"setModuleConfig:trafficManagement",
"commit",
]);
});
it("reset() discards working edits back to baseline", () => {
@@ -4,14 +4,20 @@ import { Result } from "better-result";
import type { ResultType } from "better-result";
import type { MeshClientPort } from "../../../core/client/MeshClientPort.ts";
import type { MeshError } from "../../../core/errors/MeshError.ts";
import { type ReadonlySignal, toReadonly } from "../../../core/signals/index.ts";
import {
type ReadonlySignal,
toReadonly,
} from "../../../core/signals/index.ts";
import {
beginEditSettings,
commitEditSettings,
setConfig,
setModuleConfig,
} from "../application/ConfigUseCases.ts";
import { buildModuleConfig, buildRadioConfig } from "../infrastructure/configBuilders.ts";
import {
buildModuleConfig,
buildRadioConfig,
} from "../infrastructure/configBuilders.ts";
import { ConfigMapper } from "../infrastructure/ConfigMapper.ts";
import type { ModuleConfig, ModuleConfigSection } from "./ModuleConfig.ts";
import type { RadioConfig, RadioConfigSection } from "./RadioConfig.ts";
@@ -36,18 +42,26 @@ export class ConfigEditor {
private readonly baselineModules = signal<ModuleConfig>({});
private readonly workingRadio = signal<RadioConfig>({});
private readonly workingModules = signal<ModuleConfig>({});
private readonly _dirtyRadioSections = signal<readonly RadioConfigSection[]>([]);
private readonly _dirtyModuleSections = signal<readonly ModuleConfigSection[]>([]);
private readonly _dirtyRadioSections = signal<readonly RadioConfigSection[]>(
[],
);
private readonly _dirtyModuleSections = signal<
readonly ModuleConfigSection[]
>([]);
private readonly _isDirty = signal<boolean>(false);
public readonly radio: ReadonlySignal<RadioConfig> = toReadonly(this.workingRadio);
public readonly modules: ReadonlySignal<ModuleConfig> = toReadonly(this.workingModules);
public readonly dirtyRadioSections: ReadonlySignal<readonly RadioConfigSection[]> = toReadonly(
this._dirtyRadioSections,
public readonly radio: ReadonlySignal<RadioConfig> = toReadonly(
this.workingRadio,
);
public readonly dirtyModuleSections: ReadonlySignal<readonly ModuleConfigSection[]> = toReadonly(
this._dirtyModuleSections,
public readonly modules: ReadonlySignal<ModuleConfig> = toReadonly(
this.workingModules,
);
public readonly dirtyRadioSections: ReadonlySignal<
readonly RadioConfigSection[]
> = toReadonly(this._dirtyRadioSections);
public readonly dirtyModuleSections: ReadonlySignal<
readonly ModuleConfigSection[]
> = toReadonly(this._dirtyModuleSections);
public readonly isDirty: ReadonlySignal<boolean> = toReadonly(this._isDirty);
constructor(client: MeshClientPort) {
@@ -61,19 +75,28 @@ export class ConfigEditor {
// Apply the baseline update to the working copy only if the user hasn't
// already edited this section — their in-flight edit wins.
if (!this._dirtyRadioSections.peek().includes(variant)) {
this.workingRadio.value = { ...this.workingRadio.peek(), [variant]: next[variant] };
this.workingRadio.value = {
...this.workingRadio.peek(),
[variant]: next[variant],
};
}
}
this.recomputeDirty();
});
client.events.onModuleConfigPacket.subscribe((moduleConfig) => {
const next = ConfigMapper.mergeModule(this.baselineModules.peek(), moduleConfig);
const next = ConfigMapper.mergeModule(
this.baselineModules.peek(),
moduleConfig,
);
this.baselineModules.value = next;
const variant = moduleConfig.payloadVariant.case;
if (variant) {
if (!this._dirtyModuleSections.peek().includes(variant)) {
this.workingModules.value = { ...this.workingModules.peek(), [variant]: next[variant] };
this.workingModules.value = {
...this.workingModules.peek(),
[variant]: next[variant],
};
}
}
this.recomputeDirty();
@@ -137,7 +160,10 @@ export class ConfigEditor {
if (value === undefined) {
continue;
}
const result = await setConfig(this.client, buildRadioConfig(section, value));
const result = await setConfig(
this.client,
buildRadioConfig(section, value),
);
if (Result.isError(result)) {
return Result.err(result.error);
}
@@ -149,7 +175,10 @@ export class ConfigEditor {
if (value === undefined) {
continue;
}
const result = await setModuleConfig(this.client, buildModuleConfig(section, value));
const result = await setModuleConfig(
this.client,
buildModuleConfig(section, value),
);
if (Result.isError(result)) {
return Result.err(result.error);
}
@@ -172,7 +201,10 @@ export class ConfigEditor {
const radioBase = this.baselineRadio.peek();
const radioWorking = this.workingRadio.peek();
const radioDirty: RadioConfigSection[] = [];
for (const key of new Set<string>([...Object.keys(radioBase), ...Object.keys(radioWorking)])) {
for (const key of new Set<string>([
...Object.keys(radioBase),
...Object.keys(radioWorking),
])) {
const section = key as RadioConfigSection;
if (!shallowEqual(radioBase[section], radioWorking[section])) {
radioDirty.push(section);
@@ -1,4 +1,7 @@
export { ConfigEditor } from "./domain/ConfigEditor.ts";
export type { ModuleConfig, ModuleConfigSection } from "./domain/ModuleConfig.ts";
export type {
ModuleConfig,
ModuleConfigSection,
} from "./domain/ModuleConfig.ts";
export type { RadioConfig, RadioConfigSection } from "./domain/RadioConfig.ts";
export { ConfigMapper } from "./infrastructure/ConfigMapper.ts";
@@ -8,7 +8,10 @@ import type { RadioConfig } from "../domain/RadioConfig.ts";
* with no code change, exactly like the SDK mapper in PR #1050.
*/
export const ConfigMapper = {
mergeRadio(existing: RadioConfig, incoming: Protobuf.Config.Config): RadioConfig {
mergeRadio(
existing: RadioConfig,
incoming: Protobuf.Config.Config,
): RadioConfig {
const variant = incoming.payloadVariant;
if (!variant.case) {
return existing;
@@ -16,7 +19,10 @@ export const ConfigMapper = {
return { ...existing, [variant.case]: variant.value };
},
mergeModule(existing: ModuleConfig, incoming: Protobuf.ModuleConfig.ModuleConfig): ModuleConfig {
mergeModule(
existing: ModuleConfig,
incoming: Protobuf.ModuleConfig.ModuleConfig,
): ModuleConfig {
const variant = incoming.payloadVariant;
if (!variant.case) {
return existing;
@@ -1,6 +1,9 @@
import { create } from "@bufbuild/protobuf";
import { Protobuf } from "@meshtastic/core";
import type { ModuleConfig, ModuleConfigSection } from "../domain/ModuleConfig.ts";
import type {
ModuleConfig,
ModuleConfigSection,
} from "../domain/ModuleConfig.ts";
import type { RadioConfig, RadioConfigSection } from "../domain/RadioConfig.ts";
/** Wrap a single radio-config section value back into a `Config` message. */
@@ -9,7 +12,10 @@ export function buildRadioConfig<K extends RadioConfigSection>(
value: NonNullable<RadioConfig[K]>,
): Protobuf.Config.Config {
return create(Protobuf.Config.ConfigSchema, {
payloadVariant: { case: section, value } as Protobuf.Config.Config["payloadVariant"],
payloadVariant: {
case: section,
value,
} as Protobuf.Config.Config["payloadVariant"],
});
}
+4 -1
View File
@@ -7,6 +7,9 @@ export type {
RadioConfig,
RadioConfigSection,
} from "./features/config/index.ts";
export { getConfigEditor, meshDeviceToPort } from "./adapters/fromMeshDevice.ts";
export {
getConfigEditor,
meshDeviceToPort,
} from "./adapters/fromMeshDevice.ts";
export { useConfigEditor } from "./react/useConfigEditor.ts";
export { useSignal } from "./react/useSignal.ts";