@tmsoft/webphone 1.1.9 → 1.1.10
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 +146 -77
- package/dist/index.d.ts +0 -4
- package/dist/webphone-element.umd.js +1724 -0
- package/dist/webphone.cjs.js +40 -40
- package/dist/webphone.es.js +1511 -1516
- package/dist/webphone.umd.js +66 -1690
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,54 +1,82 @@
|
|
|
1
|
-
#
|
|
1
|
+
# WebPhone Library (`@tmsoft/webphone`)
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@tmsoft/webphone)
|
|
4
|
-
[](LICENSE)
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
Librería para Vue 3 con un componente `WebPhone` (softphone) basado en SIP y WebRTC. Incluye teclado DTMF, selección de dispositivos de audio, control de volúmenes y estado de conexión.
|
|
7
6
|
|
|
8
|
-
## 📌 **Características**
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
8
|
+
### Características
|
|
9
|
+
- Integración SIP sobre WebSocket (basado en JsSIP)
|
|
10
|
+
- Audio WebRTC con manejo de permisos de micrófono
|
|
11
|
+
- Teclado DTMF y estado de llamada (entrante/saliente/en curso)
|
|
12
|
+
- Gestión de dispositivos de audio (micrófonos y altavoces)
|
|
13
|
+
- Reconexión y manejo de estado SIP
|
|
14
|
+
- Diseño compacto y dependencias UI mínimas (PrimeVue para botones/inputs)
|
|
15
15
|
|
|
16
|
-
---
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
### Requisitos
|
|
18
|
+
- Vue 3.5+
|
|
19
|
+
- PrimeVue 4.x y PrimeIcons 7.x (peer dependencies)
|
|
20
|
+
- @vueuse/core 13.x (peer dependency)
|
|
21
|
+
- Servidor SIP con WebSocket habilitado (por ejemplo, Asterisk en `/asterisk/ws`, puerto 8089 por defecto)
|
|
22
|
+
- Navegador con HTTPS y permisos de micrófono
|
|
19
23
|
|
|
20
|
-
En NPM:
|
|
21
24
|
|
|
22
|
-
|
|
23
|
-
npm install @tmsoft/webphone
|
|
24
|
-
```
|
|
25
|
+
## Instalación
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
Instale el paquete y los peer dependencies:
|
|
27
28
|
|
|
28
29
|
```sh
|
|
29
|
-
|
|
30
|
+
npm install @tmsoft/webphone primevue primeicons @vueuse/core
|
|
31
|
+
# o
|
|
32
|
+
yarn add @tmsoft/webphone primevue primeicons @vueuse/core
|
|
33
|
+
# o
|
|
34
|
+
pnpm add @tmsoft/webphone primevue primeicons @vueuse/core
|
|
30
35
|
```
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
Los estilos del componente se inyectan automáticamente en tiempo de ejecución. No es necesario configurar Tailwind en su proyecto para usar esta librería.
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
|
|
40
|
+
## Uso
|
|
41
|
+
|
|
42
|
+
Puede utilizar la librería como plugin global o importar el componente localmente.
|
|
43
|
+
|
|
44
|
+
### Opción A: Plugin global
|
|
45
|
+
`main.ts`:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { createApp } from 'vue'
|
|
49
|
+
import App from './App.vue'
|
|
50
|
+
import WebphonePlugin from '@tmsoft/webphone'
|
|
51
|
+
|
|
52
|
+
const app = createApp(App)
|
|
53
|
+
app.use(WebphonePlugin)
|
|
54
|
+
app.mount('#app')
|
|
36
55
|
```
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
Luego, en cualquier componente:
|
|
39
58
|
|
|
40
|
-
|
|
59
|
+
```vue
|
|
60
|
+
<script setup lang="ts">
|
|
61
|
+
const extension = '1001'
|
|
62
|
+
const password = 'supersecret'
|
|
63
|
+
const domain = 'sip.example.com' // ver normalización de dominio más abajo
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<WebPhone :extension="extension" :password="password" :domain="domain" />
|
|
68
|
+
</template>
|
|
69
|
+
```
|
|
41
70
|
|
|
42
|
-
|
|
71
|
+
### Opción B: Importación local del componente
|
|
43
72
|
|
|
44
73
|
```vue
|
|
45
74
|
<script setup lang="ts">
|
|
46
|
-
import {
|
|
47
|
-
import WebPhone from '@tmsoft/webphone'
|
|
75
|
+
import { WebPhone } from '@tmsoft/webphone'
|
|
48
76
|
|
|
49
|
-
const extension =
|
|
50
|
-
const password =
|
|
51
|
-
const domain =
|
|
77
|
+
const extension = '1001'
|
|
78
|
+
const password = 'supersecret'
|
|
79
|
+
const domain = 'sip.example.com'
|
|
52
80
|
</script>
|
|
53
81
|
|
|
54
82
|
<template>
|
|
@@ -56,91 +84,132 @@ const domain = ref('sip.example.com')
|
|
|
56
84
|
</template>
|
|
57
85
|
```
|
|
58
86
|
|
|
59
|
-
---
|
|
60
87
|
|
|
61
|
-
##
|
|
88
|
+
## API del componente
|
|
62
89
|
|
|
63
|
-
|
|
64
|
-
| ----------- | ---------- | --------- | --------------------------------------------------------------------------------- |
|
|
65
|
-
| `extension` | `String` | ✅ | Número de extensión del usuario. |
|
|
66
|
-
| `password` | `String` | ✅ | Contraseña SIP de la extensión. |
|
|
67
|
-
| `domain` | `String` | ✅ | Dominio del servidor SIP. |
|
|
68
|
-
| `mode` | `String` | ❌ | Tipo de llamada. Valores: `'call'`, `'webcall'`, `'video'`. Por defecto `'call'`. |
|
|
69
|
-
| `image` | `String` | ❌ | Imagen base64 o URL para mostrar en modo `webcall`. |
|
|
70
|
-
| `to` | `String` | ❌ | Número de destino en modo `webcall`. |
|
|
71
|
-
| `callback` | `Function` | ❌ | Función de volver atrás en modo `webcall`. |
|
|
90
|
+
### Props
|
|
72
91
|
|
|
73
|
-
|
|
92
|
+
| Propiedad | Tipo | Requerida | Default | Descripción |
|
|
93
|
+
|------------|--------------------------------------|-----------|-----------|-------------|
|
|
94
|
+
| `extension`| `string` | Sí | — | Extensión del usuario para registrar y originar llamadas SIP. |
|
|
95
|
+
| `password` | `string` | Sí | — | Contraseña SIP de la extensión. |
|
|
96
|
+
| `domain` | `string` | Sí | — | Dominio o URL del servidor SIP. Se normaliza automáticamente (ver detalle). |
|
|
97
|
+
| `mode` | `'webcall' \| 'call' \| 'video'` | No | `'webcall'` | Modo de uso. Nota: `video` aún no inicia video de forma automática. |
|
|
98
|
+
| `image` | `string` | No | — | URL o base64 para mostrar un logotipo en modo `webcall`. |
|
|
99
|
+
| `to` | `string` | No | — | Número destino en modo `webcall`. Si se define, se origina la llamada automáticamente cuando el registro SIP está activo (≈ 2 s). |
|
|
100
|
+
| `callback` | `(event: MouseEvent) => void` | No | — | Reservado. Actualmente no se utiliza en el componente. |
|
|
74
101
|
|
|
75
|
-
## 🏗 **Construcción del Paquete**
|
|
76
102
|
|
|
77
|
-
|
|
103
|
+
### Normalización de `domain`
|
|
104
|
+
El componente acepta distintos formatos y construye automáticamente la URL WebSocket para SIP:
|
|
105
|
+
- Si recibe solo host (por ejemplo, `pbx.midominio.com`), se asume `wss://pbx.midominio.com:8089/asterisk/ws`.
|
|
106
|
+
- Si recibe `http://host[:puerto]` se usa `ws://host[:puerto]/asterisk/ws`.
|
|
107
|
+
- Si recibe `https://host[:puerto]` se usa `wss://host[:puerto]/asterisk/ws`.
|
|
108
|
+
- Si indica explícitamente un puerto, se respeta (de lo contrario, se usa 8089 por defecto para Asterisk).
|
|
78
109
|
|
|
79
|
-
|
|
80
|
-
npm run build
|
|
81
|
-
```
|
|
110
|
+
Además, el URI SIP se compone como `sip:<extension>@<host[:puerto]>`.
|
|
82
111
|
|
|
83
|
-
Esto generará los archivos de distribución en `dist/` con los siguientes formatos:
|
|
84
112
|
|
|
85
|
-
|
|
86
|
-
-
|
|
87
|
-
- **CommonJS** (`webphone.cjs.js`) → Para entornos Node.js.
|
|
113
|
+
### Slots
|
|
114
|
+
- `back-button`: slot para renderizar un control de navegación en la cabecera cuando `mode === 'webcall'`.
|
|
88
115
|
|
|
89
|
-
---
|
|
90
116
|
|
|
91
|
-
##
|
|
117
|
+
## Uso via CDN
|
|
92
118
|
|
|
93
|
-
|
|
119
|
+
### ES Module (recomendado)
|
|
94
120
|
|
|
95
121
|
```html
|
|
96
122
|
<script type="module">
|
|
97
|
-
import
|
|
123
|
+
import { createApp } from 'vue'
|
|
124
|
+
import WebphonePlugin from 'https://cdn.jsdelivr.net/npm/@tmsoft/webphone/dist/webphone.es.js'
|
|
125
|
+
|
|
126
|
+
const App = {
|
|
127
|
+
template: '<WebPhone extension="1001" password="supersecret" domain="sip.example.com" />'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
createApp(App).use(WebphonePlugin).mount('#app')
|
|
98
131
|
</script>
|
|
99
132
|
```
|
|
100
133
|
|
|
101
|
-
|
|
134
|
+
### UMD
|
|
102
135
|
|
|
103
136
|
```html
|
|
137
|
+
<!-- Vue 3 UMD -->
|
|
138
|
+
<script src="https://unpkg.com/vue@3"></script>
|
|
139
|
+
<!-- WebPhone UMD -->
|
|
104
140
|
<script src="https://cdn.jsdelivr.net/npm/@tmsoft/webphone/dist/webphone.umd.js"></script>
|
|
141
|
+
<script>
|
|
142
|
+
const app = Vue.createApp({
|
|
143
|
+
template: '<WebPhone extension="1001" password="supersecret" domain="sip.example.com" />'
|
|
144
|
+
})
|
|
145
|
+
// El paquete UMD expone 'WebPhone' como global; la función por defecto es el plugin
|
|
146
|
+
app.use(WebPhone.default)
|
|
147
|
+
app.mount('#app')
|
|
148
|
+
</script>
|
|
105
149
|
```
|
|
106
150
|
|
|
107
|
-
|
|
151
|
+
### Sin frameworks: Web Component (`<web-phone />`)
|
|
108
152
|
|
|
109
|
-
|
|
153
|
+
Para incrustar el softphone en una página HTML sin inicializar Vue ni otros frameworks, use el build UMD específico del Web Component:
|
|
110
154
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
Si no se ha iniciado sesión:
|
|
155
|
+
```html
|
|
156
|
+
<!-- Carga el Web Component listo para usar -->
|
|
157
|
+
<script src="https://cdn.jsdelivr.net/npm/@tmsoft/webphone/dist/webphone-element.umd.js"></script>
|
|
115
158
|
|
|
116
|
-
|
|
117
|
-
|
|
159
|
+
<!-- Úselo directamente en el DOM -->
|
|
160
|
+
<web-phone extension="1001" password="supersecret" domain="sip.example.com" mode="webcall" to="099999999" image="https://example.com/logo.png"></web-phone>
|
|
118
161
|
```
|
|
119
162
|
|
|
120
|
-
|
|
121
|
-
|
|
163
|
+
Notas:
|
|
164
|
+
- Los atributos del elemento corresponden a las props del componente (`extension`, `password`, `domain`, `mode`, `image`, `to`).
|
|
165
|
+
- El build del Web Component incluye internamente Vue, PrimeVue y estilos necesarios; no requiere inicialización adicional.
|
|
122
166
|
|
|
123
|
-
```json
|
|
124
|
-
{
|
|
125
|
-
"name": "@tmsoft/webphone",
|
|
126
|
-
"version": "1.0.2"
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
167
|
|
|
130
|
-
|
|
168
|
+
## Desarrollo
|
|
169
|
+
|
|
170
|
+
Scripts principales:
|
|
131
171
|
|
|
132
172
|
```sh
|
|
133
|
-
npm run
|
|
173
|
+
npm run dev # entorno de desarrollo
|
|
174
|
+
npm run build # compila ESM/CJS y UMD
|
|
175
|
+
npm run preview # vista previa local de la build
|
|
176
|
+
npm run test:unit # pruebas unitarias (Vitest)
|
|
177
|
+
npm run test:e2e # pruebas E2E (Playwright)
|
|
178
|
+
npm run lint # lint con ESLint
|
|
179
|
+
npm run format # formateo con Prettier
|
|
134
180
|
```
|
|
135
181
|
|
|
136
|
-
|
|
182
|
+
La salida de distribución se genera en `dist/`:
|
|
183
|
+
- `webphone.es.js` (ES Module)
|
|
184
|
+
- `webphone.cjs.js` (CommonJS)
|
|
185
|
+
- `webphone.umd.js` (UMD)
|
|
186
|
+
- `index.d.ts` (tipos TypeScript)
|
|
137
187
|
|
|
138
|
-
```sh
|
|
139
|
-
npm run publish:lib
|
|
140
|
-
```
|
|
141
188
|
|
|
142
|
-
|
|
189
|
+
## Publicación en NPM
|
|
190
|
+
|
|
191
|
+
Pasos sugeridos para publicar una versión:
|
|
143
192
|
|
|
193
|
+
1. Autentíquese en NPM (una vez por entorno):
|
|
194
|
+
```sh
|
|
195
|
+
npm login
|
|
196
|
+
```
|
|
197
|
+
2. Compile el paquete:
|
|
198
|
+
```sh
|
|
199
|
+
npm run build
|
|
200
|
+
```
|
|
201
|
+
3. Publique con incremento de patch automático:
|
|
202
|
+
```sh
|
|
203
|
+
npm run publish:lib
|
|
204
|
+
```
|
|
205
|
+
Este script ejecuta `npm version patch` y `npm publish --access public`.
|
|
206
|
+
|
|
207
|
+
Para publicar en un registro local (por ejemplo, Verdaccio):
|
|
144
208
|
```sh
|
|
145
209
|
npm run publish:local
|
|
146
210
|
```
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
## Licencia
|
|
214
|
+
|
|
215
|
+
MIT.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { App } from 'vue';
|
|
2
1
|
import { ComponentOptionsMixin } from 'vue';
|
|
3
2
|
import { ComponentProvideOptions } from 'vue';
|
|
4
3
|
import { DefineComponent } from 'vue';
|
|
@@ -37,9 +36,6 @@ declare type __VLS_WithTemplateSlots<T, S> = T & {
|
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
38
|
|
|
40
|
-
declare function install(app: App): void;
|
|
41
|
-
export default install;
|
|
42
|
-
|
|
43
39
|
export declare const WebPhone: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
44
40
|
|
|
45
41
|
declare interface WebphoneProps {
|