🔨 Adds build script for ts proto

This commit is contained in:
Rune Harlyk
2026-01-03 15:11:41 +01:00
committed by nikguin04
parent 6a117ac5e3
commit 585adaf28f
4 changed files with 560 additions and 2635 deletions
+3 -1
View File
@@ -5,6 +5,7 @@
"scripts": {
"dev": "vite dev --host",
"build": "vite build",
"build:proto": "pnpm proto && vite build",
"build:embedded": "cross-env VITE_USE_HOST_NAME=true vite build",
"preview": "vite preview",
"test": "pnpm run test:integration && pnpm run test:unit",
@@ -13,7 +14,8 @@
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"test:integration": "playwright test",
"test:unit": "vitest"
"test:unit": "vitest",
"proto": "protoc --plugin=protoc-gen-ts_proto=.\\node_modules\\.bin\\protoc-gen-ts_proto.cmd --ts_proto_out=./src/lib/platform_shared --ts_proto_opt=outputTypeAnnotations=true,useExactTypes=false,outputExtensions=true,outputTypeRegistry=true -I ../platform_shared ../platform_shared/websocket_message.proto ../platform_shared/rest_message.proto"
},
"devDependencies": {
"@eslint/js": "^9.39.2",
+29 -262
View File
@@ -1,17 +1,18 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.10.1
// protoc v6.33.2
// protoc v3.20.3
// source: rest_message.proto
/* eslint-disable */
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
import type { FileDescriptorProto } from "ts-proto-descriptors";
import { KnownNetworkItem, protoMetadata as protoMetadata1 } from "./websocket_message";
import { messageTypeRegistry } from "./typeRegistry";
import { KnownNetworkItem } from "./websocket_message";
export const protobufPackage = "rest_message";
export interface WifiStatus {
$type: "rest_message.WifiStatus";
status: number;
localIp: string;
macAddress: string;
@@ -26,6 +27,7 @@ export interface WifiStatus {
}
export interface WifiSettings {
$type: "rest_message.WifiSettings";
hostname: string;
priorityRssi: boolean;
wifiNetworks: KnownNetworkItem[];
@@ -33,6 +35,7 @@ export interface WifiSettings {
function createBaseWifiStatus(): WifiStatus {
return {
$type: "rest_message.WifiStatus",
status: 0,
localIp: "",
macAddress: "",
@@ -47,7 +50,9 @@ function createBaseWifiStatus(): WifiStatus {
};
}
export const WifiStatus: MessageFns<WifiStatus> = {
export const WifiStatus: MessageFns<WifiStatus, "rest_message.WifiStatus"> = {
$type: "rest_message.WifiStatus" as const,
encode(message: WifiStatus, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.status !== 0) {
writer.uint32(8).int32(message.status);
@@ -191,6 +196,7 @@ export const WifiStatus: MessageFns<WifiStatus> = {
fromJSON(object: any): WifiStatus {
return {
$type: WifiStatus.$type,
status: isSet(object.status) ? globalThis.Number(object.status) : 0,
localIp: isSet(object.localIp) ? globalThis.String(object.localIp) : "",
macAddress: isSet(object.macAddress) ? globalThis.String(object.macAddress) : "",
@@ -243,10 +249,10 @@ export const WifiStatus: MessageFns<WifiStatus> = {
return obj;
},
create<I extends Exact<DeepPartial<WifiStatus>, I>>(base?: I): WifiStatus {
return WifiStatus.fromPartial(base ?? ({} as any));
create(base?: DeepPartial<WifiStatus>): WifiStatus {
return WifiStatus.fromPartial(base ?? {});
},
fromPartial<I extends Exact<DeepPartial<WifiStatus>, I>>(object: I): WifiStatus {
fromPartial(object: DeepPartial<WifiStatus>): WifiStatus {
const message = createBaseWifiStatus();
message.status = object.status ?? 0;
message.localIp = object.localIp ?? "";
@@ -263,11 +269,15 @@ export const WifiStatus: MessageFns<WifiStatus> = {
},
};
messageTypeRegistry.set(WifiStatus.$type, WifiStatus);
function createBaseWifiSettings(): WifiSettings {
return { hostname: "", priorityRssi: false, wifiNetworks: [] };
return { $type: "rest_message.WifiSettings", hostname: "", priorityRssi: false, wifiNetworks: [] };
}
export const WifiSettings: MessageFns<WifiSettings> = {
export const WifiSettings: MessageFns<WifiSettings, "rest_message.WifiSettings"> = {
$type: "rest_message.WifiSettings" as const,
encode(message: WifiSettings, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
if (message.hostname !== "") {
writer.uint32(10).string(message.hostname);
@@ -323,6 +333,7 @@ export const WifiSettings: MessageFns<WifiSettings> = {
fromJSON(object: any): WifiSettings {
return {
$type: WifiSettings.$type,
hostname: isSet(object.hostname) ? globalThis.String(object.hostname) : "",
priorityRssi: isSet(object.priorityRssi) ? globalThis.Boolean(object.priorityRssi) : false,
wifiNetworks: globalThis.Array.isArray(object?.wifiNetworks)
@@ -345,10 +356,10 @@ export const WifiSettings: MessageFns<WifiSettings> = {
return obj;
},
create<I extends Exact<DeepPartial<WifiSettings>, I>>(base?: I): WifiSettings {
return WifiSettings.fromPartial(base ?? ({} as any));
create(base?: DeepPartial<WifiSettings>): WifiSettings {
return WifiSettings.fromPartial(base ?? {});
},
fromPartial<I extends Exact<DeepPartial<WifiSettings>, I>>(object: I): WifiSettings {
fromPartial(object: DeepPartial<WifiSettings>): WifiSettings {
const message = createBaseWifiSettings();
message.hostname = object.hostname ?? "";
message.priorityRssi = object.priorityRssi ?? false;
@@ -357,270 +368,26 @@ export const WifiSettings: MessageFns<WifiSettings> = {
},
};
type ProtoMetaMessageOptions = {
options?: { [key: string]: any };
fields?: { [key: string]: { [key: string]: any } };
oneof?: { [key: string]: { [key: string]: any } };
nested?: { [key: string]: ProtoMetaMessageOptions };
};
export interface ProtoMetadata {
fileDescriptor: FileDescriptorProto;
references: { [key: string]: any };
dependencies?: ProtoMetadata[];
options?: {
options?: { [key: string]: any };
services?: {
[key: string]: { options?: { [key: string]: any }; methods?: { [key: string]: { [key: string]: any } } };
};
messages?: { [key: string]: ProtoMetaMessageOptions };
enums?: { [key: string]: { options?: { [key: string]: any }; values?: { [key: string]: { [key: string]: any } } } };
};
}
export const protoMetadata: ProtoMetadata = {
fileDescriptor: {
"name": "rest_message.proto",
"package": "rest_message",
"dependency": ["websocket_message.proto"],
"publicDependency": [],
"weakDependency": [],
"optionDependency": [],
"messageType": [{
"name": "WifiStatus",
"field": [{
"name": "status",
"number": 1,
"label": 1,
"type": 5,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "status",
"options": undefined,
"proto3Optional": false,
}, {
"name": "local_ip",
"number": 2,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "localIp",
"options": undefined,
"proto3Optional": false,
}, {
"name": "mac_address",
"number": 3,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "macAddress",
"options": undefined,
"proto3Optional": false,
}, {
"name": "rssi",
"number": 4,
"label": 1,
"type": 2,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "rssi",
"options": undefined,
"proto3Optional": false,
}, {
"name": "ssid",
"number": 5,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "ssid",
"options": undefined,
"proto3Optional": false,
}, {
"name": "bssid",
"number": 6,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "bssid",
"options": undefined,
"proto3Optional": false,
}, {
"name": "channel",
"number": 7,
"label": 1,
"type": 13,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "channel",
"options": undefined,
"proto3Optional": false,
}, {
"name": "subnet_mask",
"number": 8,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "subnetMask",
"options": undefined,
"proto3Optional": false,
}, {
"name": "gateway_ip",
"number": 9,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "gatewayIp",
"options": undefined,
"proto3Optional": false,
}, {
"name": "dns_ip_1",
"number": 10,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "dnsIp1",
"options": undefined,
"proto3Optional": false,
}, {
"name": "dns_ip_2",
"number": 11,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "dnsIp2",
"options": undefined,
"proto3Optional": true,
}],
"extension": [],
"nestedType": [],
"enumType": [],
"extensionRange": [],
"oneofDecl": [{ "name": "_dns_ip_2", "options": undefined }],
"options": undefined,
"reservedRange": [],
"reservedName": [],
"visibility": 0,
}, {
"name": "WifiSettings",
"field": [{
"name": "hostname",
"number": 1,
"label": 1,
"type": 9,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "hostname",
"options": undefined,
"proto3Optional": false,
}, {
"name": "priority_rssi",
"number": 2,
"label": 1,
"type": 8,
"typeName": "",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "priorityRssi",
"options": undefined,
"proto3Optional": false,
}, {
"name": "wifi_networks",
"number": 3,
"label": 3,
"type": 11,
"typeName": ".socket_message.KnownNetworkItem",
"extendee": "",
"defaultValue": "",
"oneofIndex": 0,
"jsonName": "wifiNetworks",
"options": undefined,
"proto3Optional": false,
}],
"extension": [],
"nestedType": [],
"enumType": [],
"extensionRange": [],
"oneofDecl": [],
"options": undefined,
"reservedRange": [],
"reservedName": [],
"visibility": 0,
}],
"enumType": [],
"service": [],
"extension": [],
"options": undefined,
"sourceCodeInfo": {
"location": [{
"path": [2],
"span": [5, 0, 21],
"leadingComments":
' Note: This is most likely a "temporary" proto that will be redone, as these endpoints are static for the esp32, which means we are forced to use WiFi for communication\n',
"trailingComments": "",
"leadingDetachedComments": [],
}],
},
"syntax": "proto3",
"edition": 0,
},
references: { ".rest_message.WifiStatus": WifiStatus, ".rest_message.WifiSettings": WifiSettings },
dependencies: [protoMetadata1],
};
messageTypeRegistry.set(WifiSettings.$type, WifiSettings);
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
: T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
: Partial<T>;
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin ? P
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
function isSet(value: any): boolean {
return value !== null && value !== undefined;
}
export interface MessageFns<T> {
export interface MessageFns<T, V extends string> {
readonly $type: V;
encode(message: T, writer?: BinaryWriter): BinaryWriter;
decode(input: BinaryReader | Uint8Array, length?: number): T;
fromJSON(object: any): T;
toJSON(message: T): unknown;
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
create(base?: DeepPartial<T>): T;
fromPartial(object: DeepPartial<T>): T;
}
@@ -0,0 +1,27 @@
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v2.10.1
// protoc v3.20.3
/* eslint-disable */
import type { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
export interface MessageType<Message extends UnknownMessage = UnknownMessage> {
$type: Message["$type"];
encode(message: Message, writer?: BinaryWriter): BinaryWriter;
decode(input: BinaryReader | Uint8Array, length?: number): Message;
fromJSON(object: any): Message;
toJSON(message: Message): unknown;
fromPartial(object: DeepPartial<Message>): Message;
}
export type UnknownMessage = { $type: string };
export const messageTypeRegistry = new Map<string, MessageType>();
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
export type DeepPartial<T> = T extends Builtin ? T
: T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
: T extends {} ? { [K in Exclude<keyof T, "$type">]?: DeepPartial<T[K]> }
: Partial<T>;
File diff suppressed because it is too large Load Diff