scoundrel-remote-eval 1.0.8 → 1.0.10

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 (50) hide show
  1. package/build/client/connections/web-socket/index.d.ts +34 -0
  2. package/build/client/connections/web-socket/index.d.ts.map +1 -0
  3. package/build/client/connections/web-socket/index.js +68 -0
  4. package/build/client/index.d.ts +186 -0
  5. package/build/client/index.d.ts.map +1 -0
  6. package/build/client/index.js +452 -0
  7. package/build/client/reference-proxy.d.ts +7 -0
  8. package/build/client/reference-proxy.d.ts.map +1 -0
  9. package/build/client/reference-proxy.js +41 -0
  10. package/build/client/reference.d.ts +50 -0
  11. package/build/client/reference.d.ts.map +1 -0
  12. package/build/client/reference.js +63 -0
  13. package/build/index.d.ts +2 -0
  14. package/build/index.d.ts.map +1 -0
  15. package/build/index.js +1 -0
  16. package/build/logger.d.ts +39 -0
  17. package/build/logger.d.ts.map +1 -0
  18. package/build/logger.js +64 -0
  19. package/build/python-web-socket-runner.d.ts +27 -0
  20. package/build/python-web-socket-runner.d.ts.map +1 -0
  21. package/build/python-web-socket-runner.js +94 -0
  22. package/build/server/connections/web-socket/client.d.ts +26 -0
  23. package/build/server/connections/web-socket/client.d.ts.map +1 -0
  24. package/build/server/connections/web-socket/client.js +39 -0
  25. package/build/server/connections/web-socket/index.d.ts +19 -0
  26. package/build/server/connections/web-socket/index.d.ts.map +1 -0
  27. package/build/server/connections/web-socket/index.js +29 -0
  28. package/build/server/index.d.ts +27 -0
  29. package/build/server/index.d.ts.map +1 -0
  30. package/build/server/index.js +34 -0
  31. package/build/utils/single-event-emitter.d.ts +46 -0
  32. package/build/utils/single-event-emitter.d.ts.map +1 -0
  33. package/build/utils/single-event-emitter.js +86 -0
  34. package/package.json +9 -3
  35. package/eslint.config.js +0 -18
  36. package/spec/reference-with-proxy-spec.js +0 -101
  37. package/spec/support/jasmine.json +0 -13
  38. package/spec/web-socket-javascript-spec.js +0 -66
  39. package/spec/web-socket-python-spec.js +0 -57
  40. package/src/client/connections/web-socket/index.js +0 -88
  41. package/src/client/index.js +0 -469
  42. package/src/client/reference-proxy.js +0 -53
  43. package/src/client/reference.js +0 -69
  44. package/src/index.js +0 -0
  45. package/src/logger.js +0 -70
  46. package/src/python-web-socket-runner.js +0 -116
  47. package/src/server/connections/web-socket/client.js +0 -46
  48. package/src/server/connections/web-socket/index.js +0 -34
  49. package/src/server/index.js +0 -33
  50. package/tsconfig.json +0 -13
