@stonecrop/beam 0.2.49 → 0.2.51

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.
@@ -0,0 +1,29 @@
1
+ import mqtt from 'mqtt';
2
+ import { onMounted, onUnmounted, ref } from 'vue';
3
+ export const useMqttStream = (options) => {
4
+ const client = ref(null);
5
+ const messages = ref({});
6
+ onMounted(() => {
7
+ client.value = mqtt.connect(options);
8
+ if (!options.topics) {
9
+ options.topics = ['#'];
10
+ }
11
+ for (const topic of options.topics) {
12
+ client.value.subscribe(topic, err => {
13
+ if (err) {
14
+ throw err;
15
+ }
16
+ });
17
+ }
18
+ client.value.on('message', (topic, message) => {
19
+ if (!messages.value[topic]) {
20
+ messages.value[topic] = [];
21
+ }
22
+ messages.value[topic].push(message.toString());
23
+ });
24
+ });
25
+ onUnmounted(() => {
26
+ client.value.end();
27
+ });
28
+ return { messages };
29
+ };
package/dist/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import ActionFooter from '@/components/ActionFooter.vue';
2
- import BeamMetadata from './components/BeamMetadata.vue';
2
+ import BeamArrow from '@/components/BeamArrow.vue';
3
+ import BeamBtn from '@/components/BeamBtn.vue';
4
+ import BeamHeading from '@/components/BeamHeading.vue';
5
+ import BeamMetadata from '@/components/BeamMetadata.vue';
3
6
  import BeamModal from '@/components/BeamModal.vue';
4
7
  import BeamModalOutlet from '@/components/BeamModalOutlet.vue';
8
+ import BeamProgress from '@/components/BeamProgress.vue';
5
9
  import Confirm from '@/components/Confirm.vue';
6
10
  import ItemCheck from '@/components/ItemCheck.vue';
7
11
  import ItemCount from '@/components/ItemCount.vue';
@@ -10,11 +14,8 @@ import ListItem from '@/components/ListItem.vue';
10
14
  import ListView from '@/components/ListView.vue';
11
15
  import Navbar from '@/components/Navbar.vue';
12
16
  import ScanInput from '@/components/ScanInput.vue';
13
- import SplitColumn from './components/SplitColumn.vue';
14
- import BeamHeading from './components/BeamHeading.vue';
15
- import BeamArrow from './components/BeamArrow.vue';
16
- import BeamBtn from './components/BeamBtn.vue';
17
- import BeamProgress from './components/BeamProgress.vue';
17
+ import SplitColumn from '@/components/SplitColumn.vue';
18
+ import { useMqttStream } from '@/composables/mqtt';
18
19
  import 'themes/beam.css';
19
20
  /**
20
21
  * Install all Beam components
@@ -23,9 +24,13 @@ import 'themes/beam.css';
23
24
  */
