@norgate-av/react-crestron-ch5-hooks 1.0.0 → 1.1.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.
Files changed (59) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +96 -63
  3. package/dist/index.cjs +1 -0
  4. package/dist/index.d.cts +259 -0
  5. package/dist/index.d.ts +259 -2
  6. package/dist/index.js +1 -8
  7. package/package.json +41 -92
  8. package/dist/hooks/index.d.ts +0 -18
  9. package/dist/hooks/useCrestronAnalog/index.d.ts +0 -11
  10. package/dist/hooks/useCrestronAnalogCollection/index.d.ts +0 -12
  11. package/dist/hooks/useCrestronDigital/index.d.ts +0 -11
  12. package/dist/hooks/useCrestronDigitalCollection/index.d.ts +0 -12
  13. package/dist/hooks/useCrestronPublishAnalog/index.d.ts +0 -9
  14. package/dist/hooks/useCrestronPublishAnalogCollection/index.d.ts +0 -10
  15. package/dist/hooks/useCrestronPublishDigital/index.d.ts +0 -9
  16. package/dist/hooks/useCrestronPublishDigitalCollection/index.d.ts +0 -10
  17. package/dist/hooks/useCrestronPublishSerial/index.d.ts +0 -9
  18. package/dist/hooks/useCrestronPublishSerialCollection/index.d.ts +0 -10
  19. package/dist/hooks/useCrestronSerial/index.d.ts +0 -11
  20. package/dist/hooks/useCrestronSerialCollection/index.d.ts +0 -12
  21. package/dist/hooks/useCrestronSubscribeAnalog/index.d.ts +0 -11
  22. package/dist/hooks/useCrestronSubscribeAnalogCollection/index.d.ts +0 -12
  23. package/dist/hooks/useCrestronSubscribeDigital/index.d.ts +0 -11
  24. package/dist/hooks/useCrestronSubscribeDigitalCollection/index.d.ts +0 -12
  25. package/dist/hooks/useCrestronSubscribeSerial/index.d.ts +0 -11
  26. package/dist/hooks/useCrestronSubscribeSerialCollection/index.d.ts +0 -12
  27. package/dist/react-crestron-ch5-hooks.cjs.development.js +0 -643
  28. package/dist/react-crestron-ch5-hooks.cjs.development.js.map +0 -1
  29. package/dist/react-crestron-ch5-hooks.cjs.production.min.js +0 -2
  30. package/dist/react-crestron-ch5-hooks.cjs.production.min.js.map +0 -1
  31. package/dist/react-crestron-ch5-hooks.esm.js +0 -602
  32. package/dist/react-crestron-ch5-hooks.esm.js.map +0 -1
  33. package/dist/react-crestron-ch5-hooks.umd.development.js +0 -645
  34. package/dist/react-crestron-ch5-hooks.umd.development.js.map +0 -1
  35. package/dist/react-crestron-ch5-hooks.umd.production.min.js +0 -2
  36. package/dist/react-crestron-ch5-hooks.umd.production.min.js.map +0 -1
  37. package/dist/types/Analog/index.d.ts +0 -1
  38. package/dist/types/AnalogStateCallback/index.d.ts +0 -3
  39. package/dist/types/Digital/index.d.ts +0 -1
  40. package/dist/types/DigitalStateCallback/index.d.ts +0 -3
  41. package/dist/types/IAnalogEventAction/index.d.ts +0 -4
  42. package/dist/types/IAnalogSignal/index.d.ts +0 -5
  43. package/dist/types/IAnalogState/index.d.ts +0 -4
  44. package/dist/types/IBaseEventAction/index.d.ts +0 -3
  45. package/dist/types/IBaseSignal/index.d.ts +0 -4
  46. package/dist/types/IBaseState/index.d.ts +0 -3
  47. package/dist/types/IDigitalEventAction/index.d.ts +0 -7
  48. package/dist/types/IDigitalSignal/index.d.ts +0 -5
  49. package/dist/types/IDigitalState/index.d.ts +0 -4
  50. package/dist/types/ISerialEventAction/index.d.ts +0 -4
  51. package/dist/types/ISerialSignal/index.d.ts +0 -5
  52. package/dist/types/ISerialState/index.d.ts +0 -4
  53. package/dist/types/IStateSubscription/index.d.ts +0 -4
  54. package/dist/types/Serial/index.d.ts +0 -1
  55. package/dist/types/SerialStateCallback/index.d.ts +0 -3
  56. package/dist/types/StateCallback/index.d.ts +0 -1
  57. package/dist/types/index.d.ts +0 -20
  58. package/dist/utils/getSignalCollection.d.ts +0 -3
  59. package/dist/utils/index.d.ts +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Norgate AV Solutions Ltd
3
+ Copyright (c) 2010-2026 Norgate AV
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -7,12 +7,12 @@
7
7
 
8
8
  ---
9
9
 
10
- [![CI](https://github.com/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks/actions/workflows/main.yml/badge.svg?branch=develop)](https://github.com/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks/actions/workflows/main.yml)
11
- [![codecov](https://codecov.io/gh/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks/branch/develop/graph/badge.svg?token=ZA36O8UTSI)](https://codecov.io/gh/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks)
12
- [![Coverage Status](https://coveralls.io/repos/github/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks/badge.svg?branch=develop)](https://coveralls.io/github/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks?branch=develop)
10
+ [![CI](https://github.com/Norgate-AV/react-crestron-ch5-hooks/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/Norgate-AV/react-crestron-ch5-hooks/actions/workflows/ci.yml)
11
+ [![codecov](https://codecov.io/gh/Norgate-AV/react-crestron-ch5-hooks/branch/develop/graph/badge.svg?token=ZA36O8UTSI)](https://codecov.io/gh/Norgate-AV/react-crestron-ch5-hooks)
12
+ [![Coverage Status](https://coveralls.io/repos/github/Norgate-AV/react-crestron-ch5-hooks/badge.svg?branch=master)](https://coveralls.io/github/Norgate-AV/react-crestron-ch5-hooks?branch=master)
13
13
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
14
14
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
- [![GitHub contributors](https://img.shields.io/github/contributors/Norgate-AV-Solutions-Ltd/react-crestron-ch5-hooks)](#contributors)
15
+ [![GitHub contributors](https://img.shields.io/github/contributors/Norgate-AV/react-crestron-ch5-hooks)](#contributors)
16
16
  [![NPM](https://img.shields.io/npm/v/@norgate-av/react-crestron-ch5-hooks.svg)](https://www.npmjs.com/package/@norgate-av/react-crestron-ch5-hooks)
17
17
  [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
18
18
 
@@ -25,59 +25,59 @@ A collection of React custom hooks ⚓ for Crestron CH5 project development.
25
25
 
26
26
  ## Contents 📖
27
27
 
28
- - [Features :package:](#features-package)
29
- - [Installation :zap:](#installation-zap)
30
- - [Usage :rocket:](#usage-rocket)
31
- - [Publish :arrow_right:](#publish-arrow_right)
32
- - [useCrestronPublishAnalog](#usecrestronpublishanalog)
33
- - [useCrestronPublishDigital](#usecrestronpublishdigital)
34
- - [useCrestronPublishSerial](#usecrestronpublishserial)
35
- - [useCrestronPublishAnalogCollection](#usecrestronpublishanalogcollection)
36
- - [useCrestronPublishDigitalCollection](#usecrestronpublishdigitalcollection)
37
- - [useCrestronPublishSerialCollection](#usecrestronpublishserialcollection)
38
- - [Subscribe :arrow_left:](#subscribe-arrow_left)
39
- - [useCrestronSubscribeAnalog](#usecrestronsubscribeanalog)
40
- - [useCrestronSubscribeDigital](#usecrestronsubscribedigital)
41
- - [useCrestronSubscribeSerial](#usecrestronsubscribeserial)
42
- - [useCrestronSubscribeAnalogCollection](#usecrestronsubscribeanalogcollection)
43
- - [useCrestronSubscribeDigitalCollection](#usecrestronsubscribedigitalcollection)
44
- - [useCrestronSubscribeSerialCollection](#usecrestronsubscribeserialcollection)
45
- - [Publish & Subscribe :left_right_arrow:](#publish--subscribe-left_right_arrow)
46
- - [useCrestronAnalog](#usecrestronanalog)
47
- - [useCrestronDigital](#usecrestrondigital)
48
- - [useCrestronSerial](#usecrestronserial)
49
- - [useCrestronAnalogCollection](#usecrestronanalogcollection)
50
- - [useCrestronDigitalCollection](#usecrestrondigitalcollection)
51
- - [useCrestronSerialCollection](#usecrestronserialcollection)
52
- - [Optional Subscribe Callback :phone:](#optional-subscribe-callback-phone)
53
- - [Types :keyboard:](#types-keyboard)
54
- - [Aliases](#aliases)
55
- - [Analog](#analog)
56
- - [Digital](#digital)
57
- - [Serial](#serial)
58
- - [Event Actions](#event-actions)
59
- - [IBaseEventAction](#ibaseeventaction)
60
- - [IAnalogEventAction](#ianalogeventaction)
61
- - [IDigitalEventAction](#idigitaleventaction)
62
- - [ISerialEventAction](#iserialeventaction)
63
- - [State](#state)
64
- - [IBaseState](#ibasestate)
65
- - [IAnalogState](#ianalogstate)
66
- - [IDigitalState](#idigitalstate)
67
- - [ISerialState](#iserialstate)
68
- - [IStateSubscription](#istatesubscription)
69
- - [StateCallback](#statecallback)
70
- - [AnalogStateCallback](#analogstatecallback)
71
- - [DigitalStateCallback](#digitalstatecallback)
72
- - [SerialStateCallback](#serialstatecallback)
73
- - [Signals](#signals)
74
- - [IBaseSignal](#ibasesignal)
75
- - [IAnalogSignal](#ianalogsignal)
76
- - [IDigitalSignal](#idigitalsignal)
77
- - [ISerialSignal](#iserialsignal)
78
- - [Team :soccer:](#team-soccer)
79
- - [Contributors :sparkles:](#contributors-sparkles)
80
- - [LICENSE :balance_scale:](#license-balance_scale)
28
+ - [Features :package:](#features-package)
29
+ - [Installation :zap:](#installation-zap)
30
+ - [Usage :rocket:](#usage-rocket)
31
+ - [Publish :arrow_right:](#publish-arrow_right)
32
+ - [useCrestronPublishAnalog](#usecrestronpublishanalog)
33
+ - [useCrestronPublishDigital](#usecrestronpublishdigital)
34
+ - [useCrestronPublishSerial](#usecrestronpublishserial)
35
+ - [useCrestronPublishAnalogCollection](#usecrestronpublishanalogcollection)
36
+ - [useCrestronPublishDigitalCollection](#usecrestronpublishdigitalcollection)
37
+ - [useCrestronPublishSerialCollection](#usecrestronpublishserialcollection)
38
+ - [Subscribe :arrow_left:](#subscribe-arrow_left)
39
+ - [useCrestronSubscribeAnalog](#usecrestronsubscribeanalog)
40
+ - [useCrestronSubscribeDigital](#usecrestronsubscribedigital)
41
+ - [useCrestronSubscribeSerial](#usecrestronsubscribeserial)
42
+ - [useCrestronSubscribeAnalogCollection](#usecrestronsubscribeanalogcollection)
43
+ - [useCrestronSubscribeDigitalCollection](#usecrestronsubscribedigitalcollection)
44
+ - [useCrestronSubscribeSerialCollection](#usecrestronsubscribeserialcollection)
45
+ - [Publish & Subscribe :left_right_arrow:](#publish--subscribe-left_right_arrow)
46
+ - [useCrestronAnalog](#usecrestronanalog)
47
+ - [useCrestronDigital](#usecrestrondigital)
48
+ - [useCrestronSerial](#usecrestronserial)
49
+ - [useCrestronAnalogCollection](#usecrestronanalogcollection)
50
+ - [useCrestronDigitalCollection](#usecrestrondigitalcollection)
51
+ - [useCrestronSerialCollection](#usecrestronserialcollection)
52
+ - [Optional Subscribe Callback :phone:](#optional-subscribe-callback-phone)
53
+ - [Types :keyboard:](#types-keyboard)
54
+ - [Aliases](#aliases)
55
+ - [Analog](#analog)
56
+ - [Digital](#digital)
57
+ - [Serial](#serial)
58
+ - [Event Actions](#event-actions)
59
+ - [IBaseEventAction](#ibaseeventaction)
60
+ - [IAnalogEventAction](#ianalogeventaction)
61
+ - [IDigitalEventAction](#idigitaleventaction)
62
+ - [ISerialEventAction](#iserialeventaction)
63
+ - [State](#state)
64
+ - [IBaseState](#ibasestate)
65
+ - [IAnalogState](#ianalogstate)
66
+ - [IDigitalState](#idigitalstate)
67
+ - [ISerialState](#iserialstate)
68
+ - [IStateSubscription](#istatesubscription)
69
+ - [StateCallback](#statecallback)
70
+ - [AnalogStateCallback](#analogstatecallback)
71
+ - [DigitalStateCallback](#digitalstatecallback)
72
+ - [SerialStateCallback](#serialstatecallback)
73
+ - [Signals](#signals)
74
+ - [IBaseSignal](#ibasesignal)
75
+ - [IAnalogSignal](#ianalogsignal)
76
+ - [IDigitalSignal](#idigitalsignal)
77
+ - [ISerialSignal](#iserialsignal)
78
+ - [Team :soccer:](#team-soccer)
79
+ - [Contributors :sparkles:](#contributors-sparkles)
80
+ - [LICENSE :balance_scale:](#license-balance_scale)
81
81
 
82
82
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
83
83
 
@@ -97,6 +97,10 @@ npm install @norgate-av/react-crestron-ch5-hooks
97
97
  # or
98
98
 
99
99
  yarn add @norgate-av/react-crestron-ch5-hooks
100
+
101
+ # or
102
+
103
+ pnpm add @norgate-av/react-crestron-ch5-hooks
100
104
  ```
101
105
 
102
106
  ## Usage :rocket:
@@ -148,6 +152,8 @@ export const SomeAwesomeComponent = () => {
148
152
  </button>
149
153
 
150
154
  <button onClick={() => action.click()}>Click</button>
155
+
156
+ <button onTouchStart={() => action.hold(2000)}>Hold</button>
151
157
  </div>
152
158
  );
153
159
  };
@@ -232,6 +238,8 @@ export const SomeAwesomeComponent = () => {
232
238
 
233
239
  <button onClick={() => action1.click()}>Click 1</button>
234
240
 
241
+ <button onTouchStart={() => action1.hold(2000)}>Hold 1</button>
242
+
235
243
  <button
236
244
  onTouchStart={() => action2.setValue(true)}
237
245
  onTouchEnd={() => action2.setValue(false)}
@@ -248,6 +256,8 @@ export const SomeAwesomeComponent = () => {
248
256
 
249
257
  <button onClick={() => action2.click()}>Click 2</button>
250
258
 
259
+ <button onTouchStart={() => action2.hold(2000)}>Hold 2</button>
260
+
251
261
  <button
252
262
  onTouchStart={() => action3.setValue(true)}
253
263
  onTouchEnd={() => action3.setValue(false)}
@@ -262,6 +272,8 @@ export const SomeAwesomeComponent = () => {
262
272
  Push/Release 3
263
273
  </button>
264
274
  <button onClick={() => action3.click()}>Click 3</button>
275
+
276
+ <button onTouchStart={() => action3.hold(2000)}>Hold 3</button>
265
277
  </div>
266
278
  );
267
279
  };
@@ -493,6 +505,8 @@ export const SomeAwesomeComponent = () => {
493
505
  </button>
494
506
 
495
507
  <button onClick={() => signal.action.click()}>Click</button>
508
+
509
+ <button onTouchStart={() => signal.action.hold(2000)}>Hold</button>
496
510
  </div>
497
511
  );
498
512
  };
@@ -595,6 +609,10 @@ export const SomeAwesomeComponent = () => {
595
609
 
596
610
  <button onClick={() => signal1.action.click()}>Click 1</button>
597
611
 
612
+ <button onTouchStart={() => signal1.action.hold(2000)}>
613
+ Hold 1
614
+ </button>
615
+
598
616
  <button
599
617
  onTouchStart={() => signal2.action.setValue(true)}
600
618
  onTouchEnd={() => signal2.action.setValue(false)}
@@ -611,6 +629,10 @@ export const SomeAwesomeComponent = () => {
611
629
 
612
630
  <button onClick={() => signal2.action.click()}>Click 2</button>
613
631
 
632
+ <button onTouchStart={() => signal2.action.hold(2000)}>
633
+ Hold 2
634
+ </button>
635
+
614
636
  <button
615
637
  onTouchStart={() => signal3.action.setValue(true)}
616
638
  onTouchEnd={() => signal3.action.setValue(false)}
@@ -625,6 +647,10 @@ export const SomeAwesomeComponent = () => {
625
647
  Push/Release 3
626
648
  </button>
627
649
  <button onClick={() => signal3.action.click()}>Click 3</button>
650
+
651
+ <button onTouchStart={() => signal3.action.hold(2000)}>
652
+ Hold 3
653
+ </button>
628
654
  </div>
629
655
  );
630
656
  };
@@ -770,6 +796,7 @@ export declare interface IDigitalEventAction extends IBaseEventAction<Digital> {
770
796
  push: () => void;
771
797
  release: () => void;
772
798
  click: () => void;
799
+ hold: (duration: number) => void;
773
800
  }
774
801
  ```
775
802
 
@@ -854,22 +881,28 @@ export declare interface IBaseSignal<TState, TAction> {
854
881
  #### IAnalogSignal
855
882
 
856
883
  ```ts
857
- export declare interface IAnalogSignal
858
- extends IBaseSignal<IAnalogState, IAnalogEventAction> {}
884
+ export declare interface IAnalogSignal extends IBaseSignal<
885
+ IAnalogState,
886
+ IAnalogEventAction
887
+ > {}
859
888
  ```
860
889
 
861
890
  #### IDigitalSignal
862
891
 
863
892
  ```ts
864
- export declare interface IDigitalSignal
865
- extends IBaseSignal<IDigitalState, IDigitalEventAction> {}
893
+ export declare interface IDigitalSignal extends IBaseSignal<
894
+ IDigitalState,
895
+ IDigitalEventAction
896
+ > {}
866
897
  ```
867
898
 
868
899
  #### ISerialSignal
869
900
 
870
901
  ```ts
871
- export declare interface ISerialSignal
872
- extends IBaseSignal<ISerialState, ISerialEventAction> {}
902
+ export declare interface ISerialSignal extends IBaseSignal<
903
+ ISerialState,
904
+ ISerialEventAction
905
+ > {}
873
906
  ```
874
907
 
875
908
  ## Team :soccer:
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var e=require("react"),t=require("@crestron/ch5-crcomlib");function r(e){return e&&e.__esModule?e:{default:e}}var u=r(require("@norgate-av/crestron-ch5-helper"));function s(r){let s=e.useCallback(e=>t.publishEvent(u.default.SignalType.Number,r,e),[r]);return e.useMemo(()=>[{setValue:s}],[s])}var n=s;function l(r,s){let[n,l]=e.useState(0),o=e.useRef(void 0);return e.useEffect(()=>{o.current=s},[s]),e.useEffect(()=>{let e=u.default.SignalType.Number,s=t.subscribeState(e,r,e=>{l(e),o.current&&o.current(e,r)});return()=>{t.unsubscribeState(e,r,s)}},[r]),[{value:n}]}var o=l;function a(e,t){let[r]=l(e,t),[u]=s(e);return[{state:r,action:u}]}var i=a;function c(r){let s=e.useCallback(e=>t.publishEvent(u.default.SignalType.Boolean,r,e),[r]),n=e.useCallback(()=>s(!0),[s]),l=e.useCallback(()=>s(!1),[s]),o=e.useCallback(e=>{n(),setTimeout(l,e)},[n,l]),a=e.useCallback(()=>o(0),[o]);return e.useMemo(()=>[{setValue:s,push:n,release:l,hold:o,click:a}],[s,n,l,o,a])}var b=c;function f(r,s){let[n,l]=e.useState(!1),o=e.useRef(void 0);return e.useEffect(()=>{o.current=s},[s]),e.useEffect(()=>{let e=u.default.SignalType.Boolean,s=t.subscribeState(e,r,e=>{l(e),o.current&&o.current(e,r)});return()=>{t.unsubscribeState(e,r,s)}},[r]),[{value:n}]}var p=f;function C(e,t){let[r]=f(e,t),[u]=c(e);return[{state:r,action:u}]}var S=C;function g(r){let s=e.useCallback(e=>t.publishEvent(u.default.SignalType.String,r,e),[r]);return e.useMemo(()=>[{setValue:s}],[s])}var h=g;function v(r,s){let[n,l]=e.useState(""),o=e.useRef(void 0);return e.useEffect(()=>{o.current=s},[s]),e.useEffect(()=>{let e=u.default.SignalType.String,s=t.subscribeState(e,r,e=>{l(e),o.current&&o.current(e,r)});return()=>{t.unsubscribeState(e,r,s)}},[r]),[{value:n}]}var x=v;function m(e,t){let[r]=v(e,t),[u]=g(e);return[{state:r,action:u}]}var d=m;function E(e,t,r){let u=[];for(let s=0;s<e;s++)u.push({state:t[s],action:r[s]});return u}function N(r){return e.useMemo(()=>r.map(e=>({setValue:r=>t.publishEvent(u.default.SignalType.Number,e,r)})),[r])}var y=N;function T(r,s){let[n,l]=e.useState(Array.from({length:r.length},()=>({value:0}))),o=e.useRef(void 0);return e.useEffect(()=>{o.current=s},[s]),e.useEffect(()=>{let e=u.default.SignalType.Number,s=[];r.forEach((r,u)=>{let n=t.subscribeState(e,r,e=>{l(t=>{let r=[...t];return r[u]={...r[u],value:e},r}),o.current&&o.current(e,r)});s.push({id:n,signalName:r})});return()=>{s.forEach(({id:r,signalName:u})=>{t.unsubscribeState(e,u,r)})}},[]),n}var P=T;function B(e,t){let r=T(e,t),u=N(e);return E(e.length,r,u)}var k=B;function A(r){return e.useMemo(()=>r.map(e=>{let r=r=>{t.publishEvent(u.default.SignalType.Boolean,e,r)},s=()=>r(!0),n=()=>r(!1),l=e=>{s(),setTimeout(n,e)};return{setValue:r,push:s,release:n,hold:l,click:()=>l(0)}}),[r])}var M=A;function D(r,s){let[n,l]=e.useState(Array.from({length:r.length},()=>({value:!1}))),o=e.useRef(void 0);return e.useEffect(()=>{o.current=s},[s]),e.useEffect(()=>{let e=u.default.SignalType.Boolean,s=[];r.forEach((r,u)=>{let n=t.subscribeState(e,r,e=>{l(t=>{let r=[...t];return r[u]={...r[u],value:e},r}),o.current&&o.current(e,r)});s.push({id:n,signalName:r})});return()=>{s.forEach(({id:r,signalName:u})=>{t.unsubscribeState(e,u,r)})}},[]),n}var R=D;function V(e,t){let r=D(e,t),u=A(e);return E(e.length,r,u)}var q=V;function _(r){return e.useMemo(()=>r.map(e=>({setValue:r=>t.publishEvent(u.default.SignalType.String,e,r)})),[r])}var j=_;function w(r,s){let[n,l]=e.useState(Array.from({length:r.length},()=>({value:""}))),o=e.useRef(void 0);return e.useEffect(()=>{o.current=s},[s]),e.useEffect(()=>{let e=u.default.SignalType.String,s=[];r.forEach((r,u)=>{let n=t.subscribeState(e,r,e=>{l(t=>{let r=[...t];return r[u]={...r[u],value:e},r}),o.current&&o.current(e,r)});s.push({id:n,signalName:r})});return()=>{s.forEach(({id:r,signalName:u})=>{t.unsubscribeState(e,u,r)})}},[]),n}var z=w;function F(e,t){let r=w(e,t),u=_(e);return E(e.length,r,u)}var G=F;exports.useCrestronAnalog=a,exports.useCrestronAnalogCollection=B,exports.useCrestronBoolean=S,exports.useCrestronBooleanCollection=q,exports.useCrestronDigital=C,exports.useCrestronDigitalCollection=V,exports.useCrestronNumber=i,exports.useCrestronNumberCollection=k,exports.useCrestronPublishAnalog=s,exports.useCrestronPublishAnalogCollection=N,exports.useCrestronPublishBoolean=b,exports.useCrestronPublishBooleanCollection=M,exports.useCrestronPublishDigital=c,exports.useCrestronPublishDigitalCollection=A,exports.useCrestronPublishNumber=n,exports.useCrestronPublishNumberCollection=y,exports.useCrestronPublishSerial=g,exports.useCrestronPublishSerialCollection=_,exports.useCrestronPublishString=h,exports.useCrestronPublishStringCollection=j,exports.useCrestronSerial=m,exports.useCrestronSerialCollection=F,exports.useCrestronString=d,exports.useCrestronStringCollection=G,exports.useCrestronSubscribeAnalog=l,exports.useCrestronSubscribeAnalogCollection=T,exports.useCrestronSubscribeBoolean=p,exports.useCrestronSubscribeBooleanCollection=R,exports.useCrestronSubscribeDigital=f,exports.useCrestronSubscribeDigitalCollection=D,exports.useCrestronSubscribeNumber=o,exports.useCrestronSubscribeNumberCollection=P,exports.useCrestronSubscribeSerial=v,exports.useCrestronSubscribeSerialCollection=w,exports.useCrestronSubscribeString=x,exports.useCrestronSubscribeStringCollection=z;
@@ -0,0 +1,259 @@
1
+ type Analog = number;
2
+
3
+ interface IAnalogEventAction extends IBaseEventAction<Analog> {
4
+ }
5
+
6
+ interface IAnalogState extends IBaseState<Analog> {
7
+ }
8
+
9
+ interface IAnalogSignal extends IBaseSignal<IAnalogState, IAnalogEventAction> {
10
+ }
11
+
12
+ type AnalogStateCallback = StateCallback<Analog>;
13
+
14
+ type Digital = boolean;
15
+
16
+ interface IDigitalEventAction extends IBaseEventAction<Digital> {
17
+ push: () => void;
18
+ release: () => void;
19
+ click: () => void;
20
+ hold: (duration: number) => void;
21
+ }
22
+
23
+ interface IDigitalState extends IBaseState<Digital> {
24
+ }
25
+
26
+ interface IDigitalSignal extends IBaseSignal<IDigitalState, IDigitalEventAction> {
27
+ }
28
+
29
+ type DigitalStateCallback = StateCallback<Digital>;
30
+
31
+ type Serial = string;
32
+
33
+ interface ISerialEventAction extends IBaseEventAction<Serial> {
34
+ }
35
+
36
+ interface ISerialState extends IBaseState<Serial> {
37
+ }
38
+
39
+ interface ISerialSignal extends IBaseSignal<ISerialState, ISerialEventAction> {
40
+ }
41
+
42
+ type SerialStateCallback = StateCallback<Serial>;
43
+
44
+ type StateCallback<T> = (value: T, signalName?: string) => void;
45
+
46
+ interface IStateSubscription {
47
+ id: string;
48
+ signalName: string;
49
+ }
50
+
51
+ interface IBaseEventAction<T> {
52
+ setValue: (value: T) => void;
53
+ }
54
+
55
+ interface IBaseState<T> {
56
+ value: T;
57
+ }
58
+
59
+ interface IBaseSignal<TState, TAction> {
60
+ state: TState;
61
+ action: TAction;
62
+ }
63
+
64
+ /**
65
+ * `useCrestronAnalog` is a hook that returns an object with a state and action property.
66
+ * @param {string} signalName - The name of the signal you want to use.
67
+ * @param {AnalogStateCallback} [callback] - An optional callback function that will be called whenever the state of the signal
68
+ * changes.
69
+ * @returns An array with a single IAnalogSignal object.
70
+ */
71
+ declare function useCrestronAnalog(signalName: string, callback?: AnalogStateCallback): [IAnalogSignal];
72
+
73
+ declare const useCrestronNumber: typeof useCrestronAnalog;
74
+
75
+ /**
76
+ * `useCrestronDigital` is a hook that returns an object with a state and action property.
77
+ * @param {string} signalName - The name of the signal you want to use.
78
+ * @param {DigitalStateCallback} [callback] - An optional callback function that will be called whenever the state of the signal
79
+ * changes.
80
+ * @returns An array with a single IDigitalSignal object
81
+ */
82
+ declare function useCrestronDigital(signalName: string, callback?: DigitalStateCallback): [IDigitalSignal];
83
+
84
+ declare const useCrestronBoolean: typeof useCrestronDigital;
85
+
86
+ /**
87
+ * `useCrestronSerial` is a hook that returns an object with a state and action property.
88
+ * @param {string} signalName - The name of the signal you want to use.
89
+ * @param {SerialStateCallback} [callback] - An optional callback function that will be called whenever the state of the signal
90
+ * changes.
91
+ * @returns An array with a single ISerialSignal object.
92
+ */
93
+ declare function useCrestronSerial(signalName: string, callback?: SerialStateCallback): [ISerialSignal];
94
+
95
+ declare const useCrestronString: typeof useCrestronSerial;
96
+
97
+ /**
98
+ * `useCrestronAnalogCollection` is a hook that returns an array of objects each with state and action properties.
99
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
100
+ * to use.
101
+ * @param {AnalogStateCallback} [callback] - A optional callback function that will be called whenever the state of
102
+ * the signal changes.
103
+ * @returns An array of IAnalogSignal objects.
104
+ */
105
+ declare function useCrestronAnalogCollection(signalNames: string[], callback?: AnalogStateCallback): IAnalogSignal[];
106
+
107
+ declare const useCrestronNumberCollection: typeof useCrestronAnalogCollection;
108
+
109
+ /**
110
+ * `useCrestronDigitalCollection` is a hook that returns an array of objects each with state and action properties.
111
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
112
+ * to use.
113
+ * @param {DigitalStateCallback} [callback] - A optional callback function that will be called whenever the state of
114
+ * the signal changes.
115
+ * @returns An array of IDigitalSignal objects.
116
+ */
117
+ declare function useCrestronDigitalCollection(signalNames: string[], callback?: DigitalStateCallback): IDigitalSignal[];
118
+
119
+ declare const useCrestronBooleanCollection: typeof useCrestronDigitalCollection;
120
+
121
+ /**
122
+ * `useCrestronSerialCollection` is a hook that returns an array of objects each with state and action properties.
123
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
124
+ * to use.
125
+ * @param {SerialStateCallback} [callback] - A optional callback function that will be called whenever the state of
126
+ * the signal changes.
127
+ * @returns An array of ISerialSignal objects.
128
+ */
129
+ declare function useCrestronSerialCollection(signalNames: string[], callback?: SerialStateCallback): ISerialSignal[];
130
+
131
+ declare const useCrestronStringCollection: typeof useCrestronSerialCollection;
132
+
133
+ /**
134
+ * `useCrestronPublishAnalog` is a hook that returns an object with a setValue function.
135
+ * @param {string} signalName - The name of the signal you want to publish to.
136
+ * @returns An array with a single IAnalogEventAction object.
137
+ */
138
+ declare function useCrestronPublishAnalog(signalName: string): [IAnalogEventAction];
139
+
140
+ declare const useCrestronPublishNumber: typeof useCrestronPublishAnalog;
141
+
142
+ /**
143
+ * `useCrestronPublishDigital` is a hook that returns an object with setValue, push, release and click functions.
144
+ * @param {string} signalName - The name of the signal you want to publish to.
145
+ * @returns An array with a single IDigitalEventAction object.
146
+ */
147
+ declare function useCrestronPublishDigital(signalName: string): [IDigitalEventAction];
148
+
149
+ declare const useCrestronPublishBoolean: typeof useCrestronPublishDigital;
150
+
151
+ /**
152
+ * `useCrestronPublishSerial` is a hook that returns an object with a setValue function.
153
+ * @param {string} signalName - The name of the signal you want to publish to.
154
+ * @returns An array with a single ISerialEventAction object.
155
+ */
156
+ declare function useCrestronPublishSerial(signalName: string): [ISerialEventAction];
157
+
158
+ declare const useCrestronPublishString: typeof useCrestronPublishSerial;
159
+
160
+ /**
161
+ * `useCrestronPublishAnalogCollection` is a hook that returns an array of objects each with a setValue function.
162
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
163
+ * to publish to.
164
+ * @returns An array of IAnalogEventAction objects.
165
+ */
166
+ declare function useCrestronPublishAnalogCollection(signalNames: string[]): IAnalogEventAction[];
167
+
168
+ declare const useCrestronPublishNumberCollection: typeof useCrestronPublishAnalogCollection;
169
+
170
+ /**
171
+ * `useCrestronPublishDigitalCollection` is a hook that returns an array of objects each with setValue, push, release and click functions.
172
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
173
+ * to publish to.
174
+ * @returns An array of IDigitalEventAction objects.
175
+ */
176
+ declare function useCrestronPublishDigitalCollection(signalNames: string[]): IDigitalEventAction[];
177
+
178
+ declare const useCrestronPublishBooleanCollection: typeof useCrestronPublishDigitalCollection;
179
+
180
+ /**
181
+ * `useCrestronPublishSerialCollection` is a hook that returns an array of objects each with a setValue function.
182
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
183
+ * to publish to.
184
+ * @returns An array of ISerialEventAction objects.
185
+ */
186
+ declare function useCrestronPublishSerialCollection(signalNames: string[]): ISerialEventAction[];
187
+
188
+ declare const useCrestronPublishStringCollection: typeof useCrestronPublishSerialCollection;
189
+
190
+ /**
191
+ * `useCrestronSubscribeAnalog` is a hook that returns an object with a value property.
192
+ * @param {string} signalName - The name of the signal you want to subscribe to.
193
+ * @param {AnalogStateCallback} [callback] - An optional callback function that will be called whenever the state
194
+ * changes.
195
+ * @returns An array with a single IAnalogState object.
196
+ */
197
+ declare function useCrestronSubscribeAnalog(signalName: string, callback?: AnalogStateCallback): [IAnalogState];
198
+
199
+ declare const useCrestronSubscribeNumber: typeof useCrestronSubscribeAnalog;
200
+
201
+ /**
202
+ * `useCrestronSubscribeDigital` is a hook that returns an object with a value property.
203
+ * @param {string} signalName - The name of the signal you want to subscribe to.
204
+ * @param {DigitalStateCallback} [callback] - An optional callback function that will be called whenever the state
205
+ * changes.
206
+ * @returns An array with a single IDigitalState object.
207
+ */
208
+ declare function useCrestronSubscribeDigital(signalName: string, callback?: DigitalStateCallback): [IDigitalState];
209
+
210
+ declare const useCrestronSubscribeBoolean: typeof useCrestronSubscribeDigital;
211
+
212
+ /**
213
+ * `useCrestronSubscribeSerial` is a hook that returns an object with a value property.
214
+ * @param {string} signalName - The name of the signal you want to subscribe to.
215
+ * @param {SerialStateCallback} [callback] - An optional callback function that will be called whenever the state
216
+ * changes.
217
+ * @returns An array with a single ISerialState object.
218
+ */
219
+ declare function useCrestronSubscribeSerial(signalName: string, callback?: SerialStateCallback): [ISerialState];
220
+
221
+ declare const useCrestronSubscribeString: typeof useCrestronSubscribeSerial;
222
+
223
+ /**
224
+ * `useCrestronSubscribeAnalogCollection` is a hook that returns an array of objects each with a value property.
225
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
226
+ * to subscribe to.
227
+ * @param {AnalogStateCallback} [callback] - An optional callback function that will be called whenever the
228
+ * state changes.
229
+ * @returns An array of IAnalogState objects.
230
+ */
231
+ declare function useCrestronSubscribeAnalogCollection(signalNames: string[], callback?: AnalogStateCallback): IAnalogState[];
232
+
233
+ declare const useCrestronSubscribeNumberCollection: typeof useCrestronSubscribeAnalogCollection;
234
+
235
+ /**
236
+ * `useCrestronSubscribeDigitalCollection` is a hook that returns an array of objects each with a value property.
237
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
238
+ * to subscribe to.
239
+ * @param {DigitalStateCallback} [callback] - An optional callback function that will be called whenever the
240
+ * state changes.
241
+ * @returns An array of IDigitalState objects.
242
+ */
243
+ declare function useCrestronSubscribeDigitalCollection(signalNames: string[], callback?: DigitalStateCallback): IDigitalState[];
244
+
245
+ declare const useCrestronSubscribeBooleanCollection: typeof useCrestronSubscribeDigitalCollection;
246
+
247
+ /**
248
+ * `useCrestronSubscribeSerialCollection` is a hook that returns an array of objects each with a value property.
249
+ * @param {string[]} signalNames - An array of strings that represent the names of the signals you want
250
+ * to subscribe to.
251
+ * @param {SerialStateCallback} [callback] - An optional callback function that will be called whenever the
252
+ * state changes.
253
+ * @returns An array of ISerialState objects.
254
+ */
255
+ declare function useCrestronSubscribeSerialCollection(signalNames: string[], callback?: SerialStateCallback): ISerialState[];
256
+
257
+ declare const useCrestronSubscribeStringCollection: typeof useCrestronSubscribeSerialCollection;
258
+
259
+ export { type Analog, type AnalogStateCallback, type Digital, type DigitalStateCallback, type IAnalogEventAction, type IAnalogSignal, type IAnalogState, type IBaseEventAction, type IBaseSignal, type IBaseState, type IDigitalEventAction, type IDigitalSignal, type IDigitalState, type ISerialEventAction, type ISerialSignal, type ISerialState, type IStateSubscription, type Serial, type SerialStateCallback, type StateCallback, useCrestronAnalog, useCrestronAnalogCollection, useCrestronBoolean, useCrestronBooleanCollection, useCrestronDigital, useCrestronDigitalCollection, useCrestronNumber, useCrestronNumberCollection, useCrestronPublishAnalog, useCrestronPublishAnalogCollection, useCrestronPublishBoolean, useCrestronPublishBooleanCollection, useCrestronPublishDigital, useCrestronPublishDigitalCollection, useCrestronPublishNumber, useCrestronPublishNumberCollection, useCrestronPublishSerial, useCrestronPublishSerialCollection, useCrestronPublishString, useCrestronPublishStringCollection, useCrestronSerial, useCrestronSerialCollection, useCrestronString, useCrestronStringCollection, useCrestronSubscribeAnalog, useCrestronSubscribeAnalogCollection, useCrestronSubscribeBoolean, useCrestronSubscribeBooleanCollection, useCrestronSubscribeDigital, useCrestronSubscribeDigitalCollection, useCrestronSubscribeNumber, useCrestronSubscribeNumberCollection, useCrestronSubscribeSerial, useCrestronSubscribeSerialCollection, useCrestronSubscribeString, useCrestronSubscribeStringCollection };