@djodjonx/x32-simulator 0.0.2 → 0.0.4

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 (83) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +28 -0
  3. package/dist/{UdpNetworkGateway-BrroQ6-Q.mjs → SchemaRegistry-BRVgnyaA.mjs} +990 -2
  4. package/dist/{UdpNetworkGateway-Ccdd7Us5.cjs → SchemaRegistry-CfDtw84j.cjs} +1033 -3
  5. package/dist/index.cjs +160 -6
  6. package/dist/index.d.cts +61 -11
  7. package/dist/index.d.mts +61 -11
  8. package/dist/index.mjs +146 -2
  9. package/dist/server.cjs +8 -927
  10. package/dist/server.mjs +1 -920
  11. package/package.json +5 -1
  12. package/.commitlintrc.json +0 -3
  13. package/.github/workflows/publish.yml +0 -38
  14. package/.husky/commit-msg +0 -1
  15. package/.husky/pre-commit +0 -1
  16. package/.oxlintrc.json +0 -56
  17. package/INSTALL.md +0 -107
  18. package/docs/OSC-Communication.md +0 -184
  19. package/docs/X32-INTERNAL.md +0 -262
  20. package/docs/X32-OSC.pdf +0 -0
  21. package/docs/behringer-x32-x32-osc-remote-protocol-en-44463.pdf +0 -0
  22. package/src/application/use-cases/BroadcastUpdatesUseCase.ts +0 -120
  23. package/src/application/use-cases/ManageSessionsUseCase.ts +0 -9
  24. package/src/application/use-cases/ProcessPacketUseCase.ts +0 -26
  25. package/src/application/use-cases/SimulationService.ts +0 -122
  26. package/src/domain/entities/SubscriptionManager.ts +0 -126
  27. package/src/domain/entities/X32State.ts +0 -78
  28. package/src/domain/models/MeterConfig.ts +0 -22
  29. package/src/domain/models/MeterData.ts +0 -59
  30. package/src/domain/models/OscMessage.ts +0 -93
  31. package/src/domain/models/X32Address.ts +0 -78
  32. package/src/domain/models/X32Node.ts +0 -43
  33. package/src/domain/models/types.ts +0 -96
  34. package/src/domain/ports/ILogger.ts +0 -27
  35. package/src/domain/ports/INetworkGateway.ts +0 -8
  36. package/src/domain/ports/IStateRepository.ts +0 -16
  37. package/src/domain/services/MeterService.ts +0 -46
  38. package/src/domain/services/OscMessageHandler.ts +0 -88
  39. package/src/domain/services/SchemaFactory.ts +0 -308
  40. package/src/domain/services/SchemaRegistry.ts +0 -67
  41. package/src/domain/services/StaticResponseService.ts +0 -52
  42. package/src/domain/services/strategies/BatchStrategy.ts +0 -74
  43. package/src/domain/services/strategies/MeterStrategy.ts +0 -45
  44. package/src/domain/services/strategies/NodeDiscoveryStrategy.ts +0 -36
  45. package/src/domain/services/strategies/OscCommandStrategy.ts +0 -22
  46. package/src/domain/services/strategies/StateAccessStrategy.ts +0 -71
  47. package/src/domain/services/strategies/StaticResponseStrategy.ts +0 -42
  48. package/src/domain/services/strategies/SubscriptionStrategy.ts +0 -56
  49. package/src/infrastructure/mappers/OscCodec.ts +0 -54
  50. package/src/infrastructure/repositories/InMemoryStateRepository.ts +0 -21
  51. package/src/infrastructure/services/ConsoleLogger.ts +0 -177
  52. package/src/infrastructure/services/UdpNetworkGateway.ts +0 -71
  53. package/src/presentation/cli/server.ts +0 -194
  54. package/src/presentation/library/library.ts +0 -9
  55. package/tests/application/use-cases/BroadcastUpdatesUseCase.test.ts +0 -104
  56. package/tests/application/use-cases/ManageSessionsUseCase.test.ts +0 -12
  57. package/tests/application/use-cases/ProcessPacketUseCase.test.ts +0 -49
  58. package/tests/application/use-cases/SimulationService.test.ts +0 -77
  59. package/tests/domain/entities/SubscriptionManager.test.ts +0 -50
  60. package/tests/domain/entities/X32State.test.ts +0 -52
  61. package/tests/domain/models/MeterData.test.ts +0 -23
  62. package/tests/domain/models/OscMessage.test.ts +0 -38
  63. package/tests/domain/models/X32Address.test.ts +0 -30
  64. package/tests/domain/models/X32Node.test.ts +0 -30
  65. package/tests/domain/services/MeterService.test.ts +0 -27
  66. package/tests/domain/services/OscMessageHandler.test.ts +0 -51
  67. package/tests/domain/services/SchemaRegistry.test.ts +0 -47
  68. package/tests/domain/services/StaticResponseService.test.ts +0 -15
  69. package/tests/domain/services/strategies/BatchStrategy.test.ts +0 -41
  70. package/tests/domain/services/strategies/MeterStrategy.test.ts +0 -19
  71. package/tests/domain/services/strategies/NodeDiscoveryStrategy.test.ts +0 -22
  72. package/tests/domain/services/strategies/StateAccessStrategy.test.ts +0 -49
  73. package/tests/domain/services/strategies/StaticResponseStrategy.test.ts +0 -15
  74. package/tests/domain/services/strategies/SubscriptionStrategy.test.ts +0 -45
  75. package/tests/infrastructure/mappers/OscCodec.test.ts +0 -41
  76. package/tests/infrastructure/repositories/InMemoryStateRepository.test.ts +0 -29
  77. package/tests/infrastructure/services/ConsoleLogger.test.ts +0 -74
  78. package/tests/infrastructure/services/UdpNetworkGateway.test.ts +0 -61
  79. package/tests/presentation/cli/server.test.ts +0 -178
  80. package/tests/presentation/library/library.test.ts +0 -13
  81. package/tsconfig.json +0 -21
  82. package/tsdown.config.ts +0 -15
  83. package/vitest.config.ts +0 -9