24
25
  function install(app /* options */) {
25
26
  app.component('ActionFooter', ActionFooter);
27
+ app.component('BeamArrow', BeamArrow);
28
+ app.component('BeamBtn', BeamBtn);
29
+ app.component('BeamHeading', BeamHeading);
26
30
  app.component('BeamMetadata', BeamMetadata);
27
31
  app.component('BeamModal', BeamModal);
28
32
  app.component('BeamModalOutlet', BeamModalOutlet);
33
+ app.component('BeamProgress', BeamProgress);
29
34
  app.component('Confirm', Confirm);
30
35
  app.component('ItemCheck', ItemCheck);
31
36
  app.component('ItemCount', ItemCount);
@@ -35,9 +40,5 @@ function install(app /* options */) {
35
40
  app.component('Navbar', Navbar);
36
41
  app.component('ScanInput', ScanInput);
37
42
  app.component('SplitColumn', SplitColumn);
38
- app.component('BeamHeading', BeamHeading);
39
- app.component('BeamArrow', BeamArrow);
40
- app.component('BeamBtn', BeamBtn);
41
- app.component('BeamProgress', BeamProgress);
42
43
  }
43
- export { ActionFooter, BeamMetadata, BeamModal, BeamModalOutlet, Confirm, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, install, };
44
+ export { ActionFooter, BeamArrow, BeamBtn, BeamHeading, BeamMetadata, BeamModal, BeamModalOutlet, BeamProgress, Confirm, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SplitColumn, install, useMqttStream, };
@@ -0,0 +1,9 @@
1
+ import { type IClientOptions } from 'mqtt';
2
+ interface IMqttStream extends IClientOptions {
3
+ topics?: string[];
4
+ }
5
+ export declare const useMqttStream: (options?: IMqttStream) => {
6
+ messages: import("vue").Ref<Record<string, string[]>, Record<string, string[]>>;
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=mqtt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqtt.d.ts","sourceRoot":"","sources":["../../../src/composables/mqtt.ts"],"names":[],"mappings":"AAAA,OAAa,EAAmB,KAAK,cAAc,EAAE,MAAM,MAAM,CAAA;AAGjE,UAAU,WAAY,SAAQ,cAAc;IAC3C,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;CACjB;AAED,eAAO,MAAM,aAAa,aAAc,WAAW;;CAiClD,CAAA"}
@@ -1,8 +1,12 @@
1
1
  import { App } from 'vue';
2
2
  import ActionFooter from '@/components/ActionFooter.vue';
3
- import BeamMetadata from './components/BeamMetadata.vue';
3
+ import BeamArrow from '@/components/BeamArrow.vue';
4
+ import BeamBtn from '@/components/BeamBtn.vue';
5
+ import BeamHeading from '@/components/BeamHeading.vue';
6
+ import BeamMetadata from '@/components/BeamMetadata.vue';
4
7
  import BeamModal from '@/components/BeamModal.vue';
5
8
  import BeamModalOutlet from '@/components/BeamModalOutlet.vue';
9
+ import BeamProgress from '@/components/BeamProgress.vue';
6
10
  import Confirm from '@/components/Confirm.vue';
7
11
  import ItemCheck from '@/components/ItemCheck.vue';
8
12
  import ItemCount from '@/components/ItemCount.vue';
@@ -11,6 +15,8 @@ import ListItem from '@/components/ListItem.vue';
11
15
  import ListView from '@/components/ListView.vue';
12
16
  import Navbar from '@/components/Navbar.vue';
13
17
  import ScanInput from '@/components/ScanInput.vue';
18
+ import SplitColumn from '@/components/SplitColumn.vue';
19
+ import { useMqttStream } from '@/composables/mqtt';
14
20
  import 'themes/beam.css';
15
21
  /**
16
22
  * Install all Beam components
@@ -18,5 +24,5 @@ import 'themes/beam.css';
18
24
  * @public
19
25
  */
20
26
  declare function install(app: App): void;
21
- export { ActionFooter, BeamMetadata, BeamModal, BeamModalOutlet, Confirm, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, install, };
27
+ export { ActionFooter, BeamArrow, BeamBtn, BeamHeading, BeamMetadata, BeamModal, BeamModalOutlet, BeamProgress, Confirm, ItemCheck, ItemCount, ListAnchor, ListItem, ListView, Navbar, ScanInput, SplitColumn, install, useMqttStream, };
22
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,eAAe,MAAM,kCAAkC,CAAA;AAC9D,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAMlD,OAAO,iBAAiB,CAAA;AAExB;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAkBxB;AAED,OAAO,EACN,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,eAAe,EACf,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,OAAO,GACP,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAEzB,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,eAAe,MAAM,kCAAkC,CAAA;AAC9D,OAAO,YAAY,MAAM,+BAA+B,CAAA;AACxD,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,UAAU,MAAM,6BAA6B,CAAA;AACpD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,QAAQ,MAAM,2BAA2B,CAAA;AAChD,OAAO,MAAM,MAAM,yBAAyB,CAAA;AAC5C,OAAO,SAAS,MAAM,4BAA4B,CAAA;AAClD,OAAO,WAAW,MAAM,8BAA8B,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,iBAAiB,CAAA;AAExB;;;;GAIG;AACH,iBAAS,OAAO,CAAC,GAAG,EAAE,GAAG,QAkBxB;AAED,OAAO,EACN,YAAY,EACZ,SAAS,EACT,OAAO,EACP,WAAW,EACX,YAAY,EACZ,SAAS,EACT,eAAe,EACf,YAAY,EACZ,OAAO,EACP,SAAS,EACT,SAAS,EACT,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,SAAS,EACT,WAAW,EACX,OAAO,EACP,aAAa,GACb,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/beam",
3
- "version": "0.2.49",
3
+ "version": "0.2.51",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "author": {
@@ -29,6 +29,7 @@
29
29
  "src/*"
30
30
  ],
31
31
  "dependencies": {
32
+ "mqtt": "^5.10.1",
32
33
  "onscan.js": "^1.5.2",
33
34
  "vue": "^3.5.6"
34
35
  },
@@ -0,0 +1,41 @@
1
+ import mqtt, { type MqttClient, type IClientOptions } from 'mqtt'
2
+ import { onMounted, onUnmounted, ref } from 'vue'
3
+
4
+ interface IMqttStream extends IClientOptions {
5
+ topics?: string[]
6
+ }
7
+
8
+ export const useMqttStream = (options?: IMqttStream) => {
9
+ const client = ref<MqttClient>(null)
10
+ const messages = ref<Record<string, string[]>>({})
11
+
12
+ onMounted(() => {
13
+ client.value = mqtt.connect(options)
14
+
15
+ if (!options.topics) {
16
+ options.topics = ['#']
17
+ }
18
+
19
+ for (const topic of options.topics) {
20
+ client.value.subscribe(topic, err => {
21
+ if (err) {
22
+ throw err
23
+ }
24
+ })
25
+ }
26
+
27
+ client.value.on('message', (topic, message) => {
28
+ if (!messages.value[topic]) {
29
+ messages.value[topic] = []
30
+ }
31
+
32
+ messages.value[topic].push(message.toString())
33
+ })
34
+ })
35
+
36
+ onUnmounted(() => {
37
+ client.value.end()
38
+ })
39
+
40
+ return { messages }
41
+ }
package/src/index.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import { App } from 'vue'
2
2
 
3
3
  import ActionFooter from '@/components/ActionFooter.vue'
4
- import BeamMetadata from './components/BeamMetadata.vue'
4
+ import BeamArrow from '@/components/BeamArrow.vue'
5
+ import BeamBtn from '@/components/BeamBtn.vue'
6
+ import BeamHeading from '@/components/BeamHeading.vue'
7
+ import BeamMetadata from '@/components/BeamMetadata.vue'
5
8
  import BeamModal from '@/components/BeamModal.vue'
6
9
  import BeamModalOutlet from '@/components/BeamModalOutlet.vue'
10
+ import BeamProgress from '@/components/BeamProgress.vue'
7
11
  import Confirm from '@/components/Confirm.vue'
8
12
  import ItemCheck from '@/components/ItemCheck.vue'
9
13
  import ItemCount from '@/components/ItemCount.vue'
@@ -12,11 +16,8 @@ import ListItem from '@/components/ListItem.vue'
12
16
  import ListView from '@/components/ListView.vue'
13
17
  import Navbar from '@/components/Navbar.vue'
14
18
  import ScanInput from '@/components/ScanInput.vue'
15
- import SplitColumn from './components/SplitColumn.vue'
16
- import BeamHeading from './components/BeamHeading.vue'
17
- import BeamArrow from './components/BeamArrow.vue'
18
- import BeamBtn from './components/BeamBtn.vue'
19
- import BeamProgress from './components/BeamProgress.vue'
19
+ import SplitColumn from '@/components/SplitColumn.vue'
20
+ import { useMqttStream } from '@/composables/mqtt'
20
21
  import 'themes/beam.css'
21
22
 
22
23
  /**
@@ -26,9 +27,13 @@ import 'themes/beam.css'
26
27
  */
27
28
  function install(app: App /* options */) {
28
29
  app.component('ActionFooter', ActionFooter)
30
+ app.component('BeamArrow', BeamArrow)
31
+ app.component('BeamBtn', BeamBtn)
32
+ app.component('BeamHeading', BeamHeading)
29
33
  app.component('BeamMetadata', BeamMetadata)
30
34
  app.component('BeamModal', BeamModal)
31
35
  app.component('BeamModalOutlet', BeamModalOutlet)
36
+ app.component('BeamProgress', BeamProgress)
32
37
  app.component('Confirm', Confirm)
33
38
  app.component('ItemCheck', ItemCheck)
34
39
  app.component('ItemCount', ItemCount)
@@ -38,17 +43,17 @@ function install(app: App /* options */) {
38
43
  app.component('Navbar', Navbar)
39
44
  app.component('ScanInput', ScanInput)
40
45
  app.component('SplitColumn', SplitColumn)
41
- app.component('BeamHeading', BeamHeading)
42
- app.component('BeamArrow', BeamArrow)
43
- app.component('BeamBtn', BeamBtn)
44
- app.component('BeamProgress', BeamProgress)
45
46
  }
46
47
 
47
48
  export {
48
49
  ActionFooter,
50
+ BeamArrow,
51
+ BeamBtn,
52
+ BeamHeading,
49
53
  BeamMetadata,
50
54
  BeamModal,
51
55
  BeamModalOutlet,
56
+ BeamProgress,
52
57
  Confirm,
53
58
  ItemCheck,
54
59
  ItemCount,
@@ -57,5 +62,7 @@ export {
57
62
  ListView,
58
63
  Navbar,
59
64
  ScanInput,
65
+ SplitColumn,
60
66
  install,
67
+ useMqttStream,
61
68
  }