From 4d28c3154fadda0ff3b745c1bfe92cd52f5d5996 Mon Sep 17 00:00:00 2001 From: a-crowell Date: Mon, 19 Aug 2024 14:22:53 -0700 Subject: [PATCH 1/8] Fixed --- fission/src/mirabuf/MirabufLoader.ts | 31 ++- .../configuring/ConfigureRobotBrainPanel.tsx | 247 ------------------ .../ui/panels/mirabuf/ImportMirabufPanel.tsx | 5 +- 3 files changed, 23 insertions(+), 260 deletions(-) delete mode 100644 fission/src/ui/panels/configuring/ConfigureRobotBrainPanel.tsx diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 1355d9e38c..2f1389698f 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -10,8 +10,9 @@ export type MirabufCacheID = string export interface MirabufCacheInfo { id: MirabufCacheID - cacheKey: string miraType: MiraType + cacheKey: string + buffer?: ArrayBuffer name?: string thumbnailStorageID?: string } @@ -29,12 +30,12 @@ const root = await navigator.storage.getDirectory() const robotFolderHandle = await root.getDirectoryHandle(robotsDirName, { create: true }) const fieldFolderHandle = await root.getDirectoryHandle(fieldsDirName, { create: true }) -export const backUpRobots: Map = new Map() -export const backUpFields: Map = new Map() +export let backUpRobots: MapCache = {} +export let backUpFields: MapCache = {} -const canOPFS = await (async () => { +export const canOPFS = await (async () => { try { - if (robotFolderHandle.name == robotsDirName) { + if (robotFolderHandle.name == fieldsDirName ) { // robotsDirName) { robotFolderHandle.entries robotFolderHandle.keys @@ -52,6 +53,7 @@ const canOPFS = await (async () => { } } catch (e) { console.log(`No access to OPFS`) + MirabufCachingService.RemoveAll() return false } })() @@ -243,7 +245,7 @@ class MirabufCachingService { // Get buffer from hashMap. If not in hashMap, check OPFS. Otherwise, buff is undefined const cache = miraType == MiraType.ROBOT ? backUpRobots : backUpFields const buff = - cache.get(id) ?? + (cache[id])?.buffer ?? (await (async () => { const fileHandle = canOPFS ? await (miraType == MiraType.ROBOT ? robotFolderHandle : fieldFolderHandle).getFileHandle(id, { @@ -299,7 +301,7 @@ class MirabufCachingService { const backUpCache = miraType == MiraType.ROBOT ? backUpRobots : backUpFields if (backUpCache) { - backUpCache.delete(id) + delete backUpCache[id] } World.AnalyticsSystem?.Event("Cache Remove", { @@ -328,8 +330,8 @@ class MirabufCachingService { window.localStorage.removeItem(robotsDirName) window.localStorage.removeItem(fieldsDirName) - backUpRobots.clear() - backUpFields.clear() + backUpRobots = {} + backUpFields = {} } // Optional name for when assembly is being decoded anyway like in CacheAndGetLocal() @@ -350,8 +352,8 @@ class MirabufCachingService { const map: MapCache = this.GetCacheMap(miraType) const info: MirabufCacheInfo = { id: backupID, - cacheKey: key, miraType: miraType, + cacheKey: key, name: name, } map[key] = info @@ -377,7 +379,14 @@ class MirabufCachingService { // Store in hash const cache = miraType == MiraType.ROBOT ? backUpRobots : backUpFields - cache.set(backupID, miraBuff) + const mapInfo: MirabufCacheInfo = { + id: backupID, + miraType: miraType, + cacheKey: key, + buffer: miraBuff, + name: name, + } + cache[backupID] = mapInfo return info } catch (e) { diff --git a/fission/src/ui/panels/configuring/ConfigureRobotBrainPanel.tsx b/fission/src/ui/panels/configuring/ConfigureRobotBrainPanel.tsx deleted file mode 100644 index ffbd9b9373..0000000000 --- a/fission/src/ui/panels/configuring/ConfigureRobotBrainPanel.tsx +++ /dev/null @@ -1,247 +0,0 @@ -import { MiraType } from "@/mirabuf/MirabufLoader" -import MirabufSceneObject, { RigidNodeAssociate } from "@/mirabuf/MirabufSceneObject" -import World from "@/systems/World" -import Label, { LabelSize } from "@/ui/components/Label" -import Button from "@/ui/components/Button" -import Panel, { PanelPropsImpl } from "@/ui/components/Panel" -import { useMemo, useState } from "react" -import { FaGear } from "react-icons/fa6" -import { ToggleButton, ToggleButtonGroup } from "@/ui/components/ToggleButtonGroup" -import { Divider, styled } from "@mui/material" -import GenericElevatorBehavior from "@/systems/simulation/behavior/synthesis/GenericElevatorBehavior" -import Stack, { StackDirection } from "@/ui/components/Stack" -import { JSX } from "react/jsx-runtime" -import ArcadeDriveBehavior from "@/systems/simulation/behavior/synthesis/ArcadeDriveBehavior" -import GenericArmBehavior from "@/systems/simulation/behavior/synthesis/GenericArmBehavior" -import SynthesisBrain from "@/systems/simulation/synthesis_brain/SynthesisBrain" - -// eslint-disable-next-line react-refresh/only-export-components -export enum ConfigureRobotBrainTypes { - SYNTHESIS = 0, - WIPLIB = 1, -} - -const LabelStyled = styled(Label)({ - fontWeight: 700, - margin: "0pt", -}) - -const DividerStyled = styled(Divider)({ - borderColor: "white", -}) - -/** - * Retrieves the joints of a robot and generates JSX elements for each joint. - * @param robot The MirabufSceneObject representing the robot. - * @returns An array of JSX elements representing the joints of the robot. - */ -function GetJoints(robot: MirabufSceneObject): JSX.Element[] { - const output: JSX.Element[] = [] - let elementKey = 0 - - /* Iterate through each behavior of the robot */ - const brain = robot.brain as SynthesisBrain - brain.behaviors.forEach(behavior => { - /* Adds the joints that the wheels are associated with */ - if (behavior instanceof ArcadeDriveBehavior) { - behavior.wheels.forEach(wheel => { - const assoc = World.PhysicsSystem.GetBodyAssociation( - wheel.constraint.GetVehicleBody().GetID() - ) as RigidNodeAssociate - - if (!assoc || assoc.sceneObject !== robot) { - return - } - - output.push( - - - Wheel Node {elementKey} - - - {assoc.rigidNodeId} - - - ) - elementKey++ - }) - output.push() - } else if (behavior instanceof GenericArmBehavior) { - /* Adds the joints that the arm is associated with */ - // Get the rigid node associates for the two bodies - const assoc1 = World.PhysicsSystem.GetBodyAssociation( - behavior.hingeDriver.constraint.GetBody1().GetID() - ) as RigidNodeAssociate - const assoc2 = World.PhysicsSystem.GetBodyAssociation( - behavior.hingeDriver.constraint.GetBody2().GetID() - ) as RigidNodeAssociate - - if (!assoc1 || assoc1.sceneObject !== robot || !assoc2 || assoc2.sceneObject !== robot) { - return - } - - output.push( - - - Arm Nodes - - - {assoc1.rigidNodeId + " " + assoc2.rigidNodeId} - - - ) - elementKey++ - } else if (behavior instanceof GenericElevatorBehavior) { - /* Adds the joints that the elevator is associated with */ - // Get the rigid node associates for the two bodies - const assoc1 = World.PhysicsSystem.GetBodyAssociation( - behavior.sliderDriver.constraint.GetBody1().GetID() - ) as RigidNodeAssociate - const assoc2 = World.PhysicsSystem.GetBodyAssociation( - behavior.sliderDriver.constraint.GetBody2().GetID() - ) as RigidNodeAssociate - - if (!assoc1 || assoc1.sceneObject !== robot || !assoc2 || assoc2.sceneObject !== robot) { - return - } - - output.push( - - - Elevator Nodes - - - {assoc1.rigidNodeId + " " + assoc2.rigidNodeId} - - - ) - elementKey++ - } - }) - - return output -} - -const ConfigureRobotBrainPanel: React.FC = ({ panelId, openLocation, sidePadding }) => { - const [selectedRobot, setSelectedRobot] = useState(undefined) - const [viewType, setViewType] = useState(ConfigureRobotBrainTypes.SYNTHESIS) - const robots = useMemo(() => { - const assemblies = [...World.SceneRenderer.sceneObjects.values()].filter(x => { - if (x instanceof MirabufSceneObject) { - return x.miraType === MiraType.ROBOT - } - return false - }) as MirabufSceneObject[] - return assemblies - }, []) - - return ( - } - panelId={panelId} - openLocation={openLocation} - sidePadding={sidePadding} - onAccept={() => {}} - onCancel={() => {}} - > - {selectedRobot?.ejectorPreferences == undefined ? ( - <> - - {/** Scroll view for selecting a robot to configure */} -
- {robots.map(mirabufSceneObject => { - return ( - - ) - })} -
- {/* TODO: remove the accept button on this version */} - - ) : ( - <> -
- v != null && setViewType(v)} - sx={{ - alignSelf: "center", - }} - > - SynthesisBrain - WIPLIBBrain - - {viewType === ConfigureRobotBrainTypes.SYNTHESIS ? ( - <> - - Behaviors - - - {GetJoints(selectedRobot)} - - ) : ( - <> - - Example WIPLIB Brain - - - - - Example 2 - - - - - Example 3 - - - - - Example 4 - - - - )} -
- - )} -
- ) -} - -export default ConfigureRobotBrainPanel diff --git a/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx b/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx index aa3f37b2f8..2fbd12231c 100644 --- a/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx +++ b/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx @@ -8,7 +8,7 @@ import { MirabufFilesUpdateEvent, RequestMirabufFiles, } from "@/aps/APSDataManagement" -import MirabufCachingService, { MirabufCacheInfo, MirabufRemoteInfo, MiraType } from "@/mirabuf/MirabufLoader" +import MirabufCachingService, { backUpFields, backUpRobots, MirabufCacheInfo, MirabufRemoteInfo, MiraType } from "@/mirabuf/MirabufLoader" import World from "@/systems/World" import { useTooltipControlContext } from "@/ui/TooltipContext" import { CreateMirabuf } from "@/mirabuf/MirabufSceneObject" @@ -71,7 +71,8 @@ export type MiraManifest = { } function GetCacheInfo(miraType: MiraType): MirabufCacheInfo[] { - return Object.values(MirabufCachingService.GetCacheMap(miraType)) + // return canOPFS ? + return Object.values(MirabufCachingService.GetCacheMap(miraType))// : (miraType == MiraType.ROBOT ? backUpRobots : backUpFields) } function SpawnCachedMira(info: MirabufCacheInfo, type: MiraType, progressHandle?: ProgressHandle) { From 1a3d6fe931c3a52a83b778d11d58deee8adc5d60 Mon Sep 17 00:00:00 2001 From: a-crowell Date: Mon, 19 Aug 2024 14:43:59 -0700 Subject: [PATCH 2/8] Actual fix and formatting --- fission/src/Synthesis.tsx | 7 ------- fission/src/mirabuf/MirabufLoader.ts | 7 +++++-- .../src/ui/panels/mirabuf/ImportMirabufPanel.tsx | 14 +++++++++++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/fission/src/Synthesis.tsx b/fission/src/Synthesis.tsx index c1d33806ca..e44f783dd0 100644 --- a/fission/src/Synthesis.tsx +++ b/fission/src/Synthesis.tsx @@ -47,7 +47,6 @@ import ImportMirabufPanel from "@/ui/panels/mirabuf/ImportMirabufPanel.tsx" import Skybox from "./ui/components/Skybox.tsx" import ChooseInputSchemePanel from "./ui/panels/configuring/ChooseInputSchemePanel.tsx" import ProgressNotifications from "./ui/components/ProgressNotification.tsx" -import ConfigureRobotBrainPanel from "./ui/panels/configuring/ConfigureRobotBrainPanel.tsx" import SceneOverlay from "./ui/components/SceneOverlay.tsx" import WPILibWSWorker from "@/systems/simulation/wpilib_brain/WPILibWSWorker.ts?worker" @@ -232,12 +231,6 @@ const initialPanels: ReactElement[] = [ , , , - , , , , diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 2f1389698f..ca235d2515 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -35,7 +35,7 @@ export let backUpFields: MapCache = {} export const canOPFS = await (async () => { try { - if (robotFolderHandle.name == fieldsDirName ) { // robotsDirName) { + if (robotFolderHandle.name == robotsDirName) { robotFolderHandle.entries robotFolderHandle.keys @@ -190,16 +190,19 @@ class MirabufCachingService { try { const map: MapCache = this.GetCacheMap(miraType) const id = map[key].id + const _buffer = miraType == MiraType.ROBOT ? backUpRobots[id].buffer : backUpFields[id].buffer const _name = map[key].name const _thumbnailStorageID = map[key].thumbnailStorageID const info: MirabufCacheInfo = { id: id, cacheKey: key, miraType: miraType, + buffer: _buffer, name: name ?? _name, thumbnailStorageID: thumbnailStorageID ?? _thumbnailStorageID, } map[key] = info + miraType == MiraType.ROBOT ? (backUpRobots[id] = info) : (backUpFields[id] = info) window.localStorage.setItem(miraType == MiraType.ROBOT ? robotsDirName : fieldsDirName, JSON.stringify(map)) return true } catch (e) { @@ -245,7 +248,7 @@ class MirabufCachingService { // Get buffer from hashMap. If not in hashMap, check OPFS. Otherwise, buff is undefined const cache = miraType == MiraType.ROBOT ? backUpRobots : backUpFields const buff = - (cache[id])?.buffer ?? + cache[id]?.buffer ?? (await (async () => { const fileHandle = canOPFS ? await (miraType == MiraType.ROBOT ? robotFolderHandle : fieldFolderHandle).getFileHandle(id, { diff --git a/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx b/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx index 2fbd12231c..6fe4b4d988 100644 --- a/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx +++ b/fission/src/ui/panels/mirabuf/ImportMirabufPanel.tsx @@ -8,7 +8,14 @@ import { MirabufFilesUpdateEvent, RequestMirabufFiles, } from "@/aps/APSDataManagement" -import MirabufCachingService, { backUpFields, backUpRobots, MirabufCacheInfo, MirabufRemoteInfo, MiraType } from "@/mirabuf/MirabufLoader" +import MirabufCachingService, { + backUpFields, + backUpRobots, + canOPFS, + MirabufCacheInfo, + MirabufRemoteInfo, + MiraType, +} from "@/mirabuf/MirabufLoader" import World from "@/systems/World" import { useTooltipControlContext } from "@/ui/TooltipContext" import { CreateMirabuf } from "@/mirabuf/MirabufSceneObject" @@ -71,8 +78,9 @@ export type MiraManifest = { } function GetCacheInfo(miraType: MiraType): MirabufCacheInfo[] { - // return canOPFS ? - return Object.values(MirabufCachingService.GetCacheMap(miraType))// : (miraType == MiraType.ROBOT ? backUpRobots : backUpFields) + return Object.values( + canOPFS ? MirabufCachingService.GetCacheMap(miraType) : miraType == MiraType.ROBOT ? backUpRobots : backUpFields + ) } function SpawnCachedMira(info: MirabufCacheInfo, type: MiraType, progressHandle?: ProgressHandle) { From 60f6fdbba24159dd8a8536ea1901be8e4e8b82f5 Mon Sep 17 00:00:00 2001 From: a-crowell Date: Tue, 20 Aug 2024 15:06:48 -0700 Subject: [PATCH 3/8] Generation fix --- fission/src/mirabuf/MirabufLoader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index ca235d2515..867de1a232 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -77,7 +77,7 @@ class MirabufCachingService { */ public static GetCacheMap(miraType: MiraType): MapCache { if ( - (window.localStorage.getItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY) ?? "") == MIRABUF_LOCALSTORAGE_GENERATION + (window.localStorage.getItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY) ?? "") != MIRABUF_LOCALSTORAGE_GENERATION ) { window.localStorage.setItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY, MIRABUF_LOCALSTORAGE_GENERATION) window.localStorage.setItem(robotsDirName, "{}") From 8da89583d471123b1ddba36fca980de383bb85d0 Mon Sep 17 00:00:00 2001 From: a-crowell Date: Tue, 20 Aug 2024 15:14:40 -0700 Subject: [PATCH 4/8] Better generationing and removing --- fission/src/mirabuf/MirabufLoader.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 867de1a232..3de634e5d8 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -80,8 +80,7 @@ class MirabufCachingService { (window.localStorage.getItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY) ?? "") != MIRABUF_LOCALSTORAGE_GENERATION ) { window.localStorage.setItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY, MIRABUF_LOCALSTORAGE_GENERATION) - window.localStorage.setItem(robotsDirName, "{}") - window.localStorage.setItem(fieldsDirName, "{}") + this.RemoveAll() return {} } @@ -330,8 +329,8 @@ class MirabufCachingService { fieldFolderHandle.removeEntry(key) } - window.localStorage.removeItem(robotsDirName) - window.localStorage.removeItem(fieldsDirName) + window.localStorage.setItem(robotsDirName, "{}") + window.localStorage.setItem(fieldsDirName, "{}") backUpRobots = {} backUpFields = {} From 14790b009ab55d379e72e37c3bff7e5134a397cc Mon Sep 17 00:00:00 2001 From: a-crowell Date: Wed, 21 Aug 2024 14:56:40 -0700 Subject: [PATCH 5/8] canOPFS check --- fission/src/mirabuf/MirabufLoader.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 3de634e5d8..9d0d582fea 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -322,11 +322,13 @@ class MirabufCachingService { * Removes all Mirabuf files from the caching services. Mostly for debugging purposes. */ public static async RemoveAll() { - for await (const key of robotFolderHandle.keys()) { - robotFolderHandle.removeEntry(key) - } - for await (const key of fieldFolderHandle.keys()) { - fieldFolderHandle.removeEntry(key) + if (canOPFS) { + for await (const key of robotFolderHandle.keys()) { + robotFolderHandle.removeEntry(key) + } + for await (const key of fieldFolderHandle.keys()) { + fieldFolderHandle.removeEntry(key) + } } window.localStorage.setItem(robotsDirName, "{}") From c1a0ddfbef51caebf5a410555079f67c87b7ef1b Mon Sep 17 00:00:00 2001 From: a-crowell Date: Wed, 21 Aug 2024 15:02:37 -0700 Subject: [PATCH 6/8] Debug lines --- fission/src/mirabuf/MirabufLoader.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 9d0d582fea..9d0711b716 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -76,6 +76,7 @@ class MirabufCachingService { * @returns {MapCache} Map of cached keys and paired MirabufCacheInfo */ public static GetCacheMap(miraType: MiraType): MapCache { + console.log(`getcachemap`) if ( (window.localStorage.getItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY) ?? "") != MIRABUF_LOCALSTORAGE_GENERATION ) { @@ -104,6 +105,7 @@ class MirabufCachingService { * @returns {Promise} Promise with the result of the promise. Metadata on the mirabuf file if successful, undefined if not. */ public static async CacheRemote(fetchLocation: string, miraType?: MiraType): Promise { + console.log(`cacheremote`) if (miraType) { const map = MirabufCachingService.GetCacheMap(miraType) const target = map[fetchLocation] @@ -125,6 +127,7 @@ class MirabufCachingService { } public static async CacheAPS(data: Data, miraType: MiraType): Promise { + console.log(`cacheaps`) if (!data.href) { console.error("Data has no href") return undefined @@ -160,6 +163,7 @@ class MirabufCachingService { * @returns {Promise} Promise with the result of the promise. Metadata on the mirabuf file if successful, undefined if not. */ public static async CacheLocal(buffer: ArrayBuffer, miraType: MiraType): Promise { + console.log(`cachelocal`) const key = await this.HashBuffer(buffer) const map = MirabufCachingService.GetCacheMap(miraType) @@ -222,6 +226,7 @@ class MirabufCachingService { buffer: ArrayBuffer, miraType: MiraType ): Promise { + console.log(`cachegetlocal`) const key = await this.HashBuffer(buffer) const map = MirabufCachingService.GetCacheMap(miraType) const target = map[key] @@ -322,6 +327,7 @@ class MirabufCachingService { * Removes all Mirabuf files from the caching services. Mostly for debugging purposes. */ public static async RemoveAll() { + console.log(`removeall`) if (canOPFS) { for await (const key of robotFolderHandle.keys()) { robotFolderHandle.removeEntry(key) @@ -345,8 +351,8 @@ class MirabufCachingService { miraType?: MiraType, name?: string ): Promise { - const backupID = Date.now().toString() try { + const backupID = Date.now().toString() if (!miraType) { console.log("Double loading") miraType = this.AssemblyFromBuffer(miraBuff).dynamic ? MiraType.ROBOT : MiraType.FIELD @@ -401,6 +407,7 @@ class MirabufCachingService { } private static async HashBuffer(buffer: ArrayBuffer): Promise { + console.log(`hashbuffer`) const hashBuffer = await crypto.subtle.digest("SHA-256", buffer) let hash = "" new Uint8Array(hashBuffer).forEach(x => (hash = hash + String.fromCharCode(x))) From 26bb860315c7a29f9632b1795dc5c8e1ee6e402e Mon Sep 17 00:00:00 2001 From: Dhruv Arora Date: Wed, 21 Aug 2024 15:10:49 -0700 Subject: [PATCH 7/8] Fixed all issues Co-authored-by: a-crowell --- fission/src/mirabuf/MirabufLoader.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 9d0711b716..7731330330 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -53,7 +53,21 @@ export const canOPFS = await (async () => { } } catch (e) { console.log(`No access to OPFS`) - MirabufCachingService.RemoveAll() + + // Copy-pasted from RemoveAll() + for await (const key of robotFolderHandle.keys()) { + robotFolderHandle.removeEntry(key) + } + for await (const key of fieldFolderHandle.keys()) { + fieldFolderHandle.removeEntry(key) + } + + window.localStorage.setItem(robotsDirName, "{}") + window.localStorage.setItem(fieldsDirName, "{}") + + backUpRobots = {} + backUpFields = {} + return false } })() From aa95dcd85a33ac44a431fa7619001a4a15d31e55 Mon Sep 17 00:00:00 2001 From: Dhruv Arora Date: Wed, 21 Aug 2024 15:20:09 -0700 Subject: [PATCH 8/8] Removed console logs --- fission/src/mirabuf/MirabufLoader.ts | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/fission/src/mirabuf/MirabufLoader.ts b/fission/src/mirabuf/MirabufLoader.ts index 7731330330..89b61c82e6 100644 --- a/fission/src/mirabuf/MirabufLoader.ts +++ b/fission/src/mirabuf/MirabufLoader.ts @@ -90,7 +90,6 @@ class MirabufCachingService { * @returns {MapCache} Map of cached keys and paired MirabufCacheInfo */ public static GetCacheMap(miraType: MiraType): MapCache { - console.log(`getcachemap`) if ( (window.localStorage.getItem(MIRABUF_LOCALSTORAGE_GENERATION_KEY) ?? "") != MIRABUF_LOCALSTORAGE_GENERATION ) { @@ -119,7 +118,6 @@ class MirabufCachingService { * @returns {Promise} Promise with the result of the promise. Metadata on the mirabuf file if successful, undefined if not. */ public static async CacheRemote(fetchLocation: string, miraType?: MiraType): Promise { - console.log(`cacheremote`) if (miraType) { const map = MirabufCachingService.GetCacheMap(miraType) const target = map[fetchLocation] @@ -141,7 +139,6 @@ class MirabufCachingService { } public static async CacheAPS(data: Data, miraType: MiraType): Promise { - console.log(`cacheaps`) if (!data.href) { console.error("Data has no href") return undefined @@ -177,7 +174,6 @@ class MirabufCachingService { * @returns {Promise} Promise with the result of the promise. Metadata on the mirabuf file if successful, undefined if not. */ public static async CacheLocal(buffer: ArrayBuffer, miraType: MiraType): Promise { - console.log(`cachelocal`) const key = await this.HashBuffer(buffer) const map = MirabufCachingService.GetCacheMap(miraType) @@ -240,7 +236,6 @@ class MirabufCachingService { buffer: ArrayBuffer, miraType: MiraType ): Promise { - console.log(`cachegetlocal`) const key = await this.HashBuffer(buffer) const map = MirabufCachingService.GetCacheMap(miraType) const target = map[key] @@ -341,7 +336,6 @@ class MirabufCachingService { * Removes all Mirabuf files from the caching services. Mostly for debugging purposes. */ public static async RemoveAll() { - console.log(`removeall`) if (canOPFS) { for await (const key of robotFolderHandle.keys()) { robotFolderHandle.removeEntry(key) @@ -368,7 +362,7 @@ class MirabufCachingService { try { const backupID = Date.now().toString() if (!miraType) { - console.log("Double loading") + console.debug("Double loading") miraType = this.AssemblyFromBuffer(miraBuff).dynamic ? MiraType.ROBOT : MiraType.FIELD } @@ -421,7 +415,6 @@ class MirabufCachingService { } private static async HashBuffer(buffer: ArrayBuffer): Promise { - console.log(`hashbuffer`) const hashBuffer = await crypto.subtle.digest("SHA-256", buffer) let hash = "" new Uint8Array(hashBuffer).forEach(x => (hash = hash + String.fromCharCode(x)))