package/dist/index.cjs CHANGED
@@ -1,7 +1,161 @@
1
- const require_UdpNetworkGateway = require('./UdpNetworkGateway-Ccdd7Us5.cjs');
1
+ const require_SchemaRegistry = require('./SchemaRegistry-CfDtw84j.cjs');
2
2
 
3
- exports.ConsoleLogger = require_UdpNetworkGateway.ConsoleLogger;
4
- exports.InMemoryStateRepository = require_UdpNetworkGateway.InMemoryStateRepository;
5
- exports.LogCategory = require_UdpNetworkGateway.LogCategory;
6
- exports.SimulationService = require_UdpNetworkGateway.SimulationService;
7
- exports.UdpNetworkGateway = require_UdpNetworkGateway.UdpNetworkGateway;
3
+ //#region src/domain/models/OscMessage.ts
4
+ /**
5
+ * Represents a parsed OSC message ready for handling.
6
+ * Encapsulates the address and arguments, providing helper methods for validation and extraction.
7
+ */
8
+ var OscMessage = class OscMessage {
9
+ _address;
10
+ _args;
11
+ /**
12
+ * Creates a new OscMessage instance.
13
+ * @param address - The OSC address string.
14
+ * @param args - The list of arguments.
15
+ */
16
+ constructor(address, args) {
17
+ this._address = address;
18
+ this._args = args;
19
+ }
20
+ /**
21
+ * Gets the OSC address.
22
+ * @returns The address string.
23
+ */
24
+ get address() {
25
+ return this._address;
26
+ }
27
+ /**
28
+ * Gets the message arguments.
29
+ * @returns Copy of the arguments array.
30
+ */
31
+ get args() {
32
+ return [...this._args];
33
+ }
34
+ /**
35
+ * Checks if the address starts with the given prefix.
36
+ * @param prefix - The prefix to check.
37
+ * @returns True if it starts with the prefix.
38
+ */
39
+ startsWith(prefix) {
40
+ return this._address.startsWith(prefix);
41
+ }
42
+ /**
43
+ * Gets an argument at a specific index, safely.
44
+ * @param index - The index of the argument.
45
+ * @returns The argument value or undefined.
46
+ */
47
+ getArg(index) {
48
+ return this._args[index];
49
+ }
50
+ /**
51
+ * Gets an argument as a number, or throws if missing/invalid.
52
+ * @param index - The index.
53
+ * @returns The number value.
54
+ */
55
+ getArgAsNumber(index) {
56
+ const val = this._args[index];
57
+ if (typeof val !== "number") throw new Error(`Argument at index ${index} is not a number.`);
58
+ return val;
59
+ }
60
+ /**
61
+ * Gets an argument as a string, or throws if missing/invalid.
62
+ * @param index - The index.
63
+ * @returns The string value.
64
+ */
65
+ getArgAsString(index) {
66
+ const val = this._args[index];
67
+ if (typeof val !== "string") throw new Error(`Argument at index ${index} is not a string.`);
68
+ return val;
69
+ }
70
+ /**
71
+ * Factory method to create an OscMessage from a raw packet.
72
+ * @param packet - The raw OSC packet.
73
+ * @returns A new OscMessage instance.
74
+ */
75
+ static fromPacket(packet) {
76
+ const values = packet.args.map((arg) => typeof arg === "object" && arg !== null && "value" in arg ? arg.value : arg);
77
+ return new OscMessage(packet.address, values);
78
+ }
79
+ };
80
+
81
+ //#endregion
82
+ //#region src/domain/models/X32Address.ts
83
+ /**
84
+ * Represents an X32 OSC Address path, providing parsing logic and component extraction.
85
+ */
86
+ var X32Address = class {
87
+ _path;
88
+ _parts;
89
+ /**
90
+ * Creates a new X32Address.
91
+ * @param path - The full OSC path (e.g., "/ch/01/mix/fader").
92
+ */
93
+ constructor(path) {
94
+ this._path = path;
95
+ this._parts = path.split("/").filter((p) => p.length > 0);
96
+ }
97
+ /**
98
+ * Gets the full string representation of the path.
99
+ * @returns The full OSC path string.
100
+ */
101
+ get path() {
102
+ return this._path;
103
+ }
104
+ /**
105
+ * Gets the root category (e.g., "ch", "bus", "config").
106
+ * @returns The first segment of the path.
107
+ */
108
+ get root() {
109
+ return this._parts[0];
110
+ }
111
+ /**
112
+ * Gets the index/ID part if present (e.g., "01" from "/ch/01").
113
+ * @returns The second segment of the path.
114
+ */
115
+ get index() {
116
+ return this._parts[1];
117
+ }
118
+ /**
119
+ * Gets the suffix (everything after the ID).
120
+ * e.g., for "/ch/01/mix/fader", returns "/mix/fader".
121
+ * @returns The remaining path after the index.
122
+ */
123
+ get suffix() {
124
+ if (this._parts.length < 3) return "";
125
+ return "/" + this._parts.slice(2).join("/");
126
+ }
127
+ /**
128
+ * Checks if this address belongs to a specific category.
129
+ * @param category - The category to check (e.g., "meters", "ch").
130
+ * @returns True if it matches the category.
131
+ */
132
+ isCategory(category) {
133
+ return this.root === category;
134
+ }
135
+ /**
136
+ * Checks if the address matches a specific pattern.
137
+ * @param pattern - The regex or string pattern.
138
+ * @returns True if it matches the pattern.
139
+ */
140
+ matches(pattern) {
141
+ if (typeof pattern === "string") return this._path === pattern;
142
+ return pattern.test(this._path);
143
+ }
144
+ };
145
+
146
+ //#endregion
147
+ exports.ConsoleLogger = require_SchemaRegistry.ConsoleLogger;
148
+ exports.InMemoryStateRepository = require_SchemaRegistry.InMemoryStateRepository;
149
+ exports.LogCategory = require_SchemaRegistry.LogCategory;
150
+ exports.METER_COUNTS = require_SchemaRegistry.METER_COUNTS;
151
+ exports.MeterData = require_SchemaRegistry.MeterData;
152
+ exports.OscCodec = require_SchemaRegistry.OscCodec;
153
+ exports.OscMessage = OscMessage;
154
+ exports.SchemaFactory = require_SchemaRegistry.SchemaFactory;
155
+ exports.SchemaRegistry = require_SchemaRegistry.SchemaRegistry;
156
+ exports.SimulationService = require_SchemaRegistry.SimulationService;
157
+ exports.SubscriptionManager = require_SchemaRegistry.SubscriptionManager;
158
+ exports.UdpNetworkGateway = require_SchemaRegistry.UdpNetworkGateway;
159
+ exports.X32Address = X32Address;
160
+ exports.X32Node = require_SchemaRegistry.X32Node;
161
+ exports.X32State = require_SchemaRegistry.X32State;
package/dist/index.d.cts CHANGED
@@ -20,10 +20,6 @@ interface OscMsg {
20
20
  address: string;
21
21
  args: OscArgumentValue[];
22
22
  }
