mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 20:42:58 +00:00
9639 lines
421 KiB
Plaintext
9639 lines
421 KiB
Plaintext
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
'use strict';
|
|
|
|
module.exports = function () {
|
|
throw new Error(
|
|
'ws does not work in the browser. Browser clients must use the native ' +
|
|
'WebSocket object'
|
|
);
|
|
};
|
|
|
|
},{}],2:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _AsyncReply2 = _interopRequireDefault(require("./AsyncReply.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var AsyncBag = /*#__PURE__*/function (_AsyncReply) {
|
|
_inherits(AsyncBag, _AsyncReply);
|
|
|
|
var _super = _createSuper(AsyncBag);
|
|
|
|
function AsyncBag() {
|
|
var _this;
|
|
|
|
_classCallCheck(this, AsyncBag);
|
|
|
|
_this = _super.call(this);
|
|
_this.replies = [];
|
|
_this.results = [];
|
|
_this.count = 0;
|
|
_this.sealedBag = false;
|
|
return _this;
|
|
}
|
|
|
|
_createClass(AsyncBag, [{
|
|
key: "seal",
|
|
value: function seal() {
|
|
this.sealedBag = true;
|
|
if (this.results.length == 0) this.trigger([]);
|
|
var self = this;
|
|
|
|
var singleTaskCompleted = function singleTaskCompleted(taskIndex) {
|
|
return function (results, reply) {
|
|
self.results[taskIndex] = results;
|
|
self.count++;
|
|
if (self.count == self.results.length) self.trigger(self.results);
|
|
};
|
|
};
|
|
|
|
for (var i = 0; i < this.results.length; i++) {
|
|
this.replies[i].then(singleTaskCompleted(i));
|
|
}
|
|
/*
|
|
this.replies[i].then(function(r, reply){
|
|
self.results[self.replies.indexOf(reply)] = r;
|
|
self.count++;
|
|
if (self.count == self.results.length)
|
|
self.trigger(self.results);
|
|
});
|
|
*/
|
|
|
|
}
|
|
}, {
|
|
key: "add",
|
|
value: function add(reply) {
|
|
if (!this.sealedBag) {
|
|
this.replies.push(reply);
|
|
this.results.push(null);
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return AsyncBag;
|
|
}(_AsyncReply2["default"]);
|
|
|
|
exports["default"] = AsyncBag;
|
|
|
|
},{"./AsyncReply.js":5}],3:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 18/11/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _ExceptionCode = _interopRequireDefault(require("./ExceptionCode.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var AsyncException = /*#__PURE__*/function (_Error) {
|
|
_inherits(AsyncException, _Error);
|
|
|
|
var _super = _createSuper(AsyncException);
|
|
|
|
function AsyncException(type, code, message) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, AsyncException);
|
|
|
|
_this = _super.call(this);
|
|
|
|
if (type instanceof AsyncException) {
|
|
_this.raise(type.type, type.code, type.message);
|
|
} else if (type instanceof Error) {
|
|
_this.raise(1, 0, type.message);
|
|
} else if (type != undefined) {
|
|
_this.raise(type, code, message);
|
|
} else {
|
|
_this.raised = false;
|
|
}
|
|
|
|
return _this;
|
|
}
|
|
|
|
_createClass(AsyncException, [{
|
|
key: "raise",
|
|
value: function raise(type, code, message) {
|
|
this.type = type;
|
|
this.code = code;
|
|
|
|
if (type == 0) {
|
|
for (var i in _ExceptionCode["default"]) {
|
|
if (_ExceptionCode["default"][i] == code) {
|
|
this.message = i;
|
|
break;
|
|
}
|
|
}
|
|
} else this.message = message;
|
|
|
|
this.raised = true;
|
|
}
|
|
}, {
|
|
key: "toString",
|
|
value: function toString() {
|
|
return (this.type == 0 ? "Management" : "Exception") + " (" + this.code + ") : " + this.message;
|
|
}
|
|
}]);
|
|
|
|
return AsyncException;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
|
|
exports["default"] = AsyncException;
|
|
|
|
},{"./ExceptionCode.js":7}],4:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _AsyncReply2 = _interopRequireDefault(require("./AsyncReply.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var AsyncQueue = /*#__PURE__*/function (_AsyncReply) {
|
|
_inherits(AsyncQueue, _AsyncReply);
|
|
|
|
var _super = _createSuper(AsyncQueue);
|
|
|
|
function AsyncQueue() {
|
|
var _this;
|
|
|
|
_classCallCheck(this, AsyncQueue);
|
|
|
|
_this = _super.call(this);
|
|
_this.list = [];
|
|
|
|
var self = _assertThisInitialized(_this);
|
|
|
|
_this.processQueue = function () {
|
|
for (var i = 0; i < self.list.length; i++) {
|
|
if (self.list[i].ready) {
|
|
self.trigger(self.list[i].result);
|
|
self.ready = false; //self.list.splice(i, 1);
|
|
|
|
self.list.shift();
|
|
i--;
|
|
} else if (self.list[i].failed) {
|
|
self.ready = false;
|
|
self.list.shift();
|
|
i--;
|
|
console.log("AsyncQueue (Reply Failed)");
|
|
} else break;
|
|
}
|
|
|
|
self.ready = self.list.length == 0;
|
|
};
|
|
|
|
return _this;
|
|
}
|
|
|
|
_createClass(AsyncQueue, [{
|
|
key: "add",
|
|
value: function add(reply) {
|
|
this.list.push(reply);
|
|
this.ready = false;
|
|
reply.then(this.processQueue).error(this.processQueue);
|
|
}
|
|
}, {
|
|
key: "remove",
|
|
value: function remove(reply) {
|
|
this.list.splice(this.list.indexOf(reply), 1);
|
|
this.processQueue();
|
|
}
|
|
}]);
|
|
|
|
return AsyncQueue;
|
|
}(_AsyncReply2["default"]);
|
|
|
|
exports["default"] = AsyncQueue;
|
|
|
|
},{"./AsyncReply.js":5}],5:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _AsyncException = _interopRequireDefault(require("./AsyncException.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var AsyncReply = /*#__PURE__*/function (_Promise) {
|
|
_inherits(AsyncReply, _Promise);
|
|
|
|
var _super = _createSuper(AsyncReply);
|
|
|
|
function AsyncReply(result) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, AsyncReply);
|
|
|
|
if (result instanceof Function) {
|
|
_this = _super.call(this, result);
|
|
_this.awaiter = result;
|
|
} else _this = _super.call(this, function () {});
|
|
|
|
_this.callbacks = [];
|
|
_this.errorCallbacks = [];
|
|
_this.progressCallbacks = [];
|
|
_this.chunkCallbacks = [];
|
|
_this.exception = new _AsyncException["default"](); // null;
|
|
//var self = this;
|
|
|
|
if (result !== undefined && !(result instanceof Function)) {
|
|
_this.result = result;
|
|
_this.ready = true;
|
|
} else {
|
|
_this.ready = false;
|
|
_this.result = null;
|
|
}
|
|
|
|
return _possibleConstructorReturn(_this);
|
|
}
|
|
|
|
_createClass(AsyncReply, [{
|
|
key: "then",
|
|
value: function then(callback, onError) {
|
|
if (callback != undefined) {
|
|
this.callbacks.push(callback);
|
|
if (this.ready) callback(this.result, this);
|
|
}
|
|
|
|
if (onError != undefined) {
|
|
this.error(onError);
|
|
}
|
|
|
|
return this;
|
|
} // Alias for then()
|
|
|
|
}, {
|
|
key: "done",
|
|
value: function done(callback) {
|
|
this.then(callback);
|
|
}
|
|
}, {
|
|
key: "error",
|
|
value: function error(callback) {
|
|
this.errorCallbacks.push(callback);
|
|
|
|
if (this.exception.raised) {
|
|
callback(this.exception);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "progress",
|
|
value: function progress(callback) {
|
|
this.progressCallbacks.push(callback);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "chunk",
|
|
value: function chunk(callback) {
|
|
this.chunkCallbacks.push(callback);
|
|
return this;
|
|
} // Alias for chunk()
|
|
|
|
}, {
|
|
key: "next",
|
|
value: function next(callback) {
|
|
this.chunk(callback);
|
|
}
|
|
}, {
|
|
key: "trigger",
|
|
value: function trigger(result) {
|
|
if (this.ready) return;
|
|
this.result = result;
|
|
this.ready = true;
|
|
|
|
for (var i = 0; i < this.callbacks.length; i++) {
|
|
this.callbacks[i](result, this);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "triggerError",
|
|
value: function triggerError(type, code, message) {
|
|
if (this.ready) return this;
|
|
if (type instanceof _AsyncException["default"]) this.exception.raise(type.type, type.code, type.message);else this.exception.raise(type, code, message);
|
|
if (this.errorCallbacks.length == 0) throw this.exception;else for (var i = 0; i < this.errorCallbacks.length; i++) {
|
|
this.errorCallbacks[i](this.exception, this);
|
|
}
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "triggerProgress",
|
|
value: function triggerProgress(type, value, max) {
|
|
for (var i = 0; i < this.progressCallbacks.length; i++) {
|
|
this.progressCallbacks[i](type, value, max, this);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "triggerChunk",
|
|
value: function triggerChunk(value) {
|
|
for (var i = 0; i < this.chunkCallbacks.length; i++) {
|
|
this.chunkCallbacks[i](value, this);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
}]);
|
|
|
|
return AsyncReply;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Promise));
|
|
|
|
exports["default"] = AsyncReply;
|
|
|
|
},{"./AsyncException.js":3}],6:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = {
|
|
Management: 0,
|
|
Exception: 1
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],7:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = //const ExceptionCode =
|
|
{
|
|
HostNotReachable: 0,
|
|
AccessDenied: 1,
|
|
UserOrTokenNotFound: 2,
|
|
ChallengeFailed: 3,
|
|
ResourceNotFound: 4,
|
|
AttachDenied: 5,
|
|
InvalidMethod: 6,
|
|
InvokeDenied: 7,
|
|
CreateDenied: 8,
|
|
AddParentDenied: 9,
|
|
AddChildDenied: 10,
|
|
ViewAttributeDenied: 11,
|
|
UpdateAttributeDenied: 12,
|
|
StoreNotFound: 13,
|
|
ParentNotFound: 14,
|
|
ChildNotFound: 15,
|
|
ResourceIsNotStore: 16,
|
|
DeleteDenied: 17,
|
|
DeleteFailed: 18,
|
|
UpdateAttributeFailed: 19,
|
|
GetAttributesFailed: 20,
|
|
ClearAttributesFailed: 21,
|
|
TemplateNotFound: 22,
|
|
RenameDenied: 23,
|
|
ClassNotFound: 24,
|
|
MethodNotFound: 25,
|
|
PropertyNotFound: 26,
|
|
SetPropertyDenied: 27,
|
|
ReadOnlyProperty: 28,
|
|
GeneralFailure: 29,
|
|
AddToStoreFailed: 30,
|
|
NotAttached: 31,
|
|
AlreadyListened: 32,
|
|
AlreadyUnlistened: 33,
|
|
NotListenable: 34
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],8:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 31/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IEventHandler2 = _interopRequireDefault(require("./IEventHandler.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var IDestructible = /*#__PURE__*/function (_IEventHandler) {
|
|
_inherits(IDestructible, _IEventHandler);
|
|
|
|
var _super = _createSuper(IDestructible);
|
|
|
|
function IDestructible() {
|
|
_classCallCheck(this, IDestructible);
|
|
|
|
return _super.call(this);
|
|
}
|
|
|
|
_createClass(IDestructible, [{
|
|
key: "destroy",
|
|
value: function destroy() {
|
|
this._emit("destroy", this);
|
|
}
|
|
}]);
|
|
|
|
return IDestructible;
|
|
}(_IEventHandler2["default"]);
|
|
|
|
exports["default"] = IDestructible;
|
|
|
|
},{"./IEventHandler.js":9}],9:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 30/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
var IEventHandler = /*#__PURE__*/function () {
|
|
function IEventHandler() {
|
|
_classCallCheck(this, IEventHandler);
|
|
|
|
this._events = {};
|
|
}
|
|
|
|
_createClass(IEventHandler, [{
|
|
key: "_register",
|
|
value: function _register(event) {
|
|
this._events[event] = [];
|
|
}
|
|
}, {
|
|
key: "_emit",
|
|
value: function _emit(event) {
|
|
event = event.toLowerCase();
|
|
var args = Array.prototype.slice.call(arguments, 1);
|
|
if (this._events[event]) for (var i = 0; i < this._events[event].length; i++) {
|
|
if (this._events[event][i].f.apply(this._events[event][i].i, args)) return true;
|
|
}
|
|
return false;
|
|
}
|
|
}, {
|
|
key: "_emitArgs",
|
|
value: function _emitArgs(event, args) {
|
|
event = event.toLowerCase();
|
|
if (this._events[event]) for (var i = 0; i < this._events[event].length; i++) {
|
|
if (this._events[event][i].f.apply(this._events[event][i].i, args)) return true;
|
|
}
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "on",
|
|
value: function on(event, fn, issuer) {
|
|
if (!(fn instanceof Function)) return this;
|
|
event = event.toLowerCase(); // add
|
|
|
|
if (!this._events[event]) this._events[event] = [];
|
|
|
|
this._events[event].push({
|
|
f: fn,
|
|
i: issuer == null ? this : issuer
|
|
});
|
|
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "off",
|
|
value: function off(event, fn) {
|
|
event = event.toLowerCase();
|
|
|
|
if (this._events[event]) {
|
|
if (fn) {
|
|
for (var i = 0; i < this._events[event].length; i++) {
|
|
if (this._events[event][i].f == fn) this._events[event].splice(i--, 1);
|
|
} //var index = this._events[event].indexOf(fn);
|
|
//if (index > -1)
|
|
//this._events[event].splice(index, 1);
|
|
|
|
} else {
|
|
this._events[event] = [];
|
|
}
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return IEventHandler;
|
|
}();
|
|
|
|
exports["default"] = IEventHandler;
|
|
|
|
},{}],10:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = {
|
|
Execution: 0,
|
|
Network: 1
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],11:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 05/09/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IEventHandler2 = _interopRequireDefault(require("../Core/IEventHandler.js"));
|
|
|
|
var _IDestructible = _interopRequireDefault(require("../Core/IDestructible.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
|
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
|
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
|
|
var _item_destroyed = /*#__PURE__*/new WeakMap();
|
|
|
|
var AutoList = /*#__PURE__*/function (_IEventHandler) {
|
|
_inherits(AutoList, _IEventHandler);
|
|
|
|
var _super = _createSuper(AutoList);
|
|
|
|
function AutoList() {
|
|
var _this;
|
|
|
|
_classCallCheck(this, AutoList);
|
|
|
|
_this = _super.call(this);
|
|
|
|
_item_destroyed.set(_assertThisInitialized(_this), {
|
|
writable: true,
|
|
value: function value(sender) {
|
|
this.remove(sender);
|
|
}
|
|
});
|
|
|
|
_this.list = [];
|
|
return _this;
|
|
}
|
|
|
|
_createClass(AutoList, [{
|
|
key: "length",
|
|
get: function get() {
|
|
return this.list.length;
|
|
}
|
|
}, {
|
|
key: "add",
|
|
value: function add(value) {
|
|
if (value instanceof _IDestructible["default"]) value.on("destroy", _classPrivateFieldGet(this, _item_destroyed), this);
|
|
this.list.push(value);
|
|
|
|
this._emit("add", value);
|
|
}
|
|
}, {
|
|
key: "set",
|
|
value: function set(index, value) {
|
|
if (index >= this.list.length || index < 0) return;
|
|
if (value instanceof _IDestructible["default"]) value.on("destroy", _classPrivateFieldGet(this, _item_destroyed), this);
|
|
if (this.list[index] instanceof _IDestructible["default"]) this.list[index].off("destroy", _classPrivateFieldGet(this, _item_destroyed));
|
|
this.list[index] = value;
|
|
}
|
|
}, {
|
|
key: "at",
|
|
value: function at(index) {
|
|
return this.list[index];
|
|
}
|
|
}, {
|
|
key: "item",
|
|
value: function item(index) {
|
|
return this.list[index];
|
|
}
|
|
}, {
|
|
key: "remove",
|
|
value: function remove(value) {
|
|
this.removeAt(this.list.indexOf(value));
|
|
}
|
|
}, {
|
|
key: "contains",
|
|
value: function contains(value) {
|
|
return this.list.indexOf(value) > -1;
|
|
}
|
|
}, {
|
|
key: "toArray",
|
|
value: function toArray() {
|
|
return this.list.slice(0);
|
|
}
|
|
}, {
|
|
key: "removeAt",
|
|
value: function removeAt(index) {
|
|
if (index >= this.list.length || index < 0) return;
|
|
var item = this.list[index];
|
|
if (item instanceof _IDestructible["default"]) item.off("destroy", _classPrivateFieldGet(this, _item_destroyed));
|
|
this.list.splice(index, 1);
|
|
|
|
this._emit("remove", item);
|
|
}
|
|
}]);
|
|
|
|
return AutoList;
|
|
}(_IEventHandler2["default"]);
|
|
|
|
exports["default"] = AutoList;
|
|
|
|
},{"../Core/IDestructible.js":8,"../Core/IEventHandler.js":9}],12:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 05/09/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IEventHandler2 = _interopRequireDefault(require("../Core/IEventHandler.js"));
|
|
|
|
var _IDestructible = _interopRequireDefault(require("../Core/IDestructible.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
|
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
|
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
|
|
var _item_destroyed = /*#__PURE__*/new WeakMap();
|
|
|
|
var AutoMap = /*#__PURE__*/function (_IEventHandler) {
|
|
_inherits(AutoMap, _IEventHandler);
|
|
|
|
var _super = _createSuper(AutoMap);
|
|
|
|
function AutoMap() {
|
|
var _this;
|
|
|
|
_classCallCheck(this, AutoMap);
|
|
|
|
_this = _super.call(this);
|
|
|
|
_item_destroyed.set(_assertThisInitialized(_this), {
|
|
writable: true,
|
|
value: function value(sender) {
|
|
this.remove(sender);
|
|
}
|
|
});
|
|
|
|
_this.dic = {};
|
|
return _this;
|
|
}
|
|
|
|
_createClass(AutoMap, [{
|
|
key: "add",
|
|
value: function add(key, value) {
|
|
if (value instanceof _IDestructible["default"]) value.on("destroy", _classPrivateFieldGet(this, _item_destroyed));
|
|
this.dic[key] = value;
|
|
|
|
this._emit("add", key, value);
|
|
}
|
|
}, {
|
|
key: "set",
|
|
value: function set(key, value) {
|
|
if (this.dic[key] !== undefined) this.remove(key);
|
|
this.add(key, value);
|
|
}
|
|
}, {
|
|
key: "remove",
|
|
value: function remove(key) {
|
|
if (this.dic[key] !== undefined) {
|
|
if (this.dic[key] instanceof _IDestructible["default"]) this.dic[key].off("destroy", _classPrivateFieldGet(this, _item_destroyed));
|
|
delete this.dic[key];
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return AutoMap;
|
|
}(_IEventHandler2["default"]);
|
|
|
|
exports["default"] = AutoMap;
|
|
|
|
},{"../Core/IDestructible.js":8,"../Core/IEventHandler.js":9}],13:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _DC = _interopRequireDefault(require("./DC.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
|
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
|
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
var BinaryList = /*#__PURE__*/function () {
|
|
function BinaryList() {
|
|
_classCallCheck(this, BinaryList);
|
|
|
|
this.list = []; //this.data = [];
|
|
}
|
|
|
|
_createClass(BinaryList, [{
|
|
key: "addDateTime",
|
|
value: function addDateTime(value, endian) {
|
|
this.addDC(_DC["default"].dateTimeToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertDateTime",
|
|
value: function insertDateTime(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].dateTimeToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addDateTimeArray",
|
|
value: function addDateTimeArray(value, endian) {
|
|
this.addDC(_DC["default"].dateTimeArrayToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertDateTimeArray",
|
|
value: function insertDateTimeArray(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].dateTimeArrayToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addGuid",
|
|
value: function addGuid(value) {
|
|
this.addDC(_DC["default"].guidToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertGuid",
|
|
value: function insertGuid(position, value) {
|
|
this.insertDC(position, _DC["default"].guidToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addUint8Array",
|
|
value: function addUint8Array(value) {
|
|
this.addDC(value);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addDC",
|
|
value: function addDC(value) {
|
|
var _this$list;
|
|
|
|
(_this$list = this.list).push.apply(_this$list, _toConsumableArray(value));
|
|
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertUint8Array",
|
|
value: function insertUint8Array(position, value) {
|
|
this.insertDC(position, value);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addString",
|
|
value: function addString(value) {
|
|
this.addDC(_DC["default"].stringToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertString",
|
|
value: function insertString(position, value) {
|
|
this.insertDC(position, _DC["default"].stringToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertUint8",
|
|
value: function insertUint8(position, value) {
|
|
this.list.splice(position, 0, value);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addUint8",
|
|
value: function addUint8(value) {
|
|
this.list.push(value);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addInt8",
|
|
value: function addInt8(value) {
|
|
this.list.push(value);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertInt8",
|
|
value: function insertInt8(position, value) {
|
|
this.list.splice(position, 0, value);
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addChar",
|
|
value: function addChar(value) {
|
|
this.addDC(_DC["default"].charToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertChar",
|
|
value: function insertChar(position, value) {
|
|
this.insertDC(position, _DC["default"].charToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addBoolean",
|
|
value: function addBoolean(value) {
|
|
this.addDC(_DC["default"].boolToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertBoolean",
|
|
value: function insertBoolean(position, value) {
|
|
this.insertDC(position, _DC["default"].boolToBytes(value));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addUint16",
|
|
value: function addUint16(value, endian) {
|
|
this.addDC(_DC["default"].uint16ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertUint16",
|
|
value: function insertUint16(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].uint16ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addInt16",
|
|
value: function addInt16(value, endian) {
|
|
this.addDC(_DC["default"].int16ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertInt16",
|
|
value: function insertInt16(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].int16ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addUint32",
|
|
value: function addUint32(value, endian) {
|
|
this.addDC(_DC["default"].uint32ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertUint32",
|
|
value: function insertUint32(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].uint32ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addInt32",
|
|
value: function addInt32(value, endian) {
|
|
this.addDC(_DC["default"].int32ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertInt32",
|
|
value: function insertInt32(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].int32ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addUint64",
|
|
value: function addUint64(value, endian) {
|
|
this.addDC(_DC["default"].uint64ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertUint64",
|
|
value: function insertUint64(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].uint64ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addInt64",
|
|
value: function addInt64(value, endian) {
|
|
this.addDC(_DC["default"].int64ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertInt64",
|
|
value: function insertInt64(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].int64ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addFloat32",
|
|
value: function addFloat32(value, endian) {
|
|
this.addDC(_DC["default"].float32ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertFloat32",
|
|
value: function insertFloat32(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].float32ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "addFloat64",
|
|
value: function addFloat64(value, endian) {
|
|
this.addDC(_DC["default"].float64ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "insertFloat64",
|
|
value: function insertFloat64(position, value, endian) {
|
|
this.insertDC(position, _DC["default"].float64ToBytes(value, endian));
|
|
return this;
|
|
}
|
|
}, {
|
|
key: "length",
|
|
get: function get() {
|
|
return this.list.length;
|
|
}
|
|
}, {
|
|
key: "toArray",
|
|
value: function toArray() {
|
|
return new Uint8Array(this.list);
|
|
}
|
|
}, {
|
|
key: "toDC",
|
|
value: function toDC() {
|
|
return new _DC["default"](this.list);
|
|
}
|
|
}]);
|
|
|
|
return BinaryList;
|
|
}();
|
|
|
|
exports["default"] = BinaryList;
|
|
|
|
},{"./DC.js":15}],14:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = exports.CodecParseResults = exports.CodecComposeResults = void 0;
|
|
|
|
var _DataType = _interopRequireDefault(require("./DataType.js"));
|
|
|
|
var _ResourceComparisonResult = _interopRequireDefault(require("./ResourceComparisonResult.js"));
|
|
|
|
var _StructureComparisonResult = _interopRequireDefault(require("./StructureComparisonResult.js"));
|
|
|
|
var _AsyncBag = _interopRequireDefault(require("../Core/AsyncBag.js"));
|
|
|
|
var _AsyncReply = _interopRequireDefault(require("../Core/AsyncReply.js"));
|
|
|
|
var _Structure = _interopRequireDefault(require("./Structure.js"));
|
|
|
|
var _PropertyValue = _interopRequireDefault(require("./PropertyValue.js"));
|
|
|
|
var _DC = require("./DC.js");
|
|
|
|
var _BinaryList = _interopRequireDefault(require("./BinaryList.js"));
|
|
|
|
var _DistributedPropertyContext = _interopRequireDefault(require("../Net/IIP/DistributedPropertyContext.js"));
|
|
|
|
var _DistributedResource = _interopRequireDefault(require("../Net/IIP/DistributedResource.js"));
|
|
|
|
var _IResource = _interopRequireDefault(require("../Resource/IResource.js"));
|
|
|
|
var _RecordComparisonResult = _interopRequireDefault(require("./RecordComparisonResult.js"));
|
|
|
|
var _IRecord = _interopRequireDefault(require("./IRecord.js"));
|
|
|
|
var _Record = _interopRequireDefault(require("./Record.js"));
|
|
|
|
var _ResourceArrayType = _interopRequireDefault(require("./ResourceArrayType.js"));
|
|
|
|
var _Warehouse = _interopRequireDefault(require("../Resource/Warehouse.js"));
|
|
|
|
var _TemplateType = _interopRequireDefault(require("../Resource/Template/TemplateType.js"));
|
|
|
|
var _NotModified = _interopRequireDefault(require("./NotModified.js"));
|
|
|
|
var _KeyList = _interopRequireDefault(require("./KeyList.js"));
|
|
|
|
var _StructureArray = _interopRequireDefault(require("./StructureArray.js"));
|
|
|
|
var _DataSerializer = _interopRequireDefault(require("./DataSerializer.js"));
|
|
|
|
var _DataDeserializer = _interopRequireDefault(require("./DataDeserializer.js"));
|
|
|
|
var _TypedList = _interopRequireDefault(require("./TypedList.js"));
|
|
|
|
var _TypedMap = _interopRequireDefault(require("./TypedMap.js"));
|
|
|
|
var _IEnum = _interopRequireDefault(require("./IEnum.js"));
|
|
|
|
var _TransmissionType = require("./TransmissionType.js");
|
|
|
|
var _ExtendedTypes = require("./ExtendedTypes.js");
|
|
|
|
var _PropertyValueArray = _interopRequireDefault(require("./PropertyValueArray.js"));
|
|
|
|
var _RecordArray = _interopRequireDefault(require("./RecordArray.js"));
|
|
|
|
var _ResourceArray = _interopRequireDefault(require("./ResourceArray.js"));
|
|
|
|
var _Tuple = _interopRequireDefault(require("./Tuple.js"));
|
|
|
|
var _defineProperty2;
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
// export default class Codec {
|
|
// static parse(data, offset, sizeObject, connection, dataType = DataType.Unspecified) {
|
|
// var size;
|
|
// //var reply = new AsyncReply();
|
|
// var isArray;
|
|
// var t;
|
|
// if (dataType == DataType.Unspecified) {
|
|
// size = 1;
|
|
// dataType = data[offset++];
|
|
// }
|
|
// else
|
|
// size = 0;
|
|
// t = dataType & 0x7F;
|
|
// isArray = (dataType & 0x80) == 0x80;
|
|
// var payloadSize = DataType.sizeOf(dataType);
|
|
// var contentLength = 0;
|
|
// // check if we have the enough data
|
|
// if (payloadSize == -1) {
|
|
// contentLength = data.getUint32(offset);
|
|
// offset += 4;
|
|
// size += 4 + contentLength;
|
|
// }
|
|
// else
|
|
// size += payloadSize;
|
|
// sizeObject.size = size;
|
|
// if (isArray) {
|
|
// switch (t) {
|
|
// // VarArray ?
|
|
// case DataType.Void:
|
|
// return Codec.parseVarArray(data, offset, contentLength, connection);
|
|
// case DataType.Bool:
|
|
// return new AsyncReply(data.getBooleanArray(offset, contentLength));
|
|
// case DataType.UInt8:
|
|
// return new AsyncReply(data.getUint8Array(offset, contentLength));
|
|
// case DataType.Int8:
|
|
// return new AsyncReply(data.getInt8Array(offset, contentLength));
|
|
// case DataType.Char:
|
|
// return new AsyncReply(data.getCharArray(offset, contentLength));
|
|
// case DataType.Int16:
|
|
// return new AsyncReply(data.getInt16Array(offset, contentLength));
|
|
// case DataType.UInt16:
|
|
// return new AsyncReply(data.getUint16Array(offset, contentLength));
|
|
// case DataType.Int32:
|
|
// return new AsyncReply(data.getInt32Array(offset, contentLength));
|
|
// case DataType.UInt32:
|
|
// return new AsyncReply(data.getUint32Array(offset, contentLength));
|
|
// case DataType.Int64:
|
|
// return new AsyncReply(data.getInt64Array(offset, contentLength));
|
|
// case DataType.UInt64:
|
|
// return new AsyncReply(data.getUint64Array(offset, contentLength));
|
|
// case DataType.Float32:
|
|
// return new AsyncReply(data.getFloat32Array(offset, contentLength));
|
|
// case DataType.Float64:
|
|
// return new AsyncReply(data.getFloat64Array(offset, contentLength));
|
|
// case DataType.String:
|
|
// return new AsyncReply(data.getStringArray(offset, contentLength));
|
|
// case DataType.Resource:
|
|
// case DataType.DistributedResource:
|
|
// return Codec.parseResourceArray(data, offset, contentLength, connection);
|
|
// case DataType.DateTime:
|
|
// return new AsyncReply(data.getDateTimeArray(offset, contentLength));
|
|
// case DataType.Structure:
|
|
// return Codec.parseStructureArray(data, offset, contentLength, connection);
|
|
// case DataType.Record:
|
|
// return Codec.parseRecordArray(data, offset, contentLength, connection);
|
|
// }
|
|
// }
|
|
// else {
|
|
// switch (t) {
|
|
// case DataType.NotModified:
|
|
// return new AsyncReply(new NotModified());
|
|
// case DataType.Void:
|
|
// return new AsyncReply(null);
|
|
// case DataType.Bool:
|
|
// return new AsyncReply(data.getBoolean(offset));
|
|
// case DataType.UInt8:
|
|
// return new AsyncReply(data[offset]);
|
|
// case DataType.Int8:
|
|
// return new AsyncReply(data.getInt8(offset));
|
|
// case DataType.Char:
|
|
// return new AsyncReply(data.getChar(offset));
|
|
// case DataType.Int16:
|
|
// return new AsyncReply(data.getInt16(offset));
|
|
// case DataType.UInt16:
|
|
// return new AsyncReply(data.getUint16(offset));
|
|
// case DataType.Int32:
|
|
// return new AsyncReply(data.getInt32(offset));
|
|
// case DataType.UInt32:
|
|
// return new AsyncReply(data.getUint32(offset));
|
|
// case DataType.Int64:
|
|
// return new AsyncReply(data.getInt64(offset));
|
|
// case DataType.UInt64:
|
|
// return new AsyncReply(data.getUint64(offset));
|
|
// case DataType.Float32:
|
|
// return new AsyncReply(data.getFloat32(offset));
|
|
// case DataType.Float64:
|
|
// return new AsyncReply(data.getFloat64(offset));
|
|
// case DataType.String:
|
|
// return new AsyncReply(data.getString(offset, contentLength));
|
|
// case DataType.Resource:
|
|
// return Codec.parseResource(data, offset);
|
|
// case DataType.DistributedResource:
|
|
// return Codec.parseDistributedResource(data, offset, connection);
|
|
// case DataType.DateTime:
|
|
// return new AsyncReply(data.getDateTime(offset));
|
|
// case DataType.Structure:
|
|
// return Codec.parseStructure(data, offset, contentLength, connection);
|
|
// case DataType.Record:
|
|
// return Codec.parseRecord(data, offset, contentLength, connection);
|
|
// }
|
|
// }
|
|
// // @TODO: Throw exception
|
|
// return new AsyncReply(null);
|
|
// }
|
|
// static parseResource(data, offset) {
|
|
// return Warehouse.getById(data.getUint32(offset));
|
|
// }
|
|
// static parseDistributedResource(data, offset, connection) {
|
|
// //var g = data.getGuid(offset);
|
|
// //offset += 16;
|
|
// // find the object
|
|
// var iid = data.getUint32(offset);
|
|
// return connection.fetch(iid);// Warehouse.getById(iid);
|
|
// }
|
|
// /// <summary>
|
|
// /// Parse an array of bytes into array of resources
|
|
// /// </summary>
|
|
// /// <param name="data">Array of bytes.</param>
|
|
// /// <param name="length">Number of bytes to parse.</param>
|
|
// /// <param name="offset">Zero-indexed offset.</param>
|
|
// /// <param name="connection">DistributedConnection is required to fetch resources.</param>
|
|
// /// <returns>Array of resources.</returns>
|
|
// static parseResourceArray(data, offset, length, connection)
|
|
// {
|
|
// var reply = new AsyncBag();
|
|
// if (length == 0)
|
|
// {
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// var end = offset + length;
|
|
// //
|
|
// //var result = data[offset++];
|
|
// var type = data[offset] & 0xF0;
|
|
// var result = data[offset++] & 0xF;
|
|
// if (type == ResourceArrayType.Wrapper)
|
|
// {
|
|
// let classId = data.getGuid(offset);
|
|
// offset += 16;
|
|
// let tmp = Warehouse.getTemplateByClassId(classId, TemplateType.Resource);
|
|
// // not mine, look if the type is elsewhere
|
|
// if (tmp == null)
|
|
// Warehouse.getTemplateByClassId(classId, TemplateType.Wrapper);
|
|
// reply.arrayType = tmp?.definedType;
|
|
// }
|
|
// else if (type == ResourceArrayType.Static)
|
|
// {
|
|
// let classId = data.getGuid(offset);
|
|
// offset += 16;
|
|
// let tmp = Warehouse.getTemplateByClassId(classId, TemplateType.Wrapper);
|
|
// reply.arrayType = tmp?.definedType;
|
|
// }
|
|
// var previous = null;
|
|
// if (result == ResourceComparisonResult.Empty) {
|
|
// reply.seal();
|
|
// return reply;
|
|
// } else if (result == ResourceComparisonResult.Null) {
|
|
// previous = new AsyncReply(null);
|
|
// } else if (result == ResourceComparisonResult.Local)
|
|
// {
|
|
// previous = Warehouse.getById(data.getUint32(offset));
|
|
// offset += 4;
|
|
// }
|
|
// else if (result == ResourceComparisonResult.Distributed)
|
|
// {
|
|
// previous = connection.fetch(data.getUint32(offset));
|
|
// offset += 4;
|
|
// }
|
|
// reply.add(previous);
|
|
// while (offset < end)
|
|
// {
|
|
// result = data[offset++];
|
|
// var current = null;
|
|
// if (result == ResourceComparisonResult.Null)
|
|
// {
|
|
// current = new AsyncReply(null);
|
|
// }
|
|
// else if (result == ResourceComparisonResult.Same)
|
|
// {
|
|
// current = previous;
|
|
// }
|
|
// else if (result == ResourceComparisonResult.Local)
|
|
// {
|
|
// current = Warehouse.getById(data.getUint32(offset));
|
|
// offset += 4;
|
|
// }
|
|
// else if (result == ResourceComparisonResult.Distributed)
|
|
// {
|
|
// current = connection.fetch(data.getUint32(offset));
|
|
// offset += 4;
|
|
// }
|
|
// reply.add(current);
|
|
// previous = current;
|
|
// }
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// /// <summary>
|
|
// /// Compose an array of property values.
|
|
// /// </summary>
|
|
// /// <param name="array">PropertyValue array.</param>
|
|
// /// <param name="connection">DistributedConnection is required to check locality.</param>
|
|
// /// <param name="prependLength">If True, prepend the length as UInt32 at the beginning of the output.</param>
|
|
// /// <returns>Array of bytes in the network byte order.</returns>
|
|
// static composePropertyValueArray(array, connection, prependLength = false)
|
|
// {
|
|
// var rt = BL();
|
|
// for (var i = 0; i < array.length; i++)
|
|
// rt.addUint8Array(Codec.composePropertyValue(array[i], connection));
|
|
// if (prependLength)
|
|
// rt.addUint32(rt.length, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// /// <summary>
|
|
// /// Compose a property value.
|
|
// /// </summary>
|
|
// /// <param name="propertyValue">Property value</param>
|
|
// /// <param name="connection">DistributedConnection is required to check locality.</param>
|
|
// /// <returns>Array of bytes in the network byte order.</returns>
|
|
// static composePropertyValue(propertyValue, connection)
|
|
// {
|
|
// // age, date, value
|
|
// return BL().addUint64(propertyValue.age)
|
|
// .addDateTime(propertyValue.date)
|
|
// .addUint8Array(Codec.compose(propertyValue.value, connection))
|
|
// .toArray();
|
|
// }
|
|
// /// <summary>
|
|
// /// Parse property value.
|
|
// /// </summary>
|
|
// /// <param name="data">Array of bytes.</param>
|
|
// /// <param name="offset">Zero-indexed offset.</param>
|
|
// /// <param name="connection">DistributedConnection is required to fetch resources.</param>
|
|
// /// <param name="cs">Output content size.</param>
|
|
// /// <returns>PropertyValue.</returns>
|
|
// static parsePropertyValue(data, offset, sizeObject, connection)
|
|
// {
|
|
// var reply = new AsyncReply();
|
|
// var age = data.getUint64(offset);
|
|
// offset += 8;
|
|
// var date = data.getDateTime(offset);
|
|
// offset += 8;
|
|
// var cs = {};
|
|
// Codec.parse(data, offset, cs, connection).then(function(value)
|
|
// {
|
|
// reply.trigger(new PropertyValue(value, age, date));
|
|
// });
|
|
// sizeObject.size = 16 + cs.size;
|
|
// return reply;
|
|
// }
|
|
// /// <summary>
|
|
// /// Parse resource history
|
|
// /// </summary>
|
|
// /// <param name="data">Array of bytes.</param>
|
|
// /// <param name="offset">Zero-indexed offset.</param>
|
|
// /// <param name="length">Number of bytes to parse.</param>
|
|
// /// <param name="resource">Resource</param>
|
|
// /// <param name="fromAge">Starting age.</param>
|
|
// /// <param name="toAge">Ending age.</param>
|
|
// /// <param name="connection">DistributedConnection is required to fetch resources.</param>
|
|
// /// <returns></returns>
|
|
// static parseHistory(data, offset, length, resource, connection)
|
|
// {
|
|
// var list = new KeyList();
|
|
// var reply = new AsyncReply();
|
|
// var bagOfBags = new AsyncBag();
|
|
// var ends = offset + length;
|
|
// while (offset < ends)
|
|
// {
|
|
// var index = data[offset++];
|
|
// var pt = resource.instance.template.getPropertyTemplateByIndex(index);
|
|
// list.add(pt, null);
|
|
// var cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// bagOfBags.add(Codec.parsePropertyValueArray(data, offset, cs, connection));
|
|
// offset += cs;
|
|
// }
|
|
// bagOfBags.seal();
|
|
// bagOfBags.then(x =>
|
|
// {
|
|
// for(var i = 0; i < list.length; i++)
|
|
// list.values[i] = x[i];
|
|
// reply.trigger(list);
|
|
// });
|
|
// return reply;
|
|
// }
|
|
// /// <summary>
|
|
// /// Compose resource history
|
|
// /// </summary>
|
|
// /// <param name="history">History</param>
|
|
// /// <param name="connection">DistributedConnection is required to fetch resources.</param>
|
|
// /// <returns></returns>
|
|
// static composeHistory(history, connection, prependLength = false)
|
|
// {
|
|
// var rt = new BinaryList();
|
|
// for (var i = 0; i < history.length; i++)
|
|
// rt.addUint8(history.keys[i].index).addUint8Array(Codec.composePropertyValueArray(history.values[i], connection, true));
|
|
// if (prependLength)
|
|
// rt.addUint32(rt.length, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// /// <summary>
|
|
// /// Parse an array of ProperyValue.
|
|
// /// </summary>
|
|
// /// <param name="data">Array of bytes.</param>
|
|
// /// <param name="offset">Zero-indexed offset.</param>
|
|
// /// <param name="length">Number of bytes to parse.</param>
|
|
// /// <param name="connection">DistributedConnection is required to fetch resources.</param>
|
|
// /// <returns></returns>
|
|
// static parsePropertyValueArray(data, offset, length, connection)
|
|
// {
|
|
// var rt = new AsyncBag();
|
|
// while (length > 0)
|
|
// {
|
|
// var cs = {};
|
|
// rt.add(Codec.parsePropertyValue(data, offset, cs, connection));
|
|
// if (cs.size > 0)
|
|
// {
|
|
// offset += cs.size;
|
|
// length -= cs.size;
|
|
// }
|
|
// else
|
|
// throw new Error("Error while parsing ValueInfo structured data");
|
|
// }
|
|
// rt.seal();
|
|
// return rt;
|
|
// }
|
|
// static parseStructure(data, offset, contentLength, connection, metadata = null, keys = null, types = null)
|
|
// {
|
|
// var reply = new AsyncReply();
|
|
// var bag = new AsyncBag();
|
|
// var keylist = [];
|
|
// var typelist = [];
|
|
// if (keys == null) {
|
|
// while (contentLength > 0) {
|
|
// var len = data[offset++];
|
|
// keylist.push(data.getString(offset, len));
|
|
// offset += len;
|
|
// typelist.push(data[offset]);
|
|
// var rt = {};
|
|
// bag.add(Codec.parse(data, offset, rt, connection));
|
|
// contentLength -= rt.size + len + 1;
|
|
// offset += rt.size;
|
|
// }
|
|
// }
|
|
// else if (types == null) {
|
|
// for (var i = 0; i < keys.length; i++)
|
|
// keylist.push(keys[i]);
|
|
// while (contentLength > 0) {
|
|
// typelist.push(data[offset]);
|
|
// let rt = {};
|
|
// bag.add(Codec.parse(data, offset, rt, connection));
|
|
// contentLength -= rt.size;
|
|
// offset += rt.size;
|
|
// }
|
|
// }
|
|
// else {
|
|
// for (let i = 0; i < keys.length; i++) {
|
|
// keylist.push(keys[i]);
|
|
// typelist.push(types[i]);
|
|
// }
|
|
// let i = 0;
|
|
// while (contentLength > 0) {
|
|
// let rt = {};
|
|
// bag.add(Codec.parse(data, offset, rt, connection, types[i]));
|
|
// contentLength -= rt.size;
|
|
// offset += rt.size;
|
|
// i++;
|
|
// }
|
|
// }
|
|
// bag.seal();
|
|
// bag.then(function (res) {
|
|
// // compose the list
|
|
// var s = new Structure();
|
|
// for (var i = 0; i < keylist.length; i++)
|
|
// s[keylist[i]] = res[i];
|
|
// reply.trigger(s);
|
|
// });
|
|
// if (metadata != null)
|
|
// {
|
|
// metadata.keys = keylist;
|
|
// metadata.types = typelist;
|
|
// }
|
|
// return reply;
|
|
// }
|
|
// static parseVarArray(data, offset, contentLength, connection) {
|
|
// var rt = new AsyncBag();
|
|
// while (contentLength > 0) {
|
|
// var cs = {};
|
|
// rt.add(Codec.parse(data, offset, cs, connection));
|
|
// if (cs.size > 0) {
|
|
// offset += cs.size;
|
|
// contentLength -= cs.size;
|
|
// }
|
|
// else
|
|
// throw new Error("Error while parsing structured data");
|
|
// }
|
|
// rt.seal();
|
|
// return rt;
|
|
// }
|
|
// static compose(value, connection, prependType = true) {
|
|
// if (value instanceof Function)
|
|
// value = value(connection);
|
|
// else if (value instanceof DistributedPropertyContext)
|
|
// value = value.method(this);
|
|
// var type = Codec.getDataType(value, connection);
|
|
// var rt = new BinaryList();
|
|
// switch (type) {
|
|
// case DataType.Void:
|
|
// // nothing to do;
|
|
// break;
|
|
// case DataType.String:
|
|
// var st = DC.stringToBytes(value);
|
|
// rt.addUint32(st.length).addUint8Array(st);
|
|
// break;
|
|
// case DataType.Resource:
|
|
// rt.addUint32(value._p.instanceId);
|
|
// break;
|
|
// case DataType.DistributedResource:
|
|
// // rt.addUint8Array(DC.stringToBytes(value.instance.template.classId)).addUint32(value.instance.id);
|
|
// rt.addUint32(value.instance.id);
|
|
// break;
|
|
// case DataType.Structure:
|
|
// rt.addUint8Array(Codec.composeStructure(value, connection, true, true, true));
|
|
// break;
|
|
// case DataType.VarArray:
|
|
// rt.addUint8Array(Codec.composeVarArray(value, connection, true));
|
|
// break;
|
|
// case DataType.Record:
|
|
// rt.addUint8Array(Codec.composeRecord(value, connection, true, true));
|
|
// break;
|
|
// case DataType.ResourceArray:
|
|
// rt.addUint8Array(Codec.composeResourceArray(value, connection, true));
|
|
// break;
|
|
// case DataType.StructureArray:
|
|
// rt.addUint8Array(Codec.composeStructureArray(value, connection, true));
|
|
// break;
|
|
// case DataType.RecordArray:
|
|
// rt.addUint8Array(Codec.composeRecordArray(value, connection, true));
|
|
// break;
|
|
// default:
|
|
// rt.add({type: type, value: value});
|
|
// if (DataType.isArray(type))
|
|
// rt.addUint32(rt.length, 0);
|
|
// break;
|
|
// }
|
|
// if (prependType)
|
|
// rt.addUint8(type, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// static composeVarArray(array, connection, prependLength = false) {
|
|
// var rt = new BinaryList();
|
|
// for (var i = 0; i < array.length; i++)
|
|
// rt.addUint8Array(Codec.compose(array[i], connection));
|
|
// if (prependLength)
|
|
// rt.addUint32(rt.length, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// static composeStructure(value, connection, includeKeys = true, includeTypes = true, prependLength = false) {
|
|
// let rt = new BinaryList();
|
|
// let keys = value.getKeys();
|
|
// if (includeKeys) {
|
|
// for (let i = 0; i < keys.length; i++) {
|
|
// let key = DC.stringToBytes(keys[i]);
|
|
// rt.addUint8(key.length).addUint8Array(key).addUint8Array(Codec.compose(value[keys[i]], connection));
|
|
// }
|
|
// }
|
|
// else {
|
|
// for (let i = 0; i < keys.length; i++)
|
|
// rt.addUint8Array(Codec.compose(value[keys[i]], connection, includeTypes));
|
|
// }
|
|
// if (prependLength)
|
|
// rt.addUint32(rt.length, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// static composeStructureArray(structures, connection, prependLength = false) {
|
|
// if (structures == null || structures.length == 0 || !(structures instanceof StructureArray))
|
|
// return new DC(0);
|
|
// var rt = new BinaryList();
|
|
// var comparision = StructureComparisonResult.Structure;
|
|
// rt.addUint8(comparision);
|
|
// rt.addUint8Array(Codec.composeStructure(structures[0], connection));
|
|
// for (var i = 1; i < structures.length; i++) {
|
|
// comparision = Codec.compareStructure(structures[i - 1], structures[i], connection);
|
|
// rt.addUint8(comparision);
|
|
// if (comparision == StructureComparisonResult.Structure)
|
|
// rt.addUint8Array(Codec.composeStructure(structures[i], connection));
|
|
// else if (comparision == StructureComparisonResult.StructureSameKeys)
|
|
// rt.addUint8Array(Codec.composeStructure(structures[i], connection, false));
|
|
// else if (comparision == StructureComparisonResult.StructureSameTypes)
|
|
// rt.addUint8Array(Codec.composeStructure(structures[i], connection, false, false));
|
|
// }
|
|
// if (prependLength)
|
|
// rt.addUint32(rt.length, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// /// <summary>
|
|
// /// Compare two records
|
|
// /// </summary>
|
|
// /// <param name="initial">Initial record to compare with</param>
|
|
// /// <param name="next">Next record to compare with the initial</param>
|
|
// /// <param name="connection">DistributedConnection is required in case a structure holds items at the other end</param>
|
|
// static compareRecords(initial, next)
|
|
// {
|
|
// if (next == null)
|
|
// return RecordComparisonResult.Null;
|
|
// if (initial == null)
|
|
// return RecordComparisonResult.Record;
|
|
// if (next == initial)
|
|
// return RecordComparisonResult.Same;
|
|
// if (next.constructor === initial.constructor)
|
|
// return RecordComparisonResult.RecordSameType;
|
|
// return RecordComparisonResult.Record;
|
|
// }
|
|
// static parseRecordArray(data, offset, length, connection)
|
|
// {
|
|
// var reply = new AsyncBag();
|
|
// if (length == 0)
|
|
// {
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// var end = offset + length;
|
|
// var isTyped = (data.getUint8(offset) & 0x10) == 0x10;
|
|
// var result = data.getUint8(offset++) & 0xF;
|
|
// if (isTyped)
|
|
// {
|
|
// var classId = data.getGuid(offset);
|
|
// offset += 16;
|
|
// var template = Warehouse.getTemplateByClassId(classId, TemplateType.Record);
|
|
// reply.arrayType = template?.definedType;
|
|
// var previous = null;
|
|
// if (result == RecordComparisonResult.Empty)
|
|
// {
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// else if (result == RecordComparisonResult.Null)
|
|
// {
|
|
// previous = new AsyncReply(null);
|
|
// }
|
|
// else if (result == RecordComparisonResult.Record
|
|
// || result == RecordComparisonResult.RecordSameType)
|
|
// {
|
|
// var cs = data.getUint32(offset);
|
|
// var recordLength = cs;
|
|
// offset += 4;
|
|
// previous = Codec.parseRecord(data, offset, recordLength, connection, classId);
|
|
// offset += recordLength;
|
|
// }
|
|
// reply.add(previous);
|
|
// while (offset < end)
|
|
// {
|
|
// result = data.getUint8(offset++);
|
|
// if (result == RecordComparisonResult.Null)
|
|
// previous = new AsyncReply(null);
|
|
// else if (result == RecordComparisonResult.Record
|
|
// || result == RecordComparisonResult.RecordSameType)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// previous = Codec.parseRecord(data, offset, cs, connection, classId);
|
|
// offset += cs;
|
|
// }
|
|
// else if (result == RecordComparisonResult.Same)
|
|
// {
|
|
// // do nothing
|
|
// }
|
|
// reply.add(previous);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// let previous = null;
|
|
// let classId = null;
|
|
// if (result == RecordComparisonResult.Empty)
|
|
// {
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// else if (result == RecordComparisonResult.Null)
|
|
// previous = new AsyncReply(null);
|
|
// else if (result == RecordComparisonResult.Record)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// let recordLength = cs - 16;
|
|
// offset += 4;
|
|
// classId = data.getGuid(offset);
|
|
// offset += 16;
|
|
// previous = Codec.parseRecord(data, offset, recordLength, connection, classId);
|
|
// offset += recordLength;
|
|
// }
|
|
// reply.add(previous);
|
|
// while (offset < end)
|
|
// {
|
|
// result = data.getUint8(offset++);
|
|
// if (result == RecordComparisonResult.Null)
|
|
// previous = new AsyncReply(null);
|
|
// else if (result == RecordComparisonResult.Record)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// let recordLength = cs - 16;
|
|
// offset += 4;
|
|
// classId = data.getGuid(offset);
|
|
// offset += 16;
|
|
// previous = Codec.parseRecord(data, offset, recordLength, connection, classId);
|
|
// offset += recordLength;
|
|
// }
|
|
// else if (result == RecordComparisonResult.RecordSameType)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// previous = this.parseRecord(data, offset, cs, connection, classId);
|
|
// offset += cs;
|
|
// }
|
|
// else if (result == RecordComparisonResult.Same)
|
|
// {
|
|
// // do nothing
|
|
// }
|
|
// reply.add(previous);
|
|
// }
|
|
// }
|
|
// reply.seal();
|
|
// return reply;
|
|
// // var reply = new AsyncBag();
|
|
// // if (length == 0)
|
|
// // {
|
|
// // reply.seal();
|
|
// // return reply;
|
|
// // }
|
|
// // var end = offset + length;
|
|
// // var result = data.getUint8(offset++);
|
|
// // var previous = null;
|
|
// // var classId = null;
|
|
// // if (result == RecordComparisonResult.Null)
|
|
// // previous = new AsyncReply(null);
|
|
// // else if (result == RecordComparisonResult.Record)
|
|
// // {
|
|
// // var cs = data.getUint32(offset);
|
|
// // var recordLength = cs - 16;
|
|
// // offset += 4;
|
|
// // classId = data.getGuid(offset);
|
|
// // offset += 16;
|
|
// // previous = Codec.parseRecord(data, offset, recordLength, connection, classId);
|
|
// // offset += recordLength;
|
|
// // }
|
|
// // reply.Add(previous);
|
|
// // while (offset < end)
|
|
// // {
|
|
// // result = data.getUint8(offset++);
|
|
// // if (result == RecordComparisonResult.Null)
|
|
// // previous = new AsyncReply(null);
|
|
// // else if (result == RecordComparisonResult.Record)
|
|
// // {
|
|
// // var cs = data.getUint32(offset);
|
|
// // var recordLength = cs - 16;
|
|
// // offset += 4;
|
|
// // classId = data.getGuid(offset);
|
|
// // offset += 16;
|
|
// // previous = Codec.parseRecord(data, offset, recordLength, connection, classId);
|
|
// // offset += recordLength;
|
|
// // }
|
|
// // else if (result == RecordComparisonResult.RecordSameType)
|
|
// // {
|
|
// // var cs = data.getUint32(offset);
|
|
// // offset += 4;
|
|
// // previous = Codec.parseRecord(data, offset, cs, connection, classId);
|
|
// // offset += cs;
|
|
// // }
|
|
// // else if (result == RecordComparisonResult.Same)
|
|
// // {
|
|
// // // do nothing
|
|
// // }
|
|
// // reply.add(previous);
|
|
// // }
|
|
// // reply.seal();
|
|
// // return reply;
|
|
// }
|
|
// static parseRecord(data, offset, length, connection, classId = null)
|
|
// {
|
|
// var reply = new AsyncReply();
|
|
// if (classId == null)
|
|
// {
|
|
// classId = data.getGuid(offset);
|
|
// offset += 16;
|
|
// length -= 16;
|
|
// }
|
|
// var template = Warehouse.getTemplateByClassId(classId, TemplateType.Record);
|
|
// if (template != null)
|
|
// {
|
|
// Codec.parseVarArray(data, offset, length, connection).then(ar =>
|
|
// {
|
|
// if (template.definedType != null)
|
|
// {
|
|
// let record = new template.definedType();
|
|
// for (let i = 0; i < template.properties.length; i++)
|
|
// record[template.properties[i].name] = ar[i];
|
|
// reply.trigger(record);
|
|
// }
|
|
// else
|
|
// {
|
|
// let record = new Record();
|
|
// for (let i = 0; i < template.properties.length; i++)
|
|
// record[template.properties[i].name] = ar[i];
|
|
// reply.trigger(record);
|
|
// }
|
|
// });
|
|
// }
|
|
// else
|
|
// {
|
|
// connection.getTemplate(classId).then(tmp => {
|
|
// Codec.parseVarArray(data, offset, length, connection).then(ar =>
|
|
// {
|
|
// var record = new Record();
|
|
// for (var i = 0; i < tmp.properties.length; i++)
|
|
// record[tmp.properties[i].name] = ar[i];
|
|
// reply.trigger(record);
|
|
// });
|
|
// }).error(x=>reply.triggerError(x));
|
|
// }
|
|
// return reply;
|
|
// }
|
|
// static composeRecord(record, connection, includeClassId = true, prependLength = false)
|
|
// {
|
|
// var rt = new BinaryList();
|
|
// var template = Warehouse.getTemplateByType(record.constructor);
|
|
// if (includeClassId)
|
|
// rt.addGuid(template.classId);
|
|
// for(var i = 0; i < template.properties.length; i++)
|
|
// {
|
|
// var value = record[template.properties[i].name];
|
|
// rt.addUint8Array(Codec.compose(value, connection));
|
|
// }
|
|
// if (prependLength)
|
|
// rt.insertInt32(0, rt.length);
|
|
// return rt.toArray();
|
|
// }
|
|
// static composeRecordArray(records, connection, prependLength = false)
|
|
// {
|
|
// if (records == null ) //|| records?.length == 0)
|
|
// return prependLength ? new DC(4) : new DC(0);
|
|
// var rt = new BinaryList();
|
|
// //var comparsion = Codec.compareRecords(null, records[0]);
|
|
// var comparsion = records.length == 0 ? RecordComparisonResult.Empty : Codec.compareRecords(null, records[0]);
|
|
// rt.addUint8(comparsion);
|
|
// if (comparsion == RecordComparisonResult.Record)
|
|
// rt.addUint8Array(Codec.composeRecord(records[0], connection, true, true));
|
|
// for (var i = 1; i < records.length; i++)
|
|
// {
|
|
// comparsion = Codec.compareRecords(records[i - 1], records[i]);
|
|
// rt.addUint8(comparsion);
|
|
// if (comparsion == RecordComparisonResult.Record)
|
|
// rt.addUint8Array(Codec.composeRecord(records[i], connection, true, true));
|
|
// else if (comparsion == RecordComparisonResult.RecordSameType)
|
|
// rt.addUint8Array(Codec.composeRecord(records[i], connection, false, true));
|
|
// }
|
|
// if (prependLength)
|
|
// rt.insertInt32(0, rt.length);
|
|
// return rt.toArray();
|
|
// }
|
|
// static compareStructure(previous, next, connection) {
|
|
// if (next == null)
|
|
// return StructureComparisonResult.Null;
|
|
// if (previous == null)
|
|
// return StructureComparisonResult.Structure;
|
|
// if (next == previous)
|
|
// return StructureComparisonResult.Same;
|
|
// if (previous.length != next.length)
|
|
// return StructureComparisonResult.Structure;
|
|
// var previousKeys = previous.getKeys();
|
|
// var nextKeys = next.getKeys();
|
|
// for (let i = 0; i < previousKeys.length; i++)
|
|
// if (previousKeys[i] != nextKeys[i])
|
|
// return StructureComparisonResult.Structure;
|
|
// var previousTypes = Codec.getStructureDateTypes(previous, connection);
|
|
// var nextTypes = Codec.getStructureDateTypes(next, connection);
|
|
// for (let i = 0; i < previousTypes.length; i++)
|
|
// if (previousTypes[i] != nextTypes[i])
|
|
// return StructureComparisonResult.StructureSameKeys;
|
|
// return StructureComparisonResult.StructureSameTypes;
|
|
// }
|
|
// static getStructureDateTypes(structure, connection) {
|
|
// var keys = structure.getKeys();
|
|
// var types = [];
|
|
// for (var i = 0; i < keys.length; i++)
|
|
// types.push(Codec.getDataType(structure[keys[i]], connection));
|
|
// return types;
|
|
// }
|
|
// static isLocalResource(resource, connection) {
|
|
// if (resource instanceof DistributedResource)
|
|
// if (resource._p.connection == connection)
|
|
// return true;
|
|
// return false;
|
|
// }
|
|
// static composeResource(resource, connection) {
|
|
// if (Codec.isLocalResource(resource, connection))
|
|
// return BL().addUint32(resource.id);
|
|
// else {
|
|
// return BL().addUint8Array(resource.instance.template.classId.value).addUint32(resource.instance.id);
|
|
// }
|
|
// }
|
|
// static compareResource(previous, next, connection) {
|
|
// if (next == null)
|
|
// return ResourceComparisonResult.Null;
|
|
// else if (next == previous)
|
|
// return ResourceComparisonResult.Same;
|
|
// else if (Codec.isLocalResource(next, connection))
|
|
// return ResourceComparisonResult.Local;
|
|
// else
|
|
// return ResourceComparisonResult.Distributed;
|
|
// }
|
|
// static composeResourceArray(resources, connection, prependLength = false) {
|
|
// if (resources == null)// || resources.length == 0)// || !(resources instanceof ResourceArray))
|
|
// return prependLength ? new DC(4) : new DC(0);
|
|
// var rt = new BinaryList();
|
|
// var comparsion = resources.length == 0 ? ResourceComparisonResult.Empty : Codec.compareResource(null, resources[0], connection);
|
|
// rt.addUint8(comparsion);
|
|
// if (comparsion == ResourceComparisonResult.Local)
|
|
// rt.addUint32(resources[0]._p.instanceId);
|
|
// else if (comparsion == ResourceComparisonResult.Distributed)
|
|
// rt.addUint32(resources[0].instance.id);
|
|
// for (var i = 1; i < resources.length; i++)
|
|
// {
|
|
// comparsion = Codec.compareResource(resources[i - 1], resources[i], connection);
|
|
// rt.addUint8(comparsion);
|
|
// if (comparsion == ResourceComparisonResult.Local)
|
|
// rt.addUint32(resources[i]._p.instanceId);
|
|
// else if (comparsion == ResourceComparisonResult.Distributed)
|
|
// rt.addUint32(resources[i].instance.id);
|
|
// }
|
|
// if (prependLength)
|
|
// rt.addUint32(rt.length, 0);
|
|
// return rt.toArray();
|
|
// }
|
|
// static getDataType(value, connection) {
|
|
// switch (typeof value) {
|
|
// case "number":
|
|
// // float or ?
|
|
// if (Math.floor(value) == value) {
|
|
// if (value > 0) {
|
|
// // larger than byte ?
|
|
// if (value > 0xFF) {
|
|
// // larger than short ?
|
|
// if (value > 0xFFFF) {
|
|
// // larger than int ?
|
|
// if (value > 0xFFFFFFFF) {
|
|
// return DataType.UInt64;
|
|
// }
|
|
// else {
|
|
// return DataType.UInt32;
|
|
// }
|
|
// }
|
|
// else {
|
|
// return DataType.UInt16;
|
|
// }
|
|
// }
|
|
// else {
|
|
// return DataType.UInt8;
|
|
// }
|
|
// }
|
|
// else {
|
|
// if (value < -128) {
|
|
// if (value < -32768) {
|
|
// if (value < -2147483648) {
|
|
// return DataType.Int64;
|
|
// }
|
|
// else {
|
|
// return DataType.Int32;
|
|
// }
|
|
// }
|
|
// else {
|
|
// return DataType.Int16;
|
|
// }
|
|
// }
|
|
// else {
|
|
// return DataType.Int8;
|
|
// }
|
|
// }
|
|
// }
|
|
// else {
|
|
// // float or double
|
|
// return DataType.Float64;
|
|
// }
|
|
// case "string":
|
|
// return DataType.String;
|
|
// case "boolean":
|
|
// return DataType.Bool;
|
|
// case "object":
|
|
// if (value instanceof Array) {
|
|
// return DataType.VarArray;
|
|
// }
|
|
// else if (value instanceof IResource) {
|
|
// return Codec.isLocalResource(value, connection) ? DataType.Resource : DataType.DistributedResource;
|
|
// }
|
|
// else if (value instanceof Date) {
|
|
// return DataType.DateTime;
|
|
// }
|
|
// else if (value instanceof Uint8Array
|
|
// || value instanceof ArrayBuffer) {
|
|
// return DataType.UInt8Array;
|
|
// }
|
|
// else if (value instanceof Uint16Array)
|
|
// return DataType.UInt16Array;
|
|
// else if (value instanceof Uint32Array)
|
|
// return DataType.UInt32Array;
|
|
// else if (value instanceof Int16Array)
|
|
// return DataType.Int16Array;
|
|
// else if (value instanceof Int32Array)
|
|
// return DataType.Int32Array;
|
|
// else if (value instanceof Float32Array)
|
|
// return DataType.Float32Array;
|
|
// else if (value instanceof Float64Array)
|
|
// return DataType.Float64Array;
|
|
// else if (value instanceof Number) {
|
|
// // JS numbers are always 64-bit float
|
|
// return DataType.Float64;
|
|
// }
|
|
// else if (value instanceof Structure) {
|
|
// return DataType.Structure;
|
|
// }
|
|
// else if (value instanceof IRecord){
|
|
// return DataType.Record;
|
|
// }
|
|
// else {
|
|
// return DataType.Void
|
|
// }
|
|
// default:
|
|
// return DataType.Void;
|
|
// }
|
|
// }
|
|
// /// <summary>
|
|
// /// Parse an array of structures
|
|
// /// </summary>
|
|
// /// <param name="data">Bytes array</param>
|
|
// /// <param name="offset">Zero-indexed offset</param>
|
|
// /// <param name="length">Number of bytes to parse</param>
|
|
// /// <param name="connection">DistributedConnection is required in case a structure in the array holds items at the other end</param>
|
|
// /// <returns>Array of structures</returns>
|
|
// static parseStructureArray(data, offset, length, connection)
|
|
// {
|
|
// var reply = new AsyncBag();
|
|
// if (length == 0)
|
|
// {
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// var end = offset + length;
|
|
// var result = data[offset++];
|
|
// var previous = null;
|
|
// //var previousKeys = [];
|
|
// //var previousTypes = [];
|
|
// var metadata = {keys: null, types: null};
|
|
// if (result == StructureComparisonResult.Null)
|
|
// previous = new AsyncReply(null);
|
|
// else if (result == StructureComparisonResult.Structure)
|
|
// {
|
|
// var cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// previous = Codec.parseStructure(data, offset, cs, connection, metadata);
|
|
// offset += cs;
|
|
// }
|
|
// reply.add(previous);
|
|
// while (offset < end)
|
|
// {
|
|
// result = data[offset++];
|
|
// if (result == StructureComparisonResult.Null)
|
|
// previous = new AsyncReply(null);
|
|
// else if (result == StructureComparisonResult.Structure)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// previous = Codec.parseStructure(data, offset, cs, connection, metadata);
|
|
// offset += cs;
|
|
// }
|
|
// else if (result == StructureComparisonResult.StructureSameKeys)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// previous = Codec.parseStructure(data, offset, cs, connection, metadata, metadata.keys);
|
|
// offset += cs;
|
|
// }
|
|
// else if (result == StructureComparisonResult.StructureSameTypes)
|
|
// {
|
|
// let cs = data.getUint32(offset);
|
|
// offset += 4;
|
|
// previous = Codec.parseStructure(data, offset, cs, connection, metadata, metadata.keys, metadata.types);
|
|
// offset += cs;
|
|
// }
|
|
// reply.add(previous);
|
|
// }
|
|
// reply.seal();
|
|
// return reply;
|
|
// }
|
|
// }
|
|
var CodecComposeResults = //final int transmissionTypeIdentifier;
|
|
//final DC data;
|
|
function CodecComposeResults(transmissionTypeIdentifier, data) {
|
|
_classCallCheck(this, CodecComposeResults);
|
|
|
|
this.transmissionTypeIdentifier = transmissionTypeIdentifier;
|
|
this.data = data;
|
|
};
|
|
|
|
exports.CodecComposeResults = CodecComposeResults;
|
|
|
|
var CodecParseResults = //final AsyncReply reply;
|
|
//final int size;
|
|
function CodecParseResults(size, reply) {
|
|
_classCallCheck(this, CodecParseResults);
|
|
|
|
this.size = size;
|
|
this.reply = reply;
|
|
};
|
|
|
|
exports.CodecParseResults = CodecParseResults;
|
|
|
|
var Codec = /*#__PURE__*/function () {
|
|
function Codec() {
|
|
_classCallCheck(this, Codec);
|
|
}
|
|
|
|
_createClass(Codec, null, [{
|
|
key: "parse",
|
|
value: //AsyncReply Parser(byte[] data, uint offset, uint length, DistributedConnection connection);
|
|
/// <summary>
|
|
/// Parse a value
|
|
/// </summary>
|
|
/// <param name="data">Bytes array</param>
|
|
/// <param name="offset">Zero-indexed offset.</param>
|
|
/// <param name="size">Output the number of bytes parsed</param>
|
|
/// <param name="connection">DistributedConnection is required in case a structure in the array holds items at the other end.</param>
|
|
/// <param name="dataType">DataType, in case the data is not prepended with DataType</param>
|
|
/// <returns>Value</returns>
|
|
function parse(data, offset, connection) {
|
|
var dataType = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
|
|
var len = 0;
|
|
|
|
if (dataType == null) {
|
|
var _dataType$offset, _dataType;
|
|
|
|
var parsedDataTyped = _TransmissionType.TransmissionType.parse(data, offset, data.length);
|
|
|
|
len = parsedDataTyped.size;
|
|
dataType = parsedDataTyped.type;
|
|
offset = (_dataType$offset = (_dataType = dataType) === null || _dataType === void 0 ? void 0 : _dataType.offset) !== null && _dataType$offset !== void 0 ? _dataType$offset : 0;
|
|
} else len = dataType.contentLength;
|
|
|
|
if (dataType != null) {
|
|
if (dataType.classType == _TransmissionType.TransmissionTypeClass.Fixed) {
|
|
return new CodecParseResults(len, Codec.fixedParsers[dataType.exponent][dataType.index](data, dataType.offset, dataType.contentLength, connection));
|
|
} else if (dataType.classType == _TransmissionType.TransmissionTypeClass.Dynamic) {
|
|
return new CodecParseResults(len, Codec.dynamicParsers[dataType.index](data, dataType.offset, dataType.contentLength, connection));
|
|
} else //if (tt.Class == TransmissionTypeClass.Typed)
|
|
{
|
|
return new CodecParseResults(len, Codec.typedParsers[dataType.index](data, dataType.offset, dataType.contentLength, connection));
|
|
}
|
|
}
|
|
|
|
throw Error("Can't parse transmission type.");
|
|
}
|
|
}, {
|
|
key: "mapFromObject",
|
|
value: function mapFromObject(map) {
|
|
var rt = new Map();
|
|
|
|
for (var i in map) {
|
|
rt.set(i, map[i]);
|
|
}
|
|
}
|
|
}, {
|
|
key: "getListType",
|
|
value: function getListType(list) {
|
|
if (list instanceof _TypedList["default"]) return _TypedList["default"].getType(list);else return Object;
|
|
}
|
|
}, {
|
|
key: "getMapTypes",
|
|
value: function getMapTypes(map) {
|
|
if (map instanceof _TypedMap["default"]) return _TypedMap["default"].getTypes(map);else return [Object, Object];
|
|
} /// <summary>
|
|
/// Compose a variable
|
|
/// </summary>
|
|
/// <param name="value">Value to compose.</param>
|
|
/// <param name="connection">DistributedConnection is required to check locality.</param>
|
|
/// <param name="prependType">If True, prepend the DataType at the beginning of the output.</param>
|
|
/// <returns>Array of bytes in the network byte order.</returns>
|
|
|
|
}, {
|
|
key: "compose",
|
|
value: function compose(valueOrSource, connection) {
|
|
if (valueOrSource == null) return _TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC.DC(0));
|
|
var type = valueOrSource.constructor; // if (type.)
|
|
// {
|
|
// var genericType = type.GetGenericTypeDefinition();
|
|
// if (genericType == typeof(DistributedPropertyContext<>))
|
|
// {
|
|
// valueOrSource = ((IDistributedPropertyContext)valueOrSource).GetValue(connection);
|
|
// }
|
|
// else if (genericType == typeof(Func<>))
|
|
// {
|
|
// var args = genericType.GetGenericArguments();
|
|
// if (args.Length == 2 && args[0] == typeof(DistributedConnection))
|
|
// {
|
|
// //Func<DistributedConnection, DistributedConnection> a;
|
|
// //a.Invoke()
|
|
// }
|
|
// }
|
|
// }
|
|
// if (valueOrSource is IUserType)
|
|
// valueOrSource = (valueOrSource as IUserType).Get();
|
|
//if (valueOrSource is Func<DistributedConnection, object>)
|
|
// valueOrSource = (valueOrSource as Func<DistributedConnection, object>)(connection);
|
|
// if (valueOrSource == null)
|
|
// return TransmissionType.Compose(TransmissionTypeIdentifier.Null, null);
|
|
// type = valueOrSource.GetType();
|
|
|
|
if (this.composers[type] != undefined) {
|
|
var results = this.composers[type](valueOrSource, connection);
|
|
return _TransmissionType.TransmissionType.compose(results.identifier, results.data);
|
|
} else {
|
|
if (valueOrSource instanceof _TypedList["default"]) {
|
|
var genericType = this.getListType(valueOrSource);
|
|
|
|
var _results = _DataSerializer["default"].typedListComposer(valueOrSource, genericType, connection);
|
|
|
|
return _TransmissionType.TransmissionType.compose(_results.identifier, _results.data);
|
|
} else if (valueOrSource instanceof _TypedMap["default"]) {
|
|
var genericTypes = _TypedMap["default"].getTypes(valueOrSource);
|
|
|
|
var _results2 = _DataSerializer["default"].typedMapComposer(valueOrSource, genericTypes[0], genericTypes[1], connection);
|
|
|
|
return _TransmissionType.TransmissionType.compose(_results2.identifier, _results2.data);
|
|
} else if (valueOrSource instanceof _IResource["default"]) {
|
|
var _results3 = _DataSerializer["default"].resourceComposer(valueOrSource, connection);
|
|
|
|
return _TransmissionType.TransmissionType.compose(_results3.identifier, _results3.data);
|
|
} else if (valueOrSource instanceof _IRecord["default"]) {
|
|
var _results4 = _DataSerializer["default"].recordComposer(valueOrSource, connection);
|
|
|
|
return _TransmissionType.TransmissionType.compose(_results4.identifier, _results4.data);
|
|
} else if (valueOrSource instanceof _IEnum["default"]) {
|
|
var _results5 = _DataSerializer["default"].enumComposer(valueOrSource, connection);
|
|
|
|
return _TransmissionType.TransmissionType.compose(_results5.identifier, _results5.data);
|
|
} else if (valueOrSource instanceof _Tuple["default"]) {
|
|
var _results6 = _DataSerializer["default"].tupleComposer(valueOrSource, connection);
|
|
|
|
return _TransmissionType.TransmissionType.compose(_results6.identifier, _results6.data);
|
|
}
|
|
}
|
|
|
|
return _TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC.DC(0));
|
|
} /// <summary>
|
|
/// Check if a resource is local to a given connection.
|
|
/// </summary>
|
|
/// <param name="resource">Resource to check.</param>
|
|
/// <param name="connection">DistributedConnection to check if the resource is local to it.</param>
|
|
/// <returns>True, if the resource owner is the given connection, otherwise False.</returns>
|
|
|
|
}, {
|
|
key: "isLocalResource",
|
|
value: function isLocalResource(resource, connection) {
|
|
if (connection == null) return false;
|
|
|
|
if (resource instanceof _DistributedResource["default"]) {
|
|
if (resource.connection == connection) return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}]);
|
|
|
|
return Codec;
|
|
}();
|
|
|
|
exports["default"] = Codec;
|
|
|
|
_defineProperty(Codec, "fixedParsers", [[_DataDeserializer["default"].nullParser, _DataDeserializer["default"].booleanFalseParser, _DataDeserializer["default"].booleanTrueParser, _DataDeserializer["default"].notModifiedParser], [_DataDeserializer["default"].byteParser, _DataDeserializer["default"].sByteParser, _DataDeserializer["default"].char8Parser], [_DataDeserializer["default"].int16Parser, _DataDeserializer["default"].uInt16Parser, _DataDeserializer["default"].char16Parser], [_DataDeserializer["default"].int32Parser, _DataDeserializer["default"].uInt32Parser, _DataDeserializer["default"].float32Parser, _DataDeserializer["default"].resourceParser, _DataDeserializer["default"].localResourceParser], [_DataDeserializer["default"].int64Parser, _DataDeserializer["default"].uInt64Parser, _DataDeserializer["default"].float64Parser, _DataDeserializer["default"].dateTimeParser], [_DataDeserializer["default"].int128Parser, // int 128
|
|
_DataDeserializer["default"].uInt128Parser, // uint 128
|
|
_DataDeserializer["default"].float128Parser]]);
|
|
|
|
_defineProperty(Codec, "dynamicParsers", [_DataDeserializer["default"].rawDataParser, _DataDeserializer["default"].stringParser, _DataDeserializer["default"].listParser, _DataDeserializer["default"].resourceListParser, _DataDeserializer["default"].recordListParser]);
|
|
|
|
_defineProperty(Codec, "typedParsers", [_DataDeserializer["default"].recordParser, _DataDeserializer["default"].typedListParser, _DataDeserializer["default"].typedMapParser, _DataDeserializer["default"].tupleParser, _DataDeserializer["default"].enumParser, _DataDeserializer["default"].constantParser]);
|
|
|
|
_defineProperty(Codec, "composers", (_defineProperty2 = {}, _defineProperty(_defineProperty2, Boolean, _DataSerializer["default"].boolComposer), _defineProperty(_defineProperty2, _NotModified["default"], _DataSerializer["default"].notModifiedComposer), _defineProperty(_defineProperty2, _ExtendedTypes.Char8, _DataSerializer["default"].char8Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Char16, _DataSerializer["default"].char16Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Int64, _DataSerializer["default"].int64Composer), _defineProperty(_defineProperty2, _ExtendedTypes.UInt64, _DataSerializer["default"].uInt64Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Int32, _DataSerializer["default"].int32Composer), _defineProperty(_defineProperty2, _ExtendedTypes.UInt32, _DataSerializer["default"].uInt32Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Int16, _DataSerializer["default"].int16Composer), _defineProperty(_defineProperty2, _ExtendedTypes.UInt16, _DataSerializer["default"].uInt16Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Int8, _DataSerializer["default"].int8Composer), _defineProperty(_defineProperty2, _ExtendedTypes.UInt8, _DataSerializer["default"].uInt8Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Float32, _DataSerializer["default"].float32Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Float64, _DataSerializer["default"].float64Composer), _defineProperty(_defineProperty2, _ExtendedTypes.Float128, _DataSerializer["default"].float128Composer), _defineProperty(_defineProperty2, Number, _DataSerializer["default"].numberComposer), _defineProperty(_defineProperty2, Date, _DataSerializer["default"].dateTimeComposer), _defineProperty(_defineProperty2, _DC.DC, _DataSerializer["default"].rawDataComposer), _defineProperty(_defineProperty2, Uint8Array, _DataSerializer["default"].rawDataComposer), _defineProperty(_defineProperty2, String, _DataSerializer["default"].stringComposer), _defineProperty(_defineProperty2, Array, _DataSerializer["default"].listComposer), _defineProperty(_defineProperty2, _ResourceArray["default"], _DataSerializer["default"].resourceListComposer), _defineProperty(_defineProperty2, _RecordArray["default"], _DataSerializer["default"].recordListComposer), _defineProperty(_defineProperty2, Map, _DataSerializer["default"].mapComposer), _defineProperty(_defineProperty2, _PropertyValueArray["default"], _DataSerializer["default"].propertyValueArrayComposer), _defineProperty2));
|
|
|
|
},{"../Core/AsyncBag.js":2,"../Core/AsyncReply.js":5,"../Net/IIP/DistributedPropertyContext.js":43,"../Net/IIP/DistributedResource.js":44,"../Resource/IResource.js":70,"../Resource/Template/TemplateType.js":82,"../Resource/Warehouse.js":84,"./BinaryList.js":13,"./DC.js":15,"./DataDeserializer.js":16,"./DataSerializer.js":17,"./DataType.js":18,"./ExtendedTypes.js":19,"./IEnum.js":21,"./IRecord.js":22,"./KeyList.js":23,"./NotModified.js":24,"./PropertyValue.js":26,"./PropertyValueArray.js":27,"./Record.js":28,"./RecordArray.js":29,"./RecordComparisonResult.js":30,"./ResourceArray.js":32,"./ResourceArrayType.js":33,"./ResourceComparisonResult.js":34,"./Structure.js":35,"./StructureArray.js":36,"./StructureComparisonResult.js":37,"./TransmissionType.js":38,"./Tuple.js":39,"./TypedList.js":40,"./TypedMap.js":41}],15:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.BL = BL;
|
|
exports.DC = exports["default"] = exports.Endian = exports.TWO_PWR_32 = exports.UNIX_EPOCH = void 0;
|
|
|
|
var _BinaryList = _interopRequireDefault(require("./BinaryList.js"));
|
|
|
|
var _Guid = _interopRequireDefault(require("./Guid.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var UNIX_EPOCH = 621355968000000000;
|
|
exports.UNIX_EPOCH = UNIX_EPOCH;
|
|
var TWO_PWR_32 = (1 << 16) * (1 << 16);
|
|
exports.TWO_PWR_32 = TWO_PWR_32;
|
|
var Endian = {
|
|
Big: 0,
|
|
Little: 1
|
|
};
|
|
exports.Endian = Endian;
|
|
|
|
var DC = /*#__PURE__*/function (_Uint8Array) {
|
|
_inherits(DC, _Uint8Array);
|
|
|
|
var _super = _createSuper(DC);
|
|
|
|
function DC(bufferOrSize) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, DC);
|
|
|
|
_this = _super.call(this, bufferOrSize); //if (bufferOrSize instanceof ArrayBuffer) {
|
|
// this.buffer = bufferOrSize;
|
|
//}
|
|
//else
|
|
//{
|
|
// this.buffer = new Uint8Array(bufferOrSize);
|
|
//}
|
|
|
|
_this.dv = new DataView(_this.buffer);
|
|
return _this;
|
|
}
|
|
|
|
_createClass(DC, [{
|
|
key: "append",
|
|
value: function append(src, offset, length) {
|
|
if (!(src instanceof DC)) src = new DC(src);
|
|
var appendix = src.clip(offset, length);
|
|
var rt = new DC(this.length + appendix.length);
|
|
rt.set(this, 0);
|
|
rt.set(appendix, this.length);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "clip",
|
|
value: function clip(offset, length) {
|
|
return this.slice(offset, offset + length);
|
|
}
|
|
}, {
|
|
key: "getInt8",
|
|
value: function getInt8(offset) {
|
|
return this.dv.getUint8(offset);
|
|
}
|
|
}, {
|
|
key: "getUint8",
|
|
value: function getUint8(offset) {
|
|
return this[offset]; // this.dv.getUint8(offset);
|
|
}
|
|
}, {
|
|
key: "getInt16",
|
|
value: function getInt16(offset, endian) {
|
|
return this.dv.getInt16(offset, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "getUint16",
|
|
value: function getUint16(offset, endian) {
|
|
return this.dv.getUint16(offset, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "getInt32",
|
|
value: function getInt32(offset, endian) {
|
|
return this.dv.getInt32(offset, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "getUint32",
|
|
value: function getUint32(offset, endian) {
|
|
return this.dv.getUint32(offset, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "getFloat32",
|
|
value: function getFloat32(offset, endian) {
|
|
return this.dv.getFloat32(offset, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "getFloat64",
|
|
value: function getFloat64(offset, endian) {
|
|
return this.dv.getFloat64(offset, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "setInt8",
|
|
value: function setInt8(offset, value) {
|
|
return this.dv.setInt8(offset, value);
|
|
}
|
|
}, {
|
|
key: "setUint8",
|
|
value: function setUint8(offset, value) {
|
|
return this.dv.setUint8(offset, value);
|
|
}
|
|
}, {
|
|
key: "setInt16",
|
|
value: function setInt16(offset, value, endian) {
|
|
return this.dv.setInt16(offset, value, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "setUint16",
|
|
value: function setUint16(offset, value, endian) {
|
|
return this.dv.setUint16(offset, value, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "setInt32",
|
|
value: function setInt32(offset, value, endian) {
|
|
return this.dv.setInt32(offset, value, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "setUint32",
|
|
value: function setUint32(offset, value, endian) {
|
|
return this.dv.setUint32(offset, value, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "setFloat32",
|
|
value: function setFloat32(offset, value, endian) {
|
|
return this.dv.setFloat32(offset, value, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "setFloat64",
|
|
value: function setFloat64(offset, value, endian) {
|
|
return this.dv.setFloat64(offset, value, endian != Endian.Big);
|
|
}
|
|
}, {
|
|
key: "getInt8Array",
|
|
value: function getInt8Array(offset, length) {
|
|
return new Int8Array(this.buffer, offset, length);
|
|
}
|
|
}, {
|
|
key: "getUint8Array",
|
|
value: function getUint8Array(offset, length) {
|
|
return new Uint8Array(this.buffer, offset, length);
|
|
}
|
|
}, {
|
|
key: "copy",
|
|
value: function copy(offset, length, elementSize, func, dstType, endian) {
|
|
var rt = new dstType(length / elementSize);
|
|
var d = 0,
|
|
end = offset + length;
|
|
|
|
for (var i = offset; i < end; i += elementSize) {
|
|
rt[d++] = func.call(this, i, endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "paste",
|
|
value: function paste(offset, length, elementSize, func) {
|
|
var rt = new dstType(length / elementSize);
|
|
var d = 0,
|
|
end = offset + length;
|
|
|
|
for (var i = offset; i < end; i += elementSize) {
|
|
rt[d++] = func.call(this, i);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getInt16Array",
|
|
value: function getInt16Array(offset, length, endian) {
|
|
return this.copy(offset, length, 2, this.getInt16, Int16Array, endian); //return new Int16Array(this.clip(offset, length).buffer);
|
|
}
|
|
}, {
|
|
key: "getUint16Array",
|
|
value: function getUint16Array(offset, length, endian) {
|
|
return this.copy(offset, length, 2, this.getUint16, Uint16Array, endian);
|
|
}
|
|
}, {
|
|
key: "getInt32Array",
|
|
value: function getInt32Array(offset, length, endian) {
|
|
return this.copy(offset, length, 4, this.getInt32, Int32Array, endian);
|
|
}
|
|
}, {
|
|
key: "getUint32Array",
|
|
value: function getUint32Array(offset, length, endian) {
|
|
return this.copy(offset, length, 4, this.getUint32, Uint32Array, endian);
|
|
}
|
|
}, {
|
|
key: "getFloat32Array",
|
|
value: function getFloat32Array(offset, length, endian) {
|
|
return this.copy(offset, length, 4, this.getFloat32, Float32Array, endian);
|
|
}
|
|
}, {
|
|
key: "getFloat64Array",
|
|
value: function getFloat64Array(offset, length, endian) {
|
|
return this.copy(offset, length, 8, this.getFloat64, Float64Array, endian);
|
|
}
|
|
}, {
|
|
key: "getInt64Array",
|
|
value: function getInt64Array(offset, length, endian) {
|
|
return this.copy(offset, length, 8, this.getInt64, Float64Array, endian);
|
|
}
|
|
}, {
|
|
key: "getUint64Array",
|
|
value: function getUint64Array(offset, length, endian) {
|
|
return this.copy(offset, length, 8, this.getUint64, Float64Array, endian);
|
|
}
|
|
}, {
|
|
key: "getBoolean",
|
|
value: function getBoolean(offset) {
|
|
return this.getUint8(offset) > 0;
|
|
}
|
|
}, {
|
|
key: "setBoolean",
|
|
value: function setBoolean(offset, value) {
|
|
this.setUint8(offset, value ? 1 : 0);
|
|
}
|
|
}, {
|
|
key: "getBooleanArray",
|
|
value: function getBooleanArray(offset, length) {
|
|
var rt = [];
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
rt.push(this.getBoolean(offset + i));
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getChar",
|
|
value: function getChar(offset, endian) {
|
|
return String.fromCharCode(this.getUint16(offset, endian));
|
|
}
|
|
}, {
|
|
key: "setChar",
|
|
value: function setChar(offset, value, endian) {
|
|
this.setUint16(offset, value.charCodeAt(0), endian);
|
|
}
|
|
}, {
|
|
key: "getCharArray",
|
|
value: function getCharArray(offset, length, endian) {
|
|
var rt = [];
|
|
|
|
for (var i = 0; i < length; i += 2) {
|
|
rt.push(this.getChar(offset + i, endian));
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getHex",
|
|
value: function getHex(offset, length) {
|
|
var rt = "";
|
|
|
|
for (var i = offset; i < offset + length; i++) {
|
|
var h = this[i].toString(16);
|
|
rt += h.length == 1 ? "0" + h : h;
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getString",
|
|
value: function getString(offset, length) {
|
|
if (typeof StringView != "undefined") return new StringView(this.buffer, "UTF-8", offset, length);else {
|
|
var bytes = this.getUint8Array(offset, length);
|
|
var encodedString = String.fromCharCode.apply(null, bytes),
|
|
decodedString = decodeURIComponent(escape(encodedString));
|
|
return decodedString;
|
|
}
|
|
}
|
|
}, {
|
|
key: "getStringArray",
|
|
value: function getStringArray(offset, length, endian) {
|
|
var rt = [];
|
|
var i = 0;
|
|
|
|
while (i < length) {
|
|
var cl = this.getUint32(offset + i, endian);
|
|
i += 4;
|
|
rt.push(this.getString(offset + i, cl));
|
|
i += cl;
|
|
}
|
|
|
|
return rt;
|
|
} // @TODO: Test numbers with bit 7 of h = 1
|
|
|
|
}, {
|
|
key: "getInt64",
|
|
value: function getInt64(offset, endian) {
|
|
if (endian == Endian.Big) {
|
|
var bi = BigInt(0);
|
|
bi |= BigInt(this[offset++]) << 56n;
|
|
bi |= BigInt(this[offset++]) << 48n;
|
|
bi |= BigInt(this[offset++]) << 40n;
|
|
bi |= BigInt(this[offset++]) << 32n;
|
|
bi |= BigInt(this[offset++]) << 24n;
|
|
bi |= BigInt(this[offset++]) << 16n;
|
|
bi |= BigInt(this[offset++]) << 8n;
|
|
bi |= BigInt(this[offset++]);
|
|
return parseInt(bi);
|
|
} else {
|
|
var _bi = BigInt(0);
|
|
|
|
_bi |= BigInt(this[offset++]);
|
|
_bi |= BigInt(this[offset++]) << 8n;
|
|
_bi |= BigInt(this[offset++]) << 16n;
|
|
_bi |= BigInt(this[offset++]) << 24n;
|
|
_bi |= BigInt(this[offset++]) << 32n;
|
|
_bi |= BigInt(this[offset++]) << 40n;
|
|
_bi |= BigInt(this[offset++]) << 48n;
|
|
_bi |= BigInt(this[offset++]) << 56n;
|
|
return parseInt(_bi);
|
|
} // var h = this.getInt32(offset);
|
|
// var l = this.getInt32(offset + 4);
|
|
// return h * TWO_PWR_32 + ((l >= 0) ? l : TWO_PWR_32 + l);
|
|
|
|
}
|
|
}, {
|
|
key: "getUint64",
|
|
value: function getUint64(offset, endian) {
|
|
if (endian == Endian.Big) {
|
|
var bi = BigInt(0);
|
|
bi |= BigInt(this[offset++]) << 56n;
|
|
bi |= BigInt(this[offset++]) << 48n;
|
|
bi |= BigInt(this[offset++]) << 40n;
|
|
bi |= BigInt(this[offset++]) << 32n;
|
|
bi |= BigInt(this[offset++]) << 24n;
|
|
bi |= BigInt(this[offset++]) << 16n;
|
|
bi |= BigInt(this[offset++]) << 8n;
|
|
bi |= BigInt(this[offset++]);
|
|
return parseInt(bi);
|
|
} else {
|
|
var _bi2 = BigInt(0);
|
|
|
|
_bi2 |= BigInt(this[offset++]);
|
|
_bi2 |= BigInt(this[offset++]) << 8n;
|
|
_bi2 |= BigInt(this[offset++]) << 16n;
|
|
_bi2 |= BigInt(this[offset++]) << 24n;
|
|
_bi2 |= BigInt(this[offset++]) << 32n;
|
|
_bi2 |= BigInt(this[offset++]) << 40n;
|
|
_bi2 |= BigInt(this[offset++]) << 48n;
|
|
_bi2 |= BigInt(this[offset++]) << 56n;
|
|
return parseInt(_bi2);
|
|
} //var h = this.getUint32(offset);
|
|
//var l = this.getUint32(offset + 4);
|
|
//return h * TWO_PWR_32 + ((l >= 0) ? l : TWO_PWR_32 + l);
|
|
|
|
}
|
|
}, {
|
|
key: "setInt64",
|
|
value: function setInt64(offset, value, endian) {
|
|
var bi = BigInt(value);
|
|
|
|
var _byte = BigInt(0xFF);
|
|
|
|
if (endian == Endian.Big) {
|
|
this[offset++] = parseInt(bi >> 56n & _byte);
|
|
this[offset++] = parseInt(bi >> 48n & _byte);
|
|
this[offset++] = parseInt(bi >> 40n & _byte);
|
|
this[offset++] = parseInt(bi >> 32n & _byte);
|
|
this[offset++] = parseInt(bi >> 24n & _byte);
|
|
this[offset++] = parseInt(bi >> 16n & _byte);
|
|
this[offset++] = parseInt(bi >> 8n & _byte);
|
|
this[offset++] = parseInt(bi & _byte);
|
|
} else {
|
|
this[offset++] = parseInt(bi & _byte);
|
|
this[offset++] = parseInt(bi >> 8n & _byte);
|
|
this[offset++] = parseInt(bi >> 16n & _byte);
|
|
this[offset++] = parseInt(bi >> 24n & _byte);
|
|
this[offset++] = parseInt(bi >> 32n & _byte);
|
|
this[offset++] = parseInt(bi >> 40n & _byte);
|
|
this[offset++] = parseInt(bi >> 48n & _byte);
|
|
this[offset++] = parseInt(bi >> 56n & _byte);
|
|
} //var l = (value % TWO_PWR_32) | 0;
|
|
//var h = (value / TWO_PWR_32) | 0;
|
|
//this.setInt32(offset, h);
|
|
//this.setInt32(offset + 4, l);
|
|
|
|
}
|
|
}, {
|
|
key: "setUint64",
|
|
value: function setUint64(offset, value, endian) {
|
|
var bi = BigInt(value);
|
|
|
|
var _byte2 = BigInt(0xFF);
|
|
|
|
if (endian == Endian.Big) {
|
|
this[offset++] = parseInt(bi >> 56n & _byte2);
|
|
this[offset++] = parseInt(bi >> 48n & _byte2);
|
|
this[offset++] = parseInt(bi >> 40n & _byte2);
|
|
this[offset++] = parseInt(bi >> 32n & _byte2);
|
|
this[offset++] = parseInt(bi >> 24n & _byte2);
|
|
this[offset++] = parseInt(bi >> 16n & _byte2);
|
|
this[offset++] = parseInt(bi >> 8n & _byte2);
|
|
this[offset++] = parseInt(bi & _byte2);
|
|
} else {
|
|
this[offset++] = parseInt(bi & _byte2);
|
|
this[offset++] = parseInt(bi >> 8n & _byte2);
|
|
this[offset++] = parseInt(bi >> 16n & _byte2);
|
|
this[offset++] = parseInt(bi >> 24n & _byte2);
|
|
this[offset++] = parseInt(bi >> 32n & _byte2);
|
|
this[offset++] = parseInt(bi >> 40n & _byte2);
|
|
this[offset++] = parseInt(bi >> 48n & _byte2);
|
|
this[offset++] = parseInt(bi >> 56n & _byte2);
|
|
} // var l = (value % TWO_PWR_32) | 0;
|
|
// var h = (value / TWO_PWR_32) | 0;
|
|
// this.setInt32(offset, h);
|
|
// this.setInt32(offset + 4, l);
|
|
|
|
}
|
|
}, {
|
|
key: "setDateTime",
|
|
value: function setDateTime(offset, value, endian) {
|
|
// Unix Epoch
|
|
var ticks = 621355968000000000 + value.getTime() * 10000;
|
|
this.setUint64(offset, ticks, endian);
|
|
}
|
|
}, {
|
|
key: "getDateTime",
|
|
value: function getDateTime(offset, endian) {
|
|
var ticks = this.getUint64(offset, endian);
|
|
return new Date(Math.round((ticks - UNIX_EPOCH) / 10000));
|
|
}
|
|
}, {
|
|
key: "getDateTimeArray",
|
|
value: function getDateTimeArray(offset, endian) {
|
|
var rt = [];
|
|
|
|
for (var i = 0; i < length; i += 8) {
|
|
rt.push(this.getDateTime(offset + i, endian));
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getGuid",
|
|
value: function getGuid(offset) {
|
|
return new _Guid["default"](this.clip(offset, 16));
|
|
/*
|
|
var d = this.getUint8Array(offset, 16);
|
|
var rt = "";
|
|
for (var i = 0; i < 16; i++) {
|
|
rt += String.fromCharCode(d[i]);
|
|
}
|
|
return btoa(rt);
|
|
*/
|
|
}
|
|
}, {
|
|
key: "getGuidArray",
|
|
value: function getGuidArray(offset, length) {
|
|
var rt = [];
|
|
|
|
for (var i = 0; i < length; i += 16) {
|
|
rt.push(this.getGuid(offset + i));
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "sequenceEqual",
|
|
value: function sequenceEqual(ar) {
|
|
if (ar.length != this.length) return false;else {
|
|
for (var i = 0; i < this.length; i++) {
|
|
if (ar[i] != this[i]) return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}], [{
|
|
key: "boolToBytes",
|
|
value: function boolToBytes(value) {
|
|
var rt = new DC(1);
|
|
rt.setBoolean(0, value);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int8ToBytes",
|
|
value: function int8ToBytes(value) {
|
|
var rt = new DC(1);
|
|
rt.setInt8(0, value);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "fromList",
|
|
value: function fromList(list) {
|
|
return new DC(list);
|
|
}
|
|
}, {
|
|
key: "hexToBytes",
|
|
value: function hexToBytes(value) {
|
|
// convert hex to Uint8Array
|
|
var rt = new DC(value.length / 2);
|
|
|
|
for (var i = 0; i < rt.length; i++) {
|
|
rt[i] = parseInt(value.substr(i * 2, 2), 16);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "uint8ToBytes",
|
|
value: function uint8ToBytes(value) {
|
|
var rt = new DC(1);
|
|
rt.setUint8(0, value);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "charToBytes",
|
|
value: function charToBytes(value, endian) {
|
|
var rt = new DC(2);
|
|
rt.setChar(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int16ToBytes",
|
|
value: function int16ToBytes(value, endian) {
|
|
var rt = new DC(2);
|
|
rt.setInt16(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "uint16ToBytes",
|
|
value: function uint16ToBytes(value, endian) {
|
|
var rt = new DC(2);
|
|
rt.setUint16(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int32ToBytes",
|
|
value: function int32ToBytes(value, endian) {
|
|
var rt = new DC(4);
|
|
rt.setInt32(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "uint32ToBytes",
|
|
value: function uint32ToBytes(value, endian) {
|
|
var rt = new DC(4);
|
|
rt.setUint32(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "float32ToBytes",
|
|
value: function float32ToBytes(value, endian) {
|
|
var rt = new DC(4);
|
|
rt.setFloat32(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int64ToBytes",
|
|
value: function int64ToBytes(value, endian) {
|
|
var rt = new DC(8);
|
|
rt.setInt64(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "uint64ToBytes",
|
|
value: function uint64ToBytes(value, endian) {
|
|
var rt = new DC(8);
|
|
rt.setUint64(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "float64ToBytes",
|
|
value: function float64ToBytes(value, endian) {
|
|
var rt = new DC(8);
|
|
rt.setFloat64(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "dateTimeToBytes",
|
|
value: function dateTimeToBytes(value, endian) {
|
|
var rt = new DC(8);
|
|
rt.setDateTime(0, value, endian);
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "stringToBytes",
|
|
value: function stringToBytes(value) {
|
|
var utf8 = unescape(encodeURIComponent(value));
|
|
var rt = [];
|
|
|
|
for (var i = 0; i < utf8.length; i++) {
|
|
rt.push(utf8.charCodeAt(i));
|
|
}
|
|
|
|
return new DC(rt);
|
|
}
|
|
}, {
|
|
key: "stringArrayToBytes",
|
|
value: function stringArrayToBytes(values) {
|
|
var list = new _BinaryList["default"]();
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
var s = DC.stringToBytes(values[i]);
|
|
list.addUint32(s.length).addUint8Array(s);
|
|
}
|
|
|
|
return list.toArray();
|
|
}
|
|
}, {
|
|
key: "uint16ArrayToBytes",
|
|
value: function uint16ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 2);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setUint16(i * 2, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int16ArrayToBytes",
|
|
value: function int16ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 2);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setInt16(i * 2, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "uint32ArrayToBytes",
|
|
value: function uint32ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 4);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setUint32(i * 4, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int32ArrayToBytes",
|
|
value: function int32ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 4);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setInt32(i * 4, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "int64ArrayToBytes",
|
|
value: function int64ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 8);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setInt64(i * 8, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "uint64ArrayToBytes",
|
|
value: function uint64ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 8);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setUint64(i * 8, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "float32ArrayToBytes",
|
|
value: function float32ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 4);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setFloat32(i * 4, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "float64ArrayToBytes",
|
|
value: function float64ArrayToBytes(values, endian) {
|
|
var rt = new DC(values.length * 8);
|
|
|
|
for (var i = 0; i < values.length; i++) {
|
|
rt.setFloat64(i * 8, values[i], endian);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "combine",
|
|
value: function combine(a, aOffset, aLength, b, bOffset, bLength) {
|
|
if (!(a instanceof DC)) a = new DC(a);
|
|
if (!(b instanceof DC)) b = new DC(b);
|
|
a = a.clip(aOffset, aLength);
|
|
b = b.clip(bOffset, bLength);
|
|
var rt = new DC(a.length + b.length);
|
|
rt.set(a, 0);
|
|
rt.set(b, a.length);
|
|
return rt;
|
|
}
|
|
}]);
|
|
|
|
return DC;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Uint8Array));
|
|
|
|
exports.DC = exports["default"] = DC;
|
|
|
|
function BL() {
|
|
return new _BinaryList["default"]();
|
|
}
|
|
|
|
;
|
|
|
|
},{"./BinaryList.js":13,"./Guid.js":20}],16:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = exports.PropertyValueParserResults = void 0;
|
|
|
|
var _IEnum = _interopRequireDefault(require("./IEnum.js"));
|
|
|
|
var _Tuple = _interopRequireDefault(require("./Tuple.js"));
|
|
|
|
var _TemplateType = _interopRequireDefault(require("../Resource/Template/TemplateType.js"));
|
|
|
|
var _Warehouse = _interopRequireDefault(require("../Resource/Warehouse.js"));
|
|
|
|
var _AsyncBag = _interopRequireDefault(require("../Core/AsyncBag.js"));
|
|
|
|
var _AsyncReply = _interopRequireDefault(require("../Core/AsyncReply.js"));
|
|
|
|
var _DC = _interopRequireDefault(require("./DC.js"));
|
|
|
|
var _DistributedConnection = _interopRequireDefault(require("../Net/IIP/DistributedConnection.js"));
|
|
|
|
var _NotModified = _interopRequireDefault(require("./NotModified.js"));
|
|
|
|
var _RepresentationType = _interopRequireDefault(require("./RepresentationType.js"));
|
|
|
|
var _Codec = _interopRequireDefault(require("./Codec.js"));
|
|
|
|
var _TypedMap = _interopRequireDefault(require("./TypedMap.js"));
|
|
|
|
var _PropertyValueArray = _interopRequireDefault(require("./PropertyValueArray.js"));
|
|
|
|
var _PropertyValue = _interopRequireDefault(require("./PropertyValue.js"));
|
|
|
|
var _Record = _interopRequireDefault(require("./Record.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
|
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
|
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var PropertyValueParserResults = //final int size;
|
|
///final AsyncReply<PropertyValue> reply;
|
|
function PropertyValueParserResults(size, reply) {
|
|
_classCallCheck(this, PropertyValueParserResults);
|
|
|
|
this.size = size;
|
|
this.reply = reply;
|
|
};
|
|
|
|
exports.PropertyValueParserResults = PropertyValueParserResults;
|
|
|
|
var DataDeserializer = /*#__PURE__*/function () {
|
|
function DataDeserializer() {
|
|
_classCallCheck(this, DataDeserializer);
|
|
}
|
|
|
|
_createClass(DataDeserializer, null, [{
|
|
key: "nullParser",
|
|
value: function nullParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](null);
|
|
}
|
|
}, {
|
|
key: "booleanTrueParser",
|
|
value: function booleanTrueParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](true);
|
|
}
|
|
}, {
|
|
key: "booleanFalseParser",
|
|
value: function booleanFalseParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](false);
|
|
}
|
|
}, {
|
|
key: "notModifiedParser",
|
|
value: function notModifiedParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"]((0, _NotModified["default"])());
|
|
}
|
|
}, {
|
|
key: "byteParser",
|
|
value: function byteParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data[offset]);
|
|
}
|
|
}, {
|
|
key: "sByteParser",
|
|
value: function sByteParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data[offset] > 127 ? data[offset] - 256 : data[offset]);
|
|
}
|
|
}, {
|
|
key: "char16Parser",
|
|
value: function char16Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getChar(offset));
|
|
}
|
|
}, {
|
|
key: "char8Parser",
|
|
value: function char8Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](String.fromCharCode(data[offset]));
|
|
}
|
|
}, {
|
|
key: "int16Parser",
|
|
value: function int16Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getInt16(offset));
|
|
}
|
|
}, {
|
|
key: "uInt16Parser",
|
|
value: function uInt16Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getUint16(offset));
|
|
}
|
|
}, {
|
|
key: "int32Parser",
|
|
value: function int32Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getInt32(offset));
|
|
}
|
|
}, {
|
|
key: "uInt32Parser",
|
|
value: function uInt32Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getUint32(offset));
|
|
}
|
|
}, {
|
|
key: "float32Parser",
|
|
value: function float32Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getFloat32(offset));
|
|
}
|
|
}, {
|
|
key: "float64Parser",
|
|
value: function float64Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getFloat64(offset));
|
|
}
|
|
}, {
|
|
key: "float128Parser",
|
|
value: function float128Parser(data, offset, length, connection) {
|
|
// @TODO
|
|
return new _AsyncReply["default"](data.getFloat64(offset));
|
|
}
|
|
}, {
|
|
key: "int128Parser",
|
|
value: function int128Parser(data, offset, length, connection) {
|
|
// @TODO
|
|
return new _AsyncReply["default"](data.getInt64(offset));
|
|
}
|
|
}, {
|
|
key: "uInt128Parser",
|
|
value: function uInt128Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getUint64(offset));
|
|
}
|
|
}, {
|
|
key: "int64Parser",
|
|
value: function int64Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getInt64(offset));
|
|
}
|
|
}, {
|
|
key: "uInt64Parser",
|
|
value: function uInt64Parser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getUint64(offset));
|
|
}
|
|
}, {
|
|
key: "dateTimeParser",
|
|
value: function dateTimeParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getDateTime(offset));
|
|
}
|
|
}, {
|
|
key: "resourceParser",
|
|
value: function resourceParser(data, offset, length, connection) {
|
|
if (connection != null) {
|
|
var id = data.getUint32(offset);
|
|
return connection.fetch(id);
|
|
}
|
|
|
|
throw Error("Can't parse resource with no connection");
|
|
}
|
|
}, {
|
|
key: "localResourceParser",
|
|
value: function localResourceParser(data, offset, length, connection) {
|
|
var id = data.getUint32(offset);
|
|
return _Warehouse["default"].getById(id);
|
|
}
|
|
}, {
|
|
key: "rawDataParser",
|
|
value: function rawDataParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.clip(offset, length));
|
|
}
|
|
}, {
|
|
key: "stringParser",
|
|
value: function stringParser(data, offset, length, connection) {
|
|
return new _AsyncReply["default"](data.getString(offset, length));
|
|
}
|
|
}, {
|
|
key: "recordParser",
|
|
value: function recordParser(data, offset, length, connection) {
|
|
var reply = new _AsyncReply["default"]();
|
|
var classId = data.getGuid(offset);
|
|
offset += 16;
|
|
length -= 16;
|
|
|
|
var template = _Warehouse["default"].getTemplateByClassId(classId, _TemplateType["default"].Record);
|
|
|
|
if (template != null) {
|
|
listParser(data, offset, length, connection).then(function (ar) {
|
|
var record;
|
|
|
|
if (template.definedType != null) {
|
|
record = _Warehouse["default"].createInstance(template.definedType);
|
|
} else {
|
|
record = (0, _Record["default"])();
|
|
}
|
|
|
|
var kv = new Map();
|
|
|
|
for (var i = 0; i < template.properties.length; i++) {
|
|
kv[template.properties[i].name] = ar[i];
|
|
}
|
|
|
|
record.deserialize(kv);
|
|
reply.trigger(record);
|
|
});
|
|
} else {
|
|
if (connection == null) throw Error("Can't parse record with no connection");
|
|
connection.getTemplate(classId).then(function (tmp) {
|
|
if (tmp == null) reply.triggerError(new Error("Couldn't fetch record template."));
|
|
DataDeserializer.listParser(data, offset, length, connection).then(function (ar) {
|
|
var record = new _Record["default"](); //var kv = new Map();
|
|
|
|
for (var i = 0; i < tmp.properties.length; i++) {
|
|
record[tmp.properties[i].name] = ar[i];
|
|
} //record.deserialize(kv);
|
|
|
|
|
|
reply.trigger(record);
|
|
});
|
|
}).error(function (x) {
|
|
return reply.triggerError(x);
|
|
});
|
|
}
|
|
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "constantParser",
|
|
value: function constantParser(data, offset, length, connection) {
|
|
throw Error("NotImplementedException");
|
|
}
|
|
}, {
|
|
key: "enumParser",
|
|
value: function enumParser(data, offset, length, connection) {
|
|
var classId = data.getGuid(offset);
|
|
offset += 16;
|
|
var index = data[offset++];
|
|
|
|
var template = _Warehouse["default"].getTemplateByClassId(classId, _TemplateType["default"].Enum);
|
|
|
|
if (template != null) {
|
|
if (template.definedType != null) {
|
|
var enumVal = _Warehouse["default"].createInstance(template.definedType);
|
|
|
|
enumVal.index = index;
|
|
enumVal.name = template.constants[index].name;
|
|
enumVal.value = template.constants[index].value;
|
|
return new _AsyncReply["default"].ready(enumVal);
|
|
} else {
|
|
return _AsyncReply["default"].ready((0, _IEnum["default"])(index, template.constants[index].value, template.constants[index].name));
|
|
}
|
|
} else {
|
|
var reply = new _AsyncReply["default"]();
|
|
if (connection == null) throw Error("Can't parse enum with no connection");
|
|
connection.getTemplate(classId).then(function (tmp) {
|
|
if (tmp != null) {
|
|
if (tmp.definedType != null) {
|
|
var enumVal = _Warehouse["default"].createInstance(tmp.definedType);
|
|
|
|
enumVal.index = index;
|
|
enumVal.name = tmp.constants[index].name;
|
|
enumVal.value = tmp.constants[index].value;
|
|
reply.trigger(enumVal);
|
|
} else {
|
|
reply.trigger(new _IEnum["default"](index, tmp.constants[index].value, tmp.constants[index].name));
|
|
}
|
|
} else reply.triggerError(new Error("Template not found for enum"));
|
|
}).error(function (x) {
|
|
return reply.triggerError(x);
|
|
});
|
|
return reply;
|
|
}
|
|
}
|
|
}, {
|
|
key: "recordListParser",
|
|
value: function recordListParser(data, offset, length, connection) {
|
|
var rt = new _AsyncBag["default"]();
|
|
|
|
while (length > 0) {
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
rt.add(parsed.reply);
|
|
|
|
if (parsed.size > 0) {
|
|
offset += parsed.size;
|
|
length -= parsed.size;
|
|
} else throw new Error("Error while parsing structured data");
|
|
}
|
|
|
|
rt.seal();
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "resourceListParser",
|
|
value: function resourceListParser(data, offset, length, connection) {
|
|
var rt = new _AsyncBag["default"]();
|
|
|
|
while (length > 0) {
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
rt.add(parsed.reply);
|
|
|
|
if (parsed.size > 0) {
|
|
offset += parsed.size;
|
|
length -= parsed.size;
|
|
} else throw new Error("Error while parsing structured data");
|
|
}
|
|
|
|
rt.seal();
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "listParser",
|
|
value: function listParser(data, offset, length, connection) {
|
|
var rt = new _AsyncBag["default"]();
|
|
|
|
while (length > 0) {
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
rt.add(parsed.reply);
|
|
|
|
if (parsed.size > 0) {
|
|
offset += parsed.size;
|
|
length -= parsed.size;
|
|
} else throw new Error("Error while parsing structured data");
|
|
}
|
|
|
|
rt.seal();
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "typedMapParser",
|
|
value: function typedMapParser(data, offset, length, connection) {
|
|
// get key type
|
|
var keyRep = _RepresentationType["default"].parse(data, offset);
|
|
|
|
offset += keyRep.size;
|
|
length -= keyRep.size;
|
|
|
|
var valueRep = _RepresentationType["default"].parse(data, offset);
|
|
|
|
offset += valueRep.size;
|
|
length -= valueRep.size;
|
|
var map = new _TypedMap["default"]();
|
|
var rt = new _AsyncReply["default"]();
|
|
var results = new _AsyncBag["default"]();
|
|
|
|
while (length > 0) {
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
results.add(parsed.reply);
|
|
|
|
if (parsed.size > 0) {
|
|
offset += parsed.size;
|
|
length -= parsed.size;
|
|
} else throw new Error("Error while parsing structured data");
|
|
}
|
|
|
|
results.seal();
|
|
results.then(function (ar) {
|
|
for (var i = 0; i < ar.length; i += 2) {
|
|
map.set(ar[i], ar[i + 1]);
|
|
}
|
|
|
|
rt.trigger(map);
|
|
});
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "tupleParser",
|
|
value: function tupleParser(data, offset, length, connection) {
|
|
var results = new _AsyncBag["default"]();
|
|
var rt = new _AsyncReply["default"]();
|
|
var tupleSize = data[offset++];
|
|
length--;
|
|
var types = [];
|
|
|
|
for (var i = 0; i < tupleSize; i++) {
|
|
var _rep$type$getRuntimeT;
|
|
|
|
var rep = _RepresentationType["default"].parse(data, offset);
|
|
|
|
if (rep.type != null) types.push((_rep$type$getRuntimeT = rep.type.getRuntimeType()) !== null && _rep$type$getRuntimeT !== void 0 ? _rep$type$getRuntimeT : Object);
|
|
offset += rep.size;
|
|
length -= rep.size;
|
|
}
|
|
|
|
while (length > 0) {
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
results.add(parsed.reply);
|
|
|
|
if (parsed.size > 0) {
|
|
offset += parsed.size;
|
|
length -= parsed.size;
|
|
} else throw new Error("Error while parsing structured data");
|
|
}
|
|
|
|
results.seal();
|
|
results.then(function (ar) {
|
|
rt.trigger(_construct(_Tuple["default"].of.apply(_Tuple["default"], types), _toConsumableArray(ar)));
|
|
});
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "typedListParser",
|
|
value: function typedListParser(data, offset, length, connection) {
|
|
var rt = new _AsyncBag["default"](); // get the type
|
|
|
|
var rep = _RepresentationType["default"].parse(data, offset);
|
|
|
|
offset += rep.size;
|
|
length -= rep.size;
|
|
var runtimeType = rep.type.getRuntimeType();
|
|
rt.arrayType = runtimeType;
|
|
|
|
while (length > 0) {
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
rt.add(parsed.reply);
|
|
|
|
if (parsed.size > 0) {
|
|
offset += parsed.size;
|
|
length -= parsed.size;
|
|
} else throw new Error("Error while parsing structured data");
|
|
}
|
|
|
|
rt.seal();
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "PropertyValueArrayParser",
|
|
value: function PropertyValueArrayParser(data, offset, length, connection) //, bool ageIncluded = true)
|
|
{
|
|
var rt = new _AsyncBag["default"]();
|
|
DataDeserializer.listParser(data, offset, length, connection).then(function (x) {
|
|
var pvs = new _PropertyValueArray["default"]();
|
|
|
|
for (var i = 0; i < x.length; i += 3) {
|
|
pvs.push(new _PropertyValue["default"](x[2], x[0], x[1]));
|
|
}
|
|
|
|
rt.trigger(pvs);
|
|
});
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "propertyValueParser",
|
|
value: function propertyValueParser(data, offset, connection) //, bool ageIncluded = true)
|
|
{
|
|
var reply = new _AsyncReply["default"]();
|
|
var age = data.getUint64(offset);
|
|
offset += 8;
|
|
var date = data.getDateTime(offset);
|
|
offset += 8;
|
|
|
|
var parsed = _Codec["default"].parse(data, offset, connection);
|
|
|
|
parsed.reply.then(function (value) {
|
|
reply.trigger(new _PropertyValue["default"](value, age, date));
|
|
});
|
|
return new PropertyValueParserResults(16 + parsed.size, reply);
|
|
}
|
|
}, {
|
|
key: "historyParser",
|
|
value: function historyParser(data, offset, length, resource, connection) {
|
|
throw new Error("Not implemented"); // @TODO
|
|
// var list = new KeyList<PropertyTemplate, List<PropertyValue>>();
|
|
// var reply = new AsyncReply<KeyList<PropertyTemplate, List<PropertyValue[]>>>();
|
|
// var bagOfBags = new AsyncBag<PropertyValue[]>();
|
|
// var ends = offset + length;
|
|
// while (offset < ends)
|
|
// {
|
|
// var index = data[offset++];
|
|
// var pt = resource.Instance.Template.GetPropertyTemplateByIndex(index);
|
|
// list.Add(pt, null);
|
|
// var cs = data.GetUInt32(offset);
|
|
// offset += 4;
|
|
// var (len, pv) = PropertyValueParser(data, offset, connection);
|
|
// bagOfBags.Add(pv);// ParsePropertyValueArray(data, offset, cs, connection));
|
|
// offset += len;
|
|
// }
|
|
// bagOfBags.Seal();
|
|
// bagOfBags.Then(x =>
|
|
// {
|
|
// for (var i = 0; i < list.Count; i++)
|
|
// list[list.Keys.ElementAt(i)] = x[i];
|
|
// reply.Trigger(list);
|
|
// });
|
|
// return reply;
|
|
}
|
|
}]);
|
|
|
|
return DataDeserializer;
|
|
}();
|
|
|
|
exports["default"] = DataDeserializer;
|
|
|
|
},{"../Core/AsyncBag.js":2,"../Core/AsyncReply.js":5,"../Net/IIP/DistributedConnection.js":42,"../Resource/Template/TemplateType.js":82,"../Resource/Warehouse.js":84,"./Codec.js":14,"./DC.js":15,"./IEnum.js":21,"./NotModified.js":24,"./PropertyValue.js":26,"./PropertyValueArray.js":27,"./Record.js":28,"./RepresentationType.js":31,"./Tuple.js":39,"./TypedMap.js":41}],17:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = exports.DataSerializerComposeResults = void 0;
|
|
|
|
var _BinaryList = _interopRequireDefault(require("./BinaryList.js"));
|
|
|
|
var _Codec = _interopRequireDefault(require("./Codec.js"));
|
|
|
|
var _Warehouse = _interopRequireDefault(require("../Resource/Warehouse.js"));
|
|
|
|
var _TransmissionType = require("./TransmissionType.js");
|
|
|
|
var _DC = _interopRequireWildcard(require("./DC.js"));
|
|
|
|
var _RepresentationType = _interopRequireDefault(require("./RepresentationType.js"));
|
|
|
|
var _Tuple = _interopRequireDefault(require("./Tuple.js"));
|
|
|
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
|
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
|
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
|
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
|
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var DataSerializerComposeResults = // int identifier;
|
|
//DC data;
|
|
function DataSerializerComposeResults(identifier, data) {
|
|
_classCallCheck(this, DataSerializerComposeResults);
|
|
|
|
this.identifier = identifier;
|
|
this.data = data;
|
|
};
|
|
|
|
exports.DataSerializerComposeResults = DataSerializerComposeResults;
|
|
|
|
var DataSerializer = /*#__PURE__*/function () {
|
|
function DataSerializer() {
|
|
_classCallCheck(this, DataSerializer);
|
|
}
|
|
|
|
_createClass(DataSerializer, null, [{
|
|
key: "historyComposer",
|
|
value: //public delegate byte[] Serializer(object value);
|
|
function historyComposer(history, connection) {
|
|
var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
throw new Error("Not implemented");
|
|
}
|
|
}, {
|
|
key: "int32Composer",
|
|
value: function int32Composer(value, connection) {
|
|
var rt = new _DC["default"](4);
|
|
rt.setInt32(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Int32, rt);
|
|
}
|
|
}, {
|
|
key: "uInt32Composer",
|
|
value: function uInt32Composer(value, connection) {
|
|
var rt = new _DC["default"](4);
|
|
rt.setUint32(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.UInt32, rt);
|
|
}
|
|
}, {
|
|
key: "int16Composer",
|
|
value: function int16Composer(value, connection) {
|
|
var rt = new _DC["default"](2);
|
|
rt.setInt16(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Int16, rt);
|
|
}
|
|
}, {
|
|
key: "uInt16Composer",
|
|
value: function uInt16Composer(value, connection) {
|
|
var rt = new _DC["default"](2);
|
|
rt.setUint16(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.UInt16, rt);
|
|
}
|
|
}, {
|
|
key: "float32Composer",
|
|
value: function float32Composer(value, connection) {
|
|
var rt = new _DC["default"](4);
|
|
rt.setFloat32(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Float32, rt);
|
|
}
|
|
}, {
|
|
key: "float64Composer",
|
|
value: function float64Composer(value, connection) {
|
|
var rt = new _DC["default"](8);
|
|
rt.setFloat64(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Float64, rt);
|
|
}
|
|
}, {
|
|
key: "int64Composer",
|
|
value: function int64Composer(value, connection) {
|
|
var rt = new _DC["default"](8);
|
|
rt.setInt64(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Int64, rt);
|
|
}
|
|
}, {
|
|
key: "numberComposer",
|
|
value: function numberComposer(value, connection) {
|
|
var rt = new _DC["default"](8);
|
|
|
|
if (Number.isInteger(value)) {
|
|
rt.setInt64(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Int64, rt);
|
|
} else {
|
|
rt.setFloat64(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Float64, rt);
|
|
}
|
|
}
|
|
}, {
|
|
key: "uInt64Composer",
|
|
value: function uInt64Composer(value, connection) {
|
|
var rt = new _DC["default"](8);
|
|
rt.setUint64(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.UInt64, rt);
|
|
}
|
|
}, {
|
|
key: "dateTimeComposer",
|
|
value: function dateTimeComposer(value, connection) {
|
|
var rt = new _DC["default"](8);
|
|
rt.setDateTime(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.DateTime, rt);
|
|
}
|
|
}, {
|
|
key: "float128Composer",
|
|
value: function float128Composer(value, connection) {
|
|
//@TODO: implement decimal
|
|
var rt = new _DC["default"](16);
|
|
rt.setFloat64(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Float64, rt);
|
|
}
|
|
}, {
|
|
key: "stringComposer",
|
|
value: function stringComposer(value, connection) {
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.String, _DC["default"].stringToBytes(value));
|
|
}
|
|
}, {
|
|
key: "enumComposer",
|
|
value: function enumComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
|
|
var template = _Warehouse["default"].getTemplateByType(value.runtimeType);
|
|
|
|
if (template == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var cts = template.constants.where(function (x) {
|
|
return x.value == value;
|
|
});
|
|
if (cts.isEmpty) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var rt = (0, _BinaryList["default"])();
|
|
rt.addGuid(template.classId);
|
|
rt.addUint8(cts.first.index);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Enum, rt.toDC());
|
|
}
|
|
}, {
|
|
key: "uInt8Composer",
|
|
value: function uInt8Composer(value, connection) {
|
|
var rt = new _DC["default"](1);
|
|
rt[0] = value;
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.UInt8, rt);
|
|
}
|
|
}, {
|
|
key: "int8Composer",
|
|
value: function int8Composer(value, connection) {
|
|
var rt = new _DC["default"](1);
|
|
rt[0] = value;
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Int8, rt);
|
|
}
|
|
}, {
|
|
key: "char8Composer",
|
|
value: function char8Composer(value, connection) {
|
|
var rt = new _DC["default"](1);
|
|
rt[0] = value;
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Char8, rt);
|
|
}
|
|
}, {
|
|
key: "char16Composer",
|
|
value: function char16Composer(value, connection) {
|
|
var rt = new _DC["default"](2);
|
|
rt.setUint16(0, value);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Char16, rt);
|
|
}
|
|
}, {
|
|
key: "boolComposer",
|
|
value: function boolComposer(value, connection) {
|
|
return new DataSerializerComposeResults(value ? _TransmissionType.TransmissionTypeIdentifier.True : _TransmissionType.TransmissionTypeIdentifier.False, new _DC["default"](0));
|
|
}
|
|
}, {
|
|
key: "notModifiedComposer",
|
|
value: function notModifiedComposer(value, connection) {
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.NotModified, new _DC["default"](0));
|
|
}
|
|
}, {
|
|
key: "rawDataComposer",
|
|
value: function rawDataComposer(value, connection) {
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.RawData, value);
|
|
}
|
|
}, {
|
|
key: "listComposer",
|
|
value: function listComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));else return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.List, DataSerializer.arrayComposer(value, connection)); //var rt = new List<byte>();
|
|
//var list = (IEnumerable)value;// ((List<object>)value);
|
|
//foreach (var o in list)
|
|
// rt.AddRange(Codec.Compose(o, connection));
|
|
//return (TransmissionTypeIdentifier.List, rt.ToArray());
|
|
}
|
|
}, {
|
|
key: "typedListComposer",
|
|
value: function typedListComposer(value, type, connection) {
|
|
var _RepresentationType$f;
|
|
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var composed = DataSerializer.arrayComposer(value, connection);
|
|
var header = ((_RepresentationType$f = _RepresentationType["default"].fromType(type)) !== null && _RepresentationType$f !== void 0 ? _RepresentationType$f : _RepresentationType["default"].Dynamic).compose();
|
|
var rt = new _BinaryList["default"]().addDC(header).addDC(composed);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.TypedList, rt.toDC());
|
|
}
|
|
}, {
|
|
key: "propertyValueArrayComposer",
|
|
value: function propertyValueArrayComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var rt = (0, _DC.BL)();
|
|
|
|
for (var i = 0; i < value.length; i++) {
|
|
rt.addDC(_Codec["default"].compose(value[i].age, connection));
|
|
rt.addDC(_Codec["default"].compose(value[i].date, connection));
|
|
rt.addDC(_Codec["default"].compose(value[i].value, connection));
|
|
}
|
|
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.List, rt.toDC());
|
|
}
|
|
}, {
|
|
key: "typedMapComposer",
|
|
value: function typedMapComposer(value, keyType, valueType, connection) {
|
|
var _RepresentationType$f2, _RepresentationType$f3;
|
|
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var kt = ((_RepresentationType$f2 = _RepresentationType["default"].fromType(keyType)) !== null && _RepresentationType$f2 !== void 0 ? _RepresentationType$f2 : _RepresentationType["default"].Dynamic).compose();
|
|
var vt = ((_RepresentationType$f3 = _RepresentationType["default"].fromType(valueType)) !== null && _RepresentationType$f3 !== void 0 ? _RepresentationType$f3 : _RepresentationType["default"].Dynamic).compose();
|
|
var rt = new _BinaryList["default"]();
|
|
rt.addDC(kt);
|
|
rt.addDC(vt); //@TODO
|
|
|
|
var _iterator = _createForOfIteratorHelper(value),
|
|
_step;
|
|
|
|
try {
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
var _step$value = _slicedToArray(_step.value, 2),
|
|
k = _step$value[0],
|
|
v = _step$value[1];
|
|
|
|
rt.addDC(_Codec["default"].compose(k, connection));
|
|
rt.addDC(_Codec["default"].compose(v, connection));
|
|
}
|
|
} catch (err) {
|
|
_iterator.e(err);
|
|
} finally {
|
|
_iterator.f();
|
|
}
|
|
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.TypedMap, rt.toDC());
|
|
}
|
|
}, {
|
|
key: "arrayComposer",
|
|
value: function arrayComposer(value, connection) {
|
|
var rt = new _BinaryList["default"]();
|
|
|
|
var _iterator2 = _createForOfIteratorHelper(value),
|
|
_step2;
|
|
|
|
try {
|
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
var i = _step2.value;
|
|
rt.addDC(_Codec["default"].compose(i, connection));
|
|
}
|
|
} catch (err) {
|
|
_iterator2.e(err);
|
|
} finally {
|
|
_iterator2.f();
|
|
}
|
|
|
|
return rt.toDC();
|
|
}
|
|
}, {
|
|
key: "resourceListComposer",
|
|
value: function resourceListComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.ResourceList, DataSerializer.arrayComposer(value, connection));
|
|
}
|
|
}, {
|
|
key: "recordListComposer",
|
|
value: function recordListComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.RecordList, DataSerializer.arrayComposer(value, connection));
|
|
}
|
|
}, {
|
|
key: "resourceComposer",
|
|
value: function resourceComposer(value, connection) {
|
|
var resource = value;
|
|
var rt = new _DC["default"](4);
|
|
|
|
if (_Codec["default"].isLocalResource(resource, connection)) {
|
|
var _resource$id;
|
|
|
|
rt.setUint32(0, (_resource$id = resource.id) !== null && _resource$id !== void 0 ? _resource$id : 0);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.ResourceLocal, rt);
|
|
} else {
|
|
var _resource$instance$id, _resource$instance;
|
|
|
|
// @TODO: connection.cache.Add(value as IResource, DateTime.UtcNow);
|
|
rt.setUint32(0, (_resource$instance$id = (_resource$instance = resource.instance) === null || _resource$instance === void 0 ? void 0 : _resource$instance.id) !== null && _resource$instance$id !== void 0 ? _resource$instance$id : 0);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Resource, rt);
|
|
}
|
|
}
|
|
}, {
|
|
key: "mapComposer",
|
|
value: function mapComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var rt = (0, _BinaryList["default"])();
|
|
|
|
for (var el in value) {
|
|
rt.addDC(_Codec["default"].compose(el.key, connection));
|
|
rt.addDC(_Codec["default"].compose(el.value, connection));
|
|
}
|
|
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Map, rt.toDC());
|
|
}
|
|
}, {
|
|
key: "recordComposer",
|
|
value: function recordComposer(value, connection) {
|
|
var rt = (0, _BinaryList["default"])();
|
|
|
|
var template = _Warehouse["default"].getTemplateByType(value.runtimeType);
|
|
|
|
if (template == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
rt.addDC(_DC["default"].guidToBytes(template.classId));
|
|
var recordData = value.serialize();
|
|
|
|
for (var pt in template.properties) {
|
|
var propValue = recordData[pt.name];
|
|
rt.addDC(_Codec["default"].compose(propValue, connection));
|
|
}
|
|
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Record, rt.toDC());
|
|
} // TODO:
|
|
// static DataSerializerComposeResults historyComposer(KeyList<PropertyTemplate, PropertyValue[]> history,
|
|
// DistributedConnection connection, bool prependLength = false)
|
|
// {
|
|
// //@TODO:Test
|
|
// var rt = new BinaryList();
|
|
// for (var i = 0; i < history.Count; i++)
|
|
// rt.AddUInt8(history.Keys.ElementAt(i).Index)
|
|
// .AddUInt8Array(Codec.Compose(history.Values.ElementAt(i), connection));
|
|
// if (prependLength)
|
|
// rt.InsertInt32(0, rt.Length);
|
|
// return rt.ToArray();
|
|
// }
|
|
|
|
}, {
|
|
key: "tupleComposer",
|
|
value: function tupleComposer(value, connection) {
|
|
if (value == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));
|
|
var rt = (0, _DC.BL)();
|
|
|
|
var fields = _Tuple["default"].getTypes(value);
|
|
|
|
var types = fields.map(function (x) {
|
|
return _RepresentationType["default"].fromType(x).compose();
|
|
});
|
|
rt.Add(value.length);
|
|
|
|
var _iterator3 = _createForOfIteratorHelper(types),
|
|
_step3;
|
|
|
|
try {
|
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
var t = _step3.value;
|
|
rt.addUint8Array(t);
|
|
}
|
|
} catch (err) {
|
|
_iterator3.e(err);
|
|
} finally {
|
|
_iterator3.f();
|
|
}
|
|
|
|
var composed = DataSerializer.arrayComposer(value, connection);
|
|
if (composed == null) return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC["default"](0));else {
|
|
rt.addUint8Array(composed);
|
|
return new DataSerializerComposeResults(_TransmissionType.TransmissionTypeIdentifier.Tuple, rt.toArray());
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return DataSerializer;
|
|
}();
|
|
|
|
exports["default"] = DataSerializer;
|
|
|
|
},{"../Resource/Warehouse.js":84,"./BinaryList.js":13,"./Codec.js":14,"./DC.js":15,"./RepresentationType.js":31,"./TransmissionType.js":38,"./Tuple.js":39}],18:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = {
|
|
Void: 0x0,
|
|
//Variant,
|
|
Bool: 1,
|
|
Int8: 2,
|
|
UInt8: 3,
|
|
Char: 4,
|
|
Int16: 5,
|
|
UInt16: 6,
|
|
Int32: 7,
|
|
UInt32: 8,
|
|
Int64: 9,
|
|
UInt64: 10,
|
|
Float32: 11,
|
|
Float64: 12,
|
|
Decimal: 13,
|
|
DateTime: 14,
|
|
Resource: 15,
|
|
DistributedResource: 16,
|
|
ResourceLink: 17,
|
|
String: 18,
|
|
Structure: 19,
|
|
Record: 20,
|
|
//Stream,
|
|
//Array = 0x80,
|
|
VarArray: 0x80,
|
|
BoolArray: 0x81,
|
|
Int8Array: 0x82,
|
|
UInt8Array: 0x83,
|
|
CharArray: 0x84,
|
|
Int16Array: 0x85,
|
|
UInt16Array: 0x86,
|
|
Int32Array: 0x87,
|
|
UInt32Array: 0x88,
|
|
Int64Array: 0x89,
|
|
UInt64Array: 0x8A,
|
|
Float32Array: 0x8B,
|
|
Float64Array: 0x8C,
|
|
DecimalArray: 0x8D,
|
|
DateTimeArray: 0x8E,
|
|
ResourceArray: 0x8F,
|
|
DistributedResourceArray: 0x90,
|
|
ResourceLinkArray: 0x91,
|
|
StringArray: 0x92,
|
|
StructureArray: 0x93,
|
|
RecordArray: 0x94,
|
|
NotModified: 0x7f,
|
|
Unspecified: 0xff,
|
|
isArray: function isArray(type) {
|
|
return (type & 0x80) == 0x80 && type != this.NotModified;
|
|
},
|
|
sizeOf: function sizeOf(type) {
|
|
switch (type) {
|
|
case this.Void:
|
|
case this.NotModified:
|
|
return 0;
|
|
|
|
case this.Bool:
|
|
case this.Int8:
|
|
case this.UInt8:
|
|
return 1;
|
|
|
|
case this.Char:
|
|
case this.Int16:
|
|
case this.UInt16:
|
|
return 2;
|
|
|
|
case this.Int32:
|
|
case this.UInt32:
|
|
case this.Float32:
|
|
case this.Resource:
|
|
return 4;
|
|
|
|
case this.Int64:
|
|
case this.UInt64:
|
|
case this.Float64:
|
|
case this.DateTime:
|
|
return 8;
|
|
|
|
case this.DistributedResource:
|
|
return 4;
|
|
|
|
default:
|
|
return -1;
|
|
}
|
|
}
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],19:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.Char8 = exports.Char16 = exports.Float128 = exports.Float64 = exports.Float32 = exports.UInt8 = exports.UInt16 = exports.UInt32 = exports.UInt64 = exports.UInt128 = exports.Int8 = exports.Int16 = exports.Int32 = exports.Int64 = exports.Int128 = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
|
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var Num = /*#__PURE__*/function (_Number) {
|
|
_inherits(Num, _Number);
|
|
|
|
var _super = _createSuper(Num);
|
|
|
|
function Num(value) {
|
|
_classCallCheck(this, Num);
|
|
|
|
return _super.call(this, value);
|
|
}
|
|
|
|
_createClass(Num, [{
|
|
key: "toString",
|
|
value: function toString() {
|
|
return _get(_getPrototypeOf(Num.prototype), "toString", this).call(this);
|
|
}
|
|
}]);
|
|
|
|
return Num;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Number));
|
|
|
|
var Int128 = /*#__PURE__*/function (_Num) {
|
|
_inherits(Int128, _Num);
|
|
|
|
var _super2 = _createSuper(Int128);
|
|
|
|
function Int128() {
|
|
_classCallCheck(this, Int128);
|
|
|
|
return _super2.apply(this, arguments);
|
|
}
|
|
|
|
return Int128;
|
|
}(Num);
|
|
|
|
exports.Int128 = Int128;
|
|
|
|
var Int64 = /*#__PURE__*/function (_Num2) {
|
|
_inherits(Int64, _Num2);
|
|
|
|
var _super3 = _createSuper(Int64);
|
|
|
|
function Int64() {
|
|
_classCallCheck(this, Int64);
|
|
|
|
return _super3.apply(this, arguments);
|
|
}
|
|
|
|
return Int64;
|
|
}(Num);
|
|
|
|
exports.Int64 = Int64;
|
|
|
|
var Int32 = /*#__PURE__*/function (_Num3) {
|
|
_inherits(Int32, _Num3);
|
|
|
|
var _super4 = _createSuper(Int32);
|
|
|
|
function Int32() {
|
|
_classCallCheck(this, Int32);
|
|
|
|
return _super4.apply(this, arguments);
|
|
}
|
|
|
|
return Int32;
|
|
}(Num);
|
|
|
|
exports.Int32 = Int32;
|
|
|
|
var Int16 = /*#__PURE__*/function (_Num4) {
|
|
_inherits(Int16, _Num4);
|
|
|
|
var _super5 = _createSuper(Int16);
|
|
|
|
function Int16() {
|
|
_classCallCheck(this, Int16);
|
|
|
|
return _super5.apply(this, arguments);
|
|
}
|
|
|
|
return Int16;
|
|
}(Num);
|
|
|
|
exports.Int16 = Int16;
|
|
|
|
var Int8 = /*#__PURE__*/function (_Num5) {
|
|
_inherits(Int8, _Num5);
|
|
|
|
var _super6 = _createSuper(Int8);
|
|
|
|
function Int8() {
|
|
_classCallCheck(this, Int8);
|
|
|
|
return _super6.apply(this, arguments);
|
|
}
|
|
|
|
return Int8;
|
|
}(Num);
|
|
|
|
exports.Int8 = Int8;
|
|
|
|
var UInt128 = /*#__PURE__*/function (_Num6) {
|
|
_inherits(UInt128, _Num6);
|
|
|
|
var _super7 = _createSuper(UInt128);
|
|
|
|
function UInt128() {
|
|
_classCallCheck(this, UInt128);
|
|
|
|
return _super7.apply(this, arguments);
|
|
}
|
|
|
|
return UInt128;
|
|
}(Num);
|
|
|
|
exports.UInt128 = UInt128;
|
|
|
|
var UInt64 = /*#__PURE__*/function (_Num7) {
|
|
_inherits(UInt64, _Num7);
|
|
|
|
var _super8 = _createSuper(UInt64);
|
|
|
|
function UInt64() {
|
|
_classCallCheck(this, UInt64);
|
|
|
|
return _super8.apply(this, arguments);
|
|
}
|
|
|
|
return UInt64;
|
|
}(Num);
|
|
|
|
exports.UInt64 = UInt64;
|
|
|
|
var UInt32 = /*#__PURE__*/function (_Num8) {
|
|
_inherits(UInt32, _Num8);
|
|
|
|
var _super9 = _createSuper(UInt32);
|
|
|
|
function UInt32() {
|
|
_classCallCheck(this, UInt32);
|
|
|
|
return _super9.apply(this, arguments);
|
|
}
|
|
|
|
return UInt32;
|
|
}(Num);
|
|
|
|
exports.UInt32 = UInt32;
|
|
|
|
var UInt16 = /*#__PURE__*/function (_Num9) {
|
|
_inherits(UInt16, _Num9);
|
|
|
|
var _super10 = _createSuper(UInt16);
|
|
|
|
function UInt16() {
|
|
_classCallCheck(this, UInt16);
|
|
|
|
return _super10.apply(this, arguments);
|
|
}
|
|
|
|
return UInt16;
|
|
}(Num);
|
|
|
|
exports.UInt16 = UInt16;
|
|
|
|
var UInt8 = /*#__PURE__*/function (_Num10) {
|
|
_inherits(UInt8, _Num10);
|
|
|
|
var _super11 = _createSuper(UInt8);
|
|
|
|
function UInt8() {
|
|
_classCallCheck(this, UInt8);
|
|
|
|
return _super11.apply(this, arguments);
|
|
}
|
|
|
|
return UInt8;
|
|
}(Num);
|
|
|
|
exports.UInt8 = UInt8;
|
|
|
|
var Float32 = /*#__PURE__*/function (_Num11) {
|
|
_inherits(Float32, _Num11);
|
|
|
|
var _super12 = _createSuper(Float32);
|
|
|
|
function Float32() {
|
|
_classCallCheck(this, Float32);
|
|
|
|
return _super12.apply(this, arguments);
|
|
}
|
|
|
|
return Float32;
|
|
}(Num);
|
|
|
|
exports.Float32 = Float32;
|
|
|
|
var Float64 = /*#__PURE__*/function (_Num12) {
|
|
_inherits(Float64, _Num12);
|
|
|
|
var _super13 = _createSuper(Float64);
|
|
|
|
function Float64() {
|
|
_classCallCheck(this, Float64);
|
|
|
|
return _super13.apply(this, arguments);
|
|
}
|
|
|
|
return Float64;
|
|
}(Num);
|
|
|
|
exports.Float64 = Float64;
|
|
|
|
var Float128 = /*#__PURE__*/function (_Num13) {
|
|
_inherits(Float128, _Num13);
|
|
|
|
var _super14 = _createSuper(Float128);
|
|
|
|
function Float128() {
|
|
_classCallCheck(this, Float128);
|
|
|
|
return _super14.apply(this, arguments);
|
|
}
|
|
|
|
return Float128;
|
|
}(Num);
|
|
|
|
exports.Float128 = Float128;
|
|
|
|
var Char16 = /*#__PURE__*/function (_String) {
|
|
_inherits(Char16, _String);
|
|
|
|
var _super15 = _createSuper(Char16);
|
|
|
|
function Char16() {
|
|
_classCallCheck(this, Char16);
|
|
|
|
return _super15.apply(this, arguments);
|
|
}
|
|
|
|
return Char16;
|
|
}( /*#__PURE__*/_wrapNativeSuper(String));
|
|
|
|
exports.Char16 = Char16;
|
|
|
|
var Char8 = /*#__PURE__*/function (_String2) {
|
|
_inherits(Char8, _String2);
|
|
|
|
var _super16 = _createSuper(Char8);
|
|
|
|
function Char8() {
|
|
_classCallCheck(this, Char8);
|
|
|
|
return _super16.apply(this, arguments);
|
|
}
|
|
|
|
return Char8;
|
|
}( /*#__PURE__*/_wrapNativeSuper(String));
|
|
|
|
exports.Char8 = Char8;
|
|
|
|
},{}],20:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _DC = _interopRequireDefault(require("./DC.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
var Guid = /*#__PURE__*/function () {
|
|
function Guid(dc) {
|
|
_classCallCheck(this, Guid);
|
|
|
|
this.value = dc;
|
|
}
|
|
|
|
_createClass(Guid, [{
|
|
key: "valueOf",
|
|
value: function valueOf() {
|
|
return this.value.getHex(0, 16);
|
|
}
|
|
}, {
|
|
key: "toString",
|
|
value: function toString() {
|
|
return this.vlue.toHex('');
|
|
} // [Symbol.toPrimitive](hint){
|
|
// console.log(hint);
|
|
// }
|
|
|
|
}], [{
|
|
key: "fromString",
|
|
value: function fromString(data) {
|
|
this.value = _DC["default"].fromHex(data, '');
|
|
}
|
|
}]);
|
|
|
|
return Guid;
|
|
}();
|
|
|
|
exports["default"] = Guid;
|
|
|
|
},{"./DC.js":15}],21:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
//import TemplateDescriber from '../Resource/Template/TemplateDescriber.js';
|
|
var IEnum = /*#__PURE__*/function () {
|
|
function IEnum() {
|
|
_classCallCheck(this, IEnum);
|
|
}
|
|
|
|
_createClass(IEnum, [{
|
|
key: "IEnum",
|
|
value: function IEnum(index, value, name) {
|
|
this.index = index;
|
|
this.value = value;
|
|
this.name = name;
|
|
}
|
|
}, {
|
|
key: "template",
|
|
get: function get() {//return new TemplateDescriber("IEnum");
|
|
}
|
|
}, {
|
|
key: "toString",
|
|
value: function toString() {
|
|
return "".concat(this.name, "<").concat(this.value, ">");
|
|
}
|
|
}]);
|
|
|
|
return IEnum;
|
|
}();
|
|
|
|
exports["default"] = IEnum;
|
|
|
|
},{}],22:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
var IRecord = /*#__PURE__*/function () {
|
|
function IRecord() {
|
|
_classCallCheck(this, IRecord);
|
|
}
|
|
|
|
_createClass(IRecord, [{
|
|
key: "toString",
|
|
value: function toString() {//return serialize().toString();
|
|
}
|
|
}]);
|
|
|
|
return IRecord;
|
|
}();
|
|
|
|
exports["default"] = IRecord;
|
|
|
|
},{}],23:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 06/11/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IDestructible = _interopRequireDefault(require("../Core/IDestructible.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
|
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
|
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
|
|
var _item_destroyed = /*#__PURE__*/new WeakMap();
|
|
|
|
var KeyList = /*#__PURE__*/function () {
|
|
function KeyList() {
|
|
_classCallCheck(this, KeyList);
|
|
|
|
_item_destroyed.set(this, {
|
|
writable: true,
|
|
value: function value(sender) {
|
|
for (var i = 0; i < this.values.length; i++) {
|
|
if (sender == this.values[i]) {
|
|
this.removeAt(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
this.keys = [];
|
|
this.values = [];
|
|
}
|
|
|
|
_createClass(KeyList, [{
|
|
key: "toObject",
|
|
value: function toObject() {
|
|
var rt = {};
|
|
|
|
for (var i = 0; i < this.keys.length; i++) {
|
|
rt[this.keys[i]] = this.values[i];
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "at",
|
|
value: function at(index) {
|
|
return this.values[index];
|
|
}
|
|
}, {
|
|
key: "item",
|
|
value: function item(key) {
|
|
for (var i = 0; i < this.keys.length; i++) {
|
|
if (this.keys[i] == key) return this.values[i];
|
|
}
|
|
}
|
|
}, {
|
|
key: "get",
|
|
value: function get(key) {
|
|
if (key.valueOf != null) key = key.valueOf();
|
|
|
|
for (var i = 0; i < this.keys.length; i++) {
|
|
if (this.keys[i].valueOf != null) if (this.keys[i].valueOf() == key) return this.values[i];
|
|
}
|
|
}
|
|
}, {
|
|
key: "add",
|
|
value: function add(key, value) {
|
|
this.remove(key);
|
|
if (value instanceof _IDestructible["default"]) value.on("destroy", _classPrivateFieldGet(this, _item_destroyed), this);
|
|
this.keys.push(key);
|
|
this.values.push(value);
|
|
}
|
|
}, {
|
|
key: "contains",
|
|
value: function contains(key) {
|
|
for (var i = 0; i < this.keys.length; i++) {
|
|
if (this.keys[i] == key) return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}, {
|
|
key: "containsKey",
|
|
value: function containsKey(key) {
|
|
return this.contains(key);
|
|
}
|
|
}, {
|
|
key: "set",
|
|
value: function set(key, value) {
|
|
this.remove(key);
|
|
this.add(key, value);
|
|
}
|
|
}, {
|
|
key: "remove",
|
|
value: function remove(key) {
|
|
for (var i = 0; i < this.keys.length; i++) {
|
|
if (key == this.keys[i]) {
|
|
this.removeAt(i);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "removeAt",
|
|
value: function removeAt(index) {
|
|
if (this.values[index] instanceof _IDestructible["default"]) this.values[index].off("destroy", _classPrivateFieldGet(this, _item_destroyed));
|
|
this.keys.splice(index, 1);
|
|
this.values.splice(index, 1);
|
|
}
|
|
}, {
|
|
key: "clear",
|
|
value: function clear() {
|
|
while (this.length > 0) {
|
|
this.removeAt(0);
|
|
}
|
|
}
|
|
}, {
|
|
key: "filter",
|
|
value: function filter(selector) {
|
|
if (selector instanceof Function) {
|
|
return this.values.filter(selector);
|
|
} else {
|
|
var match = function match(small, big) {
|
|
if (small == big) {
|
|
return true;
|
|
} else if (_typeof(small) == "object" && _typeof(big) == "object" && small != null && big != null) {
|
|
if (small.constructor.name == "Object") {
|
|
for (var i in small) {
|
|
if (!match(small[i], big[i])) return false;
|
|
}
|
|
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
} else return false;
|
|
};
|
|
|
|
return this.values.filter(function (x) {
|
|
return match(selector, x);
|
|
});
|
|
}
|
|
}
|
|
}, {
|
|
key: "length",
|
|
get: function get() {
|
|
return this.keys.length;
|
|
}
|
|
}]);
|
|
|
|
return KeyList;
|
|
}();
|
|
|
|
exports["default"] = KeyList;
|
|
|
|
},{"../Core/IDestructible.js":8}],24:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 26/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var NotModified = function NotModified() {
|
|
_classCallCheck(this, NotModified);
|
|
};
|
|
|
|
exports["default"] = NotModified;
|
|
|
|
},{}],25:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var ParseResult = function ParseResult(size, value) {
|
|
_classCallCheck(this, ParseResult);
|
|
|
|
this.size = size;
|
|
this.value = value;
|
|
};
|
|
|
|
exports["default"] = ParseResult;
|
|
|
|
},{}],26:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 06/11/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var PropertyValue = function PropertyValue(value, age, date) {
|
|
_classCallCheck(this, PropertyValue);
|
|
|
|
this.value = value;
|
|
this.age = age;
|
|
this.date = date;
|
|
};
|
|
|
|
exports["default"] = PropertyValue;
|
|
|
|
},{}],27:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var PropertyValueArray = /*#__PURE__*/function (_Array) {
|
|
_inherits(PropertyValueArray, _Array);
|
|
|
|
var _super = _createSuper(PropertyValueArray);
|
|
|
|
function PropertyValueArray() {
|
|
_classCallCheck(this, PropertyValueArray);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
return PropertyValueArray;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Array));
|
|
|
|
exports["default"] = PropertyValueArray;
|
|
|
|
},{}],28:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IRecord2 = _interopRequireDefault(require("./IRecord.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var Record = /*#__PURE__*/function (_IRecord) {
|
|
_inherits(Record, _IRecord);
|
|
|
|
var _super = _createSuper(Record);
|
|
|
|
function Record() {
|
|
_classCallCheck(this, Record);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
return Record;
|
|
}(_IRecord2["default"]);
|
|
|
|
exports["default"] = Record;
|
|
|
|
},{"./IRecord.js":22}],29:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017-2022 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 26/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IRecord = _interopRequireDefault(require("./IRecord.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
|
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var RecordArray = /*#__PURE__*/function (_Array) {
|
|
_inherits(RecordArray, _Array);
|
|
|
|
var _super = _createSuper(RecordArray);
|
|
|
|
function RecordArray() {
|
|
_classCallCheck(this, RecordArray);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(RecordArray, [{
|
|
key: "push",
|
|
value: function push(value) {
|
|
if (value instanceof _IRecord["default"]) _get(_getPrototypeOf(RecordArray.prototype), "push", this).call(this, value);else return;
|
|
}
|
|
}]);
|
|
|
|
return RecordArray;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Array));
|
|
|
|
exports["default"] = RecordArray;
|
|
|
|
},{"./IRecord.js":22}],30:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = // const ResourceComparisonResult =
|
|
{
|
|
Null: 0,
|
|
Record: 1,
|
|
RecordSameType: 2,
|
|
Same: 3,
|
|
Empty: 4
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],31:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.RepresentationType = exports["default"] = exports.RepresentationTypeParseResults = exports.RepresentationTypeIdentifier = void 0;
|
|
|
|
var _TemplateType = _interopRequireDefault(require("../Resource/Template/TemplateType.js"));
|
|
|
|
var _IRecord = _interopRequireDefault(require("./IRecord.js"));
|
|
|
|
var _IResource = _interopRequireDefault(require("../Resource/IResource.js"));
|
|
|
|
var _BinaryList = _interopRequireDefault(require("./BinaryList.js"));
|
|
|
|
var _DC = _interopRequireDefault(require("./DC.js"));
|
|
|
|
var _Warehouse = _interopRequireDefault(require("../Resource/Warehouse.js"));
|
|
|
|
var _ExtendedTypes = require("./ExtendedTypes.js");
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var RepresentationTypeIdentifier = {
|
|
Void: 0x0,
|
|
Dynamic: 0x1,
|
|
Bool: 0x2,
|
|
UInt8: 0x3,
|
|
Int8: 0x4,
|
|
Char: 0x5,
|
|
Int16: 0x6,
|
|
UInt16: 0x7,
|
|
Int32: 0x8,
|
|
UInt32: 0x9,
|
|
Float32: 0xA,
|
|
Int64: 0xB,
|
|
UInt64: 0xC,
|
|
Float64: 0xD,
|
|
DateTime: 0xE,
|
|
Int128: 0xF,
|
|
UInt128: 0x10,
|
|
Decimal: 0x11,
|
|
String: 0x12,
|
|
RawData: 0x13,
|
|
Resource: 0x14,
|
|
Record: 0x15,
|
|
List: 0x16,
|
|
Map: 0x17,
|
|
Enum: 0x18,
|
|
TypedResource: 0x45,
|
|
// Followed by UUID
|
|
TypedRecord: 0x46,
|
|
// Followed by UUID
|
|
TypedList: 0x48,
|
|
// Followed by element type
|
|
Tuple2: 0x50,
|
|
// Followed by element type
|
|
TypedMap: 0x51,
|
|
// Followed by key type and value type
|
|
Tuple3: 0x58,
|
|
Tuple4: 0x60,
|
|
Tuple5: 0x68,
|
|
Tuple6: 0x70,
|
|
Tuple7: 0x78
|
|
};
|
|
exports.RepresentationTypeIdentifier = RepresentationTypeIdentifier;
|
|
var RuntimeTypes = {};
|
|
RuntimeTypes[RepresentationTypeIdentifier.Void] = [Object, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Bool] = [Boolean, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Char] = [_ExtendedTypes.Char8, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Char16] = [_ExtendedTypes.Char16, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.UInt8] = [_ExtendedTypes.UInt8, _ExtendedTypes.UInt8];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Int8] = [_ExtendedTypes.Int8, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Int16] = [_ExtendedTypes.Int16, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.UInt16] = [_ExtendedTypes.UInt16, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Int32] = [_ExtendedTypes.Int32, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.UInt32] = [_ExtendedTypes.UInt32, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Int64] = [_ExtendedTypes.Int64, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.UInt64] = [_ExtendedTypes.UInt64, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Int128] = [_ExtendedTypes.Int128, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.UInt128] = [_ExtendedTypes.UInt128, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Float32] = [_ExtendedTypes.Float32, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Float64] = [_ExtendedTypes.Float64, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Decimal] = [_ExtendedTypes.Float128, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.String] = [String, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.DateTime] = [Date, Object];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Resource] = [_IResource["default"], _IResource["default"]];
|
|
RuntimeTypes[RepresentationTypeIdentifier.Record] = [_IRecord["default"], _IRecord["default"]];
|
|
|
|
var RepresentationTypeParseResults = //RepresentationType type;
|
|
//int size;
|
|
function RepresentationTypeParseResults(size, type) {
|
|
_classCallCheck(this, RepresentationTypeParseResults);
|
|
|
|
this.size = size;
|
|
this.type = type;
|
|
};
|
|
|
|
exports.RepresentationTypeParseResults = RepresentationTypeParseResults;
|
|
|
|
var RepresentationType = /*#__PURE__*/function () {
|
|
function RepresentationType(identifier, nullable, guid, subTypes) {
|
|
_classCallCheck(this, RepresentationType);
|
|
|
|
this.identifier = identifier;
|
|
this.nullable = nullable;
|
|
this.guid = guid;
|
|
this.subTypes = subTypes;
|
|
}
|
|
|
|
_createClass(RepresentationType, [{
|
|
key: "toNullable",
|
|
value: // static getTypeFromName(name) {
|
|
// const types = {
|
|
// "int": int,
|
|
// "bool": bool,
|
|
// "double": double,
|
|
// "String": String,
|
|
// "IResource": IResource,
|
|
// "IRecord": IRecord,
|
|
// "IEnum": IEnum,
|
|
// "DC": DC,
|
|
// };
|
|
// if (types[name] != null) {
|
|
// return types[name];
|
|
// } else
|
|
// return Object().runtimeType;
|
|
// }
|
|
function toNullable() {
|
|
return new RepresentationType(this.identifier, true, this.guid, this.subTypes);
|
|
}
|
|
}, {
|
|
key: "getRuntimeType",
|
|
value: function getRuntimeType() {
|
|
var _Warehouse$getTemplat, _Warehouse$getTemplat2, _Warehouse$getTemplat3;
|
|
|
|
if (RuntimeTypes[this.identifier]) return this.nullable ? RuntimeTypes[this.identifier][1] : RuntimeTypes[this.identifier][0];
|
|
if (this.identifier == RepresentationTypeIdentifier.TypedRecord) return (_Warehouse$getTemplat = _Warehouse["default"].getTemplateByClassId(this.guid, _TemplateType["default"].Record)) === null || _Warehouse$getTemplat === void 0 ? void 0 : _Warehouse$getTemplat.definedType;else if (this.identifier == RepresentationTypeIdentifier.TypedResource) return (_Warehouse$getTemplat2 = _Warehouse["default"].getTemplateByClassId(this.guid, _TemplateType["default"].Unspecified)) === null || _Warehouse$getTemplat2 === void 0 ? void 0 : _Warehouse$getTemplat2.definedType;else if (this.identifier == RepresentationTypeIdentifier.Enum) return (_Warehouse$getTemplat3 = _Warehouse["default"].getTemplateByClassId(this.guid, _TemplateType["default"].Enum)) === null || _Warehouse$getTemplat3 === void 0 ? void 0 : _Warehouse$getTemplat3.definedType;
|
|
return null;
|
|
}
|
|
}, {
|
|
key: "compose",
|
|
value: function compose() {
|
|
var rt = new _BinaryList["default"]();
|
|
if (this.nullable) rt.addUint8(0x80 | this.identifier);else rt.addUint8(this.identifier);
|
|
if (this.guid != null) rt.addDC(_DC["default"].guidToBytes(this.guid));
|
|
if (this.subTypes != null) for (var i = 0; i < this.subTypes.length; i++) {
|
|
rt.addDC(this.subTypes[i].compose());
|
|
}
|
|
return rt.toDC();
|
|
} //public override string ToString() => Identifier.ToString() + (Nullable ? "?" : "")
|
|
// + TypeTemplate != null ? "<" + TypeTemplate.ClassName + ">" : "";
|
|
|
|
}], [{
|
|
key: "Void",
|
|
get: function get() {
|
|
return new RepresentationType(RepresentationTypeIdentifier.Void, true, null, null);
|
|
}
|
|
}, {
|
|
key: "Dynamic",
|
|
get: function get() {
|
|
return new RepresentationType(RepresentationTypeIdentifier.Dynamic, true, null, null);
|
|
}
|
|
}, {
|
|
key: "fromType",
|
|
value: function fromType(type) {
|
|
var _Warehouse$typesFacto;
|
|
|
|
return (_Warehouse$typesFacto = _Warehouse["default"].typesFactory[type]) === null || _Warehouse$typesFacto === void 0 ? void 0 : _Warehouse$typesFacto.representationType;
|
|
}
|
|
}, {
|
|
key: "parse",
|
|
value: function parse(data, offset) {
|
|
var oOffset = offset;
|
|
var header = data[offset++];
|
|
var nullable = (header & 0x80) > 0;
|
|
var identifier = header & 0x7F;
|
|
|
|
if ((header & 0x40) > 0) {
|
|
var hasGUID = (header & 0x4) > 0;
|
|
var subsCount = header >> 3 & 0x7;
|
|
var guid = null;
|
|
|
|
if (hasGUID) {
|
|
guid = data.getGuid(offset);
|
|
offset += 16;
|
|
}
|
|
|
|
var subs = [];
|
|
|
|
for (var i = 0; i < subsCount; i++) {
|
|
var parsed = RepresentationType.parse(data, offset);
|
|
subs.push(parsed.type);
|
|
offset += parsed.size;
|
|
}
|
|
|
|
return new RepresentationTypeParseResults(offset - oOffset, new RepresentationType(identifier, nullable, guid, subs));
|
|
} else {
|
|
return new RepresentationTypeParseResults(1, new RepresentationType(identifier, nullable, null, null));
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return RepresentationType;
|
|
}();
|
|
|
|
exports.RepresentationType = exports["default"] = RepresentationType;
|
|
|
|
},{"../Resource/IResource.js":70,"../Resource/Template/TemplateType.js":82,"../Resource/Warehouse.js":84,"./BinaryList.js":13,"./DC.js":15,"./ExtendedTypes.js":19,"./IRecord.js":22}],32:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 26/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IResource = _interopRequireDefault(require("../Resource/IResource.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
|
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var ResourceArray = /*#__PURE__*/function (_Array) {
|
|
_inherits(ResourceArray, _Array);
|
|
|
|
var _super = _createSuper(ResourceArray);
|
|
|
|
function ResourceArray() {
|
|
_classCallCheck(this, ResourceArray);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(ResourceArray, [{
|
|
key: "push",
|
|
value: function push(value) {
|
|
if (value instanceof _IResource["default"]) _get(_getPrototypeOf(ResourceArray.prototype), "push", this).call(this, value);else return;
|
|
}
|
|
}]);
|
|
|
|
return ResourceArray;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Array));
|
|
|
|
exports["default"] = ResourceArray;
|
|
|
|
},{"../Resource/IResource.js":70}],33:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = {
|
|
Dynamic: 0x0,
|
|
Static: 0x10,
|
|
Wrapper: 0x20
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],34:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = // const ResourceComparisonResult =
|
|
{
|
|
Null: 0,
|
|
Distributed: 1,
|
|
Local: 2,
|
|
Same: 3,
|
|
Empty: 4
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],35:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 26/08/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
var Structure = /*#__PURE__*/function () {
|
|
function Structure(data) {
|
|
_classCallCheck(this, Structure);
|
|
|
|
if (data instanceof Object) for (var i in data) {
|
|
this[i] = data[i];
|
|
}
|
|
}
|
|
|
|
_createClass(Structure, [{
|
|
key: "toArray",
|
|
value: function toArray() {
|
|
return this.toPairs();
|
|
}
|
|
}, {
|
|
key: "toPairs",
|
|
value: function toPairs() {
|
|
var rt = [];
|
|
|
|
for (var i in this) {
|
|
if (!(this[i] instanceof Function)) rt.push({
|
|
key: i,
|
|
value: this[i]
|
|
});
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getKeys",
|
|
value: function getKeys() {
|
|
var rt = [];
|
|
|
|
for (var i in this) {
|
|
if (!(this[i] instanceof Function)) rt.push(i);
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "toObject",
|
|
value: function toObject() {
|
|
var rt = {};
|
|
|
|
for (var i in this) {
|
|
if (!(this[i] instanceof Function)) rt[i] = this[i];
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}]);
|
|
|
|
return Structure;
|
|
}();
|
|
|
|
exports["default"] = Structure;
|
|
|
|
},{}],36:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 06/09/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
|
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var StructureArray = /*#__PURE__*/function (_Array) {
|
|
_inherits(StructureArray, _Array);
|
|
|
|
var _super = _createSuper(StructureArray);
|
|
|
|
function StructureArray() {
|
|
_classCallCheck(this, StructureArray);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(StructureArray, [{
|
|
key: "push",
|
|
value: function push(value) {
|
|
if (value instanceof Structure) _get(_getPrototypeOf(StructureArray.prototype), "push", this).call(this, value);else return;
|
|
}
|
|
}]);
|
|
|
|
return StructureArray;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Array));
|
|
|
|
exports["default"] = StructureArray;
|
|
|
|
},{}],37:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = //const StructureComparisonResult =
|
|
{
|
|
Null: 0,
|
|
Structure: 1,
|
|
StructureSameKeys: 2,
|
|
StructureSameTypes: 3,
|
|
Same: 4
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],38:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.TransmissionType = exports["default"] = exports.TransmissionTypeParseResults = exports.TransmissionTypeClass = exports.TransmissionTypeIdentifier = void 0;
|
|
|
|
var _DC = _interopRequireDefault(require("./DC.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var TransmissionTypeIdentifier = {
|
|
Null: 0x0,
|
|
False: 0x1,
|
|
True: 0x2,
|
|
NotModified: 0x3,
|
|
UInt8: 0x8,
|
|
Int8: 0x9,
|
|
Char8: 0xA,
|
|
Int16: 0x10,
|
|
UInt16: 0x11,
|
|
Char16: 0x12,
|
|
Int32: 0x18,
|
|
UInt32: 0x19,
|
|
Float32: 0x1A,
|
|
Resource: 0x1B,
|
|
ResourceLocal: 0x1C,
|
|
Int64: 0x20,
|
|
UInt64: 0x21,
|
|
Float64: 0x22,
|
|
DateTime: 0x23,
|
|
Int128: 0x28,
|
|
UInt128: 0x29,
|
|
Float128: 0x2A,
|
|
RawData: 0x40,
|
|
String: 0x41,
|
|
List: 0x42,
|
|
ResourceList: 0x43,
|
|
RecordList: 0x44,
|
|
Map: 0x45,
|
|
MapList: 0x46,
|
|
//Tuple = 0x47,
|
|
Record: 0x80,
|
|
TypedList: 0x81,
|
|
TypedMap: 0x82,
|
|
Tuple: 0x83,
|
|
Enum: 0x84,
|
|
Constant: 0x85
|
|
};
|
|
exports.TransmissionTypeIdentifier = TransmissionTypeIdentifier;
|
|
var TransmissionTypeClass = {
|
|
Fixed: 0,
|
|
Dynamic: 1,
|
|
Typed: 2
|
|
};
|
|
exports.TransmissionTypeClass = TransmissionTypeClass;
|
|
|
|
var TransmissionTypeParseResults = function TransmissionTypeParseResults(size, type) {
|
|
_classCallCheck(this, TransmissionTypeParseResults);
|
|
|
|
this.size = size;
|
|
this.type = type;
|
|
};
|
|
|
|
exports.TransmissionTypeParseResults = TransmissionTypeParseResults;
|
|
|
|
var TransmissionType = /*#__PURE__*/function () {
|
|
function TransmissionType(identifier, classType, index, offset, contentLength) {
|
|
var exponent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
|
|
_classCallCheck(this, TransmissionType);
|
|
|
|
this.identifier = identifier;
|
|
this.classType = classType;
|
|
this.index = index;
|
|
this.offset = offset;
|
|
this.contentLength = contentLength;
|
|
this.exponent = exponent;
|
|
}
|
|
|
|
_createClass(TransmissionType, null, [{
|
|
key: "Null",
|
|
get: // final int identifier;
|
|
// final int index;
|
|
// final int classType;
|
|
// final int offset;
|
|
// final int contentLength;
|
|
// final int exponent;
|
|
function get() {
|
|
return new TransmissionType(TransmissionTypeIdentifier.Null, 0, 0, 0, 0);
|
|
}
|
|
}, {
|
|
key: "compose",
|
|
value: function compose(identifier, data) {
|
|
if (data.length == 0) return _DC["default"].fromList([identifier]);
|
|
var cls = identifier >> 6;
|
|
|
|
if (cls == TransmissionTypeClass.Fixed) {
|
|
return _DC["default"].combine([identifier], 0, 1, data, 0, data.length);
|
|
} else {
|
|
var len = data.length;
|
|
|
|
if (len == 0) {
|
|
return _DC["default"].fromList([identifier]);
|
|
} else if (len <= 0xFF) {
|
|
var rt = new _DC["default"](2 + len);
|
|
rt[0] = identifier | 0x8;
|
|
rt[1] = len;
|
|
rt.set(data, 2);
|
|
return rt;
|
|
} else if (len <= 0xFFFF) {
|
|
var _rt = new _DC["default"](3 + len);
|
|
|
|
_rt[0] = identifier | 0x10;
|
|
_rt[1] = len >> 8 & 0xFF;
|
|
_rt[2] = len & 0xFF;
|
|
|
|
_rt.set(data, 3);
|
|
|
|
return _rt;
|
|
} else if (len <= 0xFFFFFF) {
|
|
var _rt2 = new _DC["default"](4 + len);
|
|
|
|
_rt2[0] = identifier | 0x18;
|
|
_rt2[1] = len >> 16 & 0xFF;
|
|
_rt2[2] = len >> 8 & 0xFF;
|
|
_rt2[3] = len & 0xFF;
|
|
|
|
_rt2.set(data, 4);
|
|
|
|
return _rt2;
|
|
} else if (len <= 0xFFFFFFFF) {
|
|
var _rt3 = new _DC["default"](5 + len);
|
|
|
|
_rt3[0] = identifier | 0x20;
|
|
_rt3[1] = len >> 24 & 0xFF;
|
|
_rt3[2] = len >> 16 & 0xFF;
|
|
_rt3[3] = len >> 8 & 0xFF;
|
|
_rt3[4] = len & 0xFF;
|
|
|
|
_rt3.set(data, 5);
|
|
|
|
return _rt3;
|
|
} else if (len <= 0xFFFFFFFFFF) {
|
|
var _rt4 = new _DC["default"](6 + len);
|
|
|
|
_rt4[0] = identifier | 0x28;
|
|
_rt4[1] = len >> 32 & 0xFF;
|
|
_rt4[2] = len >> 24 & 0xFF;
|
|
_rt4[3] = len >> 16 & 0xFF;
|
|
_rt4[4] = len >> 8 & 0xFF;
|
|
_rt4[5] = len & 0xFF;
|
|
|
|
_rt4.set(data, 6);
|
|
|
|
return _rt4;
|
|
} else if (len <= 0xFFFFFFFFFFFF) {
|
|
var _rt5 = new _DC["default"](7 + len);
|
|
|
|
_rt5[0] = identifier | 0x30;
|
|
_rt5[1] = len >> 40 & 0xFF;
|
|
_rt5[2] = len >> 32 & 0xFF;
|
|
_rt5[3] = len >> 24 & 0xFF;
|
|
_rt5[4] = len >> 16 & 0xFF;
|
|
_rt5[5] = len >> 8 & 0xFF;
|
|
_rt5[6] = len & 0xFF;
|
|
|
|
_rt5.set(data, 7);
|
|
|
|
return _rt5;
|
|
} else //if (len <= 0xFF_FF_FF_FF_FF_FF_FF)
|
|
{
|
|
var _rt6 = new _DC["default"](8 + len);
|
|
|
|
_rt6[0] = identifier | 0x38;
|
|
_rt6[1] = len >> 48 & 0xFF;
|
|
_rt6[2] = len >> 40 & 0xFF;
|
|
_rt6[3] = len >> 32 & 0xFF;
|
|
_rt6[4] = len >> 24 & 0xFF;
|
|
_rt6[5] = len >> 16 & 0xFF;
|
|
_rt6[6] = len >> 8 & 0xFF;
|
|
_rt6[7] = len & 0xFF;
|
|
data.set(data, 8);
|
|
return _rt6;
|
|
}
|
|
}
|
|
}
|
|
}, {
|
|
key: "parse",
|
|
value: function parse(data, offset, ends) {
|
|
var h = data[offset++];
|
|
var cls = h >> 6;
|
|
|
|
if (cls == TransmissionTypeClass.Fixed) {
|
|
var exp = (h & 0x38) >> 3;
|
|
if (exp == 0) return new TransmissionTypeParseResults(1, new TransmissionType(h, cls, h & 0x7, 0, exp));
|
|
var cl = 1 << exp - 1;
|
|
if (ends - offset < cl) return new TransmissionTypeParseResults(ends - offset - cl, null);
|
|
return new TransmissionTypeParseResults(1 + cl, new TransmissionType(h, cls, h & 0x7, offset, cl, exp));
|
|
} else {
|
|
var cll = h >> 3 & 0x7;
|
|
if (ends - offset < cll) return new TransmissionTypeParseResults(ends - offset - cll, null);
|
|
var _cl = 0;
|
|
|
|
for (var i = 0; i < cll; i++) {
|
|
_cl = _cl << 8 | data[offset++];
|
|
}
|
|
|
|
return new TransmissionTypeParseResults(1 + _cl + cll, new TransmissionType(h & 0xC7, cls, h & 0x7, offset, _cl));
|
|
}
|
|
}
|
|
}]);
|
|
|
|
return TransmissionType;
|
|
}();
|
|
|
|
exports.TransmissionType = exports["default"] = TransmissionType;
|
|
|
|
},{"./DC.js":15}],39:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var Tuple = /*#__PURE__*/function (_Array) {
|
|
_inherits(Tuple, _Array);
|
|
|
|
var _super = _createSuper(Tuple);
|
|
|
|
function Tuple() {
|
|
_classCallCheck(this, Tuple);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(Tuple, null, [{
|
|
key: "getTypes",
|
|
value: function getTypes(tuple) {
|
|
return tuple.constructor.types;
|
|
}
|
|
}, {
|
|
key: "of",
|
|
value: function of() {
|
|
var types = [];
|
|
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
types.push(arguments[i]);
|
|
}
|
|
|
|
if (Tuple.cache[types] != null) return Tuple.cache[types];
|
|
|
|
var c = /*#__PURE__*/function (_Tuple) {
|
|
_inherits(c, _Tuple);
|
|
|
|
var _super2 = _createSuper(c);
|
|
|
|
function c() {
|
|
_classCallCheck(this, c);
|
|
|
|
return _super2.apply(this, arguments);
|
|
}
|
|
|
|
return c;
|
|
}(Tuple);
|
|
|
|
Object.defineProperty(c, "name", {
|
|
value: types.map(function (x) {
|
|
return x.name;
|
|
}).join('') + "Tuple"
|
|
});
|
|
Object.defineProperty(c, "types", {
|
|
value: types
|
|
});
|
|
Tuple.cache[types] = c;
|
|
return c;
|
|
}
|
|
}]);
|
|
|
|
return Tuple;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Array));
|
|
|
|
exports["default"] = Tuple;
|
|
|
|
_defineProperty(Tuple, "cache", {});
|
|
|
|
},{}],40:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IResource = _interopRequireDefault(require("../Resource/IResource.js"));
|
|
|
|
var _PropertyValue = _interopRequireDefault(require("./PropertyValue.js"));
|
|
|
|
var _PropertyValueArray = _interopRequireDefault(require("./PropertyValueArray.js"));
|
|
|
|
var _ResourceArray = _interopRequireDefault(require("./ResourceArray.js"));
|
|
|
|
var _defineProperty2;
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var TypedList = /*#__PURE__*/function (_Array) {
|
|
_inherits(TypedList, _Array);
|
|
|
|
var _super = _createSuper(TypedList);
|
|
|
|
function TypedList() {
|
|
_classCallCheck(this, TypedList);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(TypedList, null, [{
|
|
key: "getType",
|
|
value: // constructor(data)
|
|
// {
|
|
// if (data != undefined && data instanceof Array)
|
|
// for(var i = 0; i < data.length; i++)
|
|
// this.push(data[i]);
|
|
// }
|
|
function getType(typedList) {
|
|
return typedList.constructor.type;
|
|
}
|
|
}, {
|
|
key: "of",
|
|
value: function of(type) {
|
|
if (TypedList.cache[type] != null) return TypedList.cache[type];
|
|
|
|
var c = /*#__PURE__*/function (_TypedList) {
|
|
_inherits(c, _TypedList);
|
|
|
|
var _super2 = _createSuper(c);
|
|
|
|
function c() {
|
|
_classCallCheck(this, c);
|
|
|
|
return _super2.apply(this, arguments);
|
|
}
|
|
|
|
return c;
|
|
}(TypedList);
|
|
|
|
Object.defineProperty(c, "name", {
|
|
value: type.name + "List"
|
|
});
|
|
Object.defineProperty(c, "type", {
|
|
value: type
|
|
});
|
|
TypedList.cache[type] = c;
|
|
return c;
|
|
}
|
|
}]);
|
|
|
|
return TypedList;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Array));
|
|
|
|
exports["default"] = TypedList;
|
|
|
|
_defineProperty(TypedList, "cache", (_defineProperty2 = {}, _defineProperty(_defineProperty2, _IResource["default"], _ResourceArray["default"]), _defineProperty(_defineProperty2, _PropertyValue["default"], _PropertyValueArray["default"]), _defineProperty2));
|
|
|
|
},{"../Resource/IResource.js":70,"./PropertyValue.js":26,"./PropertyValueArray.js":27,"./ResourceArray.js":32}],41:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
|
|
|
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
|
|
var TypedMap = /*#__PURE__*/function (_Map) {
|
|
_inherits(TypedMap, _Map);
|
|
|
|
var _super = _createSuper(TypedMap);
|
|
|
|
function TypedMap(data) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, TypedMap);
|
|
|
|
_this = _super.call(this);
|
|
if (data instanceof Object) for (var i in data) {
|
|
_this.set(i, data[i]);
|
|
}
|
|
return _this;
|
|
}
|
|
|
|
_createClass(TypedMap, null, [{
|
|
key: "getTypes",
|
|
value: function getTypes(typedMap) {
|
|
var _typedMap$constructor, _typedMap$constructor2;
|
|
|
|
return [(_typedMap$constructor = typedMap.constructor.keyType) !== null && _typedMap$constructor !== void 0 ? _typedMap$constructor : Object, (_typedMap$constructor2 = typedMap.constructor.valueType) !== null && _typedMap$constructor2 !== void 0 ? _typedMap$constructor2 : Object];
|
|
}
|
|
}, {
|
|
key: "of",
|
|
value: function of(keyType, valueType) {
|
|
if (TypedMap.cache[[keyType, valueType]] != null) return TypedMap.cache[[keyType, valueType]]; //if (TypedMap.cache[keyType] != null)
|
|
// if (TypedMap.cache[keyType][valueType] != null)
|
|
// return TypedMap.cache[keyType][valueType];
|
|
|
|
var c = /*#__PURE__*/function (_TypedMap) {
|
|
_inherits(c, _TypedMap);
|
|
|
|
var _super2 = _createSuper(c);
|
|
|
|
function c() {
|
|
_classCallCheck(this, c);
|
|
|
|
return _super2.apply(this, arguments);
|
|
}
|
|
|
|
return c;
|
|
}(TypedMap);
|
|
|
|
Object.defineProperty(c, "name", {
|
|
value: keyType.name + valueType.name + "Map"
|
|
});
|
|
Object.defineProperty(c, "keyType", {
|
|
value: keyType
|
|
});
|
|
Object.defineProperty(c, "valueType", {
|
|
value: valueType
|
|
}); //if (TypedMap.cache[keyType] == null)
|
|
// TypedMap.cache[keyType] = {[valueType]: c};
|
|
//else
|
|
// TypedMap.cache[keyType][valueType] = c;
|
|
|
|
TypedMap.cache[[keyType, valueType]] = c;
|
|
return c;
|
|
}
|
|
}]);
|
|
|
|
return TypedMap;
|
|
}( /*#__PURE__*/_wrapNativeSuper(Map));
|
|
|
|
exports["default"] = TypedMap;
|
|
|
|
_defineProperty(TypedMap, "cache", {});
|
|
|
|
},{}],42:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IStore2 = _interopRequireDefault(require("../../Resource/IStore.js"));
|
|
|
|
var _Session = _interopRequireDefault(require("../../Security/Authority/Session.js"));
|
|
|
|
var _Authentication = _interopRequireDefault(require("../../Security/Authority/Authentication.js"));
|
|
|
|
var _AuthenticationType = _interopRequireDefault(require("../../Security/Authority/AuthenticationType.js"));
|
|
|
|
var _SHA = _interopRequireDefault(require("../../Security/Integrity/SHA256.js"));
|
|
|
|
var _DC = require("../../Data/DC.js");
|
|
|
|
var _SendList = _interopRequireDefault(require("../SendList.js"));
|
|
|
|
var _AsyncReply = _interopRequireDefault(require("../../Core/AsyncReply.js"));
|
|
|
|
var _Codec = _interopRequireDefault(require("../../Data/Codec.js"));
|
|
|
|
var _KeyList = _interopRequireDefault(require("../../Data/KeyList.js"));
|
|
|
|
var _AsyncQueue = _interopRequireDefault(require("../../Core/AsyncQueue.js"));
|
|
|
|
var _Warehouse = _interopRequireDefault(require("../../Resource/Warehouse.js"));
|
|
|
|
var _IIPAuthPacket = _interopRequireDefault(require("../Packets/IIPAuthPacket.js"));
|
|
|
|
var _IIPPacket = _interopRequireDefault(require("../Packets/IIPPacket.js"));
|
|
|
|
var _IIPAuthPacketAction = _interopRequireDefault(require("../Packets/IIPAuthPacketAction.js"));
|
|
|
|
var _IIPAuthPacketCommand = _interopRequireDefault(require("../Packets/IIPAuthPacketCommand.js"));
|
|
|
|
var _AuthenticationMethod = _interopRequireDefault(require("../../Security/Authority/AuthenticationMethod.js"));
|
|
|
|
var _IIPPacketAction = _interopRequireDefault(require("../Packets/IIPPacketAction.js"));
|
|
|
|
var _IIPPacketCommand = _interopRequireDefault(require("../Packets/IIPPacketCommand.js"));
|
|
|
|
var _IIPPacketEvent = _interopRequireDefault(require("../Packets/IIPPacketEvent.js"));
|
|
|
|
var _IIPPacketReport = _interopRequireDefault(require("../Packets//IIPPacketReport.js"));
|
|
|
|
var _ErrorType = _interopRequireDefault(require("../../Core/ErrorType.js"));
|
|
|
|
var _ProgressType = _interopRequireDefault(require("../../Core/ProgressType.js"));
|
|
|
|
var _ExceptionCode = _interopRequireDefault(require("../../Core/ExceptionCode.js"));
|
|
|
|
var _DistributedResource = _interopRequireDefault(require("./DistributedResource.js"));
|
|
|
|
var _TypeTemplate = _interopRequireDefault(require("../../Resource/Template/TypeTemplate.js"));
|
|
|
|
var _DistributedResourceQueueItem = _interopRequireDefault(require("./DistributedResourceQueueItem.js"));
|
|
|
|
var _DistributedResourceQueueItemType = _interopRequireDefault(require("./DistributedResourceQueueItemType.js"));
|
|
|
|
var _DistributedPropertyContext = _interopRequireDefault(require("./DistributedPropertyContext.js"));
|
|
|
|
var _IResource = require("../../Resource/IResource.js");
|
|
|
|
var _Ruling = _interopRequireDefault(require("../../Security/Permissions/Ruling.js"));
|
|
|
|
var _ActionType = _interopRequireDefault(require("../../Security/Permissions/ActionType.js"));
|
|
|
|
var _AsyncException = _interopRequireDefault(require("../../Core/AsyncException.js"));
|
|
|
|
var _WSocket = _interopRequireDefault(require("../Sockets/WSocket.js"));
|
|
|
|
var _ClientAuthentication = _interopRequireDefault(require("../../Security/Authority/ClientAuthentication.js"));
|
|
|
|
var _HostAuthentication = _interopRequireDefault(require("../../Security/Authority/HostAuthentication.js"));
|
|
|
|
var _SocketState = _interopRequireDefault(require("../Sockets/SocketState.js"));
|
|
|
|
var _TemplateType = _interopRequireDefault(require("../../Resource/Template/TemplateType.js"));
|
|
|
|
var _AsyncBag = _interopRequireDefault(require("../../Core/AsyncBag.js"));
|
|
|
|
var _TransmissionType = require("../../Data/TransmissionType.js");
|
|
|
|
var _PropertyValue = _interopRequireDefault(require("../../Data/PropertyValue.js"));
|
|
|
|
var _PropertyValueArray = _interopRequireDefault(require("../../Data/PropertyValueArray.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
|
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
|
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _get(target, property, receiver) { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get; } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(receiver); } return desc.value; }; } return _get(target, property, receiver || target); }
|
|
|
|
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
|
|
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
|
|
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
|
|
var _instance_resourceDestroyed = /*#__PURE__*/new WeakMap();
|
|
|
|
var _instance_propertyModified = /*#__PURE__*/new WeakMap();
|
|
|
|
var _instance_eventOccurred = /*#__PURE__*/new WeakMap();
|
|
|
|
var DistributedConnection = /*#__PURE__*/function (_IStore) {
|
|
_inherits(DistributedConnection, _IStore);
|
|
|
|
var _super = _createSuper(DistributedConnection);
|
|
|
|
function DistributedConnection(server) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, DistributedConnection);
|
|
|
|
_this = _super.call(this);
|
|
|
|
_instance_resourceDestroyed.set(_assertThisInitialized(_this), {
|
|
writable: true,
|
|
value: function value(resource) {
|
|
this._unsubscribe(resource); // compose the packet
|
|
|
|
|
|
this.sendEvent(_IIPPacketEvent["default"].ResourceDestroyed).addUint32(resource.instance.id).done();
|
|
}
|
|
});
|
|
|
|
_instance_propertyModified.set(_assertThisInitialized(_this), {
|
|
writable: true,
|
|
value: function value(info) {
|
|
var _info$resource$instan;
|
|
|
|
this.sendEvent(_IIPPacketEvent["default"].PropertyUpdated).addUint32((_info$resource$instan = info.resource.instance) === null || _info$resource$instan === void 0 ? void 0 : _info$resource$instan.id).addUint8(info.propertyTemplate.index).addUint8Array(_Codec["default"].compose(info.value, this)).done();
|
|
}
|
|
});
|
|
|
|
_instance_eventOccurred.set(_assertThisInitialized(_this), {
|
|
writable: true,
|
|
value: function value(info) {
|
|
if (info.eventTemplate.listenable) {
|
|
// check the client requested listen
|
|
if (!this.subscriptions.has(resource)) return;
|
|
if (!this.subscriptions.get(resource).includes(et.index)) return;
|
|
}
|
|
|
|
if (info.receivers instanceof Function) if (!info.receivers(this.sessions)) return;
|
|
if (info.resource.instance.applicable(this.session, _ActionType["default"].ReceiveEvent, info.eventTemplate, info.issuer) == _Ruling["default"].Denied) return; // compose the packet
|
|
|
|
this.sendEvent(_IIPPacketEvent["default"].EventOccurred).addUint32(info.resource.instance.id).addUint8(info.eventTemplate.index).addUint8Array(_Codec["default"].compose(info.value, this)).done();
|
|
}
|
|
});
|
|
|
|
_this._register("ready");
|
|
|
|
_this._register("error");
|
|
|
|
_this._register("close");
|
|
|
|
if (server != null) {
|
|
_this.session = new _Session["default"](new _Authentication["default"](_AuthenticationType["default"].Host), new _Authentication["default"](_AuthenticationType["default"].Client));
|
|
_this.server = server;
|
|
} else _this.session = new _Session["default"](new _Authentication["default"](_AuthenticationType["default"].Client), new _Authentication["default"](_AuthenticationType["default"].Host));
|
|
|
|
_this.packet = new _IIPPacket["default"]();
|
|
_this.authPacket = new _IIPAuthPacket["default"]();
|
|
_this.resources = new _KeyList["default"](); //{};
|
|
|
|
_this.templates = new _KeyList["default"]();
|
|
_this.requests = new _KeyList["default"](); // {};
|
|
//this.pathRequests = new KeyList();// {};
|
|
|
|
_this.templateRequests = new _KeyList["default"]();
|
|
_this.resourceRequests = new _KeyList["default"](); // {};
|
|
|
|
_this.callbackCounter = 0;
|
|
_this.queue = new _AsyncQueue["default"]();
|
|
_this.subscriptions = new Map();
|
|
|
|
_this.queue.then(function (x) {
|
|
if (x.type == _DistributedResourceQueueItemType["default"].Event) {
|
|
x.resource._emitEventByIndex(x.index, x.value);
|
|
} else {
|
|
x.resource._updatePropertyByIndex(x.index, x.value);
|
|
}
|
|
});
|
|
|
|
_this.localNonce = _this.generateNonce(32);
|
|
return _this;
|
|
}
|
|
|
|
_createClass(DistributedConnection, [{
|
|
key: "sendAll",
|
|
value: function sendAll(data) {
|
|
this.socket.sendAll(data.buffer);
|
|
}
|
|
}, {
|
|
key: "sendParams",
|
|
value: function sendParams(doneReply) {
|
|
return new _SendList["default"](this, doneReply);
|
|
}
|
|
}, {
|
|
key: "generateNonce",
|
|
value: function generateNonce(length) {
|
|
var rt = new Uint8Array(length);
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
rt[i] = Math.random() * 255;
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "_processPacket",
|
|
value: function _processPacket(msg, offset, ends, data) {
|
|
var _this2 = this;
|
|
|
|
var authPacket = this.authPacket;
|
|
|
|
if (this.ready) {
|
|
var packet = new _IIPPacket["default"]();
|
|
var rt = packet.parse(msg, offset, ends); //console.log("Inc " , rt, offset, ends);
|
|
|
|
if (rt <= 0) {
|
|
data.holdFor(msg, offset, ends - offset, -rt);
|
|
return ends;
|
|
} else {
|
|
offset += rt;
|
|
|
|
try {
|
|
if (packet.command == _IIPPacketCommand["default"].Event) {
|
|
switch (packet.event) {
|
|
case _IIPPacketEvent["default"].ResourceReassigned:
|
|
this.IIPEventResourceReassigned(packet.resourceId, packet.newResourceId);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].ResourceDestroyed:
|
|
this.IIPEventResourceDestroyed(packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].PropertyUpdated:
|
|
this.IIPEventPropertyUpdated(packet.resourceId, packet.methodIndex, packet.dataType, msg);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].EventOccurred:
|
|
this.IIPEventEventOccurred(packet.resourceId, packet.methodIndex, packet.dataType, msg);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].ChildAdded:
|
|
this.IIPEventChildAdded(packet.resourceId, packet.childId);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].ChildRemoved:
|
|
this.IIPEventChildRemoved(packet.resourceId, packet.childId);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].Renamed:
|
|
this.IIPEventRenamed(packet.resourceId, packet.resourceName);
|
|
break;
|
|
|
|
case _IIPPacketEvent["default"].AttributesUpdated:
|
|
//@TODO: fix this
|
|
//this.IIPEventAttributesUpdated(packet.resourceId, packet.content);
|
|
break;
|
|
}
|
|
} else if (packet.command == _IIPPacketCommand["default"].Request) {
|
|
switch (packet.action) {
|
|
// Manage
|
|
case _IIPPacketAction["default"].AttachResource:
|
|
this.IIPRequestAttachResource(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ReattachResource:
|
|
this.IIPRequestReattachResource(packet.callbackId, packet.resourceId, packet.resourceAge);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].DetachResource:
|
|
this.IIPRequestDetachResource(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].CreateResource:
|
|
// @TODO: implement this
|
|
// this.IIPRequestCreateResource(packet.callbackId, packet.storeId, packet.resourceId, packet.content);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].DeleteResource:
|
|
this.IIPRequestDeleteResource(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].AddChild:
|
|
this.IIPRequestAddChild(packet.callbackId, packet.resourceId, packet.childId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].RemoveChild:
|
|
this.IIPRequestRemoveChild(packet.callbackId, packet.resourceId, packet.childId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].RenameResource:
|
|
this.IIPRequestRenameResource(packet.callbackId, packet.resourceId, packet.resourceName);
|
|
break;
|
|
// Inquire
|
|
|
|
case _IIPPacketAction["default"].TemplateFromClassName:
|
|
this.IIPRequestTemplateFromClassName(packet.callbackId, packet.className);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].TemplateFromClassId:
|
|
this.IIPRequestTemplateFromClassId(packet.callbackId, packet.classId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].TemplateFromResourceId:
|
|
this.IIPRequestTemplateFromResourceId(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].QueryLink:
|
|
this.IIPRequestQueryResources(packet.callbackId, packet.resourceLink);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ResourceChildren:
|
|
this.IIPRequestResourceChildren(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ResourceParents:
|
|
this.IIPRequestResourceParents(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ResourceHistory:
|
|
this.IIPRequestInquireResourceHistory(packet.callbackId, packet.resourceId, packet.fromDate, packet.toDate);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].LinkTemplates:
|
|
this.IIPRequestLinkTemplates(packet.callbackId, packet.resourceLink);
|
|
break;
|
|
// Invoke
|
|
|
|
case _IIPPacketAction["default"].InvokeFunction:
|
|
this.IIPRequestInvokeFunction(packet.callbackId, packet.resourceId, packet.methodIndex, packet.dataType, msg);
|
|
break;
|
|
// case IIPPacketAction.GetProperty:
|
|
// this.IIPRequestGetProperty(packet.callbackId, packet.resourceId, packet.methodIndex);
|
|
// break;
|
|
// case IIPPacketAction.GetPropertyIfModified:
|
|
// this.IIPRequestGetPropertyIfModifiedSince(packet.callbackId, packet.resourceId, packet.methodIndex, packet.resourceAge);
|
|
// break;
|
|
|
|
case _IIPPacketAction["default"].Listen:
|
|
this.IIPRequestListen(packet.callbackId, packet.resourceId, packet.methodIndex);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].Unlisten:
|
|
this.IIPRequestUnlisten(packet.callbackId, packet.resourceId, packet.methodIndex);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].SetProperty:
|
|
this.IIPRequestSetProperty(packet.callbackId, packet.resourceId, packet.methodIndex, packet.dataType, msg);
|
|
break;
|
|
// Attribute @TODO: implement these
|
|
|
|
case _IIPPacketAction["default"].GetAllAttributes:
|
|
// this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, true);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].UpdateAllAttributes:
|
|
// this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, true);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ClearAllAttributes:
|
|
// this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, true);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].GetAttributes:
|
|
// this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, false);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].UpdateAttributes:
|
|
// this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, false);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ClearAttributes:
|
|
// this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, false);
|
|
break;
|
|
}
|
|
} else if (packet.command == _IIPPacketCommand["default"].Reply) {
|
|
switch (packet.action) {
|
|
case _IIPPacketAction["default"].AttachResource:
|
|
this.IIPReply(packet.callbackId, packet.classId, packet.resourceAge, packet.resourceLink, packet.dataType, msg);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].ReattachResource:
|
|
this.IIPReply(packet.callbackId, packet.resourceAge, packet.dataType, msg);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].DetachResource:
|
|
this.IIPReply(packet.callbackId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].CreateResource:
|
|
this.IIPReply(packet.callbackId, packet.resourceId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].DeleteResource:
|
|
case _IIPPacketAction["default"].AddChild:
|
|
case _IIPPacketAction["default"].RemoveChild:
|
|
case _IIPPacketAction["default"].RenameResource:
|
|
this.IIPReply(packet.callbackId);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].TemplateFromClassName:
|
|
case _IIPPacketAction["default"].TemplateFromClassId:
|
|
case _IIPPacketAction["default"].TemplateFromResourceId:
|
|
if (packet.dataType != null) {
|
|
var _packet$dataType$offs, _packet$dataType, _packet$dataType$cont, _packet$dataType2;
|
|
|
|
var content = msg.clip((_packet$dataType$offs = (_packet$dataType = packet.dataType) === null || _packet$dataType === void 0 ? void 0 : _packet$dataType.offset) !== null && _packet$dataType$offs !== void 0 ? _packet$dataType$offs : 0, (_packet$dataType$cont = (_packet$dataType2 = packet.dataType) === null || _packet$dataType2 === void 0 ? void 0 : _packet$dataType2.contentLength) !== null && _packet$dataType$cont !== void 0 ? _packet$dataType$cont : 0);
|
|
this.IIPReply(packet.callbackId, _TypeTemplate["default"].parse(content));
|
|
} else {
|
|
iipReportError(packet.callbackId, _ErrorType["default"].Management, _ExceptionCode["default"].TemplateNotFound.index, "Template not found");
|
|
}
|
|
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].QueryLink:
|
|
case _IIPPacketAction["default"].ResourceChildren:
|
|
case _IIPPacketAction["default"].ResourceParents:
|
|
case _IIPPacketAction["default"].ResourceHistory:
|
|
case _IIPPacketAction["default"].LinkTemplates:
|
|
this.IIPReply(packet.callbackId, packet.dataType, msg);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].InvokeFunction:
|
|
this.IIPReplyInvoke(packet.callbackId, packet.dataType, msg);
|
|
break;
|
|
// case IIPPacketAction.GetProperty:
|
|
// this.IIPReply(packet.callbackId, packet.content);
|
|
// break;
|
|
// case IIPPacketAction.GetPropertyIfModified:
|
|
// this.IIPReply(packet.callbackId, packet.content);
|
|
// break;
|
|
|
|
case _IIPPacketAction["default"].Listen:
|
|
case _IIPPacketAction["default"].Unlisten:
|
|
case _IIPPacketAction["default"].SetProperty:
|
|
this.IIPReply(packet.callbackId);
|
|
break;
|
|
// Attribute
|
|
|
|
case _IIPPacketAction["default"].GetAllAttributes:
|
|
case _IIPPacketAction["default"].GetAttributes:
|
|
this.IIPReply(packet.callbackId, packet.dataType, msg);
|
|
break;
|
|
|
|
case _IIPPacketAction["default"].UpdateAllAttributes:
|
|
case _IIPPacketAction["default"].UpdateAttributes:
|
|
case _IIPPacketAction["default"].ClearAllAttributes:
|
|
case _IIPPacketAction["default"].ClearAttributes:
|
|
this.IIPReply(packet.callbackId);
|
|
break;
|
|
}
|
|
} else if (packet.command == _IIPPacketCommand["default"].Report) {
|
|
switch (packet.report) {
|
|
case _IIPPacketReport["default"].ManagementError:
|
|
this.IIPReportError(packet.callbackId, _ErrorType["default"].Management, packet.errorCode, null);
|
|
break;
|
|
|
|
case _IIPPacketReport["default"].ExecutionError:
|
|
this.IIPReportError(packet.callbackId, _ErrorType["default"].Exception, packet.errorCode, packet.errorMessage);
|
|
break;
|
|
|
|
case _IIPPacketReport["default"].ProgressReport:
|
|
this.IIPReportProgress(packet.callbackId, _ProgressType["default"].Execution, packet.progressValue, packet.progressMax);
|
|
break;
|
|
|
|
case _IIPPacketReport["default"].ChunkStream:
|
|
this.IIPReportChunk(packet.callbackId, packet.dataType, msg);
|
|
break;
|
|
}
|
|
}
|
|
} catch (ex) {
|
|
console.log("Esiur Error ", ex);
|
|
}
|
|
}
|
|
} else {
|
|
var rt = authPacket.parse(msg, offset, ends); //console.log("Auth", rt, authPacket.command);
|
|
|
|
if (rt <= 0) {
|
|
data.holdAllFor(msg, ends - rt);
|
|
return ends;
|
|
} else {
|
|
offset += rt;
|
|
|
|
if (this.session.localAuthentication.type == _AuthenticationType["default"].Host) {
|
|
if (authPacket.command == _IIPAuthPacketCommand["default"].Declare) {
|
|
this.session.remoteAuthentication.method = authPacket.remoteMethod;
|
|
|
|
if (authPacket.remoteMethod == _AuthenticationMethod["default"].Credentials && authPacket.localMethod == _AuthenticationMethod["default"].None) {
|
|
try {
|
|
this.server.membership.userExists(authPacket.remoteUsername, authPacket.domain).then(function (x) {
|
|
if (x) {
|
|
_this2.session.remoteAuthentication.username = authPacket.remoteUsername;
|
|
_this2.remoteNonce = authPacket.remoteNonce;
|
|
_this2.session.remoteAuthentication.domain = authPacket.domain;
|
|
|
|
_this2.sendParams().addUint8(0xa0).addUint8Array(_this2.localNonce).done();
|
|
} else {
|
|
_this2.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].UserOrTokenNotFound).addUint16(14).addString("User not found").done();
|
|
}
|
|
});
|
|
} catch (ex) {
|
|
console.log(ex);
|
|
|
|
var errMsg = _DC.DC.stringToBytes(ex.message);
|
|
|
|
this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done();
|
|
}
|
|
} else if (authPacket.remoteMethod == _AuthenticationMethod["default"].Token && authPacket.localMethod == _AuthenticationMethod["default"].None) {
|
|
try {
|
|
// Check if user and token exists
|
|
this.server.membership.tokenExists(authPacket.remoteTokenIndex, authPacket.domain).then(function (x) {
|
|
if (x != null) {
|
|
_this2.session.remoteAuthentication.username = x;
|
|
_this2.session.remoteAuthentication.tokenIndex = authPacket.remoteTokenIndex;
|
|
_this2.remoteNonce = authPacket.remoteNonce;
|
|
_this2.session.remoteAuthentication.domain = authPacket.domain;
|
|
|
|
_this2.sendParams().addUint8(0xa0).addUint8Array(_this2.localNonce).done();
|
|
} else {
|
|
//Console.WriteLine("User not found");
|
|
_this2.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].UserOrTokenNotFound).addUint16(15).addString("Token not found").done();
|
|
}
|
|
});
|
|
} catch (ex) {
|
|
console.log(ex);
|
|
|
|
var errMsg = _DC.DC.stringToBytes(ex.message);
|
|
|
|
this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done();
|
|
}
|
|
} else if (authPacket.remoteMethod == _AuthenticationMethod["default"].None && authPacket.localMethod == _AuthenticationMethod["default"].None) {
|
|
try {
|
|
var _this$server;
|
|
|
|
// Check if guests are allowed
|
|
if ((_this$server = this.server) !== null && _this$server !== void 0 && _this$server.membership.guestsAllowed) {
|
|
this.session.remoteAuthentication.username = "g-" + Math.random().toString(36).substring(10);
|
|
this.session.remoteAuthentication.domain = authPacket.domain;
|
|
this.readyToEstablish = true;
|
|
this.sendParams().addUint8(0x80).done();
|
|
} else {
|
|
this.sendParams().addUInt8(0xc0).addUint8(_ExceptionCode["default"].AccessDenied).addUint16(18).addString("Guests not allowed").done();
|
|
}
|
|
} catch (ex) {
|
|
var errMsg = _DC.DC.stringToBytes(ex.message);
|
|
|
|
this.sendParams().addUInt8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done();
|
|
}
|
|
}
|
|
} else if (authPacket.command == _IIPAuthPacketCommand["default"].Action) {
|
|
if (authPacket.action == _IIPAuthPacketAction["default"].AuthenticateHash) {
|
|
var remoteHash = authPacket.hash;
|
|
var reply = null;
|
|
|
|
try {
|
|
if (this.session.remoteAuthentication.method == _AuthenticationMethod["default"].Credentials) {
|
|
reply = this.server.membership.getPassword(this.session.remoteAuthentication.username, this.session.remoteAuthentication.domain);
|
|
} else if (this.session.remoteAuthentication.method == _AuthenticationMethod["default"].Token) {
|
|
reply = this.server.membership.getToken(this.session.remoteAuthentication.tokenIndex, this.session.remoteAuthentication.domain);
|
|
} else {// Error
|
|
}
|
|
|
|
reply.then(function (pw) {
|
|
if (pw != null) {
|
|
var hash = _SHA["default"].compute((0, _DC.BL)().addUint8Array(pw).addUint8Array(_this2.remoteNonce).addUint8Array(_this2.localNonce).toArray());
|
|
|
|
if (hash.sequenceEqual(remoteHash)) {
|
|
// send our hash
|
|
var localHash = _SHA["default"].compute((0, _DC.BL)().addUint8Array(_this2.localNonce).addUint8Array(_this2.remoteNonce).addUint8Array(pw).toArray());
|
|
|
|
_this2.sendParams().addUint8(0).addUint8Array(localHash).done();
|
|
|
|
_this2.readyToEstablish = true;
|
|
} else {
|
|
_this2.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].AccessDenied).addUint16(13).addString("Access Denied").done();
|
|
}
|
|
}
|
|
});
|
|
} catch (ex) {
|
|
console.log(ex);
|
|
|
|
var errMsg = _DC.DC.stringToBytes(ex.message);
|
|
|
|
this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done();
|
|
}
|
|
} else if (authPacket.action == _IIPAuthPacketAction["default"].NewConnection) {
|
|
if (this.readyToEstablish) {
|
|
this.session.Id = this.generateNonce(32);
|
|
this.sendParams().addUint8(0x28).addUint8Array(this.session.Id).done();
|
|
|
|
if (this.instance == null) {
|
|
_Warehouse["default"].put(this.localUsername, this, null, this.server).then(function (x) {
|
|
var _this2$openReply, _this2$server;
|
|
|
|
_this2.ready = true;
|
|
(_this2$openReply = _this2.openReply) === null || _this2$openReply === void 0 ? void 0 : _this2$openReply.trigger(true);
|
|
|
|
_this2._emit("ready", _this2);
|
|
|
|
(_this2$server = _this2.server) === null || _this2$server === void 0 ? void 0 : _this2$server.membership.login(_this2.session);
|
|
}).error(function (x) {
|
|
var _this2$openReply2;
|
|
|
|
(_this2$openReply2 = _this2.openReply) === null || _this2$openReply2 === void 0 ? void 0 : _this2$openReply2.triggerError(x);
|
|
});
|
|
} else {
|
|
var _this$openReply, _this$server2;
|
|
|
|
this.ready = true;
|
|
(_this$openReply = this.openReply) === null || _this$openReply === void 0 ? void 0 : _this$openReply.trigger(true);
|
|
|
|
this._emit("ready", this);
|
|
|
|
(_this$server2 = this.server) === null || _this$server2 === void 0 ? void 0 : _this$server2.membership.login(this.session);
|
|
}
|
|
} else {
|
|
this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(9).addString("Not ready").done(); // this.close();
|
|
}
|
|
}
|
|
}
|
|
} else if (this.session.localAuthentication.type == _AuthenticationType["default"].Client) {
|
|
if (authPacket.command == _IIPAuthPacketCommand["default"].Acknowledge) {
|
|
if (authPacket.remoteMethod == _AuthenticationMethod["default"].None) {
|
|
// send establish
|
|
this.sendParams().addUint8(0x20).addUint16(0).done();
|
|
} else if (authPacket.remoteMethod == _AuthenticationMethod["default"].Credentials || authPacket.remoteMethod == _AuthenticationMethod["default"].Token) {
|
|
this.remoteNonce = authPacket.remoteNonce; // send our hash
|
|
|
|
var localHash = _SHA["default"].compute((0, _DC.BL)().addUint8Array(this.localPasswordOrToken).addUint8Array(this.localNonce).addUint8Array(this.remoteNonce).toArray());
|
|
|
|
this.sendParams().addUint8(0).addUint8Array(localHash).done();
|
|
}
|
|
} else if (authPacket.command == _IIPAuthPacketCommand["default"].Action) {
|
|
if (authPacket.action == _IIPAuthPacketAction["default"].AuthenticateHash) {
|
|
// check if the server knows my password
|
|
var remoteHash = _SHA["default"].compute((0, _DC.BL)().addUint8Array(this.remoteNonce).addUint8Array(this.localNonce).addUint8Array(this.localPasswordOrToken).toArray());
|
|
|
|
if (remoteHash.sequenceEqual(authPacket.hash)) {
|
|
// send establish request
|
|
//SendParams((byte)0x20, (ushort)0);
|
|
this.sendParams().addUint8(0x20).addUint16(0).done();
|
|
} else {
|
|
this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].ChallengeFailed).addUint16(16).addString("Challenge Failed").done();
|
|
}
|
|
} else if (authPacket.action == _IIPAuthPacketAction["default"].ConnectionEstablished) {
|
|
var _this$openReply2;
|
|
|
|
this.session.id = authPacket.sessionId;
|
|
this.ready = true;
|
|
(_this$openReply2 = this.openReply) === null || _this$openReply2 === void 0 ? void 0 : _this$openReply2.trigger(true);
|
|
|
|
this._emit("ready", this); // put it in the warehouse
|
|
|
|
|
|
if (this.instance == null) {
|
|
_Warehouse["default"].put(this.localUsername, this, null, this.server).then(function (x) {
|
|
var _this2$openReply3;
|
|
|
|
(_this2$openReply3 = _this2.openReply) === null || _this2$openReply3 === void 0 ? void 0 : _this2$openReply3.trigger(true);
|
|
|
|
_this2._emit("ready", _this2);
|
|
}).error(function (x) {
|
|
var _this2$openReply4;
|
|
|
|
return (_this2$openReply4 = _this2.openReply) === null || _this2$openReply4 === void 0 ? void 0 : _this2$openReply4.triggerError(x);
|
|
});
|
|
} else {
|
|
var _this$openReply3;
|
|
|
|
(_this$openReply3 = this.openReply) === null || _this$openReply3 === void 0 ? void 0 : _this$openReply3.trigger(true);
|
|
|
|
this._emit("ready", this);
|
|
}
|
|
}
|
|
} else if (authPacket.command == _IIPAuthPacketCommand["default"].Error) {
|
|
var _this$openReply4;
|
|
|
|
(_this$openReply4 = this.openReply) === null || _this$openReply4 === void 0 ? void 0 : _this$openReply4.triggerError(new _AsyncException["default"](_ErrorType["default"].Management, authPacket.errorCode, authPacket.errorMessage));
|
|
|
|
this._emit("error", this, authPacket.errorCode, authPacket.errorMessage);
|
|
|
|
this.close();
|
|
}
|
|
} // if (this.session.localAuthentication.type == AuthenticationType.Host) {
|
|
// if (authPacket.command == IIPAuthPacketCommand.Declare) {
|
|
// if (authPacket.remoteMethod == AuthenticationMethod.Credentials
|
|
// && authPacket.localMethod == AuthenticationMethod.None) {
|
|
// console.log("Declare");
|
|
// this.session.remoteAuthentication.username = authPacket.remoteUsername;
|
|
// this.remoteNonce = authPacket.remoteNonce;
|
|
// this.domain = authPacket.domain;
|
|
// this.sendParams().addUint8(0xa0).addUint8Array(this.localNonce).done();
|
|
// }
|
|
// }
|
|
// else if (authPacket.command == IIPAuthPacketCommand.Action) {
|
|
// if (authPacket.action == IIPAuthPacketAction.AuthenticateHash) {
|
|
// var remoteHash = authPacket.hash;
|
|
// this.server.membership.getPassword(this.session.remoteAuthentication.username, this.domain).then(function (pw) {
|
|
// if (pw != null) {
|
|
// //var hash = new DC(sha256.arrayBuffer(BL().addString(pw).addUint8Array(remoteNonce).addUint8Array(this.localNonce).toArray()));
|
|
// var hash = SHA256.compute(BL().addString(pw).addUint8Array(remoteNonce).addUint8Array(this.localNonce).toDC());
|
|
// if (hash.sequenceEqual(remoteHash)) {
|
|
// // send our hash
|
|
// //var localHash = new DC(sha256.arrayBuffer((new BinaryList()).addUint8Array(this.localNonce).addUint8Array(remoteNonce).addUint8Array(pw).toArray()));
|
|
// var localHash = SHA256.compute(BL().addUint8Array(this.localNonce).addUint8Array(remoteNonce).addUint8Array(pw).toDC());
|
|
// this.sendParams().addUint8(0).addUint8Array(localHash).done();
|
|
// this.readyToEstablish = true;
|
|
// }
|
|
// else {
|
|
// // incorrect password
|
|
// this.sendParams().addUint8(0xc0)
|
|
// .addInt32(ExceptionCode.AccessDenied)
|
|
// .addUint16(13)
|
|
// .addString("Access Denied")
|
|
// .done();
|
|
// }
|
|
// }
|
|
// });
|
|
// }
|
|
// else if (authPacket.action == IIPAuthPacketAction.NewConnection) {
|
|
// if (readyToEstablish) {
|
|
// this.session.id = this.generateNonce(32);// new DC(32);
|
|
// //window.crypto.getRandomValues(this.session.id);
|
|
// this.sendParams().addUint8(0x28).addUint8Array(this.session.id).done();
|
|
// this.ready = true;
|
|
// this.openReply.trigger(this);
|
|
// this.openReply = null;
|
|
// //this._emit("ready", this);
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// else if (this.session.localAuthentication.type == AuthenticationType.Client) {
|
|
// if (authPacket.command == IIPAuthPacketCommand.Acknowledge) {
|
|
// this.remoteNonce = authPacket.remoteNonce;
|
|
// // send our hash
|
|
// var localHash = SHA256.compute(BL().addUint8Array(this.localPasswordOrToken)
|
|
// .addUint8Array(this.localNonce)
|
|
// .addUint8Array(this.remoteNonce).toDC());
|
|
// this.sendParams().addUint8(0).addUint8Array(localHash).done();
|
|
// }
|
|
// else if (authPacket.command == IIPAuthPacketCommand.Action) {
|
|
// if (authPacket.action == IIPAuthPacketAction.AuthenticateHash) {
|
|
// var remoteHash = SHA256.compute(BL().addUint8Array(this.remoteNonce)
|
|
// .addUint8Array(this.localNonce)
|
|
// .addUint8Array(this.localPasswordOrToken).toDC());
|
|
// if (remoteHash.sequenceEqual(authPacket.hash)) {
|
|
// // send establish request
|
|
// this.sendParams().addUint8(0x20).addUint16(0).done();
|
|
// }
|
|
// else {
|
|
// this.sendParams().addUint8(0xc0)
|
|
// .addUint32(ExceptionCode.ChallengeFailed)
|
|
// .addUint16(16)
|
|
// .addString("Challenge Failed")
|
|
// .done();
|
|
// }
|
|
// }
|
|
// else if (authPacket.action == IIPAuthPacketAction.ConnectionEstablished) {
|
|
// this.session.id = authPacket.sessionId;
|
|
// this.ready = true;
|
|
// this.openReply.trigger(this);
|
|
// this.openReply = null;
|
|
// //this._emit("ready", this);
|
|
// }
|
|
// }
|
|
// else if (authPacket.command == IIPAuthPacketCommand.Error) {
|
|
// this.openReply.triggerError(1, authPacket.errorCode, authPacket.errorMessage);
|
|
// this.openReply = null;
|
|
// //this._emit("error", this, authPacket.errorCode, authPacket.errorMessage);
|
|
// this.close();
|
|
// }
|
|
// }
|
|
|
|
}
|
|
}
|
|
|
|
return offset; //if (offset < ends)
|
|
// this.processPacket(msg, offset, ends, data);
|
|
} // dataReceived(data) {
|
|
// var msg = data.read();
|
|
// var offset = 0;
|
|
// var ends = msg.length;
|
|
// var packet = this.packet;
|
|
// //console.log("Data");
|
|
// while (offset < ends) {
|
|
// offset = this.processPacket(msg, offset, ends, data);
|
|
// }
|
|
// }
|
|
|
|
}, {
|
|
key: "_dataReceived",
|
|
value: function _dataReceived(data) {
|
|
var _this$socket;
|
|
|
|
var msg = data.read();
|
|
var offset = 0;
|
|
var ends = msg.length;
|
|
this.socket.hold();
|
|
|
|
try {
|
|
while (offset < ends) {
|
|
offset = this._processPacket(msg, offset, ends, data);
|
|
}
|
|
} catch (ex) {
|
|
console.log(ex);
|
|
}
|
|
|
|
(_this$socket = this.socket) === null || _this$socket === void 0 ? void 0 : _this$socket.unhold();
|
|
}
|
|
}, {
|
|
key: "close",
|
|
value: function close(event) {
|
|
try {
|
|
this.socket.close();
|
|
} catch (_unused) {}
|
|
}
|
|
}, {
|
|
key: "reconnect",
|
|
value: function reconnect() {}
|
|
}, {
|
|
key: "hold",
|
|
value: function hold() {
|
|
this.holdSending = true;
|
|
}
|
|
}, {
|
|
key: "unhold",
|
|
value: function unhold() {
|
|
if (this.holdSending) {
|
|
this.holdSending = false;
|
|
var msg = this.sendBuffer.read();
|
|
if (msg == null || msg.length == 0) return;
|
|
this.socket.sendAll(msg);
|
|
}
|
|
}
|
|
}, {
|
|
key: "trigger",
|
|
value: function trigger(_trigger) {
|
|
if (_trigger == _IResource.ResourceTrigger.Open) {
|
|
if (this.server != null) return new _AsyncReply["default"](true);
|
|
|
|
var _this$instance$attrib = this.instance.attributes.toObject(),
|
|
_this$instance$attrib2 = _this$instance$attrib.domain,
|
|
domain = _this$instance$attrib2 === void 0 ? null : _this$instance$attrib2,
|
|
_this$instance$attrib3 = _this$instance$attrib.secure,
|
|
secure = _this$instance$attrib3 === void 0 ? false : _this$instance$attrib3,
|
|
_this$instance$attrib4 = _this$instance$attrib.username,
|
|
username = _this$instance$attrib4 === void 0 ? null : _this$instance$attrib4,
|
|
_this$instance$attrib5 = _this$instance$attrib.password,
|
|
password = _this$instance$attrib5 === void 0 ? null : _this$instance$attrib5,
|
|
_this$instance$attrib6 = _this$instance$attrib.checkInterval,
|
|
checkInterval = _this$instance$attrib6 === void 0 ? 30 : _this$instance$attrib6,
|
|
_this$instance$attrib7 = _this$instance$attrib.connectionTimeout,
|
|
connectionTimeout = _this$instance$attrib7 === void 0 ? 600 : _this$instance$attrib7,
|
|
_this$instance$attrib8 = _this$instance$attrib.revivingTime,
|
|
revivingTime = _this$instance$attrib8 === void 0 ? 120 : _this$instance$attrib8,
|
|
_this$instance$attrib9 = _this$instance$attrib.tokenIndex,
|
|
tokenIndex = _this$instance$attrib9 === void 0 ? 0 : _this$instance$attrib9,
|
|
_this$instance$attrib10 = _this$instance$attrib.token,
|
|
token = _this$instance$attrib10 === void 0 ? null : _this$instance$attrib10,
|
|
_this$instance$attrib11 = _this$instance$attrib.debug,
|
|
debug = _this$instance$attrib11 === void 0 ? false : _this$instance$attrib11;
|
|
|
|
this.debug = debug;
|
|
this.checkInterval = checkInterval * 1000; // check every 30 seconds
|
|
|
|
this.connectionTimeout = connectionTimeout * 1000; // 10 minutes (4 pings failed)
|
|
|
|
this.revivingTime = revivingTime * 1000; // 2 minutes
|
|
|
|
var host = this.instance.name.split(':');
|
|
var address = host[0];
|
|
var port = host.length > 1 ? parseInt(host[1]) : 10518;
|
|
|
|
if (username != null && password != null) {
|
|
var pw = _DC.DC.stringToBytes(password);
|
|
|
|
return this.connect(_AuthenticationMethod["default"].Credentials, null, address, port, username, null, pw, domain, secure);
|
|
} else if (token != null) {
|
|
var tk = token instanceof Uint8Array ? token : _DC.DC.stringToBytes(token);
|
|
return this.connect(_AuthenticationMethod["default"].Token, null, address, port, null, tokenIndex, tk, domain, secure);
|
|
} else {
|
|
return this.connect(_AuthenticationMethod["default"].None, null, address, port, null, 0, null, domain, secure);
|
|
}
|
|
}
|
|
|
|
return new _AsyncReply["default"](true);
|
|
}
|
|
}, {
|
|
key: "connect",
|
|
value: function connect() {
|
|
var method = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _AuthenticationMethod["default"].Certificate;
|
|
var socket = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
var hostname = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
var port = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
var username = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
|
|
var tokenIndex = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
var passwordOrToken = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null;
|
|
var domain = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : null;
|
|
var secure = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : false;
|
|
if (this.openReply != null) throw new _AsyncException["default"](_ErrorType["default"].Exception, 0, "Connection in progress");
|
|
this.openReply = new _AsyncReply["default"]();
|
|
|
|
if (hostname != null) {
|
|
this.session = new _Session["default"](new _ClientAuthentication["default"](), new _HostAuthentication["default"]());
|
|
this.session.localAuthentication.method = method;
|
|
this.session.localAuthentication.tokenIndex = tokenIndex;
|
|
this.session.localAuthentication.domain = domain;
|
|
this.session.localAuthentication.username = username;
|
|
this.localPasswordOrToken = passwordOrToken;
|
|
}
|
|
|
|
if (this.session == null) throw new _AsyncException["default"](_ErrorType["default"].Exception, 0, "Session not initialized");
|
|
if (socket == null) socket = new _WSocket["default"](); // TCPSocket();
|
|
|
|
if (port > 0) this._port = port;
|
|
if (hostname != null) this._hostname = hostname;
|
|
if (secure != null) this._secure = secure;
|
|
var self = this;
|
|
socket.connect(this._hostname, this._port, this._secure).then(function (x) {
|
|
self.assign(socket);
|
|
}).error(function (x) {
|
|
var _self$openReply;
|
|
|
|
(_self$openReply = self.openReply) === null || _self$openReply === void 0 ? void 0 : _self$openReply.triggerError(x);
|
|
self.openReply = null;
|
|
});
|
|
return this.openReply; // //connect(secure, method, hostname, port, username, tokenIndex, passwordOrToken, domain) {
|
|
// this.openReply = new AsyncReply();
|
|
// if (secure !== undefined) {
|
|
// this.session.localAuthentication.method = method;
|
|
// this.session.localAuthentication.tokenIndex = tokenIndex;
|
|
// this.session.localAuthentication.domain = domain;
|
|
// this.session.localAuthentication.username = username;
|
|
// this.localPasswordOrToken = passwordOrToken;
|
|
// //this.url = `ws${secure ? 's' : ''}://${this.instance.name}`;
|
|
// this.url = `ws${secure ? 's' : ''}://${hostname}:${port}`;
|
|
// let socket = new WebSocket(this.url, "iip");
|
|
// socket.binaryType = "arraybuffer";
|
|
// socket.connection = this;
|
|
// this.assign(socket);
|
|
// return this.openReply;
|
|
// }
|
|
}
|
|
}, {
|
|
key: "_declare",
|
|
value: function _declare() {
|
|
// declare (Credentials -> No Auth, No Enctypt)
|
|
var dmn = _DC.DC.stringToBytes(this.session.localAuthentication.domain);
|
|
|
|
if (this.session.localAuthentication.method == _AuthenticationMethod["default"].Credentials) {
|
|
var un = _DC.DC.stringToBytes(this.session.localAuthentication.username);
|
|
|
|
this.sendParams().addUint8(0x60).addUint8(dmn.length).addUint8Array(dmn).addUint8Array(this.localNonce).addUint8(un.length).addUint8Array(un).done();
|
|
} else if (this.session.localAuthentication.method == _AuthenticationMethod["default"].Token) {
|
|
this.sendParams().addUint8(0x70).addUint8(dmn.length).addUint8Array(dmn).addUint8Array(this.localNonce).addUint64(this.session.localAuthentication.tokenIndex).done();
|
|
} else if (this.session.localAuthentication.method == _AuthenticationMethod["default"].None) {
|
|
this.sendParams().addUint8(0x40).addUint8(dmn.length).addUint8Array(dmn).done();
|
|
}
|
|
}
|
|
}, {
|
|
key: "assign",
|
|
value: function assign(socket) {
|
|
this.socket = socket;
|
|
socket.receiver = this; // this.session.remoteAuthentication.source.attributes[SourceAttributeType.IPv4] = socket.RemoteEndPoint.Address;
|
|
// this.session.remoteAuthentication.source.attributes[SourceAttributeType.Port] = socket.RemoteEndPoint.Port;
|
|
// this.session.localAuthentication.source.attributes[SourceAttributeType.IPv4] = socket.LocalEndPoint.Address;
|
|
// this.session.localAuthentication.source.attributes[SourceAttributeType.Port] = socket.LocalEndPoint.Port;
|
|
|
|
if (socket.state == _SocketState["default"].Established && this.session.localAuthentication.type == _AuthenticationType["default"].Client) this._declare();
|
|
}
|
|
}, {
|
|
key: "_unsubscribeAll",
|
|
value: function _unsubscribeAll() {
|
|
var _iterator = _createForOfIteratorHelper(this.subscriptions.keys()),
|
|
_step;
|
|
|
|
try {
|
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
var _resource = _step.value;
|
|
|
|
_resource.instance.off("EventOccurred", _classPrivateFieldGet(this, _instance_eventOccurred), this);
|
|
|
|
_resource.instance.off("PropertyModified", _classPrivateFieldGet(this, _instance_propertyModified), this);
|
|
|
|
_resource.instance.off("ResourceDestroyed", _classPrivateFieldGet(this, _instance_resourceDestroyed), this);
|
|
}
|
|
} catch (err) {
|
|
_iterator.e(err);
|
|
} finally {
|
|
_iterator.f();
|
|
}
|
|
|
|
this.subscriptions.clear();
|
|
}
|
|
}, {
|
|
key: "destroy",
|
|
value: function destroy() {
|
|
this._unsubscribeAll();
|
|
|
|
_get(_getPrototypeOf(DistributedConnection.prototype), "destroy", this).call(this);
|
|
}
|
|
}, {
|
|
key: "networkClose",
|
|
value: function networkClose(socket) {
|
|
var _this$server3;
|
|
|
|
this.readyToEstablish = false;
|
|
|
|
try {
|
|
this.requests.values.forEach(function (x) {
|
|
return x.triggerError(new _AsyncException["default"](_ErrorType["default"].Management, 0, "Connection closed"));
|
|
});
|
|
this.resourceRequests.values.forEach(function (x) {
|
|
return x.triggerError(new _AsyncException["default"](_ErrorType["default"].Management, 0, "Connection closed"));
|
|
});
|
|
this.templateRequests.values.forEach(function (x) {
|
|
return x.triggerError(new _AsyncException["default"](_ErrorType["default"].Management, 0, "Connection closed"));
|
|
});
|
|
} catch (ex) {// unhandled error
|
|
}
|
|
|
|
this.requests.clear();
|
|
this.resourceRequests.clear();
|
|
this.templateRequests.clear();
|
|
this.resources.values.forEach(function (x) {
|
|
return x._suspend();
|
|
});
|
|
|
|
this._unsubscribeAll();
|
|
|
|
_Warehouse["default"].remove(this);
|
|
|
|
if (this.ready) (_this$server3 = this.server) === null || _this$server3 === void 0 ? void 0 : _this$server3.membership.logout(this.session);
|
|
this.ready = false;
|
|
|
|
this._emit("close", this);
|
|
}
|
|
}, {
|
|
key: "networkConnect",
|
|
value: function networkConnect(socket) {
|
|
if (this.session.localAuthentication.Type == _AuthenticationType["default"].Client) this._declare();
|
|
|
|
this._emit("connect", this);
|
|
}
|
|
}, {
|
|
key: "networkReceive",
|
|
value: function networkReceive(sender, buffer) {
|
|
try {
|
|
// Unassigned ?
|
|
if (this.socket == null) return; // Closed ?
|
|
|
|
if (this.socket.state == _SocketState["default"].Closed) return; //this.lastAction = DateTime.Now;
|
|
|
|
if (!this.processing) {
|
|
this.processing = true;
|
|
|
|
try {
|
|
while (buffer.available > 0 && !buffer["protected"]) {
|
|
//console.log("RX", buffer.length );
|
|
this._dataReceived(buffer);
|
|
}
|
|
} catch (_unused2) {}
|
|
|
|
this.processing = false;
|
|
}
|
|
} catch (ex) {
|
|
console.log(ex); //Global.Log("NetworkConnection", LogType.Warning, ex.ToString());
|
|
}
|
|
}
|
|
}, {
|
|
key: "put",
|
|
value: function put(resource) {
|
|
this.resources.add(parseInt(resource.instance.name), resource);
|
|
return new _AsyncReply["default"](true);
|
|
}
|
|
}, {
|
|
key: "remove",
|
|
value: function remove(resource) {// nothing to do (IStore interface)
|
|
} // Protocol Implementation
|
|
|
|
}, {
|
|
key: "sendRequest",
|
|
value: function sendRequest(action) {
|
|
var reply = new _AsyncReply["default"]();
|
|
this.callbackCounter++;
|
|
this.requests.set(this.callbackCounter, reply);
|
|
return this.sendParams(reply).addUint8(0x40 | action).addUint32(this.callbackCounter);
|
|
}
|
|
}, {
|
|
key: "sendDetachRequest",
|
|
value: function sendDetachRequest(instanceId) {
|
|
try {
|
|
return this.sendRequest(_IIPPacketAction["default"].DetachResource).addUint32(instanceId).done();
|
|
} catch (ex) {
|
|
return null;
|
|
}
|
|
}
|
|
}, {
|
|
key: "sendInvoke",
|
|
value: function sendInvoke(instanceId, index, parameters) {
|
|
var reply = new _AsyncReply["default"]();
|
|
|
|
var pb = _Codec["default"].compose(parameters, this);
|
|
|
|
var callbackId = ++this.callbackCounter;
|
|
this.sendParams().addUint8(0x40 | _IIPPacketAction["default"].InvokeFunction).addUint32(callbackId).addUint32(instanceId).addUint8(index).addUint8Array(pb).done();
|
|
this.requests.set(callbackId, reply);
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "sendError",
|
|
value: function sendError(type, callbackId, errorCode) {
|
|
var errorMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "";
|
|
|
|
var msg = _DC.DC.stringToBytes(errorMessage);
|
|
|
|
if (type == _ErrorType["default"].Management) this.sendParams().addUint8(0xC0 | _IIPPacketReport["default"].ManagementError).addUint32(callbackId).addUint16(errorCode).done();else if (type == _ErrorType["default"].Exception) this.sendParams().addUint8(0xC0 | _IIPPacketReport["default"].ExecutionError).addUint32(callbackId).addUint16(errorCode).addUint16(msg.length).addUint8Array(msg).done();
|
|
}
|
|
}, {
|
|
key: "sendProgress",
|
|
value: function sendProgress(callbackId, value, max) {
|
|
this.sendParams().addUint8(0xC0 | _IIPPacketReport["default"].ProgressReport).addUint32(callbackId).addInt32(value).addInt32(max).done();
|
|
}
|
|
}, {
|
|
key: "sendChunk",
|
|
value: function sendChunk(callbackId, chunk) {
|
|
var c = _Codec["default"].compose(chunk, this);
|
|
|
|
this.sendParams().addUint8(0xC0 | _IIPPacketReport["default"].ChunkStream).addUint32(callbackId).addUint8Array(c).done();
|
|
}
|
|
}, {
|
|
key: "IIPReply",
|
|
value: function IIPReply(callbackId) {
|
|
var results = Array.prototype.slice.call(arguments, 1);
|
|
var req = this.requests.item(callbackId);
|
|
this.requests.remove(callbackId);
|
|
req.trigger(results);
|
|
}
|
|
}, {
|
|
key: "IIPReplyInvoke",
|
|
value: function IIPReplyInvoke(callbackId, dataType, data) {
|
|
var req = this.requests.item(callbackId);
|
|
|
|
if (req != null) {
|
|
this.requests.remove(callbackId);
|
|
|
|
_Codec["default"].parse(data, 0, this, dataType).reply.then(function (rt) {
|
|
req.trigger(rt);
|
|
});
|
|
}
|
|
}
|
|
}, {
|
|
key: "IIPReportError",
|
|
value: function IIPReportError(callbackId, errorType, errorCode, errorMessage) {
|
|
var req = this.requests.item(callbackId);
|
|
|
|
if (req != null) {
|
|
this.requests.remove(callbackId);
|
|
req.triggerError(errorType, errorCode, errorMessage);
|
|
}
|
|
}
|
|
}, {
|
|
key: "IIPReportProgress",
|
|
value: function IIPReportProgress(callbackId, type, value, max) {
|
|
var req = this.requests.item(callbackId);
|
|
if (req != null) req.triggerProgress(type, value, max);
|
|
}
|
|
}, {
|
|
key: "IIPReportChunk",
|
|
value: function IIPReportChunk(callbackId, dataType, data) {
|
|
var req = this.requests.item(callbackId);
|
|
|
|
if (req != null) {
|
|
_Codec["default"].parse(data, 0, this, dataType).reply.then(function (x) {
|
|
req.triggerChunk(x);
|
|
});
|
|
}
|
|
}
|
|
}, {
|
|
key: "IIPEventResourceReassigned",
|
|
value: function IIPEventResourceReassigned(resourceId, newResourceId) {}
|
|
}, {
|
|
key: "IIPEventResourceDestroyed",
|
|
value: function IIPEventResourceDestroyed(resourceId) {
|
|
if (this.resources.item(resourceId)) {
|
|
var r = this.resources.item(resourceId);
|
|
this.resources.remove(resourceId);
|
|
r.destroy();
|
|
}
|
|
}
|
|
}, {
|
|
key: "IIPEventPropertyUpdated",
|
|
value: function IIPEventPropertyUpdated(resourceId, index, dataType, data) {
|
|
var self = this;
|
|
this.fetch(resourceId).then(function (r) {
|
|
var pt = r.instance.template.getPropertyTemplateByIndex(index);
|
|
if (pt == null) return; // ft found, fi not found, this should never happen
|
|
// push to the queue to gaurantee serialization
|
|
|
|
var item = new _AsyncReply["default"]();
|
|
self.queue.add(item);
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (args) {
|
|
item.trigger(new _DistributedResourceQueueItem["default"](r, _DistributedResourceQueueItemType["default"].Propery, args, index));
|
|
}).error(function (ex) {
|
|
self.queue.remove(item);
|
|
console.log("Esiur Property Error", ex);
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPEventEventOccurred",
|
|
value: function IIPEventEventOccurred(resourceId, index, dataType, data) {
|
|
var self = this;
|
|
this.fetch(resourceId).then(function (r) {
|
|
var et = r.instance.template.getEventTemplateByIndex(index);
|
|
if (et == null) return; // ft found, fi not found, this should never happen
|
|
// push to the queue to guarantee serialization
|
|
|
|
var item = new _AsyncReply["default"]();
|
|
self.queue.add(item); // Codec.parseVarArray(content, 0, content.length, self).then(function (args) {
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (args) {
|
|
item.trigger(new _DistributedResourceQueueItem["default"](r, _DistributedResourceQueueItemType["default"].Event, args, index));
|
|
}).error(function (ex) {
|
|
self.queue.remove(item);
|
|
console.log("Esiur Event Error", ex);
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPEventChildAdded",
|
|
value: function IIPEventChildAdded(resourceId, childId) {
|
|
var self = this;
|
|
this.fetch(resourceId).then(function (parent) {
|
|
self.fetch(childId).then(function (child) {
|
|
parent.instance.children.add(child);
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPEventChildRemoved",
|
|
value: function IIPEventChildRemoved(resourceId, childId) {
|
|
var self = this;
|
|
this.fetch(resourceId).then(function (parent) {
|
|
self.fetch(childId).then(function (child) {
|
|
parent.instance.children.remove(child);
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPEventRenamed",
|
|
value: function IIPEventRenamed(resourceId, name) {
|
|
this.fetch(resourceId).then(function (resource) {
|
|
resource.instance.attributes.set("name", name);
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPEventAttributesUpdated",
|
|
value: function IIPEventAttributesUpdated(resourceId, attributes) {
|
|
var self = this;
|
|
this.fetch(resourceId).then(function (resource) {
|
|
var attrs = attributes.getStringArray(0, attributes.length);
|
|
self.getAttributes(resource, attrs).then(function (s) {
|
|
resource.instance.setAttributes(s);
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "sendReply",
|
|
value: function sendReply(action, callbackId) {
|
|
return this.sendParams().addUint8(0x80 | action).addUint32(callbackId);
|
|
}
|
|
}, {
|
|
key: "sendEvent",
|
|
value: function sendEvent(evt) {
|
|
return this.sendParams().addUint8(evt);
|
|
}
|
|
}, {
|
|
key: "sendListenRequest",
|
|
value: function sendListenRequest(instanceId, index) {
|
|
var reply = new _AsyncReply["default"]();
|
|
var callbackId = ++this.callbackCounter;
|
|
this.sendParams().addUint8(0x40 | _IIPPacketAction["default"].Listen).addUint32(callbackId).addUint32(instanceId).addUint8(index).done();
|
|
this.requests.set(callbackId, reply);
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "sendUnlistenRequest",
|
|
value: function sendUnlistenRequest(instanceId, index) {
|
|
var reply = new _AsyncReply["default"]();
|
|
var callbackId = ++this.callbackCounter;
|
|
this.sendParams().addUint8(0x40 | _IIPPacketAction["default"].Unlisten).addUint32(callbackId).addUint32(instanceId).addUint8(index).done();
|
|
this.requests.set(callbackId, reply);
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "IIPRequestAttachResource",
|
|
value: function IIPRequestAttachResource(callback, resourceId) {
|
|
//var sl = this.sendParams();
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
if (r.instance.applicable(self.session, _ActionType["default"].Attach, null) == _Ruling["default"].Denied) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AttachDenied);
|
|
return;
|
|
}
|
|
|
|
self._unsubscribe(r); // reply ok
|
|
|
|
|
|
var link = _DC.DC.stringToBytes(r.instance.link);
|
|
|
|
if (r instanceof _DistributedResource["default"]) self.sendReply(_IIPPacketAction["default"].AttachResource, callback).addUint8Array(r.instance.template.classId.value).addUint64(r.instance.age).addUint16(link.length).addUint8Array(link).addUint8Array(_Codec["default"].compose(r._serialize(), self)).done();else self.sendReply(_IIPPacketAction["default"].AttachResource, callback).addUint8Array(r.instance.template.classId.value).addUint64(r.instance.age).addUint16(link.length).addUint8Array(link).addUint8Array(_Codec["default"].compose(r.instance.serialize(), self)).done();
|
|
|
|
self._subscribe(r);
|
|
} else {
|
|
// reply failed
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "_subscribe",
|
|
value: function _subscribe(resource) {
|
|
resource.instance.on("EventOccurred", _classPrivateFieldGet(this, _instance_eventOccurred), this);
|
|
resource.instance.on("PropertyModified", _classPrivateFieldGet(this, _instance_propertyModified), this);
|
|
resource.instance.on("ResourceDestroyed", _classPrivateFieldGet(this, _instance_resourceDestroyed), this);
|
|
this.subscriptions.set(resource, []);
|
|
}
|
|
}, {
|
|
key: "_unsubscribe",
|
|
value: function _unsubscribe(resource) {
|
|
resource.instance.off("EventOccurred", _classPrivateFieldGet(this, _instance_eventOccurred), this);
|
|
resource.instance.off("PropertyModified", _classPrivateFieldGet(this, _instance_propertyModified), this);
|
|
resource.instance.off("ResourceDestroyed", _classPrivateFieldGet(this, _instance_resourceDestroyed), this);
|
|
this.subscriptions["delete"](resource);
|
|
}
|
|
}, {
|
|
key: "IIPRequestReattachResource",
|
|
value: function IIPRequestReattachResource(callback, resourceId, resourceAge) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
self._unsubscribe(r);
|
|
|
|
self._subscribe(r); // reply ok
|
|
|
|
|
|
self.sendReply(_IIPPacketAction["default"].ReattachResource, callback).addUint64(r.instance.age).addUint8Array(_Codec["default"].compose(r.instance.serialize(), self)).done();
|
|
} else {
|
|
// reply failed
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestDetachResource",
|
|
value: function IIPRequestDetachResource(callback, resourceId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
self._unsubscribe(r); // reply ok
|
|
|
|
|
|
self.sendReply(_IIPPacketAction["default"].DetachResource, callback).done();
|
|
} else {
|
|
// reply failed
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestCreateResource",
|
|
value: function IIPRequestCreateResource(callback, storeId, parentId, content) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(storeId).then(function (store) {
|
|
if (store == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].StoreNotFound);
|
|
return;
|
|
}
|
|
|
|
if (!(store instanceof _IStore2["default"])) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceIsNotStore);
|
|
return;
|
|
} // check security
|
|
|
|
|
|
if (store.instance.applicable(self.session, _ActionType["default"].CreateResource, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].CreateDenied);
|
|
return;
|
|
}
|
|
|
|
_Warehouse["default"].getById(parentId).then(function (parent) {
|
|
// check security
|
|
if (parent != null) if (parent.instance.applicable(self.session, _ActionType["default"].AddChild, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AddChildDenied);
|
|
return;
|
|
}
|
|
var offset = 0;
|
|
var className = content.getString(offset + 1, content[0]);
|
|
offset += 1 + content[0];
|
|
var nameLength = content.getUint16(offset);
|
|
offset += 2;
|
|
var name = content.getString(offset, nameLength);
|
|
var cl = content.getUint32(offset);
|
|
offset += 4;
|
|
var type = window[className];
|
|
|
|
if (type == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ClassNotFound);
|
|
return;
|
|
}
|
|
|
|
DataDeserializer.listParser(content, offset, cl, self).then(function (parameters) {
|
|
offset += cl;
|
|
cl = content.getUint32(offset);
|
|
DataDeserializer.typedMapParser(content, offset, cl, self).then(function (attributes) {
|
|
offset += cl;
|
|
cl = content.length - offset;
|
|
DataDeserializer.typedMapParser(content, offset, cl, self).then(function (values) {
|
|
var resource = new (Function.prototype.bind.apply(type, values))();
|
|
|
|
_Warehouse["default"].put(name, resource, store, parent).then(function (ok) {
|
|
self.sendReply(_IIPPacketAction["default"].CreateResource, callback).addUint32(resource.Instance.Id).done();
|
|
}).error(function (ex) {
|
|
// send some error
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AddToStoreFailed);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestDeleteResource",
|
|
value: function IIPRequestDeleteResource(callback, resourceId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
if (r.instance.store.instance.applicable(session, _ActionType["default"].Delete, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].DeleteDenied);
|
|
return;
|
|
}
|
|
|
|
if (_Warehouse["default"].remove(r)) self.sendReply(_IIPPacketAction["default"].DeleteResource, callback).done();else self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].DeleteFailed);
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestLinkTemplates",
|
|
value: function IIPRequestLinkTemplates(callback, resourceLink) {
|
|
var _this3 = this,
|
|
_this$server4;
|
|
|
|
var queryCallback = function queryCallback(r) {
|
|
if (r == null) _this3.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);else {
|
|
var list = r.filter(function (x) {
|
|
return x.instance.applicable(_this3.session, _ActionType["default"].ViewTemplate, null) != _Ruling["default"].Denied;
|
|
});
|
|
if (list.length == 0) _this3.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);else {
|
|
// get all templates related to this resource
|
|
var msg = new BinaryList();
|
|
var templates = [];
|
|
|
|
for (var i = 0; i < list.length; i++) {
|
|
templates = templates.concat(_TypeTemplate["default"].getDependencies(list[i].instance.template).filter(function (x) {
|
|
return !templates.includes(x);
|
|
}));
|
|
}
|
|
|
|
for (var i = 0; i < templates.length; i++) {
|
|
msg.addInt32(templates[i].content.length).addUint8Array(templates[i].content);
|
|
} // send
|
|
|
|
|
|
_this3.sendReply(_IIPPacketAction["default"].LinkTemplates, callback).addDC(_TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.RawData, msg)).done();
|
|
}
|
|
}
|
|
};
|
|
|
|
if (((_this$server4 = this.server) === null || _this$server4 === void 0 ? void 0 : _this$server4.entryPoint) != null) this.server.entryPoint.query(resourceLink, this).then(queryCallback);else _Warehouse["default"].query(resourceLink).then(queryCallback);
|
|
}
|
|
}, {
|
|
key: "IIPRequestTemplateFromClassName",
|
|
value: function IIPRequestTemplateFromClassName(callback, className) {
|
|
var self = this;
|
|
|
|
var t = _Warehouse["default"].getTemplateByClassName(className);
|
|
|
|
if (t != null) {
|
|
self.sendReply(_IIPPacketAction["default"].TemplateFromClassName, callback).addUint32(t.content.length).addUint8Array(t.content).done();
|
|
} else {
|
|
// reply failed
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].TemplateNotFound);
|
|
}
|
|
}
|
|
}, {
|
|
key: "IIPRequestTemplateFromClassId",
|
|
value: function IIPRequestTemplateFromClassId(callback, classId) {
|
|
var self = this;
|
|
|
|
var t = _Warehouse["default"].getTemplateByClassId(classId);
|
|
|
|
if (t != null) self.sendReply(_IIPPacketAction["default"].TemplateFromClassId, callback).addDC(_TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.RawData, t.content)).done();else {
|
|
// reply failed
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].TemplateNotFound);
|
|
}
|
|
}
|
|
}, {
|
|
key: "IIPRequestTemplateFromResourceId",
|
|
value: function IIPRequestTemplateFromResourceId(callback, resourceId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) self.sendReply(_IIPPacketAction["default"].TemplateFromResourceId, callback).addDC(_TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.RawData, r.instance.template.content)).done();else {
|
|
// reply failed
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].TemplateNotFound);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestInvokeFunction",
|
|
value: function IIPRequestInvokeFunction(callback, resourceId, index, dataType, data) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r == null) {
|
|
this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
var ft = r.instance.template.getFunctionTemplateByIndex(index);
|
|
|
|
if (ft == null) {
|
|
// no function at this index
|
|
this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound);
|
|
return;
|
|
}
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (args) {
|
|
if (r instanceof _DistributedResource["default"]) {
|
|
var rt = r._invoke(index, args);
|
|
|
|
if (rt != null) {
|
|
rt.then(function (res) {
|
|
self.sendReply(_IIPPacketAction["default"].InvokeFunction, callback).addUint8Array(_Codec["default"].compose(res, self)).done();
|
|
});
|
|
} else {
|
|
// function not found on a distributed object
|
|
this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound);
|
|
return;
|
|
}
|
|
} else {
|
|
var fi = r[ft.name];
|
|
|
|
if (!(fi instanceof Function)) {
|
|
// ft found, fi not found, this should never happen
|
|
this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound);
|
|
return;
|
|
}
|
|
|
|
if (r.instance.applicable(self.session, _ActionType["default"].Execute, ft) == _Ruling["default"].Denied) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].InvokeDenied);
|
|
return;
|
|
}
|
|
|
|
var indexedArgs = [];
|
|
|
|
for (var i = 0; i < ft.args.length; i++) {
|
|
indexedArgs.push(args.get(i));
|
|
}
|
|
|
|
indexedArgs.push(self);
|
|
|
|
var _rt;
|
|
|
|
try {
|
|
_rt = fi.apply(r, indexedArgs);
|
|
} catch (ex) {
|
|
self.sendError(_ErrorType["default"].Exception, callback, 0, ex.toString());
|
|
return;
|
|
} // Is iterator ?
|
|
|
|
|
|
if (_rt != null && _rt[Symbol.iterator] instanceof Function) {
|
|
var _iterator2 = _createForOfIteratorHelper(_rt),
|
|
_step2;
|
|
|
|
try {
|
|
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
var v = _step2.value;
|
|
self.sendChunk(callback, v);
|
|
}
|
|
} catch (err) {
|
|
_iterator2.e(err);
|
|
} finally {
|
|
_iterator2.f();
|
|
}
|
|
|
|
self.sendReply(_IIPPacketAction["default"].InvokeFunction, callback).addUint8(DataType.Void).done();
|
|
} else if (_rt instanceof _AsyncReply["default"]) {
|
|
_rt.then(function (res) {
|
|
self.sendReply(_IIPPacketAction["default"].InvokeFunction, callback).addUint8Array(_Codec["default"].compose(res, self)).done();
|
|
}).error(function (ex) {
|
|
self.sendError(_ErrorType["default"].Exception, callback, ex.code, ex.message);
|
|
}).progress(function (pt, pv, pm) {
|
|
self.sendProgress(callback, pv, pm);
|
|
}).chunk(function (v) {
|
|
self.sendChunk(callback, v);
|
|
});
|
|
} else if (_rt instanceof Promise) {
|
|
_rt.then(function (res) {
|
|
self.sendReply(_IIPPacketAction["default"].InvokeFunction, callback).addUint8Array(_Codec["default"].compose(res, self)).done();
|
|
})["catch"](function (ex) {
|
|
self.sendError(_ErrorType["default"].Exception, callback, 0, ex.toString());
|
|
});
|
|
} else {
|
|
self.sendReply(_IIPPacketAction["default"].InvokeFunction, callback).addUint8Array(_Codec["default"].compose(_rt, self)).done();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
} // IIPRequestGetProperty(callback, resourceId, index) {
|
|
// var self = this;
|
|
// Warehouse.getById(resourceId).then(function (r) {
|
|
// if (r != null) {
|
|
// var pt = r.instance.template.getFunctionTemplateByIndex(index);
|
|
// if (pt != null) {
|
|
// if (r instanceof DistributedResource) {
|
|
// self.sendReply(IIPPacketAction.GetProperty, callback)
|
|
// .addUint8Array(Codec.compose(r._get(pt.index), self))
|
|
// .done();
|
|
// }
|
|
// else {
|
|
// var pv = r[pt.name];
|
|
// self.sendReply(IIPPacketAction.GetProperty)
|
|
// .addUint8Array(Codec.compose(pv, self))
|
|
// .done();
|
|
// }
|
|
// }
|
|
// else {
|
|
// // pt not found
|
|
// }
|
|
// }
|
|
// else {
|
|
// // resource not found
|
|
// }
|
|
// });
|
|
// }
|
|
// IIPRequestGetPropertyIfModifiedSince(callback, resourceId, index, age) {
|
|
// var self = this;
|
|
// Warehouse.getById(resourceId).then(function (r) {
|
|
// if (r != null) {
|
|
// var pt = r.instance.template.getFunctionTemplateByIndex(index);
|
|
// if (pt != null) {
|
|
// if (r.instance.getAge(index) > age) {
|
|
// var pv = r[pt.name];
|
|
// self.sendReply(IIPPacketAction.GetPropertyIfModified, callback)
|
|
// .addUint8Array(Codec.compose(pv, self))
|
|
// .done();
|
|
// }
|
|
// else {
|
|
// self.sendReply(IIPPacketAction.GetPropertyIfModified, callback)
|
|
// .addUint8(DataType.NotModified)
|
|
// .done();
|
|
// }
|
|
// }
|
|
// else {
|
|
// // pt not found
|
|
// }
|
|
// }
|
|
// else {
|
|
// // resource not found
|
|
// }
|
|
// });
|
|
// }
|
|
|
|
}, {
|
|
key: "IIPRequestListen",
|
|
value: function IIPRequestListen(callback, resourceId, index) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
var et = r.instance.template.getEventTemplateByIndex(index);
|
|
|
|
if (et != null) {
|
|
if (r instanceof _DistributedResource["default"]) {
|
|
r.listen(et).then(function (x) {
|
|
self.sendReply(_IIPPacketAction["default"].Listen, callback).done();
|
|
}).error(function (x) {
|
|
return self.sendError(_ErrorType["default"].Exception, callback, _ExceptionCode["default"].GeneralFailure);
|
|
});
|
|
} else {
|
|
if (!self.subscriptions.has(r)) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].NotAttached);
|
|
return;
|
|
}
|
|
|
|
if (self.subscriptions.get(r).includes(index)) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AlreadyListened);
|
|
return;
|
|
}
|
|
|
|
self.subscriptions.get(r).push(index);
|
|
self.sendReply(_IIPPacketAction["default"].Listen, callback).done();
|
|
}
|
|
} else {
|
|
// pt not found
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound);
|
|
}
|
|
} else {
|
|
// resource not found
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestUnlisten",
|
|
value: function IIPRequestUnlisten(callback, resourceId, index) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
var et = r.instance.template.getEventTemplateByIndex(index);
|
|
|
|
if (et != null) {
|
|
if (r instanceof _DistributedResource["default"]) {
|
|
r.unlisten(et).then(function (x) {
|
|
self.sendReply(_IIPPacketAction["default"].Unlisten, callback).done();
|
|
}).error(function (x) {
|
|
return self.sendError(_ErrorType["default"].Exception, callback, _ExceptionCode["default"].GeneralFailure);
|
|
});
|
|
} else {
|
|
if (!self.subscriptions.has(r)) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].NotAttached);
|
|
return;
|
|
}
|
|
|
|
if (!self.subscriptions.get(r).includes(index)) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AlreadyUnlistened);
|
|
return;
|
|
}
|
|
|
|
var ar = self.subscriptions.get(r);
|
|
var i = ar.indexOf(index);
|
|
ar.splice(i, 1);
|
|
self.sendReply(_IIPPacketAction["default"].Unlisten, callback).done();
|
|
}
|
|
} else {
|
|
// pt not found
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound);
|
|
}
|
|
} else {
|
|
// resource not found
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestSetProperty",
|
|
value: function IIPRequestSetProperty(callback, resourceId, index, dataType, data) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
var pt = r.instance.template.getPropertyTemplateByIndex(index);
|
|
|
|
if (pt != null) {
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (value) {
|
|
if (r instanceof _DistributedResource["default"]) {
|
|
// propagation
|
|
r._set(index, value).then(function (x) {
|
|
self.sendReply(_IIPPacketAction["default"].SetProperty, callback).done();
|
|
}).error(function (x) {
|
|
self.sendError(x.type, callback, x.code, x.message).done();
|
|
});
|
|
} else {
|
|
if (r.instance.applicable(self.session, _ActionType["default"].SetProperty, pt) == _Ruling["default"].Denied) {
|
|
self.sendError(_AsyncReply["default"].ErrorType.Exception, callback, _ExceptionCode["default"].SetPropertyDenied);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
if (r[pt.name] instanceof _DistributedPropertyContext["default"]) value = new _DistributedPropertyContext["default"](this, value);
|
|
r[pt.name] = value;
|
|
self.sendReply(_IIPPacketAction["default"].SetProperty, callback).done();
|
|
} catch (ex) {
|
|
self.sendError(_AsyncReply["default"].ErrorType.Exception, callback, 0, ex.toString()).done();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
// property not found
|
|
self.sendError(_AsyncReply["default"].ErrorType.Management, callback, _ExceptionCode["default"].PropertyNotFound).done();
|
|
}
|
|
} else {
|
|
// resource not found
|
|
self.sendError(_AsyncReply["default"].ErrorType.Management, callback, _ExceptionCode["default"].PropertyNotFound).done();
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestInquireResourceHistory",
|
|
value: function IIPRequestInquireResourceHistory(callback, resourceId, fromDate, toDate) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r != null) {
|
|
r.instance.store.getRecord(r, fromDate, toDate).then(function (results) {
|
|
var history = _Codec["default"].composeHistory(results, self, true);
|
|
|
|
self.sendReply(_IIPPacketAction["default"].ResourceHistory, callback).addUint8Array(history).done();
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestQueryResources",
|
|
value: function IIPRequestQueryResources(callback, resourceLink) {
|
|
var _this$server5;
|
|
|
|
var self = this;
|
|
|
|
var queryCallback = function queryCallback(resources) {
|
|
if (resources == null) self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);else {
|
|
var list = resources.filter(function (r) {
|
|
return r.instance.applicable(self.session, _ActionType["default"].Attach, null) != _Ruling["default"].Denied;
|
|
});
|
|
if (list.length == 0) self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);else self.sendReply(_IIPPacketAction["default"].QueryLink, callback).addUint8Array(_Codec["default"].compose(list, self)).done();
|
|
}
|
|
};
|
|
|
|
if (((_this$server5 = this.server) === null || _this$server5 === void 0 ? void 0 : _this$server5.entryPoint) != null) {
|
|
var _this$server6;
|
|
|
|
(_this$server6 = this.server) === null || _this$server6 === void 0 ? void 0 : _this$server6.entryPoint.query(resourceLink, this).then(queryCallback);
|
|
} else {
|
|
_Warehouse["default"].query(resourceLink).then(queryCallback);
|
|
}
|
|
}
|
|
}, {
|
|
key: "create",
|
|
value: function create(store, parent, className, parameters, attributes, values) {
|
|
var reply = new _AsyncReply["default"]();
|
|
|
|
var sb = _DC.DC.stringToBytes(className);
|
|
|
|
var pkt = (0, _DC.BL)().addUint32(store.instance.id).addUint32(parent.instance.id).addUint32(sb.length).addUint8Array(sb).addUint8Array(_Codec["default"].composeVarArray(parameters, this, true)).addUint8Array(_Codec["default"].composeStructure(attributes, this, true, true, true)).addUint8Array(_Codec["default"].composeStructure(values, this));
|
|
pkt.addUint32(pkt.length, 8);
|
|
this.sendRequest(_IIPPacketAction["default"].CreateResource).addUint8Array(pkt.ToArray()).done().then(function (args) {
|
|
var rid = args[0];
|
|
self.fetch(rid).then(function (r) {
|
|
reply.trigger(r);
|
|
});
|
|
});
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "query",
|
|
value: function query(resourceLink) {
|
|
var reply = new _AsyncReply["default"]();
|
|
var self = this;
|
|
|
|
var sb = _DC.DC.stringToBytes(resourceLink);
|
|
|
|
this.sendRequest(_IIPPacketAction["default"].QueryLink).addUint16(sb.length).addUint8Array(sb).done().then(function (ar) {
|
|
var dataType = ar[0];
|
|
var data = ar[1];
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (resources) {
|
|
reply.trigger(resources);
|
|
}).error(function (ex) {
|
|
return reply.triggerError(ex);
|
|
});
|
|
}).error(function (ex) {
|
|
reply.triggerError(ex);
|
|
});
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "getTemplate",
|
|
value: function getTemplate(classId) {
|
|
if (this.templates.contains(classId)) return new _AsyncReply["default"](this.templates.item(classId));else if (this.templateRequests.contains(classId)) return this.templateRequests.item(classId);
|
|
var reply = new _AsyncReply["default"]();
|
|
this.templateRequests.add(classId.valueOf(), reply);
|
|
var self = this;
|
|
this.sendRequest(_IIPPacketAction["default"].TemplateFromClassId).addUint8Array(classId.value).done().then(function (rt) {
|
|
self.templateRequests.remove(classId);
|
|
self.templates.add(rt[0].classId.valueOf(), rt[0]);
|
|
|
|
_Warehouse["default"].putTemplate(rt[0]);
|
|
|
|
reply.trigger(rt[0]);
|
|
});
|
|
return reply;
|
|
} // IStore interface
|
|
|
|
}, {
|
|
key: "get",
|
|
value: function get(path) {
|
|
var rt = new _AsyncReply["default"]();
|
|
this.query(path).then(function (ar) {
|
|
if (ar != null && ar.length > 0) rt.trigger(ar[0]);else rt.trigger(null);
|
|
}).error(function (ex) {
|
|
rt.triggerError(ex);
|
|
});
|
|
return rt;
|
|
/*
|
|
if (this.pathRequests[path])
|
|
return this.pathRequests[path];
|
|
var reply = new AsyncReply();
|
|
this.pathRequests[path] = reply;
|
|
var bl = new BinaryList();
|
|
bl.addString(path);
|
|
bl.addUint16(bl.length, 0);
|
|
var link = data.get
|
|
var self = this;
|
|
this.sendRequest(IIPPacketAction.ResourceIdFromResourceLink)
|
|
.addUint16(.then(function (rt) {
|
|
delete self.pathRequests[path];
|
|
self.fetch(rt[1]).then(function (r) {
|
|
reply.trigger(r);
|
|
});
|
|
});
|
|
return reply;
|
|
*/
|
|
}
|
|
}, {
|
|
key: "retrieve",
|
|
value: function retrieve(iid) {
|
|
var r = this.resources.item(iid);
|
|
return new _AsyncReply["default"](r); //for (var r in this.resources)
|
|
// if (this.resources[r].instance.id == iid)
|
|
// return new AsyncReply(r);
|
|
//return new AsyncReply(null);
|
|
}
|
|
}, {
|
|
key: "getLinkTemplates",
|
|
value: function getLinkTemplates(link) {
|
|
var reply = new _AsyncReply["default"]();
|
|
|
|
var l = _DC.DC.stringToBytes(link);
|
|
|
|
this.sendRequest(_IIPPacketAction["default"].LinkTemplates).addUint16(l.length).addUint8Array(l).done().then(function (rt) {
|
|
var templates = []; // parse templates
|
|
|
|
var tt = rt[0];
|
|
var data = rt[1]; //var offset = 0;
|
|
|
|
for (var offset = tt.offset; offset < tt.contentLength;) {
|
|
var cs = data.getUint32(offset);
|
|
offset += 4;
|
|
templates.push(_TypeTemplate["default"].parse(data, offset, cs));
|
|
offset += cs;
|
|
}
|
|
|
|
reply.trigger(templates);
|
|
}).error(function (ex) {
|
|
reply.triggerError(ex);
|
|
});
|
|
return reply;
|
|
} // Get a resource from the other end
|
|
|
|
}, {
|
|
key: "fetch",
|
|
value: function fetch(id) {
|
|
var resource = this.resources.item(id);
|
|
var request = this.resourceRequests.item(id);
|
|
|
|
if (request != null) {
|
|
if (resource != null) // dig for dead locks // or not
|
|
return new _AsyncReply["default"](resource);else return request;
|
|
} else if (resource != null && !resource._p.suspended) {
|
|
return new _AsyncReply["default"](resource);
|
|
}
|
|
|
|
var reply = new _AsyncReply["default"]();
|
|
this.resourceRequests.set(id, reply);
|
|
var self = this;
|
|
this.sendRequest(_IIPPacketAction["default"].AttachResource).addUint32(id).done().then(function (rt) {
|
|
var dr;
|
|
|
|
if (resource == null) {
|
|
var template = _Warehouse["default"].getTemplateByClassId(rt[0], _TemplateType["default"].Wrapper);
|
|
|
|
if ((template === null || template === void 0 ? void 0 : template.definedType) != null) dr = new template.getDependencies(self, id, rt[1], rt[2]);else dr = new _DistributedResource["default"](self, id, rt[1], rt[2]);
|
|
} else dr = resource; //let dr = resource || new DistributedResource(self, id, rt[1], rt[2]);
|
|
|
|
|
|
var transmissionType = rt[3];
|
|
var content = rt[4];
|
|
self.getTemplate(rt[0]).then(function (tmp) {
|
|
// ClassId, ResourceAge, ResourceLink, Content
|
|
if (resource == null) {
|
|
var wp = _Warehouse["default"].put(id.toString(), dr, self, null, tmp).then(function (ok) {
|
|
_Codec["default"].parse(content, 0, self, transmissionType).reply.then(function (ar) {
|
|
var pvs = new _PropertyValueArray["default"]();
|
|
|
|
for (var i = 0; i < ar.length; i += 3) {
|
|
pvs.push(new _PropertyValue["default"](ar[i + 2], ar[i], ar[i + 1]));
|
|
}
|
|
|
|
dr._attach(pvs);
|
|
|
|
self.resourceRequests.remove(id);
|
|
reply.trigger(dr);
|
|
}).error(function (ex) {
|
|
return reply.triggerError(ex);
|
|
});
|
|
});
|
|
|
|
wp.error(function (ex) {
|
|
reply.triggerError(ex);
|
|
});
|
|
} else {
|
|
_Codec["default"].parse(content, 0, self, transmissionType).reply.then(function (ar) {
|
|
//print("attached");
|
|
if (results != null) {
|
|
var pvs = new _PropertyValueArray["default"]();
|
|
|
|
for (var i = 0; i < ar.length; i += 3) {
|
|
pvs.push(new _PropertyValue["default"](ar[i + 2], ar[i], ar[i + 1]));
|
|
}
|
|
|
|
dr._attach(pvs);
|
|
}
|
|
|
|
self.resourceRequests.remove(id);
|
|
reply.trigger(dr);
|
|
}).error(function (ex) {
|
|
reply.triggerError(ex);
|
|
});
|
|
}
|
|
}).error(function (ex) {
|
|
reply.triggerError(ex);
|
|
});
|
|
}).error(function (ex) {
|
|
reply.triggerError(ex);
|
|
});
|
|
return reply;
|
|
}
|
|
}, {
|
|
key: "getRecord",
|
|
value: function getRecord(resource, fromDate, toDate) {
|
|
if (resource instanceof _DistributedResource["default"]) {
|
|
if (resource._p.connection != this) return new _AsyncReply["default"](null);
|
|
var reply = new _AsyncReply["default"]();
|
|
var self = this;
|
|
this.sendRequest(_IIPPacketAction["default"].ResourceHistory).addUint32(resource._p.instanceId).addDateTime(fromDate).addDateTime(toDate).done().then(function (rt) {
|
|
_Codec["default"].parseHistory(rt[0], 0, rt[0].length, resource, self).then(function (history) {
|
|
reply.trigger(history);
|
|
});
|
|
});
|
|
return reply;
|
|
} else return new _AsyncReply["default"](null);
|
|
}
|
|
}, {
|
|
key: "IIPRequestAddChild",
|
|
value: function IIPRequestAddChild(callback, parentId, childId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(parentId).then(function (parent) {
|
|
if (parent == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
_Warehouse["default"].getById(childId).then(function (child) {
|
|
if (child == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
if (parent.instance.applicable(self.session, _ActionType["default"].AddChild, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AddChildDenied);
|
|
return;
|
|
}
|
|
|
|
if (child.instance.applicable(self.session, _ActionType["default"].AddParent, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AddParentDenied);
|
|
return;
|
|
}
|
|
|
|
parent.instance.children.add(child);
|
|
self.sendReply(_IIPPacketAction["default"].AddChild, callback).done(); //child.Instance.Parents
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestRemoveChild",
|
|
value: function IIPRequestRemoveChild(callback, parentId, childId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(parentId).then(function (parent) {
|
|
if (parent == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
_Warehouse["default"].getById(childId).then(function (child) {
|
|
if (child == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
if (parent.instance.applicable(self.session, _ActionType["default"].RemoveChild, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AddChildDenied);
|
|
return;
|
|
}
|
|
|
|
if (child.instance.applicable(self.session, _ActionType["default"].RemoveParent, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].AddParentDenied);
|
|
return;
|
|
}
|
|
|
|
parent.instance.children.remove(child);
|
|
self.sendReply(_IIPPacketAction["default"].RemoveChild, callback).done(); //child.Instance.Parents
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestRenameResource",
|
|
value: function IIPRequestRenameResource(callback, resourceId, name) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (resource) {
|
|
if (resource == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
if (resource.instance.applicable(self.session, _ActionType["default"].Rename, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].RenameDenied);
|
|
return;
|
|
}
|
|
|
|
resource.instance.name = name;
|
|
self.sendReply(_IIPPacketAction["default"].RenameResource, callback).done();
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestResourceChildren",
|
|
value: function IIPRequestResourceChildren(callback, resourceId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (resource) {
|
|
if (resource == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
self.sendReply(_IIPPacketAction["default"].ResourceChildren, callback).addUint8Array(_Codec["default"].compose(resource.instance.children.toArray(), self)).done();
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestResourceParents",
|
|
value: function IIPRequestResourceParents(callback, resourceId) {
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (resource) {
|
|
if (resource == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
self.sendReply(_IIPPacketAction["default"].ResourceParents, callback).addUint8Array(_Codec["default"].compose(resource.instance.parents.toArray(), self)).done();
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestClearAttributes",
|
|
value: function IIPRequestClearAttributes(callback, resourceId, attributes) {
|
|
var all = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
if (r.instance.store.instance.applicable(self.session, _ActionType["default"].UpdateAttributes, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].UpdateAttributeDenied);
|
|
return;
|
|
}
|
|
|
|
var attrs = [];
|
|
if (!all) attrs = attributes.getStringArray(0, attributes.length);
|
|
if (r.instance.removeAttributes(attrs)) self.sendReply(all ? _IIPPacketAction["default"].ClearAllAttributes : _IIPPacketAction["default"].ClearAttributes, callback).done();else self.sendError(_AsyncReply["default"].ErrorType.Management, callback, _ExceptionCode["default"].UpdateAttributeFailed);
|
|
});
|
|
}
|
|
}, {
|
|
key: "IIPRequestUpdateAttributes",
|
|
value: function IIPRequestUpdateAttributes(callback, resourceId, attributes) {
|
|
var clearAttributes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
var self = this;
|
|
|
|
_Warehouse["default"].getById(resourceId).then(function (r) {
|
|
if (r == null) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound);
|
|
return;
|
|
}
|
|
|
|
if (r.instance.store.instance.applicable(self.session, _ActionType["default"].UpdateAttributes, null) != _Ruling["default"].Allowed) {
|
|
self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].UpdateAttributeDenied);
|
|
return;
|
|
}
|
|
|
|
DataDeserializer.typedListParser(attributes, 0, attributes.length, this).then(function (attrs) {
|
|
if (r.instance.setAttributes(attrs, clearAttributes)) self.sendReply(clearAttributes ? _IIPPacketAction["default"].ClearAllAttributes : _IIPPacketAction["default"].ClearAttributes, callback).done();else self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].UpdateAttributeFailed);
|
|
});
|
|
});
|
|
}
|
|
}, {
|
|
key: "getChildren",
|
|
value: function getChildren(resource) {
|
|
if (resource._p.connection != this) return new _AsyncReply["default"](null);
|
|
var rt = new _AsyncReply["default"]();
|
|
var self = this;
|
|
this.sendRequest(_IIPPacketAction["default"].ResourceChildren).addUint32(resource._p.instanceId).done().then(function (ar) {
|
|
var dataType = ar[0];
|
|
var data = ar[1];
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (resources) {
|
|
rt.trigger(resources);
|
|
}).error(function (ex) {
|
|
return rt.triggerError(ex);
|
|
});
|
|
});
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getParents",
|
|
value: function getParents(resource) {
|
|
if (resource._p.connection != this) return new _AsyncReply["default"](null);
|
|
var rt = new _AsyncReply["default"]();
|
|
var self = this;
|
|
this.sendRequest(_IIPPacketAction["default"].ResourceParents).addUint32(resource._p.instanceId).done().then(function (ar) {
|
|
var dataType = ar[0];
|
|
var data = ar[1];
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (resources) {
|
|
rt.trigger(resources);
|
|
}).error(function (ex) {
|
|
return rt.triggerError(ex);
|
|
});
|
|
});
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "removeAttributes",
|
|
value: function removeAttributes(resource) {
|
|
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
if (resource._p.connection != this) return new _AsyncReply["default"](null);
|
|
var rt = new _AsyncReply["default"]();
|
|
if (attributes == null) this.sendRequest(_IIPPacketAction["default"].ClearAllAttributes).addUint32(resource._p.instanceId).done().then(function (ar) {
|
|
rt.trigger(true);
|
|
}).error(function (ex) {
|
|
rt.triggerError(ex);
|
|
});else {
|
|
var attrs = _DC.DC.stringArrayToBytes(attributes);
|
|
|
|
this.sendRequest(_IIPPacketAction["default"].ClearAttributes).addUint32(resource.instance.id).addUint32(attrs.length).addUint8Array(attrs).done().then(function (ar) {
|
|
rt.trigger(true);
|
|
}).error(function (ex) {
|
|
rt.triggerError(ex);
|
|
});
|
|
}
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "setAttributes",
|
|
value: function setAttributes(resource, attributes) {
|
|
var clearAttributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
if (resource._p.connection != this) return new _AsyncReply["default"](null);
|
|
var rt = new _AsyncReply["default"]();
|
|
this.sendRequest(clearAttributes ? _IIPPacketAction["default"].UpdateAllAttributes : _IIPPacketAction["default"].UpdateAttributes).addUint32(resource._p.instanceId).addUint8Array(_Codec["default"].compose(attributes, this)).done().then(function () {
|
|
rt.trigger(true);
|
|
}).error(function (ex) {
|
|
rt.triggerError(ex);
|
|
});
|
|
return rt;
|
|
}
|
|
}, {
|
|
key: "getAttributes",
|
|
value: function getAttributes(resource) {
|
|
var attributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
if (resource._p.connection != this) return new _AsyncReply["default"](null);
|
|
var rt = new _AsyncReply["default"]();
|
|
var self = this;
|
|
|
|
if (attributes == null) {
|
|
this.sendRequest(_IIPPacketAction["default"].GetAllAttributes).addUint32(resource._p.instanceId).done().then(function (ar) {
|
|
var dataType = ar[0];
|
|
var data = ar[1];
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (st) {
|
|
var _resource$instance;
|
|
|
|
(_resource$instance = resource.instance) === null || _resource$instance === void 0 ? void 0 : _resource$instance.setAttributes(st);
|
|
rt.trigger(st);
|
|
}).error(function (ex) {
|
|
return rt.triggerError(ex);
|
|
});
|
|
}).error(function (ex) {
|
|
rt.triggerError(ex);
|
|
});
|
|
} else {
|
|
var attrs = _DC.DC.stringArrayToBytes(attributes);
|
|
|
|
this.sendRequest(_IIPPacketAction["default"].GetAttributes).addUint32(resource._p.instanceId).addUint32(attrs.length).addUint8Array(attrs).done().then(function (ar) {
|
|
var dataType = ar[0];
|
|
var data = ar[1];
|
|
|
|
_Codec["default"].parse(data, 0, self, dataType).reply.then(function (st) {
|
|
var _resource$instance2;
|
|
|
|
(_resource$instance2 = resource.instance) === null || _resource$instance2 === void 0 ? void 0 : _resource$instance2.setAttributes(st);
|
|
rt.trigger(st);
|
|
}).error(function (ex) {
|
|
return rt.triggerError(ex);
|
|
});
|
|
}).error(function (ex) {
|
|
return rt.triggerError(ex);
|
|
});
|
|
;
|
|
}
|
|
|
|
return rt;
|
|
}
|
|
}]);
|
|
|
|
return DistributedConnection;
|
|
}(_IStore2["default"]);
|
|
|
|
exports["default"] = DistributedConnection;
|
|
|
|
},{"../../Core/AsyncBag.js":2,"../../Core/AsyncException.js":3,"../../Core/AsyncQueue.js":4,"../../Core/AsyncReply.js":5,"../../Core/ErrorType.js":6,"../../Core/ExceptionCode.js":7,"../../Core/ProgressType.js":10,"../../Data/Codec.js":14,"../../Data/DC.js":15,"../../Data/KeyList.js":23,"../../Data/PropertyValue.js":26,"../../Data/PropertyValueArray.js":27,"../../Data/TransmissionType.js":38,"../../Resource/IResource.js":70,"../../Resource/IStore.js":71,"../../Resource/Template/TemplateType.js":82,"../../Resource/Template/TypeTemplate.js":83,"../../Resource/Warehouse.js":84,"../../Security/Authority/Authentication.js":85,"../../Security/Authority/AuthenticationMethod.js":86,"../../Security/Authority/AuthenticationType.js":87,"../../Security/Authority/ClientAuthentication.js":88,"../../Security/Authority/HostAuthentication.js":89,"../../Security/Authority/Session.js":90,"../../Security/Integrity/SHA256.js":91,"../../Security/Permissions/ActionType.js":93,"../../Security/Permissions/Ruling.js":95,"../Packets//IIPPacketReport.js":61,"../Packets/IIPAuthPacket.js":54,"../Packets/IIPAuthPacketAction.js":55,"../Packets/IIPAuthPacketCommand.js":56,"../Packets/IIPPacket.js":57,"../Packets/IIPPacketAction.js":58,"../Packets/IIPPacketCommand.js":59,"../Packets/IIPPacketEvent.js":60,"../SendList.js":62,"../Sockets/SocketState.js":64,"../Sockets/WSocket.js":65,"./DistributedPropertyContext.js":43,"./DistributedResource.js":44,"./DistributedResourceQueueItem.js":45,"./DistributedResourceQueueItemType.js":46}],43:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017-2018 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 27/10/2018.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var DistributedPropertyContext = function DistributedPropertyContext(p1, p2) {
|
|
_classCallCheck(this, DistributedPropertyContext);
|
|
|
|
if (arguments.length == 1) {
|
|
this.method = p1;
|
|
} else if (arguments.length == 2) {
|
|
this.connection = p1;
|
|
this.value = p2;
|
|
}
|
|
};
|
|
|
|
exports["default"] = DistributedPropertyContext;
|
|
|
|
},{}],44:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IResource2 = _interopRequireDefault(require("../../Resource/IResource.js"));
|
|
|
|
var _AsyncReply = _interopRequireDefault(require("../../Core/AsyncReply.js"));
|
|
|
|
var _Codec = _interopRequireDefault(require("../../Data/Codec.js"));
|
|
|
|
var _IIPPacketAction = _interopRequireDefault(require("../Packets//IIPPacketAction.js"));
|
|
|
|
var _EventTemplate = _interopRequireDefault(require("../../Resource/Template/EventTemplate.js"));
|
|
|
|
var _AsyncException = _interopRequireDefault(require("../../Core/AsyncException.js"));
|
|
|
|
var _ExceptionCode = _interopRequireDefault(require("../../Core//ExceptionCode.js"));
|
|
|
|
var _ErrorType = _interopRequireDefault(require("../../Core/ErrorType.js"));
|
|
|
|
var _ExtendedTypes = require("../../Data/ExtendedTypes.js");
|
|
|
|
var _TypedMap = _interopRequireDefault(require("../../Data/TypedMap.js"));
|
|
|
|
var _PropertyValueArray = _interopRequireDefault(require("../../Data/PropertyValueArray.js"));
|
|
|
|
var _PropertyValue = _interopRequireDefault(require("../../Data/PropertyValue.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var DistributedResource = /*#__PURE__*/function (_IResource) {
|
|
_inherits(DistributedResource, _IResource);
|
|
|
|
var _super = _createSuper(DistributedResource);
|
|
|
|
function DistributedResource(connection, instanceId, age, link) {
|
|
var _this;
|
|
|
|
_classCallCheck(this, DistributedResource);
|
|
|
|
_this = _super.call(this);
|
|
_this._p = {
|
|
suspended: false,
|
|
attached: false,
|
|
connection: connection,
|
|
instanceId: instanceId,
|
|
age: age,
|
|
link: link,
|
|
properties: []
|
|
};
|
|
return _this;
|
|
}
|
|
|
|
_createClass(DistributedResource, [{
|
|
key: "destroy",
|
|
value: function destroy() {
|
|
this.destroyed = true;
|
|
this._p.attached = false;
|
|
|
|
this._p.connection.sendDetachRequest(this._p.instanceId);
|
|
|
|
this._emit("destroy", this);
|
|
}
|
|
}, {
|
|
key: "_suspend",
|
|
value: function _suspend() {
|
|
this._p.suspended = true;
|
|
this._p.attached = false;
|
|
}
|
|
}, {
|
|
key: "trigger",
|
|
value: function trigger(type) {
|
|
return new _AsyncReply["default"](true);
|
|
}
|
|
}, {
|
|
key: "_serialize",
|
|
value: function _serialize() {
|
|
var props = new _PropertyValueArray["default"]();
|
|
|
|
for (var i = 0; i < this._p.properties.length; i++) {
|
|
props.push(new _PropertyValue["default"](this._p.properties[i], this.instance.getAge(i), this.instance.getModificationDate(i)));
|
|
}
|
|
|
|
return props;
|
|
}
|
|
}, {
|
|
key: "_attach",
|
|
value: function _attach(properties) {
|
|
if (this._p.attached) {
|
|
console.log("Already attached.");
|
|
return false;
|
|
} else {
|
|
this._p.attached = true;
|
|
this._p.suspended = false;
|
|
this._p.properties = [];
|
|
|
|
for (var i = 0; i < properties.length; i++) {
|
|
this.instance.setAge(i, properties[i].age);
|
|
this.instance.setModificationDate(i, properties[i].date);
|
|
|
|
this._p.properties.push(properties[i].value);
|
|
}
|
|
|
|
var self = this;
|
|
|
|
var makeFunc = function makeFunc(ft) {
|
|
var func = function func() {
|
|
var argsMap = new (_TypedMap["default"].of(_ExtendedTypes.UInt8, Object))();
|
|
|
|
if (arguments.length == 1 && arguments[0] instanceof Object && arguments[0].constructor.name == "Object") {
|
|
// named args
|
|
for (var _i = 0; _i < ft.args.length; _i++) {
|
|
var arg = ft.args[_i];
|
|
|
|
if (arguments[arg.name] != undefined) {
|
|
argsMap.set(new _ExtendedTypes.UInt8(arg.index), arguments[arg.name]);
|
|
}
|
|
}
|
|
|
|
return self._invoke(ft.index, argsMap);
|
|
} else {
|
|
for (var _i2 = 0; _i2 < arguments.length && _i2 < ft.args.length; _i2++) {
|
|
argsMap.set(new _ExtendedTypes.UInt8(_i2), arguments[_i2]);
|
|
}
|
|
|
|
return self._invoke(ft.index, argsMap);
|
|
}
|
|
}; // get expansion
|
|
|
|
|
|
func.help = self.instance.template.functions[ft.index].expansion;
|
|
return func;
|
|
};
|
|
|
|
var makeGetter = function makeGetter(index) {
|
|
return function () {
|
|
return self._get(index);
|
|
};
|
|
};
|
|
|
|
var makeSetter = function makeSetter(index) {
|
|
return function (value) {
|
|
self._set(index, value);
|
|
};
|
|
};
|
|
|
|
for (var _i3 = 0; _i3 < this.instance.template.functions.length; _i3++) {
|
|
var ft = this.instance.template.functions[_i3];
|
|
this[ft.name] = makeFunc(ft);
|
|
}
|
|
|
|
for (var _i4 = 0; _i4 < this.instance.template.properties.length; _i4++) {
|
|
var pt = this.instance.template.properties[_i4];
|
|
Object.defineProperty(this, pt.name, {
|
|
get: makeGetter(pt.index),
|
|
set: makeSetter(pt.index),
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}, {
|
|
key: "listen",
|
|
value: function listen(event) {
|
|
var et = event instanceof _EventTemplate["default"] ? event : this.instance.template.getEventTemplateByName(event);
|
|
if (et == null) return new _AsyncReply["default"]().triggerError(new _AsyncException["default"](_ErrorType["default"].Management, _ExceptionCode["default"].MethodNotFound, ""));
|
|
if (!et.listenable) return new _AsyncReply["default"]().triggerError(new _AsyncException["default"](_ErrorType["default"].Management, _ExceptionCode["default"].NotListenable, ""));
|
|
return this._p.connection.sendListenRequest(this._p.instanceId, et.index);
|
|
}
|
|
}, {
|
|
key: "unlisten",
|
|
value: function unlisten(event) {
|
|
var et = event instanceof _EventTemplate["default"] ? event : this.instance.template.getEventTemplateByName(event);
|
|
if (et == null) return new _AsyncReply["default"]().triggerError(new _AsyncException["default"](_ErrorType["default"].Management, _ExceptionCode["default"].MethodNotFound, ""));
|
|
if (!et.listenable) return new _AsyncReply["default"]().triggerError(new _AsyncException["default"](_ErrorType["default"].Management, _ExceptionCode["default"].NotListenable, ""));
|
|
return this._p.connection.sendUnlistenRequest(this._p.instanceId, et.index);
|
|
}
|
|
}, {
|
|
key: "_emitEventByIndex",
|
|
value: function _emitEventByIndex(index, args) {
|
|
var et = this.instance.template.getEventTemplateByIndex(index); //@TODO if array _emitArgs
|
|
//this._emitArgs(et.name, [args]);
|
|
|
|
this._emit(et.name, args);
|
|
|
|
this.instance._emitResourceEvent(null, null, et, args);
|
|
}
|
|
}, {
|
|
key: "_invoke",
|
|
value: function _invoke(index, args) {
|
|
if (this.destroyed) throw new Error("Trying to access destroyed object");
|
|
if (this._p.suspended) throw new Error("Trying to access suspended object");
|
|
if (index >= this.instance.template.functions.length) throw new Error("Function index is incorrect");
|
|
return this._p.connection.sendInvoke(this._p.instanceId, index, args);
|
|
}
|
|
}, {
|
|
key: "_get",
|
|
value: function _get(index) {
|
|
if (index >= this._p.properties.length) return null;
|
|
return this._p.properties[index];
|
|
}
|
|
}, {
|
|
key: "_updatePropertyByIndex",
|
|
value: function _updatePropertyByIndex(index, value) {
|
|
var pt = this.instance.template.getPropertyTemplateByIndex(index);
|
|
this._p.properties[index] = value;
|
|
this.instance.emitModification(pt, value); // this to invoke other property setters
|
|
|
|
this._p.neglect = true;
|
|
this[pt.name] = null;
|
|
this._p.neglect = false;
|
|
}
|
|
}, {
|
|
key: "_set",
|
|
value: function _set(index, value) {
|
|
if (!this._p.attached) {
|
|
console.log("Resource not attached.");
|
|
return;
|
|
}
|
|
|
|
if (this._p.neglect) return;
|
|
if (index >= this._p.properties.length) return null;
|
|
var reply = new _AsyncReply["default"]();
|
|
|
|
var parameters = _Codec["default"].compose(value, this._p.connection);
|
|
|
|
var self = this;
|
|
|
|
this._p.connection.sendRequest(_IIPPacketAction["default"].SetProperty).addUint32(self._p.instanceId).addUint8(index).addUint8Array(parameters).done().then(function (res) {
|
|
// not really needed, server will always send property modified, this only happens if the programmer forgot to emit in property setter
|
|
self._p.properties[index] = value;
|
|
reply.trigger(null);
|
|
});
|
|
|
|
return reply;
|
|
}
|
|
}]);
|
|
|
|
return DistributedResource;
|
|
}(_IResource2["default"]);
|
|
|
|
exports["default"] = DistributedResource;
|
|
|
|
},{"../../Core//ExceptionCode.js":7,"../../Core/AsyncException.js":3,"../../Core/AsyncReply.js":5,"../../Core/ErrorType.js":6,"../../Data/Codec.js":14,"../../Data/ExtendedTypes.js":19,"../../Data/PropertyValue.js":26,"../../Data/PropertyValueArray.js":27,"../../Data/TypedMap.js":41,"../../Resource/IResource.js":70,"../../Resource/Template/EventTemplate.js":76,"../Packets//IIPPacketAction.js":58}],45:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 25/07/2017.
|
|
*/
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
var DistributedResourceQueueItem = function DistributedResourceQueueItem(resource, type, value, index) {
|
|
_classCallCheck(this, DistributedResourceQueueItem);
|
|
|
|
this.resource = resource;
|
|
this.index = index;
|
|
this.type = type;
|
|
this.value = value;
|
|
};
|
|
|
|
exports["default"] = DistributedResourceQueueItem;
|
|
|
|
},{}],46:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
var _default = {
|
|
Propery: 0,
|
|
Event: 1
|
|
};
|
|
exports["default"] = _default;
|
|
|
|
},{}],47:[function(require,module,exports){
|
|
/*
|
|
* Copyright (c) 2017-2021 Ahmed Kh. Zamil
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
* copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
* SOFTWARE.
|
|
*/
|
|
|
|
/**
|
|
* Created by Ahmed Zamil on 03/05/2021.
|
|
*/
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IResource2 = _interopRequireDefault(require("../../Resource/IResource.js"));
|
|
|
|
var _AsyncReply = _interopRequireDefault(require("../../Core/AsyncReply.js"));
|
|
|
|
var _Codec = _interopRequireDefault(require("../../Data/Codec.js"));
|
|
|
|
var _Structure = _interopRequireDefault(require("../../Data/Structure.js"));
|
|
|
|
var _IIPPacketAction = _interopRequireDefault(require("../Packets//IIPPacketAction.js"));
|
|
|
|
var _EventTemplate = _interopRequireDefault(require("../../Resource/Template/EventTemplate.js"));
|
|
|
|
var _AsyncException = _interopRequireDefault(require("../../Core/AsyncException.js"));
|
|
|
|
var _ExceptionCode = _interopRequireDefault(require("../../Core//ExceptionCode.js"));
|
|
|
|
var _ErrorType = _interopRequireDefault(require("../../Core/ErrorType.js"));
|
|
|
|
var _DistributedConnection = _interopRequireDefault(require("./DistributedConnection.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var DistributedServer = /*#__PURE__*/function (_IResource) {
|
|
_inherits(DistributedServer, _IResource);
|
|
|
|
var _super = _createSuper(DistributedServer);
|
|
|
|
function DistributedServer() {
|
|
var _this;
|
|
|
|
_classCallCheck(this, DistributedServer);
|
|
|
|
_this = _super.call(this);
|
|
_this.connections = [];
|
|
return _this;
|
|
} //@TODO: con.off("close", ...)
|
|
|
|
|
|
_createClass(DistributedServer, [{
|
|
key: "destroy",
|
|
value: function destroy() {
|
|
this.connections = [];
|
|
this.destroyed = true;
|
|
|
|
this._emit("destroy", this);
|
|
}
|
|
}, {
|
|
key: "trigger",
|
|
value: function trigger(type) {
|
|
return new _AsyncReply["default"](true);
|
|
}
|
|
}, {
|
|
key: "membership",
|
|
get: function get() {
|
|
return this.instance.attributes.get("membership");
|
|
}
|
|
}, {
|
|
key: "entryPoint",
|
|
get: function get() {
|
|
return this.instance.attributes.get("entryPoint");
|
|
}
|
|
}, {
|
|
key: "add",
|
|
value: function add() {
|
|
var self = this;
|
|
var con = new _DistributedConnection["default"](this);
|
|
con.on("close", function () {
|
|
return self.remove(con);
|
|
});
|
|
this.connections.push(con);
|
|
return con;
|
|
}
|
|
}, {
|
|
key: "remove",
|
|
value: function remove(connection) {
|
|
var i = this.connections.indexOf(connection);
|
|
if (i > -1) this.connections.splice(i, 1);
|
|
}
|
|
}]);
|
|
|
|
return DistributedServer;
|
|
}(_IResource2["default"]);
|
|
|
|
exports["default"] = DistributedServer;
|
|
|
|
},{"../../Core//ExceptionCode.js":7,"../../Core/AsyncException.js":3,"../../Core/AsyncReply.js":5,"../../Core/ErrorType.js":6,"../../Data/Codec.js":14,"../../Data/Structure.js":35,"../../Resource/IResource.js":70,"../../Resource/Template/EventTemplate.js":76,"../Packets//IIPPacketAction.js":58,"./DistributedConnection.js":42}],48:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IResource2 = _interopRequireDefault(require("../../Resource/IResource.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var EntryPoint = /*#__PURE__*/function (_IResource) {
|
|
_inherits(EntryPoint, _IResource);
|
|
|
|
var _super = _createSuper(EntryPoint);
|
|
|
|
function EntryPoint() {
|
|
_classCallCheck(this, EntryPoint);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(EntryPoint, [{
|
|
key: "query",
|
|
value: function query(path, sender) {}
|
|
}, {
|
|
key: "create",
|
|
value: function create() {}
|
|
}]);
|
|
|
|
return EntryPoint;
|
|
}(_IResource2["default"]);
|
|
|
|
exports["default"] = EntryPoint;
|
|
|
|
},{"../../Resource/IResource.js":70}],49:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports["default"] = void 0;
|
|
|
|
var _IDestructible2 = _interopRequireDefault(require("../Core/IDestructible.js"));
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
|
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
|
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
|
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
|
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
|
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
|
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
|
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
|
|
var INetworkReceiver = /*#__PURE__*/function (_IDestructible) {
|
|
_inherits(INetworkReceiver, _IDestructible);
|
|
|
|
var _super = _createSuper(INetworkReceiver);
|
|
|
|
function INetworkReceiver() {
|
|
_classCallCheck(this, INetworkReceiver);
|
|
|
|
return _super.apply(this, arguments);
|
|
}
|
|
|
|
_createClass(INetworkReceiver, [{
|
|
key: "networkClose",
|
|
value: function networkClose(sender) {}
|
|
}, {
|
|
key: "networkReceive",
|
|
value: function networkReceive(sender, buffer) {}
|
|
}, {
|
|
key: "networkConnect",
|
|
value: function networkConnect(sender) {}
|
|
}]);
|
|
|
|
return INetworkReceiver;
|
|
}(_IDestructible2["default"]);
|
|
|
|
exports["default"] = INetworkReceiver;
|
|
|
|
},{"../Core/IDestructible.js":8}] |