@hcikn/colibri 1.1.1 → 1.3.2
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/README.md +29 -3
- package/dist/index.cjs +607 -152
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -35
- package/dist/index.d.ts +121 -35
- package/dist/index.js +574 -128
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -7,6 +7,45 @@ function _array_like_to_array(arr, len) {
|
|
|
7
7
|
function _array_without_holes(arr) {
|
|
8
8
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
9
9
|
}
|
|
10
|
+
function _assert_this_initialized(self) {
|
|
11
|
+
if (self === void 0) {
|
|
12
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
13
|
+
}
|
|
14
|
+
return self;
|
|
15
|
+
}
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
|
+
try {
|
|
18
|
+
var info = gen[key](arg);
|
|
19
|
+
var value = info.value;
|
|
20
|
+
} catch (error) {
|
|
21
|
+
reject(error);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (info.done) {
|
|
25
|
+
resolve(value);
|
|
26
|
+
} else {
|
|
27
|
+
Promise.resolve(value).then(_next, _throw);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function _async_to_generator(fn) {
|
|
31
|
+
return function() {
|
|
32
|
+
var self = this, args = arguments;
|
|
33
|
+
return new Promise(function(resolve, reject) {
|
|
34
|
+
var gen = fn.apply(self, args);
|
|
35
|
+
function _next(value) {
|
|
36
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
37
|
+
}
|
|
38
|
+
function _throw(err) {
|
|
39
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
40
|
+
}
|
|
41
|
+
_next(undefined);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
function _call_super(_this, derived, args) {
|
|
46
|
+
derived = _get_prototype_of(derived);
|
|
47
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
48
|
+
}
|
|
10
49
|
function _class_call_check(instance, Constructor) {
|
|
11
50
|
if (!(instance instanceof Constructor)) {
|
|
12
51
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -26,7 +65,27 @@ function _create_class(Constructor, protoProps, staticProps) {
|
|
|
26
65
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
27
66
|
return Constructor;
|
|
28
67
|
}
|
|
68
|
+
function _get_prototype_of(o) {
|
|
69
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
70
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
71
|
+
};
|
|
72
|
+
return _get_prototype_of(o);
|
|
73
|
+
}
|
|
74
|
+
function _inherits(subClass, superClass) {
|
|
75
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
76
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
77
|
+
}
|
|
78
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
79
|
+
constructor: {
|
|
80
|
+
value: subClass,
|
|
81
|
+
writable: true,
|
|
82
|
+
configurable: true
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
if (superClass) _set_prototype_of(subClass, superClass);
|
|
86
|
+
}
|
|
29
87
|
function _instanceof(left, right) {
|
|
88
|
+
"@swc/helpers - instanceof";
|
|
30
89
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
31
90
|
return !!right[Symbol.hasInstance](left);
|
|
32
91
|
} else {
|
|
@@ -39,9 +98,26 @@ function _iterable_to_array(iter) {
|
|
|
39
98
|
function _non_iterable_spread() {
|
|
40
99
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
41
100
|
}
|
|
101
|
+
function _possible_constructor_return(self, call) {
|
|
102
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
103
|
+
return call;
|
|
104
|
+
}
|
|
105
|
+
return _assert_this_initialized(self);
|
|
106
|
+
}
|
|
107
|
+
function _set_prototype_of(o, p) {
|
|
108
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
109
|
+
o.__proto__ = p;
|
|
110
|
+
return o;
|
|
111
|
+
};
|
|
112
|
+
return _set_prototype_of(o, p);
|
|
113
|
+
}
|
|
42
114
|
function _to_consumable_array(arr) {
|
|
43
115
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
44
116
|
}
|
|
117
|
+
function _type_of(obj) {
|
|
118
|
+
"@swc/helpers - typeof";
|
|
119
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
120
|
+
}
|
|
45
121
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
46
122
|
if (!o) return;
|
|
47
123
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -50,26 +126,131 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
50
126
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
51
127
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
52
128
|
}
|
|
53
|
-
|
|
129
|
+
function _is_native_reflect_construct() {
|
|
130
|
+
try {
|
|
131
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
132
|
+
} catch (_) {}
|
|
133
|
+
return (_is_native_reflect_construct = function() {
|
|
134
|
+
return !!result;
|
|
135
|
+
})();
|
|
136
|
+
}
|
|
137
|
+
function _ts_generator(thisArg, body) {
|
|
138
|
+
var f, y, t, _ = {
|
|
139
|
+
label: 0,
|
|
140
|
+
sent: function() {
|
|
141
|
+
if (t[0] & 1) throw t[1];
|
|
142
|
+
return t[1];
|
|
143
|
+
},
|
|
144
|
+
trys: [],
|
|
145
|
+
ops: []
|
|
146
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
147
|
+
return d(g, "next", {
|
|
148
|
+
value: verb(0)
|
|
149
|
+
}), d(g, "throw", {
|
|
150
|
+
value: verb(1)
|
|
151
|
+
}), d(g, "return", {
|
|
152
|
+
value: verb(2)
|
|
153
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
154
|
+
value: function() {
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
}), g;
|
|
158
|
+
function verb(n) {
|
|
159
|
+
return function(v) {
|
|
160
|
+
return step([
|
|
161
|
+
n,
|
|
162
|
+
v
|
|
163
|
+
]);
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function step(op) {
|
|
167
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
168
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
169
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
170
|
+
if (y = 0, t) op = [
|
|
171
|
+
op[0] & 2,
|
|
172
|
+
t.value
|
|
173
|
+
];
|
|
174
|
+
switch(op[0]){
|
|
175
|
+
case 0:
|
|
176
|
+
case 1:
|
|
177
|
+
t = op;
|
|
178
|
+
break;
|
|
179
|
+
case 4:
|
|
180
|
+
_.label++;
|
|
181
|
+
return {
|
|
182
|
+
value: op[1],
|
|
183
|
+
done: false
|
|
184
|
+
};
|
|
185
|
+
case 5:
|
|
186
|
+
_.label++;
|
|
187
|
+
y = op[1];
|
|
188
|
+
op = [
|
|
189
|
+
0
|
|
190
|
+
];
|
|
191
|
+
continue;
|
|
192
|
+
case 7:
|
|
193
|
+
op = _.ops.pop();
|
|
194
|
+
_.trys.pop();
|
|
195
|
+
continue;
|
|
196
|
+
default:
|
|
197
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
198
|
+
_ = 0;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
202
|
+
_.label = op[1];
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
206
|
+
_.label = t[1];
|
|
207
|
+
t = op;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
if (t && _.label < t[2]) {
|
|
211
|
+
_.label = t[2];
|
|
212
|
+
_.ops.push(op);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
if (t[2]) _.ops.pop();
|
|
216
|
+
_.trys.pop();
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
op = body.call(thisArg, _);
|
|
220
|
+
} catch (e) {
|
|
221
|
+
op = [
|
|
222
|
+
6,
|
|
223
|
+
e
|
|
224
|
+
];
|
|
225
|
+
y = 0;
|
|
226
|
+
} finally{
|
|
227
|
+
f = t = 0;
|
|
228
|
+
}
|
|
229
|
+
if (op[0] & 5) throw op[1];
|
|
230
|
+
return {
|
|
231
|
+
value: op[0] ? op[1] : void 0,
|
|
232
|
+
done: true
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
54
236
|
var __defProp = Object.defineProperty;
|
|
55
237
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
56
238
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
57
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
58
239
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
59
|
-
var __export = function(target, all) {
|
|
240
|
+
var __export = function __export(target, all) {
|
|
60
241
|
for(var name in all)__defProp(target, name, {
|
|
61
242
|
get: all[name],
|
|
62
243
|
enumerable: true
|
|
63
244
|
});
|
|
64
245
|
};
|
|
65
|
-
var __copyProps = function(to, from, except, desc) {
|
|
66
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
246
|
+
var __copyProps = function __copyProps(to, from, except, desc) {
|
|
247
|
+
if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
|
|
67
248
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
68
249
|
try {
|
|
69
250
|
var _loop = function() {
|
|
70
251
|
var key = _step.value;
|
|
71
252
|
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
72
|
-
get: function() {
|
|
253
|
+
get: function get() {
|
|
73
254
|
return from[key];
|
|
74
255
|
},
|
|
75
256
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
@@ -93,17 +274,7 @@ var __copyProps = function(to, from, except, desc) {
|
|
|
93
274
|
}
|
|
94
275
|
return to;
|
|
95
276
|
};
|
|
96
|
-
var
|
|
97
|
-
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
98
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
99
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
100
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
101
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
102
|
-
value: mod,
|
|
103
|
-
enumerable: true
|
|
104
|
-
}) : target, mod);
|
|
105
|
-
};
|
|
106
|
-
var __toCommonJS = function(mod) {
|
|
277
|
+
var __toCommonJS = function __toCommonJS(mod) {
|
|
107
278
|
return __copyProps(__defProp({}, "__esModule", {
|
|
108
279
|
value: true
|
|
109
280
|
}), mod);
|
|
@@ -111,118 +282,352 @@ var __toCommonJS = function(mod) {
|
|
|
111
282
|
// src/index.ts
|
|
112
283
|
var src_exports = {};
|
|
113
284
|
__export(src_exports, {
|
|
114
|
-
Colibri: function() {
|
|
285
|
+
Colibri: function Colibri1() {
|
|
115
286
|
return Colibri;
|
|
116
287
|
},
|
|
117
|
-
|
|
288
|
+
GetRestApi: function GetRestApi1() {
|
|
289
|
+
return GetRestApi;
|
|
290
|
+
},
|
|
291
|
+
PutRestApi: function PutRestApi1() {
|
|
292
|
+
return PutRestApi;
|
|
293
|
+
},
|
|
294
|
+
RegisterChannel: function RegisterChannel1() {
|
|
295
|
+
return RegisterChannel;
|
|
296
|
+
},
|
|
297
|
+
RegisterModelSync: function RegisterModelSync1() {
|
|
118
298
|
return RegisterModelSync;
|
|
119
299
|
},
|
|
120
|
-
|
|
300
|
+
RegisterOnce: function RegisterOnce1() {
|
|
301
|
+
return RegisterOnce;
|
|
302
|
+
},
|
|
303
|
+
RemoteLogger: function RemoteLogger1() {
|
|
121
304
|
return RemoteLogger;
|
|
122
305
|
},
|
|
123
|
-
|
|
306
|
+
SendMessage: function SendMessage1() {
|
|
307
|
+
return SendMessage;
|
|
308
|
+
},
|
|
309
|
+
Sync: function Sync1() {
|
|
124
310
|
return Sync;
|
|
125
311
|
},
|
|
126
|
-
SyncModel: function() {
|
|
312
|
+
SyncModel: function SyncModel1() {
|
|
127
313
|
return SyncModel;
|
|
128
314
|
},
|
|
129
|
-
Synced: function() {
|
|
315
|
+
Synced: function Synced1() {
|
|
130
316
|
return Synced;
|
|
317
|
+
},
|
|
318
|
+
UnregisterChannel: function UnregisterChannel1() {
|
|
319
|
+
return UnregisterChannel;
|
|
131
320
|
}
|
|
132
321
|
});
|
|
133
322
|
module.exports = __toCommonJS(src_exports);
|
|
134
|
-
// src/
|
|
135
|
-
var
|
|
136
|
-
|
|
137
|
-
var
|
|
138
|
-
var
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
});
|
|
146
|
-
var init = function(app, server, port) {
|
|
147
|
-
server !== null && server !== void 0 ? server : server = location;
|
|
148
|
-
port !== null && port !== void 0 ? port : port = 9011;
|
|
149
|
-
if (!server.startsWith("http")) {
|
|
150
|
-
server = "http://" + server;
|
|
323
|
+
// src/Colibri.ts
|
|
324
|
+
var import_socket = require("socket.io-client");
|
|
325
|
+
// src/ColibriError.ts
|
|
326
|
+
var import_ts_custom_error = require("ts-custom-error");
|
|
327
|
+
var ColibriError = /*#__PURE__*/ function(_import_ts_custom_error_CustomError) {
|
|
328
|
+
_inherits(ColibriError, _import_ts_custom_error_CustomError);
|
|
329
|
+
function ColibriError(message) {
|
|
330
|
+
_class_call_check(this, ColibriError);
|
|
331
|
+
return _call_super(this, ColibriError, [
|
|
332
|
+
message
|
|
333
|
+
]);
|
|
151
334
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
335
|
+
return ColibriError;
|
|
336
|
+
}(import_ts_custom_error.CustomError);
|
|
337
|
+
// src/Colibri.ts
|
|
338
|
+
var import_rxjs = require("rxjs");
|
|
339
|
+
var _Colibri = /*#__PURE__*/ function() {
|
|
340
|
+
function _Colibri(app) {
|
|
341
|
+
var server = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function() {
|
|
342
|
+
var _ref;
|
|
343
|
+
var _window_location, _window;
|
|
344
|
+
return (_ref = (_window = window) === null || _window === void 0 ? void 0 : (_window_location = _window.location) === null || _window_location === void 0 ? void 0 : _window_location.hostname) !== null && _ref !== void 0 ? _ref : "";
|
|
345
|
+
}(), port = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 9011;
|
|
346
|
+
_class_call_check(this, _Colibri);
|
|
347
|
+
this.app = app;
|
|
348
|
+
this.server = server;
|
|
349
|
+
this.port = port;
|
|
350
|
+
this.messageSubject = new import_rxjs.Subject();
|
|
351
|
+
this.messages = this.messageSubject.asObservable();
|
|
352
|
+
if (server.trim().length <= 0) {
|
|
353
|
+
throw new ColibriError("Server Address missing or empty!");
|
|
354
|
+
}
|
|
355
|
+
if (port < 1 || port > 65535) {
|
|
356
|
+
throw new ColibriError("Port out of allowed range (0 - 65535)");
|
|
357
|
+
}
|
|
358
|
+
this.uri = "".concat(server, ":").concat(port);
|
|
359
|
+
if (!new RegExp("wss?://", "i").test(this.uri)) {
|
|
360
|
+
this.uri = "ws://".concat(this.uri);
|
|
361
|
+
}
|
|
362
|
+
this.uriRestApi = "".concat(this.uri, "/api/store/").concat(app, "/");
|
|
363
|
+
if (_Colibri.instance) throw new ColibriError("A Colibri instance already exists!");
|
|
364
|
+
else _Colibri.instance = this;
|
|
365
|
+
this.socket = (0, import_socket.connect)(this.uri, {
|
|
366
|
+
query: {
|
|
367
|
+
app: app,
|
|
368
|
+
version: "1"
|
|
369
|
+
},
|
|
370
|
+
transports: [
|
|
371
|
+
"websocket"
|
|
372
|
+
]
|
|
168
373
|
});
|
|
169
|
-
|
|
374
|
+
this.socket.on("connect", this.onSocketConnect.bind(this));
|
|
375
|
+
this.socket.onAny(this.onSocketAny.bind(this));
|
|
376
|
+
this.registerChannel("colibri", function(msg) {
|
|
377
|
+
if (msg.command === "latency") {
|
|
378
|
+
SendMessage("colibri", "latency", msg.payload);
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
_create_class(_Colibri, [
|
|
383
|
+
{
|
|
384
|
+
key: "onSocketConnect",
|
|
385
|
+
value: function onSocketConnect() {
|
|
386
|
+
console.debug("Connected to colibri server on ".concat(this.server));
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
391
|
+
key: "onSocketAny",
|
|
392
|
+
value: function onSocketAny(channel, msg) {
|
|
393
|
+
this.messageSubject.next({
|
|
394
|
+
channel: channel,
|
|
395
|
+
command: msg.command,
|
|
396
|
+
payload: msg.payload
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
/**
|
|
402
|
+
* Sends a single message in the given `channel`.
|
|
403
|
+
* @param channel message channel
|
|
404
|
+
* @param command message command
|
|
405
|
+
* @param payload message payload
|
|
406
|
+
*/ key: "sendMessage",
|
|
407
|
+
value: function sendMessage(channel, command) {
|
|
408
|
+
var payload = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
409
|
+
this.socket.emit(channel, {
|
|
410
|
+
command: command,
|
|
411
|
+
payload: payload
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
//#region Socket Events
|
|
417
|
+
/**
|
|
418
|
+
* Adds a `handler` function listening for messages in `channel`.
|
|
419
|
+
* @param channel message channel
|
|
420
|
+
* @param handler handler to be executed when a message is received
|
|
421
|
+
*/ key: "registerChannel",
|
|
422
|
+
value: function registerChannel(channel, handler) {
|
|
423
|
+
this.socket.on(channel, handler);
|
|
424
|
+
}
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
/**
|
|
428
|
+
* Removes the `handler` function listening for messages in `channel`.
|
|
429
|
+
* @param channel message channel
|
|
430
|
+
* @param handler handler to be executed when a message is received
|
|
431
|
+
*/ key: "unregisterChannel",
|
|
432
|
+
value: function unregisterChannel(channel, handler) {
|
|
433
|
+
this.socket.off(channel, handler);
|
|
434
|
+
}
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
/**
|
|
438
|
+
* Adds a one-time `handler` function listening for the next message in `channel`.
|
|
439
|
+
* @param channel message channel
|
|
440
|
+
* @param handler handler to be executed when a message is received
|
|
441
|
+
*/ key: "registerOnce",
|
|
442
|
+
value: function registerOnce(channel, handler) {
|
|
443
|
+
this.socket.once(channel, handler);
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region Rest API
|
|
449
|
+
/**
|
|
450
|
+
* Returns the REST API Endpoint for a given `key` or null of the key is empty.
|
|
451
|
+
* @param key REST API storage key
|
|
452
|
+
* @returns
|
|
453
|
+
*/ key: "getRestUri",
|
|
454
|
+
value: function getRestUri(key) {
|
|
455
|
+
key = key.trim();
|
|
456
|
+
while(key.startsWith("/"))key = key.substring(1);
|
|
457
|
+
return key.length === 0 ? null : this.uriRestApi + key;
|
|
458
|
+
}
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
key: "getRestObject",
|
|
462
|
+
value: /**
|
|
463
|
+
* Queries an object from the REST API identified by `key`.
|
|
464
|
+
* @param key REST API storage key
|
|
465
|
+
* @returns JSON object with data or null if object does not exist or any other error occurrs
|
|
466
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
467
|
+
function getRestObject(key) {
|
|
468
|
+
return _async_to_generator(function() {
|
|
469
|
+
var uri, response;
|
|
470
|
+
return _ts_generator(this, function(_state) {
|
|
471
|
+
switch(_state.label){
|
|
472
|
+
case 0:
|
|
473
|
+
uri = this.getRestUri(key);
|
|
474
|
+
if (!uri) return [
|
|
475
|
+
2,
|
|
476
|
+
null
|
|
477
|
+
];
|
|
478
|
+
return [
|
|
479
|
+
4,
|
|
480
|
+
fetch(uri, {
|
|
481
|
+
method: "GET",
|
|
482
|
+
headers: {
|
|
483
|
+
"Content-Type": "application/json"
|
|
484
|
+
}
|
|
485
|
+
})
|
|
486
|
+
];
|
|
487
|
+
case 1:
|
|
488
|
+
response = _state.sent();
|
|
489
|
+
if (response.status >= 400) return [
|
|
490
|
+
2,
|
|
491
|
+
null
|
|
492
|
+
];
|
|
493
|
+
else return [
|
|
494
|
+
2,
|
|
495
|
+
response.json()
|
|
496
|
+
];
|
|
497
|
+
return [
|
|
498
|
+
2
|
|
499
|
+
];
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
}).call(this);
|
|
503
|
+
}
|
|
504
|
+
},
|
|
505
|
+
{
|
|
506
|
+
key: "setRestObject",
|
|
507
|
+
value: /**
|
|
508
|
+
* Sets or updatees an object in the REST API identified by `key`.
|
|
509
|
+
* @param key REST API storage key
|
|
510
|
+
* @param data JSON data to write
|
|
511
|
+
* @returns true if data was written to REST API
|
|
512
|
+
*/ function setRestObject(key, data) {
|
|
513
|
+
return _async_to_generator(function() {
|
|
514
|
+
var uri, response;
|
|
515
|
+
return _ts_generator(this, function(_state) {
|
|
516
|
+
switch(_state.label){
|
|
517
|
+
case 0:
|
|
518
|
+
uri = this.getRestUri(key);
|
|
519
|
+
if (!uri) return [
|
|
520
|
+
2,
|
|
521
|
+
false
|
|
522
|
+
];
|
|
523
|
+
return [
|
|
524
|
+
4,
|
|
525
|
+
fetch(uri, {
|
|
526
|
+
method: "PUT",
|
|
527
|
+
headers: {
|
|
528
|
+
"Content-Type": "application/json"
|
|
529
|
+
},
|
|
530
|
+
body: JSON.stringify(data)
|
|
531
|
+
})
|
|
532
|
+
];
|
|
533
|
+
case 1:
|
|
534
|
+
response = _state.sent();
|
|
535
|
+
return [
|
|
536
|
+
2,
|
|
537
|
+
response.status >= 200 && response.status < 300
|
|
538
|
+
];
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
}).call(this);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
], [
|
|
545
|
+
{
|
|
546
|
+
key: "getInstance",
|
|
547
|
+
value: /**
|
|
548
|
+
* Returns the existing Colibri instance or null if there's none yet
|
|
549
|
+
* @param warnIfNotInitialized true => print Log message if Colibri has not been initialized yet
|
|
550
|
+
* @returns
|
|
551
|
+
*/ function getInstance() {
|
|
552
|
+
var warnIfNotInitialized = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
553
|
+
if (warnIfNotInitialized && !_Colibri.instance) {
|
|
554
|
+
console.warn("Colibri not initialized yet! (Instance is null)");
|
|
555
|
+
}
|
|
556
|
+
return _Colibri.instance;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
]);
|
|
560
|
+
return _Colibri;
|
|
561
|
+
}();
|
|
562
|
+
_Colibri.instance = null;
|
|
563
|
+
var Colibri = _Colibri;
|
|
564
|
+
var SendMessage = function SendMessage(channel, command) {
|
|
565
|
+
var payload = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
566
|
+
var _Colibri_getInstance;
|
|
567
|
+
return (_Colibri_getInstance = Colibri.getInstance()) === null || _Colibri_getInstance === void 0 ? void 0 : _Colibri_getInstance.sendMessage(channel, command, payload);
|
|
170
568
|
};
|
|
171
|
-
var
|
|
172
|
-
|
|
569
|
+
var RegisterChannel = function RegisterChannel(channel, handler) {
|
|
570
|
+
var _Colibri_getInstance;
|
|
571
|
+
return (_Colibri_getInstance = Colibri.getInstance()) === null || _Colibri_getInstance === void 0 ? void 0 : _Colibri_getInstance.registerChannel(channel, handler);
|
|
173
572
|
};
|
|
174
|
-
var
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
573
|
+
var UnregisterChannel = function UnregisterChannel(channel, handler) {
|
|
574
|
+
var _Colibri_getInstance;
|
|
575
|
+
return (_Colibri_getInstance = Colibri.getInstance()) === null || _Colibri_getInstance === void 0 ? void 0 : _Colibri_getInstance.unregisterChannel(channel, handler);
|
|
576
|
+
};
|
|
577
|
+
var RegisterOnce = function RegisterOnce(channel, handler) {
|
|
578
|
+
var _Colibri_getInstance;
|
|
579
|
+
return (_Colibri_getInstance = Colibri.getInstance()) === null || _Colibri_getInstance === void 0 ? void 0 : _Colibri_getInstance.registerOnce(channel, handler);
|
|
180
580
|
};
|
|
181
|
-
var
|
|
182
|
-
|
|
581
|
+
var GetRestApi = function GetRestApi(key) {
|
|
582
|
+
var _Colibri_getInstance;
|
|
583
|
+
return (_Colibri_getInstance = Colibri.getInstance()) === null || _Colibri_getInstance === void 0 ? void 0 : _Colibri_getInstance.getRestObject(key);
|
|
584
|
+
};
|
|
585
|
+
var PutRestApi = function PutRestApi(key, data) {
|
|
586
|
+
var _Colibri_getInstance;
|
|
587
|
+
return (_Colibri_getInstance = Colibri.getInstance()) === null || _Colibri_getInstance === void 0 ? void 0 : _Colibri_getInstance.setRestObject(key, data);
|
|
183
588
|
};
|
|
184
589
|
// src/Broadcasting.ts
|
|
185
|
-
var sendBool = function(channel, val) {
|
|
590
|
+
var sendBool = function sendBool(channel, val) {
|
|
186
591
|
SendMessage(channel, "broadcast::bool", val);
|
|
187
592
|
};
|
|
188
|
-
var sendBoolArray = function(channel, val) {
|
|
593
|
+
var sendBoolArray = function sendBoolArray(channel, val) {
|
|
189
594
|
SendMessage(channel, "broadcast::bool[]", val);
|
|
190
595
|
};
|
|
191
|
-
var sendNumber = function(channel, val) {
|
|
596
|
+
var sendNumber = function sendNumber(channel, val) {
|
|
192
597
|
SendMessage(channel, "broadcast::float", val);
|
|
193
598
|
};
|
|
194
|
-
var sendNumberArray = function(channel, val) {
|
|
599
|
+
var sendNumberArray = function sendNumberArray(channel, val) {
|
|
195
600
|
SendMessage(channel, "broadcast::float[]", val);
|
|
196
601
|
};
|
|
197
|
-
var sendString = function(channel, val) {
|
|
602
|
+
var sendString = function sendString(channel, val) {
|
|
198
603
|
SendMessage(channel, "broadcast::string", val);
|
|
199
604
|
};
|
|
200
|
-
var sendStringArray = function(channel, val) {
|
|
605
|
+
var sendStringArray = function sendStringArray(channel, val) {
|
|
201
606
|
SendMessage(channel, "broadcast::string[]", val);
|
|
202
607
|
};
|
|
203
|
-
var sendVector3 = function(channel, val) {
|
|
608
|
+
var sendVector3 = function sendVector3(channel, val) {
|
|
204
609
|
SendMessage(channel, "broadcast::vector3", val);
|
|
205
610
|
};
|
|
206
|
-
var sendVector3Array = function(channel, val) {
|
|
611
|
+
var sendVector3Array = function sendVector3Array(channel, val) {
|
|
207
612
|
SendMessage(channel, "broadcast::vector3[]", val);
|
|
208
613
|
};
|
|
209
|
-
var sendQuaternion = function(channel, val) {
|
|
614
|
+
var sendQuaternion = function sendQuaternion(channel, val) {
|
|
210
615
|
SendMessage(channel, "broadcast::quaternion", val);
|
|
211
616
|
};
|
|
212
|
-
var sendQuaternionArray = function(channel, val) {
|
|
617
|
+
var sendQuaternionArray = function sendQuaternionArray(channel, val) {
|
|
213
618
|
SendMessage(channel, "broadcast::quaternion[]", val);
|
|
214
619
|
};
|
|
215
|
-
var sendColor = function(channel, val) {
|
|
620
|
+
var sendColor = function sendColor(channel, val) {
|
|
216
621
|
SendMessage(channel, "broadcast::color", val);
|
|
217
622
|
};
|
|
218
|
-
var sendColorArray = function(channel, val) {
|
|
623
|
+
var sendColorArray = function sendColorArray(channel, val) {
|
|
219
624
|
SendMessage(channel, "broadcast::color[]", val);
|
|
220
625
|
};
|
|
221
|
-
var sendJson = function(channel, val) {
|
|
626
|
+
var sendJson = function sendJson(channel, val) {
|
|
222
627
|
SendMessage(channel, "broadcast::json", val);
|
|
223
628
|
};
|
|
224
629
|
var listeners = {};
|
|
225
|
-
var registerListener = function(channel, type, callback) {
|
|
630
|
+
var registerListener = function registerListener(channel, type, callback) {
|
|
226
631
|
if (listeners[channel] === void 0) {
|
|
227
632
|
listeners[channel] = {};
|
|
228
633
|
RegisterChannel(channel, function(msg) {
|
|
@@ -238,46 +643,46 @@ var registerListener = function(channel, type, callback) {
|
|
|
238
643
|
}
|
|
239
644
|
listeners[channel][type].push(callback);
|
|
240
645
|
};
|
|
241
|
-
var receiveBool = function(channel, callback) {
|
|
646
|
+
var receiveBool = function receiveBool(channel, callback) {
|
|
242
647
|
registerListener(channel, "broadcast::bool", callback);
|
|
243
648
|
};
|
|
244
|
-
var receiveBoolArray = function(channel, callback) {
|
|
649
|
+
var receiveBoolArray = function receiveBoolArray(channel, callback) {
|
|
245
650
|
registerListener(channel, "broadcast::bool[]", callback);
|
|
246
651
|
};
|
|
247
|
-
var receiveNumber = function(channel, callback) {
|
|
652
|
+
var receiveNumber = function receiveNumber(channel, callback) {
|
|
248
653
|
registerListener(channel, "broadcast::float", callback);
|
|
249
654
|
};
|
|
250
|
-
var receiveNumberArray = function(channel, callback) {
|
|
655
|
+
var receiveNumberArray = function receiveNumberArray(channel, callback) {
|
|
251
656
|
registerListener(channel, "broadcast::float[]", callback);
|
|
252
657
|
};
|
|
253
|
-
var receiveString = function(channel, callback) {
|
|
658
|
+
var receiveString = function receiveString(channel, callback) {
|
|
254
659
|
registerListener(channel, "broadcast::string", callback);
|
|
255
660
|
};
|
|
256
|
-
var receiveStringArray = function(channel, callback) {
|
|
661
|
+
var receiveStringArray = function receiveStringArray(channel, callback) {
|
|
257
662
|
registerListener(channel, "broadcast::string[]", callback);
|
|
258
663
|
};
|
|
259
|
-
var receiveVector3 = function(channel, callback) {
|
|
664
|
+
var receiveVector3 = function receiveVector3(channel, callback) {
|
|
260
665
|
registerListener(channel, "broadcast::vector3", callback);
|
|
261
666
|
};
|
|
262
|
-
var receiveVector3Array = function(channel, callback) {
|
|
667
|
+
var receiveVector3Array = function receiveVector3Array(channel, callback) {
|
|
263
668
|
registerListener(channel, "broadcast::vector3[]", callback);
|
|
264
669
|
};
|
|
265
|
-
var receiveQuaternion = function(channel, callback) {
|
|
670
|
+
var receiveQuaternion = function receiveQuaternion(channel, callback) {
|
|
266
671
|
registerListener(channel, "broadcast::quaternion", callback);
|
|
267
672
|
};
|
|
268
|
-
var receiveQuaternionArray = function(channel, callback) {
|
|
673
|
+
var receiveQuaternionArray = function receiveQuaternionArray(channel, callback) {
|
|
269
674
|
registerListener(channel, "broadcast::quaternion[]", callback);
|
|
270
675
|
};
|
|
271
|
-
var receiveColor = function(channel, callback) {
|
|
676
|
+
var receiveColor = function receiveColor(channel, callback) {
|
|
272
677
|
registerListener(channel, "broadcast::color", callback);
|
|
273
678
|
};
|
|
274
|
-
var receiveColorArray = function(channel, callback) {
|
|
679
|
+
var receiveColorArray = function receiveColorArray(channel, callback) {
|
|
275
680
|
registerListener(channel, "broadcast::color[]", callback);
|
|
276
681
|
};
|
|
277
|
-
var receiveJson = function(channel, callback) {
|
|
682
|
+
var receiveJson = function receiveJson(channel, callback) {
|
|
278
683
|
registerListener(channel, "broadcast::json", callback);
|
|
279
684
|
};
|
|
280
|
-
var unregister = function(channel, callback) {
|
|
685
|
+
var unregister = function unregister(channel, callback) {
|
|
281
686
|
for(var command in listeners[channel]){
|
|
282
687
|
var index = listeners[channel][command].indexOf(callback);
|
|
283
688
|
if (index >= 0) {
|
|
@@ -320,62 +725,106 @@ var Sync = {
|
|
|
320
725
|
sendIntArray: sendNumberArray
|
|
321
726
|
};
|
|
322
727
|
// src/RemoteLogger.ts
|
|
323
|
-
var
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
728
|
+
var RemoteLogger = /*#__PURE__*/ function() {
|
|
729
|
+
function _RemoteLogger() {
|
|
730
|
+
var enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
731
|
+
var _this = this;
|
|
732
|
+
_class_call_check(this, _RemoteLogger);
|
|
733
|
+
this.enabled = enabled;
|
|
734
|
+
this.consoleDebug = console.debug;
|
|
735
|
+
this.consoleLog = console.log;
|
|
736
|
+
this.consoleInfo = console.info;
|
|
737
|
+
this.consoleWarn = console.warn;
|
|
738
|
+
this.consoleError = console.error;
|
|
739
|
+
console.debug = function() {
|
|
740
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
741
|
+
args[_key] = arguments[_key];
|
|
742
|
+
}
|
|
743
|
+
_this.consoleDebug.apply(_this, _to_consumable_array(args));
|
|
744
|
+
_this.sendMessage("debug", args);
|
|
745
|
+
};
|
|
746
|
+
console.log = function() {
|
|
747
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
748
|
+
args[_key] = arguments[_key];
|
|
749
|
+
}
|
|
750
|
+
_this.consoleLog.apply(_this, _to_consumable_array(args));
|
|
751
|
+
_this.sendMessage("info", args);
|
|
752
|
+
};
|
|
753
|
+
console.info = function() {
|
|
754
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
755
|
+
args[_key] = arguments[_key];
|
|
756
|
+
}
|
|
757
|
+
_this.consoleInfo.apply(_this, _to_consumable_array(args));
|
|
758
|
+
_this.sendMessage("info", args);
|
|
759
|
+
};
|
|
760
|
+
console.warn = function() {
|
|
761
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
762
|
+
args[_key] = arguments[_key];
|
|
763
|
+
}
|
|
764
|
+
_this.consoleWarn.apply(_this, _to_consumable_array(args));
|
|
765
|
+
_this.sendMessage("warn", args);
|
|
766
|
+
};
|
|
767
|
+
console.error = function() {
|
|
768
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
769
|
+
args[_key] = arguments[_key];
|
|
770
|
+
}
|
|
771
|
+
_this.consoleError.apply(_this, _to_consumable_array(args));
|
|
772
|
+
_this.sendMessage("error", args);
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
_create_class(_RemoteLogger, [
|
|
776
|
+
{
|
|
777
|
+
key: "sendMessage",
|
|
778
|
+
value: function sendMessage(level, args) {
|
|
779
|
+
if (!this.enabled) return;
|
|
780
|
+
SendMessage("log", level, _to_consumable_array(args).map(stringify).join().trim());
|
|
781
|
+
}
|
|
782
|
+
},
|
|
783
|
+
{
|
|
784
|
+
key: "enable",
|
|
785
|
+
value: function enable() {
|
|
786
|
+
this.enabled = true;
|
|
787
|
+
}
|
|
788
|
+
},
|
|
789
|
+
{
|
|
790
|
+
key: "disable",
|
|
791
|
+
value: function disable() {
|
|
792
|
+
this.enabled = false;
|
|
339
793
|
}
|
|
340
|
-
return value;
|
|
341
|
-
}, 2);
|
|
342
|
-
return str;
|
|
343
|
-
};
|
|
344
|
-
console.debug = function init2() {
|
|
345
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
346
|
-
args[_key] = arguments[_key];
|
|
347
|
-
}
|
|
348
|
-
consoleDebug.apply(this, Array.prototype.slice.call(args));
|
|
349
|
-
SendMessage("log", "debug", _to_consumable_array(args).map(stringify).join().trim());
|
|
350
|
-
};
|
|
351
|
-
console.log = function() {
|
|
352
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
353
|
-
args[_key] = arguments[_key];
|
|
354
794
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
795
|
+
], [
|
|
796
|
+
{
|
|
797
|
+
key: "init",
|
|
798
|
+
value: /**
|
|
799
|
+
* @deprecated use new class constructor directly
|
|
800
|
+
*/ function init() {
|
|
801
|
+
var enabled = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
|
|
802
|
+
return new _RemoteLogger(enabled);
|
|
803
|
+
}
|
|
361
804
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
805
|
+
]);
|
|
806
|
+
return _RemoteLogger;
|
|
807
|
+
}();
|
|
808
|
+
var stringify = function stringify(obj) {
|
|
809
|
+
if (_instanceof(obj, Error)) {
|
|
810
|
+
return obj.message + "\n" + obj.stack;
|
|
811
|
+
}
|
|
812
|
+
if (typeof obj === "string") return obj;
|
|
813
|
+
var cache = [];
|
|
814
|
+
var str = JSON.stringify(obj, function(_, value) {
|
|
815
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === "object" && value !== null) {
|
|
816
|
+
if (cache.indexOf(value) !== -1) {
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
cache.push(value);
|
|
368
820
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
};
|
|
373
|
-
var RemoteLogger = {
|
|
374
|
-
init: init2
|
|
821
|
+
return value;
|
|
822
|
+
}, 2);
|
|
823
|
+
return str;
|
|
375
824
|
};
|
|
376
825
|
// src/ModelSynchronization.ts
|
|
377
826
|
var import_rxjs2 = require("rxjs");
|
|
378
|
-
var RegisterModelSync = function(registration) {
|
|
827
|
+
var RegisterModelSync = function RegisterModelSync(registration) {
|
|
379
828
|
var name = registration.name || registration.type.name.toLowerCase();
|
|
380
829
|
SendMessage(name, "model::request");
|
|
381
830
|
console.log("Registering model '".concat(name, "'"));
|
|
@@ -390,7 +839,7 @@ var RegisterModelSync = function(registration) {
|
|
|
390
839
|
}
|
|
391
840
|
});
|
|
392
841
|
var models = new import_rxjs2.BehaviorSubject([]);
|
|
393
|
-
var onUpdate = function(modelData) {
|
|
842
|
+
var onUpdate = function onUpdate(modelData) {
|
|
394
843
|
var model = models.value.find(function(m) {
|
|
395
844
|
return m.id === modelData.id;
|
|
396
845
|
});
|
|
@@ -412,7 +861,7 @@ var RegisterModelSync = function(registration) {
|
|
|
412
861
|
]));
|
|
413
862
|
}
|
|
414
863
|
};
|
|
415
|
-
var onDelete = function(id) {
|
|
864
|
+
var onDelete = function onDelete(id) {
|
|
416
865
|
var model = models.value.find(function(m) {
|
|
417
866
|
return m.id === id;
|
|
418
867
|
});
|
|
@@ -421,7 +870,7 @@ var RegisterModelSync = function(registration) {
|
|
|
421
870
|
return m.id !== id;
|
|
422
871
|
}));
|
|
423
872
|
};
|
|
424
|
-
var registerModel = function(model) {
|
|
873
|
+
var registerModel = function registerModel(model) {
|
|
425
874
|
model.modelChanges$.subscribe(function(changes) {
|
|
426
875
|
if (!model.ignoreNextChange) {
|
|
427
876
|
SendMessage("".concat(name), "model::update", model.toJson(changes));
|
|
@@ -554,9 +1003,9 @@ var SyncModel = /*#__PURE__*/ function() {
|
|
|
554
1003
|
return SyncModel;
|
|
555
1004
|
}();
|
|
556
1005
|
// src/Synced.ts
|
|
557
|
-
var Synced = function() {
|
|
1006
|
+
var Synced = function Synced() {
|
|
558
1007
|
var syncedName = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
559
|
-
return function
|
|
1008
|
+
return function(target, key, descriptor) {
|
|
560
1009
|
if (!syncedName) syncedName = key.toString();
|
|
561
1010
|
syncedName = syncedName.toLowerCase();
|
|
562
1011
|
if (!_instanceof(target, SyncModel)) {
|
|
@@ -568,10 +1017,10 @@ var Synced = function() {
|
|
|
568
1017
|
if (!(descriptor === null || descriptor === void 0 ? void 0 : descriptor.get)) {
|
|
569
1018
|
Reflect.deleteProperty(target, key);
|
|
570
1019
|
Reflect.defineProperty(target, key, {
|
|
571
|
-
get: function() {
|
|
1020
|
+
get: function get() {
|
|
572
1021
|
return original;
|
|
573
1022
|
},
|
|
574
|
-
set: function(newVal) {
|
|
1023
|
+
set: function set(newVal) {
|
|
575
1024
|
console.log("Set ".concat(key.toString(), " to ").concat(newVal));
|
|
576
1025
|
original = newVal;
|
|
577
1026
|
},
|
|
@@ -600,10 +1049,16 @@ var Synced = function() {
|
|
|
600
1049
|
// Annotate the CommonJS export names for ESM import in node:
|
|
601
1050
|
0 && (module.exports = {
|
|
602
1051
|
Colibri: Colibri,
|
|
1052
|
+
GetRestApi: GetRestApi,
|
|
1053
|
+
PutRestApi: PutRestApi,
|
|
1054
|
+
RegisterChannel: RegisterChannel,
|
|
603
1055
|
RegisterModelSync: RegisterModelSync,
|
|
1056
|
+
RegisterOnce: RegisterOnce,
|
|
604
1057
|
RemoteLogger: RemoteLogger,
|
|
1058
|
+
SendMessage: SendMessage,
|
|
605
1059
|
Sync: Sync,
|
|
606
1060
|
SyncModel: SyncModel,
|
|
607
|
-
Synced: Synced
|
|
1061
|
+
Synced: Synced,
|
|
1062
|
+
UnregisterChannel: UnregisterChannel
|
|
608
1063
|
});
|
|
609
1064
|
//# sourceMappingURL=index.cjs.map
|