23
- interface X32Node {
24
- type: 'f' | 'i' | 's';
25
- default: number | string;
26
- }
27
23
  interface Subscriber {
28
24
  address: string;
29
25
  port: number;
@@ -73,7 +69,7 @@ interface ILogger {
73
69
  }
74
70
  //#endregion
75
71
  //#region src/domain/models/X32Node.d.ts
76
- declare class X32Node$1 {
72
+ declare class X32Node {
77
73
  readonly type: 'f' | 'i' | 's';
78
74
  readonly default: number | string;
79
75
  constructor(type: 'f' | 'i' | 's', defaultValue: number | string);
@@ -81,14 +77,14 @@ declare class X32Node$1 {
81
77
  static from(obj: {
82
78
  type: 'f' | 'i' | 's';
83
79
  default: number | string;
84
- }): X32Node$1;
80
+ }): X32Node;
85
81
  }
86
82
  //#endregion
87
83
  //#region src/domain/entities/X32State.d.ts
88
84
  declare class X32State extends EventEmitter {
89
85
  private state;
90
86
  private readonly defaultState;
91
- constructor(schema: Record<string, X32Node$1>);
87
+ constructor(schema: Record<string, X32Node>);
92
88
  reset(): void;
93
89
  get(address: string): number | string | undefined;
94
90
  set(address: string, value: number | string): void;
@@ -103,7 +99,7 @@ interface IStateRepository {
103
99
  //#endregion
104
100
  //#region src/domain/services/SchemaFactory.d.ts
105
101
  declare class SchemaFactory {
106
- createSchema(): Record<string, X32Node$1>;
102
+ createSchema(): Record<string, X32Node>;
107
103
  private node;
108
104
  private generateChannelStrip;
109
105
  private generateNodes;
@@ -116,8 +112,8 @@ declare class SchemaRegistry {
116
112
  private schemaFactory;
117
113
  private readonly _schema;
118
114
  constructor(schemaFactory: SchemaFactory);
119
- getSchema(): Record<string, X32Node$1>;
120
- getNode(path: string): X32Node$1 | undefined;
115
+ getSchema(): Record<string, X32Node>;
116
+ getNode(path: string): X32Node | undefined;
121
117
  has(path: string): boolean;
122
118
  getAllPaths(): string[];
123
119
  getRootFromIndex(index: number): string | null;
@@ -146,6 +142,60 @@ declare class SimulationService {
146
142
  resetState(): void;
147
143
  }
148
144
  //#endregion
145
+ //#region src/domain/entities/SubscriptionManager.d.ts
146
+ declare class SubscriptionManager {
147
+ private logger;
148
+ private subscribers;
149
+ constructor(logger: ILogger);
150
+ cleanup(): void;
151
+ getSubscribers(): Subscriber[];
152
+ addPathSubscriber(rinfo: RemoteClient, path: string): void;
153
+ addBatchSubscriber(rinfo: RemoteClient, alias: string, paths: string[], start: number, count: number, factor?: number, args?: number[]): void;
154
+ addFormatSubscriber(rinfo: RemoteClient, alias: string, pattern: string, start: number, count: number, factor?: number): void;
155
+ addMeterSubscriber(rinfo: RemoteClient, meterPath: string): void;
156
+ removeSubscriber(rinfo: RemoteClient, path: string): void;
157
+ }
158
+ //#endregion
159
+ //#region src/domain/models/OscMessage.d.ts
160
+ declare class OscMessage {
161
+ private readonly _address;
162
+ private readonly _args;
163
+ constructor(address: string, args: OscArgumentValue[]);
164
+ get address(): string;
165
+ get args(): OscArgumentValue[];
166
+ startsWith(prefix: string): boolean;
167
+ getArg(index: number): OscArgumentValue | undefined;
168
+ getArgAsNumber(index: number): number;
169
+ getArgAsString(index: number): string;
170
+ static fromPacket(packet: OscPacket): OscMessage;
171
+ }
172
+ //#endregion
173
+ //#region src/domain/models/X32Address.d.ts
174
+ declare class X32Address {
175
+ private readonly _path;
176
+ private readonly _parts;
177
+ constructor(path: string);
178
+ get path(): string;
179
+ get root(): string | undefined;
180
+ get index(): string | undefined;
181
+ get suffix(): string;
182
+ isCategory(category: string): boolean;
183
+ matches(pattern: RegExp | string): boolean;
184
+ }
185
+ //#endregion
186
+ //#region src/domain/models/MeterData.d.ts
187
+ declare class MeterData {
188
+ private readonly _path;
189
+ private readonly _values;
190
+ constructor(path: string, values: number[]);
191
+ get path(): string;
192
+ get values(): number[];
193
+ toBlob(): Buffer;
194
+ }
195
+ //#endregion
196
+ //#region src/domain/models/MeterConfig.d.ts
197
+ declare const METER_COUNTS: Record<string, number>;
198
+ //#endregion
149
199
  //#region src/infrastructure/repositories/InMemoryStateRepository.d.ts
150
200
  declare class InMemoryStateRepository implements IStateRepository {
151
201
  private logger;
@@ -204,4 +254,4 @@ declare class UdpNetworkGateway implements INetworkGateway {
204
254
  send(target: RemoteClient, address: string, args: any[]): void;
205
255
  }
206
256
  //#endregion
207
- export { ConsoleLogger, type ILogger, type INetworkGateway, type IStateRepository, InMemoryStateRepository, LogCategory, type LogData, OscArgument, OscArgumentValue, OscMsg, OscPacket, OscReply, RemoteClient, SimulationService, Subscriber, UdpNetworkGateway, X32Node };
257
+ export { ConsoleLogger, type ILogger, type INetworkGateway, type IStateRepository, InMemoryStateRepository, LogCategory, type LogData, METER_COUNTS, MeterData, OscArgument, OscArgumentValue, OscCodec, OscMessage, OscMsg, OscPacket, OscReply, RemoteClient, SchemaFactory, SchemaRegistry, SimulationService, Subscriber, SubscriptionManager, UdpNetworkGateway, X32Address, X32Node, X32State };
package/dist/index.d.mts CHANGED
@@ -20,10 +20,6 @@ interface OscMsg {
20
20
  address: string;
21
21
  args: OscArgumentValue[];
22
22
  }
23
- interface X32Node {
24
- type: 'f' | 'i' | 's';
25
- default: number | string;
26
- }
27
23
  interface Subscriber {
28
24
  address: string;
29
25
  port: number;
@@ -73,7 +69,7 @@ interface ILogger {
73
69
  }
74
70
  //#endregion
75
71
  //#region src/domain/models/X32Node.d.ts
76
- declare class X32Node$1 {
72
+ declare class X32Node {
77
73
  readonly type: 'f' | 'i' | 's';
78
74
  readonly default: number | string;
79
75
  constructor(type: 'f' | 'i' | 's', defaultValue: number | string);
@@ -81,14 +77,14 @@ declare class X32Node$1 {
81
77
  static from(obj: {
82
78
  type: 'f' | 'i' | 's';
83
79
  default: number | string;
84
- }): X32Node$1;
80
+ }): X32Node;
85
81
  }
86
82
  //#endregion
87
83
  //#region src/domain/entities/X32State.d.ts
88
84
  declare class X32State extends EventEmitter {
89
85
  private state;
90
86
  private readonly defaultState;
91
- constructor(schema: Record<string, X32Node$1>);
87
+ constructor(schema: Record<string, X32Node>);
92
88
  reset(): void;
93
89
  get(address: string): number | string | undefined;
94
90
  set(address: string, value: number | string): void;
@@ -103,7 +99,7 @@ interface IStateRepository {
103
99
  //#endregion
104
100
  //#region src/domain/services/SchemaFactory.d.ts
105
101
  declare class SchemaFactory {
106
- createSchema(): Record<string, X32Node$1>;
102
+ createSchema(): Record<string, X32Node>;
107
103
  private node;
108
104
  private generateChannelStrip;
109
105
  private generateNodes;
@@ -116,8 +112,8 @@ declare class SchemaRegistry {
116
112
  private schemaFactory;
117
113
  private readonly _schema;
118
114
  constructor(schemaFactory: SchemaFactory);
119
- getSchema(): Record<string, X32Node$1>;
120
- getNode(path: string): X32Node$1 | undefined;
115
+ getSchema(): Record<string, X32Node>;
116
+ getNode(path: string): X32Node | undefined;
121
117
  has(path: string): boolean;
122
118
  getAllPaths(): string[];
123
119
  getRootFromIndex(index: number): string | null;
@@ -146,6 +142,60 @@ declare class SimulationService {
146
142
  resetState(): void;
147
143
  }
148
144
  //#endregion
145
+ //#region src/domain/entities/SubscriptionManager.d.ts
146
+ declare class SubscriptionManager {
147
+ private logger;
148
+ private subscribers;
149
+ constructor(logger: ILogger);
150
+ cleanup(): void;
151
+ getSubscribers(): Subscriber[];
152
+ addPathSubscriber(rinfo: RemoteClient, path: string): void;
153
+ addBatchSubscriber(rinfo: RemoteClient, alias: string, paths: string[], start: number, count: number, factor?: number, args?: number[]): void;
154
+ addFormatSubscriber(rinfo: RemoteClient, alias: string, pattern: string, start: number, count: number, factor?: number): void;
155
+ addMeterSubscriber(rinfo: RemoteClient, meterPath: string): void;
156
+ removeSubscriber(rinfo: RemoteClient, path: string): void;
157
+ }
158
+ //#endregion
159
+ //#region src/domain/models/OscMessage.d.ts
160
+ declare class OscMessage {
161
+ private readonly _address;
162
+ private readonly _args;
163
+ constructor(address: string, args: OscArgumentValue[]);
164
+ get address(): string;
165
+ get args(): OscArgumentValue[];
166
+ startsWith(prefix: string): boolean;
167
+ getArg(index: number): OscArgumentValue | undefined;
168
+ getArgAsNumber(index: number): number;
169
+ getArgAsString(index: number): string;
170
+ static fromPacket(packet: OscPacket): OscMessage;
171
+ }
172
+ //#endregion
173
+ //#region src/domain/models/X32Address.d.ts
174
+ declare class X32Address {
175
+ private readonly _path;
176
+ private readonly _parts;
177
+ constructor(path: string);
178
+ get path(): string;
179
+ get root(): string | undefined;
180
+ get index(): string | undefined;
181
+ get suffix(): string;
182
+ isCategory(category: string): boolean;
183
+ matches(pattern: RegExp | string): boolean;
184
+ }
185
+ //#endregion
186
+ //#region src/domain/models/MeterData.d.ts
187
+ declare class MeterData {
188
+ private readonly _path;
189
+ private readonly _values;
190
+ constructor(path: string, values: number[]);
191
+ get path(): string;
192
+ get values(): number[];
193
+ toBlob(): Buffer;
194
+ }
195
+ //#endregion
196
+ //#region src/domain/models/MeterConfig.d.ts
197
+ declare const METER_COUNTS: Record<string, number>;
198
+ //#endregion
149
199
  //#region src/infrastructure/repositories/InMemoryStateRepository.d.ts
150
200
  declare class InMemoryStateRepository implements IStateRepository {
151
201
  private logger;
@@ -204,4 +254,4 @@ declare class UdpNetworkGateway implements INetworkGateway {
204
254
  send(target: RemoteClient, address: string, args: any[]): void;
205
255
  }
206
256
  //#endregion
207
- export { ConsoleLogger, type ILogger, type INetworkGateway, type IStateRepository, InMemoryStateRepository, LogCategory, type LogData, OscArgument, OscArgumentValue, OscMsg, OscPacket, OscReply, RemoteClient, SimulationService, Subscriber, UdpNetworkGateway, X32Node };
257
+ export { ConsoleLogger, type ILogger, type INetworkGateway, type IStateRepository, InMemoryStateRepository, LogCategory, type LogData, METER_COUNTS, MeterData, OscArgument, OscArgumentValue, OscCodec, OscMessage, OscMsg, OscPacket, OscReply, RemoteClient, SchemaFactory, SchemaRegistry, SimulationService, Subscriber, SubscriptionManager, UdpNetworkGateway, X32Address, X32Node, X32State };
package/dist/index.mjs CHANGED
@@ -1,3 +1,147 @@
1
- import { a as SimulationService, i as InMemoryStateRepository, n as ConsoleLogger, s as LogCategory, t as UdpNetworkGateway } from "./UdpNetworkGateway-BrroQ6-Q.mjs";
1
+ import { a as ConsoleLogger, c as X32Node, d as METER_COUNTS, f as MeterData, i as UdpNetworkGateway, l as X32State, m as LogCategory, n as SchemaFactory, p as SubscriptionManager, r as OscCodec, s as InMemoryStateRepository, t as SchemaRegistry, u as SimulationService } from "./SchemaRegistry-BRVgnyaA.mjs";
2
2
 
3
- export { ConsoleLogger, InMemoryStateRepository, LogCategory, SimulationService, UdpNetworkGateway };
3
+ //#region src/domain/models/OscMessage.ts
4
+ /**
5
+ * Represents a parsed OSC message ready for handling.
6
+ * Encapsulates the address and arguments, providing helper methods for validation and extraction.
7
+ */
8
+ var OscMessage = class OscMessage {
9
+ _address;
10
+ _args;
11
+ /**
12
+ * Creates a new OscMessage instance.
13
+ * @param address - The OSC address string.
14
+ * @param args - The list of arguments.
15
+ */
16
+ constructor(address, args) {
17
+ this._address = address;
18
+ this._args = args;
19
+ }
20
+ /**
21
+ * Gets the OSC address.
22
+ * @returns The address string.
23
+ */
24
+ get address() {
25
+ return this._address;
26
+ }
27
+ /**
28
+ * Gets the message arguments.
29
+ * @returns Copy of the arguments array.
30
+ */
31
+ get args() {
32
+ return [...this._args];
33
+ }
34
+ /**
35
+ * Checks if the address starts with the given prefix.
36
+ * @param prefix - The prefix to check.
37
+ * @returns True if it starts with the prefix.
38
+ */
39
+ startsWith(prefix) {
40
+ return this._address.startsWith(prefix);
41
+ }
42
+ /**
43
+ * Gets an argument at a specific index, safely.
44
+ * @param index - The index of the argument.
45
+ * @returns The argument value or undefined.
46
+ */
47
+ getArg(index) {
48
+ return this._args[index];
49
+ }
50
+ /**
51
+ * Gets an argument as a number, or throws if missing/invalid.
52
+ * @param index - The index.
53
+ * @returns The number value.
54
+ */
55
+ getArgAsNumber(index) {
56
+ const val = this._args[index];
57
+ if (typeof val !== "number") throw new Error(`Argument at index ${index} is not a number.`);
58
+ return val;
59
+ }
60
+ /**
61
+ * Gets an argument as a string, or throws if missing/invalid.
62
+ * @param index - The index.
63
+ * @returns The string value.
64
+ */
65
+ getArgAsString(index) {
66
+ const val = this._args[index];
67
+ if (typeof val !== "string") throw new Error(`Argument at index ${index} is not a string.`);
68
+ return val;
69
+ }
70
+ /**
71
+ * Factory method to create an OscMessage from a raw packet.
72
+ * @param packet - The raw OSC packet.
73
+ * @returns A new OscMessage instance.
74
+ */
75
+ static fromPacket(packet) {
76
+ const values = packet.args.map((arg) => typeof arg === "object" && arg !== null && "value" in arg ? arg.value : arg);
77
+ return new OscMessage(packet.address, values);
78
+ }
79
+ };
80
+
81
+ //#endregion
82
+ //#region src/domain/models/X32Address.ts
83
+ /**
84
+ * Represents an X32 OSC Address path, providing parsing logic and component extraction.
85
+ */
86
+ var X32Address = class {
87
+ _path;
88
+ _parts;
89
+ /**
90
+ * Creates a new X32Address.
91
+ * @param path - The full OSC path (e.g., "/ch/01/mix/fader").
92
+ */
93
+ constructor(path) {
94
+ this._path = path;
95
+ this._parts = path.split("/").filter((p) => p.length > 0);
96
+ }
97
+ /**
98
+ * Gets the full string representation of the path.
99
+ * @returns The full OSC path string.
100
+ */
101
+ get path() {
102
+ return this._path;
103
+ }
104
+ /**
105
+ * Gets the root category (e.g., "ch", "bus", "config").
106
+ * @returns The first segment of the path.
107
+ */
108
+ get root() {
109
+ return this._parts[0];
110
+ }
111
+ /**
112
+ * Gets the index/ID part if present (e.g., "01" from "/ch/01").
113
+ * @returns The second segment of the path.
114
+ */
115
+ get index() {
116
+ return this._parts[1];
117
+ }
118
+ /**
119
+ * Gets the suffix (everything after the ID).
120
+ * e.g., for "/ch/01/mix/fader", returns "/mix/fader".
121
+ * @returns The remaining path after the index.
122
+ */
123
+ get suffix() {
124
+ if (this._parts.length < 3) return "";
125
+ return "/" + this._parts.slice(2).join("/");
126
+ }
127
+ /**
128
+ * Checks if this address belongs to a specific category.
129
+ * @param category - The category to check (e.g., "meters", "ch").
130
+ * @returns True if it matches the category.
131
+ */
132
+ isCategory(category) {
133
+ return this.root === category;
134
+ }
135
+ /**
136
+ * Checks if the address matches a specific pattern.
137
+ * @param pattern - The regex or string pattern.
138
+ * @returns True if it matches the pattern.
139
+ */
140
+ matches(pattern) {
141
+ if (typeof pattern === "string") return this._path === pattern;
142
+ return pattern.test(this._path);
143
+ }
144
+ };
145
+
146
+ //#endregion
147
+ export { ConsoleLogger, InMemoryStateRepository, LogCategory, METER_COUNTS, MeterData, OscCodec, OscMessage, SchemaFactory, SchemaRegistry, SimulationService, SubscriptionManager, UdpNetworkGateway, X32Address, X32Node, X32State };