@stonecrop/beam 0.2.64 → 0.2.66
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/dist/beam.d.ts +69 -4
- package/dist/beam.js +2 -2
- package/dist/beam.js.map +1 -1
- package/dist/beam.tsbuildinfo +1 -1
- package/dist/beam.umd.cjs +6 -6
- package/dist/beam.umd.cjs.map +1 -1
- package/dist/composables/mqtt.js +6 -0
- package/dist/src/composables/mqtt.d.ts +7 -5
- package/dist/src/composables/mqtt.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/types/index.d.ts +11 -0
- package/dist/src/types/index.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +4 -4
- package/src/composables/mqtt.ts +8 -4
- package/src/index.ts +1 -1
- package/src/types/index.ts +13 -0
package/dist/beam.d.ts
CHANGED
|
@@ -12,17 +12,17 @@ import BeamModalOutlet from '@/components/BeamModalOutlet.vue';
|
|
|
12
12
|
import BeamProgress from '@/components/BeamProgress.vue';
|
|
13
13
|
import Confirm from '@/components/Confirm.vue';
|
|
14
14
|
import FixedTop from '@/components/FixedTop.vue';
|
|
15
|
+
import type { IClientOptions } from 'mqtt';
|
|
15
16
|
import ItemCheck from '@/components/ItemCheck.vue';
|
|
16
17
|
import ItemCount from '@/components/ItemCount.vue';
|
|
17
18
|
import ListAnchor from '@/components/ListAnchor.vue';
|
|
18
19
|
import ListItem from '@/components/ListItem.vue';
|
|
19
20
|
import ListView from '@/components/ListView.vue';
|
|
20
|
-
import {
|
|
21
|
+
import { MqttClient } from 'mqtt';
|
|
21
22
|
import Navbar from '@/components/Navbar.vue';
|
|
22
23
|
import ScanInput from '@/components/ScanInput.vue';
|
|
23
24
|
import SplitColumn from '@/components/SplitColumn.vue';
|
|
24
25
|
import ToggleArrow from '@/components/ToggleArrow.vue';
|
|
25
|
-
import { useMqttStream } from '@/composables/mqtt';
|
|
26
26
|
|
|
27
27
|
export { ActionFooter }
|
|
28
28
|
|
|
@@ -50,6 +50,14 @@ export { Confirm }
|
|
|
50
50
|
|
|
51
51
|
export { FixedTop }
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* MQTT stream options
|
|
55
|
+
* @public
|
|
56
|
+
*/
|
|
57
|
+
export declare interface IMqttStream extends IClientOptions {
|
|
58
|
+
topics?: string[]
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
/**
|
|
54
62
|
* Install all Beam components
|
|
55
63
|
* @param app - Vue app instance
|
|
@@ -67,7 +75,25 @@ export { ListItem }
|
|
|
67
75
|
|
|
68
76
|
export { ListView }
|
|
69
77
|
|
|
70
|
-
|
|
78
|
+
/**
|
|
79
|
+
* @beta
|
|
80
|
+
*/
|
|
81
|
+
export declare type ListViewItem = {
|
|
82
|
+
description: string
|
|
83
|
+
label: string
|
|
84
|
+
|
|
85
|
+
checked?: boolean
|
|
86
|
+
count?: {
|
|
87
|
+
count: number
|
|
88
|
+
of: number
|
|
89
|
+
uom: string
|
|
90
|
+
}
|
|
91
|
+
date?: string
|
|
92
|
+
dateFormat?: string
|
|
93
|
+
debounce?: number
|
|
94
|
+
linkComponent?: string
|
|
95
|
+
route?: string
|
|
96
|
+
}
|
|
71
97
|
|
|
72
98
|
export { Navbar }
|
|
73
99
|
|
|
@@ -77,6 +103,45 @@ export { SplitColumn }
|
|
|
77
103
|
|
|
78
104
|
export { ToggleArrow }
|
|
79
105
|
|
|
80
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Use MQTT stream
|
|
108
|
+
* @param options - MQTT stream options
|
|
109
|
+
* @returns MQTT stream messages
|
|
110
|
+
* @beta
|
|
111
|
+
*/
|
|
112
|
+
export declare const useMqttStream = (options?: IMqttStream) => {
|
|
113
|
+
const client = ref<MqttClient>(null)
|
|
114
|
+
const messages = ref<Record<string, string[]>>({})
|
|
115
|
+
|
|
116
|
+
onMounted(() => {
|
|
117
|
+
client.value = mqtt.connect(options)
|
|
118
|
+
|
|
119
|
+
if (!options.topics) {
|
|
120
|
+
options.topics = ['#']
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
for (const topic of options.topics) {
|
|
124
|
+
client.value.subscribe(topic, err => {
|
|
125
|
+
if (err) {
|
|
126
|
+
throw err
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
client.value.on('message', (topic, message) => {
|
|
132
|
+
if (!messages.value[topic]) {
|
|
133
|
+
messages.value[topic] = []
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
messages.value[topic].push(message.toString())
|
|
137
|
+
})
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
onUnmounted(() => {
|
|
141
|
+
client.value.end()
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
return { messages }
|
|
145
|
+
};
|
|
81
146
|
|
|
82
147
|
export { }
|
package/dist/beam.js
CHANGED
|
@@ -6445,7 +6445,7 @@ var Rs, nh = Ze(() => {
|
|
|
6445
6445
|
};
|
|
6446
6446
|
e.default = t;
|
|
6447
6447
|
}), _h = me((e, n) => {
|
|
6448
|
-
n.exports = { version: "5.10.
|
|
6448
|
+
n.exports = { version: "5.10.3" };
|
|
6449
6449
|
}), cr = me((e) => {
|
|
6450
6450
|
ae(), ue(), le(), Object.defineProperty(e, "__esModule", { value: !0 }), e.MQTTJS_VERSION = e.nextTick = e.applyMixin = e.ErrorWithReasonCode = void 0;
|
|
6451
6451
|
var n = class qs extends Error {
|
|
@@ -8555,7 +8555,7 @@ var Rs, nh = Ze(() => {
|
|
|
8555
8555
|
if (l === 0) r.reconnecting = !1, r._onConnect(s);
|
|
8556
8556
|
else if (l > 0) {
|
|
8557
8557
|
let f = new u.ErrorWithReasonCode(`Connection refused: ${t.ReasonCodes[l]}`, l);
|
|
8558
|
-
r.emit("error", f);
|
|
8558
|
+
r.emit("error", f), r.options.reconnectOnConnackError && r._cleanUp(!0);
|
|
8559
8559
|
}
|
|
8560
8560
|
};
|
|
8561
8561
|
e.default = i;
|