diff --git a/README.md b/README.md index d01eee7..c8cec34 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,6 @@ # Esiur.JS Esiur Library for Javascript -# Usage +# Demo npm run demo -import io; -import sys; -import json; - -res = json.load(sys.stdin) -temp = res['main']['temp'] -hum = res['main']['humidity'] -vis = res['visibility'] -wind = res['wind']['speed'] -desc = res['weather'][0]['description'] - -sys.stdout.buffer.write(f'مرحبا بكم في أعمال, درجة الحرارة {temp} مئوية, الرطوبة {hum}%, مدى الرؤية {vis} متر, سرعة الرياح {wind} كيلومتر في الساعة, {desc}'.encode('utf8')) diff --git a/build/esiur.js b/build/esiur.js index 71bcd8a..fdbe55b 100644 --- a/build/esiur.js +++ b/build/esiur.js @@ -1,4 +1,14 @@ (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 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); } } @@ -1140,263 +1158,236 @@ var BinaryList = /*#__PURE__*/function () { function BinaryList() { _classCallCheck(this, BinaryList); - this.list = []; + this.list = []; //this.data = []; } _createClass(BinaryList, [{ - key: "addRange", - value: function addRange(bl) { - for (var i = 0; i < bl.list.length; i++) { - this.list.push(bl.list[i]); - } + 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: "add", - value: function add(typedValue, position) { - if (position !== undefined) this.list.splice(position, 0, typedValue);else this.list.push(typedValue); + 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.toArray().length; + return this.list.length; } }, { key: "toArray", value: function toArray() { - var ars = []; // calculate length - - for (var i = 0; i < this.list.length; i++) { - switch (this.list[i].type) { - case _DataType["default"].Bool: - ars.push(_DataConverter["default"].boolToBytes(this.list[i].value)); - break; - - case _DataType["default"].UInt8: - ars.push(_DataConverter["default"].uint8ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Int8: - ars.push(_DataConverter["default"].int8ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Char: - ars.push(_DataConverter["default"].charToBytes(this.list[i].value)); - break; - - case _DataType["default"].UInt16: - ars.push(_DataConverter["default"].uint16ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Int16: - ars.push(_DataConverter["default"].int16ToBytes(this.list[i].value)); - break; - - case _DataType["default"].UInt32: - ars.push(_DataConverter["default"].uint32ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Int32: - ars.push(_DataConverter["default"].int32ToBytes(this.list[i].value)); - break; - - case _DataType["default"].UInt64: - ars.push(_DataConverter["default"].uint64ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Int64: - ars.push(_DataConverter["default"].int64ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Float32: - ars.push(_DataConverter["default"].float32ToBytes(this.list[i].value)); - break; - - case _DataType["default"].Float64: - ars.push(_DataConverter["default"].float64ToBytes(this.list[i].value)); - break; - - case _DataType["default"].String: - ars.push(_DataConverter["default"].stringToBytes(this.list[i].value)); - break; - - case _DataType["default"].DateTime: - ars.push(_DataConverter["default"].dateTimeToBytes(this.list[i].value)); - break; - - case _DataType["default"].UInt8Array: - ars.push(this.list[i].value); - break; - - case _DataType["default"].UInt16Array: - ars.push(_DataConverter["default"].uint16ArrayToBytes(this.list[i].value)); - break; - - case _DataType["default"].UInt32Array: - ars.push(_DataConverter["default"].uint32ArrayToBytes(this.list[i].value)); - break; - - case _DataType["default"].Int16Array: - ars.push(_DataConverter["default"].int16ArrayToBytes(this.list[i].value)); - break; - - case _DataType["default"].Int32Array: - ars.push(_DataConverter["default"].int32ArrayToBytes(this.list[i].value)); - break; - - case _DataType["default"].Float32Array: - ars.push(_DataConverter["default"].float32ArrayToBytes(this.list[i].value)); - break; - - case _DataType["default"].Float64Array: - ars.push(_DataConverter["default"].float64ArrayToBytes(this.list[i].value)); - break; - //case DataType.Resource: - // ars.push(DC.uint32ToBytes(this.list[i].value.instance.id)); - // break; - //case DataType.DistributedResource: - // ars.push(DC.int8ToBytes(this.list[i].value)); - // break; - } - } - - var length = 0; - ars.forEach(function (a) { - length += a.length; //?? a.byteLength; - }); - var rt = new Uint8Array(length); - var offset = 0; - - for (var i = 0; i < ars.length; i++) { - rt.set(ars[i], offset); - offset += ars[i].length; // ?? ars[i].byteLength; - } - - return rt; + return new Uint8Array(this.list); } }, { key: "toDC", value: function toDC() { - return new _DataConverter["default"](this.toArray()); - } - }, { - key: "addDateTime", - value: function addDateTime(value, position) { - return this.add({ - type: _DataType["default"].DateTime, - value: value - }, position); - } - }, { - key: "addUint8Array", - value: function addUint8Array(value, position) { - return this.add({ - type: _DataType["default"].UInt8Array, - value: value - }, position); - } - }, { - key: "addHex", - value: function addHex(value, position) { - return this.addUint8Array(_DataConverter["default"].hexToBytes(value), position); - } - }, { - key: "addString", - value: function addString(value, position) { - return this.add({ - type: _DataType["default"].String, - value: value - }, position); - } - }, { - key: "addUint8", - value: function addUint8(value, position) { - return this.add({ - type: _DataType["default"].UInt8, - value: value - }, position); - } - }, { - key: "addInt8", - value: function addInt8(value, position) { - return this.add({ - type: _DataType["default"].Int8, - value: value - }, position); - } - }, { - key: "addChar", - value: function addChar(value, position) { - return this.add({ - type: _DataType["default"].Char, - value: value - }, position); - } - }, { - key: "addUint16", - value: function addUint16(value, position) { - return this.add({ - type: _DataType["default"].UInt16, - value: value - }, position); - } - }, { - key: "addInt16", - value: function addInt16(value, position) { - return this.add({ - type: _DataType["default"].Int16, - value: value - }, position); - } - }, { - key: "addUint32", - value: function addUint32(value, position) { - return this.add({ - type: _DataType["default"].UInt32, - value: value - }, position); - } - }, { - key: "addInt32", - value: function addInt32(value, position) { - return this.add({ - type: _DataType["default"].Int32, - value: value - }, position); - } - }, { - key: "addUint64", - value: function addUint64(value, position) { - return this.add({ - type: _DataType["default"].UInt64, - value: value - }, position); - } - }, { - key: "addInt64", - value: function addInt64(value, position) { - return this.add({ - type: _DataType["default"].Int64, - value: value - }, position); - } - }, { - key: "addFloat32", - value: function addFloat32(value, position) { - return this.add({ - type: _DataType["default"].Float32, - value: value - }, position); - } - }, { - key: "addFloat64", - value: function addFloat64(value, position) { - return this.add({ - type: _DataType["default"].Float64, - value: value - }, position); + return new _DC["default"](this.list); } }]); @@ -1405,7 +1396,7 @@ var BinaryList = /*#__PURE__*/function () { exports["default"] = BinaryList; -},{"./DataConverter.js":14,"./DataType.js":15}],13:[function(require,module,exports){ +},{"./DC.js":15}],14:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -1436,7 +1427,7 @@ exports["default"] = BinaryList; Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = void 0; +exports["default"] = exports.CodecParseResults = exports.CodecComposeResults = void 0; var _DataType = _interopRequireDefault(require("./DataType.js")); @@ -1452,7 +1443,7 @@ var _Structure = _interopRequireDefault(require("./Structure.js")); var _PropertyValue = _interopRequireDefault(require("./PropertyValue.js")); -var _DataConverter = require("./DataConverter.js"); +var _DC = require("./DC.js"); var _BinaryList = _interopRequireDefault(require("./BinaryList.js")); @@ -1480,16 +1471,1066 @@ 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 _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 _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); +// } +// /// +// /// Parse an array of bytes into array of resources +// /// +// /// Array of bytes. +// /// Number of bytes to parse. +// /// Zero-indexed offset. +// /// DistributedConnection is required to fetch resources. +// /// Array of resources. +// 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; +// } +// /// +// /// Compose an array of property values. +// /// +// /// PropertyValue array. +// /// DistributedConnection is required to check locality. +// /// If True, prepend the length as UInt32 at the beginning of the output. +// /// Array of bytes in the network byte order. +// 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(); +// } +// /// +// /// Compose a property value. +// /// +// /// Property value +// /// DistributedConnection is required to check locality. +// /// Array of bytes in the network byte order. +// static composePropertyValue(propertyValue, connection) +// { +// // age, date, value +// return BL().addUint64(propertyValue.age) +// .addDateTime(propertyValue.date) +// .addUint8Array(Codec.compose(propertyValue.value, connection)) +// .toArray(); +// } +// /// +// /// Parse property value. +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// DistributedConnection is required to fetch resources. +// /// Output content size. +// /// PropertyValue. +// 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; +// } +// /// +// /// Parse resource history +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// Number of bytes to parse. +// /// Resource +// /// Starting age. +// /// Ending age. +// /// DistributedConnection is required to fetch resources. +// /// +// 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; +// } +// /// +// /// Compose resource history +// /// +// /// History +// /// DistributedConnection is required to fetch resources. +// /// +// 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(); +// } +// /// +// /// Parse an array of ProperyValue. +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// Number of bytes to parse. +// /// DistributedConnection is required to fetch resources. +// /// +// 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(); +// } +// /// +// /// Compare two records +// /// +// /// Initial record to compare with +// /// Next record to compare with the initial +// /// DistributedConnection is required in case a structure holds items at the other end +// 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; +// } +// } +// /// +// /// Parse an array of structures +// /// +// /// Bytes array +// /// Zero-indexed offset +// /// Number of bytes to parse +// /// DistributedConnection is required in case a structure in the array holds items at the other end +// /// Array of structures +// 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); @@ -1497,1068 +2538,152 @@ var Codec = /*#__PURE__*/function () { _createClass(Codec, null, [{ key: "parse", - value: function parse(data, offset, sizeObject, connection) { - var dataType = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : _DataType["default"].Unspecified; - var size; //var reply = new AsyncReply(); - - var isArray; - var t; - - if (dataType == _DataType["default"].Unspecified) { - size = 1; - dataType = data[offset++]; - } else size = 0; - - t = dataType & 0x7F; - isArray = (dataType & 0x80) == 0x80; - - var payloadSize = _DataType["default"].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["default"].Void: - return Codec.parseVarArray(data, offset, contentLength, connection); - - case _DataType["default"].Bool: - return new _AsyncReply["default"](data.getBooleanArray(offset, contentLength)); - - case _DataType["default"].UInt8: - return new _AsyncReply["default"](data.getUint8Array(offset, contentLength)); - - case _DataType["default"].Int8: - return new _AsyncReply["default"](data.getInt8Array(offset, contentLength)); - - case _DataType["default"].Char: - return new _AsyncReply["default"](data.getCharArray(offset, contentLength)); - - case _DataType["default"].Int16: - return new _AsyncReply["default"](data.getInt16Array(offset, contentLength)); - - case _DataType["default"].UInt16: - return new _AsyncReply["default"](data.getUint16Array(offset, contentLength)); - - case _DataType["default"].Int32: - return new _AsyncReply["default"](data.getInt32Array(offset, contentLength)); - - case _DataType["default"].UInt32: - return new _AsyncReply["default"](data.getUint32Array(offset, contentLength)); - - case _DataType["default"].Int64: - return new _AsyncReply["default"](data.getInt64Array(offset, contentLength)); - - case _DataType["default"].UInt64: - return new _AsyncReply["default"](data.getUint64Array(offset, contentLength)); - - case _DataType["default"].Float32: - return new _AsyncReply["default"](data.getFloat32Array(offset, contentLength)); - - case _DataType["default"].Float64: - return new _AsyncReply["default"](data.getFloat64Array(offset, contentLength)); - - case _DataType["default"].String: - return new _AsyncReply["default"](data.getStringArray(offset, contentLength)); - - case _DataType["default"].Resource: - case _DataType["default"].DistributedResource: - return Codec.parseResourceArray(data, offset, contentLength, connection); - - case _DataType["default"].DateTime: - return new _AsyncReply["default"](data.getDateTimeArray(offset, contentLength)); - - case _DataType["default"].Structure: - return Codec.parseStructureArray(data, offset, contentLength, connection); - - case _DataType["default"].Record: - return Codec.parseRecordArray(data, offset, contentLength, connection); - } - } else { - switch (t) { - case _DataType["default"].NotModified: - return new _AsyncReply["default"](new _NotModified["default"]()); - - case _DataType["default"].Void: - return new _AsyncReply["default"](null); - - case _DataType["default"].Bool: - return new _AsyncReply["default"](data.getBoolean(offset)); - - case _DataType["default"].UInt8: - return new _AsyncReply["default"](data[offset]); - - case _DataType["default"].Int8: - return new _AsyncReply["default"](data.getInt8(offset)); - - case _DataType["default"].Char: - return new _AsyncReply["default"](data.getChar(offset)); - - case _DataType["default"].Int16: - return new _AsyncReply["default"](data.getInt16(offset)); - - case _DataType["default"].UInt16: - return new _AsyncReply["default"](data.getUint16(offset)); - - case _DataType["default"].Int32: - return new _AsyncReply["default"](data.getInt32(offset)); - - case _DataType["default"].UInt32: - return new _AsyncReply["default"](data.getUint32(offset)); - - case _DataType["default"].Int64: - return new _AsyncReply["default"](data.getInt64(offset)); - - case _DataType["default"].UInt64: - return new _AsyncReply["default"](data.getUint64(offset)); - - case _DataType["default"].Float32: - return new _AsyncReply["default"](data.getFloat32(offset)); - - case _DataType["default"].Float64: - return new _AsyncReply["default"](data.getFloat64(offset)); - - case _DataType["default"].String: - return new _AsyncReply["default"](data.getString(offset, contentLength)); - - case _DataType["default"].Resource: - return Codec.parseResource(data, offset); - - case _DataType["default"].DistributedResource: - return Codec.parseDistributedResource(data, offset, connection); - - case _DataType["default"].DateTime: - return new _AsyncReply["default"](data.getDateTime(offset)); - - case _DataType["default"].Structure: - return Codec.parseStructure(data, offset, contentLength, connection); - - case _DataType["default"].Record: - return Codec.parseRecord(data, offset, contentLength, connection); - } - } // @TODO: Throw exception - - - return new _AsyncReply["default"](null); - } - }, { - key: "parseResource", - value: function parseResource(data, offset) { - return _Warehouse["default"].getById(data.getUint32(offset)); - } - }, { - key: "parseDistributedResource", - value: function 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); - } /// - /// Parse an array of bytes into array of resources + value: //AsyncReply Parser(byte[] data, uint offset, uint length, DistributedConnection connection); + /// + /// Parse a value /// - /// Array of bytes. - /// Number of bytes to parse. + /// Bytes array /// Zero-indexed offset. - /// DistributedConnection is required to fetch resources. - /// Array of resources. + /// Output the number of bytes parsed + /// DistributedConnection is required in case a structure in the array holds items at the other end. + /// DataType, in case the data is not prepended with DataType + /// Value + 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: "parseResourceArray", - value: function parseResourceArray(data, offset, length, connection) { - var reply = new _AsyncBag["default"](); + key: "mapFromObject", + value: function mapFromObject(map) { + var rt = new Map(); - if (length == 0) { - reply.seal(); - return reply; + for (var i in map) { + rt.set(i, map[i]); } - - var end = offset + length; // - //var result = data[offset++]; - - var type = data[offset] & 0xF0; - var result = data[offset++] & 0xF; - - if (type == _ResourceArrayType["default"].Wrapper) { - var classId = data.getGuid(offset); - offset += 16; - - var tmp = _Warehouse["default"].getTemplateByClassId(classId, _TemplateType["default"].Resource); // not mine, look if the type is elsewhere - - - if (tmp == null) _Warehouse["default"].getTemplateByClassId(classId, _TemplateType["default"].Wrapper); - reply.arrayType = tmp === null || tmp === void 0 ? void 0 : tmp.definedType; - } else if (type == _ResourceArrayType["default"].Static) { - var _classId = data.getGuid(offset); - - offset += 16; - - var _tmp = _Warehouse["default"].getTemplateByClassId(_classId, _TemplateType["default"].Wrapper); - - reply.arrayType = _tmp === null || _tmp === void 0 ? void 0 : _tmp.definedType; - } - - var previous = null; - - if (result == _ResourceComparisonResult["default"].Empty) { - reply.seal(); - return reply; - } else if (result == _ResourceComparisonResult["default"].Null) { - previous = new _AsyncReply["default"](null); - } else if (result == _ResourceComparisonResult["default"].Local) { - previous = _Warehouse["default"].getById(data.getUint32(offset)); - offset += 4; - } else if (result == _ResourceComparisonResult["default"].Distributed) { - previous = connection.fetch(data.getUint32(offset)); - offset += 4; - } - - reply.add(previous); - - while (offset < end) { - result = data[offset++]; - var current = null; - - if (result == _ResourceComparisonResult["default"].Null) { - current = new _AsyncReply["default"](null); - } else if (result == _ResourceComparisonResult["default"].Same) { - current = previous; - } else if (result == _ResourceComparisonResult["default"].Local) { - current = _Warehouse["default"].getById(data.getUint32(offset)); - offset += 4; - } else if (result == _ResourceComparisonResult["default"].Distributed) { - current = connection.fetch(data.getUint32(offset)); - offset += 4; - } - - reply.add(current); - previous = current; - } - - reply.seal(); - return reply; + } + }, { + 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]; } /// - /// Compose an array of property values. + /// Compose a variable /// - /// PropertyValue array. + /// Value to compose. /// DistributedConnection is required to check locality. - /// If True, prepend the length as UInt32 at the beginning of the output. + /// If True, prepend the DataType at the beginning of the output. /// Array of bytes in the network byte order. - }, { - key: "composePropertyValueArray", - value: function composePropertyValueArray(array, connection) { - var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var rt = (0, _DataConverter.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(); - } /// - /// Compose a property value. - /// - /// Property value - /// DistributedConnection is required to check locality. - /// Array of bytes in the network byte order. - - }, { - key: "composePropertyValue", - value: function composePropertyValue(propertyValue, connection) { - // age, date, value - return (0, _DataConverter.BL)().addUint64(propertyValue.age).addDateTime(propertyValue.date).addUint8Array(Codec.compose(propertyValue.value, connection)).toArray(); - } /// - /// Parse property value. - /// - /// Array of bytes. - /// Zero-indexed offset. - /// DistributedConnection is required to fetch resources. - /// Output content size. - /// PropertyValue. - - }, { - key: "parsePropertyValue", - value: function parsePropertyValue(data, offset, sizeObject, connection) { - var reply = new _AsyncReply["default"](); - 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["default"](value, age, date)); - }); - sizeObject.size = 16 + cs.size; - return reply; - } /// - /// Parse resource history - /// - /// Array of bytes. - /// Zero-indexed offset. - /// Number of bytes to parse. - /// Resource - /// Starting age. - /// Ending age. - /// DistributedConnection is required to fetch resources. - /// - - }, { - key: "parseHistory", - value: function parseHistory(data, offset, length, resource, connection) { - var list = new _KeyList["default"](); - var reply = new _AsyncReply["default"](); - var bagOfBags = new _AsyncBag["default"](); - 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(function (x) { - for (var i = 0; i < list.length; i++) { - list.values[i] = x[i]; - } - - reply.trigger(list); - }); - return reply; - } /// - /// Compose resource history - /// - /// History - /// DistributedConnection is required to fetch resources. - /// - - }, { - key: "composeHistory", - value: function composeHistory(history, connection) { - var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var rt = new _BinaryList["default"](); - - 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(); - } /// - /// Parse an array of ProperyValue. - /// - /// Array of bytes. - /// Zero-indexed offset. - /// Number of bytes to parse. - /// DistributedConnection is required to fetch resources. - /// - - }, { - key: "parsePropertyValueArray", - value: function parsePropertyValueArray(data, offset, length, connection) { - var rt = new _AsyncBag["default"](); - - 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; - } - }, { - key: "parseStructure", - value: function parseStructure(data, offset, contentLength, connection) { - var metadata = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - var keys = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; - var types = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; - var reply = new _AsyncReply["default"](); - var bag = new _AsyncBag["default"](); - 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]); - var _rt = {}; - bag.add(Codec.parse(data, offset, _rt, connection)); - contentLength -= _rt.size; - offset += _rt.size; - } - } else { - for (var _i2 = 0; _i2 < keys.length; _i2++) { - keylist.push(keys[_i2]); - typelist.push(types[_i2]); - } - - var _i = 0; - - while (contentLength > 0) { - var _rt2 = {}; - bag.add(Codec.parse(data, offset, _rt2, connection, types[_i])); - contentLength -= _rt2.size; - offset += _rt2.size; - _i++; - } - } - - bag.seal(); - bag.then(function (res) { - // compose the list - var s = new _Structure["default"](); - - 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; - } - }, { - key: "parseVarArray", - value: function parseVarArray(data, offset, contentLength, connection) { - var rt = new _AsyncBag["default"](); - - 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; - } }, { key: "compose", - value: function compose(value, connection) { - var prependType = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - if (value instanceof Function) value = value(connection);else if (value instanceof _DistributedPropertyContext["default"]) value = value.method(this); - var type = Codec.getDataType(value, connection); - var rt = new _BinaryList["default"](); + 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 a; + // //a.Invoke() + // } + // } + // } + // if (valueOrSource is IUserType) + // valueOrSource = (valueOrSource as IUserType).Get(); + //if (valueOrSource is Func) + // valueOrSource = (valueOrSource as Func)(connection); + // if (valueOrSource == null) + // return TransmissionType.Compose(TransmissionTypeIdentifier.Null, null); + // type = valueOrSource.GetType(); - switch (type) { - case _DataType["default"].Void: - // nothing to do; - break; - - case _DataType["default"].String: - var st = _DataConverter.DC.stringToBytes(value); - - rt.addUint32(st.length).addUint8Array(st); - break; - - case _DataType["default"].Resource: - rt.addUint32(value._p.instanceId); - break; - - case _DataType["default"].DistributedResource: - // rt.addUint8Array(DC.stringToBytes(value.instance.template.classId)).addUint32(value.instance.id); - rt.addUint32(value.instance.id); - break; - - case _DataType["default"].Structure: - rt.addUint8Array(Codec.composeStructure(value, connection, true, true, true)); - break; - - case _DataType["default"].VarArray: - rt.addUint8Array(Codec.composeVarArray(value, connection, true)); - break; - - case _DataType["default"].Record: - rt.addUint8Array(Codec.composeRecord(value, connection, true, true)); - break; - - case _DataType["default"].ResourceArray: - rt.addUint8Array(Codec.composeResourceArray(value, connection, true)); - break; - - case _DataType["default"].StructureArray: - rt.addUint8Array(Codec.composeStructureArray(value, connection, true)); - break; - - case _DataType["default"].RecordArray: - rt.addUint8Array(Codec.composeRecordArray(value, connection, true)); - break; - - default: - rt.add({ - type: type, - value: value - }); - if (_DataType["default"].isArray(type)) rt.addUint32(rt.length, 0); - break; - } - - if (prependType) rt.addUint8(type, 0); - return rt.toArray(); - } - }, { - key: "composeVarArray", - value: function composeVarArray(array, connection) { - var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - var rt = new _BinaryList["default"](); - - 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(); - } - }, { - key: "composeStructure", - value: function composeStructure(value, connection) { - var includeKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - var includeTypes = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true; - var prependLength = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; - var rt = new _BinaryList["default"](); - var keys = value.getKeys(); - - if (includeKeys) { - for (var i = 0; i < keys.length; i++) { - var key = _DataConverter.DC.stringToBytes(keys[i]); - - rt.addUint8(key.length).addUint8Array(key).addUint8Array(Codec.compose(value[keys[i]], connection)); - } + if (this.composers[type] != undefined) { + var results = this.composers[type](valueOrSource, connection); + return _TransmissionType.TransmissionType.compose(results.identifier, results.data); } else { - for (var _i3 = 0; _i3 < keys.length; _i3++) { - rt.addUint8Array(Codec.compose(value[keys[_i3]], connection, includeTypes)); + 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); } } - if (prependLength) rt.addUint32(rt.length, 0); - return rt.toArray(); - } - }, { - key: "composeStructureArray", - value: function composeStructureArray(structures, connection) { - var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (structures == null || structures.length == 0 || !(structures instanceof _StructureArray["default"])) return new _DataConverter.DC(0); - var rt = new _BinaryList["default"](); - var comparision = _StructureComparisonResult["default"].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["default"].Structure) rt.addUint8Array(Codec.composeStructure(structures[i], connection));else if (comparision == _StructureComparisonResult["default"].StructureSameKeys) rt.addUint8Array(Codec.composeStructure(structures[i], connection, false));else if (comparision == _StructureComparisonResult["default"].StructureSameTypes) rt.addUint8Array(Codec.composeStructure(structures[i], connection, false, false)); - } - - if (prependLength) rt.addUint32(rt.length, 0); - return rt.toArray(); + return _TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.Null, new _DC.DC(0)); } /// - /// Compare two records + /// Check if a resource is local to a given connection. /// - /// Initial record to compare with - /// Next record to compare with the initial - /// DistributedConnection is required in case a structure holds items at the other end + /// Resource to check. + /// DistributedConnection to check if the resource is local to it. + /// True, if the resource owner is the given connection, otherwise False. - }, { - key: "compareRecords", - value: function compareRecords(initial, next) { - if (next == null) return _RecordComparisonResult["default"].Null; - if (initial == null) return _RecordComparisonResult["default"].Record; - if (next == initial) return _RecordComparisonResult["default"].Same; - if (next.constructor === initial.constructor) return _RecordComparisonResult["default"].RecordSameType; - return _RecordComparisonResult["default"].Record; - } - }, { - key: "parseRecordArray", - value: function parseRecordArray(data, offset, length, connection) { - var reply = new _AsyncBag["default"](); - - 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["default"].getTemplateByClassId(classId, _TemplateType["default"].Record); - - reply.arrayType = template === null || template === void 0 ? void 0 : template.definedType; - var previous = null; - - if (result == _RecordComparisonResult["default"].Empty) { - reply.seal(); - return reply; - } else if (result == _RecordComparisonResult["default"].Null) { - previous = new _AsyncReply["default"](null); - } else if (result == _RecordComparisonResult["default"].Record || result == _RecordComparisonResult["default"].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["default"].Null) previous = new _AsyncReply["default"](null);else if (result == _RecordComparisonResult["default"].Record || result == _RecordComparisonResult["default"].RecordSameType) { - var _cs = data.getUint32(offset); - - offset += 4; - previous = Codec.parseRecord(data, offset, _cs, connection, classId); - offset += _cs; - } else if (result == _RecordComparisonResult["default"].Same) {// do nothing - } - reply.add(previous); - } - } else { - var _previous = null; - var _classId2 = null; - - if (result == _RecordComparisonResult["default"].Empty) { - reply.seal(); - return reply; - } else if (result == _RecordComparisonResult["default"].Null) _previous = new _AsyncReply["default"](null);else if (result == _RecordComparisonResult["default"].Record) { - var _cs2 = data.getUint32(offset); - - var _recordLength = _cs2 - 16; - - offset += 4; - _classId2 = data.getGuid(offset); - offset += 16; - _previous = Codec.parseRecord(data, offset, _recordLength, connection, _classId2); - offset += _recordLength; - } - - reply.add(_previous); - - while (offset < end) { - result = data.getUint8(offset++); - if (result == _RecordComparisonResult["default"].Null) _previous = new _AsyncReply["default"](null);else if (result == _RecordComparisonResult["default"].Record) { - var _cs3 = data.getUint32(offset); - - var _recordLength2 = _cs3 - 16; - - offset += 4; - _classId2 = data.getGuid(offset); - offset += 16; - _previous = Codec.parseRecord(data, offset, _recordLength2, connection, _classId2); - offset += _recordLength2; - } else if (result == _RecordComparisonResult["default"].RecordSameType) { - var _cs4 = data.getUint32(offset); - - offset += 4; - _previous = this.parseRecord(data, offset, _cs4, connection, _classId2); - offset += _cs4; - } else if (result == _RecordComparisonResult["default"].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; - } - }, { - key: "parseRecord", - value: function parseRecord(data, offset, length, connection) { - var classId = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; - var reply = new _AsyncReply["default"](); - - if (classId == null) { - classId = data.getGuid(offset); - offset += 16; - length -= 16; - } - - var template = _Warehouse["default"].getTemplateByClassId(classId, _TemplateType["default"].Record); - - if (template != null) { - Codec.parseVarArray(data, offset, length, connection).then(function (ar) { - if (template.definedType != null) { - var record = new template.definedType(); - - for (var i = 0; i < template.properties.length; i++) { - record[template.properties[i].name] = ar[i]; - } - - reply.trigger(record); - } else { - var _record = new _Record["default"](); - - for (var _i4 = 0; _i4 < template.properties.length; _i4++) { - _record[template.properties[_i4].name] = ar[_i4]; - } - - reply.trigger(_record); - } - }); - } else { - connection.getTemplate(classId).then(function (tmp) { - Codec.parseVarArray(data, offset, length, connection).then(function (ar) { - var record = new _Record["default"](); - - for (var i = 0; i < tmp.properties.length; i++) { - record[tmp.properties[i].name] = ar[i]; - } - - reply.trigger(record); - }); - }).error(function (x) { - return reply.triggerError(x); - }); - } - - return reply; - } - }, { - key: "composeRecord", - value: function composeRecord(record, connection) { - var includeClassId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true; - var prependLength = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false; - var rt = new _BinaryList["default"](); - - var template = _Warehouse["default"].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(); - } - }, { - key: "composeRecordArray", - value: function composeRecordArray(records, connection) { - var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (records == null) //|| records?.length == 0) - return prependLength ? new _DataConverter.DC(4) : new _DataConverter.DC(0); - var rt = new _BinaryList["default"](); //var comparsion = Codec.compareRecords(null, records[0]); - - var comparsion = records.length == 0 ? _RecordComparisonResult["default"].Empty : Codec.compareRecords(null, records[0]); - rt.addUint8(comparsion); - if (comparsion == _RecordComparisonResult["default"].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["default"].Record) rt.addUint8Array(Codec.composeRecord(records[i], connection, true, true));else if (comparsion == _RecordComparisonResult["default"].RecordSameType) rt.addUint8Array(Codec.composeRecord(records[i], connection, false, true)); - } - - if (prependLength) rt.insertInt32(0, rt.length); - return rt.toArray(); - } - }, { - key: "compareStructure", - value: function compareStructure(previous, next, connection) { - if (next == null) return _StructureComparisonResult["default"].Null; - if (previous == null) return _StructureComparisonResult["default"].Structure; - if (next == previous) return _StructureComparisonResult["default"].Same; - if (previous.length != next.length) return _StructureComparisonResult["default"].Structure; - var previousKeys = previous.getKeys(); - var nextKeys = next.getKeys(); - - for (var i = 0; i < previousKeys.length; i++) { - if (previousKeys[i] != nextKeys[i]) return _StructureComparisonResult["default"].Structure; - } - - var previousTypes = Codec.getStructureDateTypes(previous, connection); - var nextTypes = Codec.getStructureDateTypes(next, connection); - - for (var _i5 = 0; _i5 < previousTypes.length; _i5++) { - if (previousTypes[_i5] != nextTypes[_i5]) return _StructureComparisonResult["default"].StructureSameKeys; - } - - return _StructureComparisonResult["default"].StructureSameTypes; - } - }, { - key: "getStructureDateTypes", - value: function 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; - } }, { key: "isLocalResource", value: function isLocalResource(resource, connection) { - if (resource instanceof _DistributedResource["default"]) if (resource._p.connection == connection) return true; + if (connection == null) return false; + + if (resource instanceof _DistributedResource["default"]) { + if (resource.connection == connection) return true; + } + return false; } - }, { - key: "composeResource", - value: function composeResource(resource, connection) { - if (Codec.isLocalResource(resource, connection)) return (0, _DataConverter.BL)().addUint32(resource.id);else { - return (0, _DataConverter.BL)().addUint8Array(resource.instance.template.classId.value).addUint32(resource.instance.id); - } - } - }, { - key: "compareResource", - value: function compareResource(previous, next, connection) { - if (next == null) return _ResourceComparisonResult["default"].Null;else if (next == previous) return _ResourceComparisonResult["default"].Same;else if (Codec.isLocalResource(next, connection)) return _ResourceComparisonResult["default"].Local;else return _ResourceComparisonResult["default"].Distributed; - } - }, { - key: "composeResourceArray", - value: function composeResourceArray(resources, connection) { - var prependLength = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; - if (resources == null) // || resources.length == 0)// || !(resources instanceof ResourceArray)) - return prependLength ? new _DataConverter.DC(4) : new _DataConverter.DC(0); - var rt = new _BinaryList["default"](); - var comparsion = resources.length == 0 ? _ResourceComparisonResult["default"].Empty : Codec.compareResource(null, resources[0], connection); - rt.addUint8(comparsion); - if (comparsion == _ResourceComparisonResult["default"].Local) rt.addUint32(resources[0]._p.instanceId);else if (comparsion == _ResourceComparisonResult["default"].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["default"].Local) rt.addUint32(resources[i]._p.instanceId);else if (comparsion == _ResourceComparisonResult["default"].Distributed) rt.addUint32(resources[i].instance.id); - } - - if (prependLength) rt.addUint32(rt.length, 0); - return rt.toArray(); - } - }, { - key: "getDataType", - value: function 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["default"].UInt64; - } else { - return _DataType["default"].UInt32; - } - } else { - return _DataType["default"].UInt16; - } - } else { - return _DataType["default"].UInt8; - } - } else { - if (value < -128) { - if (value < -32768) { - if (value < -2147483648) { - return _DataType["default"].Int64; - } else { - return _DataType["default"].Int32; - } - } else { - return _DataType["default"].Int16; - } - } else { - return _DataType["default"].Int8; - } - } - } else { - // float or double - return _DataType["default"].Float64; - } - - case "string": - return _DataType["default"].String; - - case "boolean": - return _DataType["default"].Bool; - - case "object": - if (value instanceof Array) { - return _DataType["default"].VarArray; - } else if (value instanceof _IResource["default"]) { - return Codec.isLocalResource(value, connection) ? _DataType["default"].Resource : _DataType["default"].DistributedResource; - } else if (value instanceof Date) { - return _DataType["default"].DateTime; - } else if (value instanceof Uint8Array || value instanceof ArrayBuffer) { - return _DataType["default"].UInt8Array; - } else if (value instanceof Uint16Array) return _DataType["default"].UInt16Array;else if (value instanceof Uint32Array) return _DataType["default"].UInt32Array;else if (value instanceof Int16Array) return _DataType["default"].Int16Array;else if (value instanceof Int32Array) return _DataType["default"].Int32Array;else if (value instanceof Float32Array) return _DataType["default"].Float32Array;else if (value instanceof Float64Array) return _DataType["default"].Float64Array;else if (value instanceof Number) { - // JS numbers are always 64-bit float - return _DataType["default"].Float64; - } else if (value instanceof _Structure["default"]) { - return _DataType["default"].Structure; - } else if (value instanceof _IRecord["default"]) { - return _DataType["default"].Record; - } else { - return _DataType["default"].Void; - } - - default: - return _DataType["default"].Void; - } - } /// - /// Parse an array of structures - /// - /// Bytes array - /// Zero-indexed offset - /// Number of bytes to parse - /// DistributedConnection is required in case a structure in the array holds items at the other end - /// Array of structures - - }, { - key: "parseStructureArray", - value: function parseStructureArray(data, offset, length, connection) { - var reply = new _AsyncBag["default"](); - - 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["default"].Null) previous = new _AsyncReply["default"](null);else if (result == _StructureComparisonResult["default"].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["default"].Null) previous = new _AsyncReply["default"](null);else if (result == _StructureComparisonResult["default"].Structure) { - var _cs5 = data.getUint32(offset); - - offset += 4; - previous = Codec.parseStructure(data, offset, _cs5, connection, metadata); - offset += _cs5; - } else if (result == _StructureComparisonResult["default"].StructureSameKeys) { - var _cs6 = data.getUint32(offset); - - offset += 4; - previous = Codec.parseStructure(data, offset, _cs6, connection, metadata, metadata.keys); - offset += _cs6; - } else if (result == _StructureComparisonResult["default"].StructureSameTypes) { - var _cs7 = data.getUint32(offset); - - offset += 4; - previous = Codec.parseStructure(data, offset, _cs7, connection, metadata, metadata.keys, metadata.types); - offset += _cs7; - } - reply.add(previous); - } - - reply.seal(); - return reply; - } }]); return Codec; @@ -2566,7 +2691,17 @@ var Codec = /*#__PURE__*/function () { exports["default"] = Codec; -},{"../Core/AsyncBag.js":1,"../Core/AsyncReply.js":4,"../Net/IIP/DistributedPropertyContext.js":30,"../Net/IIP/DistributedResource.js":31,"../Resource/IResource.js":55,"../Resource/Template/TemplateType.js":65,"../Resource/Warehouse.js":67,"./BinaryList.js":12,"./DataConverter.js":14,"./DataType.js":15,"./IRecord.js":17,"./KeyList.js":18,"./NotModified.js":19,"./PropertyValue.js":20,"./Record.js":21,"./RecordComparisonResult.js":22,"./ResourceArrayType.js":24,"./ResourceComparisonResult.js":25,"./Structure.js":26,"./StructureArray.js":27,"./StructureComparisonResult.js":28}],14:[function(require,module,exports){ +_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 * @@ -2600,7 +2735,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.BL = BL; -exports.DC = exports["default"] = exports.TWO_PWR_32 = exports.UNIX_EPOCH = void 0; +exports.DC = exports["default"] = exports.Endian = exports.TWO_PWR_32 = exports.UNIX_EPOCH = void 0; var _BinaryList = _interopRequireDefault(require("./BinaryList.js")); @@ -2638,6 +2773,11 @@ 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); @@ -2688,38 +2828,33 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "getInt16", - value: function getInt16(offset) { - return this.dv.getInt16(offset); + value: function getInt16(offset, endian) { + return this.dv.getInt16(offset, endian != Endian.Big); } }, { key: "getUint16", - value: function getUint16(offset) { - return this.dv.getUint16(offset); + value: function getUint16(offset, endian) { + return this.dv.getUint16(offset, endian != Endian.Big); } }, { key: "getInt32", - value: function getInt32(offset) { - return this.dv.getInt32(offset); - } - }, { - key: "getInt32Little", - value: function getInt32Little(offset) { - return this.dv.getInt32(offset, true); + value: function getInt32(offset, endian) { + return this.dv.getInt32(offset, endian != Endian.Big); } }, { key: "getUint32", - value: function getUint32(offset) { - return this.dv.getUint32(offset); + value: function getUint32(offset, endian) { + return this.dv.getUint32(offset, endian != Endian.Big); } }, { key: "getFloat32", - value: function getFloat32(offset) { - return this.dv.getFloat32(offset); + value: function getFloat32(offset, endian) { + return this.dv.getFloat32(offset, endian != Endian.Big); } }, { key: "getFloat64", - value: function getFloat64(offset) { - return this.dv.getFloat64(offset); + value: function getFloat64(offset, endian) { + return this.dv.getFloat64(offset, endian != Endian.Big); } }, { key: "setInt8", @@ -2733,33 +2868,33 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "setInt16", - value: function setInt16(offset, value) { - return this.dv.setInt16(offset, value); + value: function setInt16(offset, value, endian) { + return this.dv.setInt16(offset, value, endian != Endian.Big); } }, { key: "setUint16", - value: function setUint16(offset, value) { - return this.dv.setUint16(offset, value); + value: function setUint16(offset, value, endian) { + return this.dv.setUint16(offset, value, endian != Endian.Big); } }, { key: "setInt32", - value: function setInt32(offset, value) { - return this.dv.setInt32(offset, value); + value: function setInt32(offset, value, endian) { + return this.dv.setInt32(offset, value, endian != Endian.Big); } }, { key: "setUint32", - value: function setUint32(offset, value) { - return this.dv.setUint32(offset, value); + value: function setUint32(offset, value, endian) { + return this.dv.setUint32(offset, value, endian != Endian.Big); } }, { key: "setFloat32", - value: function setFloat32(offset, value) { - return this.dv.setFloat32(offset, value); + value: function setFloat32(offset, value, endian) { + return this.dv.setFloat32(offset, value, endian != Endian.Big); } }, { key: "setFloat64", - value: function setFloat64(offset, value) { - return this.dv.setFloat64(offset, value); + value: function setFloat64(offset, value, endian) { + return this.dv.setFloat64(offset, value, endian != Endian.Big); } }, { key: "getInt8Array", @@ -2773,13 +2908,13 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "copy", - value: function copy(offset, length, elementSize, func, dstType) { + 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); + rt[d++] = func.call(this, i, endian); } return rt; @@ -2799,45 +2934,43 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "getInt16Array", - value: function getInt16Array(offset, length) { - return this.copy(offset, length, 2, this.getInt16, Int16Array); //return new Int16Array(this.clip(offset, length).buffer); + 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) { - return this.copy(offset, length, 2, this.getUint16, Uint16Array); //return new Uint16Array(this.clip(offset, length).buffer); + value: function getUint16Array(offset, length, endian) { + return this.copy(offset, length, 2, this.getUint16, Uint16Array, endian); } }, { key: "getInt32Array", - value: function getInt32Array(offset, length) { - return this.copy(offset, length, 4, this.getInt32, Int32Array); //return new Int32Array(this.clip(offset, length).buffer); + value: function getInt32Array(offset, length, endian) { + return this.copy(offset, length, 4, this.getInt32, Int32Array, endian); } }, { key: "getUint32Array", - value: function getUint32Array(offset, length) { - return this.copy(offset, length, 4, this.getUint32, Uint32Array); //return new Uint32Array(this.clip(offset, length).buffer); + value: function getUint32Array(offset, length, endian) { + return this.copy(offset, length, 4, this.getUint32, Uint32Array, endian); } }, { key: "getFloat32Array", - value: function getFloat32Array(offset, length) { - return this.copy(offset, length, 4, this.getFloat32, Float32Array); //return new Float32Array(this.clip(offset, length).buffer); + value: function getFloat32Array(offset, length, endian) { + return this.copy(offset, length, 4, this.getFloat32, Float32Array, endian); } }, { key: "getFloat64Array", - value: function getFloat64Array(offset, length) { - return this.copy(offset, length, 8, this.getFloat64, Float64Array); // return new Float64Array(this.clip(offset, length).buffer); + value: function getFloat64Array(offset, length, endian) { + return this.copy(offset, length, 8, this.getFloat64, Float64Array, endian); } }, { key: "getInt64Array", - value: function getInt64Array(offset, length) { - return this.copy(offset, length, 8, this.getInt64, Float64Array); //BigInt64Array); - //return new Int64Array(this.clip(offset, length).buffer); + value: function getInt64Array(offset, length, endian) { + return this.copy(offset, length, 8, this.getInt64, Float64Array, endian); } }, { key: "getUint64Array", - value: function getUint64Array(offset, length) { - return this.copy(offset, length, 8, this.getUint64, Float64Array); //BigUint64Array); - //return new Uint64Array(this.clip(offset, length).buffer); + value: function getUint64Array(offset, length, endian) { + return this.copy(offset, length, 8, this.getUint64, Float64Array, endian); } }, { key: "getBoolean", @@ -2862,21 +2995,21 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "getChar", - value: function getChar(offset) { - return String.fromCharCode(this.getUint16(offset)); + value: function getChar(offset, endian) { + return String.fromCharCode(this.getUint16(offset, endian)); } }, { key: "setChar", - value: function setChar(offset, value) { - this.setUint16(offset, value.charCodeAt(0)); + value: function setChar(offset, value, endian) { + this.setUint16(offset, value.charCodeAt(0), endian); } }, { key: "getCharArray", - value: function getCharArray(offset, length) { + value: function getCharArray(offset, length, endian) { var rt = []; for (var i = 0; i < length; i += 2) { - rt.push(this.getChar(offset + i)); + rt.push(this.getChar(offset + i, endian)); } return rt; @@ -2905,12 +3038,12 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "getStringArray", - value: function getStringArray(offset, length) { + value: function getStringArray(offset, length, endian) { var rt = []; var i = 0; while (i < length) { - var cl = this.getUint32(offset + i); + var cl = this.getUint32(offset + i, endian); i += 4; rt.push(this.getString(offset + i, cl)); i += cl; @@ -2921,54 +3054,148 @@ var DC = /*#__PURE__*/function (_Uint8Array) { }, { key: "getInt64", - value: function getInt64(offset) { - var h = this.getInt32(offset); - var l = this.getInt32(offset + 4); - return h * TWO_PWR_32 + (l >= 0 ? l : TWO_PWR_32 + l); + 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) { - var h = this.getUint32(offset); - var l = this.getUint32(offset + 4); - return h * TWO_PWR_32 + (l >= 0 ? l : TWO_PWR_32 + l); + 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) { - var l = value % TWO_PWR_32 | 0; - var h = value / TWO_PWR_32 | 0; - this.setInt32(offset, h); - this.setInt32(offset + 4, l); + 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) { - var l = value % TWO_PWR_32 | 0; - var h = value / TWO_PWR_32 | 0; - this.setInt32(offset, h); - this.setInt32(offset + 4, l); + 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) { + value: function setDateTime(offset, value, endian) { // Unix Epoch var ticks = 621355968000000000 + value.getTime() * 10000; - this.setUint64(offset, ticks); + this.setUint64(offset, ticks, endian); } }, { key: "getDateTime", - value: function getDateTime(offset) { - var ticks = this.getUint64(offset); + 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) { + value: function getDateTimeArray(offset, endian) { var rt = []; for (var i = 0; i < length; i += 8) { - rt.push(this.getDateTime(offset + i)); + rt.push(this.getDateTime(offset + i, endian)); } return rt; @@ -3021,6 +3248,11 @@ var DC = /*#__PURE__*/function (_Uint8Array) { rt.setInt8(0, value); return rt; } + }, { + key: "fromList", + value: function fromList(list) { + return new DC(list); + } }, { key: "hexToBytes", value: function hexToBytes(value) { @@ -3042,72 +3274,72 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "charToBytes", - value: function charToBytes(value) { + value: function charToBytes(value, endian) { var rt = new DC(2); - rt.setChar(0, value); + rt.setChar(0, value, endian); return rt; } }, { key: "int16ToBytes", - value: function int16ToBytes(value) { + value: function int16ToBytes(value, endian) { var rt = new DC(2); - rt.setInt16(0, value); + rt.setInt16(0, value, endian); return rt; } }, { key: "uint16ToBytes", - value: function uint16ToBytes(value) { + value: function uint16ToBytes(value, endian) { var rt = new DC(2); - rt.setUint16(0, value); + rt.setUint16(0, value, endian); return rt; } }, { key: "int32ToBytes", - value: function int32ToBytes(value) { + value: function int32ToBytes(value, endian) { var rt = new DC(4); - rt.setInt32(0, value); + rt.setInt32(0, value, endian); return rt; } }, { key: "uint32ToBytes", - value: function uint32ToBytes(value) { + value: function uint32ToBytes(value, endian) { var rt = new DC(4); - rt.setUint32(0, value); + rt.setUint32(0, value, endian); return rt; } }, { key: "float32ToBytes", - value: function float32ToBytes(value) { + value: function float32ToBytes(value, endian) { var rt = new DC(4); - rt.setFloat32(0, value); + rt.setFloat32(0, value, endian); return rt; } }, { key: "int64ToBytes", - value: function int64ToBytes(value) { + value: function int64ToBytes(value, endian) { var rt = new DC(8); - rt.setInt64(0, value); + rt.setInt64(0, value, endian); return rt; } }, { key: "uint64ToBytes", - value: function uint64ToBytes(value) { + value: function uint64ToBytes(value, endian) { var rt = new DC(8); - rt.setUint64(0, value); + rt.setUint64(0, value, endian); return rt; } }, { key: "float64ToBytes", - value: function float64ToBytes(value) { + value: function float64ToBytes(value, endian) { var rt = new DC(8); - rt.setFloat64(0, value); + rt.setFloat64(0, value, endian); return rt; } }, { key: "dateTimeToBytes", - value: function dateTimeToBytes(value) { + value: function dateTimeToBytes(value, endian) { var rt = new DC(8); - rt.setDateTime(0, value); + rt.setDateTime(0, value, endian); return rt; } }, { @@ -3136,88 +3368,88 @@ var DC = /*#__PURE__*/function (_Uint8Array) { } }, { key: "uint16ArrayToBytes", - value: function uint16ArrayToBytes(values) { + 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]); + rt.setUint16(i * 2, values[i], endian); } return rt; } }, { key: "int16ArrayToBytes", - value: function int16ArrayToBytes(values) { + 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]); + rt.setInt16(i * 2, values[i], endian); } return rt; } }, { key: "uint32ArrayToBytes", - value: function uint32ArrayToBytes(values) { + 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]); + rt.setUint32(i * 4, values[i], endian); } return rt; } }, { key: "int32ArrayToBytes", - value: function int32ArrayToBytes(values) { + 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]); + rt.setInt32(i * 4, values[i], endian); } return rt; } }, { key: "int64ArrayToBytes", - value: function int64ArrayToBytes(values) { + 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]); + rt.setInt64(i * 8, values[i], endian); } return rt; } }, { key: "uint64ArrayToBytes", - value: function uint64ArrayToBytes(values) { + 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]); + rt.setUint64(i * 8, values[i], endian); } return rt; } }, { key: "float32ArrayToBytes", - value: function float32ArrayToBytes(values) { + 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]); + rt.setFloat32(i * 4, values[i], endian); } return rt; } }, { key: "float64ArrayToBytes", - value: function float64ArrayToBytes(values) { + 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]); + rt.setFloat64(i * 8, values[i], endian); } return rt; @@ -3247,7 +3479,961 @@ function BL() { ; -},{"./BinaryList.js":12,"./Guid.js":16}],15:[function(require,module,exports){ +},{"./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 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>(); + // 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; + // 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(); + //var list = (IEnumerable)value;// ((List)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 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 * @@ -3368,32 +4554,308 @@ var _default = { }; exports["default"] = _default; -},{}],16:[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. -*/ +},{}],19:[function(require,module,exports){ +"use strict"; -/** - * Created by Ahmed Zamil on 02/09/2017. - */ +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", { @@ -3401,6 +4863,10 @@ Object.defineProperty(exports, "__esModule", { }); 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); } } @@ -3418,10 +4884,20 @@ var Guid = /*#__PURE__*/function () { 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; @@ -3429,7 +4905,7 @@ var Guid = /*#__PURE__*/function () { exports["default"] = Guid; -},{}],17:[function(require,module,exports){ +},{"./DC.js":15}],21:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3439,13 +4915,70 @@ exports["default"] = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var IRecord = function IRecord() { - _classCallCheck(this, IRecord); -}; +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; -},{}],18:[function(require,module,exports){ +},{}],23:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -3641,7 +5174,7 @@ var KeyList = /*#__PURE__*/function () { exports["default"] = KeyList; -},{"../Core/IDestructible.js":7}],19:[function(require,module,exports){ +},{"../Core/IDestructible.js":8}],24:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -3682,7 +5215,26 @@ var NotModified = function NotModified() { exports["default"] = NotModified; -},{}],20:[function(require,module,exports){ +},{}],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 * @@ -3727,7 +5279,55 @@ var PropertyValue = function PropertyValue(value, age, date) { exports["default"] = PropertyValue; -},{}],21:[function(require,module,exports){ +},{}],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); } @@ -3773,7 +5373,99 @@ var Record = /*#__PURE__*/function (_IRecord) { exports["default"] = Record; -},{"./IRecord.js":17}],22:[function(require,module,exports){ +},{"./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", { @@ -3790,7 +5482,222 @@ var _default = // const ResourceComparisonResult = }; exports["default"] = _default; -},{}],23:[function(require,module,exports){ +},{}],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 * @@ -3825,6 +5732,10 @@ Object.defineProperty(exports, "__esModule", { }); 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); } } @@ -3869,7 +5780,7 @@ var ResourceArray = /*#__PURE__*/function (_Array) { _createClass(ResourceArray, [{ key: "push", value: function push(value) { - if (value instanceof IResource) _get(_getPrototypeOf(ResourceArray.prototype), "push", this).call(this, value);else return; + if (value instanceof _IResource["default"]) _get(_getPrototypeOf(ResourceArray.prototype), "push", this).call(this, value);else return; } }]); @@ -3878,7 +5789,7 @@ var ResourceArray = /*#__PURE__*/function (_Array) { exports["default"] = ResourceArray; -},{}],24:[function(require,module,exports){ +},{"../Resource/IResource.js":70}],33:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3892,7 +5803,7 @@ var _default = { }; exports["default"] = _default; -},{}],25:[function(require,module,exports){ +},{}],34:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -3909,7 +5820,7 @@ var _default = // const ResourceComparisonResult = }; exports["default"] = _default; -},{}],26:[function(require,module,exports){ +},{}],35:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -4005,7 +5916,7 @@ var Structure = /*#__PURE__*/function () { exports["default"] = Structure; -},{}],27:[function(require,module,exports){ +},{}],36:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -4093,7 +6004,7 @@ var StructureArray = /*#__PURE__*/function (_Array) { exports["default"] = StructureArray; -},{}],28:[function(require,module,exports){ +},{}],37:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -4110,7 +6021,548 @@ var _default = //const StructureComparisonResult = }; exports["default"] = _default; -},{}],29:[function(require,module,exports){ +},{}],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 * @@ -4155,7 +6607,7 @@ var _AuthenticationType = _interopRequireDefault(require("../../Security/Authori var _SHA = _interopRequireDefault(require("../../Security/Integrity/SHA256.js")); -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); var _SendList = _interopRequireDefault(require("../SendList.js")); @@ -4223,6 +6675,12 @@ var _TemplateType = _interopRequireDefault(require("../../Resource/Template/Temp 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; } } }; } @@ -4291,29 +6749,26 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { _instance_propertyModified.set(_assertThisInitialized(_this), { writable: true, - value: function value(resource, name, newValue) { - var pt = resource.instance.template.getPropertyTemplateByName(name); - if (pt == null) return; - this.sendEvent(_IIPPacketEvent["default"].PropertyUpdated).addUint32(resource.instance.id).addUint8(pt.index).addUint8Array(_Codec["default"].compose(newValue, this)).done(); + 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(resource, issuer, receivers, name, args) { - var et = resource.instance.template.getEventTemplateByName(name); - if (et == null) return; - - if (et.listenable) { + 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 (receivers instanceof Function) if (!receivers(this.sessions)) return; - if (resource.instance.applicable(this.session, _ActionType["default"].ReceiveEvent, et, issuer) == _Ruling["default"].Denied) return; // compose the packet + 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(resource.instance.id).addUint8(et.index).addUint8Array(_Codec["default"].compose(args, this, true)).done(); + this.sendEvent(_IIPPacketEvent["default"].EventOccurred).addUint32(info.resource.instance.id).addUint8(info.eventTemplate.index).addUint8Array(_Codec["default"].compose(info.value, this)).done(); } }); @@ -4385,7 +6840,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { if (this.ready) { var packet = new _IIPPacket["default"](); - var rt = packet.parse(msg, offset, ends); + var rt = packet.parse(msg, offset, ends); //console.log("Inc " , rt, offset, ends); if (rt <= 0) { data.holdFor(msg, offset, ends - offset, -rt); @@ -4405,11 +6860,11 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; case _IIPPacketEvent["default"].PropertyUpdated: - this.IIPEventPropertyUpdated(packet.resourceId, packet.methodIndex, packet.content); + this.IIPEventPropertyUpdated(packet.resourceId, packet.methodIndex, packet.dataType, msg); break; case _IIPPacketEvent["default"].EventOccurred: - this.IIPEventEventOccurred(packet.resourceId, packet.methodIndex, packet.content); + this.IIPEventEventOccurred(packet.resourceId, packet.methodIndex, packet.dataType, msg); break; case _IIPPacketEvent["default"].ChildAdded: @@ -4421,11 +6876,12 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; case _IIPPacketEvent["default"].Renamed: - this.IIPEventRenamed(packet.resourceId, packet.content); + this.IIPEventRenamed(packet.resourceId, packet.resourceName); break; case _IIPPacketEvent["default"].AttributesUpdated: - this.IIPEventAttributesUpdated(packet.resourceId, packet.content); + //@TODO: fix this + //this.IIPEventAttributesUpdated(packet.resourceId, packet.content); break; } } else if (packet.command == _IIPPacketCommand["default"].Request) { @@ -4444,7 +6900,8 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; case _IIPPacketAction["default"].CreateResource: - this.IIPRequestCreateResource(packet.callbackId, packet.storeId, packet.resourceId, packet.content); + // @TODO: implement this + // this.IIPRequestCreateResource(packet.callbackId, packet.storeId, packet.resourceId, packet.content); break; case _IIPPacketAction["default"].DeleteResource: @@ -4460,7 +6917,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; case _IIPPacketAction["default"].RenameResource: - this.IIPRequestRenameResource(packet.callbackId, packet.resourceId, packet.content); + this.IIPRequestRenameResource(packet.callbackId, packet.resourceId, packet.resourceName); break; // Inquire @@ -4497,12 +6954,8 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; // Invoke - case _IIPPacketAction["default"].InvokeFunctionArrayArguments: - this.IIPRequestInvokeFunctionArrayArguments(packet.callbackId, packet.resourceId, packet.methodIndex, packet.content); - break; - - case _IIPPacketAction["default"].InvokeFunctionNamedArguments: - this.IIPRequestInvokeFunctionNamedArguments(packet.callbackId, packet.resourceId, packet.methodIndex, packet.content); + 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); @@ -4520,42 +6973,42 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; case _IIPPacketAction["default"].SetProperty: - this.IIPRequestSetProperty(packet.callbackId, packet.resourceId, packet.methodIndex, packet.content); + this.IIPRequestSetProperty(packet.callbackId, packet.resourceId, packet.methodIndex, packet.dataType, msg); break; - // Attribute + // Attribute @TODO: implement these case _IIPPacketAction["default"].GetAllAttributes: - this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, true); + // this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, true); break; case _IIPPacketAction["default"].UpdateAllAttributes: - this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, true); + // this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, true); break; case _IIPPacketAction["default"].ClearAllAttributes: - this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, true); + // this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, true); break; case _IIPPacketAction["default"].GetAttributes: - this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, false); + // this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, false); break; case _IIPPacketAction["default"].UpdateAttributes: - this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, false); + // this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, false); break; case _IIPPacketAction["default"].ClearAttributes: - this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, false); + // 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.content); + 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.content); + this.IIPReply(packet.callbackId, packet.resourceAge, packet.dataType, msg); break; case _IIPPacketAction["default"].DetachResource: @@ -4576,7 +7029,15 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { case _IIPPacketAction["default"].TemplateFromClassName: case _IIPPacketAction["default"].TemplateFromClassId: case _IIPPacketAction["default"].TemplateFromResourceId: - this.IIPReply(packet.callbackId, _TypeTemplate["default"].parse(packet.content)); + 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: @@ -4584,12 +7045,11 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { case _IIPPacketAction["default"].ResourceParents: case _IIPPacketAction["default"].ResourceHistory: case _IIPPacketAction["default"].LinkTemplates: - this.IIPReply(packet.callbackId, packet.content); + this.IIPReply(packet.callbackId, packet.dataType, msg); break; - case _IIPPacketAction["default"].InvokeFunctionArrayArguments: - case _IIPPacketAction["default"].InvokeFunctionNamedArguments: - this.IIPReplyInvoke(packet.callbackId, packet.content); + case _IIPPacketAction["default"].InvokeFunction: + this.IIPReplyInvoke(packet.callbackId, packet.dataType, msg); break; // case IIPPacketAction.GetProperty: // this.IIPReply(packet.callbackId, packet.content); @@ -4607,7 +7067,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { case _IIPPacketAction["default"].GetAllAttributes: case _IIPPacketAction["default"].GetAttributes: - this.IIPReply(packet.callbackId, packet.content); + this.IIPReply(packet.callbackId, packet.dataType, msg); break; case _IIPPacketAction["default"].UpdateAllAttributes: @@ -4632,7 +7092,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { break; case _IIPPacketReport["default"].ChunkStream: - this.IIPReportChunk(packet.callbackId, packet.content); + this.IIPReportChunk(packet.callbackId, packet.dataType, msg); break; } } @@ -4669,7 +7129,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } catch (ex) { console.log(ex); - var errMsg = _DataConverter.DC.stringToBytes(ex.message); + var errMsg = _DC.DC.stringToBytes(ex.message); this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done(); } @@ -4692,7 +7152,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } catch (ex) { console.log(ex); - var errMsg = _DataConverter.DC.stringToBytes(ex.message); + var errMsg = _DC.DC.stringToBytes(ex.message); this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done(); } @@ -4710,7 +7170,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { this.sendParams().addUInt8(0xc0).addUint8(_ExceptionCode["default"].AccessDenied).addUint16(18).addString("Guests not allowed").done(); } } catch (ex) { - var errMsg = _DataConverter.DC.stringToBytes(ex.message); + var errMsg = _DC.DC.stringToBytes(ex.message); this.sendParams().addUInt8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done(); } @@ -4730,11 +7190,11 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { reply.then(function (pw) { if (pw != null) { - var hash = _SHA["default"].compute((0, _DataConverter.BL)().addUint8Array(pw).addUint8Array(_this2.remoteNonce).addUint8Array(_this2.localNonce).toArray()); + 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, _DataConverter.BL)().addUint8Array(_this2.localNonce).addUint8Array(_this2.remoteNonce).addUint8Array(pw).toArray()); + var localHash = _SHA["default"].compute((0, _DC.BL)().addUint8Array(_this2.localNonce).addUint8Array(_this2.remoteNonce).addUint8Array(pw).toArray()); _this2.sendParams().addUint8(0).addUint8Array(localHash).done(); @@ -4747,7 +7207,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } catch (ex) { console.log(ex); - var errMsg = _DataConverter.DC.stringToBytes(ex.message); + var errMsg = _DC.DC.stringToBytes(ex.message); this.sendParams().addUint8(0xc0).addUint8(_ExceptionCode["default"].GeneralFailure).addUint16(errMsg.length).addUint8Array(errMsg).done(); } @@ -4794,14 +7254,14 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } 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, _DataConverter.BL)().addUint8Array(this.localPasswordOrToken).addUint8Array(this.localNonce).addUint8Array(this.remoteNonce).toArray()); + 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, _DataConverter.BL)().addUint8Array(this.remoteNonce).addUint8Array(this.localNonce).addUint8Array(this.localPasswordOrToken).toArray()); + 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 @@ -5041,11 +7501,11 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var port = host.length > 1 ? parseInt(host[1]) : 10518; if (username != null && password != null) { - var pw = _DataConverter.DC.stringToBytes(password); + 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 : _DataConverter.DC.stringToBytes(token); + 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); @@ -5114,10 +7574,10 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { key: "_declare", value: function _declare() { // declare (Credentials -> No Auth, No Enctypt) - var dmn = _DataConverter.DC.stringToBytes(this.session.localAuthentication.domain); + var dmn = _DC.DC.stringToBytes(this.session.localAuthentication.domain); if (this.session.localAuthentication.method == _AuthenticationMethod["default"].Credentials) { - var un = _DataConverter.DC.stringToBytes(this.session.localAuthentication.username); + 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) { @@ -5145,10 +7605,13 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { try { for (_iterator.s(); !(_step = _iterator.n()).done;) { - var resource = _step.value; - resource.instance.off("ResourceEventOccurred", _classPrivateFieldGet(this, _instance_eventOccurred), this); - resource.instance.off("ResourceModified", _classPrivateFieldGet(this, _instance_propertyModified), this); - resource.instance.off("ResourceDestroyed", _classPrivateFieldGet(this, _instance_resourceDestroyed), this); + 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); @@ -5262,26 +7725,14 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } } }, { - key: "sendInvokeByArrayArguments", - value: function sendInvokeByArrayArguments(instanceId, index, parameters) { + key: "sendInvoke", + value: function sendInvoke(instanceId, index, parameters) { var reply = new _AsyncReply["default"](); - var pb = _Codec["default"].composeVarArray(parameters, this, true); + var pb = _Codec["default"].compose(parameters, this); var callbackId = ++this.callbackCounter; - this.sendParams().addUint8(0x40 | _IIPPacketAction["default"].InvokeFunctionArrayArguments).addUint32(callbackId).addUint32(instanceId).addUint8(index).addUint8Array(pb).done(); - this.requests.set(callbackId, reply); - return reply; - } - }, { - key: "sendInvokeByNamedArguments", - value: function sendInvokeByNamedArguments(instanceId, index, parameters) { - var reply = new _AsyncReply["default"](); - - var pb = _Codec["default"].composeStructure(parameters, this, true, true, true); - - var callbackId = ++this.callbackCounter; - this.sendParams().addUint8(0x40 | _IIPPacketAction["default"].InvokeFunctionNamedArguments).addUint32(callbackId).addUint32(instanceId).addUint8(index).addUint8Array(pb).done(); + this.sendParams().addUint8(0x40 | _IIPPacketAction["default"].InvokeFunction).addUint32(callbackId).addUint32(instanceId).addUint8(index).addUint8Array(pb).done(); this.requests.set(callbackId, reply); return reply; } @@ -5290,7 +7741,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { value: function sendError(type, callbackId, errorCode) { var errorMessage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : ""; - var msg = _DataConverter.DC.stringToBytes(errorMessage); + 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(); } @@ -5302,7 +7753,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { }, { key: "sendChunk", value: function sendChunk(callbackId, chunk) { - var c = _Codec["default"].compose(chunk, this, true); + var c = _Codec["default"].compose(chunk, this); this.sendParams().addUint8(0xC0 | _IIPPacketReport["default"].ChunkStream).addUint32(callbackId).addUint8Array(c).done(); } @@ -5316,13 +7767,13 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } }, { key: "IIPReplyInvoke", - value: function IIPReplyInvoke(callbackId, result) { + value: function IIPReplyInvoke(callbackId, dataType, data) { var req = this.requests.item(callbackId); if (req != null) { this.requests.remove(callbackId); - _Codec["default"].parse(result, 0, {}, this).then(function (rt) { + _Codec["default"].parse(data, 0, this, dataType).reply.then(function (rt) { req.trigger(rt); }); } @@ -5345,11 +7796,11 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } }, { key: "IIPReportChunk", - value: function IIPReportChunk(callbackId, data) { + value: function IIPReportChunk(callbackId, dataType, data) { var req = this.requests.item(callbackId); if (req != null) { - _Codec["default"].parse(data, 0, {}, this).then(function (x) { + _Codec["default"].parse(data, 0, this, dataType).reply.then(function (x) { req.triggerChunk(x); }); } @@ -5368,7 +7819,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } }, { key: "IIPEventPropertyUpdated", - value: function IIPEventPropertyUpdated(resourceId, index, content) { + value: function IIPEventPropertyUpdated(resourceId, index, dataType, data) { var self = this; this.fetch(resourceId).then(function (r) { var pt = r.instance.template.getPropertyTemplateByIndex(index); @@ -5378,7 +7829,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var item = new _AsyncReply["default"](); self.queue.add(item); - _Codec["default"].parse(content, 0, {}, self).then(function (args) { + _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); @@ -5388,7 +7839,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } }, { key: "IIPEventEventOccurred", - value: function IIPEventEventOccurred(resourceId, index, content) { + value: function IIPEventEventOccurred(resourceId, index, dataType, data) { var self = this; this.fetch(resourceId).then(function (r) { var et = r.instance.template.getEventTemplateByIndex(index); @@ -5398,7 +7849,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var item = new _AsyncReply["default"](); self.queue.add(item); // Codec.parseVarArray(content, 0, content.length, self).then(function (args) { - _Codec["default"].parse(content, 0, {}, 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); @@ -5430,7 +7881,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { key: "IIPEventRenamed", value: function IIPEventRenamed(resourceId, name) { this.fetch(resourceId).then(function (resource) { - resource.instance.attributes.set("name", name.getString(0, name.length)); + resource.instance.attributes.set("name", name); }); } }, { @@ -5488,9 +7939,9 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { self._unsubscribe(r); // reply ok - var link = _DataConverter.DC.stringToBytes(r.instance.link); + 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"].composePropertyValueArray(r._serialize(), self, true)).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"].composePropertyValueArray(r.instance.serialize(), self, true)).done(); + 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 { @@ -5502,16 +7953,16 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { }, { key: "_subscribe", value: function _subscribe(resource) { - resource.instance.on("ResourceEventOccurred", _classPrivateFieldGet(this, _instance_eventOccurred), this); - resource.instance.on("ResourceModified", _classPrivateFieldGet(this, _instance_propertyModified), this); + 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("ResourceEventOccurred", _classPrivateFieldGet(this, _instance_eventOccurred), this); - resource.instance.off("ResourceModified", _classPrivateFieldGet(this, _instance_propertyModified), this); + 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); } @@ -5527,7 +7978,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { self._subscribe(r); // reply ok - self.sendReply(_IIPPacketAction["default"].ReattachResource, callback).addUint64(r.instance.age).addUint8Array(_Codec["default"].composePropertyValueArray(r.instance.serialize(), self, true)).done(); + 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); @@ -5594,15 +8045,13 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { return; } - _Codec["default"].parseVarArray(content, offset, cl, self).then(function (parameters) { + DataDeserializer.listParser(content, offset, cl, self).then(function (parameters) { offset += cl; cl = content.getUint32(offset); - - _Codec["default"].parseStructure(content, offset, cl, self).then(function (attributes) { + DataDeserializer.typedMapParser(content, offset, cl, self).then(function (attributes) { offset += cl; cl = content.length - offset; - - _Codec["default"].parseStructure(content, offset, cl, self).then(function (values) { + 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) { @@ -5663,7 +8112,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } // send - _this3.sendReply(_IIPPacketAction["default"].LinkTemplates, callback).addInt32(msg.length).addUint8Array(msg.toArray()).done(); + _this3.sendReply(_IIPPacketAction["default"].LinkTemplates, callback).addDC(_TransmissionType.TransmissionType.compose(_TransmissionType.TransmissionTypeIdentifier.RawData, msg)).done(); } } }; @@ -5691,7 +8140,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var t = _Warehouse["default"].getTemplateByClassId(classId); - if (t != null) self.sendReply(_IIPPacketAction["default"].TemplateFromClassId, callback).addUint32(t.content.length).addUint8Array(t.content).done();else { + 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); } @@ -5702,201 +8151,113 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var self = this; _Warehouse["default"].getById(resourceId).then(function (r) { - if (r != null) self.sendReply(_IIPPacketAction["default"].TemplateFromResourceId, callback).addUint32(r.instance.template.content.length).addUint8Array(r.instance.template.content).done();else { + 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: "IIPRequestInvokeFunctionArrayArguments", - value: function IIPRequestInvokeFunctionArrayArguments(callback, resourceId, index, content) { + key: "IIPRequestInvokeFunction", + value: function IIPRequestInvokeFunction(callback, resourceId, index, dataType, data) { var self = this; _Warehouse["default"].getById(resourceId).then(function (r) { - if (r != null) { - _Codec["default"].parseVarArray(content, 0, content.length, self).then(function (args) { - var ft = r.instance.template.getFunctionTemplateByIndex(index); - - if (ft != null) { - if (r instanceof _DistributedResource["default"]) { - var rt = r._invokeByArrayArguments(index, args); - - if (rt != null) { - rt.then(function (res) { - self.sendReply(_IIPPacketAction["default"].InvokeFunctionArrayArguments, callback).addUint8Array(_Codec["default"].compose(res, self)).done(); - }); - } else {// function not found on a distributed object - } - } else { - var fi = r[ft.name]; - - if (r.instance.applicable(self.session, _ActionType["default"].Execute, ft) == _Ruling["default"].Denied) { - self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].InvokeDenied); - return; - } - - if (fi instanceof Function) { - args.push(self); - var rt; - - try { - rt = fi.apply(r, args); - } 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"].InvokeFunctionArrayArguments, callback).addUint8(DataType.Void).done(); - } else if (rt instanceof _AsyncReply["default"]) { - rt.then(function (res) { - self.sendReply(_IIPPacketAction["default"].InvokeFunctionArrayArguments, 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"].InvokeFunctionArrayArguments, 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"].InvokeFunctionArrayArguments, callback).addUint8Array(_Codec["default"].compose(rt, self)).done(); - } - } else { - // ft found, fi not found, this should never happen - this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound); - } - } - } else { - // no function at this index - this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound); - } - }); - } else { - // no resource with this id + if (r == null) { this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound); + return; } - }); - } - }, { - key: "IIPRequestInvokeFunctionNamedArguments", - value: function IIPRequestInvokeFunctionNamedArguments(callback, resourceId, index, content) { - var self = this; - _Warehouse["default"].getById(resourceId).then(function (r) { - if (r != null) { - _Codec["default"].parseStructure(content, 0, content.length, self).then(function (namedArgs) { - var ft = r.instance.template.getFunctionTemplateByIndex(index); + var ft = r.instance.template.getFunctionTemplateByIndex(index); - if (ft != null) { - if (r instanceof _DistributedResource["default"]) { - var rt = r._invokeByNamedArguments(index, namedArgs); + if (ft == null) { + // no function at this index + this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound); + return; + } - if (rt != null) { - rt.then(function (res) { - self.sendReply(_IIPPacketAction["default"].InvokeFunctionNamedArguments, callback).addUint8Array(_Codec["default"].compose(res, self)).done(); - }); - } else {// function not found on a distributed object - } - } else { - var fi = r[ft.name]; + _Codec["default"].parse(data, 0, self, dataType).reply.then(function (args) { + if (r instanceof _DistributedResource["default"]) { + var rt = r._invoke(index, args); - if (r.instance.applicable(self.session, _ActionType["default"].Execute, ft) == _Ruling["default"].Denied) { - self.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].InvokeDenied); - return; - } - - if (fi instanceof Function) { - var pi = _TypeTemplate["default"].getFunctionParameters(fi); - - var args = new Array(pi.length); - - for (var i = 0; i < pi.length; i++) { - if (namedArgs[pi[i]] !== undefined) args[i] = namedArgs[pi[i]]; - } // pass this to the last argument if it is undefined - - - if (args[args.length - 1] === undefined) args[args.length - 1] = self; - var rt; - - try { - rt = fi.apply(r, args); - } catch (ex) { - self.sendError(_ErrorType["default"].Exception, callback, 0, ex.toString()); - return; - } // Is iterator ? - - - if (rt != null && rt[Symbol.iterator] instanceof Function) { - var _iterator3 = _createForOfIteratorHelper(rt), - _step3; - - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var v = _step3.value; - self.sendChunk(callback, v); - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - - self.sendReply(_IIPPacketAction["default"].InvokeFunctionNamedArguments, callback).addUint8(DataType.Void).done(); - } else if (rt instanceof _AsyncReply["default"]) { - rt.then(function (res) { - self.sendReply(_IIPPacketAction["default"].InvokeFunctionNamedArguments, 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"].InvokeFunctionNamedArguments, 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"].InvokeFunctionNamedArguments, callback).addUint8Array(_Codec["default"].compose(rt, self)).done(); - } - } else { - // ft found, fi not found, this should never happen - this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound); - } - } + if (rt != null) { + rt.then(function (res) { + self.sendReply(_IIPPacketAction["default"].InvokeFunction, callback).addUint8Array(_Codec["default"].compose(res, self)).done(); + }); } else { - // no function at this index + // function not found on a distributed object this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].MethodNotFound); + return; } - }); - } else { - // no resource with this id - this.sendError(_ErrorType["default"].Management, callback, _ExceptionCode["default"].ResourceNotFound); - } + } 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; @@ -6037,7 +8398,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } }, { key: "IIPRequestSetProperty", - value: function IIPRequestSetProperty(callback, resourceId, index, content) { + value: function IIPRequestSetProperty(callback, resourceId, index, dataType, data) { var self = this; _Warehouse["default"].getById(resourceId).then(function (r) { @@ -6045,7 +8406,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var pt = r.instance.template.getPropertyTemplateByIndex(index); if (pt != null) { - _Codec["default"].parse(content, 0, {}, this).then(function (value) { + _Codec["default"].parse(data, 0, self, dataType).reply.then(function (value) { if (r instanceof _DistributedResource["default"]) { // propagation r._set(index, value).then(function (x) { @@ -6105,7 +8466,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { 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"].composeResourceArray(list, self, true)).done(); + 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(); } }; @@ -6122,9 +8483,9 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { value: function create(store, parent, className, parameters, attributes, values) { var reply = new _AsyncReply["default"](); - var sb = _DataConverter.DC.stringToBytes(className); + var sb = _DC.DC.stringToBytes(className); - var pkt = (0, _DataConverter.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)); + 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]; @@ -6140,11 +8501,16 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { var reply = new _AsyncReply["default"](); var self = this; - var sb = _DataConverter.DC.stringToBytes(resourceLink); + var sb = _DC.DC.stringToBytes(resourceLink); - this.sendRequest(_IIPPacketAction["default"].QueryLink).addUint16(sb.length).addUint8Array(sb).done().then(function (args) { - _Codec["default"].parseResourceArray(args[0], 0, args[0].length, self).then(function (resources) { + 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); @@ -6213,14 +8579,15 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { value: function getLinkTemplates(link) { var reply = new _AsyncReply["default"](); - var l = _DataConverter.DC.stringToBytes(link); + 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 data = rt[0]; //var offset = 0; + var tt = rt[0]; + var data = rt[1]; //var offset = 0; - for (var offset = 0; offset < data.length;) { + for (var offset = tt.offset; offset < tt.contentLength;) { var cs = data.getUint32(offset); offset += 4; templates.push(_TypeTemplate["default"].parse(data, offset, cs)); @@ -6260,15 +8627,25 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { } 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"].parsePropertyValueArray(rt[3], 0, rt[3].length, self).then(function (ar) { - dr._attach(ar); + _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); }); }); @@ -6276,8 +8653,17 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { reply.triggerError(ex); }); } else { - _Codec["default"].parsePropertyValueArray(rt[3], 0, rt[3].length, self).then(function (ar) { - dr._attach(ar); + _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); @@ -6388,7 +8774,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { return; } - resource.instance.name = name.getString(0, name.length); + resource.instance.name = name; self.sendReply(_IIPPacketAction["default"].RenameResource, callback).done(); }); } @@ -6403,7 +8789,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { return; } - self.sendReply(_IIPPacketAction["default"].ResourceChildren, callback).addUint8Array(_Codec["default"].composeResourceArray(resource.instance.children.toArray(), this, true)).done(); + self.sendReply(_IIPPacketAction["default"].ResourceChildren, callback).addUint8Array(_Codec["default"].compose(resource.instance.children.toArray(), self)).done(); }); } }, { @@ -6417,7 +8803,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { return; } - self.sendReply(_IIPPacketAction["default"].ResourceParents, callback).addUint8Array(_Codec["default"].composeResourceArray(resource.instance.parents.toArray(), this, true)).done(); + self.sendReply(_IIPPacketAction["default"].ResourceParents, callback).addUint8Array(_Codec["default"].compose(resource.instance.parents.toArray(), self)).done(); }); } }, { @@ -6458,7 +8844,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { return; } - _Codec["default"].parseStructure(attributes, 0, attributes.length, this).then(function (attrs) { + 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); }); }); @@ -6469,11 +8855,14 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { 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 (d) { - _Codec["default"].parseResourceArray(d, 0, d.length, self).then(function (resources) { + 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) { - rt.triggerError(ex); + return rt.triggerError(ex); }); }); return rt; @@ -6484,11 +8873,14 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { 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 (d) { - _Codec["default"].parseResourceArray(d, 0, d.length, self).then(function (resources) { + 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) { - rt.triggerError(ex); + return rt.triggerError(ex); }); }); return rt; @@ -6504,7 +8896,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { }).error(function (ex) { rt.triggerError(ex); });else { - var attrs = _DataConverter.DC.stringArrayToBytes(attributes); + 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); @@ -6520,7 +8912,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { 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"].composeStructure(attributes, this, true, true, true)).done().then(function () { + 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); @@ -6537,30 +8929,39 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { if (attributes == null) { this.sendRequest(_IIPPacketAction["default"].GetAllAttributes).addUint32(resource._p.instanceId).done().then(function (ar) { - _Codec["default"].parseStructure(ar[0], 0, ar[0].length, this).then(function (st) { - for (var a in st) { - resource.instance.attributes.set(a, st[a]); - } + 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) { - rt.triggerError(ex); + return rt.triggerError(ex); }); + }).error(function (ex) { + rt.triggerError(ex); }); } else { - var attrs = _DataConverter.DC.stringArrayToBytes(attributes); + var attrs = _DC.DC.stringArrayToBytes(attributes); this.sendRequest(_IIPPacketAction["default"].GetAttributes).addUint32(resource._p.instanceId).addUint32(attrs.length).addUint8Array(attrs).done().then(function (ar) { - _Codec["default"].parseStructure(ar[0], 0, ar[0].length, self).then(function (st) { - for (var a in st) { - resource.instance.attributes.set(a, st[a]); - } + 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) { - rt.triggerError(ex); + return rt.triggerError(ex); }); + }).error(function (ex) { + return rt.triggerError(ex); }); + ; } return rt; @@ -6572,7 +8973,7 @@ var DistributedConnection = /*#__PURE__*/function (_IStore) { exports["default"] = DistributedConnection; -},{"../../Core/AsyncBag.js":1,"../../Core/AsyncException.js":2,"../../Core/AsyncQueue.js":3,"../../Core/AsyncReply.js":4,"../../Core/ErrorType.js":5,"../../Core/ExceptionCode.js":6,"../../Core/ProgressType.js":9,"../../Data/Codec.js":13,"../../Data/DataConverter.js":14,"../../Data/KeyList.js":18,"../../Resource/IResource.js":55,"../../Resource/IStore.js":56,"../../Resource/Template/TemplateType.js":65,"../../Resource/Template/TypeTemplate.js":66,"../../Resource/Warehouse.js":67,"../../Security/Authority/Authentication.js":68,"../../Security/Authority/AuthenticationMethod.js":69,"../../Security/Authority/AuthenticationType.js":70,"../../Security/Authority/ClientAuthentication.js":71,"../../Security/Authority/HostAuthentication.js":72,"../../Security/Authority/Session.js":73,"../../Security/Integrity/SHA256.js":74,"../../Security/Permissions/ActionType.js":76,"../../Security/Permissions/Ruling.js":78,"../Packets//IIPPacketReport.js":48,"../Packets/IIPAuthPacket.js":41,"../Packets/IIPAuthPacketAction.js":42,"../Packets/IIPAuthPacketCommand.js":43,"../Packets/IIPPacket.js":44,"../Packets/IIPPacketAction.js":45,"../Packets/IIPPacketCommand.js":46,"../Packets/IIPPacketEvent.js":47,"../SendList.js":49,"../Sockets/SocketState.js":51,"../Sockets/WSocket.js":52,"./DistributedPropertyContext.js":30,"./DistributedResource.js":31,"./DistributedResourceQueueItem.js":32,"./DistributedResourceQueueItemType.js":33}],30:[function(require,module,exports){ +},{"../../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 * @@ -6620,7 +9021,7 @@ var DistributedPropertyContext = function DistributedPropertyContext(p1, p2) { exports["default"] = DistributedPropertyContext; -},{}],31:[function(require,module,exports){ +},{}],44:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -6661,8 +9062,6 @@ 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")); @@ -6673,6 +9072,14 @@ var _ExceptionCode = _interopRequireDefault(require("../../Core//ExceptionCode.j 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"); } } @@ -6742,10 +9149,10 @@ var DistributedResource = /*#__PURE__*/function (_IResource) { }, { key: "_serialize", value: function _serialize() { - var props = []; + var props = new _PropertyValueArray["default"](); for (var i = 0; i < this._p.properties.length; i++) { - props.push(new PropertyValue(this._p.properties[i], this.instance.getAge(i), this.instance.getModificationDate(i))); + props.push(new _PropertyValue["default"](this._p.properties[i], this.instance.getAge(i), this.instance.getModificationDate(i))); } return props; @@ -6761,27 +9168,41 @@ var DistributedResource = /*#__PURE__*/function (_IResource) { 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); + 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); + this._p.properties.push(properties[i].value); } var self = this; - var makeFunc = function makeFunc(index) { + 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") { - var namedArgs = new _Structure["default"](arguments[0]); - return self._invokeByNamedArguments(index, namedArgs); + // 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 { - return self._invokeByArrayArguments(index, arguments); + 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[index].expansion; + func.help = self.instance.template.functions[ft.index].expansion; return func; }; @@ -6797,13 +9218,13 @@ var DistributedResource = /*#__PURE__*/function (_IResource) { }; }; - for (var i = 0; i < this.instance.template.functions.length; i++) { - var ft = this.instance.template.functions[i]; - this[ft.name] = makeFunc(ft.index); + 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 i = 0; i < this.instance.template.properties.length; i++) { - var pt = this.instance.template.properties[i]; + 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), @@ -6839,23 +9260,15 @@ var DistributedResource = /*#__PURE__*/function (_IResource) { this._emit(et.name, args); - this.instance._emitResourceEvent(null, null, et.name, args); + this.instance._emitResourceEvent(null, null, et, args); } }, { - key: "_invokeByArrayArguments", - value: function _invokeByArrayArguments(index, 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.sendInvokeByArrayArguments(this._p.instanceId, index, args); - } - }, { - key: "_invokeByNamedArguments", - value: function _invokeByNamedArguments(index, namedArgs) { - 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.sendInvokeByNamedArguments(this._p.instanceId, index, namedArgs); + return this._p.connection.sendInvoke(this._p.instanceId, index, args); } }, { key: "_get", @@ -6905,7 +9318,7 @@ var DistributedResource = /*#__PURE__*/function (_IResource) { exports["default"] = DistributedResource; -},{"../../Core//ExceptionCode.js":6,"../../Core/AsyncException.js":2,"../../Core/AsyncReply.js":4,"../../Core/ErrorType.js":5,"../../Data/Codec.js":13,"../../Data/Structure.js":26,"../../Resource/IResource.js":55,"../../Resource/Template/EventTemplate.js":59,"../Packets//IIPPacketAction.js":45}],32:[function(require,module,exports){ +},{"../../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 * @@ -6951,7 +9364,7 @@ var DistributedResourceQueueItem = function DistributedResourceQueueItem(resourc exports["default"] = DistributedResourceQueueItem; -},{}],33:[function(require,module,exports){ +},{}],46:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -6964,7 +9377,7 @@ var _default = { }; exports["default"] = _default; -},{}],34:[function(require,module,exports){ +},{}],47:[function(require,module,exports){ /* * Copyright (c) 2017-2021 Ahmed Kh. Zamil * @@ -7104,7 +9517,7 @@ var DistributedServer = /*#__PURE__*/function (_IResource) { exports["default"] = DistributedServer; -},{"../../Core//ExceptionCode.js":6,"../../Core/AsyncException.js":2,"../../Core/AsyncReply.js":4,"../../Core/ErrorType.js":5,"../../Data/Codec.js":13,"../../Data/Structure.js":26,"../../Resource/IResource.js":55,"../../Resource/Template/EventTemplate.js":59,"../Packets//IIPPacketAction.js":45,"./DistributedConnection.js":29}],35:[function(require,module,exports){ +},{"../../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); } @@ -7162,7 +9575,7 @@ var EntryPoint = /*#__PURE__*/function (_IResource) { exports["default"] = EntryPoint; -},{"../../Resource/IResource.js":55}],36:[function(require,module,exports){ +},{"../../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); } @@ -7223,32 +9636,7 @@ var INetworkReceiver = /*#__PURE__*/function (_IDestructible) { exports["default"] = INetworkReceiver; -},{"../Core/IDestructible.js":7}],37:[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 01/09/2017. - */ +},{"../Core/IDestructible.js":8}],50:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7256,7 +9644,7 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = _interopRequireDefault(require("../Data/DataConverter.js")); +var _DC = _interopRequireDefault(require("../Data/DC.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } @@ -7271,7 +9659,7 @@ var NetworkBuffer = /*#__PURE__*/function () { _classCallCheck(this, NetworkBuffer); this.neededDataLength = 0; - this.data = new _DataConverter["default"](0); + this.data = new _DC["default"](0); } _createClass(NetworkBuffer, [{ @@ -7298,7 +9686,7 @@ var NetworkBuffer = /*#__PURE__*/function () { key: "holdFor", value: function holdFor(src, offset, size, needed) { if (size >= needed) throw new Error("Size >= Needed !"); - this.data = _DataConverter["default"].combine(src, offset, size, this.data, 0, this.data.length); + this.data = _DC["default"].combine(src, offset, size, this.data, 0, this.data.length); this.neededDataLength = needed; } }, { @@ -7340,11 +9728,11 @@ var NetworkBuffer = /*#__PURE__*/function () { if (this.neededDataLength == 0) { rt = this.data; - this.data = new _DataConverter["default"](0); + this.data = new _DC["default"](0); } else { if (this.data.length >= this.neededDataLength) { rt = this.data; - this.data = new _DataConverter["default"](0); + this.data = new _DC["default"](0); this.neededDataLength = 0; return rt; } else { @@ -7361,7 +9749,7 @@ var NetworkBuffer = /*#__PURE__*/function () { exports["default"] = NetworkBuffer; -},{"../Data/DataConverter.js":14}],38:[function(require,module,exports){ +},{"../Data/DC.js":15}],51:[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); } @@ -7407,7 +9795,7 @@ var NetowrkConnection = /*#__PURE__*/function (_INetworkReceiver) { exports["default"] = NetowrkConnection; -},{"./INetworkReceiver.js":36}],39:[function(require,module,exports){ +},{"./INetworkReceiver.js":49}],52:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7423,7 +9811,7 @@ var NetworkServer = function NetworkServer() { exports["default"] = NetworkServer; -},{}],40:[function(require,module,exports){ +},{}],53:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7439,7 +9827,7 @@ var NetworkSession = function NetworkSession() { exports["default"] = NetworkSession; -},{}],41:[function(require,module,exports){ +},{}],54:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -7629,7 +10017,7 @@ var IIPAuthPacket = /*#__PURE__*/function () { exports["default"] = IIPAuthPacket; -},{"../../Security/Authority/AuthenticationMethod.js":69,"./IIPAuthPacketAction.js":42,"./IIPAuthPacketCommand.js":43}],42:[function(require,module,exports){ +},{"../../Security/Authority/AuthenticationMethod.js":86,"./IIPAuthPacketAction.js":55,"./IIPAuthPacketCommand.js":56}],55:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7646,7 +10034,7 @@ var _default = // const IIPAuthPacketAction = }; exports["default"] = _default; -},{}],43:[function(require,module,exports){ +},{}],56:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -7662,9 +10050,9 @@ var _default = //const IIPAuthPacketCommand = }; exports["default"] = _default; -},{}],44:[function(require,module,exports){ +},{}],57:[function(require,module,exports){ /* -* Copyright (c) 2017 Ahmed Kh. Zamil +* 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 @@ -7705,6 +10093,8 @@ var _IIPPacketReport = _interopRequireDefault(require("./IIPPacketReport.js")); var _DataType = _interopRequireDefault(require("../../Data/DataType.js")); +var _TransmissionType = _interopRequireDefault(require("../../Data/TransmissionType.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"); } } @@ -7722,8 +10112,8 @@ var IIPPacket = /*#__PURE__*/function () { this.event = 0; this.resourceId = 0; this.newResourceId = 0; - this.resourceAge = 0; - this.content = []; + this.resourceAge = 0; //this.content = []; + this.errorCode = 0; this.errorMessage = ""; this.className = ""; @@ -7734,6 +10124,8 @@ var IIPPacket = /*#__PURE__*/function () { this.callbackId = 0; this.dataLengthNeeded = 0; this.originalOffset = 0; + this.resourceName = ""; + this.dataType = null; } _createClass(IIPPacket, [{ @@ -7784,47 +10176,28 @@ var IIPPacket = /*#__PURE__*/function () { var cl = data.getUint16(offset); offset += 2; if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); + this.resourceName = data.getString(offset, cl); offset += cl; } else if (this.event == _IIPPacketEvent["default"].PropertyUpdated || this.event == _IIPPacketEvent["default"].EventOccurred) { if (this.notEnough(offset, ends, 2)) return -this.dataLengthNeeded; this.methodIndex = data[offset++]; - var dt = data.getUint8(offset++); - var size = _DataType["default"].sizeOf(dt); + var parsed = _TransmissionType["default"].parse(data, offset, ends); - if (size < 0) { - if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } else { - if (this.notEnough(offset, ends, size)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 1, size + 1); - offset += size; - } - } // else if (this.event == IIPPacketEvent.EventOccurred) - // { - // if (this.notEnough(offset, ends, 5)) - // return -this.dataLengthNeeded; - // this.methodIndex = data.getUint8(offset++); - // var cl = data.getUint32(offset); - // offset += 4; - // if (this.notEnough(offset, ends, cl)) - // return -this.dataLengthNeeded; - // this.content = data.clip(offset, cl); - // offset += cl; - // } - // Attribute + if (parsed.type == null) return -parsed.size; + this.dataType = parsed.type; + offset += parsed.size; + } // Attribute else if (this.event == _IIPPacketEvent["default"].AttributesUpdated) { if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); + + var _cl = data.getUint32(offset); + offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - offset += cl; + if (this.notEnough(offset, ends, _cl)) return -this.dataLengthNeeded; //@TODO: fix this + //this.content = data.clip(offset, cl); + + offset += _cl; } } else if (this.command == _IIPPacketCommand["default"].Request) { if (this.action == _IIPPacketAction["default"].AttachResource) { @@ -7842,15 +10215,17 @@ var IIPPacket = /*#__PURE__*/function () { this.resourceId = data.getUint32(offset); offset += 4; } else if (this.action == _IIPPacketAction["default"].CreateResource) { - if (this.notEnough(offset, ends, 12)) return -dataLengthNeeded; + if (this.notEnough(offset, ends, 12)) return -this.dataLengthNeeded; this.storeId = data.getUint32(offset); offset += 4; this.resourceId = data.getUint32(offset); offset += 4; - var cl = data.getUint32(offset); + + var _cl2 = data.getUint32(offset); + offset += 4; - if (this.notEnough(offset, ends, cl)) return -dataLengthNeeded; - this.content = data.clip(offset, cl); + if (this.notEnough(offset, ends, _cl2)) return -this.dataLengthNeeded; //@TODO: fix this + //this.content = data.clip(offset, cl); } else if (this.action == _IIPPacketAction["default"].DeleteResource) { if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; this.resourceId = data.getUint32(offset); @@ -7865,17 +10240,21 @@ var IIPPacket = /*#__PURE__*/function () { if (this.notEnough(offset, ends, 6)) return -this.dataLengthNeeded; this.resourceId = data.getUint32(offset); offset += 4; - var cl = data.getUint16(offset); + + var _cl3 = data.getUint16(offset); + offset += 2; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - offset += cl; + if (this.notEnough(offset, ends, _cl3)) return -this.dataLengthNeeded; + this.resourceName = data.getString(offset, _cl3); + offset += _cl3; } else if (this.action == _IIPPacketAction["default"].TemplateFromClassName) { if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - var cl = data.getUint8(offset++); - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.className = data.getString(offset, cl); - offset += cl; + + var _cl4 = data.getUint8(offset++); + + if (this.notEnough(offset, ends, _cl4)) return -this.dataLengthNeeded; + this.className = data.getString(offset, _cl4); + offset += _cl4; } else if (this.action == _IIPPacketAction["default"].TemplateFromClassId) { if (this.notEnough(offset, ends, 16)) return -this.dataLengthNeeded; this.classId = data.getGuid(offset); @@ -7886,11 +10265,13 @@ var IIPPacket = /*#__PURE__*/function () { offset += 4; } else if (this.action == _IIPPacketAction["default"].QueryLink || this.action == _IIPPacketAction["default"].LinkTemplates) { if (this.notEnough(offset, ends, 2)) return -this.dataLengthNeeded; - var cl = data.getUint16(offset); + + var _cl5 = data.getUint16(offset); + offset += 2; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.resourceLink = data.getString(offset, cl); - offset += cl; + if (this.notEnough(offset, ends, _cl5)) return -this.dataLengthNeeded; + this.resourceLink = data.getString(offset, _cl5); + offset += _cl5; } else if (this.action == _IIPPacketAction["default"].ResourceChildren || this.action == _IIPPacketAction["default"].ResourceParents) { if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; this.resourceId = data.getUint32(offset); @@ -7903,16 +10284,17 @@ var IIPPacket = /*#__PURE__*/function () { offset += 8; this.toDate = data.getDateTime(offset); offset += 8; - } else if (this.action == _IIPPacketAction["default"].InvokeFunctionArrayArguments || this.action == _IIPPacketAction["default"].InvokeFunctionNamedArguments) { + } else if (this.action == _IIPPacketAction["default"].InvokeFunction) { if (this.notEnough(offset, ends, 9)) return -this.dataLengthNeeded; this.resourceId = data.getUint32(offset); offset += 4; this.methodIndex = data.getUint8(offset++); - var cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - offset += cl; + + var _parsed = _TransmissionType["default"].parse(data, offset, ends); + + if (_parsed.type == null) return -_parsed.size; + this.dataType = _parsed.type; + offset += _parsed.size; } else if (this.action == _IIPPacketAction["default"].Listen || this.action == _IIPPacketAction["default"].Unlisten) //this.action == IIPPacketAction.GetProperty) { if (this.notEnough(offset, ends, 5)) return -this.dataLengthNeeded; @@ -7934,32 +10316,25 @@ var IIPPacket = /*#__PURE__*/function () { this.resourceId = data.getUint32(offset); offset += 4; this.methodIndex = data[offset++]; - var dt = data.getUint8(offset++); - var size = _DataType["default"].sizeOf(dt); + var _parsed2 = _TransmissionType["default"].parse(data, offset, ends); - if (size < 0) { - if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } else { - if (this.notEnough(offset, ends, size)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 1, size + 1); - offset += size; - } + if (_parsed2.type == null) return -_parsed2.size; + this.dataType = _parsed2.type; + offset += _parsed2.size; } // Attribute else if (this.action == _IIPPacketAction["default"].UpdateAllAttributes || this.action == _IIPPacketAction["default"].GetAttributes || this.action == _IIPPacketAction["default"].UpdateAttributes || this.action == _IIPPacketAction["default"].ClearAttributes) { if (this.notEnough(offset, ends, 8)) return -this.dataLengthNeeded; this.resourceId = data.getUint32(offset); offset += 4; - var cl = data.getUint32(offset); + + var _cl6 = data.getUint32(offset); + offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - offset += cl; + if (this.notEnough(offset, ends, _cl6)) return -this.dataLengthNeeded; // @TODO: fix this + //this.content = data.clip(offset, cl); + + offset += _cl6; } } else if (this.command == _IIPPacketCommand["default"].Reply) { if (this.action == _IIPPacketAction["default"].AttachResource || this.action == _IIPPacketAction["default"].ReattachResource) { @@ -7968,17 +10343,19 @@ var IIPPacket = /*#__PURE__*/function () { offset += 16; this.resourceAge = data.getUint64(offset); offset += 8; - var cl = data.getUint16(offset); + + var _cl7 = data.getUint16(offset); + offset += 2; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.resourceLink = data.getString(offset, cl); - offset += cl; - if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - offset += cl; + if (this.notEnough(offset, ends, _cl7)) return -this.dataLengthNeeded; + this.resourceLink = data.getString(offset, _cl7); + offset += _cl7; + + var _parsed3 = _TransmissionType["default"].parse(data, offset, ends); + + if (_parsed3.type == null) return -_parsed3.size; + this.dataType = _parsed3.type; + offset += _parsed3.size; } else if (this.action == _IIPPacketAction["default"].DetachResource) {// nothing to do } else if (this.action == _IIPPacketAction["default"].CreateResource) { if (this.notEnough(offset, ends, 20)) return -this.dataLengthNeeded; @@ -7987,33 +10364,22 @@ var IIPPacket = /*#__PURE__*/function () { } else if (this.action == _IIPPacketAction["default"].DetachResource) {// nothing to do } else if (this.action == _IIPPacketAction["default"].TemplateFromClassName || this.action == _IIPPacketAction["default"].TemplateFromClassId || this.action == _IIPPacketAction["default"].TemplateFromResourceId || this.action == _IIPPacketAction["default"].QueryLink || this.action == _IIPPacketAction["default"].ResourceChildren || this.action == _IIPPacketAction["default"].ResourceParents || this.action == _IIPPacketAction["default"].ResourceHistory || this.action == _IIPPacketAction["default"].LinkTemplates // Attribute || this.action == _IIPPacketAction["default"].GetAllAttributes || this.action == _IIPPacketAction["default"].GetAttributes) { - if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - offset += cl; - } else if (this.action == _IIPPacketAction["default"].InvokeFunctionArrayArguments || this.action == _IIPPacketAction["default"].InvokeFunctionNamedArguments) //|| this.action == IIPPacketAction.GetProperty - //|| this.action == IIPPacketAction.GetPropertyIfModified) - { - if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - var dt = data.getUint8(offset++); + if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - var size = _DataType["default"].sizeOf(dt); + var _parsed4 = _TransmissionType["default"].parse(data, offset, ends); - if (size < 0) { - if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } else { - if (this.notEnough(offset, ends, size)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 1, size + 1); - offset += size; - } - } else if (this.action == _IIPPacketAction["default"].SetProperty || this.action == _IIPPacketAction["default"].Listen || this.action == _IIPPacketAction["default"].Unlisten) {// nothing to do + if (_parsed4.type == null) return -_parsed4.size; + this.dataType = _parsed4.type; + offset += _parsed4.size; + } else if (this.action == _IIPPacketAction["default"].InvokeFunction) { + if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; + + var _parsed5 = _TransmissionType["default"].parse(data, offset, ends); + + if (_parsed5.type == null) return -_parsed5.size; + this.dataType = _parsed5.type; + offset += _parsed5.size; + } else if (this.action == _IIPPacketAction["default"].SetProperty || this.action == _IIPPacketAction["default"].Listen || this.action == _IIPPacketAction["default"].Unlisten) {// nothing to do } } else if (this.command == _IIPPacketCommand["default"].Report) { if (this.report == _IIPPacketReport["default"].ManagementError) { @@ -8025,11 +10391,13 @@ var IIPPacket = /*#__PURE__*/function () { this.errorCode = data.getUint16(offset); offset += 2; if (this.notEnough(offset, ends, 2)) return -this.dataLengthNeeded; - var cl = data.getUint16(offset); + + var _cl8 = data.getUint16(offset); + offset += 2; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.errorMessage = data.getString(offset, cl); - offset += cl; + if (this.notEnough(offset, ends, _cl8)) return -this.dataLengthNeeded; + this.errorMessage = data.getString(offset, _cl8); + offset += _cl8; } else if (this.report == _IIPPacketReport["default"].ProgressReport) { if (this.notEnough(offset, ends, 8)) return -this.dataLengthNeeded; this.progressValue = data.getInt32(offset); @@ -8037,22 +10405,13 @@ var IIPPacket = /*#__PURE__*/function () { this.progressMax = data.getInt32(offset); offset += 4; } else if (this.report == _IIPPacketReport["default"].ChunkStream) { - var dt = data.getUint8(offset++); + if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - var size = _DataType["default"].sizeOf(dt); + var _parsed6 = _TransmissionType["default"].parse(data, offset, ends); - if (size < 0) { - if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); - offset += 4; - if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } else { - if (this.notEnough(offset, ends, size)) return -this.dataLengthNeeded; - this.content = data.clip(offset - 1, size + 1); - offset += size; - } + if (_parsed6.type == null) return -_parsed6.size; + this.dataType = _parsed6.type; + offset += _parsed6.size; } } @@ -8065,7 +10424,7 @@ var IIPPacket = /*#__PURE__*/function () { exports["default"] = IIPPacket; -},{"../../Data/DataType.js":15,"./IIPPacketAction.js":45,"./IIPPacketCommand.js":46,"./IIPPacketEvent.js":47,"./IIPPacketReport.js":48}],45:[function(require,module,exports){ +},{"../../Data/DataType.js":18,"../../Data/TransmissionType.js":38,"./IIPPacketAction.js":58,"./IIPPacketCommand.js":59,"./IIPPacketEvent.js":60,"./IIPPacketReport.js":61}],58:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8093,8 +10452,8 @@ var _default = // const IIPPacketAction = ResourceParents: 14, LinkTemplates: 15, // Request Invoke - InvokeFunctionArrayArguments: 16, - InvokeFunctionNamedArguments: 17, + InvokeFunction: 16, + Reserved: 17, Listen: 18, Unlisten: 19, SetProperty: 20, @@ -8108,7 +10467,7 @@ var _default = // const IIPPacketAction = }; exports["default"] = _default; -},{}],46:[function(require,module,exports){ +},{}],59:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8124,7 +10483,7 @@ var _default = // IIPPacketCommand = }; exports["default"] = _default; -},{}],47:[function(require,module,exports){ +},{}],60:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8147,7 +10506,7 @@ var IIPPacketEvent = { var _default = IIPPacketEvent; exports["default"] = _default; -},{}],48:[function(require,module,exports){ +},{}],61:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8163,7 +10522,7 @@ var IIPPacketReport = { var _default = IIPPacketReport; exports["default"] = _default; -},{}],49:[function(require,module,exports){ +},{}],62:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -8251,7 +10610,7 @@ var SendList = /*#__PURE__*/function (_BinaryList) { exports["default"] = SendList; -},{"../Data/BinaryList.js":12}],50:[function(require,module,exports){ +},{"../Data/BinaryList.js":13}],63:[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); } @@ -8348,7 +10707,7 @@ var ISocket = /*#__PURE__*/function (_IDestructible) { exports["default"] = ISocket; -},{"../../Core/IDestructible.js":7,"./SocketState.js":51}],51:[function(require,module,exports){ +},{"../../Core/IDestructible.js":8,"./SocketState.js":64}],64:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8364,7 +10723,7 @@ var _default = { }; exports["default"] = _default; -},{}],52:[function(require,module,exports){ +},{}],65:[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); } @@ -8388,6 +10747,14 @@ var _NetworkBuffer = _interopRequireDefault(require("../NetworkBuffer.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } +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 asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } + +function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } + 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); } } @@ -8408,13 +10775,13 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re 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 WSocket = /*#__PURE__*/function (_ISocket) { _inherits(WSocket, _ISocket); var _super = _createSuper(WSocket); - //SocketState State { get; } - //INetworkReceiver Receiver { get; set; } function WSocket(websocket) { var _this; @@ -8425,21 +10792,17 @@ var WSocket = /*#__PURE__*/function (_ISocket) { _this.sendNetworkBuffer = new _NetworkBuffer["default"](); _this.held = false; - if (websocket != null) // instanceof WebSocket) - { - //websocket.onerror = () => { - // self.state = SocketState.Closed; - //}; - websocket.onopen = function () { - self.state = _SocketState["default"].Established; - }; + if (websocket != null) { + websocket.onopen = function () { + self.state = _SocketState["default"].Established; + }; - websocket.onerror = function () { - self.state = _SocketState["default"].Closed; - }; + websocket.onerror = function () { + self.state = _SocketState["default"].Closed; + }; - _this._assign(websocket); - } + _this._assign(websocket); + } return _this; } @@ -8460,6 +10823,7 @@ var WSocket = /*#__PURE__*/function (_ISocket) { }, { key: "sendAll", value: function sendAll(message) { + // console.log("Out ", message.byteLength); if (this.held) this.sendNetworkBuffer.writeAll(message);else { try { this.ws.send(message); @@ -8481,26 +10845,30 @@ var WSocket = /*#__PURE__*/function (_ISocket) { }, { key: "connect", value: function connect(hostname, port) { + var _this2 = this; + var secure = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; var self = this; var rt = new _AsyncReply["default"](); this.state = _SocketState["default"].Connecting; this.url = "ws".concat(secure ? 's' : '', "://").concat(hostname, ":").concat(port); - var ws = new WebSocket(this.url, "iip"); - ws.binaryType = "arraybuffer"; + WSocket.getWebScoket().then(function (webSocket) { + var ws; + ws = new webSocket(_this2.url, "iip"); + ws.binaryType = "arraybuffer"; - ws.onopen = function () { - self.state = _SocketState["default"].Established; - rt.trigger(true); - }; + ws.onopen = function () { + self.state = _SocketState["default"].Established; + rt.trigger(true); + }; - ws.onerror = function () { - self.state = _SocketState["default"].Closed; - rt.triggerError(_ErrorType["default"].Management, _ExceptionCode["default"].HostNotReachable); - }; - - this._assign(ws); + ws.onerror = function () { + self.state = _SocketState["default"].Closed; + rt.triggerError(_ErrorType["default"].Management, _ExceptionCode["default"].HostNotReachable); + }; + self._assign(ws); + }); return rt; // new AsyncReply(true); } }, { @@ -8516,6 +10884,7 @@ var WSocket = /*#__PURE__*/function (_ISocket) { }; ws.onmessage = function (msg) { + //console.log("WREC ", msg.data.byteLength); self.receiveNetworkBuffer.writeAll(msg.data); self.receiver.networkReceive(this, self.receiveNetworkBuffer); //self.lastAction = new Date(); }; @@ -8558,20 +10927,66 @@ var WSocket = /*#__PURE__*/function (_ISocket) { this.state = _SocketState["default"].Closed; } } + }], [{ + key: "getWebScoket", + value: function () { + var _getWebScoket = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() { + var wsModule; + return regeneratorRuntime.wrap(function _callee$(_context) { + while (1) { + switch (_context.prev = _context.next) { + case 0: + if (!(WSocket.webSocket == null)) { + _context.next = 9; + break; + } + + if (!(typeof window === 'undefined')) { + _context.next = 8; + break; + } + + _context.next = 4; + return Promise.resolve().then(function () { + return _interopRequireWildcard(require('ws')); + }); + + case 4: + wsModule = _context.sent; + WSocket.webSocket = wsModule["default"]; + _context.next = 9; + break; + + case 8: + WSocket.webSocket = WebSocket; + + case 9: + return _context.abrupt("return", WSocket.webSocket); + + case 10: + case "end": + return _context.stop(); + } + } + }, _callee); + })); + + function getWebScoket() { + return _getWebScoket.apply(this, arguments); + } + + return getWebScoket; + }() }]); return WSocket; -}(_ISocket2["default"]); // if (this.holdSending) { -// //console.log("hold ", data.length); -// this.sendBuffer.writeAll(data); -// } -// else -// //console.log("Send", data.length); - +}(_ISocket2["default"]); exports["default"] = WSocket; -},{"../../Core/AsyncReply.js":4,"../../Core/ErrorType.js":5,"../../Core/ExceptionCode.js":6,"../NetworkBuffer.js":37,"./ISocket.js":50,"./SocketState.js":51}],53:[function(require,module,exports){ +_defineProperty(WSocket, "webSocket", null); + +},{"../../Core/AsyncReply.js":5,"../../Core/ErrorType.js":6,"../../Core/ExceptionCode.js":7,"../NetworkBuffer.js":50,"./ISocket.js":63,"./SocketState.js":64,"ws":1}],66:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -8632,7 +11047,7 @@ exports["default"] = ResourceProxy; _defineProperty(ResourceProxy, "cache", {}); -},{"../Resource/Warehouse.js":67}],54:[function(require,module,exports){ +},{"../Resource/Warehouse.js":84}],67:[function(require,module,exports){ /* * Copyright (c) 2017-2018 Ahmed Kh. Zamil * @@ -8667,17 +11082,150 @@ exports["default"] = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -var CustomResourceEvent = function CustomResourceEvent(issuer, receivers, args) { +var CustomResourceEvent = function CustomResourceEvent(issuer, receivers, value) { _classCallCheck(this, CustomResourceEvent); this.issuer = issuer; this.receivers = receivers; - this.args = args; + this.value = value; }; exports["default"] = CustomResourceEvent; -},{}],55:[function(require,module,exports){ +},{}],68:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +var _Session = _interopRequireDefault(require("../Security/Authority/Session.js")); + +var _IResource = _interopRequireDefault(require("./IResource.js")); + +var _EventTemplate = _interopRequireDefault(require("./Template/EventTemplate.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 EventOccurredInfo = /*#__PURE__*/function () { + function EventOccurredInfo(resource, eventTemplate, value, issuer, receivers) { + _classCallCheck(this, EventOccurredInfo); + + this.resource = resource; + this.eventTemplate = eventTemplate; + this.value = value; + this.issuer = issuer; + this.receivers = receivers; + } + + _createClass(EventOccurredInfo, [{ + key: "name", + get: function get() { + return this.eventTemplate.name; + } + }]); + + return EventOccurredInfo; +}(); + +exports["default"] = EventOccurredInfo; + +},{"../Security/Authority/Session.js":90,"./IResource.js":70,"./Template/EventTemplate.js":76}],69:[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 _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 _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 FactoryEntry = /*#__PURE__*/function () { + function FactoryEntry(type, representationType) { + _classCallCheck(this, FactoryEntry); + + this.type = type; + this.nullableType = this.getNullableType(type); + this.representationType = representationType; + } + + _createClass(FactoryEntry, [{ + key: "isMapKeySubType", + value: //Type get type => T; + //late Type nullableType; + //final Function instanceCreator; + //final Function arrayCreator = () => []; + //final RepresentationType representationType; + function isMapKeySubType(map) {//return map is Map; + } + }, { + key: "isMapValueSubType", + value: function isMapValueSubType(map) {//return map is Map; + } + }, { + key: "isListSubType", + value: function isListSubType(list) {//return list is List; + } + }, { + key: "getNullableType", + value: function getNullableType(type) { + var c = /*#__PURE__*/function (_type) { + _inherits(c, _type); + + var _super = _createSuper(c); + + function c() { + _classCallCheck(this, c); + + return _super.apply(this, arguments); + } + + return c; + }(type); + + Object.defineProperty(c, "name", { + value: "Nullable" + type.name + }); + Object.defineProperty(c, "nullable", { + value: true + }); + return c; + } + }]); + + return FactoryEntry; +}(); + +exports["default"] = FactoryEntry; + +},{}],70:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -8767,6 +11315,13 @@ var IResource = /*#__PURE__*/function (_IDestructible) { value: function trigger(_trigger) { return new _AsyncReply["default"](true); } + }, { + key: "toString", + value: function toString() { + var _this$instance$templa, _this$instance, _this$instance$templa2; + + return (_this$instance$templa = this === null || this === void 0 ? void 0 : (_this$instance = this.instance) === null || _this$instance === void 0 ? void 0 : (_this$instance$templa2 = _this$instance.template) === null || _this$instance$templa2 === void 0 ? void 0 : _this$instance$templa2.namespace) !== null && _this$instance$templa !== void 0 ? _this$instance$templa : "IResource"; + } }], [{ key: "template", get: function get() { @@ -8784,7 +11339,7 @@ var IResource = /*#__PURE__*/function (_IDestructible) { exports["default"] = IResource; -},{"../Core/AsyncBag.js":1,"../Core/AsyncReply.js":4,"../Core/IDestructible.js":7}],56:[function(require,module,exports){ +},{"../Core/AsyncBag.js":2,"../Core/AsyncReply.js":5,"../Core/IDestructible.js":8}],71:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -8866,6 +11421,9 @@ var IStore = /*#__PURE__*/function (_IResource) { }, { key: "record", value: function record(resource, propertyName, value, age, dateTime) {} + }, { + key: "modify", + value: function modify(resource, propertyName, value, age, dateTime) {} }, { key: "getRecord", value: function getRecord(resource, fromDate, toDate) {} @@ -8879,7 +11437,7 @@ var IStore = /*#__PURE__*/function (_IResource) { exports["default"] = IStore; -},{"./IResource.js":55}],57:[function(require,module,exports){ +},{"./IResource.js":70}],72:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -8918,8 +11476,6 @@ var _IEventHandler2 = _interopRequireDefault(require("../Core/IEventHandler.js") var _IPermissionsManager = _interopRequireDefault(require("../Security/Permissions/IPermissionsManager.js")); -var _StructureArray = _interopRequireDefault(require("../Data/StructureArray.js")); - var _AutoList = _interopRequireDefault(require("../Data/AutoList.js")); var _KeyList = _interopRequireDefault(require("../Data/KeyList.js")); @@ -8934,6 +11490,16 @@ var _Warehouse = _interopRequireDefault(require("./Warehouse.js")); var _Ruling = _interopRequireDefault(require("../Security/Permissions/Ruling.js")); +var _TypedMap = _interopRequireDefault(require("../Data/TypedMap.js")); + +var _TypedList = _interopRequireDefault(require("../Data/TypedList.js")); + +var _EventOccurredInfo = _interopRequireDefault(require("./EventOccurredInfo.js")); + +var _PropertyModificationInfo = _interopRequireDefault(require("./PropertyModificationInfo.js")); + +var _PropertyValueArray = _interopRequireDefault(require("../Data/PropertyValueArray.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"); } } @@ -9011,8 +11577,8 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { } // connect events - for (var i = 0; i < _this.template.events.length; i++) { - _this.resource.on(_this.template.events[i].name, _this._makeHandler(_this.template.events[i].name)); + for (var _i = 0; _i < _this.template.events.length; _i++) { + _this.resource.on(_this.template.events[_i].name, _this._makeHandler(_this.template.events[_i])); } return _this; @@ -9071,7 +11637,7 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { }, { key: "serialize", value: function serialize() { - var props = []; + var props = new _PropertyValueArray["default"](); for (var i = 0; i < this.template.properties.length; i++) { props.push(new _PropertyValue["default"](this.resource[this.template.properties[i].name], this.ages[this.template.properties[i].index], this.modificationDates[this.template.properties[i].index])); @@ -9082,7 +11648,7 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { }, { key: "isStorable", value: function isStorable() { - return resource instanceof Storable; + return false; } }, { key: "emitModification", @@ -9091,12 +11657,15 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { var now = new Date(); this.ages[pt.index] = this.instanceAge; this.modificationDates[pt.index] = now; - if (pt.recordable) this.store.record(this.resource, pt.name, value, this.ages[pt.index], now); + if (pt.recordable) this.store.record(this.resource, pt.name, value, this.ages[pt.index], now);else this.store.modify(this.resource, pt.name, value, this.ages[pt.index], now); + var pmInfo = new _PropertyModificationInfo["default"](this.resource, pt, value, this.instanceAge); - _get(_getPrototypeOf(Instance.prototype), "_emit", this).call(this, "ResourceModified", this.resource, pt.name, value); //this.resource._emit("modified", pt.name, value); + _get(_getPrototypeOf(Instance.prototype), "_emit", this).call(this, "PropertyModified", pmInfo); + this.resource._emit(":".concat(pt.name), value); //this.resource.emitProperty(pmInfo); + //super._emit("ResourceModified", this.resource, pt.name, value); + //this.resource._emit(":" + pt.name, value); - this.resource._emit(":" + pt.name, value); } }, { key: "modified", @@ -9122,8 +11691,9 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { }) }, { key: "_emitResourceEvent", - value: function _emitResourceEvent(issuer, receivers, name, args) { - _get(_getPrototypeOf(Instance.prototype), "_emit", this).call(this, "ResourceEventOccurred", this.resource, issuer, receivers, name, args); + value: function _emitResourceEvent(issuer, receivers, eventTemplate, value) { + _get(_getPrototypeOf(Instance.prototype), "_emit", this).call(this, "EventOccurred", new _EventOccurredInfo["default"](this.resource, eventTemplate, value, issuer, receivers)); //super._emit("ResourceEventOccurred", this.resource, issuer, receivers, name, args); + } }, { key: "getPropertyValue", @@ -9137,12 +11707,17 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { return false; } + }, { + key: "age", + get: function get() { + return this.instanceAge; + } }, { key: "_makeHandler", - value: function _makeHandler(name) { + value: function _makeHandler(eventTemplate) { var self = this; - return function (args) { - if (args instanceof _CustomResourceEvent["default"]) self._emitResourceEvent(args.issuer, args.receivers, name, args.args);else self._emitResourceEvent(null, null, name, args); + return function (argument) { + if (argument instanceof _CustomResourceEvent["default"]) self._emitResourceEvent(argument.issuer, argument.receivers, eventTemplate, argument.value);else self._emitResourceEvent(null, null, eventTemplate, argument); }; } /// /// Check for permission. @@ -9187,13 +11762,13 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { for (var i = 0; i < attributes.length; i++) { var attr = attributes[i]; if (attr == "name") st["name"] = this.name;else if (attr == "managers") { - var mngrs = new _StructureArray["default"](); + var mngrs = new (_TypedList["default"].of(_TypedMap["default"].of(String, Object)))(); for (var j = 0; j < this.managers.length; j++) { var manager = this.managers.item(j); - var sm = new _Structure["default"](); - sm["type"] = manager.constructor.name; - sm["settings"] = manager.settings; + var sm = new (_TypedMap["default"].of(String, Object))(); + sm.set("type", manager.constructor.name); + sm.set("settings", manager.settings); mngrs.push(sm); } @@ -9239,7 +11814,7 @@ var Instance = /*#__PURE__*/function (_IEventHandler) { exports["default"] = Instance; -},{"../Core/IEventHandler.js":8,"../Data/AutoList.js":10,"../Data/KeyList.js":18,"../Data/PropertyValue.js":20,"../Data/Structure.js":26,"../Data/StructureArray.js":27,"../Security/Permissions/IPermissionsManager.js":77,"../Security/Permissions/Ruling.js":78,"./CustomResourceEvent.js":54,"./Warehouse.js":67}],58:[function(require,module,exports){ +},{"../Core/IEventHandler.js":9,"../Data/AutoList.js":11,"../Data/KeyList.js":23,"../Data/PropertyValue.js":26,"../Data/PropertyValueArray.js":27,"../Data/Structure.js":35,"../Data/TypedList.js":40,"../Data/TypedMap.js":41,"../Security/Permissions/IPermissionsManager.js":94,"../Security/Permissions/Ruling.js":95,"./CustomResourceEvent.js":67,"./EventOccurredInfo.js":68,"./PropertyModificationInfo.js":73,"./Warehouse.js":84}],73:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9247,11 +11822,56 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = _interopRequireDefault(require("../../Data/DataConverter.js")); +var _IResource = _interopRequireDefault(require("./IResource.js")); -var _BinaryList = _interopRequireDefault(require("../../Data/BinaryList.js")); +var _PropertyTemplate = _interopRequireDefault(require("./Template/PropertyTemplate.js")); -var _TemplateDataType = _interopRequireDefault(require("./TemplateDataType.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 PropertyModificationInfo = /*#__PURE__*/function () { + function PropertyModificationInfo() { + _classCallCheck(this, PropertyModificationInfo); + } + + _createClass(PropertyModificationInfo, [{ + key: "name", + get: function get() { + return this.propertyTemplate.name; + } + }, { + key: "PropertyModificationInfo", + value: function PropertyModificationInfo(resource, propertyTemplate, value, age) { + this.resource = resource; + this.propertyTemplate = propertyTemplate; + this.value = value; + this.age = age; + } + }]); + + return PropertyModificationInfo; +}(); + +exports["default"] = PropertyModificationInfo; + +},{"./IResource.js":70,"./Template/PropertyTemplate.js":80}],74:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports["default"] = void 0; + +var _DC = require("../../Data/DC.js"); + +var _RepresentationType = _interopRequireDefault(require("../../Data/RepresentationType.js")); + +var _ParseResult = _interopRequireDefault(require("../../Data/ParseResult.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } @@ -9262,35 +11882,33 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var ArgumentTemplate = /*#__PURE__*/function () { - function ArgumentTemplate(name, type) { + function ArgumentTemplate(name, type, optional, index) { _classCallCheck(this, ArgumentTemplate); this.name = name; this.type = type; + this.optional = optional; + this.index = index; } _createClass(ArgumentTemplate, [{ key: "compose", value: function compose() { - var name = _DataConverter["default"].stringToBytes(this.name); + var name = _DC.DC.stringToBytes(this.name); - return new _BinaryList["default"]().addUint8(name.length).addUint8Array(name).addUint8Array(this.type.compose()).toArray(); + return (0, _DC.BL)().addUint8(this.optional ? 1 : 0).addUint8(name.length).addDC(name).addDC(this.type.compose()).toDC(); } }], [{ key: "parse", - value: function parse(data, offset) { + value: function parse(data, offset, index) { + var optional = (data[offset++] & 0x1) == 0x1; var cs = data[offset++]; var name = data.getString(offset, cs); offset += cs; - var _TemplateDataType$par = _TemplateDataType["default"].parse(data, offset), - size = _TemplateDataType$par.size, - value = _TemplateDataType$par.value; + var tdr = _RepresentationType["default"].parse(data, offset); - return { - size: cs + 1 + size, - value: new ArgumentTemplate(name, value) - }; + return new _ParseResult["default"](cs + 2 + tdr.size, new ArgumentTemplate(name, tdr.type, optional, index)); } }]); @@ -9299,7 +11917,93 @@ var ArgumentTemplate = /*#__PURE__*/function () { exports["default"] = ArgumentTemplate; -},{"../../Data/BinaryList.js":12,"../../Data/DataConverter.js":14,"./TemplateDataType.js":64}],59:[function(require,module,exports){ +},{"../../Data/DC.js":15,"../../Data/ParseResult.js":25,"../../Data/RepresentationType.js":31}],75:[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 _DC = require("../../Data/DC.js"); + +var _MemberTemplate2 = _interopRequireDefault(require("./MemberTemplate.js")); + +var _Codec = _interopRequireDefault(require("../../Data/Codec.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 _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 ConstantTemplate = /*#__PURE__*/function (_MemberTemplate) { + _inherits(ConstantTemplate, _MemberTemplate); + + var _super = _createSuper(ConstantTemplate); + + //final dynamic value; + //final String? expansion; + //final RepresentationType valueType; + function ConstantTemplate(template, index, name, inherited, valueType, value, expansion) { + var _this; + + _classCallCheck(this, ConstantTemplate); + + _this = _super.call(this, template, index, name, inherited); + _this.valueType = valueType; + _this.value = value; + _this.expansion = expansion; + return _this; + } + + _createClass(ConstantTemplate, [{ + key: "compose", + value: function compose() { + var name = _get(_getPrototypeOf(ConstantTemplate.prototype), "compose", this).call(this); + + var hdr = this.inherited ? 0x80 : 0; + + if (this.expansion != null) { + var exp = _DC.DC.stringToBytes(this.expansion); + + hdr |= 0x70; + return (0, _DC.BL)().addUint8(hdr).addUint8(name.length).addDC(name).addDC(this.valueType.compose()).addDC(_Codec["default"].compose(this.value, null)).addInt32(exp.length).addDC(exp).toDC(); + } else { + hdr |= 0x60; + return (0, _DC.BL)().addUint8(hdr).addUint8(name.length).addDC(name).addDC(this.valueType.compose()).addDC(_Codec["default"].compose(this.value, null)).toDC(); + } + } + }]); + + return ConstantTemplate; +}(_MemberTemplate2["default"]); + +exports["default"] = ConstantTemplate; + +},{"../../Data/Codec.js":14,"../../Data/DC.js":15,"./MemberTemplate.js":78}],76:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -9334,12 +12038,10 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); var _MemberTemplate2 = _interopRequireDefault(require("./MemberTemplate.js")); -var _MemberType = _interopRequireDefault(require("./MemberType.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"); } } @@ -9348,10 +12050,6 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ 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); } @@ -9364,6 +12062,10 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen 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 _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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var EventTemplate = /*#__PURE__*/function (_MemberTemplate) { @@ -9371,28 +12073,38 @@ var EventTemplate = /*#__PURE__*/function (_MemberTemplate) { var _super = _createSuper(EventTemplate); - function EventTemplate() { + function EventTemplate(template, index, name, inherited, argumentType) { var _this; + var expansion = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; + var listenable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false; + _classCallCheck(this, EventTemplate); - _this = _super.call(this); - _this.type = _MemberType["default"].Event; + _this = _super.call(this, template, index, name, inherited); + _this.argumentType = argumentType; + _this.expansion = expansion; + _this.listenable = listenable; return _this; } _createClass(EventTemplate, [{ key: "compose", value: function compose() { - var rt = (0, _DataConverter.BL)(); - var name = _get(_getPrototypeOf(EventTemplate.prototype), "compose", this).call(this); - if (this.expansion != null) { - var exp = _DataConverter.DC.stringToBytes(this.expansion); + var hdr = this.inherited ? 0x80 : 0; + if (this.listenable) hdr |= 0x8; - return rt.addUint8(this.listenable ? 0x58 : 0x50).addUint8(name.length).addUint8Array(name).addUint8Array(this.argumentType.compose()).addUint32(exp.length).addUint8Array(exp).toArray(); - } else return rt.addUint8(this.listenable ? 0x48 : 0x40).addUint8(name.length).addUint8Array(name).addUint8Array(this.argumentType.compose()).toArray(); + if (this.expansion != null) { + var exp = _DC.DC.stringToBytes(this.expansion); + + hdr |= 0x50; + return (0, _DC.BL)().addUint8(hdr).addUint8(name.length).addDC(name).addDC(this.argumentType.compose()).addInt32(exp.length).addDC(exp).toDC(); + } else { + hdr |= 0x40; + return (0, _DC.BL)().addUint8(hdr).addUint8(name.length).addDC(name).addDC(this.argumentType.compose()).toDC(); + } } }]); @@ -9401,9 +12113,9 @@ var EventTemplate = /*#__PURE__*/function (_MemberTemplate) { exports["default"] = EventTemplate; -},{"../../Data/DataConverter.js":14,"./MemberTemplate.js":61,"./MemberType.js":62}],60:[function(require,module,exports){ +},{"../../Data/DC.js":15,"./MemberTemplate.js":78}],77:[function(require,module,exports){ /* -* Copyright (c) 2017 Ahmed Kh. Zamil +* 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 @@ -9436,12 +12148,10 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); var _MemberTemplate2 = _interopRequireDefault(require("./MemberTemplate.js")); -var _MemberType = _interopRequireDefault(require("./MemberType.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"); } } @@ -9473,13 +12183,17 @@ var FunctionTemplate = /*#__PURE__*/function (_MemberTemplate) { var _super = _createSuper(FunctionTemplate); - function FunctionTemplate() { + function FunctionTemplate(template, index, name, inherited, args, returnType) { var _this; + var expansion = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; + _classCallCheck(this, FunctionTemplate); - _this = _super.call(this); - _this.type = _MemberType["default"].Function; + _this = _super.call(this, template, index, name, inherited); + _this.args = args; + _this.returnType = returnType; + _this.expansion = expansion; return _this; } @@ -9488,20 +12202,20 @@ var FunctionTemplate = /*#__PURE__*/function (_MemberTemplate) { value: function compose() { var name = _get(_getPrototypeOf(FunctionTemplate.prototype), "compose", this).call(this); - var bl = (0, _DataConverter.BL)().addUint8(name.length).addUint8Array(name).addUint8Array(this.returnType.compose()).addUint8(this.arguments.length); + var bl = new _DC.BL().addUint8(name.length).addDC(name).addDC(this.returnType.compose()).addUint8(this.args.length); - for (var i = 0; i < this.arguments.length; i++) { - bl.addUint8Array(this.arguments[i].compose()); + for (var i = 0; i < this.args.length; i++) { + bl.addDC(this.args[i].compose()); } if (this.expansion != null) { - var exp = _DataConverter.DC.stringToBytes(this.expansion); + var exp = _DC.DC.stringToBytes(this.expansion); - bl.addInt32(exp.length).addUint8Array(exp); - bl.insertUint8(0, 0x10); - } else bl.addUint8(0x0, 0); + bl.addInt32(exp.length).addDC(exp); + bl.insertUint8(0, this.inherited ? 0x90 : 0x10); + } else bl.insertUint8(0, this.inherited ? 0x80 : 0x0); - return bl.toArray(); + return bl.toDC(); } }]); @@ -9510,7 +12224,7 @@ var FunctionTemplate = /*#__PURE__*/function (_MemberTemplate) { exports["default"] = FunctionTemplate; -},{"../../Data/DataConverter.js":14,"./MemberTemplate.js":61,"./MemberType.js":62}],61:[function(require,module,exports){ +},{"../../Data/DC.js":15,"./MemberTemplate.js":78}],78:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -9543,7 +12257,7 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = _interopRequireDefault(require("../../Data/DataConverter.js")); +var _DC = _interopRequireDefault(require("../../Data/DC.js")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } @@ -9554,14 +12268,24 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var MemberTemplate = /*#__PURE__*/function () { - function MemberTemplate() { + function MemberTemplate(template, index, name, inherited) { _classCallCheck(this, MemberTemplate); + + this.template = template; + this.index = index; + this.name = name; + this.inherited = inherited; } _createClass(MemberTemplate, [{ + key: "fullname", + get: function get() { + return this.template.className + "." + this.name; + } + }, { key: "compose", value: function compose() { - return _DataConverter["default"].stringToBytes(this.name); + return _DC["default"].stringToBytes(this.name); } }]); @@ -9570,7 +12294,7 @@ var MemberTemplate = /*#__PURE__*/function () { exports["default"] = MemberTemplate; -},{"../../Data/DataConverter.js":14}],62:[function(require,module,exports){ +},{"../../Data/DC.js":15}],79:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9584,32 +12308,7 @@ var _default = { }; exports["default"] = _default; -},{}],63:[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 27/08/2017. - */ +},{}],80:[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); } @@ -9617,14 +12316,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi Object.defineProperty(exports, "__esModule", { value: true }); -exports["default"] = exports.PropertyPermission = void 0; +exports["default"] = void 0; -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); var _MemberTemplate2 = _interopRequireDefault(require("./MemberTemplate.js")); -var _MemberType = _interopRequireDefault(require("./MemberType.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"); } } @@ -9633,10 +12330,6 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+ 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); } @@ -9649,27 +12342,31 @@ function _assertThisInitialized(self) { if (self === void 0) { throw new Referen 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 _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); } -var PropertyPermission = { - Read: 1, - Write: 2, - ReadWrite: 3 -}; -exports.PropertyPermission = PropertyPermission; +function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var PropertyTemplate = /*#__PURE__*/function (_MemberTemplate) { _inherits(PropertyTemplate, _MemberTemplate); var _super = _createSuper(PropertyTemplate); - function PropertyTemplate() { + function PropertyTemplate(template, index, name, inherited, valueType) { var _this; + var readExpansion = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; + var writeExpansion = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; + var recordable = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false; + _classCallCheck(this, PropertyTemplate); - _this = _super.call(this); - _this.type = _MemberType["default"].Property; + _this = _super.call(this, template, index, name, inherited); + _this.valueType = valueType; + _this.readExpansion = readExpansion; + _this.writeExpansion = writeExpansion; + _this.recordable = recordable; return _this; } @@ -9678,24 +12375,24 @@ var PropertyTemplate = /*#__PURE__*/function (_MemberTemplate) { value: function compose() { var name = _get(_getPrototypeOf(PropertyTemplate.prototype), "compose", this).call(this); - var rt = (0, _DataConverter.BL)(); var pv = this.permission << 1 | (this.recordable ? 1 : 0); + if (this.inherited) pv |= 0x80; if (this.writeExpansion != null && this.readExpansion != null) { - var rexp = _DataConverter.DC.stringToBytes(this.readExpansion); + var rexp = _DC.DC.stringToBytes(this.readExpansion); - var wexp = _DataConverter.DC.stringToBytes(this.writeExpansion); + var wexp = _DC.DC.stringToBytes(this.writeExpansion); - return rt.addUint8(0x38 | pv).addUint8(name.length).addUint8Array(name).addUint8Array(this.valueType.compose()).addUint32(wexp.length).addUint8Array(wexp).addUint32(rexp.length).addUint8Array(rexp).toArray(); + return (0, _DC.BL)().addUint8(0x38 | pv).addUint8(name.length).addDC(name).addDC(this.valueType.compose()).addInt32(wexp.length).addDC(wexp).addInt32(rexp.length).addDC(rexp).toDC(); } else if (this.writeExpansion != null) { - var wexp = _DataConverter.DC.stringToBytes(this.writeExpansion); + var _wexp = _DC.DC.stringToBytes(this.writeExpansion); - return rt.addUint8(0x30 | pv).addUint8(name.length).addUint8Array(name).addUint8Array(this.valueType.compose()).addUint32(wexp.length).addUint8Array(wexp).toArray(); + return (0, _DC.BL)().addUint8(0x30 | pv).addUint8(name.length).addDC(name).addDC(this.valueType.compose()).addInt32(_wexp.length).addDC(_wexp).toDC(); } else if (this.readExpansion != null) { - var rexp = _DataConverter.DC.stringToBytes(this.readExpansion); + var _rexp = _DC.DC.stringToBytes(this.readExpansion); - return rt.addUint8(0x28 | pv).addUint8(name.length).addUint8Array(name).addUint8Array(this.valueType.compose()).addUint32(rexp.length).addUint8Array(rexp).toArray(); - } else return rt.addUint8(0x20 | pv).addUint8(name.length).addUint8Array(name).addUint8Array(this.valueType.compose()).toArray(); + return (0, _DC.BL)().addUint8(0x28 | pv).addUint8(name.length).addDC(name).addDC(this.valueType.compose()).addInt32(_rexp.length).addDC(_rexp).toDC(); + } else return (0, _DC.BL)().addUint8(0x20 | pv).addUint8(name.length).addDC(name).addDC(this.valueType.compose()).toDC(); } }]); @@ -9704,7 +12401,7 @@ var PropertyTemplate = /*#__PURE__*/function (_MemberTemplate) { exports["default"] = PropertyTemplate; -},{"../../Data/DataConverter.js":14,"./MemberTemplate.js":61,"./MemberType.js":62}],64:[function(require,module,exports){ +},{"../../Data/DC.js":15,"./MemberTemplate.js":78}],81:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -9733,7 +12430,7 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); var _DataType = _interopRequireDefault(require("../../Data/DataType.js")); @@ -9773,8 +12470,8 @@ var TemplateDataType = /*#__PURE__*/function () { key: "compose", value: function compose() { if (this.type == _DataType["default"].Resource || this.type == _DataType["default"].ResourceArray || this.type == _DataType["default"].Record || this.type == _DataType["default"].RecordArray) { - return (0, _DataConverter.BL)().addUint8(this.type).addUint8Array(this.typeGuid).toDC(); - } else return _DataConverter.DC.from([this.type]); + return (0, _DC.BL)().addUint8(this.type).addUint8Array(this.typeGuid).toDC(); + } else return _DC.DC.from([this.type]); } }], [{ key: "fromType", @@ -9823,7 +12520,7 @@ exports["default"] = TemplateDataType; _defineProperty(TemplateDataType, "typesDefinitions", ["var", "bool", "sbyte", "byte", "char", "short", "ushort", "int", "uint", "long", "ulong", "float", "double", "decimal", "date", "resource", "DistributedResource", "ResourceLink", "string", "structure"]); -},{"../../Data/DataConverter.js":14,"../../Data/DataType.js":15,"../../Data/IRecord.js":17,"../../Data/Structure.js":26,"../IResource.js":55,"./TypeTemplate.js":66}],65:[function(require,module,exports){ +},{"../../Data/DC.js":15,"../../Data/DataType.js":18,"../../Data/IRecord.js":22,"../../Data/Structure.js":35,"../IResource.js":70,"./TypeTemplate.js":83}],82:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -9834,11 +12531,12 @@ var _default = { Unspecified: 0, Resource: 1, Record: 2, - Wrapper: 3 + Wrapper: 3, + Enum: 4 }; exports["default"] = _default; -},{}],66:[function(require,module,exports){ +},{}],83:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -9875,12 +12573,10 @@ var _EventTemplate = _interopRequireDefault(require("./EventTemplate.js")); var _SHA = _interopRequireDefault(require("../../Security/Integrity/SHA256.js")); -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); var _ArgumentTemplate = _interopRequireDefault(require("./ArgumentTemplate.js")); -var _TemplateDataType = _interopRequireDefault(require("./TemplateDataType.js")); - var _IResource = _interopRequireDefault(require("../IResource.js")); var _IRecord = _interopRequireDefault(require("../../Data/IRecord.js")); @@ -9891,6 +12587,16 @@ var _Warehouse = _interopRequireDefault(require("../Warehouse.js")); var _DistributedConnection = _interopRequireDefault(require("../../Net/IIP/DistributedConnection.js")); +var _ConstantTemplate = _interopRequireDefault(require("./ConstantTemplate.js")); + +var _IEnum = _interopRequireDefault(require("../../Data/IEnum.js")); + +var _DistributedResource = _interopRequireDefault(require("../../Net/IIP/DistributedResource.js")); + +var _RepresentationType = _interopRequireDefault(require("../../Data/RepresentationType.js")); + +var _Codec = _interopRequireDefault(require("../../Data/Codec.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"); } } @@ -9907,63 +12613,63 @@ var TypeTemplate = /*#__PURE__*/function () { this.events = []; this.functions = []; this.members = []; + this.constants = []; if (type === undefined) return; - if (type.prototype instanceof _IRecord["default"]) this.templateType = _TemplateType["default"].Record;else if (type.prototype instanceof _IResource["default"]) this.templateType = _TemplateType["default"].Resource;else throw new Error("Type is neither a resource nor a record."); + if (type.prototype instanceof _DistributedResource["default"]) this.templateType = _TemplateType["default"].Wrapper; + if (type.prototype instanceof _IRecord["default"]) this.templateType = _TemplateType["default"].Record;else if (type.prototype instanceof _IResource["default"]) this.templateType = _TemplateType["default"].Resource;else if (type.prototype instanceof _IEnum["default"]) this.templateType = _TemplateType["default"].Enum;else throw new Error("Type must implement IResource, IRecord, IEnum or a subtype of DistributedResource."); this.definedType = type; var template = type.template; // set guid this.className = template.namespace + "." + type.prototype.constructor.name; - this.classId = _SHA["default"].compute(_DataConverter.DC.stringToBytes(this.className)).getGuid(0); + this.classId = _SHA["default"].compute(_DC.DC.stringToBytes(this.className)).getGuid(0); if (addToWarehouse) addToWarehouse.putTemplate(this); //byte currentIndex = 0; if (template.properties != null) for (var i = 0; i < template.properties.length; i++) { - var _pi$, _pi$2, _pi$3; + var _RepresentationType$f, _pi$, _pi$2, _pi$3; //[name, type, {read: comment, write: comment, recordable: }] var pi = template.properties[i]; - var pt = new _PropertyTemplate["default"](); - pt.name = pi[0]; - pt.index = i; - pt.valueType = _TemplateDataType["default"].fromType(pi[1]); - pt.readExpansion = (_pi$ = pi[2]) === null || _pi$ === void 0 ? void 0 : _pi$.read; - pt.writeExpansion = (_pi$2 = pi[2]) === null || _pi$2 === void 0 ? void 0 : _pi$2.write; - pt.recordable = (_pi$3 = pi[2]) === null || _pi$3 === void 0 ? void 0 : _pi$3.recordable; + var pt = new _PropertyTemplate["default"](this, i, pi[0], false, (_RepresentationType$f = _RepresentationType["default"].fromType(pi[1])) !== null && _RepresentationType$f !== void 0 ? _RepresentationType$f : _RepresentationType["default"].Void, (_pi$ = pi[2]) === null || _pi$ === void 0 ? void 0 : _pi$.read, (_pi$2 = pi[2]) === null || _pi$2 === void 0 ? void 0 : _pi$2.write, (_pi$3 = pi[2]) === null || _pi$3 === void 0 ? void 0 : _pi$3.recordable); pt.propertyInfo = pi; this.properties.push(pt); } + if (template.constants != null) for (var _i = 0; _i < template.constants.length; _i++) { + var _RepresentationType$f2; + + var ci = template.constants[_i]; + var ct = new _ConstantTemplate["default"](this, _i, ci[0], false, (_RepresentationType$f2 = _RepresentationType["default"].fromType(ci[1])) !== null && _RepresentationType$f2 !== void 0 ? _RepresentationType$f2 : _RepresentationType["default"].Void, ci.value, ci.help); + ct.propertyInfo = ci; + this.constants.push(ct); + } if (this.templateType == _TemplateType["default"].Resource) { if (template.events != null) { - for (var _i = 0; _i < template.events.length; _i++) { - var _ei$, _ei$2; + for (var _i2 = 0; _i2 < template.events.length; _i2++) { + var _RepresentationType$f3, _ei$, _ei$2; // [name, type, {listenable: true/false, help: ""}] - var ei = template.events[_i]; - var et = new _EventTemplate["default"](); - et.name = ei[0]; - et.index = _i; - et.argumentType = _TemplateDataType["default"].fromType(ei[1]), et.expansion = (_ei$ = ei[2]) === null || _ei$ === void 0 ? void 0 : _ei$.help; - et.listenable = (_ei$2 = ei[2]) === null || _ei$2 === void 0 ? void 0 : _ei$2.listenable; + var ei = template.events[_i2]; + var et = new _EventTemplate["default"](this, _i2, ei[0], false, (_RepresentationType$f3 = _RepresentationType["default"].fromType(ei[1])) !== null && _RepresentationType$f3 !== void 0 ? _RepresentationType$f3 : _RepresentationType["default"].Void, (_ei$ = ei[2]) === null || _ei$ === void 0 ? void 0 : _ei$.help, (_ei$2 = ei[2]) === null || _ei$2 === void 0 ? void 0 : _ei$2.listenable); et.eventInfo = ei; this.events.push(et); } } if (template.functions != null) { - for (var _i2 = 0; _i2 < template.functions.length; _i2++) { - var fi = template.functions[_i2]; // [name, {param1: type, param2: int}, returnType, "Description"] + for (var _i3 = 0; _i3 < template.functions.length; _i3++) { + var _RepresentationType$f5; - var ft = new _FunctionTemplate["default"](); - ft.name = fi[0]; - ft.index = _i2; - ft.returnType = _TemplateDataType["default"].fromType(fi[2]); - ft.expansion = fi[3]; - ft.arguments = []; + var fi = template.functions[_i3]; + var args = []; - for (var arg in fi[1]) { - ft.arguments.push(new _ArgumentTemplate["default"](arg, _TemplateDataType["default"].fromType(fi[1][arg]))); - } + for (var ai = 0; ai < fi[1].length; ai++) { + var _RepresentationType$f4, _fi$1$ai$; + args.push(new _ArgumentTemplate["default"](fi[1][ai][0], (_RepresentationType$f4 = _RepresentationType["default"].fromType(fi[1][ai][1])) !== null && _RepresentationType$f4 !== void 0 ? _RepresentationType$f4 : _RepresentationType["default"].Dynamic, (_fi$1$ai$ = fi[1][ai][2]) === null || _fi$1$ai$ === void 0 ? void 0 : _fi$1$ai$.optional, ai)); + } // [name, {param1: type, param2: int}, returnType, "Description"] + + + var ft = new _FunctionTemplate["default"](this, _i3, fi[0], false, args, (_RepresentationType$f5 = _RepresentationType["default"].fromType(fi[2])) !== null && _RepresentationType$f5 !== void 0 ? _RepresentationType$f5 : _RepresentationType["default"].Void, fi[3]); ft.methodInfo = fi; this.functions.push(ft); } @@ -9971,37 +12677,42 @@ var TypeTemplate = /*#__PURE__*/function () { } // append signals - for (var _i3 = 0; _i3 < this.events.length; _i3++) { - this.members.push(this.events[_i3]); + for (var _i4 = 0; _i4 < this.events.length; _i4++) { + this.members.push(this.events[_i4]); } // append slots - for (var _i4 = 0; _i4 < this.functions.length; _i4++) { - this.members.push(this.functions[_i4]); + for (var _i5 = 0; _i5 < this.functions.length; _i5++) { + this.members.push(this.functions[_i5]); } // append properties - for (var _i5 = 0; _i5 < this.properties.length; _i5++) { - this.members.push(this.properties[_i5]); + for (var _i6 = 0; _i6 < this.properties.length; _i6++) { + this.members.push(this.properties[_i6]); + } // append constants + + + for (var _i7 = 0; _i7 < this.constants.length; _i7++) { + this.members.push(this.constants[_i7]); } // bake it binarily - var b = (0, _DataConverter.BL)(); + var b = (0, _DC.BL)(); - var cls = _DataConverter.DC.stringToBytes(this.className); + var cls = _DC.DC.stringToBytes(this.className); b.addUint8(this.templateType).addUint8Array(this.classId.value).addUint8(cls.length).addUint8Array(cls).addUint32(template.version).addUint16(this.members.length); - for (var _i6 = 0; _i6 < this.functions.length; _i6++) { - b.addUint8Array(this.functions[_i6].compose()); + for (var _i8 = 0; _i8 < this.functions.length; _i8++) { + b.addUint8Array(this.functions[_i8].compose()); } - for (var _i7 = 0; _i7 < this.properties.length; _i7++) { - b.addUint8Array(this.properties[_i7].compose()); + for (var _i9 = 0; _i9 < this.properties.length; _i9++) { + b.addUint8Array(this.properties[_i9].compose()); } - for (var _i8 = 0; _i8 < this.events.length; _i8++) { - b.addUint8Array(this.events[_i8].compose()); + for (var _i10 = 0; _i10 < this.events.length; _i10++) { + b.addUint8Array(this.events[_i10].compose()); } this.content = b.toArray(); @@ -10059,6 +12770,24 @@ var TypeTemplate = /*#__PURE__*/function () { if (this.properties[i].index == index) return this.properties[i]; } + return null; + } + }, { + key: "getConstantTemplateByName", + value: function getConstantTemplateByName(constantName) { + for (var i = 0; i < this.constants.length; i++) { + if (this.constants[i].name == constantName) return this.constants[i]; + } + + return null; + } + }, { + key: "getConstantTemplateByIndex", + value: function getConstantTemplateByIndex(index) { + for (var i = 0; i < this.constants.length; i++) { + if (this.constants[i].index == index) return this.constants[i]; + } + return null; } /* @@ -10086,7 +12815,7 @@ var TypeTemplate = /*#__PURE__*/function () { }, { key: "getTypeGuidByName", value: function getTypeGuidByName(typeName) { - return _SHA["default"].compute(_DataConverter.DC.stringToBytes(typeName)).getGuid(0); + return _SHA["default"].compute(_DC.DC.stringToBytes(typeName)).getGuid(0); } }, { key: "getDependencies", @@ -10144,8 +12873,8 @@ var TypeTemplate = /*#__PURE__*/function () { } // properties - for (var _i9 = 0; _i9 < tmp.properties.length; _i9++) { - var p = tmp.properties[_i9]; + for (var _i11 = 0; _i11 < tmp.properties.length; _i11++) { + var p = tmp.properties[_i11]; var pt = _Warehouse["default"].getTemplateByType(p.propertyInfo.propertyType); @@ -10159,8 +12888,8 @@ var TypeTemplate = /*#__PURE__*/function () { } // events - for (var _i10 = 0; _i10 < tmp.events.length; _i10++) { - var e = tmp.events[_i10]; + for (var _i12 = 0; _i12 < tmp.events.length; _i12++) { + var e = tmp.events[_i12]; var et = _Warehouse["default"].getTemplateByType(e.eventInfo.eventHandlerType); @@ -10208,11 +12937,18 @@ var TypeTemplate = /*#__PURE__*/function () { var od = new TypeTemplate(); od.content = data.clip(offset, contentLength); - od.templateType = data.getUint8(offset++); + var hasParent = (data.getUint8(offset) & 0x80) > 0; + od.templateType = data.getUint8(offset++) & 0xF; od.classId = data.getGuid(offset); offset += 16; od.className = data.getString(offset + 1, data.getUint8(offset)); offset += data.getUint8(offset) + 1; + + if (hasParent) { + od.parentId = data.getGuid(offset); + offset += 16; + } + od.version = data.getInt32(offset); offset += 4; var methodsCount = data.getUint16(offset); @@ -10220,31 +12956,30 @@ var TypeTemplate = /*#__PURE__*/function () { var functionIndex = 0; var propertyIndex = 0; var eventIndex = 0; + var constantIndex = 0; for (var i = 0; i < methodsCount; i++) { - var type = data.getUint8(offset) >> 5; + var inherited = (data.getUint8(offset) & 0x80) > 0; + var type = data.getUint8(offset) >> 5 & 0x3; if (type == 0) // function { - var ft = new _FunctionTemplate["default"](); - ft.index = functionIndex++; + var expansion = null; var hasExpansion = (data.getUint8(offset++) & 0x10) == 0x10; var len = data.getUint8(offset++); - ft.name = data.getString(offset, len); + var name = data.getString(offset, len); offset += len; // return type - var _TemplateDataType$par = _TemplateDataType["default"].parse(data, offset), - size = _TemplateDataType$par.size, - returnType = _TemplateDataType$par.value; + var _dt = _RepresentationType["default"].parse(data, offset); - offset += size; - ft.returnType = returnType; // arguments count + offset += _dt.size; //ft.returnType = returnType; + // arguments count var argsCount = data.getUint8(offset++); var args = []; for (var a = 0; a < argsCount; a++) { - var _ArgumentTemplate$par = _ArgumentTemplate["default"].parse(data, offset), + var _ArgumentTemplate$par = _ArgumentTemplate["default"].parse(data, offset, a), argSize = _ArgumentTemplate$par.size, argType = _ArgumentTemplate$par.value; @@ -10252,44 +12987,41 @@ var TypeTemplate = /*#__PURE__*/function () { offset += argSize; } - ft.arguments = args; - if (hasExpansion) // expansion ? { var cs = data.getUint32(offset); offset += 4; - ft.expansion = data.getString(offset, cs); + expansion = data.getString(offset, cs); offset += cs; } + var ft = new _FunctionTemplate["default"](od, functionIndex++, name, inherited, args, _dt.type, expansion); od.functions.push(ft); } else if (type == 1) // property { - var pt = new _PropertyTemplate["default"](); - pt.index = propertyIndex++; var hasReadExpansion = (data.getUint8(offset) & 0x8) == 0x8; var hasWriteExpansion = (data.getUint8(offset) & 0x10) == 0x10; - pt.recordable = (data.getUint8(offset) & 1) == 1; - pt.permission = data.getUint8(offset++) >> 1 & 0x3; + var readExpansion = void 0, + writeExpansion = void 0; + var recordable = (data.getUint8(offset) & 1) == 1; + var permission = data.getUint8(offset++) >> 1 & 0x3; var _len = data.getUint8(offset++); - pt.name = data.getString(offset, _len); + var _name = data.getString(offset, _len); + offset += _len; - var _TemplateDataType$par2 = _TemplateDataType["default"].parse(data, offset), - _size = _TemplateDataType$par2.size, - valueType = _TemplateDataType$par2.value; + var dt = _RepresentationType["default"].parse(data, offset); - offset += _size; - pt.valueType = valueType; + offset += dt.size; if (hasReadExpansion) // expansion ? { var _cs = data.getUint32(offset); offset += 4; - pt.readExpansion = data.getString(offset, _cs); + readExpansion = data.getString(offset, _cs); offset += _cs; } @@ -10298,58 +13030,91 @@ var TypeTemplate = /*#__PURE__*/function () { var _cs2 = data.getUint32(offset); offset += 4; - pt.writeExpansion = data.getString(offset, _cs2); + writeExpansion = data.getString(offset, _cs2); offset += _cs2; } + var pt = new _PropertyTemplate["default"](od, propertyIndex++, _name, inherited, dt.type, readExpansion, writeExpansion, recordable); od.properties.push(pt); } else if (type == 2) // Event { - var et = new _EventTemplate["default"](); - et.index = eventIndex++; - var _hasExpansion = (data.getUint8(offset) & 0x10) == 0x10; - et.listenable = (data.getUint8(offset++) & 0x8) == 0x8; + var listenable = (data.getUint8(offset++) & 0x8) == 0x8; var _len2 = data.getUint8(offset++); - et.name = data.getString(offset, _len2); + var _name2 = data.getString(offset, _len2); + + var _expansion = void 0; + offset += _len2; - var _TemplateDataType$par3 = _TemplateDataType["default"].parse(data, offset), - _size2 = _TemplateDataType$par3.size, - _argType = _TemplateDataType$par3.value; + var _dt2 = _RepresentationType["default"].parse(data, offset); - offset += _size2; - et.argumentType = _argType; + offset += _dt2.size; if (_hasExpansion) // expansion ? { var _cs3 = data.getUint32(offset); offset += 4; - et.expansion = data.getString(offset, _cs3); + _expansion = data.getString(offset, _cs3); offset += _cs3; } + var et = new _EventTemplate["default"](od, eventIndex++, _name2, inherited, _dt2.type, _expansion, listenable); od.events.push(et); + } else if (type == 3) // constant + { + var _expansion2 = null; + + var _hasExpansion2 = (data[offset++] & 0x10) == 0x10; + + var _name3 = data.getString(offset + 1, data[offset]); + + offset += data[offset] + 1; + + var _dt3 = _RepresentationType["default"].parse(data, offset); + + offset += _dt3.size; + + var parsed = _Codec["default"].parse(data, offset, null); + + offset += parsed.size; + + if (_hasExpansion2) // expansion ? + { + var _cs4 = data.getUint32(offset); + + offset += 4; + _expansion2 = data.getString(offset, _cs4); + offset += _cs4; + } + + var ct = new _ConstantTemplate["default"](this, constantIndex++, _name3, inherited, _dt3.type, parsed.reply.result, _expansion2); + od.constants.push(ct); } } // append signals - for (var _i11 = 0; _i11 < od.events.length; _i11++) { - od.members.push(od.events[_i11]); + for (var _i13 = 0; _i13 < od.events.length; _i13++) { + od.members.push(od.events[_i13]); } // append slots - for (var _i12 = 0; _i12 < od.functions.length; _i12++) { - od.members.push(od.functions[_i12]); + for (var _i14 = 0; _i14 < od.functions.length; _i14++) { + od.members.push(od.functions[_i14]); } // append properties - for (var _i13 = 0; _i13 < od.properties.length; _i13++) { - od.members.push(od.properties[_i13]); + for (var _i15 = 0; _i15 < od.properties.length; _i15++) { + od.members.push(od.properties[_i15]); + } // append constants + + + for (var _i16 = 0; _i16 < od.constants.length; _i16++) { + od.members.push(od.constants[_i16]); } return od; @@ -10361,7 +13126,7 @@ var TypeTemplate = /*#__PURE__*/function () { exports["default"] = TypeTemplate; -},{"../../Data/DataConverter.js":14,"../../Data/IRecord.js":17,"../../Net/IIP/DistributedConnection.js":29,"../../Security/Integrity/SHA256.js":74,"../IResource.js":55,"../Warehouse.js":67,"./ArgumentTemplate.js":58,"./EventTemplate.js":59,"./FunctionTemplate.js":60,"./PropertyTemplate.js":63,"./TemplateDataType.js":64,"./TemplateType.js":65}],67:[function(require,module,exports){ +},{"../../Data/Codec.js":14,"../../Data/DC.js":15,"../../Data/IEnum.js":21,"../../Data/IRecord.js":22,"../../Data/RepresentationType.js":31,"../../Net/IIP/DistributedConnection.js":42,"../../Net/IIP/DistributedResource.js":44,"../../Security/Integrity/SHA256.js":91,"../IResource.js":70,"../Warehouse.js":84,"./ArgumentTemplate.js":74,"./ConstantTemplate.js":75,"./EventTemplate.js":76,"./FunctionTemplate.js":77,"./PropertyTemplate.js":80,"./TemplateType.js":82}],84:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -10426,12 +13191,38 @@ var _TemplateType = _interopRequireDefault(require("./Template/TemplateType.js") var _DistributedResource = _interopRequireDefault(require("../Net/IIP/DistributedResource.js")); +var _TypedList = _interopRequireDefault(require("../Data/TypedList.js")); + +var _ExtendedTypes = require("../Data/ExtendedTypes.js"); + +var _Record = _interopRequireDefault(require("../Data/Record.js")); + +var _TypedMap = _interopRequireDefault(require("../Data/TypedMap.js")); + +var _RepresentationType = require("../Data/RepresentationType.js"); + +var _FactoryEntry = _interopRequireDefault(require("./FactoryEntry.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 _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 _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 _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 _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"); } } @@ -10454,6 +13245,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } +'./FactoryEntry.js'; + var WH = /*#__PURE__*/function (_IEventHandler) { _inherits(WH, _IEventHandler); @@ -10478,7 +13271,10 @@ var WH = /*#__PURE__*/function (_IEventHandler) { _this.templates.add(_TemplateType["default"].Wrapper, new _KeyList["default"]()); + _this.templates.add(_TemplateType["default"].Enum, new _KeyList["default"]()); + _this.protocols = new _KeyList["default"](); + _this.typesFactory = _this._getBuiltInTypes(); _this._register("connected"); @@ -10876,6 +13672,74 @@ var WH = /*#__PURE__*/function (_IEventHandler) { // console.log(`Resource failed at SystemInitialized ${r.Instance.Name} [${r.Instance.Template.ClassName}]`); // } + return rt; + } + /** + * @param {Function} instanceCreator - creator + * @param {RepresentationType} representationType - type + */ + + }, { + key: "_getTypeEntries", + value: function _getTypeEntries(type, representationType) { + var listType = _TypedList["default"].of(type); + + var entry = new _FactoryEntry["default"](type, representationType); + var nullableEntry = new _FactoryEntry["default"](entry.nullableType, representationType.toNullable()); + var listEntry = new _FactoryEntry["default"](listType, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedList, false, null, [representationType])); + var nullableList = new _FactoryEntry["default"](listEntry.nullableType, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedList, true, null, [representationType])); + + var nullableItemListType = _TypedList["default"].of(entry.nullableType); + + var listNullableItemEntry = new _FactoryEntry["default"](nullableItemListType, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedList, false, null, [representationType.toNullable()])); + var nullableListNullableItemEntry = new _FactoryEntry["default"](nullableItemListType, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedList, true, null, [representationType.toNullable()])); + return [entry, nullableEntry, listEntry, nullableList, listNullableItemEntry, nullableListNullableItemEntry]; + } + /** + * @param {Function} instanceCreator - creator + * @param {RepresentationType} representationType - type + */ + + }, { + key: "defineType", + value: function defineType(type, representationType) { + var entries = this._getTypeEntries(type, representationType); + + var _iterator = _createForOfIteratorHelper(entries), + _step; + + try { + for (_iterator.s(); !(_step = _iterator.n()).done;) { + var e = _step.value; + this.typesFactory[e.type] = e; + } //.push(e); + + } catch (err) { + _iterator.e(err); + } finally { + _iterator.f(); + } + } + }, { + key: "_getBuiltInTypes", + value: function _getBuiltInTypes() { + var entries = [].concat(_toConsumableArray(this._getTypeEntries(_ExtendedTypes.Int8, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int8, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.UInt8, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.UInt8, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.Int16, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int16, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.UInt16, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.UInt16, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.Int32, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int32, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.UInt32, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.UInt32, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.Int64, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int64, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.UInt64, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.UInt64, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.Float32, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Float32, false))), _toConsumableArray(this._getTypeEntries(_ExtendedTypes.Float64, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Float64, false))), _toConsumableArray(this._getTypeEntries(String, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int8, String))), _toConsumableArray(this._getTypeEntries(Date, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int8, Date))), _toConsumableArray(this._getTypeEntries(_Record["default"], new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Record, false))), _toConsumableArray(this._getTypeEntries(_IResource["default"], new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Resource, false))), _toConsumableArray(this._getTypeEntries(Array, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.List, false))), _toConsumableArray(this._getTypeEntries(Map, new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Map, false))), _toConsumableArray(this._getTypeEntries(_TypedMap["default"].of(String, Object), new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedMap, false, null, [new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.String, false), _RepresentationType.RepresentationType.Dynamic]))), _toConsumableArray(this._getTypeEntries(_TypedMap["default"].of(_ExtendedTypes.UInt8, Object), new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedMap, false, null, [new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.UInt8, false), _RepresentationType.RepresentationType.Dynamic]))), _toConsumableArray(this._getTypeEntries(_TypedMap["default"].of(_ExtendedTypes.Int32, Object), new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.TypedMap, false, null, [new _RepresentationType.RepresentationType(_RepresentationType.RepresentationTypeIdentifier.Int32, false), _RepresentationType.RepresentationType.Dynamic])))); + var rt = {}; + + var _iterator2 = _createForOfIteratorHelper(entries), + _step2; + + try { + for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { + var entry = _step2.value; + rt[entry.type] = entry; + } + } catch (err) { + _iterator2.e(err); + } finally { + _iterator2.f(); + } + return rt; } }]); @@ -10897,7 +13761,7 @@ Warehouse.protocols.add("db", function (name, attributes) { var _default = Warehouse; exports["default"] = _default; -},{"../Core/AsyncBag.js":1,"../Core/AsyncReply.js":4,"../Core/IEventHandler.js":8,"../Data/AutoList.js":10,"../Data/IRecord.js":17,"../Data/KeyList.js":18,"../Net/IIP/DistributedConnection.js":29,"../Net/IIP/DistributedResource.js":31,"../Proxy/ResourceProxy.js":53,"../Resource/Instance.js":57,"../Resource/Template/TypeTemplate.js":66,"../Stores/IndexedDBStore.js":79,"../Stores/MemoryStore.js":80,"./IResource.js":55,"./IStore.js":56,"./Template/TemplateType.js":65}],68:[function(require,module,exports){ +},{"../Core/AsyncBag.js":2,"../Core/AsyncReply.js":5,"../Core/IEventHandler.js":9,"../Data/AutoList.js":11,"../Data/ExtendedTypes.js":19,"../Data/IRecord.js":22,"../Data/KeyList.js":23,"../Data/Record.js":28,"../Data/RepresentationType.js":31,"../Data/TypedList.js":40,"../Data/TypedMap.js":41,"../Net/IIP/DistributedConnection.js":42,"../Net/IIP/DistributedResource.js":44,"../Proxy/ResourceProxy.js":66,"../Resource/Instance.js":72,"../Resource/Template/TypeTemplate.js":83,"../Stores/IndexedDBStore.js":96,"../Stores/MemoryStore.js":97,"./FactoryEntry.js":69,"./IResource.js":70,"./IStore.js":71,"./Template/TemplateType.js":82}],85:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -10960,7 +13824,7 @@ var Authentication = /*#__PURE__*/function () { exports["default"] = Authentication; -},{}],69:[function(require,module,exports){ +},{}],86:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10975,7 +13839,7 @@ var _default = { }; exports["default"] = _default; -},{}],70:[function(require,module,exports){ +},{}],87:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -10991,7 +13855,7 @@ var _default = { }; exports["default"] = _default; -},{}],71:[function(require,module,exports){ +},{}],88:[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); } @@ -11039,7 +13903,7 @@ var ClientAuthentication = /*#__PURE__*/function (_Authentication) { exports["default"] = ClientAuthentication; -},{"./Authentication.js":68,"./AuthenticationType.js":70}],72:[function(require,module,exports){ +},{"./Authentication.js":85,"./AuthenticationType.js":87}],89:[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); } @@ -11087,7 +13951,7 @@ var HostAuthentication = /*#__PURE__*/function (_Authentication) { exports["default"] = HostAuthentication; -},{"./Authentication.js":68,"./AuthenticationType.js":70}],73:[function(require,module,exports){ +},{"./Authentication.js":85,"./AuthenticationType.js":87}],90:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -11134,7 +13998,7 @@ var Session = function Session(localAuthentication, remoteAuthentication) { exports["default"] = Session; -},{}],74:[function(require,module,exports){ +},{}],91:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { @@ -11142,7 +14006,7 @@ Object.defineProperty(exports, "__esModule", { }); exports["default"] = void 0; -var _DataConverter = require("../../Data/DataConverter.js"); +var _DC = require("../../Data/DC.js"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -11187,7 +14051,7 @@ var SHA256 = /*#__PURE__*/function () { var paddingLength = (K + 1) / 8; var paddingBytes = new Uint8Array(paddingLength); paddingBytes[0] = 0x80; - var data = new _DataConverter.DC((0, _DataConverter.BL)().addUint8Array(msg).addUint8Array(paddingBytes).addUint64(L).toArray()); // append L as a 64-bit big-endian integer, making the total post-processed length a multiple of 512 bits + var data = (0, _DC.BL)().addUint8Array(msg).addUint8Array(paddingBytes).addUint64(L, _DC.Endian.Big).toDC(); // append L as a 64-bit big-endian integer, making the total post-processed length a multiple of 512 bits // Process the message in successive 512-bit chunks: // break message into 512-bit chunks // for each chunk @@ -11199,7 +14063,7 @@ var SHA256 = /*#__PURE__*/function () { var w = new Uint32Array(64); for (var i = 0; i < 16; i++) { - w[i] = data.getInt32(chunk + i * 4); + w[i] = data.getUint32(chunk + i * 4, _DC.Endian.Big); } //for(var i = 16; i < 64; i++) // w[i] = 0; // Extend the first 16 words into the remaining 48 words w[16..63] of the message schedule array: @@ -11209,10 +14073,10 @@ var SHA256 = /*#__PURE__*/function () { // w[i] := w[i-16] + s0 + w[i-7] + s1 - for (var i = 16; i < 64; i++) { - var s0 = SHA256.RROT(w[i - 15], 7) ^ SHA256.RROT(w[i - 15], 18) ^ w[i - 15] >>> 3; - var s1 = SHA256.RROT(w[i - 2], 17) ^ SHA256.RROT(w[i - 2], 19) ^ w[i - 2] >>> 10; - w[i] = w[i - 16] + s0 + w[i - 7] + s1; + for (var _i = 16; _i < 64; _i++) { + var s0 = SHA256.RROT(w[_i - 15], 7) ^ SHA256.RROT(w[_i - 15], 18) ^ w[_i - 15] >>> 3; + var s1 = SHA256.RROT(w[_i - 2], 17) ^ SHA256.RROT(w[_i - 2], 19) ^ w[_i - 2] >>> 10; + w[_i] = w[_i - 16] + s0 + w[_i - 7] + s1; } // Initialize working variables to current hash value: @@ -11225,10 +14089,10 @@ var SHA256 = /*#__PURE__*/function () { var g = hash[6]; var h = hash[7]; // Compression function main loop: - for (var i = 0; i < 64; i++) { + for (var _i2 = 0; _i2 < 64; _i2++) { var S1 = SHA256.RROT(e, 6) ^ SHA256.RROT(e, 11) ^ SHA256.RROT(e, 25); var ch = e & f ^ ~e & g; - var temp1 = h + S1 + ch + k[i] + w[i]; + var temp1 = h + S1 + ch + k[_i2] + w[_i2]; var S0 = SHA256.RROT(a, 2) ^ SHA256.RROT(a, 13) ^ SHA256.RROT(a, 22); var maj = a & b ^ a & c ^ b & c; var temp2 = S0 + maj; @@ -11255,10 +14119,10 @@ var SHA256 = /*#__PURE__*/function () { //digest := hash := h0 append h1 append h2 append h3 append h4 append h5 append h6 append h7 - var results = (0, _DataConverter.BL)(); + var results = (0, _DC.BL)(); - for (var i = 0; i < 8; i++) { - results.addUint32(hash[i]); + for (var _i3 = 0; _i3 < 8; _i3++) { + results.addUint32(hash[_i3], _DC.Endian.Big); } return results.toDC(); @@ -11270,7 +14134,7 @@ var SHA256 = /*#__PURE__*/function () { exports["default"] = SHA256; -},{"../../Data/DataConverter.js":14}],75:[function(require,module,exports){ +},{"../../Data/DC.js":15}],92:[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); } @@ -11353,7 +14217,7 @@ var IMembership = /*#__PURE__*/function (_IResource) { exports["default"] = IMembership; -},{"../../Core/AsyncReply.js":4,"../../Resource/IResource.js":55}],76:[function(require,module,exports){ +},{"../../Core/AsyncReply.js":5,"../../Resource/IResource.js":70}],93:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -11405,7 +14269,7 @@ var _default = // ActionType = }; exports["default"] = _default; -},{}],77:[function(require,module,exports){ +},{}],94:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -11473,7 +14337,7 @@ var IPermissionsManager = /*#__PURE__*/function () { exports["default"] = IPermissionsManager; -},{}],78:[function(require,module,exports){ +},{}],95:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -11513,7 +14377,7 @@ var _default = //Ruling = }; exports["default"] = _default; -},{}],79:[function(require,module,exports){ +},{}],96:[function(require,module,exports){ /* * Copyright (c) 2017-2021 Ahmed Kh. Zamil * @@ -11924,7 +14788,7 @@ var IndexedDBStore = /*#__PURE__*/function (_IStore) { exports["default"] = IndexedDBStore; -},{"../Core/AsyncBag.js":1,"../Core/AsyncReply.js":4,"../Core/ErrorType.js":5,"../Core/ExceptionCode.js":6,"../Data/Codec.js":13,"../Data/DataType.js":15,"../Resource/IResource.js":55,"../Resource/IStore.js":56,"../Resource/Warehouse.js":67}],80:[function(require,module,exports){ +},{"../Core/AsyncBag.js":2,"../Core/AsyncReply.js":5,"../Core/ErrorType.js":6,"../Core/ExceptionCode.js":7,"../Data/Codec.js":14,"../Data/DataType.js":18,"../Resource/IResource.js":70,"../Resource/IStore.js":71,"../Resource/Warehouse.js":84}],97:[function(require,module,exports){ /* * Copyright (c) 2017 Ahmed Kh. Zamil * @@ -12039,7 +14903,7 @@ var MemoryStore = /*#__PURE__*/function (_IStore) { exports["default"] = MemoryStore; -},{"../Core/AsyncReply.js":4,"../Resource/IStore.js":56}],81:[function(require,module,exports){ +},{"../Core/AsyncReply.js":5,"../Resource/IStore.js":71}],98:[function(require,module,exports){ (function (global){(function (){ "use strict"; @@ -12100,7 +14964,7 @@ var _BinaryList = _interopRequireDefault(require("./Data/BinaryList.js")); var _Codec = _interopRequireDefault(require("./Data/Codec.js")); -var _DataConverter = _interopRequireDefault(require("./Data/DataConverter.js")); +var _DC = _interopRequireDefault(require("./Data/DC.js")); var _DataType = _interopRequireDefault(require("./Data/DataType.js")); @@ -12224,7 +15088,7 @@ var namespace = { AutoMap: _AutoMap["default"], BinaryList: _BinaryList["default"], Codec: _Codec["default"], - DataConverter: _DataConverter["default"], + DC: _DC["default"], DataType: _DataType["default"], Guid: _Guid["default"], IRecord: _IRecord["default"], @@ -12345,4 +15209,4 @@ var _default = _Warehouse["default"]; exports["default"] = _default; }).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"./Core/AsyncException.js":2,"./Core/AsyncQueue.js":3,"./Core/AsyncReply.js":4,"./Core/ErrorType.js":5,"./Core/ExceptionCode.js":6,"./Core/IDestructible.js":7,"./Core/IEventHandler.js":8,"./Core/ProgressType.js":9,"./Data/AutoList.js":10,"./Data/AutoMap.js":11,"./Data/BinaryList.js":12,"./Data/Codec.js":13,"./Data/DataConverter.js":14,"./Data/DataType.js":15,"./Data/Guid.js":16,"./Data/IRecord.js":17,"./Data/KeyList.js":18,"./Data/NotModified.js":19,"./Data/PropertyValue.js":20,"./Data/Record.js":21,"./Data/RecordComparisonResult.js":22,"./Data/ResourceArray.js":23,"./Data/ResourceArrayType.js":24,"./Data/ResourceComparisonResult.js":25,"./Data/Structure.js":26,"./Data/StructureArray.js":27,"./Data/StructureComparisonResult.js":28,"./Net/IIP/DistributedConnection.js":29,"./Net/IIP/DistributedPropertyContext.js":30,"./Net/IIP/DistributedResource.js":31,"./Net/IIP/DistributedResourceQueueItem.js":32,"./Net/IIP/DistributedResourceQueueItemType.js":33,"./Net/IIP/DistributedServer.js":34,"./Net/IIP/EntryPoint.js":35,"./Net/INetworkReceiver.js":36,"./Net/NetworkBuffer.js":37,"./Net/NetworkConnections.js":38,"./Net/NetworkServer.js":39,"./Net/NetworkSession.js":40,"./Net/Packets/IIPAuthPacket.js":41,"./Net/Packets/IIPAuthPacketAction.js":42,"./Net/Packets/IIPAuthPacketCommand.js":43,"./Net/Packets/IIPPacket.js":44,"./Net/Packets/IIPPacketAction.js":45,"./Net/Packets/IIPPacketCommand.js":46,"./Net/Packets/IIPPacketEvent.js":47,"./Net/Packets/IIPPacketReport.js":48,"./Net/SendList.js":49,"./Net/Sockets/ISocket.js":50,"./Net/Sockets/SocketState.js":51,"./Net/Sockets/WSocket.js":52,"./Proxy/ResourceProxy.js":53,"./Resource/CustomResourceEvent.js":54,"./Resource/IResource.js":55,"./Resource/IStore.js":56,"./Resource/Instance.js":57,"./Resource/Template/ArgumentTemplate.js":58,"./Resource/Template/EventTemplate.js":59,"./Resource/Template/FunctionTemplate.js":60,"./Resource/Template/MemberTemplate.js":61,"./Resource/Template/MemberType.js":62,"./Resource/Template/PropertyTemplate.js":63,"./Resource/Template/TemplateDataType.js":64,"./Resource/Template/TemplateType.js":65,"./Resource/Template/TypeTemplate.js":66,"./Resource/Warehouse.js":67,"./Security/Authority/Authentication.js":68,"./Security/Authority/AuthenticationMethod.js":69,"./Security/Authority/AuthenticationType.js":70,"./Security/Authority/ClientAuthentication.js":71,"./Security/Authority/HostAuthentication.js":72,"./Security/Authority/Session.js":73,"./Security/Integrity/SHA256.js":74,"./Security/Membership/IMembership.js":75,"./Security/Permissions/ActionType.js":76,"./Security/Permissions/IPermissionsManager.js":77,"./Security/Permissions/Ruling.js":78,"./Stores/IndexedDBStore.js":79,"./Stores/MemoryStore.js":80}]},{},[81]); +},{"./Core/AsyncException.js":3,"./Core/AsyncQueue.js":4,"./Core/AsyncReply.js":5,"./Core/ErrorType.js":6,"./Core/ExceptionCode.js":7,"./Core/IDestructible.js":8,"./Core/IEventHandler.js":9,"./Core/ProgressType.js":10,"./Data/AutoList.js":11,"./Data/AutoMap.js":12,"./Data/BinaryList.js":13,"./Data/Codec.js":14,"./Data/DC.js":15,"./Data/DataType.js":18,"./Data/Guid.js":20,"./Data/IRecord.js":22,"./Data/KeyList.js":23,"./Data/NotModified.js":24,"./Data/PropertyValue.js":26,"./Data/Record.js":28,"./Data/RecordComparisonResult.js":30,"./Data/ResourceArray.js":32,"./Data/ResourceArrayType.js":33,"./Data/ResourceComparisonResult.js":34,"./Data/Structure.js":35,"./Data/StructureArray.js":36,"./Data/StructureComparisonResult.js":37,"./Net/IIP/DistributedConnection.js":42,"./Net/IIP/DistributedPropertyContext.js":43,"./Net/IIP/DistributedResource.js":44,"./Net/IIP/DistributedResourceQueueItem.js":45,"./Net/IIP/DistributedResourceQueueItemType.js":46,"./Net/IIP/DistributedServer.js":47,"./Net/IIP/EntryPoint.js":48,"./Net/INetworkReceiver.js":49,"./Net/NetworkBuffer.js":50,"./Net/NetworkConnections.js":51,"./Net/NetworkServer.js":52,"./Net/NetworkSession.js":53,"./Net/Packets/IIPAuthPacket.js":54,"./Net/Packets/IIPAuthPacketAction.js":55,"./Net/Packets/IIPAuthPacketCommand.js":56,"./Net/Packets/IIPPacket.js":57,"./Net/Packets/IIPPacketAction.js":58,"./Net/Packets/IIPPacketCommand.js":59,"./Net/Packets/IIPPacketEvent.js":60,"./Net/Packets/IIPPacketReport.js":61,"./Net/SendList.js":62,"./Net/Sockets/ISocket.js":63,"./Net/Sockets/SocketState.js":64,"./Net/Sockets/WSocket.js":65,"./Proxy/ResourceProxy.js":66,"./Resource/CustomResourceEvent.js":67,"./Resource/IResource.js":70,"./Resource/IStore.js":71,"./Resource/Instance.js":72,"./Resource/Template/ArgumentTemplate.js":74,"./Resource/Template/EventTemplate.js":76,"./Resource/Template/FunctionTemplate.js":77,"./Resource/Template/MemberTemplate.js":78,"./Resource/Template/MemberType.js":79,"./Resource/Template/PropertyTemplate.js":80,"./Resource/Template/TemplateDataType.js":81,"./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/Membership/IMembership.js":92,"./Security/Permissions/ActionType.js":93,"./Security/Permissions/IPermissionsManager.js":94,"./Security/Permissions/Ruling.js":95,"./Stores/IndexedDBStore.js":96,"./Stores/MemoryStore.js":97}]},{},[98]); diff --git a/build/esiur.js.tmp-browserify-48259691679320537716 b/build/esiur.js.tmp-browserify-48259691679320537716 new file mode 100644 index 0000000..f1a4d01 --- /dev/null +++ b/build/esiur.js.tmp-browserify-48259691679320537716 @@ -0,0 +1,9639 @@ +(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 -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); +// } +// /// +// /// Parse an array of bytes into array of resources +// /// +// /// Array of bytes. +// /// Number of bytes to parse. +// /// Zero-indexed offset. +// /// DistributedConnection is required to fetch resources. +// /// Array of resources. +// 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; +// } +// /// +// /// Compose an array of property values. +// /// +// /// PropertyValue array. +// /// DistributedConnection is required to check locality. +// /// If True, prepend the length as UInt32 at the beginning of the output. +// /// Array of bytes in the network byte order. +// 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(); +// } +// /// +// /// Compose a property value. +// /// +// /// Property value +// /// DistributedConnection is required to check locality. +// /// Array of bytes in the network byte order. +// static composePropertyValue(propertyValue, connection) +// { +// // age, date, value +// return BL().addUint64(propertyValue.age) +// .addDateTime(propertyValue.date) +// .addUint8Array(Codec.compose(propertyValue.value, connection)) +// .toArray(); +// } +// /// +// /// Parse property value. +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// DistributedConnection is required to fetch resources. +// /// Output content size. +// /// PropertyValue. +// 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; +// } +// /// +// /// Parse resource history +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// Number of bytes to parse. +// /// Resource +// /// Starting age. +// /// Ending age. +// /// DistributedConnection is required to fetch resources. +// /// +// 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; +// } +// /// +// /// Compose resource history +// /// +// /// History +// /// DistributedConnection is required to fetch resources. +// /// +// 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(); +// } +// /// +// /// Parse an array of ProperyValue. +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// Number of bytes to parse. +// /// DistributedConnection is required to fetch resources. +// /// +// 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(); +// } +// /// +// /// Compare two records +// /// +// /// Initial record to compare with +// /// Next record to compare with the initial +// /// DistributedConnection is required in case a structure holds items at the other end +// 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; +// } +// } +// /// +// /// Parse an array of structures +// /// +// /// Bytes array +// /// Zero-indexed offset +// /// Number of bytes to parse +// /// DistributedConnection is required in case a structure in the array holds items at the other end +// /// Array of structures +// 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); + /// + /// Parse a value + /// + /// Bytes array + /// Zero-indexed offset. + /// Output the number of bytes parsed + /// DistributedConnection is required in case a structure in the array holds items at the other end. + /// DataType, in case the data is not prepended with DataType + /// Value + 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]; + } /// + /// Compose a variable + /// + /// Value to compose. + /// DistributedConnection is required to check locality. + /// If True, prepend the DataType at the beginning of the output. + /// Array of bytes in the network byte order. + + }, { + 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 a; + // //a.Invoke() + // } + // } + // } + // if (valueOrSource is IUserType) + // valueOrSource = (valueOrSource as IUserType).Get(); + //if (valueOrSource is Func) + // valueOrSource = (valueOrSource as Func)(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)); + } /// + /// Check if a resource is local to a given connection. + /// + /// Resource to check. + /// DistributedConnection to check if the resource is local to it. + /// True, if the resource owner is the given connection, otherwise False. + + }, { + 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 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>(); + // 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; + // 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(); + //var list = (IEnumerable)value;// ((List)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 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}] \ No newline at end of file diff --git a/demo/chat/chat.js b/demo/chat/chat.js index 9983d5f..7f3bc63 100644 --- a/demo/chat/chat.js +++ b/demo/chat/chat.js @@ -6,10 +6,10 @@ import DistributedServer from "../../src/Net/IIP/DistributedServer.js"; import IMembership from "../../src/Security/Membership/IMembership.js"; import WSocket from "../../src/Net/Sockets/WSocket.js"; import MemoryStore from "../../src/Stores/MemoryStore.js"; -import DC from "../../src/Data/DataConverter.js"; +import DC from "../../src/Data/DC.js"; import IResource from "../../src/Resource/IResource.js"; -import Structure from "../../src/Data/Structure.js"; -import DataType from "../../src/Data/DataType.js"; +import TransmissionType, { TransmissionTypeIdentifier } from "../../src/Data/TransmissionType.js"; +import TypedMap from "../../src/Data/TypedMap.js"; const require = createRequire(import.meta.url); @@ -36,15 +36,15 @@ class MyChat extends IResource { static get template() { return { namespace: "Chat", - properties: [["title", DataType.String], ["messages", DataType.StructureArray], ["users", DataType.StringArray]], - events: [["message", DataType.Structure], ["voice", 0, {listenable: true }], ["login"], ["logout"]], - functions: [[ "send", {msg: DataType.String} ]] + properties: [["title", String], ["messages", Array], ["users", Array]], + events: [["message", Map], ["voice", 0, {listenable: true }], ["login"], ["logout"]], + functions: [[ "send", [["msg", String, {optional: true}] ]]] }; } constructor() { super(); - this.messages = [new Structure({usr: "Admin", msg: "Welcome to Esiur", date: new Date()})]; + this.messages = [new TypedMap({usr: "Admin", msg: "Welcome to Esiur", date: new Date()})]; this.title = "Chat Room"; } @@ -54,7 +54,7 @@ class MyChat extends IResource { send(msg, sender) { - let s = new Structure({ msg, usr: sender.session.remoteAuthentication.username, date: new Date()}); + let s = new TypedMap({ msg, usr: sender.session.remoteAuthentication.username, date: new Date()}); this.messages.push(s); this._emit("message", s); } @@ -64,6 +64,10 @@ class MyChat extends IResource { } } + +let x = TransmissionType.compose(TransmissionTypeIdentifier.List, new DC([1,2,3,4,5,6])); +let tt = TransmissionType.parse(x, 0, x.length); + let sys = await Warehouse.new(MemoryStore, "sys"); let ms = await Warehouse.new(MyMembership, "ms"); let chat = await Warehouse.new(MyChat, "chat", sys); diff --git a/demo/chat/index.html b/demo/chat/index.html index ca6db35..e63a415 100644 --- a/demo/chat/index.html +++ b/demo/chat/index.html @@ -34,7 +34,7 @@ { let el = document.createElement("div"); let list = document.getElementById("list"); - el.innerHTML = `${message.usr}${message.msg}${message.date.toLocaleTimeString()}`; + el.innerHTML = `${message.get("usr")}${message.get("msg")}${message.get("date").toLocaleTimeString()}`; list.append(el); list.scrollTop = list.scrollHeight; } diff --git a/demo/dotnet/service.js b/demo/dotnet/service.js new file mode 100644 index 0000000..5e2d061 --- /dev/null +++ b/demo/dotnet/service.js @@ -0,0 +1,43 @@ +import Warehouse from "../../src/Resource/Warehouse.js"; + +import { createRequire } from 'module' + +const require = createRequire(import.meta.url); + +const WebSocket = require('ws'); + +var remote = await Warehouse.get('iip://localhost/mem/service'); + +// remote?.instance?.template.properties.forEach((element) => { +// console.log(element.name); +// console.log(remote[element.name]); +// }); + +await remote?.Void(); +await remote?.Connection('ss', 33); +await remote?.ConnectionOptional('Test 2', 88); +var rt = await remote?.Optional('Optional', 311); +console.log(rt); + +var t2 = await remote?.GetTuple2(1, 'A'); +console.log(t2); +var t3 = await remote?.GetTuple3(1, 'A', 1.3); +console.log(t3); +var t4 = await remote?.GetTuple4(1, 'A', 1.3, true); +console.log(t4); + +remote?.on('StringEvent', (args) => console.log(`StringEvent ${args}`)); + +remote?.on('ArrayEvent', (args) => console.log(`ArrayEvent ${args}`)); + +await remote?.InvokeEvents('Hello'); + +// var mcr = MyChildRecord() +// ..ChildName = "I'm Child" +// ..Name = 'Dad' +// ..Score = 332 +// ..Id = 44; + +// var rec = await remote?.SendRecord(mcr); + +// print(rec); diff --git a/demo/mongo/mongo.js b/demo/mongo/mongo.js index a524afa..052c502 100644 --- a/demo/mongo/mongo.js +++ b/demo/mongo/mongo.js @@ -6,7 +6,7 @@ import DistributedServer from "../../src/Net/IIP/DistributedServer.js"; import IMembership from "../../src/Security/Membership/IMembership.js"; import WSocket from "../../src/Net/Sockets/WSocket.js"; import MemoryStore from "../../src/Stores/MemoryStore.js"; -import DC from "../../src/Data/DataConverter.js"; +import DC from "../../src/Data/DC.js"; import IResource from "../../src/Resource/IResource.js"; import Structure from "../../src/Data/Structure.js"; import MongoDBStore from "../../src/Stores/MongoDBStore.js"; diff --git a/package-lock.json b/package-lock.json index 092140a..465abe7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,5092 @@ { "name": "esiur", - "version": "1.7.1", - "lockfileVersion": 1, + "version": "2.0.0", + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "esiur", + "version": "2.0.0", + "license": "MIT", + "dependencies": { + "mongodb": "^3.6.9", + "ws": "^7.5.0" + }, + "devDependencies": { + "@babel/core": "^7.14.6", + "@babel/preset-env": "^7.14.5", + "babelify": "^10.0.0", + "browserify": "^17.0.0", + "eslint": "^7.31.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.14.5.tgz", + "integrity": "sha512-9pzDqyc6OLDaqe+zbACgFkb6fKMNG6CObKpnYXChRsvYGyEdc7CA2BaqeOM+vOtCS5ndmJicPJhKAwYRI6UfFw==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.14.5.tgz", + "integrity": "sha512-kixrYn4JwfAVPa0f2yfzc2AWti6WRRyO3XjWW5PJAvtE11qhSayrrcrEnee05KAtNaPC+EwehE8Qt1UedEVB8w==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.14.6.tgz", + "integrity": "sha512-gJnOEWSqTk96qG5BoIrl5bVtc23DCycmIePPYnamY9RboYdI4nFy5vAQMSl81O5K/W0sLDWfGysnOECC+KUUCA==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.14.5", + "@babel/generator": "^7.14.5", + "@babel/helper-compilation-targets": "^7.14.5", + "@babel/helper-module-transforms": "^7.14.5", + "@babel/helpers": "^7.14.6", + "@babel/parser": "^7.14.6", + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.14.5", + "@babel/types": "^7.14.5", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.1.2", + "semver": "^6.3.0", + "source-map": "^0.5.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@babel/core/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.14.5.tgz", + "integrity": "sha512-y3rlP+/G25OIX3mYKKIOlQRcqj7YgrvHxOLbVmyLJ9bPmi5ttvUmpydVjcFjZphOktWuA7ovbx91ECloWTfjIA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5", + "jsesc": "^2.5.1", + "source-map": "^0.5.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-annotate-as-pure": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.14.5.tgz", + "integrity": "sha512-EivH9EgBIb+G8ij1B2jAwSH36WnGvkQSEC6CkX/6v6ZFlw5fVOHvsgGF4uiEHO2GzMvunZb6tDLQEQSdrdocrA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-builder-binary-assignment-operator-visitor": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.14.5.tgz", + "integrity": "sha512-YTA/Twn0vBXDVGJuAX6PwW7x5zQei1luDDo2Pl6q1qZ7hVNl0RZrhHCQG/ArGpR29Vl7ETiB8eJyrvpuRp300w==", + "dev": true, + "dependencies": { + "@babel/helper-explode-assignable-expression": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.14.5.tgz", + "integrity": "sha512-v+QtZqXEiOnpO6EYvlImB6zCD2Lel06RzOPzmkz/D/XgQiUu3C/Jb1LOqSt/AIA34TYi/Q+KlT8vTQrgdxkbLw==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.14.5", + "@babel/helper-validator-option": "^7.14.5", + "browserslist": "^4.16.6", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-create-class-features-plugin": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.14.6.tgz", + "integrity": "sha512-Z6gsfGofTxH/+LQXqYEK45kxmcensbzmk/oi8DmaQytlQCgqNZt9XQF8iqlI/SeXWVjaMNxvYvzaYw+kh42mDg==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.14.5", + "@babel/helper-function-name": "^7.14.5", + "@babel/helper-member-expression-to-functions": "^7.14.5", + "@babel/helper-optimise-call-expression": "^7.14.5", + "@babel/helper-replace-supers": "^7.14.5", + "@babel/helper-split-export-declaration": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-create-regexp-features-plugin": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.14.5.tgz", + "integrity": "sha512-TLawwqpOErY2HhWbGJ2nZT5wSkR192QpN+nBg1THfBfftrlvOh+WbhrxXCH4q4xJ9Gl16BGPR/48JA+Ryiho/A==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.14.5", + "regexpu-core": "^4.7.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-define-polyfill-provider": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@babel/helper-define-polyfill-provider/-/helper-define-polyfill-provider-0.2.3.tgz", + "integrity": "sha512-RH3QDAfRMzj7+0Nqu5oqgO5q9mFtQEVvCRsi8qCEfzLR9p2BHfn5FzhSB2oj1fF7I2+DcTORkYaQ6aTR9Cofew==", + "dev": true, + "dependencies": { + "@babel/helper-compilation-targets": "^7.13.0", + "@babel/helper-module-imports": "^7.12.13", + "@babel/helper-plugin-utils": "^7.13.0", + "@babel/traverse": "^7.13.0", + "debug": "^4.1.1", + "lodash.debounce": "^4.0.8", + "resolve": "^1.14.2", + "semver": "^6.1.2" + }, + "peerDependencies": { + "@babel/core": "^7.4.0-0" + } + }, + "node_modules/@babel/helper-explode-assignable-expression": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.14.5.tgz", + "integrity": "sha512-Htb24gnGJdIGT4vnRKMdoXiOIlqOLmdiUYpAQ0mYfgVT/GDm8GOYhgi4GL+hMKrkiPRohO4ts34ELFsGAPQLDQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.14.5.tgz", + "integrity": "sha512-Gjna0AsXWfFvrAuX+VKcN/aNNWonizBj39yGwUzVDVTlMYJMK2Wp6xdpy72mfArFq5uK+NOuexfzZlzI1z9+AQ==", + "dev": true, + "dependencies": { + "@babel/helper-get-function-arity": "^7.14.5", + "@babel/template": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-get-function-arity": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.14.5.tgz", + "integrity": "sha512-I1Db4Shst5lewOM4V+ZKJzQ0JGGaZ6VY1jYvMghRjqs6DWgxLCIyFt30GlnKkfUeFLpJt2vzbMVEXVSXlIFYUg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.14.5.tgz", + "integrity": "sha512-R1PXiz31Uc0Vxy4OEOm07x0oSjKAdPPCh3tPivn/Eo8cvz6gveAeuyUUPB21Hoiif0uoPQSSdhIPS3352nvdyQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-member-expression-to-functions": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.14.5.tgz", + "integrity": "sha512-UxUeEYPrqH1Q/k0yRku1JE7dyfyehNwT6SVkMHvYvPDv4+uu627VXBckVj891BO8ruKBkiDoGnZf4qPDD8abDQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.14.5.tgz", + "integrity": "sha512-SwrNHu5QWS84XlHwGYPDtCxcA0hrSlL2yhWYLgeOc0w7ccOl2qv4s/nARI0aYZW+bSwAL5CukeXA47B/1NKcnQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.14.5.tgz", + "integrity": "sha512-iXpX4KW8LVODuAieD7MzhNjmM6dzYY5tfRqT+R9HDXWl0jPn/djKmA+G9s/2C2T9zggw5tK1QNqZ70USfedOwA==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.14.5", + "@babel/helper-replace-supers": "^7.14.5", + "@babel/helper-simple-access": "^7.14.5", + "@babel/helper-split-export-declaration": "^7.14.5", + "@babel/helper-validator-identifier": "^7.14.5", + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-optimise-call-expression": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.14.5.tgz", + "integrity": "sha512-IqiLIrODUOdnPU9/F8ib1Fx2ohlgDhxnIDU7OEVi+kAbEZcyiF7BLU8W6PfvPi9LzztjS7kcbzbmL7oG8kD6VA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.14.5.tgz", + "integrity": "sha512-/37qQCE3K0vvZKwoK4XU/irIJQdIfCJuhU5eKnNxpFDsOkgFaUAwbv+RYw6eYgsC0E4hS7r5KqGULUogqui0fQ==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-remap-async-to-generator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.14.5.tgz", + "integrity": "sha512-rLQKdQU+HYlxBwQIj8dk4/0ENOUEhA/Z0l4hN8BexpvmSMN9oA9EagjnhnDpNsRdWCfjwa4mn/HyBXO9yhQP6A==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.14.5", + "@babel/helper-wrap-function": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-replace-supers": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.14.5.tgz", + "integrity": "sha512-3i1Qe9/8x/hCHINujn+iuHy+mMRLoc77b2nI9TB0zjH1hvn9qGlXjWlggdwUcju36PkPCy/lpM7LLUdcTyH4Ow==", + "dev": true, + "dependencies": { + "@babel/helper-member-expression-to-functions": "^7.14.5", + "@babel/helper-optimise-call-expression": "^7.14.5", + "@babel/traverse": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.14.5.tgz", + "integrity": "sha512-nfBN9xvmCt6nrMZjfhkl7i0oTV3yxR4/FztsbOASyTvVcoYd0TRHh7eMLdlEcCqobydC0LAF3LtC92Iwxo0wyw==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-skip-transparent-expression-wrappers": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.14.5.tgz", + "integrity": "sha512-dmqZB7mrb94PZSAOYtr+ZN5qt5owZIAgqtoTuqiFbHFtxgEcmQlRJVI+bO++fciBunXtB6MK7HrzrfcAzIz2NQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.14.5.tgz", + "integrity": "sha512-hprxVPu6e5Kdp2puZUmvOGjaLv9TCe58E/Fl6hRq4YiVQxIcNvuq6uTM2r1mT/oPskuS9CgR+I94sqAYv0NGKA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.14.5.tgz", + "integrity": "sha512-5lsetuxCLilmVGyiLEfoHBRX8UCFD+1m2x3Rj97WrW3V7H3u4RWRXA4evMjImCsin2J2YT0QaVDGf+z8ondbAg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.14.5.tgz", + "integrity": "sha512-OX8D5eeX4XwcroVW45NMvoYaIuFI+GQpA2a8Gi+X/U/cDUIRsV37qQfF905F0htTRCREQIB4KqPeaveRJUl3Ow==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-wrap-function": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.14.5.tgz", + "integrity": "sha512-YEdjTCq+LNuNS1WfxsDCNpgXkJaIyqco6DAelTUjT4f2KIWC1nBcaCaSdHTBqQVLnTBexBcVcFhLSU1KnYuePQ==", + "dev": true, + "dependencies": { + "@babel/helper-function-name": "^7.14.5", + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.14.6.tgz", + "integrity": "sha512-yesp1ENQBiLI+iYHSJdoZKUtRpfTlL1grDIX9NRlAVppljLw/4tTyYupIB7uIYmC3stW/imAv8EqaKaS/ibmeA==", + "dev": true, + "dependencies": { + "@babel/template": "^7.14.5", + "@babel/traverse": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.14.5.tgz", + "integrity": "sha512-qf9u2WFWVV0MppaL877j2dBtQIDgmidgjGk5VIMw3OadXvYaXn66U1BFlH2t4+t3i+8PhedppRv+i40ABzd+gg==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.14.5", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.14.6.tgz", + "integrity": "sha512-oG0ej7efjEXxb4UgE+klVx+3j4MVo+A2vCzm7OUN4CLo6WhQ+vSOD2yJ8m7B+DghObxtLxt3EfgMWpq+AsWehQ==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining/-/plugin-bugfix-v8-spread-parameters-in-optional-chaining-7.14.5.tgz", + "integrity": "sha512-ZoJS2XCKPBfTmL122iP6NM9dOg+d4lc9fFk3zxc8iDjvt8Pk4+TlsHSKhIPf6X+L5ORCdBzqMZDjL/WHj7WknQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-skip-transparent-expression-wrappers": "^7.14.5", + "@babel/plugin-proposal-optional-chaining": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.13.0" + } + }, + "node_modules/@babel/plugin-proposal-async-generator-functions": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.14.5.tgz", + "integrity": "sha512-tbD/CG3l43FIXxmu4a7RBe4zH7MLJ+S/lFowPFO7HetS2hyOZ/0nnnznegDuzFzfkyQYTxqdTH/hKmuBngaDAA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-remap-async-to-generator": "^7.14.5", + "@babel/plugin-syntax-async-generators": "^7.8.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-class-properties": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.14.5.tgz", + "integrity": "sha512-q/PLpv5Ko4dVc1LYMpCY7RVAAO4uk55qPwrIuJ5QJ8c6cVuAmhu7I/49JOppXL6gXf7ZHzpRVEUZdYoPLM04Gg==", + "dev": true, + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-class-static-block": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-static-block/-/plugin-proposal-class-static-block-7.14.5.tgz", + "integrity": "sha512-KBAH5ksEnYHCegqseI5N9skTdxgJdmDoAOc0uXa+4QMYKeZD0w5IARh4FMlTNtaHhbB8v+KzMdTgxMMzsIy6Yg==", + "dev": true, + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-class-static-block": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.12.0" + } + }, + "node_modules/@babel/plugin-proposal-dynamic-import": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-dynamic-import/-/plugin-proposal-dynamic-import-7.14.5.tgz", + "integrity": "sha512-ExjiNYc3HDN5PXJx+bwC50GIx/KKanX2HiggnIUAYedbARdImiCU4RhhHfdf0Kd7JNXGpsBBBCOm+bBVy3Gb0g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-dynamic-import": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-export-namespace-from": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-export-namespace-from/-/plugin-proposal-export-namespace-from-7.14.5.tgz", + "integrity": "sha512-g5POA32bXPMmSBu5Dx/iZGLGnKmKPc5AiY7qfZgurzrCYgIztDlHFbznSNCoQuv57YQLnQfaDi7dxCtLDIdXdA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-json-strings": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.14.5.tgz", + "integrity": "sha512-NSq2fczJYKVRIsUJyNxrVUMhB27zb7N7pOFGQOhBKJrChbGcgEAqyZrmZswkPk18VMurEeJAaICbfm57vUeTbQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-json-strings": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-logical-assignment-operators": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-logical-assignment-operators/-/plugin-proposal-logical-assignment-operators-7.14.5.tgz", + "integrity": "sha512-YGn2AvZAo9TwyhlLvCCWxD90Xq8xJ4aSgaX3G5D/8DW94L8aaT+dS5cSP+Z06+rCJERGSr9GxMBZ601xoc2taw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-nullish-coalescing-operator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.14.5.tgz", + "integrity": "sha512-gun/SOnMqjSb98Nkaq2rTKMwervfdAoz6NphdY0vTfuzMfryj+tDGb2n6UkDKwez+Y8PZDhE3D143v6Gepp4Hg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-numeric-separator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.14.5.tgz", + "integrity": "sha512-yiclALKe0vyZRZE0pS6RXgjUOt87GWv6FYa5zqj15PvhOGFO69R5DusPlgK/1K5dVnCtegTiWu9UaBSrLLJJBg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-numeric-separator": "^7.10.4" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-object-rest-spread": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.14.5.tgz", + "integrity": "sha512-VzMyY6PWNPPT3pxc5hi9LloKNr4SSrVCg7Yr6aZpW4Ym07r7KqSU/QXYwjXLVxqwSv0t/XSXkFoKBPUkZ8vb2A==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.14.5", + "@babel/helper-compilation-targets": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-transform-parameters": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-optional-catch-binding": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.14.5.tgz", + "integrity": "sha512-3Oyiixm0ur7bzO5ybNcZFlmVsygSIQgdOa7cTfOYCMY+wEPAYhZAJxi3mixKFCTCKUhQXuCTtQ1MzrpL3WT8ZQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-optional-chaining": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.14.5.tgz", + "integrity": "sha512-ycz+VOzo2UbWNI1rQXxIuMOzrDdHGrI23fRiz/Si2R4kv2XZQ1BK8ccdHwehMKBlcH/joGW/tzrUmo67gbJHlQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-skip-transparent-expression-wrappers": "^7.14.5", + "@babel/plugin-syntax-optional-chaining": "^7.8.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-private-methods": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-methods/-/plugin-proposal-private-methods-7.14.5.tgz", + "integrity": "sha512-838DkdUA1u+QTCplatfq4B7+1lnDa/+QMI89x5WZHBcnNv+47N8QEj2k9I2MUU9xIv8XJ4XvPCviM/Dj7Uwt9g==", + "dev": true, + "dependencies": { + "@babel/helper-create-class-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-private-property-in-object/-/plugin-proposal-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-62EyfyA3WA0mZiF2e2IV9mc9Ghwxcg8YTu8BS4Wss4Y3PY725OmS9M0qLORbJwLqFtGh+jiE4wAmocK2CTUK2Q==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.14.5", + "@babel/helper-create-class-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-proposal-unicode-property-regex": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.14.5.tgz", + "integrity": "sha512-6axIeOU5LnY471KenAB9vI8I5j7NQ2d652hIYwVyRfgaZT5UpiqFKCuVXCDMSrU+3VFafnu2c5m3lrWIlr6A5Q==", + "dev": true, + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-static-block": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-static-block/-/plugin-syntax-class-static-block-7.14.5.tgz", + "integrity": "sha512-b+YyPmr6ldyNnM6sqYeMWE+bgJcJpO6yS4QD7ymxgH34GBPNDM/THBh8iunyvKIZztiwLH4CJZ0RxTk9emgpjw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-dynamic-import": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-dynamic-import/-/plugin-syntax-dynamic-import-7.8.3.tgz", + "integrity": "sha512-5gdGbFon+PszYzqs83S3E5mpi7/y/8M9eC90MRTZfduQOYW76ig6SOSPNe41IG5LoP3FGBn2N0RjVDSQiS94kQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-export-namespace-from": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-export-namespace-from/-/plugin-syntax-export-namespace-from-7.8.3.tgz", + "integrity": "sha512-MXf5laXo6c1IbEbegDmzGPwGNTsHZmEy6QGznu5Sh2UCWvueywb2ee+CCE4zQiZstxU9BMoQO9i6zUFSY0Kj0Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-private-property-in-object": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-private-property-in-object/-/plugin-syntax-private-property-in-object-7.14.5.tgz", + "integrity": "sha512-0wVnp9dxJ72ZUJDV27ZfbSj6iHLoytYZmh3rFcxNnvsJF3ktkzLDZPy/mA17HGsaQT3/DQsWYX1f1QGWkCoVUg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-arrow-functions": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.14.5.tgz", + "integrity": "sha512-KOnO0l4+tD5IfOdi4x8C1XmEIRWUjNRV8wc6K2vz/3e8yAOoZZvsRXRRIF/yo/MAOFb4QjtAw9xSxMXbSMRy8A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-async-to-generator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.14.5.tgz", + "integrity": "sha512-szkbzQ0mNk0rpu76fzDdqSyPu0MuvpXgC+6rz5rpMb5OIRxdmHfQxrktL8CYolL2d8luMCZTR0DpIMIdL27IjA==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-remap-async-to-generator": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoped-functions": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.14.5.tgz", + "integrity": "sha512-dtqWqdWZ5NqBX3KzsVCWfQI3A53Ft5pWFCT2eCVUftWZgjc5DpDponbIF1+c+7cSGk2wN0YK7HGL/ezfRbpKBQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-block-scoping": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.14.5.tgz", + "integrity": "sha512-LBYm4ZocNgoCqyxMLoOnwpsmQ18HWTQvql64t3GvMUzLQrNoV1BDG0lNftC8QKYERkZgCCT/7J5xWGObGAyHDw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-classes": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.14.5.tgz", + "integrity": "sha512-J4VxKAMykM06K/64z9rwiL6xnBHgB1+FVspqvlgCdwD1KUbQNfszeKVVOMh59w3sztHYIZDgnhOC4WbdEfHFDA==", + "dev": true, + "dependencies": { + "@babel/helper-annotate-as-pure": "^7.14.5", + "@babel/helper-function-name": "^7.14.5", + "@babel/helper-optimise-call-expression": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-replace-supers": "^7.14.5", + "@babel/helper-split-export-declaration": "^7.14.5", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-computed-properties": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.14.5.tgz", + "integrity": "sha512-pWM+E4283UxaVzLb8UBXv4EIxMovU4zxT1OPnpHJcmnvyY9QbPPTKZfEj31EUvG3/EQRbYAGaYEUZ4yWOBC2xg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-destructuring": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.14.5.tgz", + "integrity": "sha512-wU9tYisEbRMxqDezKUqC9GleLycCRoUsai9ddlsq54r8QRLaeEhc+d+9DqCG+kV9W2GgQjTZESPTpn5bAFMDww==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-dotall-regex": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.14.5.tgz", + "integrity": "sha512-loGlnBdj02MDsFaHhAIJzh7euK89lBrGIdM9EAtHFo6xKygCUGuuWe07o1oZVk287amtW1n0808sQM99aZt3gw==", + "dev": true, + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-duplicate-keys": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.14.5.tgz", + "integrity": "sha512-iJjbI53huKbPDAsJ8EmVmvCKeeq21bAze4fu9GBQtSLqfvzj2oRuHVx4ZkDwEhg1htQ+5OBZh/Ab0XDf5iBZ7A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-exponentiation-operator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.14.5.tgz", + "integrity": "sha512-jFazJhMBc9D27o9jDnIE5ZErI0R0m7PbKXVq77FFvqFbzvTMuv8jaAwLZ5PviOLSFttqKIW0/wxNSDbjLk0tYA==", + "dev": true, + "dependencies": { + "@babel/helper-builder-binary-assignment-operator-visitor": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-for-of": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.14.5.tgz", + "integrity": "sha512-CfmqxSUZzBl0rSjpoQSFoR9UEj3HzbGuGNL21/iFTmjb5gFggJp3ph0xR1YBhexmLoKRHzgxuFvty2xdSt6gTA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-function-name": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.14.5.tgz", + "integrity": "sha512-vbO6kv0fIzZ1GpmGQuvbwwm+O4Cbm2NrPzwlup9+/3fdkuzo1YqOZcXw26+YUJB84Ja7j9yURWposEHLYwxUfQ==", + "dev": true, + "dependencies": { + "@babel/helper-function-name": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-literals": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.14.5.tgz", + "integrity": "sha512-ql33+epql2F49bi8aHXxvLURHkxJbSmMKl9J5yHqg4PLtdE6Uc48CH1GS6TQvZ86eoB/ApZXwm7jlA+B3kra7A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-member-expression-literals": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-member-expression-literals/-/plugin-transform-member-expression-literals-7.14.5.tgz", + "integrity": "sha512-WkNXxH1VXVTKarWFqmso83xl+2V3Eo28YY5utIkbsmXoItO8Q3aZxN4BTS2k0hz9dGUloHK26mJMyQEYfkn/+Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-amd": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.14.5.tgz", + "integrity": "sha512-3lpOU8Vxmp3roC4vzFpSdEpGUWSMsHFreTWOMMLzel2gNGfHE5UWIh/LN6ghHs2xurUp4jRFYMUIZhuFbody1g==", + "dev": true, + "dependencies": { + "@babel/helper-module-transforms": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "babel-plugin-dynamic-import-node": "^2.3.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-commonjs": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.14.5.tgz", + "integrity": "sha512-en8GfBtgnydoao2PS+87mKyw62k02k7kJ9ltbKe0fXTHrQmG6QZZflYuGI1VVG7sVpx4E1n7KBpNlPb8m78J+A==", + "dev": true, + "dependencies": { + "@babel/helper-module-transforms": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-simple-access": "^7.14.5", + "babel-plugin-dynamic-import-node": "^2.3.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-systemjs": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.14.5.tgz", + "integrity": "sha512-mNMQdvBEE5DcMQaL5LbzXFMANrQjd2W7FPzg34Y4yEz7dBgdaC+9B84dSO+/1Wba98zoDbInctCDo4JGxz1VYA==", + "dev": true, + "dependencies": { + "@babel/helper-hoist-variables": "^7.14.5", + "@babel/helper-module-transforms": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-validator-identifier": "^7.14.5", + "babel-plugin-dynamic-import-node": "^2.3.3" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-modules-umd": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.14.5.tgz", + "integrity": "sha512-RfPGoagSngC06LsGUYyM9QWSXZ8MysEjDJTAea1lqRjNECE3y0qIJF/qbvJxc4oA4s99HumIMdXOrd+TdKaAAA==", + "dev": true, + "dependencies": { + "@babel/helper-module-transforms": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-named-capturing-groups-regex": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.14.5.tgz", + "integrity": "sha512-+Xe5+6MWFo311U8SchgeX5c1+lJM+eZDBZgD+tvXu9VVQPXwwVzeManMMjYX6xw2HczngfOSZjoFYKwdeB/Jvw==", + "dev": true, + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/plugin-transform-new-target": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.14.5.tgz", + "integrity": "sha512-Nx054zovz6IIRWEB49RDRuXGI4Gy0GMgqG0cII9L3MxqgXz/+rgII+RU58qpo4g7tNEx1jG7rRVH4ihZoP4esQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-object-super": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.14.5.tgz", + "integrity": "sha512-MKfOBWzK0pZIrav9z/hkRqIk/2bTv9qvxHzPQc12RcVkMOzpIKnFCNYJip00ssKWYkd8Sf5g0Wr7pqJ+cmtuFg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-replace-supers": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-parameters": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.14.5.tgz", + "integrity": "sha512-Tl7LWdr6HUxTmzQtzuU14SqbgrSKmaR77M0OKyq4njZLQTPfOvzblNKyNkGwOfEFCEx7KeYHQHDI0P3F02IVkA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-property-literals": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-property-literals/-/plugin-transform-property-literals-7.14.5.tgz", + "integrity": "sha512-r1uilDthkgXW8Z1vJz2dKYLV1tuw2xsbrp3MrZmD99Wh9vsfKoob+JTgri5VUb/JqyKRXotlOtwgu4stIYCmnw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-regenerator": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.14.5.tgz", + "integrity": "sha512-NVIY1W3ITDP5xQl50NgTKlZ0GrotKtLna08/uGY6ErQt6VEQZXla86x/CTddm5gZdcr+5GSsvMeTmWA5Ii6pkg==", + "dev": true, + "dependencies": { + "regenerator-transform": "^0.14.2" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-reserved-words": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-reserved-words/-/plugin-transform-reserved-words-7.14.5.tgz", + "integrity": "sha512-cv4F2rv1nD4qdexOGsRQXJrOcyb5CrgjUH9PKrrtyhSDBNWGxd0UIitjyJiWagS+EbUGjG++22mGH1Pub8D6Vg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-shorthand-properties": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.14.5.tgz", + "integrity": "sha512-xLucks6T1VmGsTB+GWK5Pl9Jl5+nRXD1uoFdA5TSO6xtiNjtXTjKkmPdFXVLGlK5A2/or/wQMKfmQ2Y0XJfn5g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-spread": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.14.6.tgz", + "integrity": "sha512-Zr0x0YroFJku7n7+/HH3A2eIrGMjbmAIbJSVv0IZ+t3U2WUQUA64S/oeied2e+MaGSjmt4alzBCsK9E8gh+fag==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-skip-transparent-expression-wrappers": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-sticky-regex": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.14.5.tgz", + "integrity": "sha512-Z7F7GyvEMzIIbwnziAZmnSNpdijdr4dWt+FJNBnBLz5mwDFkqIXU9wmBcWWad3QeJF5hMTkRe4dAq2sUZiG+8A==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-template-literals": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.14.5.tgz", + "integrity": "sha512-22btZeURqiepOfuy/VkFr+zStqlujWaarpMErvay7goJS6BWwdd6BY9zQyDLDa4x2S3VugxFb162IZ4m/S/+Gg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-typeof-symbol": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.14.5.tgz", + "integrity": "sha512-lXzLD30ffCWseTbMQzrvDWqljvZlHkXU+CnseMhkMNqU1sASnCsz3tSzAaH3vCUXb9PHeUb90ZT1BdFTm1xxJw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-escapes": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.14.5.tgz", + "integrity": "sha512-crTo4jATEOjxj7bt9lbYXcBAM3LZaUrbP2uUdxb6WIorLmjNKSpHfIybgY4B8SRpbf8tEVIWH3Vtm7ayCrKocA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-unicode-regex": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.14.5.tgz", + "integrity": "sha512-UygduJpC5kHeCiRw/xDVzC+wj8VaYSoKl5JNVmbP7MadpNinAm3SvZCxZ42H37KZBKztz46YC73i9yV34d0Tzw==", + "dev": true, + "dependencies": { + "@babel/helper-create-regexp-features-plugin": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-env": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.14.5.tgz", + "integrity": "sha512-ci6TsS0bjrdPpWGnQ+m4f+JSSzDKlckqKIJJt9UZ/+g7Zz9k0N8lYU8IeLg/01o2h8LyNZDMLGgRLDTxpudLsA==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.14.5", + "@babel/helper-compilation-targets": "^7.14.5", + "@babel/helper-plugin-utils": "^7.14.5", + "@babel/helper-validator-option": "^7.14.5", + "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.14.5", + "@babel/plugin-proposal-async-generator-functions": "^7.14.5", + "@babel/plugin-proposal-class-properties": "^7.14.5", + "@babel/plugin-proposal-class-static-block": "^7.14.5", + "@babel/plugin-proposal-dynamic-import": "^7.14.5", + "@babel/plugin-proposal-export-namespace-from": "^7.14.5", + "@babel/plugin-proposal-json-strings": "^7.14.5", + "@babel/plugin-proposal-logical-assignment-operators": "^7.14.5", + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5", + "@babel/plugin-proposal-numeric-separator": "^7.14.5", + "@babel/plugin-proposal-object-rest-spread": "^7.14.5", + "@babel/plugin-proposal-optional-catch-binding": "^7.14.5", + "@babel/plugin-proposal-optional-chaining": "^7.14.5", + "@babel/plugin-proposal-private-methods": "^7.14.5", + "@babel/plugin-proposal-private-property-in-object": "^7.14.5", + "@babel/plugin-proposal-unicode-property-regex": "^7.14.5", + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-class-properties": "^7.12.13", + "@babel/plugin-syntax-class-static-block": "^7.14.5", + "@babel/plugin-syntax-dynamic-import": "^7.8.3", + "@babel/plugin-syntax-export-namespace-from": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.10.4", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.10.4", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-private-property-in-object": "^7.14.5", + "@babel/plugin-syntax-top-level-await": "^7.14.5", + "@babel/plugin-transform-arrow-functions": "^7.14.5", + "@babel/plugin-transform-async-to-generator": "^7.14.5", + "@babel/plugin-transform-block-scoped-functions": "^7.14.5", + "@babel/plugin-transform-block-scoping": "^7.14.5", + "@babel/plugin-transform-classes": "^7.14.5", + "@babel/plugin-transform-computed-properties": "^7.14.5", + "@babel/plugin-transform-destructuring": "^7.14.5", + "@babel/plugin-transform-dotall-regex": "^7.14.5", + "@babel/plugin-transform-duplicate-keys": "^7.14.5", + "@babel/plugin-transform-exponentiation-operator": "^7.14.5", + "@babel/plugin-transform-for-of": "^7.14.5", + "@babel/plugin-transform-function-name": "^7.14.5", + "@babel/plugin-transform-literals": "^7.14.5", + "@babel/plugin-transform-member-expression-literals": "^7.14.5", + "@babel/plugin-transform-modules-amd": "^7.14.5", + "@babel/plugin-transform-modules-commonjs": "^7.14.5", + "@babel/plugin-transform-modules-systemjs": "^7.14.5", + "@babel/plugin-transform-modules-umd": "^7.14.5", + "@babel/plugin-transform-named-capturing-groups-regex": "^7.14.5", + "@babel/plugin-transform-new-target": "^7.14.5", + "@babel/plugin-transform-object-super": "^7.14.5", + "@babel/plugin-transform-parameters": "^7.14.5", + "@babel/plugin-transform-property-literals": "^7.14.5", + "@babel/plugin-transform-regenerator": "^7.14.5", + "@babel/plugin-transform-reserved-words": "^7.14.5", + "@babel/plugin-transform-shorthand-properties": "^7.14.5", + "@babel/plugin-transform-spread": "^7.14.5", + "@babel/plugin-transform-sticky-regex": "^7.14.5", + "@babel/plugin-transform-template-literals": "^7.14.5", + "@babel/plugin-transform-typeof-symbol": "^7.14.5", + "@babel/plugin-transform-unicode-escapes": "^7.14.5", + "@babel/plugin-transform-unicode-regex": "^7.14.5", + "@babel/preset-modules": "^0.1.4", + "@babel/types": "^7.14.5", + "babel-plugin-polyfill-corejs2": "^0.2.2", + "babel-plugin-polyfill-corejs3": "^0.2.2", + "babel-plugin-polyfill-regenerator": "^0.2.2", + "core-js-compat": "^3.14.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/preset-modules": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/@babel/preset-modules/-/preset-modules-0.1.4.tgz", + "integrity": "sha512-J36NhwnfdzpmH41M1DrnkkgAqhZaqr/NBdPfQ677mLzlaXo+oDiv1deyCDtgAhz8p328otdob0Du7+xgHGZbKg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.4.4", + "@babel/plugin-transform-dotall-regex": "^7.4.4", + "@babel/types": "^7.4.4", + "esutils": "^2.0.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/runtime": { + "version": "7.14.6", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.14.6.tgz", + "integrity": "sha512-/PCB2uJ7oM44tz8YhC4Z/6PeOKXp4K588f+5M3clr1M4zbqztlo0XEfJ2LEzj/FgwfgGcIdl8n7YYjTCI0BYwg==", + "dev": true, + "dependencies": { + "regenerator-runtime": "^0.13.4" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/template": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.14.5.tgz", + "integrity": "sha512-6Z3Po85sfxRGachLULUhOmvAaOo7xCvqGQtxINai2mEGPFm6pQ4z5QInFnUrRpfoSV60BnjyF5F3c+15fxFV1g==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.14.5", + "@babel/parser": "^7.14.5", + "@babel/types": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.14.5.tgz", + "integrity": "sha512-G3BiS15vevepdmFqmUc9X+64y0viZYygubAMO8SvBmKARuF6CPSZtH4Ng9vi/lrWlZFGe3FWdXNy835akH8Glg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.14.5", + "@babel/generator": "^7.14.5", + "@babel/helper-function-name": "^7.14.5", + "@babel/helper-hoist-variables": "^7.14.5", + "@babel/helper-split-export-declaration": "^7.14.5", + "@babel/parser": "^7.14.5", + "@babel/types": "^7.14.5", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse/node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/@babel/traverse/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/@babel/types": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.14.5.tgz", + "integrity": "sha512-M/NzBpEL95I5Hh4dwhin5JlE7EzO5PHMAuzjxss3tiOBD46KfQvVedN/3jEPZvdRvtsK2222XfdHogNIttFgcg==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.14.5", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.3.tgz", + "integrity": "sha512-J6KFFz5QCYUJq3pf0mjEcCJVERbzv71PUIDczuh9JkwGEzced6CO5ADLHB1rbf/+oPBtoPfMYNOpGDzCANlbXw==", + "dev": true, + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.1.1", + "espree": "^7.3.0", + "globals": "^13.9.0", + "ignore": "^4.0.6", + "import-fresh": "^3.2.1", + "js-yaml": "^3.13.1", + "minimatch": "^3.0.4", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "13.10.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.10.0.tgz", + "integrity": "sha512-piHC3blgLGFjvOuMmWZX60f+na1lXFDhQXBf1UYp2fXPXqvEUbOhNwi6BsQ0bQishwedgnjkwv1d9zKf+MWw3g==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@humanwhocodes/config-array": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.5.0.tgz", + "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", + "dev": true, + "dependencies": { + "@humanwhocodes/object-schema": "^1.2.0", + "debug": "^4.1.1", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=10.10.0" + } + }, + "node_modules/@humanwhocodes/object-schema": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.0.tgz", + "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", + "dev": true + }, + "node_modules/acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, + "node_modules/acorn-node": { + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/acorn-node/-/acorn-node-1.8.2.tgz", + "integrity": "sha512-8mt+fslDufLYntIoPAaIMUe/lrbrehIiwmR3t2k9LljIzoigEPF27eLk2hy8zSGzmR/ogr7zbRKINMo1u0yh5A==", + "dev": true, + "dependencies": { + "acorn": "^7.0.0", + "acorn-walk": "^7.0.0", + "xtend": "^4.0.2" + } + }, + "node_modules/acorn-walk": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", + "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/asn1.js": { + "version": "5.4.1", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-5.4.1.tgz", + "integrity": "sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==", + "dev": true, + "dependencies": { + "bn.js": "^4.0.0", + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0", + "safer-buffer": "^2.1.0" + } + }, + "node_modules/asn1.js/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/assert": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-1.5.0.tgz", + "integrity": "sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA==", + "dev": true, + "dependencies": { + "object-assign": "^4.1.1", + "util": "0.10.3" + } + }, + "node_modules/assert/node_modules/inherits": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", + "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", + "dev": true + }, + "node_modules/assert/node_modules/util": { + "version": "0.10.3", + "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", + "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", + "dev": true, + "dependencies": { + "inherits": "2.0.1" + } + }, + "node_modules/astral-regex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", + "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.4.tgz", + "integrity": "sha512-SA5mXJWrId1TaQjfxUYghbqQ/hYioKmLJvPJyDuYRtXXenFNMjj4hSSt1Cf1xsuXSXrtxrVC5Ot4eU6cOtBDdA==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/babel-plugin-dynamic-import-node": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", + "integrity": "sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==", + "dev": true, + "dependencies": { + "object.assign": "^4.1.0" + } + }, + "node_modules/babel-plugin-polyfill-corejs2": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.2.2.tgz", + "integrity": "sha512-kISrENsJ0z5dNPq5eRvcctITNHYXWOA4DUZRFYCz3jYCcvTb/A546LIddmoGNMVYg2U38OyFeNosQwI9ENTqIQ==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.13.11", + "@babel/helper-define-polyfill-provider": "^0.2.2", + "semver": "^6.1.1" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-plugin-polyfill-corejs3": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.2.3.tgz", + "integrity": "sha512-rCOFzEIJpJEAU14XCcV/erIf/wZQMmMT5l5vXOpL5uoznyOGfDIjPj6FVytMvtzaKSTSVKouOCTPJ5OMUZH30g==", + "dev": true, + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.2.2", + "core-js-compat": "^3.14.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babel-plugin-polyfill-regenerator": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-regenerator/-/babel-plugin-polyfill-regenerator-0.2.2.tgz", + "integrity": "sha512-Goy5ghsc21HgPDFtzRkSirpZVW35meGoTmTOb2bxqdl60ghub4xOidgNTHaZfQ2FaxQsKmwvXtOAkcIS4SMBWg==", + "dev": true, + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.2.2" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/babelify": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/babelify/-/babelify-10.0.0.tgz", + "integrity": "sha512-X40FaxyH7t3X+JFAKvb1H9wooWKLRCi8pg3m8poqtdZaIng+bjzp9RvKQCvRjF9isHiPkXspbbXT/zwXLtwgwg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/bl": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/bl/-/bl-2.2.1.tgz", + "integrity": "sha512-6Pesp1w0DEX1N550i/uGV/TqucVL4AM/pgThFSN/Qq9si1/DF9aIHs1BxD8V/QU0HoeHO6cQRTAuYnLPKq1e4g==", + "dependencies": { + "readable-stream": "^2.3.5", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/brorand": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/brorand/-/brorand-1.1.0.tgz", + "integrity": "sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=", + "dev": true + }, + "node_modules/browser-pack": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/browser-pack/-/browser-pack-6.1.0.tgz", + "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", + "dev": true, + "dependencies": { + "combine-source-map": "~0.8.0", + "defined": "^1.0.0", + "JSONStream": "^1.0.3", + "safe-buffer": "^5.1.1", + "through2": "^2.0.0", + "umd": "^3.0.0" + }, + "bin": { + "browser-pack": "bin/cmd.js" + } + }, + "node_modules/browser-resolve": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/browser-resolve/-/browser-resolve-2.0.0.tgz", + "integrity": "sha512-7sWsQlYL2rGLy2IWm8WL8DCTJvYLc/qlOnsakDac87SOoCd16WLsaAMdCiAqsTNHIe+SXfaqyxyo6THoWqs8WQ==", + "dev": true, + "dependencies": { + "resolve": "^1.17.0" + } + }, + "node_modules/browserify": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/browserify/-/browserify-17.0.0.tgz", + "integrity": "sha512-SaHqzhku9v/j6XsQMRxPyBrSP3gnwmE27gLJYZgMT2GeK3J0+0toN+MnuNYDfHwVGQfLiMZ7KSNSIXHemy905w==", + "dev": true, + "dependencies": { + "assert": "^1.4.0", + "browser-pack": "^6.0.1", + "browser-resolve": "^2.0.0", + "browserify-zlib": "~0.2.0", + "buffer": "~5.2.1", + "cached-path-relative": "^1.0.0", + "concat-stream": "^1.6.0", + "console-browserify": "^1.1.0", + "constants-browserify": "~1.0.0", + "crypto-browserify": "^3.0.0", + "defined": "^1.0.0", + "deps-sort": "^2.0.1", + "domain-browser": "^1.2.0", + "duplexer2": "~0.1.2", + "events": "^3.0.0", + "glob": "^7.1.0", + "has": "^1.0.0", + "htmlescape": "^1.1.0", + "https-browserify": "^1.0.0", + "inherits": "~2.0.1", + "insert-module-globals": "^7.2.1", + "JSONStream": "^1.0.3", + "labeled-stream-splicer": "^2.0.0", + "mkdirp-classic": "^0.5.2", + "module-deps": "^6.2.3", + "os-browserify": "~0.3.0", + "parents": "^1.0.1", + "path-browserify": "^1.0.0", + "process": "~0.11.0", + "punycode": "^1.3.2", + "querystring-es3": "~0.2.0", + "read-only-stream": "^2.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.1.4", + "shasum-object": "^1.0.0", + "shell-quote": "^1.6.1", + "stream-browserify": "^3.0.0", + "stream-http": "^3.0.0", + "string_decoder": "^1.1.1", + "subarg": "^1.0.0", + "syntax-error": "^1.1.1", + "through2": "^2.0.0", + "timers-browserify": "^1.0.1", + "tty-browserify": "0.0.1", + "url": "~0.11.0", + "util": "~0.12.0", + "vm-browserify": "^1.0.0", + "xtend": "^4.0.0" + }, + "bin": { + "browserify": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/browserify-aes": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-1.2.0.tgz", + "integrity": "sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==", + "dev": true, + "dependencies": { + "buffer-xor": "^1.0.3", + "cipher-base": "^1.0.0", + "create-hash": "^1.1.0", + "evp_bytestokey": "^1.0.3", + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/browserify-cipher": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/browserify-cipher/-/browserify-cipher-1.0.1.tgz", + "integrity": "sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w==", + "dev": true, + "dependencies": { + "browserify-aes": "^1.0.4", + "browserify-des": "^1.0.0", + "evp_bytestokey": "^1.0.0" + } + }, + "node_modules/browserify-des": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/browserify-des/-/browserify-des-1.0.2.tgz", + "integrity": "sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.1", + "des.js": "^1.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/browserify-rsa": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/browserify-rsa/-/browserify-rsa-4.1.0.tgz", + "integrity": "sha512-AdEER0Hkspgno2aR97SAf6vi0y0k8NuOpGnVH3O99rcA5Q6sh8QxcngtHuJ6uXwnfAXNM4Gn1Gb7/MV1+Ymbog==", + "dev": true, + "dependencies": { + "bn.js": "^5.0.0", + "randombytes": "^2.0.1" + } + }, + "node_modules/browserify-sign": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserify-sign/-/browserify-sign-4.2.1.tgz", + "integrity": "sha512-/vrA5fguVAKKAVTNJjgSm1tRQDHUU6DbwO9IROu/0WAzC8PKhucDSh18J0RMvVeHAn5puMd+QHC2erPRNf8lmg==", + "dev": true, + "dependencies": { + "bn.js": "^5.1.1", + "browserify-rsa": "^4.0.1", + "create-hash": "^1.2.0", + "create-hmac": "^1.1.7", + "elliptic": "^6.5.3", + "inherits": "^2.0.4", + "parse-asn1": "^5.1.5", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + } + }, + "node_modules/browserify-sign/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/browserify-zlib": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.2.0.tgz", + "integrity": "sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA==", + "dev": true, + "dependencies": { + "pako": "~1.0.5" + } + }, + "node_modules/browserslist": { + "version": "4.16.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.16.6.tgz", + "integrity": "sha512-Wspk/PqO+4W9qp5iUTJsa1B/QrYn1keNCcEP5OvP7WBwT4KaDly0uONYmC6Xa3Z5IqnUgS0KcgLYu1l74x0ZXQ==", + "dev": true, + "dependencies": { + "caniuse-lite": "^1.0.30001219", + "colorette": "^1.2.2", + "electron-to-chromium": "^1.3.723", + "escalade": "^3.1.1", + "node-releases": "^1.1.71" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + } + }, + "node_modules/bson": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.6.tgz", + "integrity": "sha512-EvVNVeGo4tHxwi8L6bPj3y3itEvStdwvvlojVxxbyYfoaxJ6keLgrTuKdyfEAszFK+H3olzBuafE0yoh0D1gdg==", + "engines": { + "node": ">=0.6.19" + } + }, + "node_modules/buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz", + "integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==", + "dev": true, + "dependencies": { + "base64-js": "^1.0.2", + "ieee754": "^1.1.4" + } + }, + "node_modules/buffer-from": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", + "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", + "dev": true + }, + "node_modules/buffer-xor": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", + "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=", + "dev": true + }, + "node_modules/builtin-status-codes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", + "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", + "dev": true + }, + "node_modules/cached-path-relative": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cached-path-relative/-/cached-path-relative-1.0.2.tgz", + "integrity": "sha512-5r2GqsoEb4qMTTN9J+WzXfjov+hjxT+j3u5K+kIVNIwAd99DLCJE9pBIMP1qVeybV6JiijL385Oz0DcYxfbOIg==", + "dev": true + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001315", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001315.tgz", + "integrity": "sha512-5v7LFQU4Sb/qvkz7JcZkvtSH1Ko+1x2kgo3ocdBeMGZSOFpuE1kkm0kpTwLtWeFrw5qw08ulLxJjVIXIS8MkiQ==", + "dev": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + } + }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/cipher-base": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.4.tgz", + "integrity": "sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true + }, + "node_modules/colorette": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-1.2.2.tgz", + "integrity": "sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==", + "dev": true + }, + "node_modules/combine-source-map": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/combine-source-map/-/combine-source-map-0.8.0.tgz", + "integrity": "sha1-pY0N8ELBhvz4IqjoAV9UUNLXmos=", + "dev": true, + "dependencies": { + "convert-source-map": "~1.1.0", + "inline-source-map": "~0.6.0", + "lodash.memoize": "~3.0.3", + "source-map": "~0.5.3" + } + }, + "node_modules/combine-source-map/node_modules/convert-source-map": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.1.3.tgz", + "integrity": "sha1-SCnId+n+SbMWHzvzZziI4gRpmGA=", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "node_modules/concat-stream": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.2.tgz", + "integrity": "sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==", + "dev": true, + "engines": [ + "node >= 0.8" + ], + "dependencies": { + "buffer-from": "^1.0.0", + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "node_modules/console-browserify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==", + "dev": true + }, + "node_modules/constants-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", + "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", + "dev": true + }, + "node_modules/convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.1" + } + }, + "node_modules/convert-source-map/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/core-js-compat": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.14.0.tgz", + "integrity": "sha512-R4NS2eupxtiJU+VwgkF9WTpnSfZW4pogwKHd8bclWU2sp93Pr5S1uYJI84cMOubJRou7bcfL0vmwtLslWN5p3A==", + "dev": true, + "dependencies": { + "browserslist": "^4.16.6", + "semver": "7.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/core-js-compat/node_modules/semver": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.0.0.tgz", + "integrity": "sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" + }, + "node_modules/create-ecdh": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", + "integrity": "sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "elliptic": "^6.5.3" + } + }, + "node_modules/create-ecdh/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/create-hash": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.2.0.tgz", + "integrity": "sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.1", + "inherits": "^2.0.1", + "md5.js": "^1.3.4", + "ripemd160": "^2.0.1", + "sha.js": "^2.4.0" + } + }, + "node_modules/create-hmac": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/create-hmac/-/create-hmac-1.1.7.tgz", + "integrity": "sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg==", + "dev": true, + "dependencies": { + "cipher-base": "^1.0.3", + "create-hash": "^1.1.0", + "inherits": "^2.0.1", + "ripemd160": "^2.0.0", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/crypto-browserify": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz", + "integrity": "sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg==", + "dev": true, + "dependencies": { + "browserify-cipher": "^1.0.0", + "browserify-sign": "^4.0.0", + "create-ecdh": "^4.0.0", + "create-hash": "^1.1.0", + "create-hmac": "^1.1.0", + "diffie-hellman": "^5.0.0", + "inherits": "^2.0.1", + "pbkdf2": "^3.0.3", + "public-encrypt": "^4.0.0", + "randombytes": "^2.0.0", + "randomfill": "^1.0.3" + }, + "engines": { + "node": "*" + } + }, + "node_modules/dash-ast": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz", + "integrity": "sha512-Vy4dx7gquTeMcQR/hDkYLGUnwVil6vk4FOOct+djUnHOUWt+zJPJAaRIXaAFkPXtJjvlY7o3rfRu0/3hpnwoUA==", + "dev": true + }, + "node_modules/debug": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-is": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", + "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", + "dev": true + }, + "node_modules/define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "dev": true, + "dependencies": { + "object-keys": "^1.0.12" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/defined": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/defined/-/defined-1.0.0.tgz", + "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", + "dev": true + }, + "node_modules/denque": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", + "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==", + "engines": { + "node": ">=0.10" + } + }, + "node_modules/deps-sort": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/deps-sort/-/deps-sort-2.0.1.tgz", + "integrity": "sha512-1orqXQr5po+3KI6kQb9A4jnXT1PBwggGl2d7Sq2xsnOeI9GPcE/tGcF9UiSZtZBM7MukY4cAh7MemS6tZYipfw==", + "dev": true, + "dependencies": { + "JSONStream": "^1.0.3", + "shasum-object": "^1.0.0", + "subarg": "^1.0.0", + "through2": "^2.0.0" + }, + "bin": { + "deps-sort": "bin/cmd.js" + } + }, + "node_modules/des.js": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/des.js/-/des.js-1.0.1.tgz", + "integrity": "sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "minimalistic-assert": "^1.0.0" + } + }, + "node_modules/detective": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/detective/-/detective-5.2.0.tgz", + "integrity": "sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==", + "dev": true, + "dependencies": { + "acorn-node": "^1.6.1", + "defined": "^1.0.0", + "minimist": "^1.1.1" + }, + "bin": { + "detective": "bin/detective.js" + }, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/diffie-hellman": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", + "integrity": "sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "miller-rabin": "^4.0.0", + "randombytes": "^2.0.0" + } + }, + "node_modules/diffie-hellman/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/doctrine": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", + "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", + "dev": true, + "dependencies": { + "esutils": "^2.0.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/domain-browser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz", + "integrity": "sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA==", + "dev": true, + "engines": { + "node": ">=0.4", + "npm": ">=1.2" + } + }, + "node_modules/duplexer2": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/duplexer2/-/duplexer2-0.1.4.tgz", + "integrity": "sha1-ixLauHjA1p4+eJEFFmKjL8a93ME=", + "dev": true, + "dependencies": { + "readable-stream": "^2.0.2" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.3.752", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.752.tgz", + "integrity": "sha512-2Tg+7jSl3oPxgsBsWKh5H83QazTkmWG/cnNwJplmyZc7KcN61+I10oUgaXSVk/NwfvN3BdkKDR4FYuRBQQ2v0A==", + "dev": true + }, + "node_modules/elliptic": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", + "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", + "dev": true, + "dependencies": { + "bn.js": "^4.11.9", + "brorand": "^1.1.0", + "hash.js": "^1.0.0", + "hmac-drbg": "^1.0.1", + "inherits": "^2.0.4", + "minimalistic-assert": "^1.0.1", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/elliptic/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "dev": true, + "dependencies": { + "ansi-colors": "^4.1.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/es-abstract": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.3.tgz", + "integrity": "sha512-nQIr12dxV7SSxE6r6f1l3DtAeEYdsGpps13dR0TwJg1S8gyp4ZPgy3FZcHBgbiQqnoqSTb+oC+kO4UQ0C/J8vw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.2", + "is-callable": "^1.2.3", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.3", + "is-string": "^1.0.6", + "object-inspect": "^1.10.3", + "object-keys": "^1.1.1", + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "dependencies": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/eslint": { + "version": "7.31.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.31.0.tgz", + "integrity": "sha512-vafgJpSh2ia8tnTkNUkwxGmnumgckLh5aAbLa1xRmIn9+owi8qBNGKL+B881kNKNTy7FFqTEkpNkUvmw0n6PkA==", + "dev": true, + "dependencies": { + "@babel/code-frame": "7.12.11", + "@eslint/eslintrc": "^0.4.3", + "@humanwhocodes/config-array": "^0.5.0", + "ajv": "^6.10.0", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.0.1", + "doctrine": "^3.0.0", + "enquirer": "^2.3.5", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^5.1.1", + "eslint-utils": "^2.1.0", + "eslint-visitor-keys": "^2.0.0", + "espree": "^7.3.1", + "esquery": "^1.4.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^6.0.1", + "functional-red-black-tree": "^1.0.1", + "glob-parent": "^5.1.2", + "globals": "^13.6.0", + "ignore": "^4.0.6", + "import-fresh": "^3.0.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "js-yaml": "^3.13.1", + "json-stable-stringify-without-jsonify": "^1.0.1", + "levn": "^0.4.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.0.4", + "natural-compare": "^1.4.0", + "optionator": "^0.9.1", + "progress": "^2.0.0", + "regexpp": "^3.1.0", + "semver": "^7.2.1", + "strip-ansi": "^6.0.0", + "strip-json-comments": "^3.1.0", + "table": "^6.0.9", + "text-table": "^0.2.0", + "v8-compile-cache": "^2.0.3" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/eslint-utils": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", + "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^1.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, + "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", + "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint/node_modules/@babel/code-frame": { + "version": "7.12.11", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", + "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.10.4" + } + }, + "node_modules/eslint/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/eslint/node_modules/chalk": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", + "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/eslint/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/eslint/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/eslint/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/globals": { + "version": "13.10.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.10.0.tgz", + "integrity": "sha512-piHC3blgLGFjvOuMmWZX60f+na1lXFDhQXBf1UYp2fXPXqvEUbOhNwi6BsQ0bQishwedgnjkwv1d9zKf+MWw3g==", + "dev": true, + "dependencies": { + "type-fest": "^0.20.2" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint/node_modules/semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/eslint/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/espree": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", + "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", + "dev": true, + "dependencies": { + "acorn": "^7.4.0", + "acorn-jsx": "^5.3.1", + "eslint-visitor-keys": "^1.3.0" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/espree/node_modules/eslint-visitor-keys": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", + "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esquery": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", + "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", + "dev": true, + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esquery/node_modules/estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", + "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esutils": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", + "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/evp_bytestokey": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", + "integrity": "sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA==", + "dev": true, + "dependencies": { + "md5.js": "^1.3.4", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "dev": true + }, + "node_modules/fast-safe-stringify": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.0.7.tgz", + "integrity": "sha512-Utm6CdzT+6xsDk2m8S6uL8VHxNwI6Jub+e9NYTcAms28T84pTa25GJQV9j0CY0N1rM8hK4x6grpF2BQf+2qwVA==", + "dev": true + }, + "node_modules/file-entry-cache": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", + "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", + "dev": true, + "dependencies": { + "flat-cache": "^3.0.4" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flat-cache": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", + "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", + "dev": true, + "dependencies": { + "flatted": "^3.1.0", + "rimraf": "^3.0.2" + }, + "engines": { + "node": "^10.12.0 || >=12.0.0" + } + }, + "node_modules/flatted": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.2.1.tgz", + "integrity": "sha512-OMQjaErSFHmHqZe+PSidH5n8j3O0F2DdnVh8JB4j4eUQ2k6KvB0qGfrKIhapvez5JerBbmWkaLYUYWISaESoXg==", + "dev": true + }, + "node_modules/foreach": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", + "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", + "dev": true + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, + "node_modules/functional-red-black-tree": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", + "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", + "dev": true + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-assigned-identifiers": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/get-assigned-identifiers/-/get-assigned-identifiers-1.2.0.tgz", + "integrity": "sha512-mBBwmeGTrxEMO4pMaaf/uUEFHnYtwr8FTe8Y/mer4rcV/bye0qGm6pw1bGZFGStxC5O76c5ZAVBGnqHmOaJpdQ==", + "dev": true + }, + "node_modules/get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/glob": { + "version": "7.1.7", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", + "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-bigints": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", + "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hash-base": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/hash-base/-/hash-base-3.1.0.tgz", + "integrity": "sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "safe-buffer": "^5.2.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/hash-base/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/hash.js": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/hash.js/-/hash.js-1.1.7.tgz", + "integrity": "sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "minimalistic-assert": "^1.0.1" + } + }, + "node_modules/hmac-drbg": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", + "integrity": "sha1-0nRXAQJabHdabFRXk+1QL8DGSaE=", + "dev": true, + "dependencies": { + "hash.js": "^1.0.3", + "minimalistic-assert": "^1.0.0", + "minimalistic-crypto-utils": "^1.0.1" + } + }, + "node_modules/htmlescape": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/htmlescape/-/htmlescape-1.1.1.tgz", + "integrity": "sha1-OgPtwiFLyjtmQko+eVk0lQnLA1E=", + "dev": true, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/https-browserify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-1.0.0.tgz", + "integrity": "sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM=", + "dev": true + }, + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/ignore": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", + "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/inline-source-map": { + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/inline-source-map/-/inline-source-map-0.6.2.tgz", + "integrity": "sha1-+Tk0ccGKedFyT4Y/o4tYY3Ct4qU=", + "dev": true, + "dependencies": { + "source-map": "~0.5.3" + } + }, + "node_modules/insert-module-globals": { + "version": "7.2.1", + "resolved": "https://registry.npmjs.org/insert-module-globals/-/insert-module-globals-7.2.1.tgz", + "integrity": "sha512-ufS5Qq9RZN+Bu899eA9QCAYThY+gGW7oRkmb0vC93Vlyu/CFGcH0OYPEjVkDXA5FEbTt1+VWzdoOD3Ny9N+8tg==", + "dev": true, + "dependencies": { + "acorn-node": "^1.5.2", + "combine-source-map": "^0.8.0", + "concat-stream": "^1.6.1", + "is-buffer": "^1.1.0", + "JSONStream": "^1.0.3", + "path-is-absolute": "^1.0.1", + "process": "~0.11.0", + "through2": "^2.0.0", + "undeclared-identifiers": "^1.1.2", + "xtend": "^4.0.0" + }, + "bin": { + "insert-module-globals": "bin/cmd.js" + } + }, + "node_modules/is-arguments": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.0.tgz", + "integrity": "sha512-1Ij4lOMPl/xB5kBDn7I+b2ttPMKa8szhEIrXDuXQD/oe3HJLTLhqhgGspwgyGd6MOywBUqVvYicF72lkgDnIHg==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.2.tgz", + "integrity": "sha512-0JV5+SOCQkIdzjBK9buARcV804Ddu7A0Qet6sHi3FimE9ne6m4BGQZfRn+NZiXbBk4F4XmHfDZIipLj9pX8dSA==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-boolean-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.1.tgz", + "integrity": "sha512-bXdQWkECBUIAcCkeH1unwJLIpZYaa5VvuygSyS/c2lf719mTKZDU5UdDRlpd01UjADgmW8RfqaP+mRaVPdr/Ng==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-buffer": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", + "dev": true + }, + "node_modules/is-callable": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.3.tgz", + "integrity": "sha512-J1DcMe8UYTBSrKezuIUTUwjXsho29693unXM2YhJUTR2txK/eG47bvNa/wipPFmZFgr/N6f1GA66dv0mEyTIyQ==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.4.0.tgz", + "integrity": "sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.4.tgz", + "integrity": "sha512-/b4ZVsG7Z5XVtIxs/h9W8nvfLgSAyKYdtGWQLbqy6jA1icmgjf8WCoTKgeS4wy5tYaPePouzFMANbnj94c2Z+A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-function": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.9.tgz", + "integrity": "sha512-ZJ34p1uvIfptHCN7sFTjGibB9/oBg17sHqzDLfuwhvmN/qLVvIQXRQ8licZQ35WJ8KuEQt/etnnzQFI9C9Ue/A==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-glob": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "dev": true, + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", + "integrity": "sha512-2z6JzQvZRa9A2Y7xC6dQQm4FSTSTNWjKIYYTt4246eMTJmIo0Q+ZyOsU66X8lxK1AbB92dFeglPLrhwpeRKO6w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number-object": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.5.tgz", + "integrity": "sha512-RU0lI/n95pMoUKu9v1BZP5MBcZuNSVJkMkAG2dJqC4z2GlkGUNeH68SuHuBKBD/XFe+LHZ+f9BKkLET60Niedw==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-regex": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.3.tgz", + "integrity": "sha512-qSVXFz28HM7y+IWX6vLCsexdlvzT1PJNFSBuaQLQ5o0IEw8UDYW6/2+eCMVyIsbM8CNLX2a/QWmSpyxYEHY7CQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.6.tgz", + "integrity": "sha512-2gdzbKUuqtQ3lYNrUTQYoClPhm7oQu4UdpSZMp1/DGgkHBT8E2Z1l0yMdb6D4zNAxwDiMv8MdulKROJGNl0Q0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.5.tgz", + "integrity": "sha512-S+GRDgJlR3PyEbsX/Fobd9cqpZBuvUS+8asRqYDMLCb2qMzt1oz5m5oxQCxOgUDxiWsOVNi4yaF+/uvdlHlYug==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.2", + "call-bind": "^1.0.2", + "es-abstract": "^1.18.0-next.2", + "foreach": "^2.0.5", + "has-symbols": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.0.tgz", + "integrity": "sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA==", + "dev": true, + "dependencies": { + "minimist": "^1.2.5" + }, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/jsonparse": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", + "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", + "dev": true, + "engines": [ + "node >= 0.2.0" + ] + }, + "node_modules/JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dev": true, + "dependencies": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + }, + "bin": { + "JSONStream": "bin.js" + }, + "engines": { + "node": "*" + } + }, + "node_modules/labeled-stream-splicer": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", + "integrity": "sha512-Ca4LSXFFZUjPScRaqOcFxneA0VpKZr4MMYCljyQr4LIewTLb3Y0IUTIsnBBsVubIeEfxeSZpSjSsRM8APEQaAw==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "stream-splicer": "^2.0.0" + } + }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/lodash.clonedeep": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", + "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", + "dev": true + }, + "node_modules/lodash.debounce": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz", + "integrity": "sha1-gteb/zCmfEAF/9XiUVMArZyk168=", + "dev": true + }, + "node_modules/lodash.memoize": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-3.0.4.tgz", + "integrity": "sha1-LcvSwofLwKVcxCMovQxzYVDVPj8=", + "dev": true + }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true + }, + "node_modules/lodash.truncate": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", + "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", + "dev": true + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/md5.js": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", + "integrity": "sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg==", + "dev": true, + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, + "node_modules/miller-rabin": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", + "integrity": "sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA==", + "dev": true, + "dependencies": { + "bn.js": "^4.0.0", + "brorand": "^1.0.1" + }, + "bin": { + "miller-rabin": "bin/miller-rabin" + } + }, + "node_modules/miller-rabin/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/minimalistic-assert": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", + "integrity": "sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==", + "dev": true + }, + "node_modules/minimalistic-crypto-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz", + "integrity": "sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo=", + "dev": true + }, + "node_modules/minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "node_modules/mkdirp-classic": { + "version": "0.5.3", + "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", + "dev": true + }, + "node_modules/module-deps": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/module-deps/-/module-deps-6.2.3.tgz", + "integrity": "sha512-fg7OZaQBcL4/L+AK5f4iVqf9OMbCclXfy/znXRxTVhJSeW5AIlS9AwheYwDaXM3lVW7OBeaeUEY3gbaC6cLlSA==", + "dev": true, + "dependencies": { + "browser-resolve": "^2.0.0", + "cached-path-relative": "^1.0.2", + "concat-stream": "~1.6.0", + "defined": "^1.0.0", + "detective": "^5.2.0", + "duplexer2": "^0.1.2", + "inherits": "^2.0.1", + "JSONStream": "^1.0.3", + "parents": "^1.0.0", + "readable-stream": "^2.0.2", + "resolve": "^1.4.0", + "stream-combiner2": "^1.1.1", + "subarg": "^1.0.0", + "through2": "^2.0.0", + "xtend": "^4.0.0" + }, + "bin": { + "module-deps": "bin/cmd.js" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/mongodb": { + "version": "3.6.9", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-3.6.9.tgz", + "integrity": "sha512-1nSCKgSunzn/CXwgOWgbPHUWOO5OfERcuOWISmqd610jn0s8BU9K4879iJVabqgpPPbA6hO7rG48eq+fGED3Mg==", + "dependencies": { + "bl": "^2.2.1", + "bson": "^1.1.4", + "denque": "^1.4.1", + "optional-require": "^1.0.3", + "safe-buffer": "^5.1.2" + }, + "engines": { + "node": ">=4" + }, + "optionalDependencies": { + "saslprep": "^1.0.0" + }, + "peerDependenciesMeta": { + "aws4": { + "optional": true + }, + "bson-ext": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "mongodb-extjson": { + "optional": true + }, + "snappy": { + "optional": true + } + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", + "dev": true + }, + "node_modules/node-releases": { + "version": "1.1.73", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.73.tgz", + "integrity": "sha512-uW7fodD6pyW2FZNZnp/Z3hvWKeEW1Y8R1+1CnErE8cXFXzl5blBOoVB41CvMer6P6Q0S5FXDwcHgFd1Wj0U9zg==", + "dev": true + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.10.3.tgz", + "integrity": "sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw==", + "dev": true, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/optional-require": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/optional-require/-/optional-require-1.0.3.tgz", + "integrity": "sha512-RV2Zp2MY2aeYK5G+B/Sps8lW5NHAzE5QClbFP15j+PWmP+T9PxlJXBOOLoSAdgwFvS4t0aMR4vpedMkbHfh0nA==", + "engines": { + "node": ">=4" + } + }, + "node_modules/optionator": { + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", + "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "dev": true, + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.3" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/os-browserify": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", + "integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=", + "dev": true + }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "dev": true + }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/parents": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parents/-/parents-1.0.1.tgz", + "integrity": "sha1-/t1NK/GTp3dF/nHjcdc8MwfZx1E=", + "dev": true, + "dependencies": { + "path-platform": "~0.11.15" + } + }, + "node_modules/parse-asn1": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/parse-asn1/-/parse-asn1-5.1.6.tgz", + "integrity": "sha512-RnZRo1EPU6JBnra2vGHj0yhp6ebyjBZpmUCLHWiFhxlzvBCCpAuZ7elsBp1PVAbQN0/04VD/19rfzlBSwLstMw==", + "dev": true, + "dependencies": { + "asn1.js": "^5.2.0", + "browserify-aes": "^1.0.0", + "evp_bytestokey": "^1.0.0", + "pbkdf2": "^3.0.3", + "safe-buffer": "^5.1.1" + } + }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "dev": true + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/path-platform": { + "version": "0.11.15", + "resolved": "https://registry.npmjs.org/path-platform/-/path-platform-0.11.15.tgz", + "integrity": "sha1-6GQhf3TDaFDwhSt43Hv31KVyG/I=", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/pbkdf2": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", + "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "dev": true, + "dependencies": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + }, + "engines": { + "node": ">=0.12" + } + }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", + "dev": true, + "engines": { + "node": ">= 0.6.0" + } + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==" + }, + "node_modules/progress": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", + "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", + "dev": true, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/public-encrypt": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/public-encrypt/-/public-encrypt-4.0.3.tgz", + "integrity": "sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q==", + "dev": true, + "dependencies": { + "bn.js": "^4.1.0", + "browserify-rsa": "^4.0.0", + "create-hash": "^1.1.0", + "parse-asn1": "^5.0.0", + "randombytes": "^2.0.1", + "safe-buffer": "^5.1.2" + } + }, + "node_modules/public-encrypt/node_modules/bn.js": { + "version": "4.12.0", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", + "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "dev": true + }, + "node_modules/punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + }, + "node_modules/querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "deprecated": "The querystring API is considered Legacy. new code should use the URLSearchParams API instead.", + "dev": true, + "engines": { + "node": ">=0.4.x" + } + }, + "node_modules/querystring-es3": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", + "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", + "dev": true, + "engines": { + "node": ">=0.4.x" + } + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/randomfill": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/randomfill/-/randomfill-1.0.4.tgz", + "integrity": "sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw==", + "dev": true, + "dependencies": { + "randombytes": "^2.0.5", + "safe-buffer": "^5.1.0" + } + }, + "node_modules/read-only-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-only-stream/-/read-only-stream-2.0.0.tgz", + "integrity": "sha1-JyT9aoET1zdkrCiNQ4YnDB2/F/A=", + "dev": true, + "dependencies": { + "readable-stream": "^2.0.2" + } + }, + "node_modules/readable-stream": { + "version": "2.3.7", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz", + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/readable-stream/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "node_modules/readable-stream/node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, + "node_modules/regenerate": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "dev": true + }, + "node_modules/regenerate-unicode-properties": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-8.2.0.tgz", + "integrity": "sha512-F9DjY1vKLo/tPePDycuH3dn9H1OTPIkVD9Kz4LODu+F2C75mgjAJ7x/gwy6ZcSNRAAkhNlJSOHRe8k3p+K9WhA==", + "dev": true, + "dependencies": { + "regenerate": "^1.4.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regenerator-runtime": { + "version": "0.13.7", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", + "integrity": "sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==", + "dev": true + }, + "node_modules/regenerator-transform": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.14.5.tgz", + "integrity": "sha512-eOf6vka5IO151Jfsw2NO9WpGX58W6wWmefK3I1zEGr0lOD0u8rwPaNqQL1aRxUaxLeKO3ArNh3VYg1KbaD+FFw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.8.4" + } + }, + "node_modules/regexpp": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", + "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/mysticatea" + } + }, + "node_modules/regexpu-core": { + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.7.1.tgz", + "integrity": "sha512-ywH2VUraA44DZQuRKzARmw6S66mr48pQVva4LBeRhcOltJ6hExvWly5ZjFLYo67xbIxb6W1q4bAGtgfEl20zfQ==", + "dev": true, + "dependencies": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^8.2.0", + "regjsgen": "^0.5.1", + "regjsparser": "^0.6.4", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.2.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/regjsgen": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.5.2.tgz", + "integrity": "sha512-OFFT3MfrH90xIW8OOSyUrk6QHD5E9JOTeGodiJeBS3J6IwlgzJMNE/1bZklWz5oTg+9dCMyEetclvCVXOPoN3A==", + "dev": true + }, + "node_modules/regjsparser": { + "version": "0.6.9", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.6.9.tgz", + "integrity": "sha512-ZqbNRz1SNjLAiYuwY0zoXW8Ne675IX5q+YHioAGbCw4X96Mjl2+dcX9B2ciaeyYjViDAfvIjFpQjJgLttTEERQ==", + "dev": true, + "dependencies": { + "jsesc": "~0.5.0" + }, + "bin": { + "regjsparser": "bin/parser" + } + }, + "node_modules/regjsparser/node_modules/jsesc": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-0.5.0.tgz", + "integrity": "sha1-597mbjXW/Bb3EP6R1c9p9w8IkR0=", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + } + }, + "node_modules/require-from-string": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", + "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/ripemd160": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-2.0.2.tgz", + "integrity": "sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA==", + "dev": true, + "dependencies": { + "hash-base": "^3.0.0", + "inherits": "^2.0.1" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "node_modules/saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "dependencies": { + "sparse-bitfield": "^3.0.3" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/sha.js": { + "version": "2.4.11", + "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.11.tgz", + "integrity": "sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "safe-buffer": "^5.0.1" + }, + "bin": { + "sha.js": "bin.js" + } + }, + "node_modules/shasum-object": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shasum-object/-/shasum-object-1.0.0.tgz", + "integrity": "sha512-Iqo5rp/3xVi6M4YheapzZhhGPVs0yZwHj7wvwQ1B9z8H6zk+FEnI7y3Teq7qwnekfEhu8WmG2z0z4iWZaxLWVg==", + "dev": true, + "dependencies": { + "fast-safe-stringify": "^2.0.7" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/shell-quote": { + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz", + "integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg==", + "dev": true + }, + "node_modules/simple-concat": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", + "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/slice-ansi": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", + "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "astral-regex": "^2.0.0", + "is-fullwidth-code-point": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/slice-ansi?sponsor=1" + } + }, + "node_modules/slice-ansi/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/slice-ansi/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/slice-ansi/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha1-/0rm5oZWBWuks+eSqzM004JzyhE=", + "optional": true, + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true + }, + "node_modules/stream-browserify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-3.0.0.tgz", + "integrity": "sha512-H73RAHsVBapbim0tU2JwwOiXUj+fikfiaoYAKHF3VJfA0pe2BCzkhAHBlLG6REzE+2WNZcxOXjK7lkso+9euLA==", + "dev": true, + "dependencies": { + "inherits": "~2.0.4", + "readable-stream": "^3.5.0" + } + }, + "node_modules/stream-browserify/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-combiner2": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/stream-combiner2/-/stream-combiner2-1.1.1.tgz", + "integrity": "sha1-+02KFCDqNidk4hrUeAOXvry0HL4=", + "dev": true, + "dependencies": { + "duplexer2": "~0.1.0", + "readable-stream": "^2.0.2" + } + }, + "node_modules/stream-http": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz", + "integrity": "sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A==", + "dev": true, + "dependencies": { + "builtin-status-codes": "^3.0.0", + "inherits": "^2.0.4", + "readable-stream": "^3.6.0", + "xtend": "^4.0.2" + } + }, + "node_modules/stream-http/node_modules/readable-stream": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/stream-splicer": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/stream-splicer/-/stream-splicer-2.0.1.tgz", + "integrity": "sha512-Xizh4/NPuYSyAXyT7g8IvdJ9HJpxIGL9PjyhtywCZvvP0OPIdqyrr4dMikeuvY8xahpdKEBlBTySe583totajg==", + "dev": true, + "dependencies": { + "inherits": "^2.0.1", + "readable-stream": "^2.0.2" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", + "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", + "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", + "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", + "dev": true, + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/subarg": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/subarg/-/subarg-1.0.0.tgz", + "integrity": "sha1-9izxdYHplrSPyWVpn1TAauJouNI=", + "dev": true, + "dependencies": { + "minimist": "^1.1.0" + } + }, + "node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/syntax-error": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", + "integrity": "sha512-YPPlu67mdnHGTup2A8ff7BC2Pjq0e0Yp/IyTFN03zWO0RcK07uLcbi7C2KpGR2FvWbaB0+bfE27a+sBKebSo7w==", + "dev": true, + "dependencies": { + "acorn-node": "^1.2.0" + } + }, + "node_modules/table": { + "version": "6.7.1", + "resolved": "https://registry.npmjs.org/table/-/table-6.7.1.tgz", + "integrity": "sha512-ZGum47Yi6KOOFDE8m223td53ath2enHcYLgOCjGr5ngu8bdIARQk6mN/wRMv4yMRcHnCSnHbCEha4sobQx5yWg==", + "dev": true, + "dependencies": { + "ajv": "^8.0.1", + "lodash.clonedeep": "^4.5.0", + "lodash.truncate": "^4.4.2", + "slice-ansi": "^4.0.0", + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/table/node_modules/ajv": { + "version": "8.6.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.6.2.tgz", + "integrity": "sha512-9807RlWAgT564wT+DjeyU5OFMPjmzxVobvDFmNAhY+5zD6A2ly3jDp6sgnfyDtlIQ+7H97oc/DGCzzfu9rjw9w==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "json-schema-traverse": "^1.0.0", + "require-from-string": "^2.0.2", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/table/node_modules/json-schema-traverse": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", + "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", + "dev": true + }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", + "dev": true + }, + "node_modules/through": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true + }, + "node_modules/through2": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.5.tgz", + "integrity": "sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ==", + "dev": true, + "dependencies": { + "readable-stream": "~2.3.6", + "xtend": "~4.0.1" + } + }, + "node_modules/timers-browserify": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-1.4.2.tgz", + "integrity": "sha1-ycWLV1voQHN1y14kYtrO50NZ9B0=", + "dev": true, + "dependencies": { + "process": "~0.11.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/tty-browserify": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.1.tgz", + "integrity": "sha512-C3TaO7K81YvjCgQH9Q1S3R3P3BtN3RIM8n+OvX4il1K1zgE8ZhI0op7kClgkxtutIE8hQrcrHBXvIheqKUUCxw==", + "dev": true + }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/type-fest": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", + "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typedarray": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", + "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", + "dev": true + }, + "node_modules/umd": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/umd/-/umd-3.0.3.tgz", + "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", + "dev": true, + "bin": { + "umd": "bin/cli.js" + } + }, + "node_modules/unbox-primitive": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", + "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1", + "has-bigints": "^1.0.1", + "has-symbols": "^1.0.2", + "which-boxed-primitive": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/undeclared-identifiers": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/undeclared-identifiers/-/undeclared-identifiers-1.1.3.tgz", + "integrity": "sha512-pJOW4nxjlmfwKApE4zvxLScM/njmwj/DiUBv7EabwE4O8kRUy+HIwxQtZLBPll/jx1LJyBcqNfB3/cpv9EZwOw==", + "dev": true, + "dependencies": { + "acorn-node": "^1.3.0", + "dash-ast": "^1.0.0", + "get-assigned-identifiers": "^1.2.0", + "simple-concat": "^1.0.0", + "xtend": "^4.0.1" + }, + "bin": { + "undeclared-identifiers": "bin.js" + } + }, + "node_modules/unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dev": true, + "dependencies": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-match-property-value-ecmascript": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.2.0.tgz", + "integrity": "sha512-wjuQHGQVofmSJv1uVISKLE5zO2rNGzM/KCYZch/QQvez7C1hUhBIuZ701fYXExuufJFMPhv2SyL8CyoIfMLbIQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/unicode-property-aliases-ecmascript": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.1.0.tgz", + "integrity": "sha512-PqSoPh/pWetQ2phoj5RLiaqIk4kCNwoV3CI+LfGmWLKI3rE3kl1h59XpX2BjgDrmbxD9ARtQobPGU1SguCYuQg==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/uri-js/node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "dependencies": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + }, + "node_modules/url/node_modules/punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + }, + "node_modules/util": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.4.tgz", + "integrity": "sha512-bxZ9qtSlGUWSOy9Qa9Xgk11kSslpuZwaxCg4sNIDj6FLucDab2JxnHwyNTCpHMtK1MjoQiWQ6DiUMZYbSrO+Sw==", + "dev": true, + "dependencies": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "safe-buffer": "^5.1.2", + "which-typed-array": "^1.1.2" + } + }, + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" + }, + "node_modules/v8-compile-cache": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", + "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", + "dev": true + }, + "node_modules/vm-browserify": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz", + "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", + "dev": true + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "dependencies": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.4.tgz", + "integrity": "sha512-49E0SpUe90cjpoc7BOJwyPHRqSAd12c10Qm2amdEZrJPCY2NDxaW01zHITrem+rnETY3dwrbH3UUrUwagfCYDA==", + "dev": true, + "dependencies": { + "available-typed-arrays": "^1.0.2", + "call-bind": "^1.0.0", + "es-abstract": "^1.18.0-next.1", + "foreach": "^2.0.5", + "function-bind": "^1.1.1", + "has-symbols": "^1.0.1", + "is-typed-array": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/word-wrap": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", + "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + }, + "node_modules/ws": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", + "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, + "node_modules/xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true, + "engines": { + "node": ">=0.4" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + } + }, "dependencies": { "@babel/code-frame": { "version": "7.14.5", @@ -1154,16 +6238,6 @@ "integrity": "sha512-wdppn25U8z/2yiaT6YGquE6X8sSv7hNMWSXYSSU1jGv/yd6XqjXgTDJ8KP4NgjTXfJ3GbRjeeb8RTV7a/VpM+w==", "dev": true }, - "JSONStream": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", - "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", - "dev": true, - "requires": { - "jsonparse": "^1.2.0", - "through": ">=2.2.7 <3" - } - }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", @@ -1174,7 +6248,8 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-node": { "version": "1.8.2", @@ -1337,7 +6412,8 @@ "version": "10.0.0", "resolved": "https://registry.npmjs.org/babelify/-/babelify-10.0.0.tgz", "integrity": "sha512-X40FaxyH7t3X+JFAKvb1H9wooWKLRCi8pg3m8poqtdZaIng+bjzp9RvKQCvRjF9isHiPkXspbbXT/zwXLtwgwg==", - "dev": true + "dev": true, + "requires": {} }, "balanced-match": { "version": "1.0.2", @@ -1388,9 +6464,9 @@ "integrity": "sha512-erYug8XoqzU3IfcU8fUgyHqyOXqIE4tUTTQ+7mqUjQlvnXkOO6OlT9c/ZoJVHYoAaqGxr09CN53G7XIsO4KtWA==", "dev": true, "requires": { - "JSONStream": "^1.0.3", "combine-source-map": "~0.8.0", "defined": "^1.0.0", + "JSONStream": "^1.0.3", "safe-buffer": "^5.1.1", "through2": "^2.0.0", "umd": "^3.0.0" @@ -1411,7 +6487,6 @@ "integrity": "sha512-SaHqzhku9v/j6XsQMRxPyBrSP3gnwmE27gLJYZgMT2GeK3J0+0toN+MnuNYDfHwVGQfLiMZ7KSNSIXHemy905w==", "dev": true, "requires": { - "JSONStream": "^1.0.3", "assert": "^1.4.0", "browser-pack": "^6.0.1", "browser-resolve": "^2.0.0", @@ -1433,6 +6508,7 @@ "https-browserify": "^1.0.0", "inherits": "~2.0.1", "insert-module-globals": "^7.2.1", + "JSONStream": "^1.0.3", "labeled-stream-splicer": "^2.0.0", "mkdirp-classic": "^0.5.2", "module-deps": "^6.2.3", @@ -1616,9 +6692,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001238", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001238.tgz", - "integrity": "sha512-bZGam2MxEt7YNsa2VwshqWQMwrYs5tR5WZQRYSuFxsBQunWjBuXhN4cS9nV5FFb1Z9y+DoQcQ0COyQbv6A+CKw==", + "version": "1.0.30001315", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001315.tgz", + "integrity": "sha512-5v7LFQU4Sb/qvkz7JcZkvtSH1Ko+1x2kgo3ocdBeMGZSOFpuE1kkm0kpTwLtWeFrw5qw08ulLxJjVIXIS8MkiQ==", "dev": true }, "chalk": { @@ -2555,11 +7631,11 @@ "integrity": "sha512-ufS5Qq9RZN+Bu899eA9QCAYThY+gGW7oRkmb0vC93Vlyu/CFGcH0OYPEjVkDXA5FEbTt1+VWzdoOD3Ny9N+8tg==", "dev": true, "requires": { - "JSONStream": "^1.0.3", "acorn-node": "^1.5.2", "combine-source-map": "^0.8.0", "concat-stream": "^1.6.1", "is-buffer": "^1.1.0", + "JSONStream": "^1.0.3", "path-is-absolute": "^1.0.1", "process": "~0.11.0", "through2": "^2.0.0", @@ -2755,6 +7831,16 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, + "JSONStream": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz", + "integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==", + "dev": true, + "requires": { + "jsonparse": "^1.2.0", + "through": ">=2.2.7 <3" + } + }, "labeled-stream-splicer": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/labeled-stream-splicer/-/labeled-stream-splicer-2.0.2.tgz", @@ -2888,7 +7974,6 @@ "integrity": "sha512-fg7OZaQBcL4/L+AK5f4iVqf9OMbCclXfy/znXRxTVhJSeW5AIlS9AwheYwDaXM3lVW7OBeaeUEY3gbaC6cLlSA==", "dev": true, "requires": { - "JSONStream": "^1.0.3", "browser-resolve": "^2.0.0", "cached-path-relative": "^1.0.2", "concat-stream": "~1.6.0", @@ -2896,6 +7981,7 @@ "detective": "^5.2.0", "duplexer2": "^0.1.2", "inherits": "^2.0.1", + "JSONStream": "^1.0.3", "parents": "^1.0.0", "readable-stream": "^2.0.2", "resolve": "^1.4.0", @@ -3512,6 +8598,15 @@ "readable-stream": "^2.0.2" } }, + "string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dev": true, + "requires": { + "safe-buffer": "~5.2.0" + } + }, "string-width": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", @@ -3543,15 +8638,6 @@ "define-properties": "^1.1.3" } }, - "string_decoder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", - "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, - "requires": { - "safe-buffer": "~5.2.0" - } - }, "strip-ansi": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", @@ -3869,7 +8955,8 @@ "ws": { "version": "7.5.0", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", - "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==" + "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==", + "requires": {} }, "xtend": { "version": "4.0.2", diff --git a/package.json b/package.json index 3a090cc..7d3148c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "esiur", - "version": "1.8.2", + "version": "2.0.0", "description": "Distributed Object Framework", "main": "esiur.js", "type": "module", @@ -9,7 +9,6 @@ "babel": "./node_modules/.bin/babel src -d build", "build": "browserify src/esiur.js -t babelify --outfile build/esiur.js", "prepublish": "browserify src/esiur.js -t babelify --outfile build/esiur.js" - }, "repository": { "type": "git", diff --git a/src/Core/AsyncQueue.js b/src/Core/AsyncQueue.js index ae06403..2aec76a 100644 --- a/src/Core/AsyncQueue.js +++ b/src/Core/AsyncQueue.js @@ -71,7 +71,6 @@ export default class AsyncQueue extends AsyncReply remove(reply) { - console.log("REMOVE QUEUE"); this.list.splice(this.list.indexOf(reply), 1); this.processQueue(); } diff --git a/src/Core/AsyncReply.js b/src/Core/AsyncReply.js index 84c223a..23201a3 100644 --- a/src/Core/AsyncReply.js +++ b/src/Core/AsyncReply.js @@ -153,7 +153,7 @@ export default class AsyncReply extends Promise this.chunkCallbacks = []; this.exception = new AsyncException();// null; - var self = this; + //var self = this; if (result !== undefined && !(result instanceof Function)) { this.result = result; diff --git a/src/Data/BinaryList.js b/src/Data/BinaryList.js index 3baad04..171cd32 100644 --- a/src/Data/BinaryList.js +++ b/src/Data/BinaryList.js @@ -26,8 +26,7 @@ "use strict"; -import DataType from './DataType.js'; -import DC from './DataConverter.js'; +import DC from './DC.js'; export default class BinaryList { @@ -35,216 +34,198 @@ export default class BinaryList constructor() { this.list = []; + //this.data = []; } - - addRange(bl) - { - for(var i = 0; i < bl.list.length; i++) - this.list.push(bl.list[i]); - + addDateTime(value, endian) { + this.addDC(DC.dateTimeToBytes(value, endian)); return this; } - - add(typedValue, position) - { - if (position !== undefined) - this.list.splice(position, 0, typedValue); - else - this.list.push(typedValue); + + insertDateTime(position, value, endian) { + this.insertDC(position, DC.dateTimeToBytes(value, endian)); return this; } + + addDateTimeArray(value, endian) { + this.addDC(DC.dateTimeArrayToBytes(value, endian)); + return this; + } + + insertDateTimeArray(position, value, endian) { + this.insertDC(position, DC.dateTimeArrayToBytes(value, endian)); + return this; + } + + addGuid(value) { + this.addDC(DC.guidToBytes(value)); + return this; + } + + insertGuid(position, value) { + this.insertDC(position, DC.guidToBytes(value)); + return this; + } + + addUint8Array(value) { + this.addDC(value); + return this; + } + + addDC(value) { + this.list.push(...value); + return this; + } + + insertUint8Array(position, value) { + this.insertDC(position, value); + return this; + } + + addString(value) { + this.addDC(DC.stringToBytes(value)); + return this; + } + + insertString(position, value) { + this.insertDC(position, DC.stringToBytes(value)); + return this; + } + + insertUint8(position, value) { + this.list.splice(position, 0, value); + return this; + } + + addUint8(value) { + this.list.push(value); + return this; + } + + addInt8(value) { + this.list.push(value); + return this; + } + + insertInt8(position, value) { + this.list.splice(position, 0, value); + return this; + } + + addChar(value) { + this.addDC(DC.charToBytes(value)); + return this; + } + + insertChar(position, value) { + this.insertDC(position, DC.charToBytes(value)); + return this; + } + + addBoolean(value) { + this.addDC(DC.boolToBytes(value)); + return this; + } + + insertBoolean(position, value) { + this.insertDC(position, DC.boolToBytes(value)); + return this; + } + + addUint16(value, endian) { + this.addDC(DC.uint16ToBytes(value, endian)); + return this; + } + + insertUint16(position, value, endian) { + this.insertDC(position, DC.uint16ToBytes(value, endian)); + return this; + } + + addInt16(value, endian) { + this.addDC(DC.int16ToBytes(value, endian)); + return this; + } + + insertInt16(position, value, endian) { + this.insertDC(position, DC.int16ToBytes(value, endian)); + return this; + } + + addUint32(value, endian) { + this.addDC(DC.uint32ToBytes(value, endian)); + return this; + } + + insertUint32(position, value, endian ) { + this.insertDC(position, DC.uint32ToBytes(value, endian)); + return this; + } + + addInt32(value, endian) { + this.addDC(DC.int32ToBytes(value, endian)); + return this; + } + + insertInt32(position, value, endian) { + this.insertDC(position, DC.int32ToBytes(value, endian)); + return this; + } + + addUint64(value, endian) { + this.addDC(DC.uint64ToBytes(value, endian)); + return this; + } + + insertUint64( position, value, endian) { + this.insertDC(position, DC.uint64ToBytes(value, endian)); + return this; + } + + addInt64(value, endian) { + this.addDC(DC.int64ToBytes(value, endian)); + return this; + } + + insertInt64(position, value, endian) { + this.insertDC(position, DC.int64ToBytes(value, endian)); + return this; + } + + addFloat32(value, endian) { + this.addDC(DC.float32ToBytes(value, endian)); + return this; + } + + insertFloat32(position, value, endian ) { + this.insertDC(position, DC.float32ToBytes(value, endian)); + return this; + } + + addFloat64(value, endian) { + this.addDC(DC.float64ToBytes(value, endian)); + return this; + } + + insertFloat64(position, value, endian) { + this.insertDC(position, DC.float64ToBytes(value, endian)); + return this; + } + + get length() { - return this.toArray().length; + return this.list.length; } toArray() { - var ars = []; - // calculate length - for(var i = 0; i < this.list.length; i++) - { - switch (this.list[i].type) - { - case DataType.Bool: - ars.push(DC.boolToBytes(this.list[i].value)); - break; - case DataType.UInt8: - ars.push(DC.uint8ToBytes(this.list[i].value)); - break; - case DataType.Int8: - ars.push(DC.int8ToBytes(this.list[i].value)); - break; - case DataType.Char: - ars.push(DC.charToBytes(this.list[i].value)); - break; - case DataType.UInt16: - ars.push(DC.uint16ToBytes(this.list[i].value)); - break; - case DataType.Int16: - ars.push(DC.int16ToBytes(this.list[i].value)); - break; - case DataType.UInt32: - ars.push(DC.uint32ToBytes(this.list[i].value)); - break; - case DataType.Int32: - ars.push(DC.int32ToBytes(this.list[i].value)); - break; - case DataType.UInt64: - ars.push(DC.uint64ToBytes(this.list[i].value)); - break; - case DataType.Int64: - ars.push(DC.int64ToBytes(this.list[i].value)); - break; - case DataType.Float32: - ars.push(DC.float32ToBytes(this.list[i].value)); - break; - case DataType.Float64: - ars.push(DC.float64ToBytes(this.list[i].value)); - break; - case DataType.String: - ars.push(DC.stringToBytes(this.list[i].value)); - break; - case DataType.DateTime: - ars.push(DC.dateTimeToBytes(this.list[i].value)); - break; - case DataType.UInt8Array: - ars.push(this.list[i].value); - break; - - case DataType.UInt16Array: - ars.push(DC.uint16ArrayToBytes(this.list[i].value)); - break; - - case DataType.UInt32Array: - ars.push(DC.uint32ArrayToBytes(this.list[i].value)); - break; - - case DataType.Int16Array: - ars.push(DC.int16ArrayToBytes(this.list[i].value)); - break; - - case DataType.Int32Array: - ars.push(DC.int32ArrayToBytes(this.list[i].value)); - break; - - case DataType.Float32Array: - ars.push(DC.float32ArrayToBytes(this.list[i].value)); - break; - - case DataType.Float64Array: - ars.push(DC.float64ArrayToBytes(this.list[i].value)); - break; - - //case DataType.Resource: - // ars.push(DC.uint32ToBytes(this.list[i].value.instance.id)); - // break; - //case DataType.DistributedResource: - // ars.push(DC.int8ToBytes(this.list[i].value)); - // break; - - - - } - } - - var length = 0; - ars.forEach(function(a){ - length += a.length ;//?? a.byteLength; - }); - - var rt = new Uint8Array(length); - - var offset = 0; - for(var i = 0; i < ars.length; i++) { - rt.set(ars[i], offset); - offset+=ars[i].length;// ?? ars[i].byteLength; - } - - return rt; + return new Uint8Array(this.list); } toDC() { - return new DC(this.toArray()); + return new DC(this.list); } - - addDateTime(value, position) - { - return this.add({type: DataType.DateTime, value: value}, position); - } - - addUint8Array(value, position) - { - return this.add({type: DataType.UInt8Array, value: value}, position); - } - - - addHex(value, position) - { - return this.addUint8Array(DC.hexToBytes(value), position); - } - - addString(value, position) - { - return this.add({type: DataType.String, value: value}, position); - } - - addUint8(value, position) - { - return this.add({type: DataType.UInt8, value: value}, position); - } - - addInt8(value, position) - { - return this.add({type: DataType.Int8, value: value}, position); - } - - addChar(value, position) - { - return this.add({type: DataType.Char, value: value}, position); - } - - addUint16(value, position) - { - return this.add({type: DataType.UInt16, value: value}, position); - } - - addInt16(value, position) - { - return this.add({type: DataType.Int16, value: value}, position); - } - - addUint32(value, position) - { - return this.add({type: DataType.UInt32, value: value}, position); - } - - addInt32(value, position) - { - return this.add({type: DataType.Int32, value: value}, position); - } - - addUint64(value, position) - { - return this.add({type: DataType.UInt64, value: value}, position); - } - - addInt64(value, position) - { - return this.add({type: DataType.Int64, value: value}, position); - } - - addFloat32(value, position) - { - return this.add({type: DataType.Float32, value: value}, position); - } - - addFloat64(value, position) - { - return this.add({type: DataType.Float64, value: value}, position); - } - } \ No newline at end of file diff --git a/src/Data/Codec.js b/src/Data/Codec.js index 389290c..34a1c47 100644 --- a/src/Data/Codec.js +++ b/src/Data/Codec.js @@ -34,7 +34,7 @@ import AsyncBag from '../Core/AsyncBag.js'; import AsyncReply from '../Core/AsyncReply.js'; import Structure from './Structure.js'; import PropertyValue from './PropertyValue.js'; -import {DC, BL} from './DataConverter.js'; +import {DC, BL} from './DC.js'; import BinaryList from './BinaryList.js'; import DistributedPropertyContext from '../Net/IIP/DistributedPropertyContext.js'; import DistributedResource from '../Net/IIP/DistributedResource.js' @@ -49,1281 +49,1570 @@ import NotModified from './NotModified.js'; import KeyList from './KeyList.js'; import StructureArray from './StructureArray.js'; -export default class Codec { - static parse(data, offset, sizeObject, connection, dataType = DataType.Unspecified) { +import DataSerializer from './DataSerializer.js'; +import DataDeserializer from './DataDeserializer.js'; +import TypedList from './TypedList.js'; +import TypedMap from './TypedMap.js'; +import IEnum from './IEnum.js'; - var size; +import {TransmissionType, TransmissionTypeIdentifier, TransmissionTypeClass} from './TransmissionType.js'; - //var reply = new AsyncReply(); +import { Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128, Float32, Float64, Float128, Char16, Char8 } from './ExtendedTypes.js'; - var isArray; - var t; +import PropertyValueArray from './PropertyValueArray.js'; +import RecordArray from './RecordArray.js'; +import ResourceArray from './ResourceArray.js'; +import Tuple from './Tuple.js'; - if (dataType == DataType.Unspecified) { - size = 1; - dataType = data[offset++]; - } - else - size = 0; +// export default class Codec { - t = dataType & 0x7F; +// static parse(data, offset, sizeObject, connection, dataType = DataType.Unspecified) { - isArray = (dataType & 0x80) == 0x80; +// var size; - var payloadSize = DataType.sizeOf(dataType); +// //var reply = new AsyncReply(); - var contentLength = 0; +// var isArray; +// var t; - // check if we have the enough data - if (payloadSize == -1) { - contentLength = data.getUint32(offset); - offset += 4; - size += 4 + contentLength; - } - else - size += payloadSize; +// if (dataType == DataType.Unspecified) { +// size = 1; +// dataType = data[offset++]; +// } +// else +// size = 0; +// t = dataType & 0x7F; - sizeObject.size = size; +// isArray = (dataType & 0x80) == 0x80; - if (isArray) { - switch (t) { - // VarArray ? - case DataType.Void: - return Codec.parseVarArray(data, offset, contentLength, connection); +// var payloadSize = DataType.sizeOf(dataType); - case DataType.Bool: - return new AsyncReply(data.getBooleanArray(offset, contentLength)); +// var contentLength = 0; - case DataType.UInt8: - return new AsyncReply(data.getUint8Array(offset, contentLength)); +// // check if we have the enough data +// if (payloadSize == -1) { +// contentLength = data.getUint32(offset); +// offset += 4; +// size += 4 + contentLength; +// } +// else +// size += payloadSize; - case DataType.Int8: - return new AsyncReply(data.getInt8Array(offset, contentLength)); - case DataType.Char: - return new AsyncReply(data.getCharArray(offset, contentLength)); +// sizeObject.size = size; - case DataType.Int16: - return new AsyncReply(data.getInt16Array(offset, contentLength)); +// if (isArray) { +// switch (t) { +// // VarArray ? +// case DataType.Void: +// return Codec.parseVarArray(data, offset, contentLength, connection); - case DataType.UInt16: - return new AsyncReply(data.getUint16Array(offset, contentLength)); +// case DataType.Bool: +// return new AsyncReply(data.getBooleanArray(offset, contentLength)); - case DataType.Int32: - return new AsyncReply(data.getInt32Array(offset, contentLength)); +// case DataType.UInt8: +// return new AsyncReply(data.getUint8Array(offset, contentLength)); - case DataType.UInt32: - return new AsyncReply(data.getUint32Array(offset, contentLength)); +// case DataType.Int8: +// return new AsyncReply(data.getInt8Array(offset, contentLength)); - case DataType.Int64: - return new AsyncReply(data.getInt64Array(offset, contentLength)); +// case DataType.Char: +// return new AsyncReply(data.getCharArray(offset, contentLength)); - case DataType.UInt64: - return new AsyncReply(data.getUint64Array(offset, contentLength)); +// case DataType.Int16: +// return new AsyncReply(data.getInt16Array(offset, contentLength)); - case DataType.Float32: - return new AsyncReply(data.getFloat32Array(offset, contentLength)); +// case DataType.UInt16: +// return new AsyncReply(data.getUint16Array(offset, contentLength)); - case DataType.Float64: - return new AsyncReply(data.getFloat64Array(offset, contentLength)); +// case DataType.Int32: +// return new AsyncReply(data.getInt32Array(offset, contentLength)); - case DataType.String: - return new AsyncReply(data.getStringArray(offset, contentLength)); +// case DataType.UInt32: +// return new AsyncReply(data.getUint32Array(offset, contentLength)); - case DataType.Resource: - case DataType.DistributedResource: - return Codec.parseResourceArray(data, offset, contentLength, connection); +// case DataType.Int64: +// return new AsyncReply(data.getInt64Array(offset, contentLength)); - case DataType.DateTime: - return new AsyncReply(data.getDateTimeArray(offset, contentLength)); +// case DataType.UInt64: +// return new AsyncReply(data.getUint64Array(offset, contentLength)); - case DataType.Structure: - return Codec.parseStructureArray(data, offset, contentLength, connection); +// case DataType.Float32: +// return new AsyncReply(data.getFloat32Array(offset, contentLength)); - case DataType.Record: - return Codec.parseRecordArray(data, offset, contentLength, connection); - } - } - else { - switch (t) { - case DataType.NotModified: - return new AsyncReply(new NotModified()); +// case DataType.Float64: +// return new AsyncReply(data.getFloat64Array(offset, contentLength)); - case DataType.Void: - return new AsyncReply(null); +// case DataType.String: +// return new AsyncReply(data.getStringArray(offset, contentLength)); - case DataType.Bool: - return new AsyncReply(data.getBoolean(offset)); +// case DataType.Resource: +// case DataType.DistributedResource: +// return Codec.parseResourceArray(data, offset, contentLength, connection); - case DataType.UInt8: - return new AsyncReply(data[offset]); +// case DataType.DateTime: +// return new AsyncReply(data.getDateTimeArray(offset, contentLength)); - case DataType.Int8: - return new AsyncReply(data.getInt8(offset)); +// case DataType.Structure: +// return Codec.parseStructureArray(data, offset, contentLength, connection); - case DataType.Char: - return new AsyncReply(data.getChar(offset)); +// case DataType.Record: +// return Codec.parseRecordArray(data, offset, contentLength, connection); +// } +// } +// else { +// switch (t) { +// case DataType.NotModified: +// return new AsyncReply(new NotModified()); - case DataType.Int16: - return new AsyncReply(data.getInt16(offset)); +// case DataType.Void: +// return new AsyncReply(null); - case DataType.UInt16: - return new AsyncReply(data.getUint16(offset)); +// case DataType.Bool: +// return new AsyncReply(data.getBoolean(offset)); - case DataType.Int32: - return new AsyncReply(data.getInt32(offset)); +// case DataType.UInt8: +// return new AsyncReply(data[offset]); - case DataType.UInt32: - return new AsyncReply(data.getUint32(offset)); +// case DataType.Int8: +// return new AsyncReply(data.getInt8(offset)); - case DataType.Int64: - return new AsyncReply(data.getInt64(offset)); +// case DataType.Char: +// return new AsyncReply(data.getChar(offset)); - case DataType.UInt64: - return new AsyncReply(data.getUint64(offset)); +// case DataType.Int16: +// return new AsyncReply(data.getInt16(offset)); - case DataType.Float32: - return new AsyncReply(data.getFloat32(offset)); +// case DataType.UInt16: +// return new AsyncReply(data.getUint16(offset)); - case DataType.Float64: - return new AsyncReply(data.getFloat64(offset)); +// case DataType.Int32: +// return new AsyncReply(data.getInt32(offset)); - case DataType.String: - return new AsyncReply(data.getString(offset, contentLength)); +// case DataType.UInt32: +// return new AsyncReply(data.getUint32(offset)); - case DataType.Resource: - return Codec.parseResource(data, offset); +// case DataType.Int64: +// return new AsyncReply(data.getInt64(offset)); - case DataType.DistributedResource: - return Codec.parseDistributedResource(data, offset, connection); +// case DataType.UInt64: +// return new AsyncReply(data.getUint64(offset)); - case DataType.DateTime: - return new AsyncReply(data.getDateTime(offset)); +// case DataType.Float32: +// return new AsyncReply(data.getFloat32(offset)); - case DataType.Structure: - return Codec.parseStructure(data, offset, contentLength, connection); +// case DataType.Float64: +// return new AsyncReply(data.getFloat64(offset)); - case DataType.Record: - return Codec.parseRecord(data, offset, contentLength, connection); +// case DataType.String: +// return new AsyncReply(data.getString(offset, contentLength)); - } - } +// case DataType.Resource: +// return Codec.parseResource(data, offset); - // @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); - } - - /// - /// Parse an array of bytes into array of resources - /// - /// Array of bytes. - /// Number of bytes to parse. - /// Zero-indexed offset. - /// DistributedConnection is required to fetch resources. - /// Array of resources. - 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; - } - - /// - /// Compose an array of property values. - /// - /// PropertyValue array. - /// DistributedConnection is required to check locality. - /// If True, prepend the length as UInt32 at the beginning of the output. - /// Array of bytes in the network byte order. +// 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); +// } + +// /// +// /// Parse an array of bytes into array of resources +// /// +// /// Array of bytes. +// /// Number of bytes to parse. +// /// Zero-indexed offset. +// /// DistributedConnection is required to fetch resources. +// /// Array of resources. +// 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; +// } + +// /// +// /// Compose an array of property values. +// /// +// /// PropertyValue array. +// /// DistributedConnection is required to check locality. +// /// If True, prepend the length as UInt32 at the beginning of the output. +// /// Array of bytes in the network byte order. - 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(); - } +// 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(); +// } - /// - /// Compose a property value. - /// - /// Property value - /// DistributedConnection is required to check locality. - /// Array of bytes in the network byte order. - static composePropertyValue(propertyValue, connection) - { - // age, date, value - return BL().addUint64(propertyValue.age) - .addDateTime(propertyValue.date) - .addUint8Array(Codec.compose(propertyValue.value, connection)) - .toArray(); - } +// /// +// /// Compose a property value. +// /// +// /// Property value +// /// DistributedConnection is required to check locality. +// /// Array of bytes in the network byte order. +// static composePropertyValue(propertyValue, connection) +// { +// // age, date, value +// return BL().addUint64(propertyValue.age) +// .addDateTime(propertyValue.date) +// .addUint8Array(Codec.compose(propertyValue.value, connection)) +// .toArray(); +// } - /// - /// Parse property value. - /// - /// Array of bytes. - /// Zero-indexed offset. - /// DistributedConnection is required to fetch resources. - /// Output content size. - /// PropertyValue. - static parsePropertyValue(data, offset, sizeObject, connection) - { - var reply = new AsyncReply(); +// /// +// /// Parse property value. +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// DistributedConnection is required to fetch resources. +// /// Output content size. +// /// PropertyValue. +// static parsePropertyValue(data, offset, sizeObject, connection) +// { +// var reply = new AsyncReply(); - var age = data.getUint64(offset); - offset += 8; +// var age = data.getUint64(offset); +// offset += 8; - var date = data.getDateTime(offset); - offset += 8; +// var date = data.getDateTime(offset); +// offset += 8; - var cs = {}; +// var cs = {}; - Codec.parse(data, offset, cs, connection).then(function(value) - { - reply.trigger(new PropertyValue(value, age, date)); - }); +// Codec.parse(data, offset, cs, connection).then(function(value) +// { +// reply.trigger(new PropertyValue(value, age, date)); +// }); - sizeObject.size = 16 + cs.size; - return reply; - } +// sizeObject.size = 16 + cs.size; +// return reply; +// } - /// - /// Parse resource history - /// - /// Array of bytes. - /// Zero-indexed offset. - /// Number of bytes to parse. - /// Resource - /// Starting age. - /// Ending age. - /// DistributedConnection is required to fetch resources. - /// - static parseHistory(data, offset, length, resource, connection) - { - var list = new KeyList(); +// /// +// /// Parse resource history +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// Number of bytes to parse. +// /// Resource +// /// Starting age. +// /// Ending age. +// /// DistributedConnection is required to fetch resources. +// /// +// static parseHistory(data, offset, length, resource, connection) +// { +// var list = new KeyList(); - var reply = new AsyncReply(); +// var reply = new AsyncReply(); - var bagOfBags = new AsyncBag(); +// var bagOfBags = new AsyncBag(); - var ends = offset + length; - while (offset < ends) - { - var index = data[offset++]; - var pt = resource.instance.template.getPropertyTemplateByIndex(index); +// var ends = offset + length; +// while (offset < ends) +// { +// var index = data[offset++]; +// var pt = resource.instance.template.getPropertyTemplateByIndex(index); - list.add(pt, null); +// list.add(pt, null); - var cs = data.getUint32(offset); - offset += 4; - bagOfBags.add(Codec.parsePropertyValueArray(data, offset, cs, connection)); - offset += cs; - } +// var cs = data.getUint32(offset); +// offset += 4; +// bagOfBags.add(Codec.parsePropertyValueArray(data, offset, cs, connection)); +// offset += cs; +// } - bagOfBags.seal(); +// bagOfBags.seal(); - bagOfBags.then(x => - { - for(var i = 0; i < list.length; i++) - list.values[i] = x[i]; +// bagOfBags.then(x => +// { +// for(var i = 0; i < list.length; i++) +// list.values[i] = x[i]; - reply.trigger(list); - }); +// reply.trigger(list); +// }); - return reply; +// return reply; - } +// } - /// - /// Compose resource history - /// - /// History - /// DistributedConnection is required to fetch resources. - /// - static composeHistory(history, connection, prependLength = false) - { - var rt = new BinaryList(); +// /// +// /// Compose resource history +// /// +// /// History +// /// DistributedConnection is required to fetch resources. +// /// +// 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)); +// 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); +// if (prependLength) +// rt.addUint32(rt.length, 0); - return rt.toArray(); - } +// return rt.toArray(); +// } - /// - /// Parse an array of ProperyValue. - /// - /// Array of bytes. - /// Zero-indexed offset. - /// Number of bytes to parse. - /// DistributedConnection is required to fetch resources. - /// - static parsePropertyValueArray(data, offset, length, connection) - { - var rt = new AsyncBag(); +// /// +// /// Parse an array of ProperyValue. +// /// +// /// Array of bytes. +// /// Zero-indexed offset. +// /// Number of bytes to parse. +// /// DistributedConnection is required to fetch resources. +// /// +// static parsePropertyValueArray(data, offset, length, connection) +// { +// var rt = new AsyncBag(); - while (length > 0) - { - var cs = {}; +// while (length > 0) +// { +// var cs = {}; - rt.add(Codec.parsePropertyValue(data, offset, cs, connection)); +// 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"); - } +// if (cs.size > 0) +// { +// offset += cs.size; +// length -= cs.size; +// } +// else +// throw new Error("Error while parsing ValueInfo structured data"); +// } - rt.seal(); - return rt; - } +// rt.seal(); +// return rt; +// } - static parseStructure(data, offset, contentLength, connection, metadata = null, keys = null, types = null) - { - var reply = new AsyncReply(); - var bag = new AsyncBag(); +// static parseStructure(data, offset, contentLength, connection, metadata = null, keys = null, types = null) +// { +// var reply = new AsyncReply(); +// var bag = new AsyncBag(); - var keylist = []; - var typelist = []; +// var keylist = []; +// var typelist = []; - if (keys == null) { - while (contentLength > 0) { - var len = data[offset++]; - keylist.push(data.getString(offset, len)); - offset += len; +// if (keys == null) { +// while (contentLength > 0) { +// var len = data[offset++]; +// keylist.push(data.getString(offset, len)); +// offset += len; - typelist.push(data[offset]); +// 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]); +// 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]); +// while (contentLength > 0) { +// typelist.push(data[offset]); - let rt = {}; - bag.add(Codec.parse(data, offset, rt, connection)); - contentLength -= rt.size; - offset += rt.size; - } - } - else { +// 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]); - } +// 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++; - } - } +// 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.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); - }); +// 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; - } +// if (metadata != null) +// { +// metadata.keys = keylist; +// metadata.types = typelist; +// } - return reply; - } +// return reply; +// } - static parseVarArray(data, offset, contentLength, connection) { - var rt = new AsyncBag(); +// static parseVarArray(data, offset, contentLength, connection) { +// var rt = new AsyncBag(); - while (contentLength > 0) { - var cs = {}; +// while (contentLength > 0) { +// var cs = {}; - rt.add(Codec.parse(data, offset, cs, connection)); +// 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"); +// if (cs.size > 0) { +// offset += cs.size; +// contentLength -= cs.size; +// } +// else +// throw new Error("Error while parsing structured data"); - } +// } - rt.seal(); - return rt; - } +// rt.seal(); +// return rt; +// } - static compose(value, connection, prependType = true) { +// static compose(value, connection, prependType = true) { - if (value instanceof Function) - value = value(connection); - else if (value instanceof DistributedPropertyContext) - value = value.method(this); +// 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(); +// var type = Codec.getDataType(value, connection); +// var rt = new BinaryList(); - switch (type) { - case DataType.Void: - // nothing to do; - break; +// 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.String: +// var st = DC.stringToBytes(value); +// rt.addUint32(st.length).addUint8Array(st); +// break; - case DataType.Resource: - rt.addUint32(value._p.instanceId); - 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.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.Structure: +// rt.addUint8Array(Codec.composeStructure(value, connection, true, true, true)); +// break; - case DataType.VarArray: - rt.addUint8Array(Codec.composeVarArray(value, connection, 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.Record: +// rt.addUint8Array(Codec.composeRecord(value, connection, true, true)); +// break; - case DataType.ResourceArray: - rt.addUint8Array(Codec.composeResourceArray(value, connection, 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.StructureArray: +// rt.addUint8Array(Codec.composeStructureArray(value, connection, true)); +// break; - case DataType.RecordArray: - rt.addUint8Array(Codec.composeRecordArray(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); +// default: +// rt.add({type: type, value: value}); +// if (DataType.isArray(type)) +// rt.addUint32(rt.length, 0); - break; - } +// break; +// } - if (prependType) - rt.addUint8(type, 0); +// if (prependType) +// rt.addUint8(type, 0); - return rt.toArray(); - } +// return rt.toArray(); +// } - static composeVarArray(array, connection, prependLength = false) { - var rt = new BinaryList(); +// 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)); +// 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(); - } +// if (prependLength) +// rt.addUint32(rt.length, 0); +// return rt.toArray(); +// } - static composeStructure(value, connection, includeKeys = true, includeTypes = true, prependLength = false) { - let rt = new BinaryList(); +// static composeStructure(value, connection, includeKeys = true, includeTypes = true, prependLength = false) { +// let rt = new BinaryList(); - let keys = value.getKeys(); +// 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 (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); +// if (prependLength) +// rt.addUint32(rt.length, 0); - return rt.toArray(); - } +// return rt.toArray(); +// } - static composeStructureArray(structures, connection, prependLength = false) { - if (structures == null || structures.length == 0 || !(structures instanceof StructureArray)) - return new DC(0); +// 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; +// var rt = new BinaryList(); +// var comparision = StructureComparisonResult.Structure; - rt.addUint8(comparision); - rt.addUint8Array(Codec.composeStructure(structures[0], connection)); +// 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); +// 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 (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); +// if (prependLength) +// rt.addUint32(rt.length, 0); - return rt.toArray(); - } +// return rt.toArray(); +// } - /// - /// Compare two records - /// - /// Initial record to compare with - /// Next record to compare with the initial - /// DistributedConnection is required in case a structure holds items at the other end - static compareRecords(initial, next) - { - if (next == null) - return RecordComparisonResult.Null; +// /// +// /// Compare two records +// /// +// /// Initial record to compare with +// /// Next record to compare with the initial +// /// DistributedConnection is required in case a structure holds items at the other end +// static compareRecords(initial, next) +// { +// if (next == null) +// return RecordComparisonResult.Null; - if (initial == null) - return RecordComparisonResult.Record; +// if (initial == null) +// return RecordComparisonResult.Record; - if (next == initial) - return RecordComparisonResult.Same; +// if (next == initial) +// return RecordComparisonResult.Same; - if (next.constructor === initial.constructor) - return RecordComparisonResult.RecordSameType; +// if (next.constructor === initial.constructor) +// return RecordComparisonResult.RecordSameType; - return RecordComparisonResult.Record; - } +// return RecordComparisonResult.Record; +// } - static parseRecordArray(data, offset, length, connection) - { +// 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); +// 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)); +// 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); +// 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; +// 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(); +// var previousKeys = previous.getKeys(); +// var nextKeys = next.getKeys(); - for (let i = 0; i < previousKeys.length; i++) - if (previousKeys[i] != nextKeys[i]) - return StructureComparisonResult.Structure; +// 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); +// 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; +// for (let i = 0; i < previousTypes.length; i++) +// if (previousTypes[i] != nextTypes[i]) +// return StructureComparisonResult.StructureSameKeys; - return StructureComparisonResult.StructureSameTypes; - } +// return StructureComparisonResult.StructureSameTypes; +// } - static getStructureDateTypes(structure, connection) { - var keys = structure.getKeys(); - var types = []; +// 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; - } +// 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; +// static isLocalResource(resource, connection) { +// if (resource instanceof DistributedResource) +// if (resource._p.connection == connection) +// return true; - return false; -} +// 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 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) { +// 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; - } +// 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) { +// static composeResourceArray(resources, connection, prependLength = false) { - if (resources == null)// || resources.length == 0)// || !(resources instanceof ResourceArray)) - return prependLength ? new DC(4) : new DC(0); +// 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); +// var rt = new BinaryList(); +// var comparsion = resources.length == 0 ? ResourceComparisonResult.Empty : Codec.compareResource(null, resources[0], connection); - rt.addUint8(comparsion); +// rt.addUint8(comparsion); - if (comparsion == ResourceComparisonResult.Local) - rt.addUint32(resources[0]._p.instanceId); - else if (comparsion == ResourceComparisonResult.Distributed) - rt.addUint32(resources[0].instance.id); +// 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); - } +// 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); +// if (prependLength) +// rt.addUint32(rt.length, 0); - return rt.toArray(); - } +// 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; - } +// 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 - } +// 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; - } - } +// default: +// return DataType.Void; +// } +// } - /// - /// Parse an array of structures - /// - /// Bytes array - /// Zero-indexed offset - /// Number of bytes to parse - /// DistributedConnection is required in case a structure in the array holds items at the other end - /// Array of structures - static parseStructureArray(data, offset, length, connection) - { - var reply = new AsyncBag(); - if (length == 0) - { - reply.seal(); - return reply; - } +// /// +// /// Parse an array of structures +// /// +// /// Bytes array +// /// Zero-indexed offset +// /// Number of bytes to parse +// /// DistributedConnection is required in case a structure in the array holds items at the other end +// /// Array of structures +// static parseStructureArray(data, offset, length, connection) +// { +// var reply = new AsyncBag(); +// if (length == 0) +// { +// reply.seal(); +// return reply; +// } - var end = offset + length; +// var end = offset + length; - var result = data[offset++]; +// var result = data[offset++]; - var previous = null; - //var previousKeys = []; - //var previousTypes = []; +// var previous = null; +// //var previousKeys = []; +// //var previousTypes = []; - var metadata = {keys: null, types: null}; +// 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; - } +// 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); +// reply.add(previous); - while (offset < end) - { - result = data[offset++]; +// 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; - } +// 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.add(previous); +// } - reply.seal(); - return reply; - } +// reply.seal(); +// return reply; +// } -} \ No newline at end of file +// } + + + + +export class CodecComposeResults { + //final int transmissionTypeIdentifier; + //final DC data; + constructor(transmissionTypeIdentifier, data) { + this.transmissionTypeIdentifier = transmissionTypeIdentifier; + this.data = data; + } +} + +export class CodecParseResults { + //final AsyncReply reply; + //final int size; + + constructor(size, reply){ + this.size = size; + this.reply = reply; + } +} + +export default class Codec { + //AsyncReply Parser(byte[] data, uint offset, uint length, DistributedConnection connection); + + static fixedParsers = [ + [ + DataDeserializer.nullParser, + DataDeserializer.booleanFalseParser, + DataDeserializer.booleanTrueParser, + DataDeserializer.notModifiedParser, + ], + [ + DataDeserializer.byteParser, + DataDeserializer.sByteParser, + DataDeserializer.char8Parser, + ], + [ + DataDeserializer.int16Parser, + DataDeserializer.uInt16Parser, + DataDeserializer.char16Parser, + ], + [ + DataDeserializer.int32Parser, + DataDeserializer.uInt32Parser, + DataDeserializer.float32Parser, + DataDeserializer.resourceParser, + DataDeserializer.localResourceParser, + ], + [ + DataDeserializer.int64Parser, + DataDeserializer.uInt64Parser, + DataDeserializer.float64Parser, + DataDeserializer.dateTimeParser, + ], + [ + DataDeserializer.int128Parser, // int 128 + DataDeserializer.uInt128Parser, // uint 128 + DataDeserializer.float128Parser, + ] + ]; + + static dynamicParsers = [ + DataDeserializer.rawDataParser, + DataDeserializer.stringParser, + DataDeserializer.listParser, + DataDeserializer.resourceListParser, + DataDeserializer.recordListParser, + ]; + + static typedParsers = [ + DataDeserializer.recordParser, + DataDeserializer.typedListParser, + DataDeserializer.typedMapParser, + DataDeserializer.tupleParser, + DataDeserializer.enumParser, + DataDeserializer.constantParser, + ]; + + /// + /// Parse a value + /// + /// Bytes array + /// Zero-indexed offset. + /// Output the number of bytes parsed + /// DistributedConnection is required in case a structure in the array holds items at the other end. + /// DataType, in case the data is not prepended with DataType + /// Value + static parse( + data, offset, connection, + dataType = null) { + + let len = 0; + + if (dataType == null) { + var parsedDataTyped = TransmissionType.parse(data, offset, data.length); + len = parsedDataTyped.size; + dataType = parsedDataTyped.type; + offset = dataType?.offset ?? 0; + } else + len = dataType.contentLength; + + if (dataType != null) { + if (dataType.classType == TransmissionTypeClass.Fixed) { + return new CodecParseResults( + len, + Codec.fixedParsers[dataType.exponent][dataType.index]( + data, dataType.offset, dataType.contentLength, connection)); + } else if (dataType.classType == 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."); + } + + static mapFromObject(map){ + var rt = new Map(); + for(var i in map) + rt.set(i, map[i]); + } + + static composers = { + // Fixed + [Boolean]: DataSerializer.boolComposer, + [NotModified]: DataSerializer.notModifiedComposer, + [Char8]: DataSerializer.char8Composer, + [Char16]: DataSerializer.char16Composer, + [Int64]: DataSerializer.int64Composer, + [UInt64]: DataSerializer.uInt64Composer, + [Int32]: DataSerializer.int32Composer, + [UInt32]: DataSerializer.uInt32Composer, + [Int16]: DataSerializer.int16Composer, + [UInt16]: DataSerializer.uInt16Composer, + [Int8]: DataSerializer.int8Composer, + [UInt8]: DataSerializer.uInt8Composer, + [Float32]: DataSerializer.float32Composer, + [Float64]: DataSerializer.float64Composer, + [Float128]: DataSerializer.float128Composer, + [Number]: DataSerializer.numberComposer, + [Date]: DataSerializer.dateTimeComposer, + [DC]: DataSerializer.rawDataComposer, + [Uint8Array]: DataSerializer.rawDataComposer, + [String]: DataSerializer.stringComposer, + // Special + [Array]: DataSerializer.listComposer, + [ResourceArray]: DataSerializer.resourceListComposer, + [RecordArray]: DataSerializer.recordListComposer, + [Map]: DataSerializer.mapComposer, + [PropertyValueArray]: DataSerializer.propertyValueArrayComposer + // Typed + }; + + + static getListType(list) { + if (list instanceof TypedList) + return TypedList.getType(list); + else + return Object; + } + + static getMapTypes(map) { + + if (map instanceof TypedMap) + return TypedMap.getTypes(map); + else + return [Object, Object]; + } + + /// + /// Compose a variable + /// + /// Value to compose. + /// DistributedConnection is required to check locality. + /// If True, prepend the DataType at the beginning of the output. + /// Array of bytes in the network byte order. + static compose(valueOrSource, connection) { + if (valueOrSource == null) + return TransmissionType.compose(TransmissionTypeIdentifier.Null, new 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 a; + // //a.Invoke() + // } + // } + // } + + // if (valueOrSource is IUserType) + // valueOrSource = (valueOrSource as IUserType).Get(); + + //if (valueOrSource is Func) + // valueOrSource = (valueOrSource as Func)(connection); + + // if (valueOrSource == null) + // return TransmissionType.Compose(TransmissionTypeIdentifier.Null, null); + + // type = valueOrSource.GetType(); + + + if (this.composers[type] != undefined) { + let results = this.composers[type](valueOrSource, connection); + return TransmissionType.compose(results.identifier, results.data); + } else { + if (valueOrSource instanceof TypedList) { + let genericType = this.getListType(valueOrSource); + let results = DataSerializer.typedListComposer( + valueOrSource, genericType, connection); + return TransmissionType.compose(results.identifier, results.data); + } else if (valueOrSource instanceof TypedMap) { + let genericTypes =TypedMap.getTypes(valueOrSource); + let results = DataSerializer.typedMapComposer( + valueOrSource, genericTypes[0], genericTypes[1], connection); + return TransmissionType.compose(results.identifier, results.data); + } else if (valueOrSource instanceof IResource) { + let results = + DataSerializer.resourceComposer(valueOrSource, connection); + return TransmissionType.compose(results.identifier, results.data); + } else if (valueOrSource instanceof IRecord) { + let results = DataSerializer.recordComposer(valueOrSource, connection); + return TransmissionType.compose(results.identifier, results.data); + } else if (valueOrSource instanceof IEnum) { + let results = DataSerializer.enumComposer(valueOrSource, connection); + return TransmissionType.compose(results.identifier, results.data); + } + else if (valueOrSource instanceof Tuple) { + let results = DataSerializer.tupleComposer(valueOrSource, connection); + return TransmissionType.compose(results.identifier, results.data); + } + } + + return TransmissionType.compose(TransmissionTypeIdentifier.Null, new DC(0)); + } + + /// + /// Check if a resource is local to a given connection. + /// + /// Resource to check. + /// DistributedConnection to check if the resource is local to it. + /// True, if the resource owner is the given connection, otherwise False. + static isLocalResource( resource, connection) { + if (connection == null) return false; + if (resource instanceof DistributedResource) { + if (resource.connection == connection) return true; + } + return false; + } + +} + diff --git a/src/Data/DataConverter.js b/src/Data/DC.js similarity index 51% rename from src/Data/DataConverter.js rename to src/Data/DC.js index a5d37e5..271bcd8 100644 --- a/src/Data/DataConverter.js +++ b/src/Data/DC.js @@ -32,6 +32,11 @@ import Guid from './Guid.js'; export const UNIX_EPOCH = 621355968000000000; export const TWO_PWR_32 = (1 << 16) * (1 << 16); +export const Endian = { + Big: 0, + Little: 1 +} + export default class DC extends Uint8Array { constructor(bufferOrSize) { @@ -63,6 +68,10 @@ export default class DC extends Uint8Array return rt; } + static fromList(list){ + return new DC(list); + } + static hexToBytes(value) { // convert hex to Uint8Array @@ -79,73 +88,73 @@ export default class DC extends Uint8Array return rt; } - static charToBytes(value) + static charToBytes(value, endian) { var rt = new DC(2); - rt.setChar(0, value); + rt.setChar(0, value, endian); return rt; } - static int16ToBytes(value) + static int16ToBytes(value, endian) { var rt = new DC(2); - rt.setInt16(0, value); + rt.setInt16(0, value, endian); return rt; } - static uint16ToBytes(value) + static uint16ToBytes(value, endian) { var rt = new DC(2); - rt.setUint16(0, value); + rt.setUint16(0, value, endian); return rt; } - static int32ToBytes(value) + static int32ToBytes(value, endian) { var rt = new DC(4); - rt.setInt32(0, value); + rt.setInt32(0, value, endian); return rt; } - static uint32ToBytes(value) + static uint32ToBytes(value, endian) { var rt = new DC(4); - rt.setUint32(0, value); + rt.setUint32(0, value, endian); return rt; } - static float32ToBytes(value) + static float32ToBytes(value, endian) { var rt = new DC(4); - rt.setFloat32(0, value); + rt.setFloat32(0, value, endian); return rt; } - static int64ToBytes(value) + static int64ToBytes(value, endian) { var rt = new DC(8); - rt.setInt64(0, value); + rt.setInt64(0, value, endian); return rt; } - static uint64ToBytes(value) + static uint64ToBytes(value, endian) { var rt = new DC(8); - rt.setUint64(0, value); + rt.setUint64(0, value, endian); return rt; } - static float64ToBytes(value) + static float64ToBytes(value, endian) { var rt = new DC(8); - rt.setFloat64(0, value); + rt.setFloat64(0, value, endian); return rt; } - static dateTimeToBytes(value) + static dateTimeToBytes(value, endian) { var rt = new DC(8); - rt.setDateTime(0, value); + rt.setDateTime(0, value, endian); return rt; } @@ -172,68 +181,68 @@ export default class DC extends Uint8Array return list.toArray(); } - static uint16ArrayToBytes(values) + static uint16ArrayToBytes(values, endian) { var rt = new DC(values.length * 2); for(var i = 0; i < values.length; i++) - rt.setUint16(i * 2, values[i]); + rt.setUint16(i * 2, values[i], endian); return rt; } - static int16ArrayToBytes(values) + static int16ArrayToBytes(values, endian) { var rt = new DC(values.length * 2); for(var i = 0; i < values.length; i++) - rt.setInt16(i * 2, values[i]); + rt.setInt16(i * 2, values[i], endian); return rt; } - static uint32ArrayToBytes(values) + static uint32ArrayToBytes(values, endian) { var rt = new DC(values.length * 4); for(var i = 0; i < values.length; i++) - rt.setUint32(i * 4, values[i]); + rt.setUint32(i * 4, values[i], endian); return rt; } - static int32ArrayToBytes(values) + static int32ArrayToBytes(values, endian) { var rt = new DC(values.length * 4); for(var i = 0; i < values.length; i++) - rt.setInt32(i * 4, values[i]); + rt.setInt32(i * 4, values[i], endian); return rt; } - static int64ArrayToBytes(values) + static int64ArrayToBytes(values, endian) { var rt = new DC(values.length * 8); for(var i = 0; i < values.length; i++) - rt.setInt64(i * 8, values[i]); + rt.setInt64(i * 8, values[i], endian); return rt; } - static uint64ArrayToBytes(values) + static uint64ArrayToBytes(values, endian) { var rt = new DC(values.length * 8); for(var i = 0; i < values.length; i++) - rt.setUint64(i * 8, values[i]); + rt.setUint64(i * 8, values[i], endian); return rt; } - static float32ArrayToBytes(values) + static float32ArrayToBytes(values, endian) { var rt = new DC(values.length * 4); for(var i = 0; i < values.length; i++) - rt.setFloat32(i * 4, values[i]); + rt.setFloat32(i * 4, values[i], endian); return rt; } - static float64ArrayToBytes(values) + static float64ArrayToBytes(values, endian) { var rt = new DC(values.length * 8); for(var i = 0; i < values.length; i++) - rt.setFloat64(i * 8, values[i]); + rt.setFloat64(i * 8, values[i], endian); return rt; } @@ -280,39 +289,34 @@ export default class DC extends Uint8Array return this[offset];// this.dv.getUint8(offset); } - getInt16(offset) + getInt16(offset, endian) { - return this.dv.getInt16(offset); + return this.dv.getInt16(offset, endian != Endian.Big); } - getUint16(offset) + getUint16(offset, endian) { - return this.dv.getUint16(offset); + return this.dv.getUint16(offset, endian != Endian.Big); } - getInt32(offset) + getInt32(offset, endian) { - return this.dv.getInt32(offset); + return this.dv.getInt32(offset, endian != Endian.Big); } - getInt32Little(offset) + getUint32(offset, endian) { - return this.dv.getInt32(offset, true); + return this.dv.getUint32(offset, endian != Endian.Big); } - getUint32(offset) + getFloat32(offset, endian) { - return this.dv.getUint32(offset); + return this.dv.getFloat32(offset, endian != Endian.Big); } - getFloat32(offset) + getFloat64(offset, endian) { - return this.dv.getFloat32(offset); - } - - getFloat64(offset) - { - return this.dv.getFloat64(offset); + return this.dv.getFloat64(offset, endian != Endian.Big); } setInt8(offset, value) @@ -325,34 +329,34 @@ export default class DC extends Uint8Array return this.dv.setUint8(offset, value); } - setInt16(offset, value) + setInt16(offset, value, endian) { - return this.dv.setInt16(offset, value); + return this.dv.setInt16(offset, value, endian != Endian.Big); } - setUint16(offset, value) + setUint16(offset, value, endian) { - return this.dv.setUint16(offset, value); + return this.dv.setUint16(offset, value, endian != Endian.Big); } - setInt32(offset, value) + setInt32(offset, value, endian) { - return this.dv.setInt32(offset, value); + return this.dv.setInt32(offset, value, endian != Endian.Big); } - setUint32(offset, value) + setUint32(offset, value, endian) { - return this.dv.setUint32(offset, value); + return this.dv.setUint32(offset, value, endian != Endian.Big); } - setFloat32(offset, value) + setFloat32(offset, value, endian) { - return this.dv.setFloat32(offset, value); + return this.dv.setFloat32(offset, value, endian != Endian.Big); } - setFloat64(offset, value) + setFloat64(offset, value, endian) { - return this.dv.setFloat64(offset, value); + return this.dv.setFloat64(offset, value, endian != Endian.Big); } getInt8Array(offset, length) @@ -365,12 +369,12 @@ export default class DC extends Uint8Array return new Uint8Array(this.buffer, offset, length); } - copy(offset, length, elementSize, func, dstType) + copy(offset, length, elementSize, func, dstType, endian) { let rt = new dstType(length / elementSize); let d = 0, end = offset + length; for (let i = offset; i < end; i += elementSize) - rt[d++] = func.call(this, i); + rt[d++] = func.call(this, i, endian); return rt; } @@ -384,55 +388,47 @@ export default class DC extends Uint8Array } - getInt16Array(offset, length) + getInt16Array(offset, length, endian) { - return this.copy(offset, length, 2, this.getInt16, Int16Array); + return this.copy(offset, length, 2, this.getInt16, Int16Array, endian); //return new Int16Array(this.clip(offset, length).buffer); } - getUint16Array(offset, length) + getUint16Array(offset, length, endian) { - return this.copy(offset, length, 2, this.getUint16, Uint16Array); - //return new Uint16Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 2, this.getUint16, Uint16Array, endian); } - getInt32Array(offset, length) + getInt32Array(offset, length, endian) { - return this.copy(offset, length, 4, this.getInt32, Int32Array); - //return new Int32Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 4, this.getInt32, Int32Array, endian); } - getUint32Array(offset, length) + getUint32Array(offset, length, endian) { - return this.copy(offset, length, 4, this.getUint32, Uint32Array); - //return new Uint32Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 4, this.getUint32, Uint32Array, endian); } - getFloat32Array(offset, length) + getFloat32Array(offset, length, endian) { - return this.copy(offset, length, 4, this.getFloat32, Float32Array); - //return new Float32Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 4, this.getFloat32, Float32Array, endian); } - getFloat64Array(offset, length) + getFloat64Array(offset, length, endian) { - return this.copy(offset, length, 8, this.getFloat64, Float64Array); - -// return new Float64Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 8, this.getFloat64, Float64Array, endian); } - getInt64Array(offset, length) + getInt64Array(offset, length, endian) { - return this.copy(offset, length, 8, this.getInt64, Float64Array);//BigInt64Array); - //return new Int64Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 8, this.getInt64, Float64Array, endian); } - getUint64Array(offset, length) + getUint64Array(offset, length, endian) { - return this.copy(offset, length, 8, this.getUint64, Float64Array);//BigUint64Array); - //return new Uint64Array(this.clip(offset, length).buffer); + return this.copy(offset, length, 8, this.getUint64, Float64Array, endian); } getBoolean(offset) @@ -453,21 +449,21 @@ export default class DC extends Uint8Array return rt; } - getChar(offset) + getChar(offset, endian) { - return String.fromCharCode(this.getUint16(offset)); + return String.fromCharCode(this.getUint16(offset, endian)); } - setChar(offset, value) + setChar(offset, value, endian) { - this.setUint16(offset, value.charCodeAt(0)); + this.setUint16(offset, value.charCodeAt(0), endian); } - getCharArray(offset, length) + getCharArray(offset, length, endian) { var rt = []; for(var i = 0; i < length; i+=2) - rt.push(this.getChar(offset+i)); + rt.push(this.getChar(offset+i, endian)); return rt; } @@ -495,14 +491,14 @@ export default class DC extends Uint8Array } } - getStringArray(offset, length) + getStringArray(offset, length, endian) { var rt = []; var i = 0; while (i < length) { - var cl = this.getUint32(offset + i); + var cl = this.getUint32(offset + i, endian); i += 4; rt.push(this.getString(offset + i, cl)); i += cl; @@ -512,55 +508,160 @@ export default class DC extends Uint8Array } // @TODO: Test numbers with bit 7 of h = 1 - getInt64(offset) + getInt64(offset, endian) { - var h = this.getInt32(offset); - var l = this.getInt32(offset + 4); + if (endian == Endian.Big) { + let 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 { + let 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); + // return h * TWO_PWR_32 + ((l >= 0) ? l : TWO_PWR_32 + l); } - getUint64(offset) + getUint64(offset, endian) { - var h = this.getUint32(offset); - var l = this.getUint32(offset + 4); - return h * TWO_PWR_32 + ((l >= 0) ? l : TWO_PWR_32 + l); + + if (endian == Endian.Big) { + let 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 { + let 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.getUint32(offset); + //var l = this.getUint32(offset + 4); + //return h * TWO_PWR_32 + ((l >= 0) ? l : TWO_PWR_32 + l); } - setInt64(offset, value) + setInt64(offset, value, endian) { - var l = (value % TWO_PWR_32) | 0; - var h = (value / TWO_PWR_32) | 0; - this.setInt32(offset, h); - this.setInt32(offset + 4, l); + + 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); } - setUint64(offset, value) + setUint64(offset, value, endian) { - var l = (value % TWO_PWR_32) | 0; - var h = (value / TWO_PWR_32) | 0; - this.setInt32(offset, h); - this.setInt32(offset + 4, l); + + 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); } - setDateTime(offset, value) + setDateTime(offset, value, endian) { // Unix Epoch var ticks = 621355968000000000 + (value.getTime() * 10000); - this.setUint64(offset, ticks); + this.setUint64(offset, ticks, endian); } - getDateTime(offset) + getDateTime(offset, endian) { - var ticks = this.getUint64(offset); + var ticks = this.getUint64(offset, endian); return new Date(Math.round((ticks-UNIX_EPOCH)/10000)); } - getDateTimeArray(offset) + getDateTimeArray(offset, endian) { var rt = []; for(var i = 0; i < length; i+=8) - rt.push(this.getDateTime(offset+i)); + rt.push(this.getDateTime(offset+i, endian)); return rt; } diff --git a/src/Data/DataDeserializer.js b/src/Data/DataDeserializer.js new file mode 100644 index 0000000..9fb428f --- /dev/null +++ b/src/Data/DataDeserializer.js @@ -0,0 +1,510 @@ +import IEnum from './IEnum.js'; +import Tuple from './Tuple.js'; +import TemplateType from '../Resource/Template/TemplateType.js'; +import Warehouse from '../Resource/Warehouse.js'; +import AsyncBag from '../Core/AsyncBag.js'; +import AsyncReply from '../Core/AsyncReply.js'; +import DC from './DC.js'; +import DistributedConnection from '../Net/IIP/DistributedConnection.js'; +import NotModified from './NotModified.js'; +import RepresentationType from './RepresentationType.js'; +import Codec from './Codec.js'; +import TypedMap from './TypedMap.js'; +import PropertyValueArray from './PropertyValueArray.js'; +import PropertyValue from './PropertyValue.js'; +import Record from './Record.js'; + +export class PropertyValueParserResults { + //final int size; + ///final AsyncReply reply; + + constructor(size, reply){ + this.size = size; + this.reply = reply; + } +} + +export default class DataDeserializer { + static nullParser(data, offset, length, connection) { + return new AsyncReply(null); + } + + static booleanTrueParser( + data, offset, length, connection) { + return new AsyncReply(true); + } + + static booleanFalseParser( + data, offset, length, connection) { + return new AsyncReply(false); + } + + static notModifiedParser( + data, offset, length, connection) { + return new AsyncReply(NotModified()); + } + + static byteParser( + data, offset, length, connection) { + return new AsyncReply(data[offset]); + } + + static sByteParser( + data, offset, length, connection) { + return new AsyncReply( + data[offset] > 127 ? data[offset] - 256 : data[offset]); + } + + static char16Parser( + data, offset, length, connection) { + return new AsyncReply(data.getChar(offset)); + } + + static char8Parser( + data, offset, length, connection) { + return new AsyncReply(String.fromCharCode(data[offset])); + } + + static int16Parser( + data, offset, length, connection) { + return new AsyncReply(data.getInt16(offset)); + } + + static uInt16Parser( + data, offset, length, connection) { + return new AsyncReply(data.getUint16(offset)); + } + + static int32Parser( + data, offset, length, connection) { + return new AsyncReply(data.getInt32(offset)); + } + + static uInt32Parser( + data, offset, length, connection) { + return new AsyncReply(data.getUint32(offset)); + } + + static float32Parser( + data, offset, length, connection) { + return new AsyncReply(data.getFloat32(offset)); + } + + static float64Parser( + data, offset, length, connection) { + return new AsyncReply(data.getFloat64(offset)); + } + + static float128Parser( + data, offset, length, connection) { + // @TODO + return new AsyncReply(data.getFloat64(offset)); + } + + static int128Parser( + data, offset, length, connection) { + // @TODO + return new AsyncReply(data.getInt64(offset)); + } + + static uInt128Parser( + data, offset, length, connection) { + return new AsyncReply(data.getUint64(offset)); + } + + static int64Parser( + data, offset, length, connection) { + return new AsyncReply(data.getInt64(offset)); + } + + static uInt64Parser( + data, offset, length, connection) { + return new AsyncReply(data.getUint64(offset)); + } + + static dateTimeParser( + data, offset, length, connection) { + return new AsyncReply(data.getDateTime(offset)); + } + + static 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"); + } + + static localResourceParser( + data, offset, length, connection) { + var id = data.getUint32(offset); + return Warehouse.getById(id); + } + + static rawDataParser( + data, offset, length, connection) { + return new AsyncReply(data.clip(offset, length)); + } + + static stringParser( + data, offset, length, connection) { + return new AsyncReply(data.getString(offset, length)); + } + + static recordParser( + data, offset, length, connection) { + var reply = new AsyncReply(); + + var classId = data.getGuid(offset); + offset += 16; + length -= 16; + + var template = Warehouse.getTemplateByClassId(classId, TemplateType.Record); + + if (template != null) { + listParser(data, offset, length, connection).then((ar) => { + let record; + + if (template.definedType != null) { + record = Warehouse.createInstance(template.definedType); + } else { + record = Record(); + } + + 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((tmp) => { + if (tmp == null) + reply.triggerError(new Error("Couldn't fetch record template.")); + + DataDeserializer.listParser(data, offset, length, connection).then((ar) => { + + var record = new Record(); + + //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((x) => reply.triggerError(x)); + } + + return reply; + } + + static constantParser( + data, offset, length, connection) { + throw Error("NotImplementedException"); + } + + static enumParser(data, offset, length, connection) { + var classId = data.getGuid(offset); + offset += 16; + var index = data[offset++]; + + var template = Warehouse.getTemplateByClassId(classId, TemplateType.Enum); + + if (template != null) { + if (template.definedType != null) { + var enumVal = Warehouse.createInstance(template.definedType); + enumVal.index = index; + enumVal.name = template.constants[index].name; + enumVal.value = template.constants[index].value; + return new AsyncReply.ready(enumVal); + } else { + return AsyncReply.ready(IEnum(index, template.constants[index].value, + template.constants[index].name)); + } + } else { + var reply = new AsyncReply(); + + if (connection == null) + throw Error("Can't parse enum with no connection"); + connection.getTemplate(classId).then((tmp) => { + if (tmp != null) { + if (tmp.definedType != null) { + var enumVal = Warehouse.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( + index, tmp.constants[index].value, tmp.constants[index].name)); + } + } else + reply.triggerError(new Error("Template not found for enum")); + }).error((x) => reply.triggerError(x)); + + return reply; + } + } + + static recordListParser( + data, offset, length, connection) { + var rt = new AsyncBag(); + + while (length > 0) { + var parsed = Codec.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; + } + + static resourceListParser( + data, offset, length, connection) { + var rt = new AsyncBag(); + + while (length > 0) { + var parsed = Codec.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; + } + + static listParser( + data, offset, length, connection) { + var rt = new AsyncBag(); + + while (length > 0) { + var parsed = Codec.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; + } + + static typedMapParser( + data, offset, length, connection) { + // get key type + var keyRep = RepresentationType.parse(data, offset); + offset += keyRep.size; + length -= keyRep.size; + + var valueRep = RepresentationType.parse(data, offset); + offset += valueRep.size; + length -= valueRep.size; + + + + var map = new TypedMap(); + var rt = new AsyncReply(); + + var results = new AsyncBag(); + + while (length > 0) { + var parsed = Codec.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((ar) => { + for (var i = 0; i < ar.length; i += 2) + map.set(ar[i], ar[i + 1]); + + rt.trigger(map); + }); + + return rt; + } + + static tupleParser( + data, offset, length, connection) { + + + var results = new AsyncBag(); + var rt = new AsyncReply(); + + var tupleSize = data[offset++]; + length--; + + var types = []; + + for (var i = 0; i < tupleSize; i++) { + var rep = RepresentationType.parse(data, offset); + if (rep.type != null) + types.push(rep.type.getRuntimeType() ?? Object); + offset += rep.size; + length -= rep.size; + } + + while (length > 0) { + var parsed = Codec.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((ar) => { + rt.trigger(new (Tuple.of(...types))(...ar)); + }); + + return rt; + } + + static typedListParser( + data, offset, length, connection) { + var rt = new AsyncBag(); + + // get the type + var rep = RepresentationType.parse(data, offset); + + offset += rep.size; + length -= rep.size; + + var runtimeType = rep.type.getRuntimeType(); + + rt.arrayType = runtimeType; + + while (length > 0) { + var parsed = Codec.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; + } + + static PropertyValueArrayParser( + data, + offset, + length, + connection) //, bool ageIncluded = true) + { + var rt = new AsyncBag(); + + DataDeserializer.listParser(data, offset, length, connection).then((x) => { + var pvs = new PropertyValueArray(); + + for (var i = 0; i < x.length; i += 3) + pvs.push(new PropertyValue(x[2], x[0], x[1])); + + rt.trigger(pvs); + }); + + return rt; + } + + static propertyValueParser(data, offset, + connection) //, bool ageIncluded = true) + { + let reply = new AsyncReply(); + + let age = data.getUint64(offset); + offset += 8; + + let date = data.getDateTime(offset); + offset += 8; + + let parsed = Codec.parse(data, offset, connection); + + parsed.reply.then((value) => { + reply.trigger(new PropertyValue(value, age, date)); + }); + + return new PropertyValueParserResults(16 + parsed.size, reply); + } + + static + historyParser(data, offset, length, resource, + connection) { + throw new Error("Not implemented"); + // @TODO + // 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; + + // 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; + } +} diff --git a/src/Data/DataSerializer.js b/src/Data/DataSerializer.js new file mode 100644 index 0000000..0afedcd --- /dev/null +++ b/src/Data/DataSerializer.js @@ -0,0 +1,418 @@ + import BinaryList from './BinaryList.js'; + import Codec from './Codec.js'; + //import IRecord from './IRecord.js'; + //import DistributedResource from '../Net/IIP/DistributedResource.js'; + + //import IResource from '../Resource/IResource.js'; + + import Warehouse from '../Resource/Warehouse.js'; + + //import PropertyTemplate from '../Resource/Template/PropertyTemplate.js'; +//import PropertyValue from './PropertyValue.js'; +import { TransmissionTypeIdentifier} from './TransmissionType.js'; + +//import DistributedConnection from '../Net/IIP/DistributedConnection.js'; +import DC, { BL } from './DC.js'; +import RepresentationType from './RepresentationType.js'; +import Tuple from './Tuple.js'; + +export class DataSerializerComposeResults { +// int identifier; + //DC data; + + constructor(identifier, data){ + this.identifier = identifier; + this.data = data; + } +} + +export default class DataSerializer { + //public delegate byte[] Serializer(object value); + + static historyComposer(history, connection, prependLength = false) { + throw new Error("Not implemented"); + } + + static int32Composer( + value, connection) { + var rt = new DC(4); + rt.setInt32(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Int32, rt); + } + + static uInt32Composer( + value, connection) { + var rt = new DC(4); + rt.setUint32(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.UInt32, rt); + } + + static int16Composer( + value, connection) { + var rt = new DC(2); + rt.setInt16(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Int16, rt); + } + + static uInt16Composer( + value, connection) { + var rt = new DC(2); + rt.setUint16(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.UInt16, rt); + } + + static float32Composer( + value, connection) { + var rt = new DC(4); + rt.setFloat32(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Float32, rt); + } + + static float64Composer(value, connection) { + var rt = new DC(8); + rt.setFloat64(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Float64, rt); + } + + static int64Composer( + value, connection) { + var rt = new DC(8); + rt.setInt64(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Int64, rt); + } + + static numberComposer(value, connection) { + var rt = new DC(8); + if (Number.isInteger(value)){ + rt.setInt64(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Int64, rt); + } + else { + rt.setFloat64(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Float64, rt); + } + } + + + static uInt64Composer( + value, connection) { + var rt = new DC(8); + rt.setUint64(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.UInt64, rt); + } + + static dateTimeComposer( + value, connection) { + var rt = new DC(8); + rt.setDateTime(0, value); + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.DateTime, rt); + } + + static float128Composer( + value, connection) { + //@TODO: implement decimal + var rt = new DC(16); + rt.setFloat64(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Float64, rt); + } + + static stringComposer( + value, connection) { + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.String, DC.stringToBytes(value)); + } + + static enumComposer( + value, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var template = Warehouse.getTemplateByType(value.runtimeType); + + if (template == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var cts = template.constants.where((x) => x.value == value); + + if (cts.isEmpty) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var rt = BinaryList(); + + rt.addGuid(template.classId); + rt.addUint8(cts.first.index); + + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Enum, rt.toDC()); + } + + static uInt8Composer( + value, connection) { + var rt = new DC(1); + rt[0] = value; + return new DataSerializerComposeResults(TransmissionTypeIdentifier.UInt8, rt); + } + + static int8Composer( + value, connection) { + var rt = new DC(1); + rt[0] = value; + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Int8, rt); + } + + static char8Composer( + value, connection) { + var rt = new DC(1); + rt[0] = value; + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Char8, rt); + } + + static char16Composer( + value, connection) { + var rt = new DC(2); + rt.setUint16(0, value); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Char16, rt); + } + + static boolComposer( + value, connection) { + return new DataSerializerComposeResults( + value + ? TransmissionTypeIdentifier.True + : TransmissionTypeIdentifier.False, + new DC(0)); + } + + static notModifiedComposer( + value, connection) { + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.NotModified, new DC(0)); + } + + static rawDataComposer( + value, connection) { + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.RawData, value); + } + + static listComposer( + value, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + else + return new DataSerializerComposeResults(TransmissionTypeIdentifier.List, + DataSerializer.arrayComposer(value , connection)); + + //var rt = new List(); + //var list = (IEnumerable)value;// ((List)value); + + //foreach (var o in list) + // rt.AddRange(Codec.Compose(o, connection)); + + //return (TransmissionTypeIdentifier.List, rt.ToArray()); + } + + static typedListComposer( + value, type, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var composed = DataSerializer.arrayComposer(value, connection); + + var header = + (RepresentationType.fromType(type) ?? RepresentationType.Dynamic) + .compose(); + + var rt = new BinaryList() + .addDC(header) + .addDC(composed); + + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.TypedList, rt.toDC()); + } + + static propertyValueArrayComposer( + value, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var rt = BL(); + + + for (var i = 0; i < value.length; i ++){ + rt.addDC(Codec.compose(value[i].age, connection)); + rt.addDC(Codec.compose(value[i].date, connection)); + rt.addDC(Codec.compose(value[i].value, connection)); + } + + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.List, rt.toDC()); + } + + static typedMapComposer( + value, keyType, valueType, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var kt = + (RepresentationType.fromType(keyType) ?? RepresentationType.Dynamic) + .compose(); + var vt = + (RepresentationType.fromType(valueType) ?? RepresentationType.Dynamic) + .compose(); + + var rt = new BinaryList(); + + rt.addDC(kt); + rt.addDC(vt); + + +//@TODO + + for(let [k, v] of value) + { + rt.addDC(Codec.compose(k, connection)); + rt.addDC(Codec.compose(v, connection)); + } + + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.TypedMap, rt.toDC()); + } + + static arrayComposer(value, connection) { + var rt = new BinaryList(); + + for (var i of value) + rt.addDC(Codec.compose(i, connection)); + + return rt.toDC(); + } + + static resourceListComposer( + value, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + return new DataSerializerComposeResults(TransmissionTypeIdentifier.ResourceList, + DataSerializer.arrayComposer(value, connection)); + } + + static recordListComposer( + value, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + return new DataSerializerComposeResults(TransmissionTypeIdentifier.RecordList, + DataSerializer.arrayComposer(value, connection)); + } + + static resourceComposer( + value, connection) { + var resource = value; + var rt = new DC(4); + + if (Codec.isLocalResource(resource, connection)) { + rt.setUint32(0, resource.id ?? 0); + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.ResourceLocal, rt); + } else { + // @TODO: connection.cache.Add(value as IResource, DateTime.UtcNow); + rt.setUint32(0, resource.instance?.id ?? 0); + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Resource, rt); + } + } + + static mapComposer( + value, connection) { + if (value == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + var rt = BinaryList(); + + for (var el in value) { + rt.addDC(Codec.compose(el.key, connection)); + rt.addDC(Codec.compose(el.value, connection)); + } + + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Map, rt.toDC()); + } + + static recordComposer( + value, connection) { + var rt = BinaryList(); + + + var template = Warehouse.getTemplateByType(value.runtimeType); + + if (template == null) + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Null, new DC(0)); + + rt.addDC(DC.guidToBytes(template.classId)); + + var recordData = value.serialize(); + + for (var pt in template.properties) { + var propValue = recordData[pt.name]; + rt.addDC(Codec.compose(propValue, connection)); + } + + return new DataSerializerComposeResults( + TransmissionTypeIdentifier.Record, rt.toDC()); + } + + // TODO: + // static DataSerializerComposeResults historyComposer(KeyList 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(); + // } + + static tupleComposer(value, connection) { + if (value == null) + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Null, new DC(0)); + + var rt = BL(); + + var fields = Tuple.getTypes(value); + var types = fields.map(x => RepresentationType.fromType(x).compose()); + + rt.Add(value.length); + + for (var t of types) + rt.addUint8Array(t); + + var composed = DataSerializer.arrayComposer(value, connection); + + if (composed == null) + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Null, new DC(0)); + else + { + rt.addUint8Array(composed); + return new DataSerializerComposeResults(TransmissionTypeIdentifier.Tuple, rt.toArray()); + } + } +} diff --git a/src/Data/ExtendedTypes.js b/src/Data/ExtendedTypes.js new file mode 100644 index 0000000..7a7ee25 --- /dev/null +++ b/src/Data/ExtendedTypes.js @@ -0,0 +1,28 @@ +class Num extends Number { + + toString() { return super.toString()} + + constructor(value) { + super(value); + } +} + +export class Int128 extends Num {} +export class Int64 extends Num { } +export class Int32 extends Num { } +export class Int16 extends Num { } +export class Int8 extends Num { } + +export class UInt128 extends Num {} +export class UInt64 extends Num { } +export class UInt32 extends Num { } +export class UInt16 extends Num { } +export class UInt8 extends Num { } + +export class Float32 extends Num{} +export class Float64 extends Num{} + +export class Float128 extends Num{} + +export class Char16 extends String {} +export class Char8 extends String {} \ No newline at end of file diff --git a/src/Data/Guid.js b/src/Data/Guid.js index 7b294b1..ea7b3c2 100644 --- a/src/Data/Guid.js +++ b/src/Data/Guid.js @@ -24,8 +24,8 @@ * Created by Ahmed Zamil on 02/09/2017. */ -"use strict"; +import DC from './DC.js'; export default class Guid { constructor(dc) @@ -38,6 +38,14 @@ export default class Guid return this.value.getHex(0, 16); } + static fromString(data) { + this.value = DC.fromHex(data, ''); + } + + toString() { + return this.vlue.toHex(''); + } + // [Symbol.toPrimitive](hint){ // console.log(hint); // } diff --git a/src/Data/IEnum.js b/src/Data/IEnum.js new file mode 100644 index 0000000..a4fe5a0 --- /dev/null +++ b/src/Data/IEnum.js @@ -0,0 +1,18 @@ +//import TemplateDescriber from '../Resource/Template/TemplateDescriber.js'; + +export default class IEnum { + + IEnum(index, value, name){ + this.index = index; + this.value = value; + this.name = name; + } + + get template () { + //return new TemplateDescriber("IEnum"); + } + + toString() { + return `${this.name}<${this.value}>`; + } +} diff --git a/src/Data/IRecord.js b/src/Data/IRecord.js index 81c930c..64860d7 100644 --- a/src/Data/IRecord.js +++ b/src/Data/IRecord.js @@ -1,3 +1,6 @@ export default class IRecord { + toString() { + //return serialize().toString(); + } } \ No newline at end of file diff --git a/src/Data/ParseResult.js b/src/Data/ParseResult.js new file mode 100644 index 0000000..d4a1002 --- /dev/null +++ b/src/Data/ParseResult.js @@ -0,0 +1,7 @@ +export default class ParseResult { + + constructor (size, value){ + this.size = size; + this.value = value; + } +} \ No newline at end of file diff --git a/src/Data/PropertyValueArray.js b/src/Data/PropertyValueArray.js new file mode 100644 index 0000000..04dcd50 --- /dev/null +++ b/src/Data/PropertyValueArray.js @@ -0,0 +1,3 @@ +export default class PropertyValueArray extends Array { + +} \ No newline at end of file diff --git a/src/Data/Record.js b/src/Data/Record.js index acf71a2..6c8d627 100644 --- a/src/Data/Record.js +++ b/src/Data/Record.js @@ -28,5 +28,5 @@ import IRecord from './IRecord.js'; export default class Record extends IRecord { - + } \ No newline at end of file diff --git a/src/Data/RecordArray.js b/src/Data/RecordArray.js new file mode 100644 index 0000000..135294f --- /dev/null +++ b/src/Data/RecordArray.js @@ -0,0 +1,40 @@ +/* +* 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"; + + import IRecord from "./IRecord.js"; + +export default class RecordArray extends Array +{ + push(value) + { + if (value instanceof IRecord) + super.push(value); + else + return; + } + } \ No newline at end of file diff --git a/src/Data/RepresentationType.js b/src/Data/RepresentationType.js new file mode 100644 index 0000000..70039bd --- /dev/null +++ b/src/Data/RepresentationType.js @@ -0,0 +1,197 @@ + + import TemplateType from '../Resource/Template/TemplateType.js'; +import IRecord from './IRecord.js'; +import IResource from '../Resource/IResource.js'; + +import BinaryList from './BinaryList.js'; +import DC from './DC.js'; + +import Warehouse from '../Resource/Warehouse.js'; +import {Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Char8, Char16, Float32, Float64, Float128} from './ExtendedTypes.js'; + +export const 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 +} + +let RuntimeTypes = {}; + +RuntimeTypes[RepresentationTypeIdentifier.Void] = [Object, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Bool] = [Boolean, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Char] = [Char8, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Char16] = [Char16, Object]; +RuntimeTypes[RepresentationTypeIdentifier.UInt8] = [UInt8, UInt8]; +RuntimeTypes[RepresentationTypeIdentifier.Int8] = [Int8, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Int16] = [Int16, Object]; +RuntimeTypes[RepresentationTypeIdentifier.UInt16] = [UInt16, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Int32] = [Int32, Object]; +RuntimeTypes[RepresentationTypeIdentifier.UInt32] = [UInt32, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Int64] = [Int64, Object]; +RuntimeTypes[RepresentationTypeIdentifier.UInt64] = [UInt64, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Int128] = [Int128, Object]; +RuntimeTypes[RepresentationTypeIdentifier.UInt128] = [UInt128, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Float32] = [Float32, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Float64] = [Float64, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Decimal] = [Float128, Object]; +RuntimeTypes[RepresentationTypeIdentifier.String] = [String, Object]; +RuntimeTypes[RepresentationTypeIdentifier.DateTime] = [Date, Object]; +RuntimeTypes[RepresentationTypeIdentifier.Resource] = [IResource, IResource]; +RuntimeTypes[RepresentationTypeIdentifier.Record] = [IRecord, IRecord]; + + +export class RepresentationTypeParseResults { + //RepresentationType type; + //int size; + constructor(size, type){ + this.size= size; + this.type = type; + } +} + +export default class RepresentationType { +// 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; +// } + + toNullable() { + return new RepresentationType(this.identifier, true, this.guid, this.subTypes); + } + + static get Void () { return new RepresentationType(RepresentationTypeIdentifier.Void, true, null, null);} + + static get Dynamic() { return new RepresentationType(RepresentationTypeIdentifier.Dynamic, true, null, null);} + + static fromType(type) { + return Warehouse.typesFactory[type]?.representationType; + } + + + getRuntimeType() { + if (RuntimeTypes[this.identifier]) + return this.nullable + ? RuntimeTypes[this.identifier][1] + : RuntimeTypes[this.identifier][0]; + if (this.identifier == RepresentationTypeIdentifier.TypedRecord) + return Warehouse.getTemplateByClassId(this.guid, TemplateType.Record) + ?.definedType; + else if (this.identifier == RepresentationTypeIdentifier.TypedResource) + return Warehouse.getTemplateByClassId(this.guid, TemplateType.Unspecified) + ?.definedType; + else if (this.identifier == RepresentationTypeIdentifier.Enum) + return Warehouse.getTemplateByClassId(this.guid, TemplateType.Enum) + ?.definedType; + + return null; + } + + + constructor(identifier, nullable, guid, subTypes) { + this.identifier = identifier; + this.nullable = nullable; + this.guid = guid; + this.subTypes = subTypes; + } + + compose() { + var rt = new BinaryList(); + + if (this.nullable) + rt.addUint8(0x80 | this.identifier); + else + rt.addUint8(this.identifier); + + if (this.guid != null) rt.addDC(DC.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 + ">" : ""; + + static parse(data, offset) { + let oOffset = offset; + + let header = data[offset++]; + let nullable = (header & 0x80) > 0; + let identifier = (header & 0x7F); + + if ((header & 0x40) > 0) { + let hasGUID = (header & 0x4) > 0; + let subsCount = (header >> 3) & 0x7; + + let guid = null; + + if (hasGUID) { + guid = data.getGuid(offset); + offset += 16; + } + + let subs = []; + + for (let i = 0; i < subsCount; i++) { + let 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)); + } + } +} + +export {RepresentationType}; diff --git a/src/Data/ResourceArray.js b/src/Data/ResourceArray.js index c08edd6..b9a22ad 100644 --- a/src/Data/ResourceArray.js +++ b/src/Data/ResourceArray.js @@ -26,6 +26,7 @@ "use strict"; +import IResource from "../Resource/IResource.js"; export default class ResourceArray extends Array { push(value) diff --git a/src/Data/TransmissionType.js b/src/Data/TransmissionType.js new file mode 100644 index 0000000..333b3fc --- /dev/null +++ b/src/Data/TransmissionType.js @@ -0,0 +1,196 @@ +import DC from './DC.js'; + +export const 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 +}; + + +export let TransmissionTypeClass = { + Fixed : 0, + Dynamic : 1, + Typed : 2 +} + +export class TransmissionTypeParseResults { + constructor(size, type) { + this.size = size; + this.type = type; + } +} + +export default class TransmissionType { +// final int identifier; +// final int index; +// final int classType; +// final int offset; +// final int contentLength; +// final int exponent; + + static get Null() { return new + TransmissionType(TransmissionTypeIdentifier.Null, 0, 0, 0, 0);} + + constructor(identifier, classType, index, offset, contentLength, exponent = 0){ + this.identifier = identifier; + this.classType = classType; + this.index = index; + this.offset = offset; + this.contentLength = contentLength; + this.exponent = exponent; +} + + static compose(identifier, data) { + if (data.length == 0) return DC.fromList([identifier]); + + var cls = identifier >> 6; + if (cls == TransmissionTypeClass.Fixed) { + return DC.combine([identifier], 0, 1, data, 0, data.length); + } else { + var len = data.length; + + if (len == 0) { + return DC.fromList([identifier]); + } else if (len <= 0xFF) { + let rt = new DC(2 + len); + rt[0] = identifier | 0x8; + rt[1] = len; + rt.set(data, 2); + return rt; + } else if (len <= 0xFFFF) { + let rt = new DC(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) { + let rt = new DC(4 + len); + rt[0] = identifier | 0x18; + rt[1] = (len >> 16) & 0xFF; + rt[2] = (len >> 8) & 0xFF; + rt[3] = len & 0xFF; + + rt.set(data, 4); + return rt; + } else if (len <= 0xFFFFFFFF) { + let rt = new DC(5 + len); + rt[0] = (identifier | 0x20); + rt[1] = ((len >> 24) & 0xFF); + rt[2] = ((len >> 16) & 0xFF); + rt[3] = ((len >> 8) & 0xFF); + rt[4] = (len & 0xFF); + rt.set(data, 5); + return rt; + } else if (len <= 0xFFFFFFFFFF) { + let rt = new DC(6 + len); + + rt[0] = identifier | 0x28; + rt[1] = ((len >> 32) & 0xFF); + rt[2] = ((len >> 24) & 0xFF); + rt[3] = ((len >> 16) & 0xFF); + rt[4] = ((len >> 8) & 0xFF); + rt[5] = (len & 0xFF); + rt.set(data, 6); + + return rt; + } else if (len <= 0xFFFFFFFFFFFF) { + let rt = new DC(7 + len); + + rt[0] = identifier | 0x30; + rt[1] = (len >> 40) & 0xFF; + rt[2] = (len >> 32) & 0xFF; + rt[3] = (len >> 24) & 0xFF; + rt[4] = (len >> 16) & 0xFF; + rt[5] = (len >> 8) & 0xFF; + rt[6] = len & 0xFF; + + rt.set(data, 7); + return rt; + } else //if (len <= 0xFF_FF_FF_FF_FF_FF_FF) + { + let rt = new DC(8 + len); + rt[0] = identifier | 0x38; + rt[1] = (len >> 48) & 0xFF; + rt[2] = (len >> 40) & 0xFF; + rt[3] = (len >> 32) & 0xFF; + rt[4] = (len >> 24) & 0xFF; + rt[5] = (len >> 16) & 0xFF; + rt[6] = (len >> 8) & 0xFF; + rt[7] = len & 0xFF; + data.set(data, 8); + return rt; + } + } + } + + static 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)); + + let 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 { + let cll = (h >> 3) & 0x7; + + if (ends - offset < cll) + return new TransmissionTypeParseResults(ends - offset - cll, null); + + let 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)); + } + } +} + +export {TransmissionType} \ No newline at end of file diff --git a/src/Data/Tuple.js b/src/Data/Tuple.js new file mode 100644 index 0000000..c1508a6 --- /dev/null +++ b/src/Data/Tuple.js @@ -0,0 +1,26 @@ +export default class Tuple extends Array { + static cache = {}; + + static getTypes(tuple){ + return tuple.constructor.types; + } + + static of(){ + + let types = []; + for(let i =0 ; i < arguments.length; i++){ + types.push(arguments[i]); + } + + if (Tuple.cache[types] != null) + return Tuple.cache[types]; + + let c = class extends Tuple{} + Object.defineProperty(c, "name", {value: types.map(x => x.name).join('') + "Tuple"}); + Object.defineProperty(c, "types", {value: types}); + + Tuple.cache[types] = c; + + return c; + } +} \ No newline at end of file diff --git a/src/Data/TypedList.js b/src/Data/TypedList.js new file mode 100644 index 0000000..0741269 --- /dev/null +++ b/src/Data/TypedList.js @@ -0,0 +1,36 @@ +import IResource from "../Resource/IResource.js"; +import PropertyValue from "./PropertyValue.js"; +import PropertyValueArray from "./PropertyValueArray.js"; +import ResourceArray from "./ResourceArray.js"; + +export default class TypedList extends Array +{ + // constructor(data) + // { + + // if (data != undefined && data instanceof Array) + // for(var i = 0; i < data.length; i++) + // this.push(data[i]); + // } + + static cache = { [IResource] : ResourceArray, + [PropertyValue] : PropertyValueArray + }; + + static getType(typedList){ + return typedList.constructor.type; + } + + static of(type){ + if (TypedList.cache[type] != null) + return TypedList.cache[type]; + + let c = class extends TypedList{} + Object.defineProperty(c, "name", {value: type.name + "List"}); + Object.defineProperty(c, "type", {value: type}); + + TypedList.cache[type] = c; + + return c; + } +} \ No newline at end of file diff --git a/src/Data/TypedMap.js b/src/Data/TypedMap.js new file mode 100644 index 0000000..5ccf45c --- /dev/null +++ b/src/Data/TypedMap.js @@ -0,0 +1,43 @@ + +export default class TypedMap extends Map { + + constructor(data) + { + super(); + if (data instanceof Object) + for(var i in data) + this.set(i, data[i]); + } + + static getTypes(typedMap){ + return [typedMap.constructor.keyType ?? Object, typedMap.constructor.valueType ?? Object]; + } + + + static cache = {}; + + static 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]; + + let c = class extends 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; + } + +} \ No newline at end of file diff --git a/src/Net/IIP/DistributedConnection.js b/src/Net/IIP/DistributedConnection.js index 234b7dc..58d845c 100644 --- a/src/Net/IIP/DistributedConnection.js +++ b/src/Net/IIP/DistributedConnection.js @@ -32,7 +32,7 @@ import Authentication from '../../Security/Authority/Authentication.js'; import AuthenticationType from "../../Security/Authority/AuthenticationType.js"; import SHA256 from '../../Security/Integrity/SHA256.js'; -import { BL, DC } from '../../Data/DataConverter.js'; +import { BL, DC } from '../../Data/DC.js'; import SendList from '../SendList.js'; import AsyncReply from '../../Core/AsyncReply.js'; @@ -76,6 +76,11 @@ import SocketState from "../Sockets/SocketState.js"; import TemplateType from '../../Resource/Template/TemplateType.js'; import AsyncBag from '../../Core/AsyncBag.js'; +import {TransmissionType, TransmissionTypeIdentifier} from '../../Data/TransmissionType.js'; + +import PropertyValue from '../../Data/PropertyValue.js'; +import PropertyValueArray from '../../Data/PropertyValueArray.js'; + export default class DistributedConnection extends IStore { @@ -151,6 +156,8 @@ export default class DistributedConnection extends IStore { 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; @@ -168,10 +175,10 @@ export default class DistributedConnection extends IStore { this.IIPEventResourceDestroyed(packet.resourceId); break; case IIPPacketEvent.PropertyUpdated: - this.IIPEventPropertyUpdated(packet.resourceId, packet.methodIndex, packet.content); + this.IIPEventPropertyUpdated(packet.resourceId, packet.methodIndex, packet.dataType, msg); break; case IIPPacketEvent.EventOccurred: - this.IIPEventEventOccurred(packet.resourceId, packet.methodIndex, packet.content); + this.IIPEventEventOccurred(packet.resourceId, packet.methodIndex, packet.dataType, msg); break; case IIPPacketEvent.ChildAdded: @@ -181,10 +188,11 @@ export default class DistributedConnection extends IStore { this.IIPEventChildRemoved(packet.resourceId, packet.childId); break; case IIPPacketEvent.Renamed: - this.IIPEventRenamed(packet.resourceId, packet.content); + this.IIPEventRenamed(packet.resourceId, packet.resourceName); break; case IIPPacketEvent.AttributesUpdated: - this.IIPEventAttributesUpdated(packet.resourceId, packet.content); + //@TODO: fix this + //this.IIPEventAttributesUpdated(packet.resourceId, packet.content); break; } @@ -203,7 +211,8 @@ export default class DistributedConnection extends IStore { this.IIPRequestDetachResource(packet.callbackId, packet.resourceId); break; case IIPPacketAction.CreateResource: - this.IIPRequestCreateResource(packet.callbackId, packet.storeId, packet.resourceId, packet.content); + // @TODO: implement this + // this.IIPRequestCreateResource(packet.callbackId, packet.storeId, packet.resourceId, packet.content); break; case IIPPacketAction.DeleteResource: this.IIPRequestDeleteResource(packet.callbackId, packet.resourceId); @@ -215,7 +224,7 @@ export default class DistributedConnection extends IStore { this.IIPRequestRemoveChild(packet.callbackId, packet.resourceId, packet.childId); break; case IIPPacketAction.RenameResource: - this.IIPRequestRenameResource(packet.callbackId, packet.resourceId, packet.content); + this.IIPRequestRenameResource(packet.callbackId, packet.resourceId, packet.resourceName); break; // Inquire @@ -246,12 +255,11 @@ export default class DistributedConnection extends IStore { break; // Invoke - case IIPPacketAction.InvokeFunctionArrayArguments: - this.IIPRequestInvokeFunctionArrayArguments(packet.callbackId, packet.resourceId, packet.methodIndex, packet.content); - break; - case IIPPacketAction.InvokeFunctionNamedArguments: - this.IIPRequestInvokeFunctionNamedArguments(packet.callbackId, packet.resourceId, packet.methodIndex, packet.content); + case IIPPacketAction.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; @@ -267,28 +275,28 @@ export default class DistributedConnection extends IStore { break; case IIPPacketAction.SetProperty: - this.IIPRequestSetProperty(packet.callbackId, packet.resourceId, packet.methodIndex, packet.content); + this.IIPRequestSetProperty(packet.callbackId, packet.resourceId, packet.methodIndex, packet.dataType, msg); break; - // Attribute + // Attribute @TODO: implement these case IIPPacketAction.GetAllAttributes: - this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, true); + // this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, true); break; case IIPPacketAction.UpdateAllAttributes: - this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, true); + // this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, true); break; case IIPPacketAction.ClearAllAttributes: - this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, true); + // this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, true); break; case IIPPacketAction.GetAttributes: - this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, false); + // this.IIPRequestGetAttributes(packet.callbackId, packet.resourceId, packet.content, false); break; case IIPPacketAction.UpdateAttributes: - this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, false); + // this.IIPRequestUpdateAttributes(packet.callbackId, packet.resourceId, packet.content, false); break; case IIPPacketAction.ClearAttributes: - this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, false); + // this.IIPRequestClearAttributes(packet.callbackId, packet.resourceId, packet.content, false); break; } @@ -296,10 +304,10 @@ export default class DistributedConnection extends IStore { else if (packet.command == IIPPacketCommand.Reply) { switch (packet.action) { case IIPPacketAction.AttachResource: - this.IIPReply(packet.callbackId, packet.classId, packet.resourceAge, packet.resourceLink, packet.content); + this.IIPReply(packet.callbackId, packet.classId, packet.resourceAge, packet.resourceLink, packet.dataType, msg); break; case IIPPacketAction.ReattachResource: - this.IIPReply(packet.callbackId, packet.resourceAge, packet.content); + this.IIPReply(packet.callbackId, packet.resourceAge, packet.dataType, msg); break; case IIPPacketAction.DetachResource: this.IIPReply(packet.callbackId); @@ -316,7 +324,16 @@ export default class DistributedConnection extends IStore { case IIPPacketAction.TemplateFromClassName: case IIPPacketAction.TemplateFromClassId: case IIPPacketAction.TemplateFromResourceId: - this.IIPReply(packet.callbackId, TypeTemplate.parse(packet.content)); + + if (packet.dataType != null) { + var content = msg.clip(packet.dataType?.offset ?? 0, + packet.dataType?.contentLength ?? 0); + this.IIPReply(packet.callbackId, TypeTemplate.parse(content)); + } else { + iipReportError(packet.callbackId, ErrorType.Management, + ExceptionCode.TemplateNotFound.index, "Template not found"); + } + break; case IIPPacketAction.QueryLink: @@ -324,12 +341,11 @@ export default class DistributedConnection extends IStore { case IIPPacketAction.ResourceParents: case IIPPacketAction.ResourceHistory: case IIPPacketAction.LinkTemplates: - this.IIPReply(packet.callbackId, packet.content); + this.IIPReply(packet.callbackId, packet.dataType, msg); break; - case IIPPacketAction.InvokeFunctionArrayArguments: - case IIPPacketAction.InvokeFunctionNamedArguments: - this.IIPReplyInvoke(packet.callbackId, packet.content); + case IIPPacketAction.InvokeFunction: + this.IIPReplyInvoke(packet.callbackId, packet.dataType, msg); break; // case IIPPacketAction.GetProperty: @@ -348,7 +364,7 @@ export default class DistributedConnection extends IStore { // Attribute case IIPPacketAction.GetAllAttributes: case IIPPacketAction.GetAttributes: - this.IIPReply(packet.callbackId, packet.content); + this.IIPReply(packet.callbackId, packet.dataType, msg); break; case IIPPacketAction.UpdateAllAttributes: @@ -373,7 +389,7 @@ export default class DistributedConnection extends IStore { this.IIPReportProgress(packet.callbackId, ProgressType.Execution, packet.progressValue, packet.progressMax); break; case IIPPacketReport.ChunkStream: - this.IIPReportChunk(packet.callbackId, packet.content); + this.IIPReportChunk(packet.callbackId, packet.dataType, msg); break; } @@ -1150,8 +1166,8 @@ export default class DistributedConnection extends IStore { { for (let resource of this.subscriptions.keys()) { - resource.instance.off("ResourceEventOccurred", this.#_instance_eventOccurred, this); - resource.instance.off("ResourceModified", this.#_instance_propertyModified, this); + resource.instance.off("EventOccurred", this.#_instance_eventOccurred, this); + resource.instance.off("PropertyModified", this.#_instance_propertyModified, this); resource.instance.off("ResourceDestroyed", this.#_instance_resourceDestroyed, this); } @@ -1279,33 +1295,14 @@ export default class DistributedConnection extends IStore { } } - sendInvokeByArrayArguments(instanceId, index, parameters) { + sendInvoke(instanceId, index, parameters) { var reply = new AsyncReply(); - var pb = Codec.composeVarArray(parameters, this, true); + var pb = Codec.compose(parameters, this); let callbackId = ++this.callbackCounter; this.sendParams() - .addUint8(0x40 | IIPPacketAction.InvokeFunctionArrayArguments) - .addUint32(callbackId) - .addUint32(instanceId) - .addUint8(index) - .addUint8Array(pb) - .done(); - - this.requests.set(callbackId, reply); - - return reply; - } - - sendInvokeByNamedArguments(instanceId, index, parameters) { - var reply = new AsyncReply(); - - var pb = Codec.composeStructure(parameters, this, true, true, true); - - let callbackId = ++this.callbackCounter; - this.sendParams() - .addUint8(0x40 | IIPPacketAction.InvokeFunctionNamedArguments) + .addUint8(0x40 | IIPPacketAction.InvokeFunction) .addUint32(callbackId) .addUint32(instanceId) .addUint8(index) @@ -1346,7 +1343,7 @@ export default class DistributedConnection extends IStore { } sendChunk(callbackId, chunk) { - var c = Codec.compose(chunk, this, true); + var c = Codec.compose(chunk, this); this.sendParams() .addUint8(0xC0 | IIPPacketReport.ChunkStream) .addUint32(callbackId) @@ -1362,7 +1359,7 @@ export default class DistributedConnection extends IStore { req.trigger(results); } - IIPReplyInvoke(callbackId, result) { + IIPReplyInvoke(callbackId, dataType, data) { var req = this.requests.item(callbackId); @@ -1370,7 +1367,7 @@ export default class DistributedConnection extends IStore { this.requests.remove(callbackId); - Codec.parse(result, 0, {}, this).then(function (rt) { + Codec.parse(data, 0, this, dataType).reply.then(function (rt) { req.trigger(rt); }); } @@ -1391,10 +1388,10 @@ export default class DistributedConnection extends IStore { req.triggerProgress(type, value, max); } - IIPReportChunk(callbackId, data) { + IIPReportChunk(callbackId, dataType, data) { var req = this.requests.item(callbackId); if (req != null) { - Codec.parse(data, 0, {}, this).then(function (x) { + Codec.parse(data, 0, this, dataType).reply.then(function (x) { req.triggerChunk(x); }); } @@ -1412,7 +1409,7 @@ export default class DistributedConnection extends IStore { } } - IIPEventPropertyUpdated(resourceId, index, content) { + IIPEventPropertyUpdated(resourceId, index, dataType, data) { let self = this; @@ -1427,7 +1424,7 @@ export default class DistributedConnection extends IStore { let item = new AsyncReply(); self.queue.add(item); - Codec.parse(content, 0, {}, self).then(function (args) { + Codec.parse(data, 0, self, dataType).reply.then(function (args) { item.trigger(new DistributedResourceQueueItem(r, DistributedResourceQueueItemType.Propery, args, index)); }).error(function (ex) { self.queue.remove(item); @@ -1437,7 +1434,7 @@ export default class DistributedConnection extends IStore { } - IIPEventEventOccurred(resourceId, index, content) { + IIPEventEventOccurred(resourceId, index, dataType, data) { var self = this; this.fetch(resourceId).then(function (r) { @@ -1451,7 +1448,7 @@ export default class DistributedConnection extends IStore { self.queue.add(item); // Codec.parseVarArray(content, 0, content.length, self).then(function (args) { - Codec.parse(content, 0, {}, self).then(function (args) { + Codec.parse(data, 0, self, dataType).reply.then(function (args) { item.trigger(new DistributedResourceQueueItem(r, DistributedResourceQueueItemType.Event, args, index)); }).error(function (ex) { @@ -1483,7 +1480,7 @@ export default class DistributedConnection extends IStore { IIPEventRenamed(resourceId, name) { this.fetch(resourceId).then(function (resource) { - resource.instance.attributes.set("name", name.getString(0, name.length)); + resource.instance.attributes.set("name", name); }); } @@ -1568,7 +1565,7 @@ export default class DistributedConnection extends IStore { .addUint64(r.instance.age) .addUint16(link.length) .addUint8Array(link) - .addUint8Array(Codec.composePropertyValueArray(r._serialize(), self, true)) + .addUint8Array(Codec.compose(r._serialize(), self)) .done(); else self.sendReply(IIPPacketAction.AttachResource, callback) @@ -1576,7 +1573,7 @@ export default class DistributedConnection extends IStore { .addUint64(r.instance.age) .addUint16(link.length) .addUint8Array(link) - .addUint8Array(Codec.composePropertyValueArray(r.instance.serialize(), self, true)) + .addUint8Array(Codec.compose(r.instance.serialize(), self)) .done(); @@ -1591,8 +1588,8 @@ export default class DistributedConnection extends IStore { _subscribe(resource) { - resource.instance.on("ResourceEventOccurred", this.#_instance_eventOccurred, this); - resource.instance.on("ResourceModified", this.#_instance_propertyModified, this); + resource.instance.on("EventOccurred", this.#_instance_eventOccurred, this); + resource.instance.on("PropertyModified", this.#_instance_propertyModified, this); resource.instance.on("ResourceDestroyed", this.#_instance_resourceDestroyed, this); this.subscriptions.set(resource, []); @@ -1600,8 +1597,8 @@ export default class DistributedConnection extends IStore { _unsubscribe(resource) { - resource.instance.off("ResourceEventOccurred", this.#_instance_eventOccurred, this); - resource.instance.off("ResourceModified", this.#_instance_propertyModified, this); + resource.instance.off("EventOccurred", this.#_instance_eventOccurred, this); + resource.instance.off("PropertyModified", this.#_instance_propertyModified, this); resource.instance.off("ResourceDestroyed", this.#_instance_resourceDestroyed, this); this.subscriptions.delete(resource); @@ -1620,7 +1617,7 @@ export default class DistributedConnection extends IStore { // reply ok self.sendReply(IIPPacketAction.ReattachResource, callback) .addUint64(r.instance.age) - .addUint8Array(Codec.composePropertyValueArray(r.instance.serialize(), self, true)) + .addUint8Array(Codec.compose(r.instance.serialize(), self)) .done(); } else { @@ -1694,14 +1691,14 @@ export default class DistributedConnection extends IStore { return; } - Codec.parseVarArray(content, offset, cl, self).then(function (parameters) { + DataDeserializer.listParser(content, offset, cl, self).then(function (parameters) { offset += cl; cl = content.getUint32(offset); - Codec.parseStructure(content, offset, cl, self).then(function (attributes) { + DataDeserializer.typedMapParser(content, offset, cl, self).then(function (attributes) { offset += cl; cl = content.length - offset; - Codec.parseStructure(content, offset, cl, self).then(function (values) { + DataDeserializer.typedMapParser(content, offset, cl, self).then(function (values) { var resource = new (Function.prototype.bind.apply(type, values)); @@ -1772,9 +1769,8 @@ export default class DistributedConnection extends IStore { // send this.sendReply(IIPPacketAction.LinkTemplates, callback) - .addInt32(msg.length) - .addUint8Array(msg.toArray()) - .done(); + .addDC(TransmissionType.compose(TransmissionTypeIdentifier.RawData, msg)) + .done(); } } }; @@ -1807,8 +1803,8 @@ export default class DistributedConnection extends IStore { if (t != null) self.sendReply(IIPPacketAction.TemplateFromClassId, callback) - .addUint32(t.content.length) - .addUint8Array(t.content) + .addDC(TransmissionType.compose( + TransmissionTypeIdentifier.RawData, t.content)) .done(); else { // reply failed @@ -1823,8 +1819,8 @@ export default class DistributedConnection extends IStore { Warehouse.getById(resourceId).then(function (r) { if (r != null) self.sendReply(IIPPacketAction.TemplateFromResourceId, callback) - .addUint32(r.instance.template.content.length) - .addUint8Array(r.instance.template.content) + .addDC(TransmissionType.compose( + TransmissionTypeIdentifier.RawData, r.instance.template.content)) .done(); else { // reply failed @@ -1833,229 +1829,122 @@ export default class DistributedConnection extends IStore { }); } - IIPRequestInvokeFunctionArrayArguments(callback, resourceId, index, content) { + IIPRequestInvokeFunction(callback, resourceId, index, dataType, data) { - var self = this; + let self = this; Warehouse.getById(resourceId).then(function (r) { - if (r != null) { - Codec.parseVarArray(content, 0, content.length, self).then(function (args) { - var ft = r.instance.template.getFunctionTemplateByIndex(index); - if (ft != null) { - if (r instanceof DistributedResource) { - var rt = r._invokeByArrayArguments(index, args); - if (rt != null) { - rt.then(function (res) { - self.sendReply(IIPPacketAction.InvokeFunctionArrayArguments, callback) - .addUint8Array(Codec.compose(res, self)) - .done(); - }); - } - else { - // function not found on a distributed object - } - } - else { + + if (r == null) { + this.sendError(ErrorType.Management, callback, ExceptionCode.ResourceNotFound); + return; + } + + let ft = r.instance.template.getFunctionTemplateByIndex(index); - var fi = r[ft.name]; + if (ft == null) + { + // no function at this index + this.sendError(ErrorType.Management, callback, ExceptionCode.MethodNotFound); + return; + } - if (r.instance.applicable(self.session, ActionType.Execute, ft) == Ruling.Denied) { - self.sendError(ErrorType.Management, callback, ExceptionCode.InvokeDenied); - return; - } - - if (fi instanceof Function) { - args.push(self); - - var rt; - - try - { - rt = fi.apply(r, args); - } - catch(ex) - { - self.sendError(ErrorType.Exception, callback, 0, ex.toString()); - return; - } - - // Is iterator ? - if (rt != null && rt[Symbol.iterator] instanceof Function) { - for (let v of rt) - self.sendChunk(callback, v); - - self.sendReply(IIPPacketAction.InvokeFunctionArrayArguments, callback) - .addUint8(DataType.Void) - .done(); - } - else if (rt instanceof AsyncReply) { - rt.then(function (res) { - self.sendReply(IIPPacketAction.InvokeFunctionArrayArguments, callback) - .addUint8Array(Codec.compose(res, self)) - .done(); - }).error(ex => { - self.sendError(ErrorType.Exception, callback, ex.code, ex.message); - }).progress((pt, pv, pm) => - { - self.sendProgress(callback, pv, pm); - }).chunk(v => - { - self.sendChunk(callback, v); - }); - } - else if (rt instanceof Promise) - { - rt.then(function (res) { - self.sendReply(IIPPacketAction.InvokeFunctionArrayArguments, callback) - .addUint8Array(Codec.compose(res, self)) - .done(); - }).catch(ex => { - self.sendError(ErrorType.Exception, callback, 0, ex.toString()); - }); - } - else { - self.sendReply(IIPPacketAction.InvokeFunctionArrayArguments, callback) - .addUint8Array(Codec.compose(rt, self)) - .done(); - } - } - else { - // ft found, fi not found, this should never happen - this.sendError(ErrorType.Management, callback, ExceptionCode.MethodNotFound); - } - } + Codec.parse(data, 0, self, dataType).reply.then(function (args) { + if (r instanceof DistributedResource) { + var rt = r._invoke(index, args); + if (rt != null) { + rt.then(function (res) { + self.sendReply(IIPPacketAction.InvokeFunction, callback) + .addUint8Array(Codec.compose(res, self)) + .done(); + }); } else { - // no function at this index + // function not found on a distributed object this.sendError(ErrorType.Management, callback, ExceptionCode.MethodNotFound); + return; } - }); - } - else { - // no resource with this id - this.sendError(ErrorType.Management, callback, ExceptionCode.ResourceNotFound); - } + } + else + { + var fi = r[ft.name]; + + if (!(fi instanceof Function)) { + // ft found, fi not found, this should never happen + this.sendError(ErrorType.Management, callback, ExceptionCode.MethodNotFound); + return; + } + + if (r.instance.applicable(self.session, ActionType.Execute, ft) == Ruling.Denied) { + self.sendError(ErrorType.Management, callback, ExceptionCode.InvokeDenied); + return; + } + + let indexedArgs = []; + + for(let i = 0; i < ft.args.length; i++) + indexedArgs.push(args.get(i)); + + indexedArgs.push(self); + + let rt; + + try + { + rt = fi.apply(r, indexedArgs); + } + catch(ex) + { + self.sendError(ErrorType.Exception, callback, 0, ex.toString()); + return; + } + + // Is iterator ? + if (rt != null && rt[Symbol.iterator] instanceof Function) { + for (let v of rt) + self.sendChunk(callback, v); + + self.sendReply(IIPPacketAction.InvokeFunction, callback) + .addUint8(DataType.Void) + .done(); + } + else if (rt instanceof AsyncReply) { + rt.then(function (res) { + self.sendReply(IIPPacketAction.InvokeFunction, callback) + .addUint8Array(Codec.compose(res, self)) + .done(); + }).error(ex => { + self.sendError(ErrorType.Exception, callback, ex.code, ex.message); + }).progress((pt, pv, pm) => + { + self.sendProgress(callback, pv, pm); + }).chunk(v => + { + self.sendChunk(callback, v); + }); + } + else if (rt instanceof Promise) + { + rt.then(function (res) { + self.sendReply(IIPPacketAction.InvokeFunction, callback) + .addUint8Array(Codec.compose(res, self)) + .done(); + }).catch(ex => { + self.sendError(ErrorType.Exception, callback, 0, ex.toString()); + }); + } + else { + self.sendReply(IIPPacketAction.InvokeFunction, callback) + .addUint8Array(Codec.compose(rt, self)) + .done(); + } + + } + }); }); } - IIPRequestInvokeFunctionNamedArguments(callback, resourceId, index, content) { - - var self = this; - - Warehouse.getById(resourceId).then(function (r) { - if (r != null) { - Codec.parseStructure(content, 0, content.length, self).then(function (namedArgs) { - var ft = r.instance.template.getFunctionTemplateByIndex(index); - if (ft != null) { - if (r instanceof DistributedResource) { - var rt = r._invokeByNamedArguments(index, namedArgs); - if (rt != null) { - rt.then(function (res) { - self.sendReply(IIPPacketAction.InvokeFunctionNamedArguments, callback) - .addUint8Array(Codec.compose(res, self)) - .done(); - }); - } - else { - // function not found on a distributed object - } - } - else { - - var fi = r[ft.name]; - - if (r.instance.applicable(self.session, ActionType.Execute, ft) == Ruling.Denied) { - self.sendError(ErrorType.Management, callback, ExceptionCode.InvokeDenied); - return; - } - - if (fi instanceof Function) { - - var pi = TypeTemplate.getFunctionParameters(fi); - var args = new Array(pi.length); - - for (var i = 0; i < pi.length; i++) { - if (namedArgs[pi[i]] !== undefined) - args[i] = namedArgs[pi[i]]; - } - - // pass this to the last argument if it is undefined - if (args[args.length - 1] === undefined) - args[args.length - 1] = self; - - - var rt; - - try - { - rt = fi.apply(r, args); - } - catch(ex) - { - self.sendError(ErrorType.Exception, callback, 0, ex.toString()); - return; - } - - // Is iterator ? - if (rt != null && rt[Symbol.iterator] instanceof Function) { - for (let v of rt) - self.sendChunk(callback, v); - - self.sendReply(IIPPacketAction.InvokeFunctionNamedArguments, callback) - .addUint8(DataType.Void) - .done(); - } - else if (rt instanceof AsyncReply) { - rt.then(function (res) { - self.sendReply(IIPPacketAction.InvokeFunctionNamedArguments, callback) - .addUint8Array(Codec.compose(res, self)) - .done(); - }).error(ex => { - self.sendError(ErrorType.Exception, callback, ex.code, ex.message); - }).progress((pt, pv, pm) => - { - self.sendProgress(callback, pv, pm); - }).chunk(v => - { - self.sendChunk(callback, v); - }); - } - else if (rt instanceof Promise) - { - rt.then(function (res) { - self.sendReply(IIPPacketAction.InvokeFunctionNamedArguments, callback) - .addUint8Array(Codec.compose(res, self)) - .done(); - }).catch(ex => { - self.sendError(ErrorType.Exception, callback, 0, ex.toString()); - }); - } - else { - self.sendReply(IIPPacketAction.InvokeFunctionNamedArguments, callback) - .addUint8Array(Codec.compose(rt, self)) - .done(); - } - } - else { - // ft found, fi not found, this should never happen - this.sendError(ErrorType.Management, callback, ExceptionCode.MethodNotFound); - } - } - } - else { - // no function at this index - this.sendError(ErrorType.Management, callback, ExceptionCode.MethodNotFound); - } - }); - } - else { - // no resource with this id - this.sendError(ErrorType.Management, callback, ExceptionCode.ResourceNotFound); - } - }); - } - // IIPRequestGetProperty(callback, resourceId, index) { // var self = this; @@ -2222,7 +2111,7 @@ export default class DistributedConnection extends IStore { }); } - IIPRequestSetProperty(callback, resourceId, index, content) { + IIPRequestSetProperty(callback, resourceId, index, dataType, data) { var self = this; @@ -2232,7 +2121,7 @@ export default class DistributedConnection extends IStore { var pt = r.instance.template.getPropertyTemplateByIndex(index); if (pt != null) { - Codec.parse(content, 0, {}, this).then(function (value) { + Codec.parse(data, 0, self, dataType).reply.then(function (value) { if (r instanceof DistributedResource) { // propagation r._set(index, value).then(function (x) { @@ -2304,7 +2193,7 @@ export default class DistributedConnection extends IStore { self.sendError(ErrorType.Management, callback, ExceptionCode.ResourceNotFound); else self.sendReply(IIPPacketAction.QueryLink, callback) - .addUint8Array(Codec.composeResourceArray(list, self, true)) + .addUint8Array(Codec.compose(list, self)) .done(); } }; @@ -2354,10 +2243,16 @@ export default class DistributedConnection extends IStore { .addUint16(sb.length) .addUint8Array(sb) .done() - .then(function (args) { - Codec.parseResourceArray(args[0], 0, args[0].length, self).then(function (resources) { - reply.trigger(resources); - }); + .then(function (ar) { + + let dataType = ar[0]; + let data = ar[1]; + + Codec.parse(data, 0, self, dataType).reply.then((resources) => { + reply.trigger((resources)) + } + ).error((ex) => reply.triggerError(ex)); + }).error(function (ex) { reply.triggerError(ex); }); @@ -2459,10 +2354,12 @@ export default class DistributedConnection extends IStore { var templates = []; // parse templates - var data = rt[0]; + + let tt = rt[0]; + let data = rt[1] ; + //var offset = 0; - for (var offset = 0; offset < data.length;) - { + for (var offset = tt.offset; offset < tt.contentLength;) { var cs = data.getUint32(offset); offset += 4; templates.push(TypeTemplate.parse(data, offset, cs)); @@ -2523,17 +2420,34 @@ export default class DistributedConnection extends IStore { //let dr = resource || new DistributedResource(self, id, rt[1], rt[2]); + let transmissionType = rt[3] ; + let content = rt[4] ; + self.getTemplate(rt[0]).then(function (tmp) { // ClassId, ResourceAge, ResourceLink, Content if (resource == null) { let wp = Warehouse.put(id.toString(), dr, self, null, tmp).then(function(ok){ - Codec.parsePropertyValueArray(rt[3], 0, rt[3].length, self).then(function (ar) { - dr._attach(ar); - self.resourceRequests.remove(id); - reply.trigger(dr); - }); + + + Codec.parse(content, 0, self, transmissionType) + .reply + .then((ar) => { + var pvs = new PropertyValueArray(); + + for (var i = 0; i < ar.length; i += 3) + pvs.push(new PropertyValue( + ar[i + 2], ar[i], ar[i + 1])); + + dr._attach(pvs); + + self.resourceRequests.remove(id); + reply.trigger(dr); + }) + .error((ex) => reply.triggerError(ex)); + + }); wp.error(function(ex){ @@ -2542,13 +2456,24 @@ export default class DistributedConnection extends IStore { } else { - Codec.parsePropertyValueArray(rt[3], 0, rt[3].length, self).then(function (ar) { - dr._attach(ar); - self.resourceRequests.remove(id); - reply.trigger(dr); - }).error(function(ex){ - reply.triggerError(ex); - }); + Codec.parse(content, 0, self, transmissionType) + .reply + .then((ar) => { + //print("attached"); + if (results != null) { + var pvs = new PropertyValueArray(); + + for (var i = 0; i < ar.length; i += 3) + pvs.push(new PropertyValue( + 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); @@ -2595,26 +2520,20 @@ export default class DistributedConnection extends IStore { .done(); } - #_instance_propertyModified = function(resource, name, newValue) { - var pt = resource.instance.template.getPropertyTemplateByName(name); - - if (pt == null) - return; + #_instance_propertyModified = function(info) { this.sendEvent(IIPPacketEvent.PropertyUpdated) - .addUint32(resource.instance.id) - .addUint8(pt.index) - .addUint8Array(Codec.compose(newValue, this)) + .addUint32(info.resource.instance?.id) + .addUint8(info.propertyTemplate.index) + .addUint8Array(Codec.compose(info.value, this)) .done(); + } - #_instance_eventOccurred = function(resource, issuer, receivers, name, args) { - var et = resource.instance.template.getEventTemplateByName(name); - - if (et == null) - return; - - if (et.listenable) + #_instance_eventOccurred = function(info) { + + + if (info.eventTemplate.listenable) { // check the client requested listen if (!this.subscriptions.has(resource)) @@ -2624,19 +2543,20 @@ export default class DistributedConnection extends IStore { return; } - if (receivers instanceof Function) - if (!receivers(this.sessions)) + if (info.receivers instanceof Function) + if (!info.receivers(this.sessions)) return; - if (resource.instance.applicable(this.session, ActionType.ReceiveEvent, et, issuer) == Ruling.Denied) + if (info.resource.instance.applicable(this.session, + ActionType.ReceiveEvent, info.eventTemplate, info.issuer) == Ruling.Denied) return; // compose the packet this.sendEvent(IIPPacketEvent.EventOccurred) - .addUint32(resource.instance.id) - .addUint8(et.index) - .addUint8Array(Codec.compose(args, this, true)) + .addUint32(info.resource.instance.id) + .addUint8(info.eventTemplate.index) + .addUint8Array(Codec.compose(info.value, this)) .done(); } @@ -2725,7 +2645,7 @@ export default class DistributedConnection extends IStore { return; } - resource.instance.name = name.getString(0, name.length); + resource.instance.name = name; self.sendReply(IIPPacketAction.RenameResource, callback) .done(); }); @@ -2740,7 +2660,7 @@ export default class DistributedConnection extends IStore { } self.sendReply(IIPPacketAction.ResourceChildren, callback) - .addUint8Array(Codec.composeResourceArray(resource.instance.children.toArray(), this, true)) + .addUint8Array(Codec.compose(resource.instance.children.toArray(), self)) .done(); }); @@ -2756,7 +2676,7 @@ export default class DistributedConnection extends IStore { } self.sendReply(IIPPacketAction.ResourceParents, callback) - .addUint8Array(Codec.composeResourceArray(resource.instance.parents.toArray(), this, true)) + .addUint8Array(Codec.compose(resource.instance.parents.toArray(), self)) .done(); }); } @@ -2801,7 +2721,7 @@ export default class DistributedConnection extends IStore { return; } - Codec.parseStructure(attributes, 0, attributes.length, this).then(function (attrs) { + DataDeserializer.typedListParser(attributes, 0, attributes.length, this).then(function (attrs) { if (r.instance.setAttributes(attrs, clearAttributes)) self.sendReply(clearAttributes ? IIPPacketAction.ClearAllAttributes : IIPPacketAction.ClearAttributes, callback) @@ -2826,12 +2746,17 @@ export default class DistributedConnection extends IStore { this.sendRequest(IIPPacketAction.ResourceChildren) .addUint32(resource._p.instanceId) .done() - .then(function (d) { + .then(function (ar) { - Codec.parseResourceArray(d, 0, d.length, self).then(function (resources) { - rt.trigger(resources); - }).error(function (ex) { rt.triggerError(ex); }); - }); + let dataType = ar[0]; + let data = ar[1]; + + Codec.parse(data, 0, self, dataType).reply.then((resources) => { + rt.trigger(resources); + }) + .error((ex) => rt.triggerError(ex)); + + }); return rt; } @@ -2846,10 +2771,15 @@ export default class DistributedConnection extends IStore { this.sendRequest(IIPPacketAction.ResourceParents) .addUint32(resource._p.instanceId) .done() - .then(function (d) { - Codec.parseResourceArray(d, 0, d.length, self).then(function (resources) { - rt.trigger(resources); - }).error(function (ex) { rt.triggerError(ex); }); + .then(function (ar) { + + let dataType = ar[0] ; + let data = ar[1]; + Codec.parse(data, 0, self, dataType).reply.then((resources) => { + rt.trigger(resources); + }) + .error((ex) => rt.triggerError(ex)); + }); return rt; @@ -2891,7 +2821,7 @@ export default class DistributedConnection extends IStore { this.sendRequest(clearAttributes ? IIPPacketAction.UpdateAllAttributes : IIPPacketAction.UpdateAttributes) .addUint32(resource._p.instanceId) - .addUint8Array(Codec.composeStructure(attributes, this, true, true, true)) + .addUint8Array(Codec.compose(attributes, this)) .done() .then(function () { rt.trigger(true); @@ -2904,35 +2834,47 @@ export default class DistributedConnection extends IStore { if (resource._p.connection != this) return new AsyncReply(null); - var rt = new AsyncReply(); - var self = this; + let rt = new AsyncReply(); + let self = this; if (attributes == null) { this.sendRequest(IIPPacketAction.GetAllAttributes) .addUint32(resource._p.instanceId) .done() .then(function (ar) { - Codec.parseStructure(ar[0], 0, ar[0].length, this).then(function (st) { - for (var a in st) - resource.instance.attributes.set(a, st[a]); - rt.trigger(st); - }).error(function (ex) { rt.triggerError(ex); }); - }); + + let dataType = ar[0]; + let data = ar[1]; + + Codec.parse(data, 0, self, dataType).reply.then((st) => { + resource.instance?.setAttributes(st); + rt.trigger(st); + }) + .error((ex) => rt.triggerError(ex)); + + }).error(function(ex) { rt.triggerError(ex); }); } else { - var attrs = DC.stringArrayToBytes(attributes); + let attrs = DC.stringArrayToBytes(attributes); this.sendRequest(IIPPacketAction.GetAttributes) .addUint32(resource._p.instanceId) .addUint32(attrs.length) .addUint8Array(attrs) .done() .then(function (ar) { - Codec.parseStructure(ar[0], 0, ar[0].length, self).then(function (st) { - for (var a in st) - resource.instance.attributes.set(a, st[a]); + + + let dataType = ar[0] ; + let data = ar[1] ; + + Codec.parse(data, 0, self, dataType).reply + .then((st) => { + resource.instance?.setAttributes(st); + rt.trigger(st); - }).error(function (ex) { rt.triggerError(ex); }); - }); + }) + .error((ex) => rt.triggerError(ex)); + }).error((ex) => rt.triggerError(ex));; } return rt; diff --git a/src/Net/IIP/DistributedResource.js b/src/Net/IIP/DistributedResource.js index 61cffd9..d663a66 100644 --- a/src/Net/IIP/DistributedResource.js +++ b/src/Net/IIP/DistributedResource.js @@ -29,12 +29,15 @@ import IResource from '../../Resource/IResource.js'; import AsyncReply from '../../Core/AsyncReply.js'; import Codec from '../../Data/Codec.js'; -import Structure from '../../Data/Structure.js'; import IIPPacketAction from '../Packets//IIPPacketAction.js'; import EventTemplate from '../../Resource/Template/EventTemplate.js'; import AsyncException from '../../Core/AsyncException.js'; import ExceptionCode from '../../Core//ExceptionCode.js'; import ErrorType from '../../Core/ErrorType.js'; +import {UInt8} from '../../Data/ExtendedTypes.js'; +import TypedMap from '../../Data/TypedMap.js'; +import PropertyValueArray from '../../Data/PropertyValueArray.js'; +import PropertyValue from '../../Data/PropertyValue.js'; export default class DistributedResource extends IResource { @@ -74,7 +77,7 @@ export default class DistributedResource extends IResource _serialize() { - var props = []; + var props = new PropertyValueArray(); for (var i = 0; i < this._p.properties.length; i++) props.push(new PropertyValue(this._p.properties[i], @@ -112,25 +115,37 @@ export default class DistributedResource extends IResource var self = this; - var makeFunc = function(index) + var makeFunc = function(ft) { var func = function () { + var argsMap = new (TypedMap.of(UInt8, Object)); + if ( arguments.length == 1 && arguments[0] instanceof Object && arguments[0].constructor.name == "Object") { - var namedArgs = new Structure(arguments[0]); - return self._invokeByNamedArguments(index, namedArgs); + + // named args + for (let i = 0; i < ft.args.length; i++){ + let arg = ft.args[i]; + if (arguments[arg.name] != undefined) { + argsMap.set(new UInt8(arg.index), arguments[arg.name]); + } + } + + return self._invoke(ft.index, argsMap); } else { - return self._invokeByArrayArguments(index, arguments); + for(let i = 0; (i < arguments.length) && (i < ft.args.length); i++) + argsMap.set(new UInt8(i), arguments[i]); + return self._invoke(ft.index, argsMap); } }; // get expansion - func.help = self.instance.template.functions[index].expansion; + func.help = self.instance.template.functions[ft.index].expansion; return func; }; @@ -148,15 +163,15 @@ export default class DistributedResource extends IResource }; }; - for(var i = 0; i < this.instance.template.functions.length; i++) + for(let i = 0; i < this.instance.template.functions.length; i++) { - var ft = this.instance.template.functions[i]; - this[ft.name] = makeFunc(ft.index); + let ft = this.instance.template.functions[i]; + this[ft.name] = makeFunc(ft); } - for(var i = 0; i < this.instance.template.properties.length; i++) + for(let i = 0; i < this.instance.template.properties.length; i++) { - var pt = this.instance.template.properties[i]; + let pt = this.instance.template.properties[i]; Object.defineProperty(this, pt.name, { get: makeGetter(pt.index), @@ -202,10 +217,10 @@ export default class DistributedResource extends IResource //@TODO if array _emitArgs //this._emitArgs(et.name, [args]); this._emit(et.name, args); - this.instance._emitResourceEvent(null, null, et.name, args); + this.instance._emitResourceEvent(null, null, et, args); } - _invokeByArrayArguments(index, args) { + _invoke(index, args) { if (this.destroyed) throw new Error("Trying to access destroyed object"); @@ -215,20 +230,7 @@ export default class DistributedResource extends IResource if (index >= this.instance.template.functions.length) throw new Error("Function index is incorrect"); - return this._p.connection.sendInvokeByArrayArguments(this._p.instanceId, index, args); - } - - _invokeByNamedArguments(index, namedArgs) { - 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.sendInvokeByNamedArguments(this._p.instanceId, index, namedArgs); + return this._p.connection.sendInvoke(this._p.instanceId, index, args); } _get(index) diff --git a/src/Net/NetworkBuffer.js b/src/Net/NetworkBuffer.js index 88beed1..fa2078d 100644 --- a/src/Net/NetworkBuffer.js +++ b/src/Net/NetworkBuffer.js @@ -24,9 +24,8 @@ * Created by Ahmed Zamil on 01/09/2017. */ -"use strict"; -import DC from '../Data/DataConverter.js'; +import DC from '../Data/DC.js'; export default class NetworkBuffer { constructor() { diff --git a/src/Net/Packets/IIPPacket.js b/src/Net/Packets/IIPPacket.js index e5ffae4..7c9ae6b 100644 --- a/src/Net/Packets/IIPPacket.js +++ b/src/Net/Packets/IIPPacket.js @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017 Ahmed Kh. Zamil +* 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 @@ -31,6 +31,7 @@ import IIPPacketCommand from "./IIPPacketCommand.js"; import IIPPacketEvent from "./IIPPacketEvent.js"; import IIPPacketReport from "./IIPPacketReport.js"; import DataType from '../../Data/DataType.js'; +import TransmissionType from '../../Data/TransmissionType.js'; export default class IIPPacket { @@ -42,7 +43,7 @@ export default class IIPPacket this.resourceId = 0; this.newResourceId = 0; this.resourceAge = 0; - this.content = []; + //this.content = []; this.errorCode = 0; this.errorMessage = ""; this.className = ""; @@ -53,6 +54,8 @@ export default class IIPPacket this.callbackId = 0; this.dataLengthNeeded = 0; this.originalOffset = 0; + this.resourceName = ""; + this.dataType = null; } notEnough(offset, ends, needed) @@ -136,14 +139,13 @@ export default class IIPPacket if (this.notEnough(offset, ends, 2)) return -this.dataLengthNeeded; - var cl = data.getUint16(offset); + let cl = data.getUint16(offset); offset += 2; if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); - + this.resourceName = data.getString(offset, cl); offset += cl; } else if (this.event == IIPPacketEvent.PropertyUpdated @@ -154,61 +156,28 @@ export default class IIPPacket this.methodIndex = data[offset++]; - var dt = data.getUint8(offset++); - var size = DataType.sizeOf(dt); + var parsed = TransmissionType.parse(data, offset, ends); - if (size < 0) - { - if (this.notEnough(offset, ends, 4)) - return -this.dataLengthNeeded; - - var cl = data.getUint32(offset); - offset += 4; - - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } - else - { - if (this.notEnough(offset, ends, size)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset - 1, size + 1); - offset += size; - } + if (parsed.type == null) return -parsed.size; + + this.dataType = parsed.type; + offset += parsed.size; + } - // else if (this.event == IIPPacketEvent.EventOccurred) - // { - // if (this.notEnough(offset, ends, 5)) - // return -this.dataLengthNeeded; - - // this.methodIndex = data.getUint8(offset++); - - // var cl = data.getUint32(offset); - // offset += 4; - - // if (this.notEnough(offset, ends, cl)) - // return -this.dataLengthNeeded; - - // this.content = data.clip(offset, cl); - // offset += cl; - // } // Attribute else if (this.event == IIPPacketEvent.AttributesUpdated) { if (this.notEnough(offset, ends, 4)) return -this.dataLengthNeeded; - var cl = data.getUint32(offset); + let cl = data.getUint32(offset); offset += 4; if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); + //@TODO: fix this + //this.content = data.clip(offset, cl); offset += cl; } @@ -246,20 +215,21 @@ export default class IIPPacket else if (this.action == IIPPacketAction.CreateResource) { if (this.notEnough(offset, ends, 12)) - return -dataLengthNeeded; + return -this.dataLengthNeeded; this.storeId = data.getUint32(offset); offset += 4; this.resourceId = data.getUint32(offset); offset += 4; - var cl = data.getUint32(offset); + let cl = data.getUint32(offset); offset += 4; if (this.notEnough(offset, ends, cl)) - return -dataLengthNeeded; + return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); + //@TODO: fix this + //this.content = data.clip(offset, cl); } else if (this.action == IIPPacketAction.DeleteResource) { @@ -291,13 +261,13 @@ export default class IIPPacket this.resourceId = data.getUint32(offset); offset += 4; - var cl = data.getUint16(offset); + let cl = data.getUint16(offset); offset += 2; if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); + this.resourceName = data.getString(offset, cl); offset += cl; } @@ -306,7 +276,7 @@ export default class IIPPacket if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - var cl = data.getUint8(offset++); + let cl = data.getUint8(offset++); if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; @@ -337,7 +307,7 @@ export default class IIPPacket if (this.notEnough(offset, ends, 2)) return -this.dataLengthNeeded; - var cl = data.getUint16(offset); + let cl = data.getUint16(offset); offset += 2; if (this.notEnough(offset, ends, cl)) @@ -370,8 +340,7 @@ export default class IIPPacket offset += 8; } - else if ( this.action == IIPPacketAction.InvokeFunctionArrayArguments - || this.action == IIPPacketAction.InvokeFunctionNamedArguments) + else if ( this.action == IIPPacketAction.InvokeFunction ) { if (this.notEnough(offset, ends, 9)) @@ -382,14 +351,13 @@ export default class IIPPacket this.methodIndex = data.getUint8(offset++); - var cl = data.getUint32(offset); - offset += 4; + + let parsed = TransmissionType.parse(data, offset, ends); - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; + if (parsed.type == null) return -parsed.size; - this.content = data.clip(offset, cl); - offset += cl; + this.dataType = parsed.type; + offset += parsed.size; } else if (this.action == IIPPacketAction.Listen @@ -428,33 +396,13 @@ export default class IIPPacket offset += 4; this.methodIndex = data[offset++]; + let parsed = TransmissionType.parse(data, offset, ends); - - var dt = data.getUint8(offset++); - var size = DataType.sizeOf(dt); - - if (size < 0) - { - if (this.notEnough(offset, ends, 4)) - return -this.dataLengthNeeded; - - var cl = data.getUint32(offset); - offset += 4; - - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset-5, cl + 5); - offset += cl; - } - else - { - if (this.notEnough(offset, ends, size)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset-1, size + 1); - offset += size; - } + if (parsed.type == null) return -parsed.size; + + this.dataType = parsed.type; + offset += parsed.size; + } // Attribute @@ -468,13 +416,14 @@ export default class IIPPacket this.resourceId = data.getUint32(offset); offset += 4; - var cl = data.getUint32(offset); + let cl = data.getUint32(offset); offset += 4; if (this.notEnough(offset, ends, cl)) return -this.dataLengthNeeded; - this.content = data.clip(offset, cl); + // @TODO: fix this + //this.content = data.clip(offset, cl); offset += cl; } @@ -493,7 +442,7 @@ export default class IIPPacket this.resourceAge = data.getUint64(offset); offset += 8; - var cl = data.getUint16(offset); + let cl = data.getUint16(offset); offset+=2; if (this.notEnough(offset, ends, cl)) @@ -502,17 +451,13 @@ export default class IIPPacket this.resourceLink = data.getString(offset, cl); offset += cl; - if (this.notEnough(offset, ends, 4)) - return -this.dataLengthNeeded; + let parsed = TransmissionType.parse(data, offset, ends); - cl = data.getUint32(offset); - offset += 4; - - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset, cl); - offset += cl; + if (parsed.type == null) return -parsed.size; + + this.dataType = parsed.type; + offset += parsed.size; + } else if (this.action == IIPPacketAction.DetachResource) { @@ -544,52 +489,30 @@ export default class IIPPacket || this.action == IIPPacketAction.GetAllAttributes || this.action == IIPPacketAction.GetAttributes) { - if (this.notEnough(offset, ends, 4)) - return -this.dataLengthNeeded; - var cl = data.getUint32(offset); - offset += 4; + if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; + let parsed = TransmissionType.parse(data, offset, ends); + + if (parsed.type == null) return -parsed.size; + + this.dataType = parsed.type; + offset += parsed.size; - this.content = data.clip(offset, cl); - offset += cl; } - else if (this.action == IIPPacketAction.InvokeFunctionArrayArguments - || this.action == IIPPacketAction.InvokeFunctionNamedArguments) - //|| this.action == IIPPacketAction.GetProperty - //|| this.action == IIPPacketAction.GetPropertyIfModified) + else if (this.action == IIPPacketAction.InvokeFunction) { if (this.notEnough(offset, ends, 1)) return -this.dataLengthNeeded; - var dt = data.getUint8(offset++); - var size = DataType.sizeOf(dt); + let parsed = TransmissionType.parse(data, offset, ends); - if (size < 0) - { - if (this.notEnough(offset, ends, 4)) - return -this.dataLengthNeeded; - - var cl = data.getUint32(offset); - offset += 4; - - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } - else - { - if (this.notEnough(offset, ends, size)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset - 1, size + 1); - offset += size; - } + if (parsed.type == null) return -parsed.size; + + this.dataType = parsed.type; + offset += parsed.size; + } else if (this.action == IIPPacketAction.SetProperty || this.action == IIPPacketAction.Listen @@ -619,7 +542,7 @@ export default class IIPPacket if (this.notEnough(offset, ends, 2)) return -this.dataLengthNeeded; - var cl = data.getUint16(offset); + let cl = data.getUint16(offset); offset += 2; if (this.notEnough(offset, ends, cl)) @@ -640,31 +563,16 @@ export default class IIPPacket } else if (this.report == IIPPacketReport.ChunkStream) { - var dt = data.getUint8(offset++); - var size = DataType.sizeOf(dt); + if (this.notEnough(offset, ends, 1)) + return -this.dataLengthNeeded; - if (size < 0) - { - if (this.notEnough(offset, ends, 4)) - return -this.dataLengthNeeded; - - var cl = data.getUint32(offset); - offset += 4; - - if (this.notEnough(offset, ends, cl)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset - 5, cl + 5); - offset += cl; - } - else - { - if (this.notEnough(offset, ends, size)) - return -this.dataLengthNeeded; - - this.content = data.clip(offset - 1, size + 1); - offset += size; - } + let parsed = TransmissionType.parse(data, offset, ends); + + if (parsed.type == null) return -parsed.size; + + this.dataType = parsed.type; + offset += parsed.size; + } } diff --git a/src/Net/Packets/IIPPacketAction.js b/src/Net/Packets/IIPPacketAction.js index d8bee5d..0a140f4 100644 --- a/src/Net/Packets/IIPPacketAction.js +++ b/src/Net/Packets/IIPPacketAction.js @@ -21,8 +21,8 @@ export default // const IIPPacketAction = LinkTemplates: 15, // Request Invoke - InvokeFunctionArrayArguments: 16, - InvokeFunctionNamedArguments: 17, + InvokeFunction: 16, + Reserved: 17, Listen: 18, Unlisten: 19, SetProperty: 20, diff --git a/src/Net/Sockets/WSocket.js b/src/Net/Sockets/WSocket.js index 24fadca..a77ff38 100644 --- a/src/Net/Sockets/WSocket.js +++ b/src/Net/Sockets/WSocket.js @@ -4,22 +4,18 @@ import ExceptionCode from "../../Core/ExceptionCode.js"; import ISocket from "./ISocket.js"; import SocketState from "./SocketState.js"; import NetworkBuffer from "../NetworkBuffer.js"; - + export default class WSocket extends ISocket { - //SocketState State { get; } - //INetworkReceiver Receiver { get; set; } constructor(websocket){ super(); this.receiveNetworkBuffer = new NetworkBuffer(); this.sendNetworkBuffer = new NetworkBuffer(); this.held = false; - if (websocket != null)// instanceof WebSocket) + if (websocket != null) { - //websocket.onerror = () => { - // self.state = SocketState.Closed; - //}; + websocket.onopen = () => { self.state = SocketState.Established; }; @@ -47,6 +43,8 @@ export default class WSocket extends ISocket sendAll(message) { + // console.log("Out ", message.byteLength); + if (this.held) this.sendNetworkBuffer.writeAll(message); else @@ -68,31 +66,53 @@ export default class WSocket extends ISocket this.ws.close(); } + static webSocket = null; + + static async getWebScoket(){ + if (WSocket.webSocket == null) { + if (typeof window === 'undefined') { + const wsModule = await import('ws'); + WSocket.webSocket = wsModule.default; + } + else + { + WSocket.webSocket = WebSocket; + } + } + return WSocket.webSocket; + } + connect(hostname, port, secure = false) { let self = this; - var rt = new AsyncReply(); - this.state = SocketState.Connecting; - this.url = `ws${secure ? 's' : ''}://${hostname}:${port}`; - let ws = new WebSocket(this.url, "iip"); - ws.binaryType = "arraybuffer"; + WSocket.getWebScoket().then(webSocket => + { - ws.onopen = () => { - self.state = SocketState.Established; - rt.trigger(true); - }; + let ws; - ws.onerror = () => { - self.state = SocketState.Closed; - rt.triggerError(ErrorType.Management, ExceptionCode.HostNotReachable); - }; + ws = new webSocket(this.url, "iip"); + + + ws.binaryType = "arraybuffer"; + + ws.onopen = () => { + self.state = SocketState.Established; + rt.trigger(true); + }; + + ws.onerror = () => { + self.state = SocketState.Closed; + rt.triggerError(ErrorType.Management, ExceptionCode.HostNotReachable); + }; + + self._assign(ws); + + }); - this._assign(ws); - return rt;// new AsyncReply(true); } @@ -106,6 +126,7 @@ export default class WSocket extends ISocket }; ws.onmessage = function(msg) { + //console.log("WREC ", msg.data.byteLength); self.receiveNetworkBuffer.writeAll(msg.data); self.receiver.networkReceive(this, self.receiveNetworkBuffer); //self.lastAction = new Date(); @@ -155,11 +176,4 @@ export default class WSocket extends ISocket this.state = SocketState.Closed; } } -} - - // if (this.holdSending) { - // //console.log("hold ", data.length); - // this.sendBuffer.writeAll(data); - // } - // else - // //console.log("Send", data.length); \ No newline at end of file +} \ No newline at end of file diff --git a/src/Resource/CustomResourceEvent.js b/src/Resource/CustomResourceEvent.js index 051b4dd..3be5b4a 100644 --- a/src/Resource/CustomResourceEvent.js +++ b/src/Resource/CustomResourceEvent.js @@ -28,10 +28,10 @@ export default class CustomResourceEvent { - constructor(issuer, receivers, args) + constructor(issuer, receivers, value) { this.issuer = issuer; this.receivers = receivers; - this.args = args; + this.value = value; } } \ No newline at end of file diff --git a/src/Resource/EventOccurredInfo.js b/src/Resource/EventOccurredInfo.js new file mode 100644 index 0000000..566a3a0 --- /dev/null +++ b/src/Resource/EventOccurredInfo.js @@ -0,0 +1,20 @@ +import Session from '../Security/Authority/Session.js'; +import IResource from './IResource.js'; +import EventTemplate from './Template/EventTemplate.js'; + +export default class EventOccurredInfo { + + get name(){ + return this.eventTemplate.name; + } + + + constructor(resource, eventTemplate, value, issuer, + receivers) { + this.resource =resource; + this.eventTemplate = eventTemplate; + this.value = value; + this.issuer = issuer; + this.receivers = receivers; + } +} diff --git a/src/Resource/FactoryEntry.js b/src/Resource/FactoryEntry.js new file mode 100644 index 0000000..7eb967e --- /dev/null +++ b/src/Resource/FactoryEntry.js @@ -0,0 +1,34 @@ +export default class FactoryEntry { + + //Type get type => T; + + //late Type nullableType; + //final Function instanceCreator; + //final Function arrayCreator = () => []; + //final RepresentationType representationType; + + isMapKeySubType(map) { + //return map is Map; + } + + isMapValueSubType(map) { + //return map is Map; + } + + isListSubType(list) { + //return list is List; + } + + constructor(type, representationType) { + this.type = type; + this.nullableType = this.getNullableType(type); + this.representationType = representationType; + } + + getNullableType(type){ + let c = class extends type {}; + Object.defineProperty(c, "name", {value: "Nullable" + type.name}); + Object.defineProperty(c, "nullable", {value: true}); + return c; + } +} \ No newline at end of file diff --git a/src/Resource/IResource.js b/src/Resource/IResource.js index 2effe64..a3de804 100644 --- a/src/Resource/IResource.js +++ b/src/Resource/IResource.js @@ -53,6 +53,10 @@ export default class IResource extends IDestructible super(); } + toString(){ + return this?.instance?.template?.namespace ?? "IResource"; + } + static get template() { return { diff --git a/src/Resource/IStore.js b/src/Resource/IStore.js index 6c7f15d..d269983 100644 --- a/src/Resource/IStore.js +++ b/src/Resource/IStore.js @@ -46,6 +46,11 @@ export default class IStore extends IResource { } + modify(resource, propertyName, value, age, dateTime) + { + + } + getRecord(resource, fromDate, toDate) { diff --git a/src/Resource/Instance.js b/src/Resource/Instance.js index 8192994..2e98de2 100644 --- a/src/Resource/Instance.js +++ b/src/Resource/Instance.js @@ -28,7 +28,6 @@ import IEventHandler from '../Core/IEventHandler.js'; import IPermissionsManager from '../Security/Permissions/IPermissionsManager.js'; -import StructureArray from '../Data/StructureArray.js'; import AutoList from '../Data/AutoList.js'; import KeyList from '../Data/KeyList.js'; import Structure from '../Data/Structure.js'; @@ -36,6 +35,11 @@ import PropertyValue from '../Data/PropertyValue.js'; import CustomResourceEvent from './CustomResourceEvent.js'; import Warehouse from './Warehouse.js'; import Ruling from '../Security/Permissions/Ruling.js'; +import TypedMap from '../Data/TypedMap.js'; +import TypedList from '../Data/TypedList.js'; +import EventOccurredInfo from './EventOccurredInfo.js'; +import PropertyModificationInfo from './PropertyModificationInfo.js'; +import PropertyValueArray from '../Data/PropertyValueArray.js'; export default class Instance extends IEventHandler { @@ -110,7 +114,7 @@ export default class Instance extends IEventHandler serialize() { - var props = []; + var props = new PropertyValueArray(); for (var i = 0; i < this.template.properties.length; i++) props.push(new PropertyValue(this.resource[this.template.properties[i].name], @@ -122,7 +126,7 @@ export default class Instance extends IEventHandler isStorable() { - return resource instanceof Storable; + return false; } emitModification(pt, value) @@ -136,10 +140,17 @@ export default class Instance extends IEventHandler if (pt.recordable) this.store.record(this.resource, pt.name, value, this.ages[pt.index], now); + else + this.store.modify(this.resource, pt.name, value, this.ages[pt.index], now); - super._emit("ResourceModified", this.resource, pt.name, value); - //this.resource._emit("modified", pt.name, value); - this.resource._emit(":" + pt.name, value); + let pmInfo = new PropertyModificationInfo(this.resource, pt, value, this.instanceAge); + + super._emit("PropertyModified", pmInfo); + this.resource._emit(`:${pt.name}`, value); + //this.resource.emitProperty(pmInfo); + + //super._emit("ResourceModified", this.resource, pt.name, value); + //this.resource._emit(":" + pt.name, value); } modified(propertyName = null) @@ -155,9 +166,11 @@ export default class Instance extends IEventHandler } } - _emitResourceEvent(issuer, receivers, name, args) + _emitResourceEvent(issuer, receivers, eventTemplate, value) { - super._emit("ResourceEventOccurred", this.resource, issuer, receivers, name, args); + super._emit("EventOccurred", + new EventOccurredInfo(this.resource, eventTemplate, value, issuer, receivers)); + //super._emit("ResourceEventOccurred", this.resource, issuer, receivers, name, args); } getPropertyValue(name, resultObject) @@ -173,6 +186,9 @@ export default class Instance extends IEventHandler } + get age() { + return this.instanceAge; + } constructor(id, name, resource, store, customTemplate = null, age = 0) { @@ -223,20 +239,20 @@ export default class Instance extends IEventHandler } // connect events - for (var i = 0; i < this.template.events.length; i++) - this.resource.on(this.template.events[i].name, this._makeHandler(this.template.events[i].name)); + for (let i = 0; i < this.template.events.length; i++) + this.resource.on(this.template.events[i].name, this._makeHandler(this.template.events[i])); } - _makeHandler(name) + _makeHandler(eventTemplate) { var self = this; - return function(args) + return function(argument) { - if (args instanceof CustomResourceEvent) - self._emitResourceEvent(args.issuer, args.receivers, name, args.args); + if (argument instanceof CustomResourceEvent) + self._emitResourceEvent(argument.issuer, argument.receivers, eventTemplate, argument.value); else - self._emitResourceEvent(null, null, name, args); + self._emitResourceEvent(null, null, eventTemplate, argument); }; } @@ -294,14 +310,14 @@ export default class Instance extends IEventHandler else if (attr == "managers") { - var mngrs = new StructureArray(); + var mngrs = new (TypedList.of(TypedMap.of(String, Object))); for(var j = 0; j < this.managers.length; j++) { var manager = this.managers.item(j); - var sm = new Structure(); - sm["type"] = manager.constructor.name; - sm["settings"] = manager.settings; + var sm = new (TypedMap.of(String, Object)); + sm.set("type", manager.constructor.name); + sm.set("settings", manager.settings); mngrs.push(sm); } diff --git a/src/Resource/PropertyModificationInfo.js b/src/Resource/PropertyModificationInfo.js new file mode 100644 index 0000000..76ea27e --- /dev/null +++ b/src/Resource/PropertyModificationInfo.js @@ -0,0 +1,17 @@ +import IResource from './IResource.js'; +import PropertyTemplate from './Template/PropertyTemplate.js'; + +export default class PropertyModificationInfo { + + get name(){ + return this.propertyTemplate.name; + } + + PropertyModificationInfo( + resource, propertyTemplate, value, age) { + this.resource = resource; + this.propertyTemplate = propertyTemplate; + this.value = value; + this.age = age; + } +} diff --git a/src/Resource/Template/ArgumentTemplate.js b/src/Resource/Template/ArgumentTemplate.js index 34c7024..eece9d2 100644 --- a/src/Resource/Template/ArgumentTemplate.js +++ b/src/Resource/Template/ArgumentTemplate.js @@ -1,32 +1,38 @@ -import DC from "../../Data/DataConverter.js"; -import BinaryList from "../../Data/BinaryList.js"; -import TemplateDataType from "./TemplateDataType.js"; -export default class ArgumentTemplate -{ - static parse(data, offset) - { - var cs = data[offset++]; - var name = data.getString(offset, cs); - offset += cs; - var {size, value} = TemplateDataType.parse(data, offset); +import {DC, BL} from '../../Data/DC.js'; +import RepresentationType from '../../Data/RepresentationType.js'; - return {size: cs + 1 + size, value: new ArgumentTemplate(name, value)}; - } +import ParseResult from "../../Data/ParseResult.js"; - constructor(name, type){ - this.name = name; - this.type = type; - } +export default class ArgumentTemplate { - compose() - { - var name = DC.stringToBytes(this.name); + static parse(data, offset, index) { + var optional = (data[offset++] & 0x1) == 0x1; - return new BinaryList() - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.type.compose()) - .toArray(); - } + var cs = data[offset++]; + var name = data.getString(offset, cs); + offset += cs; + var tdr = RepresentationType.parse(data, offset); + + return new ParseResult( + cs + 2 + tdr.size, new ArgumentTemplate(name, tdr.type, optional, index)); + } + + constructor(name, type, optional, index){ + this.name = name; + this.type = type; + this.optional = optional; + this.index = index; + } + + compose() { + var name = DC.stringToBytes(this.name); + + return (BL() + .addUint8(this.optional ? 1 : 0) + .addUint8(name.length) + .addDC(name) + .addDC(this.type.compose())) + .toDC(); + } } diff --git a/src/Resource/Template/ConstantTemplate.js b/src/Resource/Template/ConstantTemplate.js new file mode 100644 index 0000000..0e9c545 --- /dev/null +++ b/src/Resource/Template/ConstantTemplate.js @@ -0,0 +1,46 @@ +import {DC, BL} from '../../Data/DC.js'; +import MemberTemplate from './MemberTemplate.js'; +import Codec from '../../Data/Codec.js'; + +export default class ConstantTemplate extends MemberTemplate { + //final dynamic value; + //final String? expansion; + //final RepresentationType valueType; + + constructor(template, index, name, + inherited, valueType, value, expansion){ + super(template, index, name, inherited) ; + this.valueType = valueType; + this.value = value; + this.expansion = expansion; + } + + compose() { + var name = super.compose(); + var hdr = this.inherited ? 0x80 : 0; + + if (this.expansion != null) { + var exp = DC.stringToBytes(this.expansion); + hdr |= 0x70; + return (BL() + .addUint8(hdr) + .addUint8(name.length) + .addDC(name) + .addDC(this.valueType.compose()) + .addDC(Codec.compose(this.value, null)) + .addInt32(exp.length) + .addDC(exp)) + .toDC(); + } else { + hdr |= 0x60; + + return (BL() + .addUint8(hdr) + .addUint8(name.length) + .addDC(name) + .addDC(this.valueType.compose()) + .addDC(Codec.compose(this.value, null))) + .toDC(); + } + } +} diff --git a/src/Resource/Template/EventTemplate.js b/src/Resource/Template/EventTemplate.js index b7274b5..5f40edf 100644 --- a/src/Resource/Template/EventTemplate.js +++ b/src/Resource/Template/EventTemplate.js @@ -26,39 +26,48 @@ "use strict"; -import {DC, BL} from '../../Data/DataConverter.js'; +import {DC, BL} from '../../Data/DC.js'; import MemberTemplate from './MemberTemplate.js'; -import MemberType from './MemberType.js'; + -export default class EventTemplate extends MemberTemplate -{ +export default class EventTemplate extends MemberTemplate { - constructor() - { - super(); - this.type = MemberType.Event; + compose() { + let name = super.compose(); + + let hdr = this.inherited ? 0x80 : 0; + + if (this.listenable) hdr |= 0x8; + + if (this.expansion != null) { + let exp = DC.stringToBytes(this.expansion); + hdr |= 0x50; + return (BL() + .addUint8(hdr) + .addUint8(name.length) + .addDC(name) + .addDC(this.argumentType.compose()) + .addInt32(exp.length) + .addDC(exp)) + .toDC(); + } else { + hdr |= 0x40; + return (BL() + .addUint8(hdr) + .addUint8(name.length) + .addDC(name) + .addDC(this.argumentType.compose())) + .toDC(); + } + } + + constructor(template, index, name, inherited, argumentType, + expansion = null, listenable = false) + { + super(template, index, name, inherited) ; + this.argumentType = argumentType; + this.expansion = expansion; + this.listenable = listenable; } - compose() - { - var rt = BL(); - - var name = super.compose(); - if (this.expansion != null) { - var exp = DC.stringToBytes(this.expansion); - return rt.addUint8(this.listenable ? 0x58 : 0x50) - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.argumentType.compose()) - .addUint32(exp.length) - .addUint8Array(exp) - .toArray(); - } - else - return rt.addUint8(this.listenable ? 0x48 : 0x40) - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.argumentType.compose()) - .toArray(); - } } diff --git a/src/Resource/Template/FunctionTemplate.js b/src/Resource/Template/FunctionTemplate.js index 76c3245..7b8b816 100644 --- a/src/Resource/Template/FunctionTemplate.js +++ b/src/Resource/Template/FunctionTemplate.js @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017 Ahmed Kh. Zamil +* 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 @@ -26,38 +26,38 @@ "use strict"; -import {DC, BL} from '../../Data/DataConverter.js'; +import {DC, BL} from '../../Data/DC.js'; import MemberTemplate from './MemberTemplate.js'; -import MemberType from './MemberType.js'; export default class FunctionTemplate extends MemberTemplate { - compose() { - var name = super.compose(); + compose() { + var name = super.compose(); - var bl = BL() - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.returnType.compose()) - .addUint8(this.arguments.length); + var bl = new BL() + .addUint8(name.length) + .addDC(name) + .addDC(this.returnType.compose()) + .addUint8(this.args.length); - for (var i = 0; i < this.arguments.length; i++) - bl.addUint8Array(this.arguments[i].compose()); + for (var i = 0; i < this.args.length; i++) bl.addDC(this.args[i].compose()); - if (this.expansion != null) - { - var exp = DC.stringToBytes(this.expansion); - bl.addInt32(exp.length) - .addUint8Array(exp); - bl.insertUint8(0, 0x10); - } - else - bl.addUint8(0x0, 0); - - return bl.toArray(); - } + if (this.expansion != null) { + var exp = DC.stringToBytes(this.expansion); + bl + .addInt32(exp.length) + .addDC(exp); + bl.insertUint8(0, this.inherited ? 0x90 : 0x10); + } else + bl.insertUint8(0, this.inherited ? 0x80 : 0x0); - constructor() { - super(); - this.type = MemberType.Function; - } + return bl.toDC(); + } + + constructor(template, index, name, inherited, args, returnType, expansion = null){ + super(template, index, name, inherited); + + this.args = args; + this.returnType = returnType; + this.expansion = expansion; + } } diff --git a/src/Resource/Template/MemberTemplate.js b/src/Resource/Template/MemberTemplate.js index 6053bf3..5cc533b 100644 --- a/src/Resource/Template/MemberTemplate.js +++ b/src/Resource/Template/MemberTemplate.js @@ -26,10 +26,21 @@ "use strict"; -import DC from '../../Data/DataConverter.js'; +import DC from '../../Data/DC.js'; + export default class MemberTemplate { - compose() { - return DC.stringToBytes(this.name); - } -} \ No newline at end of file + + constructor(template, index, name, inherited) { + this.template = template; + this.index = index; + this.name = name; + this.inherited = inherited; + } + + get fullname() {return this.template.className + "." + this.name;} + + compose() { + return DC.stringToBytes(this.name); + } +} diff --git a/src/Resource/Template/PropertyTemplate.js b/src/Resource/Template/PropertyTemplate.js index f0f792f..79f9e2b 100644 --- a/src/Resource/Template/PropertyTemplate.js +++ b/src/Resource/Template/PropertyTemplate.js @@ -1,5 +1,5 @@ /* -* Copyright (c) 2017 Ahmed Kh. Zamil +* 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 @@ -24,74 +24,66 @@ * Created by Ahmed Zamil on 27/08/2017. */ -"use strict"; - -import {DC, BL} from '../../Data/DataConverter.js'; +import {DC, BL} from '../../Data/DC.js'; import MemberTemplate from './MemberTemplate.js'; -import MemberType from './MemberType.js'; -export const PropertyPermission = { - Read: 1, - Write: 2, - ReadWrite: 3 -}; +export default class PropertyTemplate extends MemberTemplate { -export default class PropertyTemplate extends MemberTemplate -{ + compose() { + var name = super.compose(); + var pv = (this.permission << 1) | (this.recordable ? 1 : 0); - constructor() - { - super(); - this.type = MemberType.Property; - } + if (this.inherited) pv |= 0x80; - compose() - { - var name = super.compose(); - var rt = BL(); - var pv = (this.permission << 1) | (this.recordable ? 1 : 0); + if (this.writeExpansion != null && this.readExpansion != null) { + let rexp = DC.stringToBytes(this.readExpansion); + let wexp = DC.stringToBytes(this.writeExpansion); + return (BL() + .addUint8(0x38 | pv) + .addUint8(name.length) + .addDC(name) + .addDC(this.valueType.compose()) + .addInt32(wexp.length) + .addDC(wexp) + .addInt32(rexp.length) + .addDC(rexp)) + .toDC(); + } else if (this.writeExpansion != null) { + let wexp = DC.stringToBytes(this.writeExpansion); + return (BL() + .addUint8(0x30 | pv) + .addUint8(name.length) + .addDC(name) + .addDC(this.valueType.compose()) + .addInt32(wexp.length) + .addDC(wexp)) + .toDC(); + } else if (this.readExpansion != null) { + let rexp = DC.stringToBytes(this.readExpansion); + return (BL() + .addUint8(0x28 | pv) + .addUint8(name.length) + .addDC(name) + .addDC(this.valueType.compose()) + .addInt32(rexp.length) + .addDC(rexp)) + .toDC(); + } else + return (BL() + .addUint8(0x20 | pv) + .addUint8(name.length) + .addDC(name) + .addDC(this.valueType.compose())) + .toDC(); + } - if (this.writeExpansion != null && this.readExpansion != null) - { - var rexp = DC.stringToBytes(this.readExpansion); - var wexp = DC.stringToBytes(this.writeExpansion); - return rt.addUint8(0x38 | pv) - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.valueType.compose()) - .addUint32(wexp.length) - .addUint8Array(wexp) - .addUint32(rexp.length) - .addUint8Array(rexp) - .toArray(); - } - else if (this.writeExpansion != null) - { - var wexp = DC.stringToBytes(this.writeExpansion); - return rt.addUint8(0x30 | pv) - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.valueType.compose()) - .addUint32(wexp.length) - .addUint8Array(wexp) - .toArray(); - } - else if (this.readExpansion != null) - { - var rexp = DC.stringToBytes(this.readExpansion); - return rt.addUint8(0x28 | pv) - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.valueType.compose()) - .addUint32(rexp.length) - .addUint8Array(rexp) - .toArray(); - } - else - return rt.addUint8(0x20 | pv) - .addUint8(name.length) - .addUint8Array(name) - .addUint8Array(this.valueType.compose()) - .toArray(); - } + constructor(template, index, name, + inherited, valueType, readExpansion = null, writeExpansion = null, recordable = false) + { + super(template, index, name, inherited); + this.valueType = valueType; + this.readExpansion = readExpansion; + this.writeExpansion = writeExpansion; + this.recordable = recordable; + } } diff --git a/src/Resource/Template/TemplateDataType.js b/src/Resource/Template/TemplateDataType.js index 0dbd47b..fe133f5 100644 --- a/src/Resource/Template/TemplateDataType.js +++ b/src/Resource/Template/TemplateDataType.js @@ -22,7 +22,7 @@ "use strict"; -import {DC, BL} from '../../Data/DataConverter.js'; +import {DC, BL} from '../../Data/DC.js'; import DataType from "../../Data/DataType.js"; import Structure from '../../Data/Structure.js'; import IResource from '../IResource.js'; diff --git a/src/Resource/Template/TemplateType.js b/src/Resource/Template/TemplateType.js index 87afcf3..c2c4318 100644 --- a/src/Resource/Template/TemplateType.js +++ b/src/Resource/Template/TemplateType.js @@ -4,4 +4,5 @@ export default Resource: 1, Record: 2, Wrapper: 3, + Enum: 4 } \ No newline at end of file diff --git a/src/Resource/Template/TypeTemplate.js b/src/Resource/Template/TypeTemplate.js index e011dc3..5711659 100644 --- a/src/Resource/Template/TypeTemplate.js +++ b/src/Resource/Template/TypeTemplate.js @@ -26,15 +26,20 @@ import FunctionTemplate from './FunctionTemplate.js'; import PropertyTemplate from './PropertyTemplate.js'; import EventTemplate from './EventTemplate.js'; import SHA256 from '../../Security/Integrity/SHA256.js'; -import {DC, BL} from '../../Data/DataConverter.js'; +import {DC, BL} from '../../Data/DC.js'; import ArgumentTemplate from './ArgumentTemplate.js'; -import TemplateDataType from "./TemplateDataType.js"; import IResource from '../IResource.js'; import IRecord from '../../Data/IRecord.js'; import TemplateType from './TemplateType.js' import Warehouse from '../Warehouse.js'; import DistributedConnection from '../../Net/IIP/DistributedConnection.js'; +import ConstantTemplate from './ConstantTemplate.js'; +import IEnum from '../../Data/IEnum.js'; +import DistributedResource from '../../Net/IIP/DistributedResource.js'; +import RepresentationType from '../../Data/RepresentationType.js'; +import Codec from '../../Data/Codec.js'; + export default class TypeTemplate { getEventTemplateByName(eventName) { @@ -79,6 +84,20 @@ export default class TypeTemplate { return null; } + getConstantTemplateByName(constantName) { + for (var i = 0; i < this.constants.length; i++) + if (this.constants[i].name == constantName) + return this.constants[i]; + return null; + } + + getConstantTemplateByIndex(index) { + for (var i = 0; i < this.constants.length; i++) + if (this.constants[i].index == index) + return this.constants[i]; + return null; + } + /* @@ -217,16 +236,22 @@ export default class TypeTemplate { this.events = []; this.functions = []; this.members = []; + this.constants = []; + if (type === undefined) return; - + + if (type.prototype instanceof DistributedResource) + this.templateType = TemplateType.Wrapper; if (type.prototype instanceof IRecord) this.templateType = TemplateType.Record; else if (type.prototype instanceof IResource) this.templateType = TemplateType.Resource; + else if (type.prototype instanceof IEnum) + this.templateType = TemplateType.Enum; else - throw new Error("Type is neither a resource nor a record."); + throw new Error("Type must implement IResource, IRecord, IEnum or a subtype of DistributedResource."); this.definedType = type; @@ -244,35 +269,38 @@ export default class TypeTemplate { //byte currentIndex = 0; if (template.properties != null) - for (var i = 0; i < template.properties.length; i++) { + for (let i = 0; i < template.properties.length; i++) { //[name, type, {read: comment, write: comment, recordable: }] - var pi = template.properties[i]; - var pt = new PropertyTemplate(); - pt.name = pi[0]; - pt.index = i; - pt.valueType = TemplateDataType.fromType(pi[1]); - pt.readExpansion = pi[2]?.read; - pt.writeExpansion = pi[2]?.write; - pt.recordable = pi[2]?.recordable; + let pi = template.properties[i]; + let pt = new PropertyTemplate(this, i, pi[0], false, + RepresentationType.fromType(pi[1]) ?? RepresentationType.Void, + pi[2]?.read, pi[2]?.write, pi[2]?.recordable); pt.propertyInfo = pi; this.properties.push(pt); } + + if (template.constants != null) + for (let i = 0; i < template.constants.length; i++) { + let ci = template.constants[i]; + let ct = new ConstantTemplate(this, i, ci[0], false, + RepresentationType.fromType(ci[1]) ?? RepresentationType.Void, + ci.value, ci.help); + ct.propertyInfo = ci; + this.constants.push(ct); + } + if (this.templateType == TemplateType.Resource) { - if (template.events != null) { for (let i = 0; i < template.events.length; i++) { // [name, type, {listenable: true/false, help: ""}] var ei = template.events[i]; - var et = new EventTemplate(); - et.name = ei[0]; - et.index = i; - et.argumentType = TemplateDataType.fromType(ei[1]), - et.expansion = ei[2]?.help; - et.listenable = ei[2]?.listenable; + var et = new EventTemplate(this, i, ei[0], false, + RepresentationType.fromType(ei[1]) ?? RepresentationType.Void, + ei[2]?.help, ei[2]?.listenable) et.eventInfo = ei; this.events.push(et); } @@ -284,16 +312,15 @@ export default class TypeTemplate { var fi = template.functions[i]; - // [name, {param1: type, param2: int}, returnType, "Description"] - var ft = new FunctionTemplate(); - ft.name = fi[0]; - ft.index = i; - ft.returnType = TemplateDataType.fromType(fi[2]); - ft.expansion = fi[3]; - ft.arguments = []; + let args = []; + for(let ai = 0; ai < fi[1].length; ai++) + args.push(new ArgumentTemplate(fi[1][ai][0], RepresentationType.fromType(fi[1][ai][1]) + ?? RepresentationType.Dynamic, fi[1][ai][2]?.optional, ai)); - for(var arg in fi[1]) - ft.arguments.push(new ArgumentTemplate(arg, TemplateDataType.fromType(fi[1][arg]))) + // [name, {param1: type, param2: int}, returnType, "Description"] + var ft = new FunctionTemplate(this, i, fi[0], false, args, + RepresentationType.fromType(fi[2]) ?? RepresentationType.Void, + fi[3]); ft.methodInfo = fi; @@ -312,6 +339,9 @@ export default class TypeTemplate { // append properties for (let i = 0; i < this.properties.length; i++) this.members.push(this.properties[i]); + // append constants + for (let i = 0; i < this.constants.length; i++) + this.members.push(this.constants[i]); // bake it binarily var b = BL(); @@ -369,41 +399,52 @@ export default class TypeTemplate { var od = new TypeTemplate(); od.content = data.clip(offset, contentLength); - od.templateType = data.getUint8(offset++); + let hasParent = (data.getUint8(offset) & 0x80) > 0; + + od.templateType = data.getUint8(offset++) & 0xF; + od.classId = data.getGuid(offset); offset += 16; od.className = data.getString(offset + 1, data.getUint8(offset)); offset += data.getUint8(offset) + 1; + if (hasParent) { + od.parentId = data.getGuid(offset); + offset += 16; + } + od.version = data.getInt32(offset); offset += 4; - var methodsCount = data.getUint16(offset); + let methodsCount = data.getUint16(offset); offset += 2; - var functionIndex = 0; - var propertyIndex = 0; - var eventIndex = 0; + let functionIndex = 0; + let propertyIndex = 0; + let eventIndex = 0; + let constantIndex = 0; - for (var i = 0; i < methodsCount; i++) { - var type = data.getUint8(offset) >> 5; + for (let i = 0; i < methodsCount; i++) { + let inherited = (data.getUint8(offset) & 0x80) > 0; + let type = (data.getUint8(offset) >> 5) & 0x3; + if (type == 0) // function { - let ft = new FunctionTemplate(); - ft.index = functionIndex++; + let expansion = null; let hasExpansion = ((data.getUint8(offset++) & 0x10) == 0x10); let len = data.getUint8(offset++); - ft.name = data.getString(offset, len); + let name = data.getString(offset, len); offset += len; // return type - let {size, value: returnType} = TemplateDataType.parse(data, offset); - offset += size; + let dt = RepresentationType.parse(data, offset); - ft.returnType = returnType; + offset += dt.size; + + //ft.returnType = returnType; // arguments count var argsCount = data.getUint8(offset++); @@ -411,47 +452,45 @@ export default class TypeTemplate { for (var a = 0; a < argsCount; a++) { - let {size: argSize, value: argType} = ArgumentTemplate.parse(data, offset); + let {size: argSize, value: argType} = ArgumentTemplate.parse(data, offset, a); args.push(argType); offset += argSize; } - ft.arguments = args; - if (hasExpansion) // expansion ? { var cs = data.getUint32(offset); offset += 4; - ft.expansion = data.getString(offset, cs); + expansion = data.getString(offset, cs); offset += cs; } + let ft = new FunctionTemplate(od, functionIndex++, name, inherited, + args, dt.type, expansion); + od.functions.push(ft); } else if (type == 1) // property { - let pt = new PropertyTemplate(); - pt.index = propertyIndex++; let hasReadExpansion = ((data.getUint8(offset) & 0x8) == 0x8); let hasWriteExpansion = ((data.getUint8(offset) & 0x10) == 0x10); - pt.recordable = ((data.getUint8(offset) & 1) == 1); - pt.permission = ((data.getUint8(offset++) >> 1) & 0x3); + let readExpansion, writeExpansion; + let recordable = ((data.getUint8(offset) & 1) == 1); + let permission = ((data.getUint8(offset++) >> 1) & 0x3); let len = data.getUint8(offset++); - pt.name = data.getString(offset, len); + let name = data.getString(offset, len); offset += len; - let {size, value: valueType} = TemplateDataType.parse(data, offset); + var dt = RepresentationType.parse(data, offset); - offset += size; - - pt.valueType = valueType; + offset += dt.size; if (hasReadExpansion) // expansion ? { let cs = data.getUint32(offset); offset += 4; - pt.readExpansion = data.getString(offset, cs); + readExpansion = data.getString(offset, cs); offset += cs; } @@ -459,39 +498,70 @@ export default class TypeTemplate { { let cs = data.getUint32(offset); offset += 4; - pt.writeExpansion = data.getString(offset, cs); + writeExpansion = data.getString(offset, cs); offset += cs; } + let pt = new PropertyTemplate(od, propertyIndex++, name, inherited, dt.type, readExpansion, writeExpansion, recordable); + od.properties.push(pt); } else if (type == 2) // Event { - let et = new EventTemplate(); - et.index = eventIndex++; let hasExpansion = ((data.getUint8(offset) & 0x10) == 0x10); - et.listenable = ((data.getUint8(offset++) & 0x8) == 0x8); + let listenable = ((data.getUint8(offset++) & 0x8) == 0x8); let len = data.getUint8(offset++); - et.name = data.getString(offset, len); + let name = data.getString(offset, len); + let expansion; offset += len; - let {size, value: argType} = TemplateDataType.parse(data, offset); + let dt = RepresentationType.parse(data, offset); - offset += size; - et.argumentType = argType; + offset += dt.size; + if (hasExpansion) // expansion ? { let cs = data.getUint32(offset); offset += 4; - et.expansion = data.getString(offset, cs); + expansion = data.getString(offset, cs); offset += cs; } + let et = new EventTemplate(od, eventIndex++, name, inherited, dt.type, expansion, listenable); od.events.push(et); } + else if (type == 3) // constant + { + let expansion = null; + let hasExpansion = ((data[offset++] & 0x10) == 0x10); + + let name = data.getString(offset + 1, data[offset]); + offset += data[offset] + 1; + + let dt = RepresentationType.parse(data, offset); + + offset += dt.size; + + let parsed = Codec.parse(data, offset, null); + + offset += parsed.size; + + if (hasExpansion) // expansion ? + { + let cs = data.getUint32(offset); + offset += 4; + expansion = data.getString(offset, cs); + offset += cs; + } + + let ct = new ConstantTemplate(this, constantIndex++, name, inherited, + dt.type, parsed.reply.result, expansion); + + od.constants.push(ct); + } } // append signals @@ -503,6 +573,9 @@ export default class TypeTemplate { // append properties for (let i = 0; i < od.properties.length; i++) od.members.push(od.properties[i]); + // append constants + for (let i = 0; i < od.constants.length; i++) + od.members.push(od.constants[i]); return od; diff --git a/src/Resource/Warehouse.js b/src/Resource/Warehouse.js index b5bbf0c..159fddf 100644 --- a/src/Resource/Warehouse.js +++ b/src/Resource/Warehouse.js @@ -42,7 +42,12 @@ import AsyncBag from '../Core/AsyncBag.js'; import IRecord from '../Data/IRecord.js'; import TemplateType from './Template/TemplateType.js'; import DistributedResource from '../Net/IIP/DistributedResource.js'; - +import TypedList from '../Data/TypedList.js'; +import { Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Float32, Float64 } from '../Data/ExtendedTypes.js'; +import Record from '../Data/Record.js'; +import TypedMap from '../Data/TypedMap.js'; +import {RepresentationType, RepresentationTypeIdentifier} from '../Data/RepresentationType.js'; +import FactoryEntry from './FactoryEntry.js'; './FactoryEntry.js'; export class WH extends IEventHandler { constructor() @@ -58,8 +63,12 @@ export class WH extends IEventHandler this.templates.add(TemplateType.Resource, new KeyList()); this.templates.add(TemplateType.Record, new KeyList()); this.templates.add(TemplateType.Wrapper, new KeyList()); + this.templates.add(TemplateType.Enum, new KeyList()); this.protocols = new KeyList(); + + this.typesFactory = this._getBuiltInTypes(); + this._register("connected"); this._register("disconnected"); ///this._urlRegex = /^(?:([\S]*):\/\/([^\/]*)\/?)/; @@ -529,6 +538,91 @@ export class WH extends IEventHandler return rt; } + /** + * @param {Function} instanceCreator - creator + * @param {RepresentationType} representationType - type + */ + _getTypeEntries(type, representationType) { + + let listType = TypedList.of(type); + + + var entry = new FactoryEntry(type, representationType); + let nullableEntry = new FactoryEntry(entry.nullableType, representationType.toNullable()); + let listEntry = new FactoryEntry(listType, + new RepresentationType(RepresentationTypeIdentifier.TypedList, false, + null, [representationType])); + let nullableList = new FactoryEntry(listEntry.nullableType, + new RepresentationType(RepresentationTypeIdentifier.TypedList, true, null, + [representationType])); + + let nullableItemListType = TypedList.of(entry.nullableType); + let listNullableItemEntry = new FactoryEntry(nullableItemListType, + new RepresentationType(RepresentationTypeIdentifier.TypedList, false, + null, [representationType.toNullable()])); + + let nullableListNullableItemEntry = new FactoryEntry(nullableItemListType, + new RepresentationType(RepresentationTypeIdentifier.TypedList, true, null, + [representationType.toNullable()])); + + return [ + entry, nullableEntry, listEntry, nullableList, listNullableItemEntry, nullableListNullableItemEntry + ]; + } + + + /** + * @param {Function} instanceCreator - creator + * @param {RepresentationType} representationType - type + */ + defineType(type, representationType) { + var entries = this._getTypeEntries(type, representationType); + + for(var e of entries) + this.typesFactory[e.type] = e; //.push(e); + } + + _getBuiltInTypes() { + + let entries = [ + ...this._getTypeEntries(Int8, new RepresentationType(RepresentationTypeIdentifier.Int8, false)), + ...this._getTypeEntries(UInt8, new RepresentationType(RepresentationTypeIdentifier.UInt8, false)), + ...this._getTypeEntries(Int16, new RepresentationType(RepresentationTypeIdentifier.Int16, false)), + ...this._getTypeEntries(UInt16, new RepresentationType(RepresentationTypeIdentifier.UInt16, false)), + ...this._getTypeEntries(Int32, new RepresentationType(RepresentationTypeIdentifier.Int32, false)), + ...this._getTypeEntries(UInt32, new RepresentationType(RepresentationTypeIdentifier.UInt32, false)), + ...this._getTypeEntries(Int64, new RepresentationType(RepresentationTypeIdentifier.Int64, false)), + ...this._getTypeEntries(UInt64, new RepresentationType(RepresentationTypeIdentifier.UInt64, false)), + ...this._getTypeEntries(Float32, new RepresentationType(RepresentationTypeIdentifier.Float32, false)), + ...this._getTypeEntries(Float64, new RepresentationType(RepresentationTypeIdentifier.Float64, false)), + ...this._getTypeEntries(String, new RepresentationType(RepresentationTypeIdentifier.Int8, String)), + ...this._getTypeEntries(Date, new RepresentationType(RepresentationTypeIdentifier.Int8, Date)), + ...this._getTypeEntries(Record, new RepresentationType(RepresentationTypeIdentifier.Record, false)), + ...this._getTypeEntries(IResource, new RepresentationType(RepresentationTypeIdentifier.Resource, false)), + ...this._getTypeEntries(Array, new RepresentationType(RepresentationTypeIdentifier.List, false)), + ...this._getTypeEntries(Map, new RepresentationType(RepresentationTypeIdentifier.Map, false)), + //...this._getTypeEntries(IResource, new RepresentationType(RepresentationTypeIdentifier.Resource, false)), + //...this._getTypeEntries(TypedMap, new RepresentationType(RepresentationTypeIdentifier.Resource, false)), + + ...this._getTypeEntries(TypedMap.of(String, Object), new RepresentationType(RepresentationTypeIdentifier.TypedMap, false, null, [ + new RepresentationType(RepresentationTypeIdentifier.String, false), + RepresentationType.Dynamic])), + + ...this._getTypeEntries(TypedMap.of(UInt8, Object), new RepresentationType(RepresentationTypeIdentifier.TypedMap, false, null, [ + new RepresentationType(RepresentationTypeIdentifier.UInt8, false), + RepresentationType.Dynamic])), + + ...this._getTypeEntries(TypedMap.of(Int32, Object), new RepresentationType(RepresentationTypeIdentifier.TypedMap, false, null, [ + new RepresentationType(RepresentationTypeIdentifier.Int32, false), + RepresentationType.Dynamic])), + + ]; + + let rt = {}; + for(let entry of entries) + rt[entry.type] = entry; + return rt; + } } let Warehouse = new WH(); diff --git a/src/Security/Integrity/SHA256.js b/src/Security/Integrity/SHA256.js index c259b33..2c6df1e 100644 --- a/src/Security/Integrity/SHA256.js +++ b/src/Security/Integrity/SHA256.js @@ -26,7 +26,7 @@ * Ref: https://en.wikipedia.org/wiki/SHA-2 */ -import {DC, BL} from '../../Data/DataConverter.js'; +import { DC, BL, Endian } from '../../Data/DC.js'; export default class SHA256 { @@ -82,7 +82,7 @@ export default class SHA256 var paddingBytes = new Uint8Array(paddingLength); paddingBytes[0] = 0x80; - var data = new DC(BL().addUint8Array(msg).addUint8Array(paddingBytes).addUint64(L).toArray()); + var data = BL().addUint8Array(msg).addUint8Array(paddingBytes).addUint64(L, Endian.Big).toDC(); @@ -99,8 +99,8 @@ export default class SHA256 // copy chunk into first 16 words w[0..15] of the message schedule array var w = new Uint32Array(64); - for(var i = 0; i < 16; i++) - w[i] = data.getInt32(chunk + (i * 4)); + for(let i = 0; i < 16; i++) + w[i] = data.getUint32(chunk + (i * 4), Endian.Big); //for(var i = 16; i < 64; i++) // w[i] = 0; @@ -111,7 +111,7 @@ export default class SHA256 // s1 := (w[i-2] rightrotate 17) xor (w[i-2] rightrotate 19) xor (w[i-2] rightshift 10) // w[i] := w[i-16] + s0 + w[i-7] + s1 - for (var i = 16; i < 64; i++) + for (let i = 16; i < 64; i++) { var s0 = SHA256.RROT(w[i-15], 7) ^ SHA256.RROT(w[i-15], 18) ^ (w[i-15] >>> 3); var s1 = SHA256.RROT(w[i-2], 17) ^ SHA256.RROT(w[i-2], 19) ^ (w[i-2] >>> 10); @@ -130,7 +130,7 @@ export default class SHA256 // Compression function main loop: - for (var i = 0; i < 64; i++) + for (let i = 0; i < 64; i++) { var S1 = SHA256.RROT(e, 6) ^ SHA256.RROT(e, 11) ^ SHA256.RROT(e, 25); var ch = (e & f) ^ ((~e) & g); @@ -170,8 +170,8 @@ export default class SHA256 //digest := hash := h0 append h1 append h2 append h3 append h4 append h5 append h6 append h7 var results = BL(); - for(var i = 0; i < 8; i++) - results.addUint32(hash[i]); + for(let i = 0; i < 8; i++) + results.addUint32(hash[i], Endian.Big); return results.toDC(); diff --git a/src/esiur.js b/src/esiur.js index c1f4df4..c047bb3 100644 --- a/src/esiur.js +++ b/src/esiur.js @@ -25,7 +25,7 @@ import AutoList from './Data/AutoList.js'; import AutoMap from './Data/AutoMap.js'; import BinaryList from './Data/BinaryList.js'; import Codec from './Data/Codec.js'; -import DataConverter from './Data/DataConverter.js'; +import DC from './Data/DC.js'; import DataType from './Data/DataType.js'; import Guid from './Data/Guid.js'; import IRecord from './Data/IRecord.js'; @@ -86,7 +86,7 @@ import Ruling from './Security/Permissions/Ruling.js'; let namespace = { Core: { AsyncReply, AsyncException, AsyncQueue, ErrorType, ExceptionCode, IDestructible, IEventHandler, ProgressType}, - Data: {AutoList, AutoMap, BinaryList, Codec, DataConverter, DataType, Guid, IRecord, KeyList, NotModified, + Data: {AutoList, AutoMap, BinaryList, Codec, DC, DataType, Guid, IRecord, KeyList, NotModified, PropertyValue, Record, RecordComparisonResult, ResourceArray, ResourceArrayType, ResourceComparisonResult, Structure, StructureArray, StructureComparisonResult }, Net: {INetworkReceiver, NetworkBuffer, NetworkConnections, NetworkServer, NetworkSession, SendList,