@workadventure/room-api-client 1.30.7 → 1.31.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.
@@ -1,24 +1,21 @@
1
- "use strict";
2
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
2
  // versions:
4
- // protoc-gen-ts_proto v2.4.2
3
+ // protoc-gen-ts_proto v2.11.6
5
4
  // protoc v3.19.1
6
5
  // source: google/protobuf/empty.proto
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.Empty = exports.protobufPackage = void 0;
9
6
  /* eslint-disable */
10
- const wire_1 = require("@bufbuild/protobuf/wire");
11
- exports.protobufPackage = "google.protobuf";
7
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
+ export const protobufPackage = "google.protobuf";
12
9
  function createBaseEmpty() {
13
10
  return {};
14
11
  }
15
- exports.Empty = {
16
- encode(_, writer = new wire_1.BinaryWriter()) {
12
+ export const Empty = {
13
+ encode(_, writer = new BinaryWriter()) {
17
14
  return writer;
18
15
  },
19
16
  decode(input, length) {
20
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
21
- let end = length === undefined ? reader.len : reader.pos + length;
17
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
18
+ const end = length === undefined ? reader.len : reader.pos + length;
22
19
  const message = createBaseEmpty();
23
20
  while (reader.pos < end) {
24
21
  const tag = reader.uint32();
@@ -39,7 +36,7 @@ exports.Empty = {
39
36
  return obj;
40
37
  },
41
38
  create(base) {
42
- return exports.Empty.fromPartial(base ?? {});
39
+ return Empty.fromPartial(base ?? {});
43
40
  },
44
41
  fromPartial(_) {
45
42
  const message = createBaseEmpty();
@@ -1,27 +1,24 @@
1
- "use strict";
2
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
2
  // versions:
4
- // protoc-gen-ts_proto v2.4.2
3
+ // protoc-gen-ts_proto v2.11.6
5
4
  // protoc v3.19.1
6
5
  // source: google/protobuf/struct.proto
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.ListValue = exports.Value = exports.Struct_FieldsEntry = exports.Struct = exports.nullValueToJSON = exports.nullValueFromJSON = exports.NullValue = exports.protobufPackage = void 0;
9
6
  /* eslint-disable */
10
- const wire_1 = require("@bufbuild/protobuf/wire");
11
- exports.protobufPackage = "google.protobuf";
7
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
+ export const protobufPackage = "google.protobuf";
12
9
  /**
13
10
  * `NullValue` is a singleton enumeration to represent the null value for the
14
11
  * `Value` type union.
15
12
  *
16
13
  * The JSON representation for `NullValue` is JSON `null`.
17
14
  */
18
- var NullValue;
15
+ export var NullValue;
19
16
  (function (NullValue) {
20
17
  /** NULL_VALUE - Null value. */
21
18
  NullValue[NullValue["NULL_VALUE"] = 0] = "NULL_VALUE";
22
19
  NullValue[NullValue["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
23
- })(NullValue = exports.NullValue || (exports.NullValue = {}));
24
- function nullValueFromJSON(object) {
20
+ })(NullValue || (NullValue = {}));
21
+ export function nullValueFromJSON(object) {
25
22
  switch (object) {
26
23
  case 0:
27
24
  case "NULL_VALUE":
@@ -32,8 +29,7 @@ function nullValueFromJSON(object) {
32
29
  return NullValue.UNRECOGNIZED;
33
30
  }
34
31
  }
35
- exports.nullValueFromJSON = nullValueFromJSON;
36
- function nullValueToJSON(object) {
32
+ export function nullValueToJSON(object) {
37
33
  switch (object) {
38
34
  case NullValue.NULL_VALUE:
39
35
  return "NULL_VALUE";
@@ -42,22 +38,21 @@ function nullValueToJSON(object) {
42
38
  return "UNRECOGNIZED";
43
39
  }
44
40
  }
45
- exports.nullValueToJSON = nullValueToJSON;
46
41
  function createBaseStruct() {
47
42
  return { fields: {} };
48
43
  }
49
- exports.Struct = {
50
- encode(message, writer = new wire_1.BinaryWriter()) {
51
- Object.entries(message.fields).forEach(([key, value]) => {
44
+ export const Struct = {
45
+ encode(message, writer = new BinaryWriter()) {
46
+ globalThis.Object.entries(message.fields).forEach(([key, value]) => {
52
47
  if (value !== undefined) {
53
- exports.Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
48
+ Struct_FieldsEntry.encode({ key: key, value }, writer.uint32(10).fork()).join();
54
49
  }
55
50
  });
56
51
  return writer;
57
52
  },
58
53
  decode(input, length) {
59
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
60
- let end = length === undefined ? reader.len : reader.pos + length;
54
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
55
+ const end = length === undefined ? reader.len : reader.pos + length;
61
56
  const message = createBaseStruct();
62
57
  while (reader.pos < end) {
63
58
  const tag = reader.uint32();
@@ -66,7 +61,7 @@ exports.Struct = {
66
61
  if (tag !== 10) {
67
62
  break;
68
63
  }
69
- const entry1 = exports.Struct_FieldsEntry.decode(reader, reader.uint32());
64
+ const entry1 = Struct_FieldsEntry.decode(reader, reader.uint32());
70
65
  if (entry1.value !== undefined) {
71
66
  message.fields[entry1.key] = entry1.value;
72
67
  }
@@ -83,7 +78,7 @@ exports.Struct = {
83
78
  fromJSON(object) {
84
79
  return {
85
80
  fields: isObject(object.fields)
86
- ? Object.entries(object.fields).reduce((acc, [key, value]) => {
81
+ ? globalThis.Object.entries(object.fields).reduce((acc, [key, value]) => {
87
82
  acc[key] = value;
88
83
  return acc;
89
84
  }, {})
@@ -93,7 +88,7 @@ exports.Struct = {
93
88
  toJSON(message) {
94
89
  const obj = {};
95
90
  if (message.fields) {
96
- const entries = Object.entries(message.fields);
91
+ const entries = globalThis.Object.entries(message.fields);
97
92
  if (entries.length > 0) {
98
93
  obj.fields = {};
99
94
  entries.forEach(([k, v]) => {
@@ -104,11 +99,11 @@ exports.Struct = {
104
99
  return obj;
105
100
  },
106
101
  create(base) {
107
- return exports.Struct.fromPartial(base ?? {});
102
+ return Struct.fromPartial(base ?? {});
108
103
  },
109
104
  fromPartial(object) {
110
105
  const message = createBaseStruct();
111
- message.fields = Object.entries(object.fields ?? {}).reduce((acc, [key, value]) => {
106
+ message.fields = globalThis.Object.entries(object.fields ?? {}).reduce((acc, [key, value]) => {
112
107
  if (value !== undefined) {
113
108
  acc[key] = value;
114
109
  }
@@ -119,7 +114,7 @@ exports.Struct = {
119
114
  wrap(object) {
120
115
  const struct = createBaseStruct();
121
116
  if (object !== undefined) {
122
- for (const key of Object.keys(object)) {
117
+ for (const key of globalThis.Object.keys(object)) {
123
118
  struct.fields[key] = object[key];
124
119
  }
125
120
  }
@@ -128,7 +123,7 @@ exports.Struct = {
128
123
  unwrap(message) {
129
124
  const object = {};
130
125
  if (message.fields) {
131
- for (const key of Object.keys(message.fields)) {
126
+ for (const key of globalThis.Object.keys(message.fields)) {
132
127
  object[key] = message.fields[key];
133
128
  }
134
129
  }
@@ -138,19 +133,19 @@ exports.Struct = {
138
133
  function createBaseStruct_FieldsEntry() {
139
134
  return { key: "", value: undefined };
140
135
  }
141
- exports.Struct_FieldsEntry = {
142
- encode(message, writer = new wire_1.BinaryWriter()) {
136
+ export const Struct_FieldsEntry = {
137
+ encode(message, writer = new BinaryWriter()) {
143
138
  if (message.key !== "") {
144
139
  writer.uint32(10).string(message.key);
145
140
  }
146
141
  if (message.value !== undefined) {
147
- exports.Value.encode(exports.Value.wrap(message.value), writer.uint32(18).fork()).join();
142
+ Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).join();
148
143
  }
149
144
  return writer;
150
145
  },
151
146
  decode(input, length) {
152
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
153
- let end = length === undefined ? reader.len : reader.pos + length;
147
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
148
+ const end = length === undefined ? reader.len : reader.pos + length;
154
149
  const message = createBaseStruct_FieldsEntry();
155
150
  while (reader.pos < end) {
156
151
  const tag = reader.uint32();
@@ -166,7 +161,7 @@ exports.Struct_FieldsEntry = {
166
161
  if (tag !== 18) {
167
162
  break;
168
163
  }
169
- message.value = exports.Value.unwrap(exports.Value.decode(reader, reader.uint32()));
164
+ message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
170
165
  continue;
171
166
  }
172
167
  }
@@ -194,7 +189,7 @@ exports.Struct_FieldsEntry = {
194
189
  return obj;
195
190
  },
196
191
  create(base) {
197
- return exports.Struct_FieldsEntry.fromPartial(base ?? {});
192
+ return Struct_FieldsEntry.fromPartial(base ?? {});
198
193
  },
199
194
  fromPartial(object) {
200
195
  const message = createBaseStruct_FieldsEntry();
@@ -213,8 +208,8 @@ function createBaseValue() {
213
208
  listValue: undefined,
214
209
  };
215
210
  }
216
- exports.Value = {
217
- encode(message, writer = new wire_1.BinaryWriter()) {
211
+ export const Value = {
212
+ encode(message, writer = new BinaryWriter()) {
218
213
  if (message.nullValue !== undefined) {
219
214
  writer.uint32(8).int32(message.nullValue);
220
215
  }
@@ -228,16 +223,16 @@ exports.Value = {
228
223
  writer.uint32(32).bool(message.boolValue);
229
224
  }
230
225
  if (message.structValue !== undefined) {
231
- exports.Struct.encode(exports.Struct.wrap(message.structValue), writer.uint32(42).fork()).join();
226
+ Struct.encode(Struct.wrap(message.structValue), writer.uint32(42).fork()).join();
232
227
  }
233
228
  if (message.listValue !== undefined) {
234
- exports.ListValue.encode(exports.ListValue.wrap(message.listValue), writer.uint32(50).fork()).join();
229
+ ListValue.encode(ListValue.wrap(message.listValue), writer.uint32(50).fork()).join();
235
230
  }
236
231
  return writer;
237
232
  },
238
233
  decode(input, length) {
239
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
240
- let end = length === undefined ? reader.len : reader.pos + length;
234
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
235
+ const end = length === undefined ? reader.len : reader.pos + length;
241
236
  const message = createBaseValue();
242
237
  while (reader.pos < end) {
243
238
  const tag = reader.uint32();
@@ -274,14 +269,14 @@ exports.Value = {
274
269
  if (tag !== 42) {
275
270
  break;
276
271
  }
277
- message.structValue = exports.Struct.unwrap(exports.Struct.decode(reader, reader.uint32()));
272
+ message.structValue = Struct.unwrap(Struct.decode(reader, reader.uint32()));
278
273
  continue;
279
274
  }
280
275
  case 6: {
281
276
  if (tag !== 50) {
282
277
  break;
283
278
  }
284
- message.listValue = exports.ListValue.unwrap(exports.ListValue.decode(reader, reader.uint32()));
279
+ message.listValue = ListValue.unwrap(ListValue.decode(reader, reader.uint32()));
285
280
  continue;
286
281
  }
287
282
  }
@@ -294,12 +289,36 @@ exports.Value = {
294
289
  },
295
290
  fromJSON(object) {
296
291
  return {
297
- nullValue: isSet(object.nullValue) ? nullValueFromJSON(object.nullValue) : undefined,
298
- numberValue: isSet(object.numberValue) ? globalThis.Number(object.numberValue) : undefined,
299
- stringValue: isSet(object.stringValue) ? globalThis.String(object.stringValue) : undefined,
300
- boolValue: isSet(object.boolValue) ? globalThis.Boolean(object.boolValue) : undefined,
301
- structValue: isObject(object.structValue) ? object.structValue : undefined,
302
- listValue: globalThis.Array.isArray(object.listValue) ? [...object.listValue] : undefined,
292
+ nullValue: isSet(object.nullValue)
293
+ ? nullValueFromJSON(object.nullValue)
294
+ : isSet(object.null_value)
295
+ ? nullValueFromJSON(object.null_value)
296
+ : undefined,
297
+ numberValue: isSet(object.numberValue)
298
+ ? globalThis.Number(object.numberValue)
299
+ : isSet(object.number_value)
300
+ ? globalThis.Number(object.number_value)
301
+ : undefined,
302
+ stringValue: isSet(object.stringValue)
303
+ ? globalThis.String(object.stringValue)
304
+ : isSet(object.string_value)
305
+ ? globalThis.String(object.string_value)
306
+ : undefined,
307
+ boolValue: isSet(object.boolValue)
308
+ ? globalThis.Boolean(object.boolValue)
309
+ : isSet(object.bool_value)
310
+ ? globalThis.Boolean(object.bool_value)
311
+ : undefined,
312
+ structValue: isObject(object.structValue)
313
+ ? object.structValue
314
+ : isObject(object.struct_value)
315
+ ? object.struct_value
316
+ : undefined,
317
+ listValue: globalThis.Array.isArray(object.listValue)
318
+ ? [...object.listValue]
319
+ : globalThis.Array.isArray(object.list_value)
320
+ ? [...object.list_value]
321
+ : undefined,
303
322
  };
304
323
  },
305
324
  toJSON(message) {
@@ -325,7 +344,7 @@ exports.Value = {
325
344
  return obj;
326
345
  },
327
346
  create(base) {
328
- return exports.Value.fromPartial(base ?? {});
347
+ return Value.fromPartial(base ?? {});
329
348
  },
330
349
  fromPartial(object) {
331
350
  const message = createBaseValue();
@@ -387,16 +406,16 @@ exports.Value = {
387
406
  function createBaseListValue() {
388
407
  return { values: [] };
389
408
  }
390
- exports.ListValue = {
391
- encode(message, writer = new wire_1.BinaryWriter()) {
409
+ export const ListValue = {
410
+ encode(message, writer = new BinaryWriter()) {
392
411
  for (const v of message.values) {
393
- exports.Value.encode(exports.Value.wrap(v), writer.uint32(10).fork()).join();
412
+ Value.encode(Value.wrap(v), writer.uint32(10).fork()).join();
394
413
  }
395
414
  return writer;
396
415
  },
397
416
  decode(input, length) {
398
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
399
- let end = length === undefined ? reader.len : reader.pos + length;
417
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
418
+ const end = length === undefined ? reader.len : reader.pos + length;
400
419
  const message = createBaseListValue();
401
420
  while (reader.pos < end) {
402
421
  const tag = reader.uint32();
@@ -405,7 +424,7 @@ exports.ListValue = {
405
424
  if (tag !== 10) {
406
425
  break;
407
426
  }
408
- message.values.push(exports.Value.unwrap(exports.Value.decode(reader, reader.uint32())));
427
+ message.values.push(Value.unwrap(Value.decode(reader, reader.uint32())));
409
428
  continue;
410
429
  }
411
430
  }
@@ -427,7 +446,7 @@ exports.ListValue = {
427
446
  return obj;
428
447
  },
429
448
  create(base) {
430
- return exports.ListValue.fromPartial(base ?? {});
449
+ return ListValue.fromPartial(base ?? {});
431
450
  },
432
451
  fromPartial(object) {
433
452
  const message = createBaseListValue();
@@ -1,5 +1,5 @@
1
1
  import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
2
- import { type CallContext, type CallOptions } from "nice-grpc-common";
2
+ import type { CallContext, CallOptions } from "nice-grpc-common";
3
3
  import { Empty } from "./google/protobuf/empty";
4
4
  import { Value } from "./google/protobuf/struct";
5
5
  export declare const protobufPackage = "roomApi";
@@ -39,45 +39,45 @@ export declare const RoomApiDefinition: {
39
39
  /** Get the current value of the given variable */
40
40
  readonly readVariable: {
41
41
  readonly name: "readVariable";
42
- readonly requestType: MessageFns<VariableRequest>;
42
+ readonly requestType: typeof VariableRequest;
43
43
  readonly requestStream: false;
44
- readonly responseType: import("./google/protobuf/struct").MessageFns<Value> & import("./google/protobuf/struct").AnyValueWrapperFns;
44
+ readonly responseType: typeof Value;
45
45
  readonly responseStream: false;
46
46
  readonly options: {};
47
47
  };
48
48
  /** Listen to value updates for a given variable */
49
49
  readonly listenVariable: {
50
50
  readonly name: "listenVariable";
51
- readonly requestType: MessageFns<VariableRequest>;
51
+ readonly requestType: typeof VariableRequest;
52
52
  readonly requestStream: false;
53
- readonly responseType: import("./google/protobuf/struct").MessageFns<Value> & import("./google/protobuf/struct").AnyValueWrapperFns;
53
+ readonly responseType: typeof Value;
54
54
  readonly responseStream: true;
55
55
  readonly options: {};
56
56
  };
57
57
  /** Set the value of the given variable */
58
58
  readonly saveVariable: {
59
59
  readonly name: "saveVariable";
60
- readonly requestType: MessageFns<SaveVariableRequest>;
60
+ readonly requestType: typeof SaveVariableRequest;
61
61
  readonly requestStream: false;
62
- readonly responseType: import("./google/protobuf/empty").MessageFns<Empty>;
62
+ readonly responseType: typeof Empty;
63
63
  readonly responseStream: false;
64
64
  readonly options: {};
65
65
  };
66
66
  /** Dispatch an event to all users in the room */
67
67
  readonly broadcastEvent: {
68
68
  readonly name: "broadcastEvent";
69
- readonly requestType: MessageFns<DispatchEventRequest>;
69
+ readonly requestType: typeof DispatchEventRequest;
70
70
  readonly requestStream: false;
71
- readonly responseType: import("./google/protobuf/empty").MessageFns<Empty>;
71
+ readonly responseType: typeof Empty;
72
72
  readonly responseStream: false;
73
73
  readonly options: {};
74
74
  };
75
75
  /** Listen to events dispatched in the room */
76
76
  readonly listenToEvent: {
77
77
  readonly name: "listenToEvent";
78
- readonly requestType: MessageFns<EventRequest>;
78
+ readonly requestType: typeof EventRequest;
79
79
  readonly requestStream: false;
80
- readonly responseType: MessageFns<EventResponse>;
80
+ readonly responseType: typeof EventResponse;
81
81
  readonly responseStream: true;
82
82
  readonly options: {};
83
83
  };
@@ -1,21 +1,18 @@
1
- "use strict";
2
1
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
2
  // versions:
4
- // protoc-gen-ts_proto v2.4.2
3
+ // protoc-gen-ts_proto v2.11.6
5
4
  // protoc v3.19.1
6
5
  // source: room-api.proto
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.RoomApiDefinition = exports.DispatchEventRequest = exports.EventResponse = exports.EventRequest = exports.SaveVariableRequest = exports.VariableRequest = exports.protobufPackage = void 0;
9
6
  /* eslint-disable */
10
- const wire_1 = require("@bufbuild/protobuf/wire");
11
- const empty_1 = require("./google/protobuf/empty");
12
- const struct_1 = require("./google/protobuf/struct");
13
- exports.protobufPackage = "roomApi";
7
+ import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
8
+ import { Empty } from "./google/protobuf/empty";
9
+ import { Value } from "./google/protobuf/struct";
10
+ export const protobufPackage = "roomApi";
14
11
  function createBaseVariableRequest() {
15
12
  return { room: "", name: "" };
16
13
  }
17
- exports.VariableRequest = {
18
- encode(message, writer = new wire_1.BinaryWriter()) {
14
+ export const VariableRequest = {
15
+ encode(message, writer = new BinaryWriter()) {
19
16
  if (message.room !== "") {
20
17
  writer.uint32(10).string(message.room);
21
18
  }
@@ -25,8 +22,8 @@ exports.VariableRequest = {
25
22
  return writer;
26
23
  },
27
24
  decode(input, length) {
28
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
29
- let end = length === undefined ? reader.len : reader.pos + length;
25
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
26
+ const end = length === undefined ? reader.len : reader.pos + length;
30
27
  const message = createBaseVariableRequest();
31
28
  while (reader.pos < end) {
32
29
  const tag = reader.uint32();
@@ -70,7 +67,7 @@ exports.VariableRequest = {
70
67
  return obj;
71
68
  },
72
69
  create(base) {
73
- return exports.VariableRequest.fromPartial(base ?? {});
70
+ return VariableRequest.fromPartial(base ?? {});
74
71
  },
75
72
  fromPartial(object) {
76
73
  const message = createBaseVariableRequest();
@@ -82,8 +79,8 @@ exports.VariableRequest = {
82
79
  function createBaseSaveVariableRequest() {
83
80
  return { room: "", name: "", value: undefined };
84
81
  }
85
- exports.SaveVariableRequest = {
86
- encode(message, writer = new wire_1.BinaryWriter()) {
82
+ export const SaveVariableRequest = {
83
+ encode(message, writer = new BinaryWriter()) {
87
84
  if (message.room !== "") {
88
85
  writer.uint32(10).string(message.room);
89
86
  }
@@ -91,13 +88,13 @@ exports.SaveVariableRequest = {
91
88
  writer.uint32(18).string(message.name);
92
89
  }
93
90
  if (message.value !== undefined) {
94
- struct_1.Value.encode(struct_1.Value.wrap(message.value), writer.uint32(26).fork()).join();
91
+ Value.encode(Value.wrap(message.value), writer.uint32(26).fork()).join();
95
92
  }
96
93
  return writer;
97
94
  },
98
95
  decode(input, length) {
99
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
100
- let end = length === undefined ? reader.len : reader.pos + length;
96
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
97
+ const end = length === undefined ? reader.len : reader.pos + length;
101
98
  const message = createBaseSaveVariableRequest();
102
99
  while (reader.pos < end) {
103
100
  const tag = reader.uint32();
@@ -120,7 +117,7 @@ exports.SaveVariableRequest = {
120
117
  if (tag !== 26) {
121
118
  break;
122
119
  }
123
- message.value = struct_1.Value.unwrap(struct_1.Value.decode(reader, reader.uint32()));
120
+ message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
124
121
  continue;
125
122
  }
126
123
  }
@@ -152,7 +149,7 @@ exports.SaveVariableRequest = {
152
149
  return obj;
153
150
  },
154
151
  create(base) {
155
- return exports.SaveVariableRequest.fromPartial(base ?? {});
152
+ return SaveVariableRequest.fromPartial(base ?? {});
156
153
  },
157
154
  fromPartial(object) {
158
155
  const message = createBaseSaveVariableRequest();
@@ -165,8 +162,8 @@ exports.SaveVariableRequest = {
165
162
  function createBaseEventRequest() {
166
163
  return { room: "", name: "" };
167
164
  }
168
- exports.EventRequest = {
169
- encode(message, writer = new wire_1.BinaryWriter()) {
165
+ export const EventRequest = {
166
+ encode(message, writer = new BinaryWriter()) {
170
167
  if (message.room !== "") {
171
168
  writer.uint32(10).string(message.room);
172
169
  }
@@ -176,8 +173,8 @@ exports.EventRequest = {
176
173
  return writer;
177
174
  },
178
175
  decode(input, length) {
179
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
180
- let end = length === undefined ? reader.len : reader.pos + length;
176
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
177
+ const end = length === undefined ? reader.len : reader.pos + length;
181
178
  const message = createBaseEventRequest();
182
179
  while (reader.pos < end) {
183
180
  const tag = reader.uint32();
@@ -221,7 +218,7 @@ exports.EventRequest = {
221
218
  return obj;
222
219
  },
223
220
  create(base) {
224
- return exports.EventRequest.fromPartial(base ?? {});
221
+ return EventRequest.fromPartial(base ?? {});
225
222
  },
226
223
  fromPartial(object) {
227
224
  const message = createBaseEventRequest();
@@ -233,10 +230,10 @@ exports.EventRequest = {
233
230
  function createBaseEventResponse() {
234
231
  return { data: undefined, senderId: undefined };
235
232
  }
236
- exports.EventResponse = {
237
- encode(message, writer = new wire_1.BinaryWriter()) {
233
+ export const EventResponse = {
234
+ encode(message, writer = new BinaryWriter()) {
238
235
  if (message.data !== undefined) {
239
- struct_1.Value.encode(struct_1.Value.wrap(message.data), writer.uint32(10).fork()).join();
236
+ Value.encode(Value.wrap(message.data), writer.uint32(10).fork()).join();
240
237
  }
241
238
  if (message.senderId !== undefined) {
242
239
  writer.uint32(16).int32(message.senderId);
@@ -244,8 +241,8 @@ exports.EventResponse = {
244
241
  return writer;
245
242
  },
246
243
  decode(input, length) {
247
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
248
- let end = length === undefined ? reader.len : reader.pos + length;
244
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
245
+ const end = length === undefined ? reader.len : reader.pos + length;
249
246
  const message = createBaseEventResponse();
250
247
  while (reader.pos < end) {
251
248
  const tag = reader.uint32();
@@ -254,7 +251,7 @@ exports.EventResponse = {
254
251
  if (tag !== 10) {
255
252
  break;
256
253
  }
257
- message.data = struct_1.Value.unwrap(struct_1.Value.decode(reader, reader.uint32()));
254
+ message.data = Value.unwrap(Value.decode(reader, reader.uint32()));
258
255
  continue;
259
256
  }
260
257
  case 2: {
@@ -289,7 +286,7 @@ exports.EventResponse = {
289
286
  return obj;
290
287
  },
291
288
  create(base) {
292
- return exports.EventResponse.fromPartial(base ?? {});
289
+ return EventResponse.fromPartial(base ?? {});
293
290
  },
294
291
  fromPartial(object) {
295
292
  const message = createBaseEventResponse();
@@ -301,8 +298,8 @@ exports.EventResponse = {
301
298
  function createBaseDispatchEventRequest() {
302
299
  return { room: "", name: "", data: undefined, targetUserIds: [] };
303
300
  }
304
- exports.DispatchEventRequest = {
305
- encode(message, writer = new wire_1.BinaryWriter()) {
301
+ export const DispatchEventRequest = {
302
+ encode(message, writer = new BinaryWriter()) {
306
303
  if (message.room !== "") {
307
304
  writer.uint32(10).string(message.room);
308
305
  }
@@ -310,7 +307,7 @@ exports.DispatchEventRequest = {
310
307
  writer.uint32(18).string(message.name);
311
308
  }
312
309
  if (message.data !== undefined) {
313
- struct_1.Value.encode(struct_1.Value.wrap(message.data), writer.uint32(26).fork()).join();
310
+ Value.encode(Value.wrap(message.data), writer.uint32(26).fork()).join();
314
311
  }
315
312
  writer.uint32(34).fork();
316
313
  for (const v of message.targetUserIds) {
@@ -320,8 +317,8 @@ exports.DispatchEventRequest = {
320
317
  return writer;
321
318
  },
322
319
  decode(input, length) {
323
- const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input);
324
- let end = length === undefined ? reader.len : reader.pos + length;
320
+ const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
321
+ const end = length === undefined ? reader.len : reader.pos + length;
325
322
  const message = createBaseDispatchEventRequest();
326
323
  while (reader.pos < end) {
327
324
  const tag = reader.uint32();
@@ -344,7 +341,7 @@ exports.DispatchEventRequest = {
344
341
  if (tag !== 26) {
345
342
  break;
346
343
  }
347
- message.data = struct_1.Value.unwrap(struct_1.Value.decode(reader, reader.uint32()));
344
+ message.data = Value.unwrap(Value.decode(reader, reader.uint32()));
348
345
  continue;
349
346
  }
350
347
  case 4: {
@@ -396,7 +393,7 @@ exports.DispatchEventRequest = {
396
393
  return obj;
397
394
  },
398
395
  create(base) {
399
- return exports.DispatchEventRequest.fromPartial(base ?? {});
396
+ return DispatchEventRequest.fromPartial(base ?? {});
400
397
  },
401
398
  fromPartial(object) {
402
399
  const message = createBaseDispatchEventRequest();
@@ -407,52 +404,52 @@ exports.DispatchEventRequest = {
407
404
  return message;
408
405
  },
409
406
  };
410
- exports.RoomApiDefinition = {
407
+ export const RoomApiDefinition = {
411
408
  name: "RoomApi",
412
409
  fullName: "roomApi.RoomApi",
413
410
  methods: {
414
411
  /** Get the current value of the given variable */
415
412
  readVariable: {
416
413
  name: "readVariable",
417
- requestType: exports.VariableRequest,
414
+ requestType: VariableRequest,
418
415
  requestStream: false,
419
- responseType: struct_1.Value,
416
+ responseType: Value,
420
417
  responseStream: false,
421
418
  options: {},
422
419
  },
423
420
  /** Listen to value updates for a given variable */
424
421
  listenVariable: {
425
422
  name: "listenVariable",
426
- requestType: exports.VariableRequest,
423
+ requestType: VariableRequest,
427
424
  requestStream: false,
428
- responseType: struct_1.Value,
425
+ responseType: Value,
429
426
  responseStream: true,
430
427
  options: {},
431
428
  },
432
429
  /** Set the value of the given variable */
433
430
  saveVariable: {
434
431
  name: "saveVariable",
435
- requestType: exports.SaveVariableRequest,
432
+ requestType: SaveVariableRequest,
436
433
  requestStream: false,
437
- responseType: empty_1.Empty,
434
+ responseType: Empty,
438
435
  responseStream: false,
439
436
  options: {},
440
437
  },
441
438
  /** Dispatch an event to all users in the room */
442
439
  broadcastEvent: {
443
440
  name: "broadcastEvent",
444
- requestType: exports.DispatchEventRequest,
441
+ requestType: DispatchEventRequest,
445
442
  requestStream: false,
446
- responseType: empty_1.Empty,
443
+ responseType: Empty,
447
444
  responseStream: false,
448
445
  options: {},
449
446
  },
450
447
  /** Listen to events dispatched in the room */
451
448
  listenToEvent: {
452
449
  name: "listenToEvent",
453
- requestType: exports.EventRequest,
450
+ requestType: EventRequest,
454
451
  requestStream: false,
455
- responseType: exports.EventResponse,
452
+ responseType: EventResponse,
456
453
  responseStream: true,
457
454
  options: {},
458
455
  },
@@ -1,11 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const index_1 = require("./index");
1
+ import { createRoomApiClient } from "./index";
4
2
  const apiKey = process.env.ROOM_API_SECRET_KEY;
5
3
  if (!apiKey) {
6
4
  throw new Error("No ROOM_API_SECRET_KEY defined on environment variables!");
7
5
  }
8
- const client = (0, index_1.createRoomApiClient)(apiKey, "room-api.workadventure.localhost", 80);
6
+ const client = createRoomApiClient(apiKey, "room-api.workadventure.localhost", 80);
9
7
  // URL of the room you wish to interact with
10
8
  const roomUrl = "http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/Variables/shared_variables.json";
11
9
  // Name of the event with which you want to interact
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const struct_1 = require("./compiled_proto/google/protobuf/struct");
4
- const index_1 = require("./index");
1
+ import { Value } from "./compiled_proto/google/protobuf/struct";
2
+ import { createRoomApiClient } from "./index";
5
3
  const apiKey = process.env.ROOM_API_SECRET_KEY;
6
4
  if (!apiKey) {
7
5
  throw new Error("No ROOM_API_SECRET_KEY defined on environment variables!");
8
6
  }
9
- const client = (0, index_1.createRoomApiClient)(apiKey, "room-api.workadventure.localhost", 80);
7
+ const client = createRoomApiClient(apiKey, "room-api.workadventure.localhost", 80);
10
8
  const roomUrl = "http://play.workadventure.localhost/_/global/maps.workadventure.localhost/tests/Variables/shared_variables.json";
11
9
  const variableName = "textField";
12
10
  async function init() {
@@ -23,7 +21,7 @@ async function init() {
23
21
  room: roomUrl,
24
22
  });
25
23
  console.log("Value read plain:", value);
26
- console.log("Value read:", struct_1.Value.unwrap(value));
24
+ console.log("Value read:", Value.unwrap(value));
27
25
  // Save a variable in 5sec
28
26
  setTimeout(() => {
29
27
  client.saveVariable({
@@ -41,7 +39,7 @@ async function init() {
41
39
  });
42
40
  for await (const value of listenVariable) {
43
41
  console.log("Value listened plain:", value);
44
- console.log("Value listened:", struct_1.Value.unwrap(value));
42
+ console.log("Value listened:", Value.unwrap(value));
45
43
  break;
46
44
  }
47
45
  }
package/dist/index.js CHANGED
@@ -1,30 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.createRoomApiClient = void 0;
18
- __exportStar(require("./compiled_proto/room-api"), exports);
19
- const nice_grpc_1 = require("nice-grpc");
20
- const room_api_1 = require("./compiled_proto/room-api");
21
- const createRoomApiClient = (apiKey, host = "room-api.workadventu.re", port = 443) => {
22
- const channel = (0, nice_grpc_1.createChannel)(`${host}:${port}`, port === 443 || host.startsWith("https://") ? nice_grpc_1.ChannelCredentials.createSsl() : nice_grpc_1.ChannelCredentials.createInsecure());
23
- const client = (0, nice_grpc_1.createClient)(room_api_1.RoomApiDefinition, channel, {
1
+ export * from "./compiled_proto/room-api";
2
+ import { ChannelCredentials, createChannel, createClient, Metadata } from "nice-grpc";
3
+ import { RoomApiDefinition } from "./compiled_proto/room-api";
4
+ export const createRoomApiClient = (apiKey, host = "room-api.workadventu.re", port = 443) => {
5
+ const channel = createChannel(`${host}:${port}`, port === 443 || host.startsWith("https://") ? ChannelCredentials.createSsl() : ChannelCredentials.createInsecure());
6
+ const client = createClient(RoomApiDefinition, channel, {
24
7
  "*": {
25
- metadata: new nice_grpc_1.Metadata({ "X-API-Key": apiKey }),
8
+ metadata: new Metadata({ "X-API-Key": apiKey }),
26
9
  }
27
10
  });
28
11
  return client;
29
12
  };
30
- exports.createRoomApiClient = createRoomApiClient;
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "@workadventure/room-api-client",
3
- "version": "v1.30.7",
3
+ "version": "v1.31.0",
4
4
  "description": "Workadventure Room Api Client",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "files": [
8
9
  "/dist"
9
10
  ],
10
11
  "scripts": {
11
- "ts-proto": "grpc_tools_node_protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/compiled_proto --ts_proto_opt=\"outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false\" --proto_path=../../../messages/protos ../../../messages/protos/room-api.proto",
12
+ "ts-proto": "grpc_tools_node_protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/compiled_proto --ts_proto_opt=\"outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false,esModuleInterop=true\" --proto_path=../../../messages/protos ../../../messages/protos/room-api.proto",
12
13
  "build": "tsc --build",
13
14
  "example-variables": "tsx ./src/example_variables.ts",
14
15
  "example-events": "tsx ./src/example_events.ts",
@@ -36,6 +37,7 @@
36
37
  "homepage": "https://github.com/thecodingmachine/workadventure/tree/master/libs/room-api-clients/room-api-client-js#readme",
37
38
  "dependencies": {
38
39
  "@bufbuild/protobuf": "^2.2.2",
40
+ "@grpc/grpc-js": "1.8.22",
39
41
  "long": "^5.2.1",
40
42
  "nice-grpc": "^2.1.3"
41
43
  },
@@ -48,7 +50,7 @@
48
50
  "prettier": "^2.8.6",
49
51
  "ts-proto": "^2.4.2",
50
52
  "tsx": "^4.7.1",
51
- "typescript": "^5.0.2"
53
+ "typescript": "^5.8.3"
52
54
  },
53
55
  "lint-staged": {
54
56
  "*.{js,ts}": [