-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
170 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// We have to add a few node polyfills to make Vite work. | ||
// Vite's official stance is they DO NOT support modules that | ||
// require node builtins as dependencies, but that doesn't really | ||
// work for us because of all the crypto modules. | ||
// So on the first js file compiled by vite, add a few globals... | ||
export function vitePolyfills() { | ||
let addedPolyfills = false; | ||
return { | ||
name: "vite-polyfills", | ||
transform(src, id) { | ||
if (!addedPolyfills && /\.m?js$/.test(id)) { | ||
addedPolyfills = true; | ||
return { | ||
code: [ | ||
`import { Buffer as ___Buffer } from 'buffer'; window.Buffer = ___Buffer;`, | ||
`import * as ___process from 'process'; window.process = ___process;`, | ||
`window.global = window;`, | ||
src, | ||
].join("\n"), | ||
}; | ||
} | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useCore } from "@/hooks/useCore"; | ||
import { flagsStore } from "@/store/modules/flags"; | ||
import { defineComponent, watch } from "@vue/runtime-core"; | ||
import { onMounted, ref } from "vue"; | ||
import { Button } from "../Button/Button"; | ||
|
||
const isProduction = import.meta.env.VITE_APP_DEPLOYMENT === "production"; | ||
|
||
const loadGui = async () => { | ||
return (await import("./flagsGui")).createGui; | ||
}; | ||
|
||
export const Flags = defineComponent({ | ||
name: "FlagsGui", | ||
setup() { | ||
if (isProduction) return null; | ||
|
||
const guiRef = ref<dat.GUI>(); | ||
|
||
watch(flagsStore.state, () => flagsStore.persist(), { deep: true }); | ||
|
||
watch(flagsStore.refs.ibcTransferTimeoutMinutes.computed(), (timeout) => { | ||
useCore().services.ibc.transferTimeoutMinutes = timeout; | ||
}); | ||
|
||
const toggleGui = async () => { | ||
if (!guiRef.value) { | ||
const createGui = await loadGui(); | ||
guiRef.value = createGui(); | ||
document.body.appendChild(guiRef.value.domElement); | ||
} else { | ||
guiRef.value.domElement.remove(); | ||
guiRef.value.destroy(); | ||
guiRef.value = undefined; | ||
} | ||
}; | ||
|
||
return () => ( | ||
<Button.Inline | ||
icon="interactive/settings" | ||
class="fixed top-[8px] right-[8px]" | ||
onClick={toggleGui} | ||
/> | ||
); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { flagsStore } from "@/store/modules/flags"; | ||
import * as dat from "dat.gui"; | ||
|
||
export const createGui = () => { | ||
const gui = new dat.GUI({ | ||
load: { | ||
preset: "Default", | ||
closed: true, | ||
}, | ||
autoPlace: false, | ||
width: 400, | ||
}); | ||
|
||
gui.useLocalStorage = true; | ||
|
||
Object.assign(gui.domElement.style, { | ||
zIndex: 30, | ||
position: "fixed", | ||
top: "48px", | ||
right: 0, | ||
}); | ||
gui.domElement.querySelector(".close-button")?.remove(); | ||
gui.show(); | ||
|
||
Object.keys(flagsStore.state).forEach((key) => { | ||
gui.add(flagsStore.state, key); | ||
}); | ||
|
||
return gui; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { defineComponent } from "@vue/runtime-core"; | ||
import { Vuextra } from "../Vuextra"; | ||
|
||
export type FlagsState = { | ||
ibcTransferTimeoutMinutes: number; | ||
enableRewardsClaim: boolean; | ||
}; | ||
|
||
let json: any = {}; | ||
try { | ||
json = JSON.parse(localStorage.getItem("flags") || "") || {}; | ||
} catch (_) {} | ||
|
||
export const flagsStore = Vuextra.createStore({ | ||
name: "flags", | ||
options: { | ||
devtools: true, | ||
}, | ||
state: { | ||
ibcTransferTimeoutMinutes: json?.ibcTransferTimeoutMinutes || 45, | ||
enableRewardsClaim: json?.enableRewardsClaim || false, | ||
} as FlagsState, | ||
getters: (state) => ({}), | ||
mutations: (state) => ({}), | ||
actions: (ctx) => ({ | ||
persist: () => { | ||
localStorage.setItem("flags", JSON.stringify(ctx.state)); | ||
}, | ||
}), | ||
modules: [], | ||
}); | ||
|
||
const self = flagsStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3375,6 +3375,11 @@ | |
resolved "https://registry.yarnpkg.com/@types/color-hash/-/color-hash-1.0.0.tgz#2671e71d46ce07248ca149ca058bdc01c2dbb975" | ||
integrity sha512-Vj9gPc43pJeILnI0Yh0ds4+1toNUmvVqKxg/5sY8ESZafKo24TY5eCKXwXPym1xcgEMb2Qxy3dRwaYOro4U5Tg== | ||
|
||
"@types/dat.gui@^0.7.7": | ||
version "0.7.7" | ||
resolved "https://registry.yarnpkg.com/@types/dat.gui/-/dat.gui-0.7.7.tgz#2125aedfaa190364c5a50b0447858a7e159aea2e" | ||
integrity sha512-CxLCme0He5Jk3uQwfO/fGZMyNhb/ypANzqX0yU9lviBQMlen5SOvQTBQ/Cd9x5mFlUAK5Tk8RgvTyLj1nYkz+w== | ||
|
||
"@types/[email protected]": | ||
version "0.0.39" | ||
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f" | ||
|
@@ -6628,6 +6633,11 @@ dashdash@^1.12.0: | |
dependencies: | ||
assert-plus "^1.0.0" | ||
|
||
dat.gui@^0.7.7: | ||
version "0.7.7" | ||
resolved "https://registry.yarnpkg.com/dat.gui/-/dat.gui-0.7.7.tgz#7f96dbd21621a76385203659aebfa264ee6ae89b" | ||
integrity sha512-sRl/28gF/XRC5ywC9I4zriATTsQcpSsRG7seXCPnTkK8/EQMIbCu5NPMpICLGxX9ZEUvcXR3ArLYCtgreFoMDw== | ||
|
||
[email protected]: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636" | ||
|