@bacca2095/webphone 1.0.0 → 1.2.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,73 +1,169 @@
1
- # webphone
1
+ # @bacca2095/webphone
2
2
 
3
- This template should help get you started developing with Vue 3 in Vite.
3
+ A Vue 3 WebPhone component library built on top of JsSIP for SIP/WebRTC communication.
4
4
 
5
- ## Recommended IDE Setup
5
+ [![npm version](https://img.shields.io/npm/v/@bacca2095/webphone)](https://www.npmjs.com/package/@bacca2095/webphone)
6
+ [![license](https://img.shields.io/npm/l/@bacca2095/webphone)](LICENSE)
6
7
 
7
- [VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
8
+ ## Requirements
8
9
 
9
- ## Recommended Browser Setup
10
+ - Node.js >= 24
11
+ - Vue >= 3.5
12
+ - Pinia >= 3.0
10
13
 
11
- - Chromium-based browsers (Chrome, Edge, Brave, etc.):
12
- - [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
13
- - [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
14
- - Firefox:
15
- - [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
16
- - [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
14
+ ## Installation
17
15
 
18
- ## Type Support for `.vue` Imports in TS
16
+ ```sh
17
+ npm install @bacca2095/webphone
18
+ # or
19
+ pnpm add @bacca2095/webphone
20
+ ```
19
21
 
20
- TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
22
+ ## Setup
21
23
 
22
- ## Customize configuration
24
+ ### 1. Register the plugin
23
25
 
24
- See [Vite Configuration Reference](https://vite.dev/config/).
26
+ The library requires Pinia. Register `WebPhonePlugin` after `createPinia()`.
25
27
 
26
- ## Project Setup
28
+ ```ts
29
+ import { createApp } from 'vue'
30
+ import { createPinia } from 'pinia'
31
+ import { WebPhone } from '@bacca2095/webphone'
32
+ import '@bacca2095/webphone/style.css'
27
33
 
28
- ```sh
29
- pnpm install
34
+ const app = createApp(App)
35
+ app.use(createPinia())
36
+ app.use(WebPhone)
37
+ app.mount('#app')
30
38
  ```
31
39
 
32
- ### Compile and Hot-Reload for Development
40
+ ### 2. Use the component
33
41
 
34
- ```sh
35
- pnpm dev
36
- ```
42
+ ```vue
43
+ <script setup lang="ts">
44
+ import { WebPhone } from '@bacca2095/webphone'
45
+ import type { WebPhoneConfig, Contact } from '@bacca2095/webphone'
37
46
 
38
- ### Type-Check, Compile and Minify for Production
47
+ const config: WebPhoneConfig = {
48
+ uri: 'sip:user@domain.com',
49
+ password: 'secret',
50
+ server: 'wss://sip.domain.com',
51
+ }
39
52
 
40
- ```sh
41
- pnpm build
53
+ const contacts: Contact[] = [
54
+ { id: '1', name: 'Alice', phone: 'sip:alice@domain.com', type: 'internal' },
55
+ ]
56
+ </script>
57
+
58
+ <template>
59
+ <WebPhone :config="config" :contacts="contacts" />
60
+ </template>
42
61
  ```
43
62
 
44
- ### Run Unit Tests with [Vitest](https://vitest.dev/)
63
+ ## WebPhone Props
45
64
 
46
- ```sh
47
- pnpm test:unit
65
+ | Prop | Type | Required | Description |
66
+ |------|------|----------|-------------|
67
+ | `config` | `WebPhoneConfig` | No | SIP connection configuration. If omitted, the phone renders without connecting. |
68
+ | `floating` | `boolean` | No | Renders the phone as a fixed, draggable overlay. |
69
+ | `contacts` | `Contact[]` | No | External contact list surfaced in the contacts panel. |
70
+
71
+ ## WebPhone Emits
72
+
73
+ | Event | Payload | Description |
74
+ |-------|---------|-------------|
75
+ | `open-history` | — | Fired when the user navigates to the history panel. |
76
+ | `open-notes` | `remoteUri?: string` | Fired when the user navigates to the notes panel. |
77
+ | `open-contacts` | — | Fired when the user navigates to the contacts panel. |
78
+ | `open-calendar` | — | Fired when the user navigates to the calendar panel. |
79
+
80
+ ## Types
81
+
82
+ ### `WebPhoneConfig`
83
+
84
+ | Field | Type | Required | Description |
85
+ |-------|------|----------|-------------|
86
+ | `server` | `string` | Yes | WebSocket server URL — e.g. `wss://sip.domain.com` |
87
+ | `uri` | `string` | Yes | SIP URI — e.g. `sip:user@domain.com` |
88
+ | `password` | `string` | Yes | SIP account password |
89
+ | `displayName` | `string` | No | Caller ID display name |
90
+ | `iceServers` | `RTCIceServer[]` | No | STUN/TURN servers for ICE negotiation |
91
+
92
+ ### `Contact`
93
+
94
+ | Field | Type | Required | Description |
95
+ |-------|------|----------|-------------|
96
+ | `id` | `string` | Yes | Unique identifier |
97
+ | `name` | `string` | Yes | Display name |
98
+ | `phone` | `string` | Yes | Extension, phone number, or SIP URI |
99
+ | `type` | `'internal' \| 'external' \| 'service' \| 'emergency'` | No | Contact category |
100
+
101
+ ## API
102
+
103
+ ### Components
104
+
105
+ | Component | Description |
106
+ |-----------|-------------|
107
+ | `WebPhone` | Main phone interface — dialer, active call controls, and panel navigation |
108
+ | `NotesPanel` | Per-number persistent notes |
109
+ | `HistoryPanel` | Call history with filtering |
110
+ | `ContactsPanel` | Contacts management |
111
+ | `CalendarPanel` | Scheduled calls |
112
+
113
+ ### Composables
114
+
115
+ | Composable | Description |
116
+ |------------|-------------|
117
+ | `useWebPhone` | Core SIP/WebRTC logic — register, call, hold, transfer |
118
+ | `useAudioDevices` | Audio input/output device enumeration and selection |
119
+ | `useContacts` | Contacts CRUD and search |
120
+ | `useWebPhoneStore` | Pinia store — reactive phone state |
121
+
122
+ ### Additional Types
123
+
124
+ `CallInfo`, `CallStatus`, `CallDirection`, `PhoneNote`, `NoteColor`, `ScheduledCall`, `MicPermission`
125
+
126
+ ## CDN Usage (Web Component)
127
+
128
+ The library ships a self-contained web component build that works without Vue or any bundler.
129
+
130
+ **ES module (recommended):**
131
+
132
+ ```html
133
+ <script type="module" src="https://unpkg.com/@bacca2095/webphone/dist/webphone.es.js"></script>
134
+
135
+ <web-phone></web-phone>
48
136
  ```
49
137
 
50
- ### Run End-to-End Tests with [Playwright](https://playwright.dev)
138
+ **IIFE (no module support required):**
51
139
 
52
- ```sh
53
- # Install browsers for the first run
54
- npx playwright install
55
-
56
- # When testing on CI, must build the project first
57
- pnpm build
58
-
59
- # Runs the end-to-end tests
60
- pnpm test:e2e
61
- # Runs the tests only on Chromium
62
- pnpm test:e2e --project=chromium
63
- # Runs the tests of a specific file
64
- pnpm test:e2e tests/example.spec.ts
65
- # Runs the tests in debug mode
66
- pnpm test:e2e --debug
140
+ ```html
141
+ <script src="https://unpkg.com/@bacca2095/webphone/dist/webphone.iife.js"></script>
142
+
143
+ <web-phone></web-phone>
67
144
  ```
68
145
 
69
- ### Lint with [ESLint](https://eslint.org/)
146
+ **Passing config via attribute:**
70
147
 
71
- ```sh
72
- pnpm lint
148
+ ```html
149
+ <web-phone id="phone"></web-phone>
150
+
151
+ <script type="module">
152
+ const phone = document.getElementById('phone')
153
+ phone.config = {
154
+ uri: 'sip:user@domain.com',
155
+ password: 'secret',
156
+ server: 'wss://sip.domain.com',
157
+ }
158
+ </script>
73
159
  ```
160
+
161
+ > The web component bundles all dependencies including styles. No additional CSS import is needed.
162
+
163
+ ## Demo
164
+
165
+ A live demo is available at [bacca2095.github.io/webphone](https://bacca2095.github.io/webphone).
166
+
167
+ ## License
168
+
169
+ [MIT](LICENSE)