summaryrefslogtreecommitdiff
path: root/packages/frontend/src/debug.ts
diff options
context:
space:
mode:
authorAcid Chicken (硫酸鶏) <root@acid-chicken.com>2023-03-09 14:35:38 +0900
committerGitHub <noreply@github.com>2023-03-09 14:35:38 +0900
commit93ea9c20337a652defbd90fe41932a43d252baa3 (patch)
treeeecb594593285d9f75ce30f5eeb907a0218a7135 /packages/frontend/src/debug.ts
parentenhance: アカウント削除時のクライアントの挙動をいい感... (diff)
downloadsharkey-93ea9c20337a652defbd90fe41932a43d252baa3.tar.gz
sharkey-93ea9c20337a652defbd90fe41932a43d252baa3.tar.bz2
sharkey-93ea9c20337a652defbd90fe41932a43d252baa3.zip
chore(frontend): add debugger for #6864 (#10270)
Diffstat (limited to 'packages/frontend/src/debug.ts')
-rw-r--r--packages/frontend/src/debug.ts27
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/frontend/src/debug.ts b/packages/frontend/src/debug.ts
new file mode 100644
index 0000000000..5715acf674
--- /dev/null
+++ b/packages/frontend/src/debug.ts
@@ -0,0 +1,27 @@
+import { type ComponentInternalInstance, getCurrentInstance } from 'vue';
+
+export function isDebuggerEnabled(id: number): boolean {
+ try {
+ return localStorage.getItem(`DEBUG_${id}`) !== null;
+ } catch {
+ return false;
+ }
+}
+
+export function switchDebuggerEnabled(id: number, enabled: boolean): void {
+ if (enabled) {
+ localStorage.setItem(`DEBUG_${id}`, '');
+ } else {
+ localStorage.removeItem(`DEBUG_${id}`);
+ }
+}
+
+export function stackTraceInstances(): ComponentInternalInstance[] {
+ let instance = getCurrentInstance();
+ const stack: ComponentInternalInstance[] = [];
+ while (instance) {
+ stack.push(instance);
+ instance = instance.parent;
+ }
+ return stack;
+}