feat: expose ws globally for console debugging
This commit is contained in:
parent
448b1770fc
commit
34f9d8fd81
|
|
@ -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
|
||||
|
|
|
|||
11
src/nuxt.ts
11
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
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue