aes70 1.6.0 → 1.6.2

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 (34) hide show
  1. package/Changelog +30 -0
  2. package/dist/AES70.es5.js +5795 -1
  3. package/package.json +1 -1
  4. package/src/OCP1/encoded_arguments.js +31 -19
  5. package/src/connection.d.ts +5 -0
  6. package/src/controller/ControlClasses/OcaBlock.d.ts +15 -15
  7. package/src/controller/ControlClasses/OcaBlock.js +16 -16
  8. package/src/controller/ControlClasses/OcaControlNetwork.d.ts +5 -0
  9. package/src/controller/ControlClasses/OcaControlNetwork.js +5 -0
  10. package/src/controller/ControlClasses/OcaFilterParametric.d.ts +4 -0
  11. package/src/controller/ControlClasses/OcaFilterParametric.js +5 -0
  12. package/src/controller/ControlClasses/OcaGrouper.d.ts +12 -0
  13. package/src/controller/ControlClasses/OcaGrouper.js +15 -0
  14. package/src/controller/ControlClasses/OcaMediaClockManager.d.ts +4 -0
  15. package/src/controller/ControlClasses/OcaMediaClockManager.js +5 -0
  16. package/src/controller/ControlClasses/OcaMediaTransportNetwork.d.ts +4 -0
  17. package/src/controller/ControlClasses/OcaMediaTransportNetwork.js +5 -0
  18. package/src/controller/ControlClasses/OcaNetworkSignalChannel.d.ts +68 -68
  19. package/src/controller/ControlClasses/OcaNetworkSignalChannel.js +72 -72
  20. package/src/controller/ControlClasses/OcaSecurityManager.d.ts +31 -31
  21. package/src/controller/ControlClasses/OcaSecurityManager.js +29 -29
  22. package/src/controller/ControlClasses/OcaStreamConnector.d.ts +70 -70
  23. package/src/controller/ControlClasses/OcaStreamConnector.js +80 -80
  24. package/src/controller/ControlClasses/OcaStreamNetwork.d.ts +18 -18
  25. package/src/controller/ControlClasses/OcaStreamNetwork.js +49 -49
  26. package/src/controller/ControlClasses/OcaSubscriptionManager.d.ts +13 -13
  27. package/src/controller/ControlClasses/OcaSubscriptionManager.js +12 -12
  28. package/src/controller/base_event.js +2 -2
  29. package/src/controller/client_connection.js +7 -3
  30. package/src/controller/fetch_device_content.js +8 -3
  31. package/src/controller/make_control_class.js +30 -4
  32. package/src/controller/object_base.d.ts +34 -0
  33. package/src/controller/tcp_connection.d.ts +8 -4
  34. package/src/controller/tcp_connection.js +23 -6
@@ -52,11 +52,11 @@ function createPropertySync(control_class) {
52
52
  return constructor;
53
53
  }
54
54
 
55
- // method = [ name, level, index, argumentTypes, returnTypes ]
55
+ // method = [ name, level, index, argumentTypes, returnTypes, aliases ]
56
56
  function implement_method(cls, method) {
57
57
  if (!method || !method.length) return;
58
58
 
59
- const [name, level, index, argumentTypes, returnTypes] = method;
59
+ const [name, level, index, argumentTypes, returnTypes, aliases] = method;
60
60
 
61
61
  cls.prototype[name] = function (...args) {
62
62
  const argumentCount = argumentTypes.length;
@@ -88,6 +88,14 @@ function implement_method(cls, method) {
88
88
  );
89
89
  return this.device.send_command(cmd, returnTypes, callback);
90
90
  };
91
+
92
+ if (aliases) {
93
+ aliases.forEach((alias) => {
94
+ cls.prototype[alias] = function (...args) {
95
+ return this[name](...args);
96
+ };
97
+ });
98
+ }
91
99
  }
92
100
 
93
101
  // event = [ name, level, index, argumentTypes ]
@@ -110,13 +118,19 @@ function implement_event(cls, event) {
110
118
  });
111
119
  }
112
120
 
