diff --git a/frontend/app/block/block.tsx b/frontend/app/block/block.tsx index 97d11a1d..6dc99bb1 100644 --- a/frontend/app/block/block.tsx +++ b/frontend/app/block/block.tsx @@ -18,7 +18,7 @@ interface BlockProps { } const BlockHeader = ({ blockId, onClose }: BlockProps) => { - const [blockData, blockDataLoading] = WOS.useWaveObjectValue(WOS.makeORef("block", blockId)); + const [blockData] = WOS.useWaveObjectValue(WOS.makeORef("block", blockId)); return (
diff --git a/frontend/app/store/wos.ts b/frontend/app/store/wos.ts index bffeb8a2..d4952979 100644 --- a/frontend/app/store/wos.ts +++ b/frontend/app/store/wos.ts @@ -21,7 +21,7 @@ type WaveObjectValue = { }; function splitORef(oref: string): [string, string] { - let parts = oref.split(":"); + const parts = oref.split(":"); if (parts.length != 2) { throw new Error("invalid oref"); } @@ -54,11 +54,7 @@ function makeORef(otype: string, oid: string): string { } function GetObject(oref: string): Promise { - let prtn = $Call.ByName( - "github.com/wavetermdev/thenextwave/pkg/service/objectservice.ObjectService.GetObject", - oref - ); - return prtn; + return $Call.ByName("github.com/wavetermdev/thenextwave/pkg/service/objectservice.ObjectService.GetObject", oref); } const waveObjectValueCache = new Map>(); @@ -75,8 +71,8 @@ function createWaveValueObject(oref: string, shouldFetch: boo if (!shouldFetch) { return wov; } - let startTs = Date.now(); - let localPromise = GetObject(oref); + const startTs = Date.now(); + const localPromise = GetObject(oref); wov.pendingPromise = localPromise; localPromise.then((val) => { if (wov.pendingPromise != localPromise) { @@ -138,24 +134,21 @@ function getWaveObjectAtom(oref: string): jotai.WritableAtom< waveObjectValueCache.set(oref, wov); } return jotai.atom( - (get) => { - let dataValue = get(wov.dataAtom); - return dataValue.value; - }, + (get) => get(wov.dataAtom).value, (_get, set, value: T) => { setObjectValue(value, set, true); } ); } -function getWaveObjectLoadingAtom(oref: string): jotai.Atom { +function getWaveObjectLoadingAtom(oref: string): jotai.Atom { let wov = waveObjectValueCache.get(oref); if (wov == null) { wov = createWaveValueObject(oref, true); waveObjectValueCache.set(oref, wov); } return jotai.atom((get) => { - let dataValue = get(wov.dataAtom); + const dataValue = get(wov.dataAtom); if (dataValue.loading) { return null; } @@ -203,7 +196,7 @@ function updateWaveObject(update: WaveObjUpdate) { if (update == null) { return; } - let oref = makeORef(update.otype, update.oid); + const oref = makeORef(update.otype, update.oid); let wov = waveObjectValueCache.get(oref); if (wov == null) { wov = createWaveValueObject(oref, false); @@ -217,7 +210,7 @@ function updateWaveObject(update: WaveObjUpdate) { console.log("invalid wave object update", update); return; } - let curValue: WaveObjectDataItemType = globalStore.get(wov.dataAtom); + const curValue: WaveObjectDataItemType = globalStore.get(wov.dataAtom); if (curValue.value != null && curValue.value.version >= update.obj.version) { return; } @@ -229,14 +222,14 @@ function updateWaveObject(update: WaveObjUpdate) { } function updateWaveObjects(vals: WaveObjUpdate[]) { - for (let val of vals) { + for (const val of vals) { updateWaveObject(val); } } function cleanWaveObjectCache() { - let now = Date.now(); - for (let [oref, wov] of waveObjectValueCache) { + const now = Date.now(); + for (const [oref, wov] of waveObjectValueCache) { if (wov.refCount == 0 && wov.holdTime < now) { waveObjectValueCache.delete(oref); } @@ -280,11 +273,11 @@ function wrapObjectServiceCall(fnName: string, ...args: any[]): Promise { // should provide getFn if it is available (e.g. inside of a jotai atom) // otherwise it will use the globalStore.get function function getObjectValue(oref: string, getFn?: jotai.Getter): T { - let wov = waveObjectValueCache.get(oref); - if (wov == null) { + const wov = waveObjectValueCache.get(oref); + if (wov === undefined) { return null; } - if (getFn == null) { + if (getFn === undefined) { getFn = globalStore.get; } const atomVal = getFn(wov.dataAtom); @@ -296,11 +289,11 @@ function getObjectValue(oref: string, getFn?: jotai.Getter): T { // otherwise it will use the globalStore.set function function setObjectValue(value: T, setFn?: jotai.Setter, pushToServer?: boolean) { const oref = makeORef(value.otype, value.oid); - let wov = waveObjectValueCache.get(oref); - if (wov == null) { + const wov = waveObjectValueCache.get(oref); + if (wov === undefined) { return; } - if (setFn == null) { + if (setFn === undefined) { setFn = globalStore.set; } setFn(wov.dataAtom, { value: value, loading: false }); diff --git a/frontend/util/fontutil.ts b/frontend/util/fontutil.ts index fd231a06..aa9d4afe 100644 --- a/frontend/util/fontutil.ts +++ b/frontend/util/fontutil.ts @@ -61,11 +61,11 @@ function loadFiraCodeFont() { return; } isFiraCodeLoaded = true; - let firaCodeRegular = new FontFace("Fira Code", "url('/fonts/firacode-regular.woff2')", { + const firaCodeRegular = new FontFace("Fira Code", "url('/fonts/firacode-regular.woff2')", { style: "normal", weight: "400", }); - let firaCodeBold = new FontFace("Fira Code", "url('/fonts/firacode-bold.woff2')", { + const firaCodeBold = new FontFace("Fira Code", "url('/fonts/firacode-bold.woff2')", { style: "normal", weight: "700", }); @@ -80,19 +80,19 @@ function loadHackFont() { return; } isHackFontLoaded = true; - let hackRegular = new FontFace("Hack", "url('/fonts/hack-regular.woff2')", { + const hackRegular = new FontFace("Hack", "url('/fonts/hack-regular.woff2')", { style: "normal", weight: "400", }); - let hackBold = new FontFace("Hack", "url('/fonts/hack-bold.woff2')", { + const hackBold = new FontFace("Hack", "url('/fonts/hack-bold.woff2')", { style: "normal", weight: "700", }); - let hackItalic = new FontFace("Hack", "url('/fonts/hack-italic.woff2')", { + const hackItalic = new FontFace("Hack", "url('/fonts/hack-italic.woff2')", { style: "italic", weight: "400", }); - let hackBoldItalic = new FontFace("Hack", "url('/fonts/hack-bolditalic.woff2')", { + const hackBoldItalic = new FontFace("Hack", "url('/fonts/hack-bolditalic.woff2')", { style: "italic", weight: "700", }); @@ -111,7 +111,7 @@ function loadBaseFonts() { return; } isBaseFontsLoaded = true; - let mmFont = new FontFace("Martian Mono", "url(/fonts/MartianMono-VariableFont_wdth,wght.ttf)", { + const mmFont = new FontFace("Martian Mono", "url(/fonts/MartianMono-VariableFont_wdth,wght.ttf)", { style: "normal", weight: "normal", }); diff --git a/frontend/util/ijson.ts b/frontend/util/ijson.ts index dbcfd98d..5cccafda 100644 --- a/frontend/util/ijson.ts +++ b/frontend/util/ijson.ts @@ -13,7 +13,7 @@ function formatPath(path: PathType): string { return "$"; } let pathStr = "$"; - for (let pathPart of path) { + for (const pathPart of path) { if (typeof pathPart === "string") { if (simplePathStrRe.test(pathPart)) { pathStr += "." + pathPart; @@ -39,7 +39,7 @@ function isObject(obj: any): boolean { function getPath(obj: any, path: PathType): any { let cur = obj; - for (let pathPart of path) { + for (const pathPart of path) { if (cur == null) { return null; } @@ -86,7 +86,7 @@ function checkPath(path: PathType): boolean { if (!isArray(path)) { return false; } - for (let pathPart of path) { + for (const pathPart of path) { if (typeof pathPart !== "string" && typeof pathPart !== "number") { return false; } @@ -118,7 +118,7 @@ function isEmpty(obj: any): boolean { return obj.length == 0; } if (isObject(obj)) { - for (let key in obj) { + for (const _ in obj) { return false; } return true; diff --git a/frontend/wave.ts b/frontend/wave.ts index 45e97ad3..892f4d19 100644 --- a/frontend/wave.ts +++ b/frontend/wave.ts @@ -33,9 +33,9 @@ document.addEventListener("DOMContentLoaded", async () => { await WOS.loadAndPinWaveObject(WOS.makeORef("client", clientId)); const waveWindow = await WOS.loadAndPinWaveObject(WOS.makeORef("window", windowId)); await WOS.loadAndPinWaveObject(WOS.makeORef("workspace", waveWindow.workspaceid)); - let reactElem = React.createElement(App, null, null); - let elem = document.getElementById("main"); - let root = createRoot(elem); + const reactElem = React.createElement(App, null, null); + const elem = document.getElementById("main"); + const root = createRoot(elem); document.fonts.ready.then(() => { console.log("Wave First Render"); root.render(reactElem);