summaryrefslogtreecommitdiff
path: root/packages/frontend/src/debug.ts
diff options
context:
space:
mode:
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;
+}