constants.uts 932 Bytes
export const WsCommand = {
	GetLog: "getLog",
	GetStorage: "getStorage",
	Message: "message",
	GetLogList: "getLogList",
	RemoveLog: "removeLog",
	RemoveRecord: "removeRecord",
	StopPolling: "stopPolling",
	StartPolling: "startPolling",
	SetPollingInterval: "setPollingInterval",
	Records: "records",
	TempRecords: "tempRecords",
	RemoveTempRecord: "removeTempRecord",
	AddTempRecord: "addTempRecord",
	AddRecord: "addRecord",
	ExecuteSql: "executeSql",
	LiveLog: "liveLog",
	FileExplorer: "fileExplorer",
	UploadFile: "uploadFile"
} as UTSJSONObject;

export const WsMessageType = {
	Private: "private",
	System: "system"
} as UTSJSONObject;

export function normalizeWsUrl(url: string): string {
	if (url.startsWith("ws://") || url.startsWith("wss://")) {
		return url;
	}
	if (url.startsWith("https://")) {
		return `wss://${url.slice(8)}`;
	}
	if (url.startsWith("http://")) {
		return `ws://${url.slice(7)}`;
	}
	return url;
}