mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 12:32:58 +00:00
Cleanup
This commit is contained in:
parent
15eb1453e7
commit
c03112d96c
1879
build/esiur.js
1879
build/esiur.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "esiur",
|
"name": "esiur",
|
||||||
"version": "2.0.0",
|
"version": "2.0.1",
|
||||||
"description": "Distributed Object Framework",
|
"description": "Distributed Object Framework",
|
||||||
"main": "esiur.js",
|
"main": "esiur.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
1287
src/Data/Codec.js
1287
src/Data/Codec.js
File diff suppressed because it is too large
Load Diff
@ -1,116 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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";
|
|
||||||
|
|
||||||
export 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(type)
|
|
||||||
{
|
|
||||||
return ((type & 0x80) == 0x80) && (type != this.NotModified);
|
|
||||||
},
|
|
||||||
|
|
||||||
sizeOf: function(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,8 +0,0 @@
|
|||||||
export default // const ResourceComparisonResult =
|
|
||||||
{
|
|
||||||
Null: 0,
|
|
||||||
Record: 1,
|
|
||||||
RecordSameType: 2,
|
|
||||||
Same: 3,
|
|
||||||
Empty: 4
|
|
||||||
};
|
|
@ -1,8 +0,0 @@
|
|||||||
export default // const ResourceComparisonResult =
|
|
||||||
{
|
|
||||||
Null: 0,
|
|
||||||
Distributed: 1,
|
|
||||||
Local: 2,
|
|
||||||
Same: 3,
|
|
||||||
Empty: 4
|
|
||||||
};
|
|
@ -1,67 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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";
|
|
||||||
|
|
||||||
export default class Structure
|
|
||||||
{
|
|
||||||
toArray() {
|
|
||||||
return this.toPairs();
|
|
||||||
}
|
|
||||||
|
|
||||||
toPairs() {
|
|
||||||
var rt = [];
|
|
||||||
for (var i in this)
|
|
||||||
if (!(this[i] instanceof Function))
|
|
||||||
rt.push({ key: i, value: this[i]});
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
|
|
||||||
getKeys() {
|
|
||||||
var rt = [];
|
|
||||||
for (var i in this)
|
|
||||||
if (!(this[i] instanceof Function))
|
|
||||||
rt.push(i);
|
|
||||||
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
|
|
||||||
toObject()
|
|
||||||
{
|
|
||||||
var rt = {};
|
|
||||||
for (var i in this)
|
|
||||||
if (!(this[i] instanceof Function))
|
|
||||||
rt[i] = this[i];
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(data)
|
|
||||||
{
|
|
||||||
if (data instanceof Object)
|
|
||||||
for(var i in data)
|
|
||||||
this[i] = data[i];
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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";
|
|
||||||
|
|
||||||
|
|
||||||
export default class StructureArray extends Array
|
|
||||||
{
|
|
||||||
push(value)
|
|
||||||
{
|
|
||||||
if (value instanceof Structure)
|
|
||||||
super.push(value);
|
|
||||||
else
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
export default //const StructureComparisonResult =
|
|
||||||
{
|
|
||||||
Null: 0,
|
|
||||||
Structure: 1,
|
|
||||||
StructureSameKeys: 2,
|
|
||||||
StructureSameTypes: 3,
|
|
||||||
Same: 4
|
|
||||||
};
|
|
@ -1,6 +1,9 @@
|
|||||||
import IResource from "../Resource/IResource.js";
|
import IResource from "../Resource/IResource.js";
|
||||||
|
import IRecord from "./IRecord.js";
|
||||||
|
import Record from "./Record.js";
|
||||||
import PropertyValue from "./PropertyValue.js";
|
import PropertyValue from "./PropertyValue.js";
|
||||||
import PropertyValueArray from "./PropertyValueArray.js";
|
import PropertyValueArray from "./PropertyValueArray.js";
|
||||||
|
import RecordArray from "./RecordArray.js";
|
||||||
import ResourceArray from "./ResourceArray.js";
|
import ResourceArray from "./ResourceArray.js";
|
||||||
|
|
||||||
export default class TypedList extends Array
|
export default class TypedList extends Array
|
||||||
@ -14,7 +17,9 @@ export default class TypedList extends Array
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
static cache = { [IResource] : ResourceArray,
|
static cache = { [IResource] : ResourceArray,
|
||||||
[PropertyValue] : PropertyValueArray
|
[PropertyValue] : PropertyValueArray,
|
||||||
|
[IRecord] : RecordArray,
|
||||||
|
[Record] : RecordArray
|
||||||
};
|
};
|
||||||
|
|
||||||
static getType(typedList){
|
static getType(typedList){
|
||||||
|
@ -28,13 +28,6 @@
|
|||||||
|
|
||||||
import IResource from '../../Resource/IResource.js';
|
import IResource from '../../Resource/IResource.js';
|
||||||
import AsyncReply from '../../Core/AsyncReply.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 DistributedConnection from './DistributedConnection.js';
|
import DistributedConnection from './DistributedConnection.js';
|
||||||
|
|
||||||
export default class DistributedServer extends IResource
|
export default class DistributedServer extends IResource
|
||||||
|
@ -30,7 +30,6 @@ import IIPPacketAction from "./IIPPacketAction.js";
|
|||||||
import IIPPacketCommand from "./IIPPacketCommand.js";
|
import IIPPacketCommand from "./IIPPacketCommand.js";
|
||||||
import IIPPacketEvent from "./IIPPacketEvent.js";
|
import IIPPacketEvent from "./IIPPacketEvent.js";
|
||||||
import IIPPacketReport from "./IIPPacketReport.js";
|
import IIPPacketReport from "./IIPPacketReport.js";
|
||||||
import DataType from '../../Data/DataType.js';
|
|
||||||
import TransmissionType from '../../Data/TransmissionType.js';
|
import TransmissionType from '../../Data/TransmissionType.js';
|
||||||
|
|
||||||
export default class IIPPacket
|
export default class IIPPacket
|
||||||
|
@ -30,7 +30,6 @@ import IEventHandler from '../Core/IEventHandler.js';
|
|||||||
import IPermissionsManager from '../Security/Permissions/IPermissionsManager.js';
|
import IPermissionsManager from '../Security/Permissions/IPermissionsManager.js';
|
||||||
import AutoList from '../Data/AutoList.js';
|
import AutoList from '../Data/AutoList.js';
|
||||||
import KeyList from '../Data/KeyList.js';
|
import KeyList from '../Data/KeyList.js';
|
||||||
import Structure from '../Data/Structure.js';
|
|
||||||
import PropertyValue from '../Data/PropertyValue.js';
|
import PropertyValue from '../Data/PropertyValue.js';
|
||||||
import CustomResourceEvent from './CustomResourceEvent.js';
|
import CustomResourceEvent from './CustomResourceEvent.js';
|
||||||
import Warehouse from './Warehouse.js';
|
import Warehouse from './Warehouse.js';
|
||||||
@ -293,7 +292,7 @@ export default class Instance extends IEventHandler
|
|||||||
|
|
||||||
getAttributes(attributes = null)
|
getAttributes(attributes = null)
|
||||||
{
|
{
|
||||||
var st = new Structure();
|
var st = new (TypedMap.of(String, Object))();
|
||||||
|
|
||||||
if (attributes == null)
|
if (attributes == null)
|
||||||
{
|
{
|
||||||
@ -306,7 +305,7 @@ export default class Instance extends IEventHandler
|
|||||||
var attr = attributes[i];
|
var attr = attributes[i];
|
||||||
|
|
||||||
if (attr == "name")
|
if (attr == "name")
|
||||||
st["name"] = this.name;
|
st.set("name", this.name);
|
||||||
|
|
||||||
else if (attr == "managers")
|
else if (attr == "managers")
|
||||||
{
|
{
|
||||||
@ -322,11 +321,11 @@ export default class Instance extends IEventHandler
|
|||||||
mngrs.push(sm);
|
mngrs.push(sm);
|
||||||
}
|
}
|
||||||
|
|
||||||
st["managers"] = mngrs;
|
st.set("managers", mngrs);
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
st[attr] = this.attributes.item(attr);
|
st.set(attr, this.attributes.item(attr));
|
||||||
}
|
}
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
|
@ -1,137 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
import {DC, BL} from '../../Data/DC.js';
|
|
||||||
import DataType from "../../Data/DataType.js";
|
|
||||||
import Structure from '../../Data/Structure.js';
|
|
||||||
import IResource from '../IResource.js';
|
|
||||||
import TypeTemplate from './TypeTemplate.js';
|
|
||||||
import IRecord from '../../Data/IRecord.js';
|
|
||||||
|
|
||||||
export default class TemplateDataType
|
|
||||||
{
|
|
||||||
|
|
||||||
static typesDefinitions = [
|
|
||||||
"var",
|
|
||||||
"bool",
|
|
||||||
"sbyte",
|
|
||||||
"byte",
|
|
||||||
"char",
|
|
||||||
"short",
|
|
||||||
"ushort",
|
|
||||||
"int",
|
|
||||||
"uint",
|
|
||||||
"long",
|
|
||||||
"ulong",
|
|
||||||
"float",
|
|
||||||
"double",
|
|
||||||
"decimal",
|
|
||||||
"date",
|
|
||||||
"resource",
|
|
||||||
"DistributedResource",
|
|
||||||
"ResourceLink",
|
|
||||||
"string",
|
|
||||||
"structure"
|
|
||||||
];
|
|
||||||
|
|
||||||
get typeTemplate() {
|
|
||||||
return this.typeGuid == null ? null : Warehouse.getTemplateByType(this.typeGuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
//@TODO: implement this
|
|
||||||
static fromType(type)
|
|
||||||
{
|
|
||||||
var isArray = type instanceof Array;
|
|
||||||
if (isArray)
|
|
||||||
type = type[0]
|
|
||||||
|
|
||||||
var dataType = 0;
|
|
||||||
var typeGuid = null;
|
|
||||||
|
|
||||||
|
|
||||||
if (!isNaN(type))
|
|
||||||
dataType = type;
|
|
||||||
else if (type == Structure)
|
|
||||||
dataType = DataType.Structure;
|
|
||||||
else if (typeof type == "string")
|
|
||||||
{
|
|
||||||
var tIndex = this.typesDefinitions.indexOf(type);
|
|
||||||
dataType = tIndex > -1 ? tIndex : 0;
|
|
||||||
}
|
|
||||||
else if (type?.prototype instanceof IResource)
|
|
||||||
{
|
|
||||||
dataType = DataType.Resource;
|
|
||||||
typeGuid = TypeTemplate.getTypeGuid(type);
|
|
||||||
}
|
|
||||||
else if (type?.prototype instanceof IRecord)
|
|
||||||
{
|
|
||||||
dataType = DataType.Record;
|
|
||||||
typeGuid = TypeTemplate.getTypeGuid(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isArray)
|
|
||||||
dataType |= DataType.VarArray;
|
|
||||||
|
|
||||||
return new TemplateDataType(DataType.StructureArray);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
compose()
|
|
||||||
{
|
|
||||||
if (this.type == DataType.Resource ||
|
|
||||||
this.type == DataType.ResourceArray ||
|
|
||||||
this.type == DataType.Record ||
|
|
||||||
this.type == DataType.RecordArray)
|
|
||||||
{
|
|
||||||
return BL()
|
|
||||||
.addUint8(this.type)
|
|
||||||
.addUint8Array(this.typeGuid)
|
|
||||||
.toDC();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return DC.from([this.type]);
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(type, guid){
|
|
||||||
this.type = type;
|
|
||||||
this.typeGuid = guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
static parse(data, offset)
|
|
||||||
{
|
|
||||||
var type = data.getUint8(offset++);
|
|
||||||
if (type == DataType.Resource ||
|
|
||||||
type == DataType.ResourceArray ||
|
|
||||||
type == DataType.Record ||
|
|
||||||
type == DataType.RecordArray)
|
|
||||||
{
|
|
||||||
var guid = data.getGuid(offset);
|
|
||||||
return {size: 17, value: new TemplateDataType(type, guid)};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return {size: 1, value: new TemplateDataType(type)};
|
|
||||||
}
|
|
||||||
}
|
|
@ -29,12 +29,13 @@
|
|||||||
import { ResourceTrigger } from '../Resource/IResource.js';
|
import { ResourceTrigger } from '../Resource/IResource.js';
|
||||||
import IStore from '../Resource/IStore.js'
|
import IStore from '../Resource/IStore.js'
|
||||||
import AsyncReply from '../Core/AsyncReply.js';
|
import AsyncReply from '../Core/AsyncReply.js';
|
||||||
import Codec from '../Data/Codec.js';
|
|
||||||
import Warehouse from '../Resource/Warehouse.js';
|
import Warehouse from '../Resource/Warehouse.js';
|
||||||
import DataType from '../Data/DataType.js';
|
|
||||||
import AsyncBag from '../Core/AsyncBag.js';
|
import AsyncBag from '../Core/AsyncBag.js';
|
||||||
import ErrorType from '../Core/ErrorType.js';
|
import ErrorType from '../Core/ErrorType.js';
|
||||||
import ExceptionCode from '../Core/ExceptionCode.js';
|
import ExceptionCode from '../Core/ExceptionCode.js';
|
||||||
|
import {RepresentationType, RepresentationTypeIdentifier} from '../Data/RepresentationType.js';
|
||||||
|
import TypedMap from '../Data/TypedMap.js';
|
||||||
|
import ResourceProxy from '../Proxy/ResourceProxy.js';
|
||||||
|
|
||||||
export default class IndexedDBStore extends IStore
|
export default class IndexedDBStore extends IStore
|
||||||
{
|
{
|
||||||
@ -47,32 +48,33 @@ export default class IndexedDBStore extends IStore
|
|||||||
|
|
||||||
compose(value)
|
compose(value)
|
||||||
{
|
{
|
||||||
let type = Codec.getDataType(value, null);
|
let type = RepresentationType.fromType(value);
|
||||||
|
|
||||||
switch (type)
|
switch (type.identifier)
|
||||||
{
|
{
|
||||||
case DataType.Void:
|
|
||||||
|
case RepresentationTypeIdentifier.Void:
|
||||||
// nothing to do;
|
// nothing to do;
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
case DataType.String:
|
case RepresentationTypeIdentifier.String:
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
case DataType.Resource:
|
case RepresentationTypeIdentifier.Resource:
|
||||||
case DataType.DistributedResource:
|
case RepresentationTypeIdentifier.DistributedResource:
|
||||||
return { "type": 0 , "link": value.instance.link };
|
return { "type": 0 , "link": value.instance.link };
|
||||||
|
|
||||||
case DataType.Structure:
|
case RepresentationTypeIdentifier.Map:
|
||||||
return this.composeStructure(value);
|
return this.composeMap(value);
|
||||||
|
|
||||||
case DataType.VarArray:
|
case RepresentationTypeIdentifier.List:
|
||||||
return this.composeVarArray(value);
|
return this.composeList(value);
|
||||||
|
|
||||||
case DataType.ResourceArray:
|
// case RepresentationTypeIdentifier.List:
|
||||||
return this.composeResourceArray(value);
|
// return this.composeResourceArray(value);
|
||||||
|
|
||||||
case DataType.StructureArray:
|
//case RepresentationTypeIdentifier.Typed:
|
||||||
return this.composeStructureArray(value);
|
// return this.composeStructureArray(value);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return value;
|
return value;
|
||||||
@ -103,7 +105,7 @@ export default class IndexedDBStore extends IStore
|
|||||||
var bag = new AsyncBag();
|
var bag = new AsyncBag();
|
||||||
var rt = new AsyncReply();
|
var rt = new AsyncReply();
|
||||||
|
|
||||||
let s = new Structure();
|
let s = new (TypedMap.of(String, Object))();
|
||||||
|
|
||||||
for (let i = 0; i < value.values.length; i++)
|
for (let i = 0; i < value.values.length; i++)
|
||||||
bag.add(this.parse(value.values[i].value));
|
bag.add(this.parse(value.values[i].value));
|
||||||
@ -112,7 +114,7 @@ export default class IndexedDBStore extends IStore
|
|||||||
bag.then((x) =>
|
bag.then((x) =>
|
||||||
{
|
{
|
||||||
for (let i = 0; i < x.length; i++)
|
for (let i = 0; i < x.length; i++)
|
||||||
s[value.values[i].name] = x[i];
|
s.set(value.values[i].name, x[i]);
|
||||||
|
|
||||||
rt.trigger(s);
|
rt.trigger(s);
|
||||||
});
|
});
|
||||||
@ -190,7 +192,7 @@ export default class IndexedDBStore extends IStore
|
|||||||
|
|
||||||
var bag = new AsyncBag();
|
var bag = new AsyncBag();
|
||||||
|
|
||||||
for(var i = 0; i < doc.values.length; i++)
|
for(let i = 0; i < doc.values.length; i++)
|
||||||
{
|
{
|
||||||
let v = doc.values[i];
|
let v = doc.values[i];
|
||||||
|
|
||||||
@ -347,12 +349,15 @@ export default class IndexedDBStore extends IStore
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
composeStructure(value)
|
composeMap(value)
|
||||||
{
|
{
|
||||||
return {type: 1, values: value.toObject()};
|
var values = {};
|
||||||
|
for(let [k,v] of value)
|
||||||
|
values[[k]] = v;
|
||||||
|
return {type: 1, values};
|
||||||
}
|
}
|
||||||
|
|
||||||
composeVarArray(array)
|
composeList(array)
|
||||||
{
|
{
|
||||||
var rt = [];
|
var rt = [];
|
||||||
|
|
||||||
@ -361,25 +366,25 @@ export default class IndexedDBStore extends IStore
|
|||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
composeStructureArray(structures)
|
// composeStructureArray(structures)
|
||||||
{
|
// {
|
||||||
var rt = [];
|
// var rt = [];
|
||||||
|
|
||||||
if (structures == null || structures.length == 0)
|
// if (structures == null || structures.length == 0)
|
||||||
return rt;
|
// return rt;
|
||||||
|
|
||||||
for(var i = 0; i < structures.length; i++)
|
// for(var i = 0; i < structures.length; i++)
|
||||||
rt.push(this.composeStructure(structures[s]));
|
// rt.push(this.composeStructure(structures[s]));
|
||||||
|
|
||||||
return rt;
|
// return rt;
|
||||||
}
|
// }
|
||||||
|
|
||||||
composeResourceArray(array)
|
// composeResourceArray(array)
|
||||||
{
|
// {
|
||||||
var rt = [];
|
// var rt = [];
|
||||||
for (var i = 0; i < array.length; i++)
|
// for (var i = 0; i < array.length; i++)
|
||||||
rt.push({ "type": 0 , "link": array[i].instance.link });
|
// rt.push({ "type": 0 , "link": array[i].instance.link });
|
||||||
return rt;
|
// return rt;
|
||||||
}
|
// }
|
||||||
|
|
||||||
}
|
}
|
30
src/esiur.js
30
src/esiur.js
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
import Structure from './Data/Structure.js';
|
import TypedMap from './Data/TypedMap.js';
|
||||||
|
import TypedList from './Data/TypedList.js';
|
||||||
|
|
||||||
import DistributedResource from './Net/IIP/DistributedResource.js'
|
import DistributedResource from './Net/IIP/DistributedResource.js'
|
||||||
import MemoryStore from './Stores/MemoryStore.js';
|
import MemoryStore from './Stores/MemoryStore.js';
|
||||||
import IndexedDBStore from './Stores/IndexedDBStore.js';
|
import IndexedDBStore from './Stores/IndexedDBStore.js';
|
||||||
@ -26,19 +28,14 @@ import AutoMap from './Data/AutoMap.js';
|
|||||||
import BinaryList from './Data/BinaryList.js';
|
import BinaryList from './Data/BinaryList.js';
|
||||||
import Codec from './Data/Codec.js';
|
import Codec from './Data/Codec.js';
|
||||||
import DC from './Data/DC.js';
|
import DC from './Data/DC.js';
|
||||||
import DataType from './Data/DataType.js';
|
|
||||||
import Guid from './Data/Guid.js';
|
import Guid from './Data/Guid.js';
|
||||||
import IRecord from './Data/IRecord.js';
|
import IRecord from './Data/IRecord.js';
|
||||||
import KeyList from './Data/KeyList.js';
|
import KeyList from './Data/KeyList.js';
|
||||||
import NotModified from './Data/NotModified.js';
|
import NotModified from './Data/NotModified.js';
|
||||||
import PropertyValue from './Data/PropertyValue.js';
|
import PropertyValue from './Data/PropertyValue.js';
|
||||||
import Record from './Data/Record.js';
|
import Record from './Data/Record.js';
|
||||||
import ResourceComparisonResult from './Data/ResourceComparisonResult.js';
|
|
||||||
import ResourceArrayType from './Data/ResourceArrayType.js';
|
import ResourceArrayType from './Data/ResourceArrayType.js';
|
||||||
import ResourceArray from './Data/ResourceArray.js';
|
import ResourceArray from './Data/ResourceArray.js';
|
||||||
import RecordComparisonResult from './Data/RecordComparisonResult.js';
|
|
||||||
import StructureComparisonResult from './Data/StructureComparisonResult.js';
|
|
||||||
import StructureArray from './Data/StructureArray.js';
|
|
||||||
import INetworkReceiver from './Net/INetworkReceiver.js';
|
import INetworkReceiver from './Net/INetworkReceiver.js';
|
||||||
import NetworkBuffer from './Net/NetworkBuffer.js';
|
import NetworkBuffer from './Net/NetworkBuffer.js';
|
||||||
import NetworkConnections from './Net/NetworkConnections.js';
|
import NetworkConnections from './Net/NetworkConnections.js';
|
||||||
@ -67,10 +64,12 @@ import FunctionTemplate from './Resource/Template/FunctionTemplate.js';
|
|||||||
import MemberTemplate from './Resource/Template/MemberTemplate.js';
|
import MemberTemplate from './Resource/Template/MemberTemplate.js';
|
||||||
import MemberType from './Resource/Template/MemberType.js';
|
import MemberType from './Resource/Template/MemberType.js';
|
||||||
import PropertyTemplate from './Resource/Template/PropertyTemplate.js';
|
import PropertyTemplate from './Resource/Template/PropertyTemplate.js';
|
||||||
import TemplateDataType from './Resource/Template/TemplateDataType.js';
|
|
||||||
import TemplateType from './Resource/Template/TemplateType.js';
|
import TemplateType from './Resource/Template/TemplateType.js';
|
||||||
import TypeTemplate from './Resource/Template/TypeTemplate.js';
|
import TypeTemplate from './Resource/Template/TypeTemplate.js';
|
||||||
|
|
||||||
|
import {RepresentationType, RepresentationTypeIdentifier} from './Data/RepresentationType.js';
|
||||||
|
import {TransmissionType, TransmissionTypeIdentifier} from './Data/TransmissionType.js';
|
||||||
|
|
||||||
import Authentication from './Security/Authority/Authentication.js';
|
import Authentication from './Security/Authority/Authentication.js';
|
||||||
import AuthenticationMethod from './Security/Authority/AuthenticationMethod.js';
|
import AuthenticationMethod from './Security/Authority/AuthenticationMethod.js';
|
||||||
import AuthenticationType from './Security/Authority/AuthenticationType.js';
|
import AuthenticationType from './Security/Authority/AuthenticationType.js';
|
||||||
@ -84,11 +83,14 @@ import ActionType from './Security/Permissions/ActionType.js';
|
|||||||
import IPermissionsManager from './Security/Permissions/IPermissionsManager.js';
|
import IPermissionsManager from './Security/Permissions/IPermissionsManager.js';
|
||||||
import Ruling from './Security/Permissions/Ruling.js';
|
import Ruling from './Security/Permissions/Ruling.js';
|
||||||
|
|
||||||
|
import { Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128, Float32, Float64, Float128, Char16, Char8 } from './Data/ExtendedTypes.js';
|
||||||
|
|
||||||
let namespace = {
|
let namespace = {
|
||||||
Core: { AsyncReply, AsyncException, AsyncQueue, ErrorType, ExceptionCode, IDestructible, IEventHandler, ProgressType},
|
Core: { AsyncReply, AsyncException, AsyncQueue, ErrorType, ExceptionCode, IDestructible, IEventHandler, ProgressType},
|
||||||
Data: {AutoList, AutoMap, BinaryList, Codec, DC, DataType, Guid, IRecord, KeyList, NotModified,
|
Data: {AutoList, AutoMap, BinaryList, Codec, DC, TypedList, TypedMap, Guid, IRecord, KeyList, NotModified,
|
||||||
PropertyValue, Record, RecordComparisonResult, ResourceArray, ResourceArrayType, ResourceComparisonResult, Structure,
|
PropertyValue, Record, ResourceArray, RepresentationType, RepresentationTypeIdentifier, TransmissionType, TransmissionTypeIdentifier,
|
||||||
StructureArray, StructureComparisonResult },
|
Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64, Int128, UInt128, Float32, Float64, Float128, Char16, Char8
|
||||||
|
},
|
||||||
Net: {INetworkReceiver, NetworkBuffer, NetworkConnections, NetworkServer, NetworkSession, SendList,
|
Net: {INetworkReceiver, NetworkBuffer, NetworkConnections, NetworkServer, NetworkSession, SendList,
|
||||||
IIP: {DistributedConnection, DistributedPropertyContext, DistributedResource, DistributedResourceQueueItem,
|
IIP: {DistributedConnection, DistributedPropertyContext, DistributedResource, DistributedResourceQueueItem,
|
||||||
DistributedResourceQueueItemType, DistributedServer, EntryPoint},
|
DistributedResourceQueueItemType, DistributedServer, EntryPoint},
|
||||||
@ -100,7 +102,7 @@ let namespace = {
|
|||||||
Resource: {CustomResourceEvent, Instance, IResource, IStore, Warehouse,
|
Resource: {CustomResourceEvent, Instance, IResource, IStore, Warehouse,
|
||||||
Template: {
|
Template: {
|
||||||
ArgumentTemplate, EventTemplate, FunctionTemplate, MemberTemplate,
|
ArgumentTemplate, EventTemplate, FunctionTemplate, MemberTemplate,
|
||||||
MemberType, PropertyTemplate, TemplateDataType, TemplateType, TypeTemplate
|
MemberType, PropertyTemplate, TemplateType, TypeTemplate
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Security: {
|
Security: {
|
||||||
@ -118,7 +120,8 @@ let namespace = {
|
|||||||
if (typeof window !== 'undefined')
|
if (typeof window !== 'undefined')
|
||||||
{
|
{
|
||||||
window.wh = Warehouse;
|
window.wh = Warehouse;
|
||||||
window.Structure = Structure;
|
window.TypedMap = TypedMap;
|
||||||
|
window.TypedList = TypedList;
|
||||||
window.DistributedResource = DistributedResource;
|
window.DistributedResource = DistributedResource;
|
||||||
window.MemoryStore = MemoryStore;
|
window.MemoryStore = MemoryStore;
|
||||||
window.IndexedDBStore = IndexedDBStore;
|
window.IndexedDBStore = IndexedDBStore;
|
||||||
@ -131,7 +134,8 @@ if (typeof window !== 'undefined')
|
|||||||
else if (typeof global !== 'undefined')
|
else if (typeof global !== 'undefined')
|
||||||
{
|
{
|
||||||
global.wh = Warehouse;
|
global.wh = Warehouse;
|
||||||
global.Structure = Structure;
|
global.TypedMap = TypedMap;
|
||||||
|
global.TypedList = TypedList;
|
||||||
global.DistributedResource = DistributedResource;
|
global.DistributedResource = DistributedResource;
|
||||||
global.MemoryStore = MemoryStore;
|
global.MemoryStore = MemoryStore;
|
||||||
global.IndexedDBStore = IndexedDBStore;
|
global.IndexedDBStore = IndexedDBStore;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user