121
+ function property_event_name(propertyName) {
122
+ return 'On' + propertyName + 'Changed';
123
+ }
124
+
113
125
  function implement_property_event(cls, property) {
114
126
  if (property.static) return;
115
127
  if (property.name === 'ObjectNumber') return;
116
128
 
117
- Object.defineProperty(cls.prototype, 'On' + property.name + 'Changed', {
129
+ const event_name = property_event_name(property.name);
130
+
131
+ Object.defineProperty(cls.prototype, event_name, {
118
132
  get: function () {
119
- const ev_name = '_On' + property.name + 'Changed';
133
+ const ev_name = '_' + event_name;
120
134
  const event = this[ev_name];
121
135
 
122
136
  if (event) return event;
@@ -128,6 +142,18 @@ function implement_property_event(cls, property) {
128
142
  ));
129
143
  },
130
144
  });
145
+
146
+ if (property.aliases) {
147
+ property.aliases.forEach((alias) => {
148
+ const ev_name = property_event_name(alias);
149
+ if (cls.prototype[ev_name]) return;
150
+ Object.defineProperty(cls.prototype, ev_name, {
151
+ get: function () {
152
+ return this[event_name];
153
+ },
154
+ });
155
+ });
156
+ }
131
157
  }
132
158
 
133
159
  function make_property(o) {
@@ -0,0 +1,34 @@
1
+ import { RemoteDevice } from './remote_device';
2
+ import { IOcaPropertyID, OcaPropertyID } from '../types/OcaPropertyID';
3
+
4
+ export class ObjectBase {
5
+ readonly device: RemoteDevice;
6
+ readonly ono: number;
7
+
8
+ constructor(ObjectNumber: number, device: RemoteDevice);
9
+
10
+ /**
11
+ * Returns the object number.
12
+ */
13
+ get ObjectNumber(): number;
14
+
15
+ /**
16
+ * Returns the class version of this implementation.
17
+ */
18
+ get ClassVersion(): number;
19
+
20
+ /**
21
+ * Returns the class id of this implementation.
22
+ */
23
+ get ClassID(): string;
24
+
25
+ /**
26
+ * Returns the name of this class.
27
+ */
28
+ get ClassName(): string;
29
+
30
+ GetPropertyName(id: IOcaPropertyID): string | undefined;
31
+ GetPropertyID(name: string): OcaPropertyID;
32
+
33
+ Dispose(): void;
34
+ }
@@ -2,11 +2,15 @@ import {
2
2
  ClientConnection,
3
3
  IClientConnectionOptions,
4
4
  } from './client_connection.js';
5
- import { Socket, TcpSocketConnectOpts } from 'net';
5
+ import { Socket, NetConnectOpts } from 'node:net';
6
6
 
7
- export interface ITCPConnectionOptions
8
- extends IClientConnectionOptions,
9
- TcpSocketConnectOpts {}
7
+ export type ITCPConnectionOptions = IClientConnectionOptions &
8
+ NetConnectOpts & {
9
+ /**
10
+ * This AbortSignal can be used to abort a connection attempt.
11
+ */
12
+ connectSignal?: AbortSignal;
13
+ };
10
14
 
11
15
  /**
12
16
  * :class:`ClientConnection` subclass which implements OCP.1 with TCP
@@ -1,6 +1,6 @@
1
1
  /* eslint-env node */
2
2
 
3
- import { Socket } from 'net';
3
+ import { createConnection } from 'net';
4
4
  import { Buffer } from 'buffer';
5
5
  import { performance } from 'perf_hooks';
6
6
 
@@ -41,28 +41,45 @@ export class TCPConnection extends ClientConnection {
41
41
 
42
42
  /**
43
43
  * Connect to the given endpoint.
44
- *
44
+ * @param {net.NetConnectOpts} options
45
45
  * @param {String} options.host
46
46
  * Hostname or ip address.
47
47
  * @param {number} options.port
48
48
  * Port number.
49
+ * @param {AbortSignal} [options.connectSignal]
50
+ * An optional AbortSignal which can be used to abort the connect attempt.
51
+ * Note that this is different from the `signal` option which will destroy
52
+ * the socket also after the connect attempt has been successful.
49
53
  * @returns {Promise<TCPConnection>}
50
54
  * The connection.
51
55
  */
52
56
  static connect(options) {
53
57
  return new Promise((resolve, reject) => {
54
- const socket = new Socket();
58
+ const connectSignal = options.connectSignal;
59
+ if (connectSignal) connectSignal.throwIfAborted();
60
+ const socket = new createConnection(options);
55
61
  const onerror = function (ev) {
56
62
  reject(ev);
63
+ cleanup();
57
64
  };
65
+ const onabort = function (ev) {
66
+ const err = connectSignal.reason;
67
+ reject(err);
68
+ socket.destroy(err);
69
+ };
70
+ const cleanup = function () {
71
+ socket.removeListener('error', onerror);
72
+ socket.removeListener('timeout', onerror);
73
+ if (connectSignal) connectSignal.removeEventListener('abort', onabort);
74
+ };
75
+
76
+ if (connectSignal) connectSignal.addEventListener('abort', onabort);
58
77
  socket.on('error', onerror);
59
78
  socket.on('timeout', onerror);
60
79
  socket.on('connect', () => {
61
- socket.removeListener('error', onerror);
62
- socket.removeListener('timeout', onerror);
63
80
  resolve(new this(socket, options));
81
+ cleanup();
64
82
  });
65
- socket.connect(options);
66
83
  });
67
84
  }
68
85