@stonecrop/beam 0.11.0 → 0.11.1
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/package.json +1 -1
- package/dist/beam.umd.cjs +0 -10
- package/dist/beam.umd.cjs.map +0 -1
- package/dist/src/composables/mqtt.js +0 -85
- package/dist/src/index.js +0 -56
- package/dist/src/tsdoc-metadata.json +0 -11
- package/dist/src/types/index.js +0 -0
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import mqtt from 'mqtt';
|
|
2
|
-
import { onMounted, onUnmounted, ref } from 'vue';
|
|
3
|
-
/**
|
|
4
|
-
* Use MQTT stream
|
|
5
|
-
* @param options - MQTT stream options
|
|
6
|
-
* @returns MQTT stream messages
|
|
7
|
-
* @beta
|
|
8
|
-
*/
|
|
9
|
-
export const useMqttStream = async (options) => {
|
|
10
|
-
if (options.host && options.port) {
|
|
11
|
-
const portActive = await isPortActive(options.host, options.port);
|
|
12
|
-
if (!portActive) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const client = ref();
|
|
17
|
-
const messages = ref({});
|
|
18
|
-
onMounted(() => {
|
|
19
|
-
client.value = mqtt.connect(options);
|
|
20
|
-
if (!options.topics) {
|
|
21
|
-
options.topics = ['#'];
|
|
22
|
-
}
|
|
23
|
-
for (const topic of options.topics) {
|
|
24
|
-
client.value.subscribe(topic, err => {
|
|
25
|
-
if (err) {
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
client.value.on('message', (topic, message) => {
|
|
31
|
-
if (!messages.value[topic]) {
|
|
32
|
-
messages.value[topic] = [];
|
|
33
|
-
}
|
|
34
|
-
messages.value[topic].push(message.toString());
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
onUnmounted(() => {
|
|
38
|
-
client.value?.end();
|
|
39
|
-
});
|
|
40
|
-
return { messages };
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Check if a local port has a service running
|
|
44
|
-
* @param host the host to check
|
|
45
|
-
* @param port the port to check
|
|
46
|
-
* @returns true if the port has a service running, false otherwise
|
|
47
|
-
*
|
|
48
|
-
* @beta
|
|
49
|
-
*/
|
|
50
|
-
export const isPortActive = async (host, port) => {
|
|
51
|
-
try {
|
|
52
|
-
const controller = new AbortController();
|
|
53
|
-
// Set a timeout of 2 seconds
|
|
54
|
-
const timeoutId = setTimeout(() => controller.abort(), 2000);
|
|
55
|
-
try {
|
|
56
|
-
await fetch(`${host}:${port}`, {
|
|
57
|
-
mode: 'no-cors', // This allows checking without CORS issues
|
|
58
|
-
signal: controller.signal,
|
|
59
|
-
});
|
|
60
|
-
clearTimeout(timeoutId);
|
|
61
|
-
// If we get any response, the port is in use
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
65
|
-
clearTimeout(timeoutId);
|
|
66
|
-
if (error instanceof DOMException && error.name === 'AbortError') {
|
|
67
|
-
// Timeout - port is probably not in use
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
// For connection refused errors, we need to check the error message
|
|
71
|
-
// as different browsers handle this differently
|
|
72
|
-
const errorString = String(error);
|
|
73
|
-
if (errorString.includes('NetworkError') ||
|
|
74
|
-
errorString.includes('Failed to fetch') ||
|
|
75
|
-
errorString.includes('net::ERR_CONNECTION_REFUSED')) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
// If we get here, there might be something running on the port
|
|
79
|
-
return true;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
catch {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
};
|
package/dist/src/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import ActionFooter from './components/ActionFooter.vue';
|
|
2
|
-
import BeamArrow from './components/BeamArrow.vue';
|
|
3
|
-
import BeamBtn from './components/BeamBtn.vue';
|
|
4
|
-
import BeamDayDivider from './components/BeamDayDivider.vue';
|
|
5
|
-
import BeamFilter from './components/BeamFilter.vue';
|
|
6
|
-
import BeamFilterOption from './components/BeamFilterOption.vue';
|
|
7
|
-
import BeamHeading from './components/BeamHeading.vue';
|
|
8
|
-
import BeamMetadata from './components/BeamMetadata.vue';
|
|
9
|
-
import BeamModal from './components/BeamModal.vue';
|
|
10
|
-
import BeamModalOutlet from './components/BeamModalOutlet.vue';
|
|
11
|
-
import BeamProgress from './components/BeamProgress.vue';
|
|
12
|
-
import Confirm from './components/Confirm.vue';
|
|
13
|
-
import FixedTop from './components/FixedTop.vue';
|
|
14
|
-
import ItemCheck from './components/ItemCheck.vue';
|
|
15
|
-
import ItemCount from './components/ItemCount.vue';
|
|
16
|
-
import ListAnchor from './components/ListAnchor.vue';
|
|
17
|
-
import ListItem from './components/ListItem.vue';
|
|
18
|
-
import ListView from './components/ListView.vue';
|
|
19
|
-
import Navbar from './components/Navbar.vue';
|
|
20
|
-
import ScanInput from './components/ScanInput.vue';
|
|
21
|
-
import SegmentedDisplay from './components/SegmentedDisplay.vue';
|
|
22
|
-
import SplitColumn from './components/SplitColumn.vue';
|
|
23
|
-
import ToggleArrow from './components/ToggleArrow.vue';
|
|
24
|
-
import { useMqttStream } from './composables/mqtt';
|
|
25
|
-
import '../themes/beam.css';
|
|
26
|
-
/**
|
|
27
|
-
* Install all Beam components
|
|
28
|
-
* @param app - Vue app instance
|
|
29
|
-
* @public
|
|
30
|
-
*/
|
|
31
|
-
function install(app /* options */) {
|
|
32
|
-
app.component('ActionFooter', ActionFooter);
|
|
33
|
-
app.component('BeamArrow', BeamArrow);
|
|
34
|
-
app.component('BeamBtn', BeamBtn);
|
|
35
|
-
app.component('BeamDayDivider', BeamDayDivider);
|
|
36
|
-
app.component('BeamFilter', BeamFilter);
|
|
37
|
-
app.component('BeamFilterOption', BeamFilterOption);
|
|
38
|
-
app.component('BeamHeading', BeamHeading);
|
|
39
|
-
app.component('BeamMetadata', BeamMetadata);
|
|
40
|
-
app.component('BeamModal', BeamModal);
|
|
41
|
-
app.component('BeamModalOutlet', BeamModalOutlet);
|
|
42
|
-
app.component('BeamProgress', BeamProgress);
|
|
43
|
-
app.component('Confirm', Confirm);
|
|
44
|
-
app.component('FixedTop', FixedTop);
|
|
45
|
-
app.component('ItemCheck', ItemCheck);
|
|
46
|
-
app.component('ItemCount', ItemCount);
|
|
47
|
-
app.component('ListAnchor', ListAnchor);
|
|
48
|
-
app.component('ListItem', ListItem);
|
|
49
|
-
app.component('ListView', ListView);
|
|
50
|
-
app.component('Navbar', Navbar);
|
|
51
|
-
app.component('ScanInput', ScanInput);
|
|
52
|
-
app.component('SegmentedDisplay', SegmentedDisplay);
|
|
53
|
-
app.component('SplitColumn', SplitColumn);
|
|
54
|
-
app.component('ToggleArrow', ToggleArrow);
|
|
55
|
-
}
|
|
56
|
-
export { ActionFooter, BeamArrow, BeamBtn, BeamDayDivider, BeamFilter, BeamFilterOption, BeamHeading, BeamMetadata, BeamModal, BeamModalOutlet, BeamProgress, Confirm, FixedTop, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SegmentedDisplay, SplitColumn, ToggleArrow, install, useMqttStream, };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.57.0"
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
package/dist/src/types/index.js
DELETED
|
File without changes
|