From 34f9d8fd81a93b822452c2d9c1e5b0a053dc324f Mon Sep 17 00:00:00 2001 From: "Fabian @ Blax Software" Date: Thu, 16 Apr 2026 08:48:19 +0200 Subject: [PATCH] feat: expose ws globally for console debugging --- .github/copilot-instructions.md | 4 ++-- src/nuxt.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index c8661f0..3451cf1 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -5,8 +5,8 @@ Plug-and-play API + WebSocket client for Vue/Nuxt apps. Framework-agnostic core ## Build - `pnpm build` — builds via tsup to `dist/` -- `dist/` is committed to the repo (required for GitHub-based `pnpm` installs) -- Always rebuild before committing changes: `pnpm build && git add dist/` +- `dist/` is gitignored — never commit build artifacts +- `prepare` script runs `tsup` automatically on `git+https://` installs - Exports: `.` (core), `./vue`, `./nuxt`, `./axios` ## WebSocket diff --git a/src/nuxt.ts b/src/nuxt.ts index e6aa3cb..2a1174a 100644 --- a/src/nuxt.ts +++ b/src/nuxt.ts @@ -122,6 +122,11 @@ export function createFromNuxtConfig(options: NuxtNetworkingOptions = {}): { vueRef, ) + // Expose ws globally for console debugging: `await ws.send('auth.user')` + if (!isServer && typeof globalThis !== 'undefined') { + ;(globalThis as any).ws = ws + } + return { api, ws } } @@ -130,3 +135,9 @@ export { createApiClient } from './api' export { createWsClient } from './ws' export type { ApiClient } from './api' export type { WsClient, WsChannel } from './ws' + +// Global type declaration — makes `ws` available in browser console and TypeScript +declare global { + // eslint-disable-next-line no-var + var ws: WsClient | undefined +}