@@ -0,0 +1,452 @@
1
+ // @ts-check
2
+ import Logger from "../logger.js";
3
+ import Reference from "./reference.js";
4
+ const logger = new Logger("Scoundrel Client");
5
+ // logger.setDebug(true)
6
+ export default class Client {
7
+ /**
8
+ * Creates a new Scoundrel Client
9
+ *
10
+ * @param {any} backend The backend connection (e.g., WebSocket)
11
+ * @param {{enableServerControl?: boolean}} [options]
12
+ */
13
+ constructor(backend, options = {}) {
14
+ /**
15
+ * Handles an incoming command from the backend
16
+ * @param {object} args
17
+ * @param {string} args.command
18
+ * @param {number} args.command_id
19
+ * @param {any} args.data
20
+ * @param {string} [args.error]
21
+ * @param {string} [args.errorStack]
22
+ */
23
+ this.onCommand = ({ command, command_id: commandID, data, error, errorStack, ...restArgs }) => {
24
+ logger.log(() => ["onCommand", { command, commandID, data, error, errorStack, restArgs }]);
25
+ try {
26
+ if (!command) {
27
+ throw new Error(`No command key given in data: ${Object.keys(restArgs).join(", ")}`);
28
+ }
29
+ else if (command == "command_response") {
30
+ if (!(commandID in this.outgoingCommands)) {
31
+ throw new Error(`Outgoing command ${commandID} not found: ${Object.keys(this.outgoingCommands).join(", ")}`);
32
+ }
33
+ const savedCommand = this.outgoingCommands[commandID];
34
+ delete this.outgoingCommands[commandID];
35
+ if (error) {
36
+ const errorToThrow = new Error(error);
37
+ if (errorStack) {
38
+ errorToThrow.stack = `${errorStack}\n\n${errorToThrow.stack}`;
39
+ }
40
+ savedCommand.reject(errorToThrow);
41
+ }
42
+ else {
43
+ logger.log(() => [`Resolving command ${commandID} with data`, data]);
44
+ savedCommand.resolve(data.data);
45
+ }
46
+ }
47
+ else if (!this.serverControlEnabled) {
48
+ this.send({ command: "command_response", command_id: commandID, error: "Server control is disabled" });
49
+ return;
50
+ }
51
+ else if (command == "get_object") {
52
+ const serverObject = this._getRegisteredObject(data.object_name);
53
+ let object;
54
+ if (serverObject) {
55
+ object = serverObject;
56
+ }
57
+ else {
58
+ object = globalThis[data.object_name];
59
+ if (!object)
60
+ throw new Error(`No such object: ${data.object_name}`);
61
+ }
62
+ const objectId = ++this.objectsCount;
63
+ this.objects[objectId] = object;
64
+ this.respondToCommand(commandID, { object_id: objectId });
65
+ }
66
+ else if (command == "new_object_with_reference") {
67
+ const className = data.class_name;
68
+ let object;
69
+ if (typeof className == "string") {
70
+ const ClassInstance = this.getClass(className) || globalThis[className];
71
+ if (!ClassInstance)
72
+ throw new Error(`No such class: ${className}`);
73
+ object = new ClassInstance(...data.args);
74
+ }
75
+ else {
76
+ throw new Error(`Don't know how to handle class name: ${typeof className}`);
77
+ }
78
+ const objectId = ++this.objectsCount;
79
+ this.objects[objectId] = object;
80
+ this.respondToCommand(commandID, { object_id: objectId });
81
+ }
82
+ else if (command == "call_method_on_reference") {
83
+ const referenceId = data.reference_id;
84
+ const object = this.objects[referenceId];
85
+ if (!object)
86
+ throw new Error(`No object by that ID: ${referenceId}`);
87
+ const method = object[data.method_name];
88
+ if (!method)
89
+ throw new Error(`No method called '${data.method_name}' on a '${object.constructor.name}'`);
90
+ const response = method.call(object, ...data.args);
91
+ if (data.with == "reference") {
92
+ const objectId = ++this.objectsCount;
93
+ this.objects[objectId] = response;
94
+ this.respondToCommand(commandID, { response: objectId });
95
+ }
96
+ else {
97
+ this.respondToCommand(commandID, { response });
98
+ }
99
+ }
100
+ else if (command == "serialize_reference") {
101
+ const referenceId = data.reference_id;
102
+ const object = this.objects[referenceId];
103
+ if (!object)
104
+ throw new Error(`No object by that ID: ${referenceId}`);
105
+ this.respondToCommand(commandID, JSON.stringify(object));
106
+ }
107
+ else if (command == "read_attribute") {
108
+ const attributeName = data.attribute_name;
109
+ const referenceId = data.reference_id;
110
+ const returnWith = data.with;
111
+ const object = this.objects[referenceId];
112
+ if (!object)
113
+ throw new Error(`No object by that ID: ${referenceId}`);
114
+ const attribute = object[attributeName];
115
+ if (returnWith == "reference") {
116
+ const objectId = ++this.objectsCount;
117
+ this.objects[objectId] = attribute;
118
+ this.respondToCommand(commandID, { response: objectId });
119
+ }
120
+ else {
121
+ this.respondToCommand(commandID, { response: attribute });
122
+ }
123
+ }
124
+ else if (command == "eval") {
125
+ const respondWithResult = (evalResult) => {
126
+ if (data.with_reference) {
127
+ const objectId = ++this.objectsCount;
128
+ this.objects[objectId] = evalResult;
129
+ this.respondToCommand(commandID, { object_id: objectId });
130
+ }
131
+ else {
132
+ this.respondToCommand(commandID, { response: evalResult });
133
+ }
134
+ };
135
+ const evalResult = eval(data.eval_string);
136
+ if (evalResult && typeof evalResult.then == "function") {
137
+ evalResult.then(respondWithResult).catch((promiseError) => {
138
+ if (promiseError instanceof Error) {
139
+ this.send({ command: "command_response", command_id: commandID, error: promiseError.message, errorStack: promiseError.stack });
140
+ }
141
+ else {
142
+ this.send({ command: "command_response", command_id: commandID, error: String(promiseError) });
143
+ }
144
+ });
145
+ }
146
+ else {
147
+ respondWithResult(evalResult);
148
+ }
149
+ }
150
+ else {
151
+ throw new Error(`Unknown command: ${command}`);
152
+ }
153
+ }
154
+ catch (error) {
155
+ if (error instanceof Error) {
156
+ this.send({ command: "command_response", command_id: commandID, error: error.message, errorStack: error.stack });
157
+ }
158
+ else {
159
+ this.send({ command: "command_response", command_id: commandID, error: String(error) });
160
+ }
161
+ logger.error(error);
162
+ }
163
+ };
164
+ this.backend = backend;
165
+ this.backend.onCommand(this.onCommand);
166
+ /** @type {Record<number, any>} */
167
+ this.outgoingCommands = {};
168
+ this.incomingCommands = {};
169
+ this.outgoingCommandsCount = 0;
170
+ /** @type {Record<string, any>} */
171
+ this._classes = {};
172
+ /** @type {Record<string, any>} */
173
+ this._objects = {};
174
+ /** @type {Record<string, Reference>} */
175
+ this.references = {};
176
+ /** @type {Record<number, any>} */
177
+ this.objects = {};
178
+ this.objectsCount = 0;
179
+ /** @type {boolean} */
180
+ this.serverControlEnabled = Boolean(options.enableServerControl);
181
+ }
182
+ /**
183
+ * Closes the client connection
184
+ */
185
+ async close() {
186
+ this.backend.close();
187
+ }
188
+ /**
189
+ * Calls a method on a reference and returns the result directly
190
+ *
191
+ * @param {number} referenceId
192
+ * @param {string} methodName
193
+ * @param {...any} args
194
+ * @returns {Promise<any>}
195
+ */
196
+ async callMethodOnReference(referenceId, methodName, ...args) {
197
+ const result = await this.sendCommand("call_method_on_reference", {
198
+ args: this.parseArg(args),
199
+ method_name: methodName,
200
+ reference_id: referenceId,
201
+ with: "result"
202
+ });
203
+ return result.response;
204
+ }
205
+ /**
206
+ * Calls a method on a reference and returns a new reference
207
+ *
208
+ * @param {number} referenceId
209
+ * @param {string} methodName
210
+ * @param {...any} args
211
+ * @returns {Promise<Reference>}
212
+ */
213
+ async callMethodOnReferenceWithReference(referenceId, methodName, ...args) {
214
+ const result = await this.sendCommand("call_method_on_reference", {
215
+ args: this.parseArg(args),
216
+ method_name: methodName,
217
+ reference_id: referenceId,
218
+ with: "reference"
219
+ });
220
+ const id = result.response;
221
+ return this.spawnReference(id);
222
+ }
223
+ /**
224
+ * Evaluates a string and returns a new reference
225
+ *
226
+ * @param {string} evalString
227
+ * @returns {Promise<Reference>}
228
+ */
229
+ async evalWithReference(evalString) {
230
+ const evalReference = await this.getObject("eval");
231
+ return await evalReference.callMethodWithReference("call", null, evalString);
232
+ }
233
+ /**
234
+ * Imports a module and returns a reference to it
235
+ *
236
+ * @param {string} importName
237
+ * @returns {Promise<Reference>}
238
+ */
239
+ async import(importName) {
240
+ const result = await this.sendCommand("import", {
241
+ import_name: importName
242
+ });
243
+ logger.log(() => ["import", { result }]);
244
+ if (!result)
245
+ throw new Error("No result given");
246
+ if (!result.object_id)
247
+ throw new Error(`No object ID given in result: ${JSON.stringify(result)}`);
248
+ const id = result.object_id;
249
+ return this.spawnReference(id);
250
+ }
251
+ /**
252
+ * Gets a registered object by name
253
+ *
254
+ * @param {string} objectName
255
+ * @returns {Promise<Reference>}
256
+ */
257
+ async getObject(objectName) {
258
+ const result = await this.sendCommand("get_object", {
259
+ object_name: objectName
260
+ });
261
+ if (!result)
262
+ throw new Error("Blank result given");
263
+ const id = result.object_id;
264
+ return this.spawnReference(id);
265
+ }
266
+ /**
267
+ * Spawns a new reference to an object
268
+ *
269
+ * @param {string} className
270
+ * @param {...any} args
271
+ * @returns {Promise<Reference>}
272
+ */
273
+ async newObjectWithReference(className, ...args) {
274
+ const result = await this.sendCommand("new_object_with_reference", {
275
+ args: this.parseArg(args),
276
+ class_name: className
277
+ });
278
+ if (!result)
279
+ throw new Error("Blank result given");
280
+ const id = result.object_id;
281
+ if (!id)
282
+ throw new Error(`No object ID given in result: ${JSON.stringify(result)}`);
283
+ return this.spawnReference(id);
284
+ }
285
+ /**
286
+ * Checks if the input is a plain object
287
+ * @param {any} input
288
+ * @returns {boolean}
289
+ */
290
+ isPlainObject(input) {
291
+ if (input && typeof input === "object" && !Array.isArray(input)) {
292
+ return true;
293
+ }
294
+ return false;
295
+ }
296
+ /**
297
+ * Parases an argument for sending to the server
298
+ *
299
+ * @param {any} arg
300
+ * @returns {any}
301
+ */
302
+ parseArg(arg) {
303
+ if (Array.isArray(arg)) {
304
+ return arg.map((argInArray) => this.parseArg(argInArray));
305
+ }
306
+ else if (arg instanceof Reference) {
307
+ return {
308
+ __scoundrel_object_id: arg.id,
309
+ __scoundrel_type: "reference"
310
+ };
311
+ }
312
+ else if (this.isPlainObject(arg)) {
313
+ /** @type {Record<any, any>} */
314
+ const newObject = {};
315
+ for (const key in arg) {
316
+ const value = arg[key];
317
+ newObject[key] = this.parseArg(value);
318
+ }
319
+ return newObject;
320
+ }
321
+ return arg;
322
+ }
323
+ /**
324
+ * Reads an attribute on a reference and returns a new reference
325
+ *
326
+ * @param {number} referenceId
327
+ * @param {string} attributeName
328
+ * @returns {Promise<Reference>}
329
+ */
330
+ async readAttributeOnReferenceWithReference(referenceId, attributeName) {
331
+ const result = await this.sendCommand("read_attribute", {
332
+ attribute_name: attributeName,
333
+ reference_id: referenceId,
334
+ with: "reference"
335
+ });
336
+ const id = result.response;
337
+ return this.spawnReference(id);
338
+ }
339
+ /**
340
+ * Reads an attribute on a reference and returns the result directly
341
+ *
342
+ * @param {number} referenceId
343
+ * @param {string} attributeName
344
+ * @returns {Promise<any>}
345
+ */
346
+ async readAttributeOnReference(referenceId, attributeName) {
347
+ const result = await this.sendCommand("read_attribute", {
348
+ attribute_name: attributeName,
349
+ reference_id: referenceId,
350
+ with: "result"
351
+ });
352
+ return result.response;
353
+ }
354
+ /**
355
+ * Registers a class by name
356
+ *
357
+ * @param {string} className
358
+ * @param {any} classInstance
359
+ */
360
+ registerClass(className, classInstance) {
361
+ if (className in this._classes)
362
+ throw new Error(`Class already exists: ${className}`);
363
+ this._classes[className] = classInstance;
364
+ }
365
+ /**
366
+ * Gets a registered class by name
367
+ *
368
+ * @param {string} className
369
+ * @returns {any}
370
+ */
371
+ getClass(className) {
372
+ return this._classes[className];
373
+ }
374
+ /**
375
+ * Registers an object by name
376
+ *
377
+ * @param {string} objectName
378
+ * @param {any} objectInstance
379
+ */
380
+ registerObject(objectName, objectInstance) {
381
+ if (objectName in this._objects)
382
+ throw new Error(`Object already exists: ${objectName}`);
383
+ this._objects[objectName] = objectInstance;
384
+ }
385
+ /**
386
+ * Gets a registered object by name
387
+ *
388
+ * @param {string} objectName
389
+ * @returns {any}
390
+ */
391
+ _getRegisteredObject(objectName) {
392
+ return this._objects[objectName];
393
+ }
394
+ /**
395
+ * Responds to a command from the backend
396
+ * @param {number} commandId
397
+ * @param {any} data
398
+ */
399
+ respondToCommand(commandId, data) {
400
+ this.sendCommand("command_response", { command_id: commandId, data });
401
+ }
402
+ /**
403
+ * Sends a command to the backend and returns a promise that resolves with the response
404
+ * @param {string} command
405
+ * @param {any} data
406
+ * @returns {Promise<any>}
407
+ */
408
+ sendCommand(command, data) {
409
+ return new Promise((resolve, reject) => {
410
+ const outgoingCommandCount = ++this.outgoingCommandsCount;
411
+ const commandData = {
412
+ command,
413
+ command_id: outgoingCommandCount,
414
+ data
415
+ };
416
+ this.outgoingCommands[outgoingCommandCount] = { resolve, reject };
417
+ logger.log(() => ["Sending", commandData]);
418
+ this.send(commandData);
419
+ });
420
+ }
421
+ /**
422
+ * Sends data to the backend
423
+ * @param {any} data
424
+ */
425
+ send(data) {
426
+ this.backend.send(data);
427
+ }
428
+ /**
429
+ * Serializes a reference and returns the result directly
430
+ *
431
+ * @param {number} referenceId
432
+ * @returns {Promise<any>}
433
+ */
434
+ async serializeReference(referenceId) {
435
+ const json = await this.sendCommand("serialize_reference", { reference_id: referenceId });
436
+ return JSON.parse(json);
437
+ }
438
+ /**
439
+ * Spawns a new reference to an object
440
+ *
441
+ * @param {string} id
442
+ * @returns {Reference}
443
+ */
444
+ spawnReference(id) {
445
+ const reference = new Reference(this, id);
446
+ this.references[id] = reference;
447
+ return reference;
448
+ }
449
+ enableServerControl() {
450
+ this.serverControlEnabled = true;
451
+ }
452
+ }
@@ -0,0 +1,7 @@
1
+ export default referenceProxy;
2
+ /**
3
+ * @param {any} wrappedObject
4
+ * @returns {Proxy}
5
+ */
6
+ declare function referenceProxy(wrappedObject: any): ProxyConstructor;
7
+ //# sourceMappingURL=reference-proxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference-proxy.d.ts","sourceRoot":"","sources":["../../src/client/reference-proxy.js"],"names":[],"mappings":";AAyCA;;;GAGG;AACH,+CAHW,GAAG,oBAGwE"}
@@ -0,0 +1,41 @@
1
+ // @ts-check
2
+ /**
3
+ * @param {import("./reference.js").default} reference
4
+ * @param {string} prop
5
+ * @returns {(...args: any[]) => Promise<any>}
6
+ */
7
+ const proxyMethodSpawner = (reference, prop) => (...args) => reference.callMethodWithReference(prop, ...args);
8
+ const proxyObjectHandler = {
9
+ /**
10
+ * @param {import("./reference.js").default|(() => import("./reference.js").default)} reference
11
+ * @param {string} prop
12
+ * @returns {any}
13
+ */
14
+ get(reference, prop) {
15
+ if (typeof reference == "function")
16
+ reference = reference();
17
+ if (prop == "__serialize") {
18
+ const method = reference.serialize;
19
+ const boundMethod = method.bind(reference);
20
+ return boundMethod;
21
+ }
22
+ return proxyMethodSpawner(reference, prop);
23
+ },
24
+ /**
25
+ * @param {import("./reference.js").default|(() => import("./reference.js").default)} receiver
26
+ * @param {string} prop
27
+ * @param {any} newValue
28
+ */
29
+ set(receiver, prop, newValue) {
30
+ void receiver;
31
+ void prop;
32
+ void newValue;
33
+ throw new Error("set property isn't supported yet");
34
+ }
35
+ };
36
+ /**
37
+ * @param {any} wrappedObject
38
+ * @returns {Proxy}
39
+ */
40
+ const referenceProxy = (wrappedObject) => new Proxy(wrappedObject, proxyObjectHandler);
41
+ export default referenceProxy;
@@ -0,0 +1,50 @@
1
+ export default class Reference {
2
+ /**
3
+ * Creates a new Reference
4
+ *
5
+ * @param {any} client The client instance
6
+ * @param {string} id The reference ID
7
+ */
8
+ constructor(client: any, id: string);
9
+ client: any;
10
+ id: string;
11
+ /**
12
+ * Calls a method on the reference
13
+ *
14
+ * @param {string} methodName
15
+ * @param {...any} args
16
+ * @returns {Promise<any>}
17
+ */
18
+ callMethod(methodName: string, ...args: any[]): Promise<any>;
19
+ /**
20
+ * Calls a method on the reference using another reference as argument
21
+ *
22
+ * @param {string} methodName
23
+ * @param {...any} args
24
+ * @returns {Promise<any>}
25
+ */
26
+ callMethodWithReference(methodName: string, ...args: any[]): Promise<any>;
27
+ /**
28
+ * Reads an attribute from the reference
29
+ *
30
+ * @param {string} attributeName
31
+ * @param {...any} args
32
+ * @returns {Promise<any>}
33
+ */
34
+ readAttribute(attributeName: string, ...args: any[]): Promise<any>;
35
+ /**
36
+ * Reads an attribute from the reference using another reference as argument
37
+ *
38
+ * @param {string} attributeName
39
+ * @param {...any} args
40
+ * @returns {Promise<any>}
41
+ */
42
+ readAttributeWithReference(attributeName: string, ...args: any[]): Promise<any>;
43
+ /**
44
+ * Serializes the reference and returns the result directly
45
+ *
46
+ * @returns {Promise<any>}
47
+ */
48
+ serialize(): Promise<any>;
49
+ }
50
+ //# sourceMappingURL=reference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../src/client/reference.js"],"names":[],"mappings":"AAEA;IACE;;;;;OAKG;IACH,oBAHW,GAAG,MACH,MAAM,EAOhB;IAJC,YAAoB;IACpB,WAAY;IAKd;;;;;;OAMG;IACH,uBAJW,MAAM,WACF,GAAG,EAAA,GACL,OAAO,CAAC,GAAG,CAAC,CAIxB;IAED;;;;;;OAMG;IACH,oCAJW,MAAM,WACF,GAAG,EAAA,GACL,OAAO,CAAC,GAAG,CAAC,CAIxB;IAED;;;;;;OAMG;IACH,6BAJW,MAAM,WACF,GAAG,EAAA,GACL,OAAO,CAAC,GAAG,CAAC,CAIxB;IAED;;;;;;OAMG;IACH,0CAJW,MAAM,WACF,GAAG,EAAA,GACL,OAAO,CAAC,GAAG,CAAC,CAIxB;IAED;;;;OAIG;IACH,aAFa,OAAO,CAAC,GAAG,CAAC,CAIxB;CACF"}
@@ -0,0 +1,63 @@
1
+ // @ts-check
2
+ export default class Reference {
3
+ /**
4
+ * Creates a new Reference
5
+ *
6
+ * @param {any} client The client instance
7
+ * @param {string} id The reference ID
8
+ */
9
+ constructor(client, id) {
10
+ this.client = client;
11
+ this.id = id;
12
+ if (!id)
13
+ throw new Error(`Invalid ID given: ${id}`);
14
+ }
15
+ /**
16
+ * Calls a method on the reference
17
+ *
18
+ * @param {string} methodName
19
+ * @param {...any} args
20
+ * @returns {Promise<any>}
21
+ */
22
+ async callMethod(methodName, ...args) {
23
+ return await this.client.callMethodOnReference(this.id, methodName, ...args);
24
+ }
25
+ /**
26
+ * Calls a method on the reference using another reference as argument
27
+ *
28
+ * @param {string} methodName
29
+ * @param {...any} args
30
+ * @returns {Promise<any>}
31
+ */
32
+ async callMethodWithReference(methodName, ...args) {
33
+ return await this.client.callMethodOnReferenceWithReference(this.id, methodName, ...args);
34
+ }
35
+ /**
36
+ * Reads an attribute from the reference
37
+ *
38
+ * @param {string} attributeName
39
+ * @param {...any} args
40
+ * @returns {Promise<any>}
41
+ */
42
+ async readAttribute(attributeName, ...args) {
43
+ return await this.client.readAttributeOnReference(this.id, attributeName, ...args);
44
+ }
45
+ /**
46
+ * Reads an attribute from the reference using another reference as argument
47
+ *
48
+ * @param {string} attributeName
49
+ * @param {...any} args
50
+ * @returns {Promise<any>}
51
+ */
52
+ async readAttributeWithReference(attributeName, ...args) {
53
+ return await this.client.readAttributeOnReferenceWithReference(this.id, attributeName, ...args);
54
+ }
55
+ /**
56
+ * Serializes the reference and returns the result directly
57
+ *
58
+ * @returns {Promise<any>}
59
+ */
60
+ async serialize() {
61
+ return await this.client.serializeReference(this.id);
62
+ }
63
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":""}
package/build/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,39 @@
1
+ export default class Logger {
2
+ /**
3
+ * Creates a new Logger instance
4
+ *
5
+ * @param {string} scopeName The name of the scope for the logger
6
+ */
7
+ constructor(scopeName: string);
8
+ debug: boolean;
9
+ scopeName: string;
10
+ /**
11
+ * Enables or disables debug logging
12
+ *
13
+ * @param {boolean} newValue
14
+ */
15
+ setDebug(newValue: boolean): void;
16
+ /**
17
+ * Logs an error message to the console if debug is enabled
18
+ *
19
+ * @param {...any} args
20
+ */
21
+ error(...args: any[]): void;
22
+ /**
23
+ * Logs a message to the console if debug is enabled
24
+ * @param {...any} args
25
+ */
26
+ log(...args: any[]): void;
27
+ /**
28
+ * Logs a warning message to the console if debug is enabled
29
+ * @param {...any} args
30
+ */
31
+ warn(...args: any[]): void;
32
+ /**
33
+ * Sends the log message to the console
34
+ * @param {string} logType
35
+ * @param {...any} args
36
+ */
37
+ _sendToConsole(logType: string, ...args: any[]): void;
38
+ }
39
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.js"],"names":[],"mappings":"AAEA;IACE;;;;OAIG;IACH,uBAFW,MAAM,EAKhB;IAFC,eAAkB;IAClB,kBAA0B;IAG5B;;;;OAIG;IACH,mBAFW,OAAO,QAIjB;IAED;;;;OAIG;IACH,eAFe,GAAG,EAAA,QAIjB;IAED;;;OAGG;IACH,aAFe,GAAG,EAAA,QAIjB;IAED;;;OAGG;IACH,cAFe,GAAG,EAAA,QAIjB;IAED;;;;OAIG;IACH,wBAHW,MAAM,WACF,GAAG,EAAA,QAkBjB;CACF"}