@wireflowapp/vue-websocket 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,36 @@
1
- # Temporary Holding Version
1
+ # @wireflowapp/vue-websocket
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Vue 3 composable for native WebSocket connection management in **Wireflow**.
4
+
5
+ ## Features
6
+
7
+ - **Reactive State**: Exposes `Ref<ConnectionStatus>` for straightforward template binding.
8
+ - **Automatic Cleanup**: Integrates with Vue's `onUnmounted` lifecycle.
9
+ - **Zero Framework Pollution in Core**: Thin, type-safe adapter over `@wireflowapp/websocket-core`.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pnpm add @wireflowapp/vue-websocket @wireflowapp/websocket-core @wireflowapp/core
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```vue
20
+ <script setup lang="ts">
21
+ import { useWebSocket } from "@wireflowapp/vue-websocket";
22
+
23
+ const { status, connect, retry, disconnect, send } = useWebSocket("wss://example.com/ws", {
24
+ retryAttempts: 5,
25
+ });
26
+ </script>
27
+
28
+ <template>
29
+ <div>
30
+ <p>Status: {{ status }}</p>
31
+ <button @click="send('Ping')">Send Ping</button>
32
+ <button @click="disconnect">Disconnect</button>
33
+ <button @click="retry">Retry</button>
34
+ </div>
35
+ </template>
36
+ ```
@@ -0,0 +1,42 @@
1
+ import { Ref } from 'vue';
2
+ import { ConnectionStatus } from '@wireflowapp/core';
3
+ import { WebSocketOptions, WebSocketDataType, WebSocketClient } from '@wireflowapp/websocket-core';
4
+
5
+ interface UseWebSocketOptions extends WebSocketOptions {
6
+ }
7
+ interface UseWebSocketResult {
8
+ /**
9
+ * Reactive connection status.
10
+ */
11
+ readonly status: Ref<ConnectionStatus>;
12
+ /**
13
+ * Connect to the WebSocket server.
14
+ */
15
+ connect: () => void;
16
+ /**
17
+ * Retry connection if idle or failed.
18
+ */
19
+ retry: () => void;
20
+ /**
21
+ * Disconnect the active socket and cancel retries.
22
+ */
23
+ disconnect: () => void;
24
+ /**
25
+ * Send data through the active WebSocket connection.
26
+ */
27
+ send: (data: WebSocketDataType) => boolean;
28
+ /**
29
+ * The underlying WebSocketClient instance.
30
+ */
31
+ client: WebSocketClient;
32
+ }
33
+
34
+ /**
35
+ * Vue composable providing reactive connection state and controls over a native WebSocket connection.
36
+ *
37
+ * @param url The WebSocket server URL.
38
+ * @param options Optional configuration parameters and lifecycle event handlers.
39
+ */
40
+ declare function useWebSocket(url: string, options?: UseWebSocketOptions): UseWebSocketResult;
41
+
42
+ export { type UseWebSocketOptions, type UseWebSocketResult, useWebSocket };
@@ -0,0 +1,42 @@
1
+ import { Ref } from 'vue';
2
+ import { ConnectionStatus } from '@wireflowapp/core';
3
+ import { WebSocketOptions, WebSocketDataType, WebSocketClient } from '@wireflowapp/websocket-core';
4
+
5
+ interface UseWebSocketOptions extends WebSocketOptions {
6
+ }
7
+ interface UseWebSocketResult {
8
+ /**
9
+ * Reactive connection status.
10
+ */
11
+ readonly status: Ref<ConnectionStatus>;
12
+ /**
13
+ * Connect to the WebSocket server.
14
+ */
15
+ connect: () => void;
16
+ /**
17
+ * Retry connection if idle or failed.
18
+ */
19
+ retry: () => void;
20
+ /**
21
+ * Disconnect the active socket and cancel retries.
22
+ */
23
+ disconnect: () => void;
24
+ /**
25
+ * Send data through the active WebSocket connection.
26
+ */
27
+ send: (data: WebSocketDataType) => boolean;
28
+ /**
29
+ * The underlying WebSocketClient instance.
30
+ */
31
+ client: WebSocketClient;
32
+ }
33
+
34
+ /**
35
+ * Vue composable providing reactive connection state and controls over a native WebSocket connection.
36
+ *
37
+ * @param url The WebSocket server URL.
38
+ * @param options Optional configuration parameters and lifecycle event handlers.
39
+ */
40
+ declare function useWebSocket(url: string, options?: UseWebSocketOptions): UseWebSocketResult;
41
+
42
+ export { type UseWebSocketOptions, type UseWebSocketResult, useWebSocket };
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ useWebSocket: () => useWebSocket
24
+ });
25
+ module.exports = __toCommonJS(index_exports);
26
+
27
+ // src/composables/useWebSocket.ts
28
+ var import_vue = require("vue");
29
+ var import_websocket_core = require("@wireflowapp/websocket-core");
30
+ function useWebSocket(url, options = {}) {
31
+ const status = (0, import_vue.ref)("Idle");
32
+ const client = new import_websocket_core.WebSocketClient(url, {
33
+ ...options,
34
+ onStatusChange: (newStatus) => {
35
+ status.value = newStatus;
36
+ options.onStatusChange?.(newStatus);
37
+ }
38
+ });
39
+ status.value = client.status;
40
+ if ((0, import_vue.getCurrentInstance)()) {
41
+ (0, import_vue.onUnmounted)(() => {
42
+ client.dispose();
43
+ });
44
+ }
45
+ const connect = () => {
46
+ client.connect();
47
+ };
48
+ const retry = () => {
49
+ client.retry();
50
+ };
51
+ const disconnect = () => {
52
+ client.disconnect();
53
+ };
54
+ const send = (data) => {
55
+ return client.send(data);
56
+ };
57
+ return {
58
+ status,
59
+ connect,
60
+ retry,
61
+ disconnect,
62
+ send,
63
+ client
64
+ };
65
+ }
66
+ // Annotate the CommonJS export names for ESM import in node:
67
+ 0 && (module.exports = {
68
+ useWebSocket
69
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,44 @@
1
+ // src/composables/useWebSocket.ts
2
+ import { getCurrentInstance, onUnmounted, ref } from "vue";
3
+ import {
4
+ WebSocketClient
5
+ } from "@wireflowapp/websocket-core";
6
+ function useWebSocket(url, options = {}) {
7
+ const status = ref("Idle");
8
+ const client = new WebSocketClient(url, {
9
+ ...options,
10
+ onStatusChange: (newStatus) => {
11
+ status.value = newStatus;
12
+ options.onStatusChange?.(newStatus);
13
+ }
14
+ });
15
+ status.value = client.status;
16
+ if (getCurrentInstance()) {
17
+ onUnmounted(() => {
18
+ client.dispose();
19
+ });
20
+ }
21
+ const connect = () => {
22
+ client.connect();
23
+ };
24
+ const retry = () => {
25
+ client.retry();
26
+ };
27
+ const disconnect = () => {
28
+ client.disconnect();
29
+ };
30
+ const send = (data) => {
31
+ return client.send(data);
32
+ };
33
+ return {
34
+ status,
35
+ connect,
36
+ retry,
37
+ disconnect,
38
+ send,
39
+ client
40
+ };
41
+ }
42
+ export {
43
+ useWebSocket
44
+ };
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@wireflowapp/vue-websocket",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Vue composable for native WebSocket connection management with Wireflow",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ }
19
+ },
20
+ "sideEffects": false,
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "peerDependencies": {
28
+ "vue": ">=3.0.0"
29
+ },
30
+ "dependencies": {
31
+ "@wireflowapp/core": "1.0.0",
32
+ "@wireflowapp/websocket-core": "1.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "vue": "^3.5.13"
36
+ },
37
+ "keywords": [
38
+ "vue",
39
+ "composable",
40
+ "websocket",
41
+ "wireflow",
42
+ "real-time"
43
+ ],
44
+ "author": "",
45
+ "license": "MIT",
46
+ "scripts": {
47
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
48
+ "typecheck": "tsc --noEmit",
49
+ "test": "vitest run"
50
+ }
6
51
  }