@hla4ts/hla-api 0.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.
package/src/index.ts ADDED
@@ -0,0 +1,378 @@
1
+ /**
2
+ * @hla4ts/hla-api - High-level HLA 4 API for TypeScript
3
+ *
4
+ * This package provides a TypeScript-friendly API for HLA 4 (IEEE 1516-2025)
5
+ * federates using the Federate Protocol.
6
+ *
7
+ * Main components:
8
+ * - RTIAmbassador: Interface for federate-to-RTI communication
9
+ * - FederateAmbassador: Callback interface for RTI-to-federate communication
10
+ * - Exception classes: Type-safe HLA exception handling
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import {
15
+ * RTIAmbassador,
16
+ * BaseFederateAmbassador,
17
+ * CallbackModel,
18
+ * ResignAction,
19
+ * } from '@hla4ts/hla-api';
20
+ *
21
+ * // Create your federate ambassador
22
+ * class MyFederateAmbassador extends BaseFederateAmbassador {
23
+ * discoverObjectInstance(objectInstance, objectClass, name, producer) {
24
+ * console.log(`Discovered object: ${name}`);
25
+ * }
26
+ *
27
+ * reflectAttributeValues(objectInstance, attributeValues, tag) {
28
+ * console.log(`Received update`);
29
+ * }
30
+ * }
31
+ *
32
+ * // Create RTI ambassador and connect
33
+ * const rtiAmbassador = new RTIAmbassador({ host: 'rti.example.com' });
34
+ * const federateAmbassador = new MyFederateAmbassador();
35
+ *
36
+ * await rtiAmbassador.connect(federateAmbassador, {
37
+ * callbackModel: CallbackModel.EVOKED,
38
+ * });
39
+ *
40
+ * // Join a federation
41
+ * const joinResult = await rtiAmbassador.joinFederationExecution(
42
+ * 'MyFederateType',
43
+ * 'TestFederation'
44
+ * );
45
+ *
46
+ * // Get handles for FOM elements
47
+ * const objectClassHandle = await rtiAmbassador.getObjectClassHandle('HLAobjectRoot.MyClass');
48
+ * const attributeHandle = await rtiAmbassador.getAttributeHandle(objectClassHandle, 'MyAttribute');
49
+ *
50
+ * // Publish and register
51
+ * await rtiAmbassador.publishObjectClassAttributes(objectClassHandle, [attributeHandle]);
52
+ * const objectInstance = await rtiAmbassador.registerObjectInstance(objectClassHandle);
53
+ *
54
+ * // Update attributes
55
+ * await rtiAmbassador.updateAttributeValues(
56
+ * objectInstance,
57
+ * [{ attributeHandle, value: new Uint8Array([1, 2, 3]) }],
58
+ * new Uint8Array()
59
+ * );
60
+ *
61
+ * // Clean up
62
+ * await rtiAmbassador.resignFederationExecution(ResignAction.DELETE_OBJECTS_THEN_DIVEST);
63
+ * await rtiAmbassador.disconnect();
64
+ * ```
65
+ *
66
+ * @packageDocumentation
67
+ */
68
+
69
+ // =============================================================================
70
+ // RTI Ambassador
71
+ // =============================================================================
72
+ export { RTIAmbassador, type RTIAmbassadorOptions } from "./rti-ambassador.ts";
73
+
74
+ // =============================================================================
75
+ // Federate Ambassador
76
+ // =============================================================================
77
+ export {
78
+ type FederateAmbassador,
79
+ NullFederateAmbassador,
80
+ BaseFederateAmbassador,
81
+ } from "./federate-ambassador.ts";
82
+
83
+ // =============================================================================
84
+ // Types
85
+ // =============================================================================
86
+ export {
87
+ // Enums (re-exported from proto)
88
+ CallbackModel,
89
+ ResignAction,
90
+ OrderType,
91
+ SynchronizationPointFailureReason,
92
+ SaveFailureReason,
93
+ RestoreFailureReason,
94
+ SaveStatus,
95
+ RestoreStatus,
96
+
97
+ // Handle types
98
+ type FederateHandle,
99
+ type ObjectClassHandle,
100
+ type AttributeHandle,
101
+ type InteractionClassHandle,
102
+ type ParameterHandle,
103
+ type ObjectInstanceHandle,
104
+ type MessageRetractionHandle,
105
+ type TransportationTypeHandle,
106
+ type DimensionHandle,
107
+ type RegionHandle,
108
+
109
+ // Time types
110
+ type LogicalTime,
111
+ type LogicalTimeInterval,
112
+
113
+ // Handle sets
114
+ type FederateHandleSet,
115
+ type AttributeHandleSet,
116
+ type DimensionHandleSet,
117
+ type RegionHandleSet,
118
+ type InteractionClassHandleSet,
119
+
120
+ // Handle-value maps
121
+ type AttributeHandleValue,
122
+ type AttributeHandleValueMap,
123
+ type ParameterHandleValue,
124
+ type ParameterHandleValueMap,
125
+
126
+ // Federation info
127
+ type FederationExecutionInformation,
128
+ type FederationExecutionInformationSet,
129
+ type FederationExecutionMemberInformation,
130
+ type FederationExecutionMemberInformationSet,
131
+ type JoinResult,
132
+
133
+ // Save/Restore
134
+ type FederateRestoreStatus,
135
+ type FederateRestoreStatusArray,
136
+ type FederateHandleSaveStatusPair,
137
+ type FederateHandleSaveStatusPairArray,
138
+
139
+ // Time returns
140
+ type TimeQueryReturn,
141
+ type MessageRetractionReturn,
142
+
143
+ // DDM types
144
+ type RangeBounds,
145
+ type DimensionAndRange,
146
+ type ConveyedRegion,
147
+ type ConveyedRegionSet,
148
+ type AttributeSetRegionSetPair,
149
+ type AttributeSetRegionSetPairList,
150
+
151
+ // Supplemental info
152
+ type SupplementalReflectInfo,
153
+ type SupplementalReceiveInfo,
154
+
155
+ // FOM modules
156
+ type FomModule,
157
+ type FomModuleInline,
158
+ type FomModuleFile,
159
+ type FomModuleUrl,
160
+ type FomModuleSet,
161
+
162
+ // Configuration
163
+ type RtiConfiguration,
164
+ type ConfigurationResult,
165
+ type Credentials,
166
+ type ConnectionOptions,
167
+
168
+ // Utilities
169
+ type UserSuppliedTag,
170
+ handlesEqual,
171
+ handleToHex,
172
+ handleFromHex,
173
+ } from "./types.ts";
174
+
175
+ // =============================================================================
176
+ // Exceptions
177
+ // =============================================================================
178
+ export {
179
+ // Base
180
+ RTIexception,
181
+ RTIinternalError,
182
+
183
+ // Connection
184
+ AlreadyConnected,
185
+ ConnectionFailed,
186
+ NotConnected,
187
+ Unauthorized,
188
+ InvalidCredentials,
189
+ UnsupportedCallbackModel,
190
+ CallNotAllowedFromWithinCallback,
191
+
192
+ // Federation Management
193
+ FederationExecutionAlreadyExists,
194
+ FederationExecutionDoesNotExist,
195
+ FederatesCurrentlyJoined,
196
+ FederateAlreadyExecutionMember,
197
+ FederateNotExecutionMember,
198
+ FederateIsExecutionMember,
199
+ FederateNameAlreadyInUse,
200
+ FederateOwnsAttributes,
201
+
202
+ // FOM/MIM
203
+ InconsistentFOM,
204
+ InvalidFOM,
205
+ CouldNotOpenFOM,
206
+ ErrorReadingFOM,
207
+ InvalidMIM,
208
+ CouldNotOpenMIM,
209
+ ErrorReadingMIM,
210
+ DesignatorIsHLAstandardMIM,
211
+
212
+ // Time Management
213
+ CouldNotCreateLogicalTimeFactory,
214
+ FederateUnableToUseTime,
215
+ InvalidLogicalTime,
216
+ InvalidLogicalTimeInterval,
217
+ InvalidLookahead,
218
+ LogicalTimeAlreadyPassed,
219
+ InTimeAdvancingState,
220
+ TimeConstrainedAlreadyEnabled,
221
+ TimeConstrainedIsNotEnabled,
222
+ TimeRegulationAlreadyEnabled,
223
+ TimeRegulationIsNotEnabled,
224
+ RequestForTimeConstrainedPending,
225
+ RequestForTimeRegulationPending,
226
+ IllegalTimeArithmetic,
227
+
228
+ // Save/Restore
229
+ SaveInProgress,
230
+ SaveNotInProgress,
231
+ SaveNotInitiated,
232
+ RestoreInProgress,
233
+ RestoreNotInProgress,
234
+ RestoreNotRequested,
235
+ FederateHasNotBegunSave,
236
+
237
+ // Object Class
238
+ ObjectClassNotDefined,
239
+ ObjectClassNotPublished,
240
+ InvalidObjectClassHandle,
241
+
242
+ // Object Instance
243
+ ObjectInstanceNotKnown,
244
+ ObjectInstanceNameInUse,
245
+ ObjectInstanceNameNotReserved,
246
+ InvalidObjectInstanceHandle,
247
+ DeletePrivilegeNotHeld,
248
+
249
+ // Attribute
250
+ AttributeNotDefined,
251
+ AttributeNotOwned,
252
+ AttributeNotPublished,
253
+ AttributeAlreadyOwned,
254
+ AttributeAlreadyBeingAcquired,
255
+ AttributeAlreadyBeingChanged,
256
+ AttributeAlreadyBeingDivested,
257
+ AttributeAcquisitionWasNotRequested,
258
+ AttributeDivestitureWasNotRequested,
259
+ InvalidAttributeHandle,
260
+
261
+ // Interaction
262
+ InteractionClassNotDefined,
263
+ InteractionClassNotPublished,
264
+ InteractionClassAlreadyBeingChanged,
265
+ InteractionParameterNotDefined,
266
+ InvalidInteractionClassHandle,
267
+ InvalidParameterHandle,
268
+
269
+ // Federate Handle
270
+ FederateHandleNotKnown,
271
+ InvalidFederateHandle,
272
+
273
+ // Ownership
274
+ NoAcquisitionPending,
275
+ OwnershipAcquisitionPending,
276
+
277
+ // Region
278
+ InvalidRegion,
279
+ InvalidRegionContext,
280
+ RegionNotCreatedByThisFederate,
281
+ RegionDoesNotContainSpecifiedDimension,
282
+ RegionInUseForUpdateOrSubscription,
283
+ InvalidDimensionHandle,
284
+ InvalidRangeBound,
285
+
286
+ // Message Retraction
287
+ InvalidMessageRetractionHandle,
288
+ MessageCanNoLongerBeRetracted,
289
+
290
+ // Transportation
291
+ InvalidTransportationName,
292
+ InvalidTransportationTypeHandle,
293
+
294
+ // Order
295
+ InvalidOrderName,
296
+ InvalidOrderType,
297
+
298
+ // Service/Switch
299
+ InvalidServiceGroup,
300
+ InvalidUpdateRateDesignator,
301
+ AsynchronousDeliveryAlreadyEnabled,
302
+ AsynchronousDeliveryAlreadyDisabled,
303
+ FederateServiceInvocationsAreBeingReportedViaMOM,
304
+ ReportServiceInvocationsAreSubscribed,
305
+
306
+ // Synchronization
307
+ SynchronizationPointLabelNotAnnounced,
308
+
309
+ // Miscellaneous
310
+ NameNotFound,
311
+ NameSetWasEmpty,
312
+ IllegalName,
313
+ InvalidResignAction,
314
+ CouldNotDecode,
315
+ CouldNotEncode,
316
+ FederateInternalError,
317
+
318
+ // Exception utilities
319
+ createException,
320
+ createExceptionFromProto,
321
+ throwException,
322
+ throwExceptionFromProto,
323
+ } from "./exceptions.ts";
324
+
325
+ // =============================================================================
326
+ // Callback Dispatcher (advanced use)
327
+ // =============================================================================
328
+ export {
329
+ CallbackDispatcher,
330
+ type CallbackDispatchResult,
331
+ } from "./callback-dispatcher.ts";
332
+
333
+ // =============================================================================
334
+ // Encoding Helpers
335
+ // =============================================================================
336
+ export {
337
+ encodeHLAinteger64Time,
338
+ decodeHLAinteger64Time,
339
+ encodeHLAinteger64Interval,
340
+ decodeHLAinteger64Interval,
341
+ } from "./encoding.ts";
342
+
343
+ // =============================================================================
344
+ // Converters (advanced use)
345
+ // =============================================================================
346
+ export {
347
+ // Proto -> TS conversions
348
+ convertObjectClassHandle,
349
+ convertAttributeHandle,
350
+ convertInteractionClassHandle,
351
+ convertParameterHandle,
352
+ convertObjectInstanceHandle,
353
+ convertFederateHandle,
354
+ convertTransportationTypeHandle,
355
+ convertLogicalTime,
356
+ convertLogicalTimeInterval,
357
+ convertMessageRetractionHandle,
358
+ convertAttributeHandleSet,
359
+ convertFederateHandleSet,
360
+ convertAttributeHandleValueMap,
361
+ convertParameterHandleValueMap,
362
+ convertJoinResult,
363
+ convertConfigurationResult,
364
+
365
+ // TS -> Proto conversions
366
+ toProtoObjectClassHandle,
367
+ toProtoAttributeHandle,
368
+ toProtoInteractionClassHandle,
369
+ toProtoParameterHandle,
370
+ toProtoObjectInstanceHandle,
371
+ toProtoFederateHandle,
372
+ toProtoLogicalTime,
373
+ toProtoLogicalTimeInterval,
374
+ toProtoAttributeHandleSet,
375
+ toProtoFederateHandleSet,
376
+ toProtoAttributeHandleValueMap,
377
+ toProtoParameterHandleValueMap,
378
+ } from "./converters.ts";