roslib-ts 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/LICENSE ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @naviai/roslib-ts
2
+
3
+ TypeScript-first ROSLIB implementation.
4
+
5
+ ## ✨ Features
6
+
7
+ ✅ WebSocket transport (rosbridge)
8
+ ✅ Web / React Native compatible
9
+ ✅ TypeScript first
10
+ ✅ Event-driven API
11
+ ❌ No socket.io support
12
+ ❌ No WebRTC support
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ pnpm add @naviai/roslib-ts
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```typescript
23
+ import { Ros, Topic } from '@naviai/roslib-ts'
24
+
25
+ const ros = new Ros({
26
+ url: 'ws://localhost:9090'
27
+ })
28
+
29
+ ros.on('connection', () => {
30
+ console.log('Connected');
31
+ });
32
+
33
+ ros.on('close', () => {
34
+ console.log('Disconnected');
35
+ });
36
+
37
+ const cmdVel = new Topic({
38
+ ros,
39
+ name: '/cmd_vel',
40
+ messageType: 'geometry_msgs/Twist'
41
+ })
42
+
43
+ cmdVel.subscribe(msg => {
44
+ console.log(msg.linear.x)
45
+ })
46
+ ```
47
+
48
+
49
+
50
+
@@ -0,0 +1,458 @@
1
+ 'use strict';
2
+
3
+ // 简单的事件发射器实现
4
+ class EventEmitter {
5
+ constructor() {
6
+ this.events = {};
7
+ }
8
+ on(event, listener) {
9
+ if (!this.events[event]) {
10
+ this.events[event] = [];
11
+ }
12
+ this.events[event].push(listener);
13
+ return this;
14
+ }
15
+ once(event, listener) {
16
+ const onceWrapper = (...args) => {
17
+ this.off(event, onceWrapper);
18
+ listener.apply(this, args);
19
+ };
20
+ this.on(event, onceWrapper);
21
+ return this;
22
+ }
23
+ off(event, listener) {
24
+ if (!this.events[event])
25
+ return this;
26
+ if (!listener) {
27
+ delete this.events[event];
28
+ return this;
29
+ }
30
+ const index = this.events[event].indexOf(listener);
31
+ if (index > -1) {
32
+ this.events[event].splice(index, 1);
33
+ }
34
+ return this;
35
+ }
36
+ emit(event, ...args) {
37
+ if (!this.events[event])
38
+ return false;
39
+ this.events[event].forEach(listener => {
40
+ try {
41
+ listener.apply(this, args);
42
+ }
43
+ catch (error) {
44
+ console.error('Error in event listener:', error);
45
+ }
46
+ });
47
+ return true;
48
+ }
49
+ removeAllListeners(event) {
50
+ if (event) {
51
+ delete this.events[event];
52
+ }
53
+ else {
54
+ this.events = {};
55
+ }
56
+ return this;
57
+ }
58
+ listenerCount(event) {
59
+ return this.events[event] ? this.events[event].length : 0;
60
+ }
61
+ }
62
+
63
+ class Ros extends EventEmitter {
64
+ // private reconnectDelay = 1000;
65
+ constructor(options = {}) {
66
+ super();
67
+ this.socket = null;
68
+ this._isConnected = false;
69
+ this.idCounter = 0;
70
+ this.reconnectTimer = null;
71
+ this.options = options;
72
+ if (options.url) {
73
+ this.connect(options.url);
74
+ }
75
+ }
76
+ get isConnected() {
77
+ return this._isConnected;
78
+ }
79
+ connect(url) {
80
+ var _a, _b;
81
+ if (this.socket && this.socket.readyState === WebSocket.OPEN && this.socket.url === url) {
82
+ return;
83
+ }
84
+ if (this.socket) {
85
+ this.close();
86
+ }
87
+ try {
88
+ const WS = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.WebSocket) !== null && _b !== void 0 ? _b : WebSocket;
89
+ this.socket = new WS(url);
90
+ this.socket.onopen = () => {
91
+ this._isConnected = true;
92
+ this.emit('connection');
93
+ // 清除重连定时器
94
+ if (this.reconnectTimer) {
95
+ clearTimeout(this.reconnectTimer);
96
+ this.reconnectTimer = null;
97
+ }
98
+ };
99
+ this.socket.onclose = () => {
100
+ this._isConnected = false;
101
+ this.emit('close');
102
+ };
103
+ this.socket.onerror = (error) => {
104
+ this.emit('error', error);
105
+ };
106
+ this.socket.onmessage = (event) => {
107
+ this.handleMessage(event.data);
108
+ };
109
+ }
110
+ catch (error) {
111
+ this.emit('error', error);
112
+ }
113
+ }
114
+ close() {
115
+ if (this.socket) {
116
+ this.socket.close();
117
+ this.socket = null;
118
+ }
119
+ this._isConnected = false;
120
+ if (this.reconnectTimer) {
121
+ clearTimeout(this.reconnectTimer);
122
+ this.reconnectTimer = null;
123
+ }
124
+ }
125
+ handleMessage(data) {
126
+ try {
127
+ const message = JSON.parse(data);
128
+ if (message.op === 'publish') {
129
+ // 发布消息到对应的 topic
130
+ this.emit(message.topic, message.msg);
131
+ }
132
+ else if (message.op === 'service_response') {
133
+ // 服务响应
134
+ this.emit(message.id, message);
135
+ }
136
+ else if (message.op === 'status') {
137
+ // 状态消息
138
+ if (message.id) {
139
+ this.emit('status:' + message.id, message);
140
+ }
141
+ else {
142
+ this.emit('status', message);
143
+ }
144
+ }
145
+ }
146
+ catch (error) {
147
+ console.error('Error parsing message:', error);
148
+ }
149
+ }
150
+ callOnConnection(message) {
151
+ const messageStr = JSON.stringify(message);
152
+ if (this._isConnected && this.socket) {
153
+ this.socket.send(messageStr);
154
+ }
155
+ else {
156
+ // 等待连接建立后发送
157
+ this.once('connection', () => {
158
+ if (this.socket) {
159
+ this.socket.send(messageStr);
160
+ }
161
+ });
162
+ }
163
+ }
164
+ getNextId() {
165
+ return (++this.idCounter).toString();
166
+ }
167
+ }
168
+
169
+ class Topic extends EventEmitter {
170
+ constructor(options) {
171
+ super();
172
+ this.isSubscribed = false;
173
+ this.isAdvertised = false;
174
+ this.ros = options.ros;
175
+ this.name = options.name;
176
+ this.messageType = options.messageType;
177
+ this.compression = options.compression;
178
+ this.throttle_rate = options.throttle_rate;
179
+ this.queue_size = options.queue_size;
180
+ this.latch = options.latch;
181
+ this.queue_length = options.queue_length;
182
+ }
183
+ subscribe(callback) {
184
+ if (this.isSubscribed) {
185
+ return;
186
+ }
187
+ const subscribeMessage = Object.assign(Object.assign(Object.assign({ op: 'subscribe', topic: this.name, type: this.messageType }, (this.compression && { compression: this.compression })), (this.throttle_rate && { throttle_rate: this.throttle_rate })), (this.queue_length && { queue_length: this.queue_length }));
188
+ this.ros.callOnConnection(subscribeMessage);
189
+ this.isSubscribed = true;
190
+ // 监听来自 ROS 的消息
191
+ this.ros.on(this.name, (message) => {
192
+ this.emit('message', message);
193
+ if (callback) {
194
+ callback(message);
195
+ }
196
+ });
197
+ // 监听连接关闭事件,重新订阅
198
+ this.ros.on('close', () => {
199
+ this.isSubscribed = false;
200
+ });
201
+ this.ros.on('connection', () => {
202
+ if (!this.isSubscribed) {
203
+ this.subscribe(callback);
204
+ }
205
+ });
206
+ }
207
+ unsubscribe() {
208
+ if (!this.isSubscribed) {
209
+ return;
210
+ }
211
+ const unsubscribeMessage = {
212
+ op: 'unsubscribe',
213
+ topic: this.name
214
+ };
215
+ this.ros.callOnConnection(unsubscribeMessage);
216
+ this.isSubscribed = false;
217
+ // 移除事件监听器
218
+ this.ros.off(this.name);
219
+ }
220
+ advertise() {
221
+ if (this.isAdvertised) {
222
+ return;
223
+ }
224
+ const advertiseMessage = Object.assign(Object.assign({ op: 'advertise', topic: this.name, type: this.messageType }, (this.latch && { latch: this.latch })), (this.queue_size && { queue_size: this.queue_size }));
225
+ this.ros.callOnConnection(advertiseMessage);
226
+ this.isAdvertised = true;
227
+ // 监听连接关闭事件
228
+ this.ros.on('close', () => {
229
+ this.isAdvertised = false;
230
+ });
231
+ this.ros.on('connection', () => {
232
+ if (!this.isAdvertised) {
233
+ this.advertise();
234
+ }
235
+ });
236
+ }
237
+ unadvertise() {
238
+ if (!this.isAdvertised) {
239
+ return;
240
+ }
241
+ const unadvertiseMessage = {
242
+ op: 'unadvertise',
243
+ topic: this.name
244
+ };
245
+ this.ros.callOnConnection(unadvertiseMessage);
246
+ this.isAdvertised = false;
247
+ }
248
+ publish(message) {
249
+ if (!this.isAdvertised) {
250
+ this.advertise();
251
+ }
252
+ const publishMessage = {
253
+ op: 'publish',
254
+ topic: this.name,
255
+ msg: message
256
+ };
257
+ this.ros.callOnConnection(publishMessage);
258
+ }
259
+ }
260
+
261
+ class ServiceRequest {
262
+ constructor(values) {
263
+ if (values) {
264
+ Object.assign(this, values);
265
+ }
266
+ }
267
+ }
268
+ class ServiceResponse {
269
+ constructor(values) {
270
+ if (values) {
271
+ Object.assign(this, values);
272
+ }
273
+ }
274
+ }
275
+
276
+ class Service extends EventEmitter {
277
+ constructor(options) {
278
+ super();
279
+ this.isAdvertised = false;
280
+ this.ros = options.ros;
281
+ this.name = options.name;
282
+ this.serviceType = options.serviceType;
283
+ }
284
+ callService(request, callback, failedCallback) {
285
+ return new Promise((resolve, reject) => {
286
+ const serviceId = this.ros.getNextId();
287
+ const serviceMessage = {
288
+ op: 'call_service',
289
+ id: serviceId,
290
+ service: this.name,
291
+ type: this.serviceType,
292
+ args: request
293
+ };
294
+ // 监听服务响应
295
+ const responseHandler = (message) => {
296
+ var _a;
297
+ if (message.id === serviceId) {
298
+ this.ros.off(serviceId, responseHandler);
299
+ // rosbridge-level error
300
+ if (message.result === false) {
301
+ const error = new Error(message.error || `Service ${this.name} call failed`);
302
+ failedCallback === null || failedCallback === void 0 ? void 0 : failedCallback(error);
303
+ reject(error);
304
+ return;
305
+ }
306
+ // protocol error
307
+ if (message.result === undefined) {
308
+ const error = new Error('Invalid service response');
309
+ failedCallback === null || failedCallback === void 0 ? void 0 : failedCallback(error);
310
+ reject(error);
311
+ return;
312
+ }
313
+ // success
314
+ const response = new ServiceResponse((_a = message.values) !== null && _a !== void 0 ? _a : {});
315
+ callback === null || callback === void 0 ? void 0 : callback(response);
316
+ resolve(response);
317
+ }
318
+ };
319
+ this.ros.on(serviceId, responseHandler);
320
+ this.ros.callOnConnection(serviceMessage);
321
+ });
322
+ }
323
+ advertise(callback) {
324
+ if (this.isAdvertised) {
325
+ return;
326
+ }
327
+ const advertiseMessage = {
328
+ op: 'advertise_service',
329
+ service: this.name,
330
+ type: this.serviceType
331
+ };
332
+ this.ros.callOnConnection(advertiseMessage);
333
+ this.isAdvertised = true;
334
+ // 监听服务请求
335
+ this.ros.on('service_request:' + this.name, (message) => {
336
+ const request = new ServiceRequest(message.args);
337
+ const response = new ServiceResponse();
338
+ try {
339
+ const result = callback(request, response);
340
+ const responseMessage = {
341
+ op: 'service_response',
342
+ service: this.name,
343
+ id: message.id,
344
+ values: response,
345
+ result: result !== false
346
+ };
347
+ this.ros.callOnConnection(responseMessage);
348
+ }
349
+ catch (error) {
350
+ const errorMessage = {
351
+ op: 'service_response',
352
+ service: this.name,
353
+ id: message.id,
354
+ result: false,
355
+ error: error instanceof Error ? error.message : 'Unknown error'
356
+ };
357
+ this.ros.callOnConnection(errorMessage);
358
+ }
359
+ });
360
+ // 监听连接关闭事件
361
+ this.ros.on('close', () => {
362
+ this.isAdvertised = false;
363
+ });
364
+ this.ros.on('connection', () => {
365
+ if (!this.isAdvertised) {
366
+ this.advertise(callback);
367
+ }
368
+ });
369
+ }
370
+ unadvertise() {
371
+ if (!this.isAdvertised) {
372
+ return;
373
+ }
374
+ const unadvertiseMessage = {
375
+ op: 'unadvertise_service',
376
+ service: this.name
377
+ };
378
+ this.ros.callOnConnection(unadvertiseMessage);
379
+ this.isAdvertised = false;
380
+ // 移除事件监听器
381
+ this.ros.off('service_request:' + this.name);
382
+ }
383
+ }
384
+
385
+ class Param {
386
+ constructor(options) {
387
+ this.ros = options.ros;
388
+ this.name = options.name;
389
+ }
390
+ get(callback) {
391
+ return new Promise((resolve, reject) => {
392
+ const service = new Service({
393
+ ros: this.ros,
394
+ name: '/rosapi/get_param',
395
+ serviceType: 'rosapi/GetParam'
396
+ });
397
+ const request = new ServiceRequest({
398
+ name: this.name,
399
+ default: ''
400
+ });
401
+ service.callService(request, (response) => {
402
+ if (callback)
403
+ callback(response.value);
404
+ resolve(response.value);
405
+ }, (error) => {
406
+ reject(error);
407
+ });
408
+ });
409
+ }
410
+ set(value, callback) {
411
+ return new Promise((resolve, reject) => {
412
+ const service = new Service({
413
+ ros: this.ros,
414
+ name: '/rosapi/set_param',
415
+ serviceType: 'rosapi/SetParam'
416
+ });
417
+ const request = new ServiceRequest({
418
+ name: this.name,
419
+ value: JSON.stringify(value)
420
+ });
421
+ service.callService(request, () => {
422
+ if (callback)
423
+ callback();
424
+ resolve();
425
+ }, (error) => {
426
+ reject(error);
427
+ });
428
+ });
429
+ }
430
+ delete(callback) {
431
+ return new Promise((resolve, reject) => {
432
+ const service = new Service({
433
+ ros: this.ros,
434
+ name: '/rosapi/delete_param',
435
+ serviceType: 'rosapi/DeleteParam'
436
+ });
437
+ const request = new ServiceRequest({
438
+ name: this.name
439
+ });
440
+ service.callService(request, () => {
441
+ if (callback)
442
+ callback();
443
+ resolve();
444
+ }, (error) => {
445
+ reject(error);
446
+ });
447
+ });
448
+ }
449
+ }
450
+
451
+ exports.EventEmitter = EventEmitter;
452
+ exports.Param = Param;
453
+ exports.Ros = Ros;
454
+ exports.Service = Service;
455
+ exports.ServiceRequest = ServiceRequest;
456
+ exports.ServiceResponse = ServiceResponse;
457
+ exports.Topic = Topic;
458
+ //# sourceMappingURL=index.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/EventEmitter.ts","../src/Ros.ts","../src/Topic.ts","../src/ServiceRequest.ts","../src/Service.ts","../src/Param.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"mappings":";;AAAA;AACc,MAAO,YAAY,CAAA;AAAjC,IAAA,WAAA,GAAA;QACU,IAAA,CAAA,MAAM,GAAkC,EAAE;IA2DpD;IAzDE,EAAE,CAAC,KAAa,EAAE,QAAkB,EAAA;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AACvB,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;QACzB;QACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;AACjC,QAAA,OAAO,IAAI;IACb;IAEA,IAAI,CAAC,KAAa,EAAE,QAAkB,EAAA;AACpC,QAAA,MAAM,WAAW,GAAG,CAAC,GAAG,IA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AAC,OAAO,EAAE,MAAK;AAChC,gBAAA,IAAI,QAAQ;AAAE,oBAAA,QAAQ,EAAE;AACxB,gBAAA,OAAO,EAAE;AACX,YAAA,CAAC,EAAE,CAAC,KAAU,KAAI;gBAChB,MAAM,CAAC,KAAK,CAAC;AACf,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;IACJ;AACD;;;;;;;;;;"}
@@ -0,0 +1,101 @@
1
+ declare class EventEmitter {
2
+ private events;
3
+ on(event: string, listener: Function): this;
4
+ once(event: string, listener: Function): this;
5
+ off(event: string, listener?: Function): this;
6
+ emit(event: string, ...args: any[]): boolean;
7
+ removeAllListeners(event?: string): this;
8
+ listenerCount(event: string): number;
9
+ }
10
+
11
+ interface RosOptions {
12
+ url?: string;
13
+ WebSocket?: typeof WebSocket;
14
+ }
15
+ declare class Ros extends EventEmitter {
16
+ private socket;
17
+ private _isConnected;
18
+ private idCounter;
19
+ private reconnectTimer;
20
+ private options;
21
+ constructor(options?: RosOptions);
22
+ get isConnected(): boolean;
23
+ connect(url: string): void;
24
+ close(): void;
25
+ private handleMessage;
26
+ callOnConnection(message: any): void;
27
+ getNextId(): string;
28
+ }
29
+
30
+ interface TopicOptions {
31
+ ros: Ros;
32
+ name: string;
33
+ messageType: string;
34
+ compression?: string;
35
+ throttle_rate?: number;
36
+ queue_size?: number;
37
+ latch?: boolean;
38
+ queue_length?: number;
39
+ }
40
+ declare class Topic extends EventEmitter {
41
+ readonly ros: Ros;
42
+ readonly name: string;
43
+ readonly messageType: string;
44
+ readonly compression?: string;
45
+ readonly throttle_rate?: number;
46
+ readonly queue_size?: number;
47
+ readonly latch?: boolean;
48
+ readonly queue_length?: number;
49
+ private isSubscribed;
50
+ private isAdvertised;
51
+ constructor(options: TopicOptions);
52
+ subscribe(callback?: (message: any) => void): void;
53
+ unsubscribe(): void;
54
+ advertise(): void;
55
+ unadvertise(): void;
56
+ publish(message: any): void;
57
+ }
58
+
59
+ declare class ServiceRequest {
60
+ [key: string]: any;
61
+ constructor(values?: {
62
+ [key: string]: any;
63
+ });
64
+ }
65
+ declare class ServiceResponse {
66
+ [key: string]: any;
67
+ constructor(values?: {
68
+ [key: string]: any;
69
+ });
70
+ }
71
+
72
+ interface ServiceOptions {
73
+ ros: Ros;
74
+ name: string;
75
+ serviceType: string;
76
+ }
77
+ declare class Service extends EventEmitter {
78
+ private ros;
79
+ private name;
80
+ private serviceType;
81
+ private isAdvertised;
82
+ constructor(options: ServiceOptions);
83
+ callService(request: ServiceRequest, callback?: (response: ServiceResponse) => void, failedCallback?: (error: any) => void): Promise<ServiceResponse>;
84
+ advertise(callback: (request: ServiceRequest, response: ServiceResponse) => boolean | void): void;
85
+ unadvertise(): void;
86
+ }
87
+
88
+ interface ParamOptions {
89
+ ros: Ros;
90
+ name: string;
91
+ }
92
+ declare class Param {
93
+ private ros;
94
+ private name;
95
+ constructor(options: ParamOptions);
96
+ get(callback?: (value: any) => void): Promise<any>;
97
+ set(value: any, callback?: () => void): Promise<void>;
98
+ delete(callback?: () => void): Promise<void>;
99
+ }
100
+
101
+ export { EventEmitter, Param, Ros, Service, ServiceRequest, ServiceResponse, Topic };
@@ -0,0 +1,450 @@
1
+ // 简单的事件发射器实现
2
+ class EventEmitter {
3
+ constructor() {
4
+ this.events = {};
5
+ }
6
+ on(event, listener) {
7
+ if (!this.events[event]) {
8
+ this.events[event] = [];
9
+ }
10
+ this.events[event].push(listener);
11
+ return this;
12
+ }
13
+ once(event, listener) {
14
+ const onceWrapper = (...args) => {
15
+ this.off(event, onceWrapper);
16
+ listener.apply(this, args);
17
+ };
18
+ this.on(event, onceWrapper);
19
+ return this;
20
+ }
21
+ off(event, listener) {
22
+ if (!this.events[event])
23
+ return this;
24
+ if (!listener) {
25
+ delete this.events[event];
26
+ return this;
27
+ }
28
+ const index = this.events[event].indexOf(listener);
29
+ if (index > -1) {
30
+ this.events[event].splice(index, 1);
31
+ }
32
+ return this;
33
+ }
34
+ emit(event, ...args) {
35
+ if (!this.events[event])
36
+ return false;
37
+ this.events[event].forEach(listener => {
38
+ try {
39
+ listener.apply(this, args);
40
+ }
41
+ catch (error) {
42
+ console.error('Error in event listener:', error);
43
+ }
44
+ });
45
+ return true;
46
+ }
47
+ removeAllListeners(event) {
48
+ if (event) {
49
+ delete this.events[event];
50
+ }
51
+ else {
52
+ this.events = {};
53
+ }
54
+ return this;
55
+ }
56
+ listenerCount(event) {
57
+ return this.events[event] ? this.events[event].length : 0;
58
+ }
59
+ }
60
+
61
+ class Ros extends EventEmitter {
62
+ // private reconnectDelay = 1000;
63
+ constructor(options = {}) {
64
+ super();
65
+ this.socket = null;
66
+ this._isConnected = false;
67
+ this.idCounter = 0;
68
+ this.reconnectTimer = null;
69
+ this.options = options;
70
+ if (options.url) {
71
+ this.connect(options.url);
72
+ }
73
+ }
74
+ get isConnected() {
75
+ return this._isConnected;
76
+ }
77
+ connect(url) {
78
+ var _a, _b;
79
+ if (this.socket && this.socket.readyState === WebSocket.OPEN && this.socket.url === url) {
80
+ return;
81
+ }
82
+ if (this.socket) {
83
+ this.close();
84
+ }
85
+ try {
86
+ const WS = (_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.WebSocket) !== null && _b !== void 0 ? _b : WebSocket;
87
+ this.socket = new WS(url);
88
+ this.socket.onopen = () => {
89
+ this._isConnected = true;
90
+ this.emit('connection');
91
+ // 清除重连定时器
92
+ if (this.reconnectTimer) {
93
+ clearTimeout(this.reconnectTimer);
94
+ this.reconnectTimer = null;
95
+ }
96
+ };
97
+ this.socket.onclose = () => {
98
+ this._isConnected = false;
99
+ this.emit('close');
100
+ };
101
+ this.socket.onerror = (error) => {
102
+ this.emit('error', error);
103
+ };
104
+ this.socket.onmessage = (event) => {
105
+ this.handleMessage(event.data);
106
+ };
107
+ }
108
+ catch (error) {
109
+ this.emit('error', error);
110
+ }
111
+ }
112
+ close() {
113
+ if (this.socket) {
114
+ this.socket.close();
115
+ this.socket = null;
116
+ }
117
+ this._isConnected = false;
118
+ if (this.reconnectTimer) {
119
+ clearTimeout(this.reconnectTimer);
120
+ this.reconnectTimer = null;
121
+ }
122
+ }
123
+ handleMessage(data) {
124
+ try {
125
+ const message = JSON.parse(data);
126
+ if (message.op === 'publish') {
127
+ // 发布消息到对应的 topic
128
+ this.emit(message.topic, message.msg);
129
+ }
130
+ else if (message.op === 'service_response') {
131
+ // 服务响应
132
+ this.emit(message.id, message);
133
+ }
134
+ else if (message.op === 'status') {
135
+ // 状态消息
136
+ if (message.id) {
137
+ this.emit('status:' + message.id, message);
138
+ }
139
+ else {
140
+ this.emit('status', message);
141
+ }
142
+ }
143
+ }
144
+ catch (error) {
145
+ console.error('Error parsing message:', error);
146
+ }
147
+ }
148
+ callOnConnection(message) {
149
+ const messageStr = JSON.stringify(message);
150
+ if (this._isConnected && this.socket) {
151
+ this.socket.send(messageStr);
152
+ }
153
+ else {
154
+ // 等待连接建立后发送
155
+ this.once('connection', () => {
156
+ if (this.socket) {
157
+ this.socket.send(messageStr);
158
+ }
159
+ });
160
+ }
161
+ }
162
+ getNextId() {
163
+ return (++this.idCounter).toString();
164
+ }
165
+ }
166
+
167
+ class Topic extends EventEmitter {
168
+ constructor(options) {
169
+ super();
170
+ this.isSubscribed = false;
171
+ this.isAdvertised = false;
172
+ this.ros = options.ros;
173
+ this.name = options.name;
174
+ this.messageType = options.messageType;
175
+ this.compression = options.compression;
176
+ this.throttle_rate = options.throttle_rate;
177
+ this.queue_size = options.queue_size;
178
+ this.latch = options.latch;
179
+ this.queue_length = options.queue_length;
180
+ }
181
+ subscribe(callback) {
182
+ if (this.isSubscribed) {
183
+ return;
184
+ }
185
+ const subscribeMessage = Object.assign(Object.assign(Object.assign({ op: 'subscribe', topic: this.name, type: this.messageType }, (this.compression && { compression: this.compression })), (this.throttle_rate && { throttle_rate: this.throttle_rate })), (this.queue_length && { queue_length: this.queue_length }));
186
+ this.ros.callOnConnection(subscribeMessage);
187
+ this.isSubscribed = true;
188
+ // 监听来自 ROS 的消息
189
+ this.ros.on(this.name, (message) => {
190
+ this.emit('message', message);
191
+ if (callback) {
192
+ callback(message);
193
+ }
194
+ });
195
+ // 监听连接关闭事件,重新订阅
196
+ this.ros.on('close', () => {
197
+ this.isSubscribed = false;
198
+ });
199
+ this.ros.on('connection', () => {
200
+ if (!this.isSubscribed) {
201
+ this.subscribe(callback);
202
+ }
203
+ });
204
+ }
205
+ unsubscribe() {
206
+ if (!this.isSubscribed) {
207
+ return;
208
+ }
209
+ const unsubscribeMessage = {
210
+ op: 'unsubscribe',
211
+ topic: this.name
212
+ };
213
+ this.ros.callOnConnection(unsubscribeMessage);
214
+ this.isSubscribed = false;
215
+ // 移除事件监听器
216
+ this.ros.off(this.name);
217
+ }
218
+ advertise() {
219
+ if (this.isAdvertised) {
220
+ return;
221
+ }
222
+ const advertiseMessage = Object.assign(Object.assign({ op: 'advertise', topic: this.name, type: this.messageType }, (this.latch && { latch: this.latch })), (this.queue_size && { queue_size: this.queue_size }));
223
+ this.ros.callOnConnection(advertiseMessage);
224
+ this.isAdvertised = true;
225
+ // 监听连接关闭事件
226
+ this.ros.on('close', () => {
227
+ this.isAdvertised = false;
228
+ });
229
+ this.ros.on('connection', () => {
230
+ if (!this.isAdvertised) {
231
+ this.advertise();
232
+ }
233
+ });
234
+ }
235
+ unadvertise() {
236
+ if (!this.isAdvertised) {
237
+ return;
238
+ }
239
+ const unadvertiseMessage = {
240
+ op: 'unadvertise',
241
+ topic: this.name
242
+ };
243
+ this.ros.callOnConnection(unadvertiseMessage);
244
+ this.isAdvertised = false;
245
+ }
246
+ publish(message) {
247
+ if (!this.isAdvertised) {
248
+ this.advertise();
249
+ }
250
+ const publishMessage = {
251
+ op: 'publish',
252
+ topic: this.name,
253
+ msg: message
254
+ };
255
+ this.ros.callOnConnection(publishMessage);
256
+ }
257
+ }
258
+
259
+ class ServiceRequest {
260
+ constructor(values) {
261
+ if (values) {
262
+ Object.assign(this, values);
263
+ }
264
+ }
265
+ }
266
+ class ServiceResponse {
267
+ constructor(values) {
268
+ if (values) {
269
+ Object.assign(this, values);
270
+ }
271
+ }
272
+ }
273
+
274
+ class Service extends EventEmitter {
275
+ constructor(options) {
276
+ super();
277
+ this.isAdvertised = false;
278
+ this.ros = options.ros;
279
+ this.name = options.name;
280
+ this.serviceType = options.serviceType;
281
+ }
282
+ callService(request, callback, failedCallback) {
283
+ return new Promise((resolve, reject) => {
284
+ const serviceId = this.ros.getNextId();
285
+ const serviceMessage = {
286
+ op: 'call_service',
287
+ id: serviceId,
288
+ service: this.name,
289
+ type: this.serviceType,
290
+ args: request
291
+ };
292
+ // 监听服务响应
293
+ const responseHandler = (message) => {
294
+ var _a;
295
+ if (message.id === serviceId) {
296
+ this.ros.off(serviceId, responseHandler);
297
+ // rosbridge-level error
298
+ if (message.result === false) {
299
+ const error = new Error(message.error || `Service ${this.name} call failed`);
300
+ failedCallback === null || failedCallback === void 0 ? void 0 : failedCallback(error);
301
+ reject(error);
302
+ return;
303
+ }
304
+ // protocol error
305
+ if (message.result === undefined) {
306
+ const error = new Error('Invalid service response');
307
+ failedCallback === null || failedCallback === void 0 ? void 0 : failedCallback(error);
308
+ reject(error);
309
+ return;
310
+ }
311
+ // success
312
+ const response = new ServiceResponse((_a = message.values) !== null && _a !== void 0 ? _a : {});
313
+ callback === null || callback === void 0 ? void 0 : callback(response);
314
+ resolve(response);
315
+ }
316
+ };
317
+ this.ros.on(serviceId, responseHandler);
318
+ this.ros.callOnConnection(serviceMessage);
319
+ });
320
+ }
321
+ advertise(callback) {
322
+ if (this.isAdvertised) {
323
+ return;
324
+ }
325
+ const advertiseMessage = {
326
+ op: 'advertise_service',
327
+ service: this.name,
328
+ type: this.serviceType
329
+ };
330
+ this.ros.callOnConnection(advertiseMessage);
331
+ this.isAdvertised = true;
332
+ // 监听服务请求
333
+ this.ros.on('service_request:' + this.name, (message) => {
334
+ const request = new ServiceRequest(message.args);
335
+ const response = new ServiceResponse();
336
+ try {
337
+ const result = callback(request, response);
338
+ const responseMessage = {
339
+ op: 'service_response',
340
+ service: this.name,
341
+ id: message.id,
342
+ values: response,
343
+ result: result !== false
344
+ };
345
+ this.ros.callOnConnection(responseMessage);
346
+ }
347
+ catch (error) {
348
+ const errorMessage = {
349
+ op: 'service_response',
350
+ service: this.name,
351
+ id: message.id,
352
+ result: false,
353
+ error: error instanceof Error ? error.message : 'Unknown error'
354
+ };
355
+ this.ros.callOnConnection(errorMessage);
356
+ }
357
+ });
358
+ // 监听连接关闭事件
359
+ this.ros.on('close', () => {
360
+ this.isAdvertised = false;
361
+ });
362
+ this.ros.on('connection', () => {
363
+ if (!this.isAdvertised) {
364
+ this.advertise(callback);
365
+ }
366
+ });
367
+ }
368
+ unadvertise() {
369
+ if (!this.isAdvertised) {
370
+ return;
371
+ }
372
+ const unadvertiseMessage = {
373
+ op: 'unadvertise_service',
374
+ service: this.name
375
+ };
376
+ this.ros.callOnConnection(unadvertiseMessage);
377
+ this.isAdvertised = false;
378
+ // 移除事件监听器
379
+ this.ros.off('service_request:' + this.name);
380
+ }
381
+ }
382
+
383
+ class Param {
384
+ constructor(options) {
385
+ this.ros = options.ros;
386
+ this.name = options.name;
387
+ }
388
+ get(callback) {
389
+ return new Promise((resolve, reject) => {
390
+ const service = new Service({
391
+ ros: this.ros,
392
+ name: '/rosapi/get_param',
393
+ serviceType: 'rosapi/GetParam'
394
+ });
395
+ const request = new ServiceRequest({
396
+ name: this.name,
397
+ default: ''
398
+ });
399
+ service.callService(request, (response) => {
400
+ if (callback)
401
+ callback(response.value);
402
+ resolve(response.value);
403
+ }, (error) => {
404
+ reject(error);
405
+ });
406
+ });
407
+ }
408
+ set(value, callback) {
409
+ return new Promise((resolve, reject) => {
410
+ const service = new Service({
411
+ ros: this.ros,
412
+ name: '/rosapi/set_param',
413
+ serviceType: 'rosapi/SetParam'
414
+ });
415
+ const request = new ServiceRequest({
416
+ name: this.name,
417
+ value: JSON.stringify(value)
418
+ });
419
+ service.callService(request, () => {
420
+ if (callback)
421
+ callback();
422
+ resolve();
423
+ }, (error) => {
424
+ reject(error);
425
+ });
426
+ });
427
+ }
428
+ delete(callback) {
429
+ return new Promise((resolve, reject) => {
430
+ const service = new Service({
431
+ ros: this.ros,
432
+ name: '/rosapi/delete_param',
433
+ serviceType: 'rosapi/DeleteParam'
434
+ });
435
+ const request = new ServiceRequest({
436
+ name: this.name
437
+ });
438
+ service.callService(request, () => {
439
+ if (callback)
440
+ callback();
441
+ resolve();
442
+ }, (error) => {
443
+ reject(error);
444
+ });
445
+ });
446
+ }
447
+ }
448
+
449
+ export { EventEmitter, Param, Ros, Service, ServiceRequest, ServiceResponse, Topic };
450
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/EventEmitter.ts","../src/Ros.ts","../src/Topic.ts","../src/ServiceRequest.ts","../src/Service.ts","../src/Param.ts"],"sourcesContent":[null,null,null,null,null,null],"names":[],"mappings":"AAAA;AACc,MAAO,YAAY,CAAA;AAAjC,IAAA,WAAA,GAAA;QACU,IAAA,CAAA,MAAM,GAAkC,EAAE;IA2DpD;IAzDE,EAAE,CAAC,KAAa,EAAE,QAAkB,EAAA;QAClC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;AACvB,YAAA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;QACzB;QACA,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC;AACjC,QAAA,OAAO,IAAI;IACb;IAEA,IAAI,CAAC,KAAa,EAAE,QAAkB,EAAA;AACpC,QAAA,MAAM,WAAW,GAAG,CAAC,GAAG,IAAW,KAAI;AACrC,YAAA,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,WAAW,CAAC;AAC5B,YAAA,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC;AAC5B,QAAA,CAAC;AACD,QAAA,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,CAAC;AAC3B,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C;IACJ;AACD;;;;"}
@@ -0,0 +1,10 @@
1
+ export default class EventEmitter {
2
+ private events;
3
+ on(event: string, listener: Function): this;
4
+ once(event: string, listener: Function): this;
5
+ off(event: string, listener?: Function): this;
6
+ emit(event: string, ...args: any[]): boolean;
7
+ removeAllListeners(event?: string): this;
8
+ listenerCount(event: string): number;
9
+ }
10
+ //# sourceMappingURL=EventEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../src/EventEmitter.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,OAAO,CAAC,MAAM,CAAqC;IAEnD,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAQ3C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAS7C,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI;IAe7C,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO;IAa5C,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IASxC,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAGrC"}
@@ -0,0 +1,15 @@
1
+ import Ros from './Ros';
2
+ interface ParamOptions {
3
+ ros: Ros;
4
+ name: string;
5
+ }
6
+ export default class Param {
7
+ private ros;
8
+ private name;
9
+ constructor(options: ParamOptions);
10
+ get(callback?: (value: any) => void): Promise<any>;
11
+ set(value: any, callback?: () => void): Promise<void>;
12
+ delete(callback?: () => void): Promise<void>;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=Param.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Param.d.ts","sourceRoot":"","sources":["../../src/Param.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAIxB,UAAU,YAAY;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,IAAI,CAAS;gBAET,OAAO,EAAE,YAAY;IAKjC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC;IAsBlD,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBrD,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB7C"}
@@ -0,0 +1,21 @@
1
+ import EventEmitter from './EventEmitter';
2
+ interface RosOptions {
3
+ url?: string;
4
+ WebSocket?: typeof WebSocket;
5
+ }
6
+ export default class Ros extends EventEmitter {
7
+ private socket;
8
+ private _isConnected;
9
+ private idCounter;
10
+ private reconnectTimer;
11
+ private options;
12
+ constructor(options?: RosOptions);
13
+ get isConnected(): boolean;
14
+ connect(url: string): void;
15
+ close(): void;
16
+ private handleMessage;
17
+ callOnConnection(message: any): void;
18
+ getNextId(): string;
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=Ros.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Ros.d.ts","sourceRoot":"","sources":["../../src/Ros.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,UAAU,UAAU;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,SAAS,CAAC;CAC9B;AAED,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,YAAY;IAC3C,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,cAAc,CAA8C;IACpE,OAAO,CAAC,OAAO,CAAa;gBAGhB,OAAO,GAAE,UAAe;IASpC,IAAI,WAAW,IAAI,OAAO,CAEzB;IAED,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IA0C1B,KAAK,IAAI,IAAI;IAab,OAAO,CAAC,aAAa;IAuBrB,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAepC,SAAS,IAAI,MAAM;CAGpB"}
@@ -0,0 +1,20 @@
1
+ import EventEmitter from './EventEmitter';
2
+ import Ros from './Ros';
3
+ import ServiceRequest, { ServiceResponse } from './ServiceRequest';
4
+ interface ServiceOptions {
5
+ ros: Ros;
6
+ name: string;
7
+ serviceType: string;
8
+ }
9
+ export default class Service extends EventEmitter {
10
+ private ros;
11
+ private name;
12
+ private serviceType;
13
+ private isAdvertised;
14
+ constructor(options: ServiceOptions);
15
+ callService(request: ServiceRequest, callback?: (response: ServiceResponse) => void, failedCallback?: (error: any) => void): Promise<ServiceResponse>;
16
+ advertise(callback: (request: ServiceRequest, response: ServiceResponse) => boolean | void): void;
17
+ unadvertise(): void;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=Service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Service.d.ts","sourceRoot":"","sources":["../../src/Service.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,cAAc,EAAE,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnE,UAAU,cAAc;IACtB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,YAAY;IAC/C,OAAO,CAAC,GAAG,CAAM;IACjB,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,cAAc;IAQnC,WAAW,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,IAAI,EAAE,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC;IA+CrJ,SAAS,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,eAAe,KAAK,OAAO,GAAG,IAAI,GAAG,IAAI;IAwDjG,WAAW,IAAI,IAAI;CAgBpB"}
@@ -0,0 +1,13 @@
1
+ export default class ServiceRequest {
2
+ [key: string]: any;
3
+ constructor(values?: {
4
+ [key: string]: any;
5
+ });
6
+ }
7
+ export declare class ServiceResponse {
8
+ [key: string]: any;
9
+ constructor(values?: {
10
+ [key: string]: any;
11
+ });
12
+ }
13
+ //# sourceMappingURL=ServiceRequest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServiceRequest.d.ts","sourceRoot":"","sources":["../../src/ServiceRequest.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBAEP,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;CAK5C;AAED,qBAAa,eAAe;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;gBAEP,MAAM,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;CAK5C"}
@@ -0,0 +1,32 @@
1
+ import EventEmitter from './EventEmitter';
2
+ import Ros from './Ros';
3
+ interface TopicOptions {
4
+ ros: Ros;
5
+ name: string;
6
+ messageType: string;
7
+ compression?: string;
8
+ throttle_rate?: number;
9
+ queue_size?: number;
10
+ latch?: boolean;
11
+ queue_length?: number;
12
+ }
13
+ export default class Topic extends EventEmitter {
14
+ readonly ros: Ros;
15
+ readonly name: string;
16
+ readonly messageType: string;
17
+ readonly compression?: string;
18
+ readonly throttle_rate?: number;
19
+ readonly queue_size?: number;
20
+ readonly latch?: boolean;
21
+ readonly queue_length?: number;
22
+ private isSubscribed;
23
+ private isAdvertised;
24
+ constructor(options: TopicOptions);
25
+ subscribe(callback?: (message: any) => void): void;
26
+ unsubscribe(): void;
27
+ advertise(): void;
28
+ unadvertise(): void;
29
+ publish(message: any): void;
30
+ }
31
+ export {};
32
+ //# sourceMappingURL=Topic.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Topic.d.ts","sourceRoot":"","sources":["../../src/Topic.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,UAAU,YAAY;IACpB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,YAAY;IAC7C,SAAgB,GAAG,EAAE,GAAG,CAAC;IACzB,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,SAAgB,WAAW,EAAE,MAAM,CAAC;IAEpC,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErC,SAAgB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvC,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpC,SAAgB,KAAK,CAAC,EAAE,OAAO,CAAC;IAEhC,SAAgB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,YAAY,CAAS;gBAEjB,OAAO,EAAE,YAAY;IAajC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAqClD,WAAW,IAAI,IAAI;IAiBnB,SAAS,IAAI,IAAI;IA4BjB,WAAW,IAAI,IAAI;IAcnB,OAAO,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;CAa5B"}
@@ -0,0 +1,7 @@
1
+ export { default as Ros } from './Ros';
2
+ export { default as Topic } from './Topic';
3
+ export { default as Service } from './Service';
4
+ export { default as ServiceRequest, ServiceResponse } from './ServiceRequest';
5
+ export { default as Param } from './Param';
6
+ export { default as EventEmitter } from './EventEmitter';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "roslib-ts",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript-first ROSLIB implementation",
5
+ "author": "naviai",
6
+ "license": "MIT",
7
+ "main": "dist/index.cjs.js",
8
+ "module": "dist/index.esm.js",
9
+ "types": "dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./dist/index.esm.js",
13
+ "require": "./dist/index.cjs.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "rollup -c",
22
+ "prepublishOnly": "pnpm build"
23
+ },
24
+ "keywords": [
25
+ "ros",
26
+ "roslib",
27
+ "robotics",
28
+ "typescript"
29
+ ],
30
+ "peerDependencies": {
31
+ "ws": "^8.0.0"
32
+ },
33
+ "packageManager": "pnpm@10.12.4",
34
+ "devDependencies": {
35
+ "@rollup/plugin-commonjs": "^29.0.0",
36
+ "@rollup/plugin-node-resolve": "^16.0.3",
37
+ "@rollup/plugin-typescript": "^12.3.0",
38
+ "rollup": "^4.54.0",
39
+ "rollup-plugin-dts": "^6.3.0",
40
+ "tslib": "^2.8.1",
41
+ "typescript": "^5.9.3"
42
+ },
43
+ "publishConfig": {
44
+ "registry": "https://registry.npmjs.org/",
45
+ "access": "public"
46
+ }
47
+ }