mirror of
				https://github.com/esiur/esiur-js.git
				synced 2025-11-04 11:21:35 +00:00 
			
		
		
		
	1.8.2
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
module.exports = {
 | 
			
		||||
    "env": {
 | 
			
		||||
        "browser": true,
 | 
			
		||||
        "es2021": true,
 | 
			
		||||
       // "es2021": true,
 | 
			
		||||
        "node": true
 | 
			
		||||
    },
 | 
			
		||||
    "extends": "eslint:recommended",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								README.md
									
									
									
									
									
								
							@@ -2,4 +2,17 @@
 | 
			
		||||
Esiur Library for Javascript
 | 
			
		||||
 | 
			
		||||
# Usage
 | 
			
		||||
npm run 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'))
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1741
									
								
								build/esiur.js
									
									
									
									
									
								
							
							
						
						
									
										1741
									
								
								build/esiur.js
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -42,7 +42,7 @@ class MyChat extends IResource {
 | 
			
		||||
        };
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    constructor(){
 | 
			
		||||
    constructor() {
 | 
			
		||||
      super();
 | 
			
		||||
      this.messages = [new Structure({usr: "Admin", msg: "Welcome to Esiur", date: new Date()})];
 | 
			
		||||
      this.title = "Chat Room";
 | 
			
		||||
 
 | 
			
		||||
@@ -1,13 +1,15 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "esiur",
 | 
			
		||||
  "version": "1.7.2",
 | 
			
		||||
  "version": "1.8.2",
 | 
			
		||||
  "description": "Distributed Object Framework",
 | 
			
		||||
  "main": "esiur.js",
 | 
			
		||||
  "type": "module",
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "demo": "node ./demo/chat/chat.js",
 | 
			
		||||
    "babel": "./node_modules/.bin/babel src -d build",
 | 
			
		||||
    "build": "browserify src/esiur.js -t babelify --outfile build/esiur.js"
 | 
			
		||||
    "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",
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,7 @@ export default class IEventHandler
 | 
			
		||||
    
 | 
			
		||||
    off(event, fn)
 | 
			
		||||
    {
 | 
			
		||||
        event = event.toLocaleString();
 | 
			
		||||
        event = event.toLowerCase();
 | 
			
		||||
        if (this._events[event])
 | 
			
		||||
        {
 | 
			
		||||
            if (fn)
 | 
			
		||||
 
 | 
			
		||||
@@ -45,7 +45,7 @@ export default class AutoList extends IEventHandler
 | 
			
		||||
    add(value)
 | 
			
		||||
    {
 | 
			
		||||
        if (value instanceof IDestructible)
 | 
			
		||||
            value.on("destroy", this._item_destroyed, this);
 | 
			
		||||
            value.on("destroy", this.#_item_destroyed, this);
 | 
			
		||||
 | 
			
		||||
        this.list.push(value);
 | 
			
		||||
 | 
			
		||||
@@ -58,10 +58,10 @@ export default class AutoList extends IEventHandler
 | 
			
		||||
            return;
 | 
			
		||||
 | 
			
		||||
        if (value instanceof IDestructible)
 | 
			
		||||
            value.on("destroy", this._item_destroyed, this);
 | 
			
		||||
            value.on("destroy", this.#_item_destroyed, this);
 | 
			
		||||
 | 
			
		||||
        if (this.list[index] instanceof IDestructible)
 | 
			
		||||
            this.list[index].off("destroy", this._item_destroyed);
 | 
			
		||||
            this.list[index].off("destroy", this.#_item_destroyed);
 | 
			
		||||
 | 
			
		||||
        this.list[index] = value;
 | 
			
		||||
    }
 | 
			
		||||
@@ -99,14 +99,14 @@ export default class AutoList extends IEventHandler
 | 
			
		||||
        var item = this.list[index];
 | 
			
		||||
 | 
			
		||||
        if (item instanceof IDestructible)
 | 
			
		||||
            item.off("destroy", this._item_destroyed);
 | 
			
		||||
            item.off("destroy", this.#_item_destroyed);
 | 
			
		||||
 | 
			
		||||
        this.list.splice(index, 1);
 | 
			
		||||
 | 
			
		||||
        this._emit("remove", item);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _item_destroyed(sender)
 | 
			
		||||
    #_item_destroyed = function(sender)
 | 
			
		||||
    {
 | 
			
		||||
        this.remove(sender);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ export default class AutoMap extends IEventHandler
 | 
			
		||||
    add(key, value)
 | 
			
		||||
    {
 | 
			
		||||
        if (value instanceof IDestructible)
 | 
			
		||||
            value.on("destroy", this._item_destroyed);
 | 
			
		||||
            value.on("destroy", this.#_item_destroyed);
 | 
			
		||||
 | 
			
		||||
        this.dic[key] = value;
 | 
			
		||||
 | 
			
		||||
@@ -58,13 +58,13 @@ export default class AutoMap extends IEventHandler
 | 
			
		||||
    {
 | 
			
		||||
        if (this.dic[key] !== undefined) {
 | 
			
		||||
            if (this.dic[key] instanceof IDestructible)
 | 
			
		||||
                this.dic[key].off("destroy", this._item_destroyed);
 | 
			
		||||
                this.dic[key].off("destroy", this.#_item_destroyed);
 | 
			
		||||
 | 
			
		||||
            delete this.dic[key];
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _item_destroyed(sender)
 | 
			
		||||
    #_item_destroyed = function(sender)
 | 
			
		||||
    {
 | 
			
		||||
        this.remove(sender);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -276,9 +276,12 @@ export default class Codec {
 | 
			
		||||
 | 
			
		||||
            var previous = null;
 | 
			
		||||
 | 
			
		||||
            if (result == ResourceComparisonResult.Null)
 | 
			
		||||
            if (result == ResourceComparisonResult.Empty) {
 | 
			
		||||
                reply.seal();
 | 
			
		||||
                return reply;
 | 
			
		||||
            } else if (result == ResourceComparisonResult.Null) {
 | 
			
		||||
                previous = new AsyncReply(null);
 | 
			
		||||
            else if (result == ResourceComparisonResult.Local)
 | 
			
		||||
            } else if (result == ResourceComparisonResult.Local)
 | 
			
		||||
            {
 | 
			
		||||
                previous = Warehouse.getById(data.getUint32(offset));
 | 
			
		||||
                offset += 4;
 | 
			
		||||
@@ -761,12 +764,19 @@ export default class Codec {
 | 
			
		||||
 | 
			
		||||
            var template = Warehouse.getTemplateByClassId(classId, TemplateType.Record);
 | 
			
		||||
 | 
			
		||||
            reply.arrayType = template.definedType;
 | 
			
		||||
            reply.arrayType = template?.definedType;
 | 
			
		||||
 | 
			
		||||
            var previous = null;
 | 
			
		||||
 | 
			
		||||
            if (result == RecordComparisonResult.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)
 | 
			
		||||
            {
 | 
			
		||||
@@ -806,7 +816,12 @@ export default class Codec {
 | 
			
		||||
            let previous = null;
 | 
			
		||||
            let classId = null;
 | 
			
		||||
 | 
			
		||||
            if (result == RecordComparisonResult.Null)
 | 
			
		||||
            if (result == RecordComparisonResult.Empty)
 | 
			
		||||
            {
 | 
			
		||||
                reply.seal();
 | 
			
		||||
                return reply;
 | 
			
		||||
            }
 | 
			
		||||
            else if (result == RecordComparisonResult.Null)
 | 
			
		||||
                previous = new AsyncReply(null);
 | 
			
		||||
            else if (result == RecordComparisonResult.Record)
 | 
			
		||||
            {
 | 
			
		||||
@@ -820,7 +835,7 @@ export default class Codec {
 | 
			
		||||
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            reply.Add(previous);
 | 
			
		||||
            reply.add(previous);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
            while (offset < end)
 | 
			
		||||
@@ -856,7 +871,7 @@ export default class Codec {
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        reply.Seal();
 | 
			
		||||
        reply.seal();
 | 
			
		||||
        return reply;
 | 
			
		||||
 | 
			
		||||
        // var reply = new AsyncBag();
 | 
			
		||||
@@ -954,7 +969,7 @@ export default class Codec {
 | 
			
		||||
                {
 | 
			
		||||
                    let record = new Record();
 | 
			
		||||
 | 
			
		||||
                    for (let i = 0; i < template.properties.Length; i++)
 | 
			
		||||
                    for (let i = 0; i < template.properties.length; i++)
 | 
			
		||||
                        record[template.properties[i].name] = ar[i];
 | 
			
		||||
 | 
			
		||||
                    reply.trigger(record);
 | 
			
		||||
@@ -1002,11 +1017,12 @@ export default class Codec {
 | 
			
		||||
 | 
			
		||||
    static composeRecordArray(records, connection, prependLength = false)
 | 
			
		||||
    {
 | 
			
		||||
        if (records == null || records?.length == 0)
 | 
			
		||||
        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 = Codec.compareRecords(null, records[0]);
 | 
			
		||||
        var comparsion = records.length == 0 ? RecordComparisonResult.Empty : Codec.compareRecords(null, records[0]);
 | 
			
		||||
 | 
			
		||||
        rt.addUint8(comparsion);
 | 
			
		||||
 | 
			
		||||
@@ -1101,11 +1117,11 @@ static isLocalResource(resource, connection) {
 | 
			
		||||
 | 
			
		||||
 static composeResourceArray(resources, connection, prependLength = false) {
 | 
			
		||||
 | 
			
		||||
    if (resources == null || resources.length == 0)// || !(resources instanceof ResourceArray))
 | 
			
		||||
    if (resources == null)// || resources.length == 0)// || !(resources instanceof ResourceArray))
 | 
			
		||||
        return prependLength ? new DC(4) : new DC(0);
 | 
			
		||||
 | 
			
		||||
    var rt = new BinaryList();
 | 
			
		||||
    var comparsion = Codec.compareResource(null, resources[0], connection);
 | 
			
		||||
    var comparsion = resources.length == 0 ? ResourceComparisonResult.Empty : Codec.compareResource(null, resources[0], connection);
 | 
			
		||||
 | 
			
		||||
    rt.addUint8(comparsion);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -67,7 +67,7 @@ export default class DC extends Uint8Array
 | 
			
		||||
    {
 | 
			
		||||
        // convert hex to Uint8Array
 | 
			
		||||
        var rt = new DC(value.length/2);
 | 
			
		||||
        for(var i = 0; i < ar.length; i++)
 | 
			
		||||
        for(var i = 0; i < rt.length; i++)
 | 
			
		||||
            rt[i] = parseInt(value.substr(i*2, 2), 16);
 | 
			
		||||
        return rt;
 | 
			
		||||
    }
 | 
			
		||||
@@ -295,6 +295,11 @@ export default class DC extends Uint8Array
 | 
			
		||||
        return this.dv.getInt32(offset);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getInt32Little(offset)
 | 
			
		||||
    {
 | 
			
		||||
        return this.dv.getInt32(offset, true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    getUint32(offset)
 | 
			
		||||
    {
 | 
			
		||||
        return this.dv.getUint32(offset);
 | 
			
		||||
@@ -506,6 +511,7 @@ export default class DC extends Uint8Array
 | 
			
		||||
        return rt;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // @TODO: Test numbers with bit 7 of h = 1 
 | 
			
		||||
    getInt64(offset)
 | 
			
		||||
    {
 | 
			
		||||
        var h = this.getInt32(offset);
 | 
			
		||||
 
 | 
			
		||||
@@ -37,4 +37,8 @@ export default class Guid
 | 
			
		||||
    {
 | 
			
		||||
        return this.value.getHex(0, 16);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // [Symbol.toPrimitive](hint){
 | 
			
		||||
    //     console.log(hint);
 | 
			
		||||
    // }
 | 
			
		||||
}
 | 
			
		||||
@@ -57,12 +57,16 @@ export default class KeyList
 | 
			
		||||
 | 
			
		||||
     get(key)
 | 
			
		||||
     {
 | 
			
		||||
         if (key.valueOf != null)
 | 
			
		||||
            key = key.valueOf();
 | 
			
		||||
 | 
			
		||||
        for(var i = 0; i < this.keys.length; i++)
 | 
			
		||||
            if (this.keys[i] == key)
 | 
			
		||||
                return this.values[i];
 | 
			
		||||
            if (this.keys[i].valueOf != null)
 | 
			
		||||
                if (this.keys[i].valueOf() == key)
 | 
			
		||||
                    return this.values[i];
 | 
			
		||||
     }
 | 
			
		||||
 | 
			
		||||
     _item_destroyed(sender)
 | 
			
		||||
     #_item_destroyed = function(sender)
 | 
			
		||||
     {
 | 
			
		||||
         for(var i = 0; i < this.values.length; i++)
 | 
			
		||||
            if (sender == this.values[i])
 | 
			
		||||
@@ -77,7 +81,7 @@ export default class KeyList
 | 
			
		||||
        this.remove(key);
 | 
			
		||||
 | 
			
		||||
        if (value instanceof IDestructible)
 | 
			
		||||
            value.on("destroy", this._item_destroyed, this);
 | 
			
		||||
            value.on("destroy", this.#_item_destroyed, this);
 | 
			
		||||
 | 
			
		||||
        this.keys.push(key);
 | 
			
		||||
        this.values.push(value);
 | 
			
		||||
@@ -116,7 +120,7 @@ export default class KeyList
 | 
			
		||||
     removeAt(index)
 | 
			
		||||
     {
 | 
			
		||||
        if (this.values[index] instanceof IDestructible)
 | 
			
		||||
            this.values[index].off("destroy", this._item_destroyed);
 | 
			
		||||
            this.values[index].off("destroy", this.#_item_destroyed);
 | 
			
		||||
 | 
			
		||||
        this.keys.splice(index, 1);
 | 
			
		||||
        this.values.splice(index, 1);
 | 
			
		||||
 
 | 
			
		||||
@@ -3,5 +3,6 @@ export default // const ResourceComparisonResult =
 | 
			
		||||
    Null: 0,
 | 
			
		||||
    Record: 1,
 | 
			
		||||
    RecordSameType: 2,
 | 
			
		||||
    Same: 3
 | 
			
		||||
    Same: 3,
 | 
			
		||||
    Empty: 4
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -3,5 +3,6 @@ export default // const ResourceComparisonResult =
 | 
			
		||||
    Null: 0,
 | 
			
		||||
    Distributed: 1,
 | 
			
		||||
    Local: 2,
 | 
			
		||||
    Same: 3
 | 
			
		||||
    Same: 3,
 | 
			
		||||
    Empty: 4
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,10 @@
 | 
			
		||||
 | 
			
		||||
export default class Structure
 | 
			
		||||
{
 | 
			
		||||
    toArray() {
 | 
			
		||||
        return this.toPairs();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    toPairs() {
 | 
			
		||||
        var rt = [];
 | 
			
		||||
        for (var i in this)
 | 
			
		||||
 
 | 
			
		||||
@@ -37,7 +37,6 @@ import SendList from '../SendList.js';
 | 
			
		||||
 | 
			
		||||
import AsyncReply from '../../Core/AsyncReply.js';
 | 
			
		||||
import Codec from '../../Data/Codec.js';
 | 
			
		||||
import NetworkBuffer from '../NetworkBuffer.js';
 | 
			
		||||
import KeyList from '../../Data/KeyList.js';
 | 
			
		||||
import AsyncQueue from '../../Core/AsyncQueue.js';
 | 
			
		||||
import Warehouse from '../../Resource/Warehouse.js';
 | 
			
		||||
@@ -601,7 +600,7 @@ export default class DistributedConnection extends IStore {
 | 
			
		||||
                                this.sendParams()
 | 
			
		||||
                                    .addUint8(0xc0)
 | 
			
		||||
                                    .addUint8(ExceptionCode.GeneralFailure)
 | 
			
		||||
                                    .addUint16(errMsg.Length)
 | 
			
		||||
                                    .addUint16(errMsg.length)
 | 
			
		||||
                                    .addUint8Array(errMsg)
 | 
			
		||||
                                    .done();
 | 
			
		||||
                            }
 | 
			
		||||
@@ -1151,9 +1150,9 @@ 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("ResourceDestroyed", this._instance_resourceDestroyed, this);    
 | 
			
		||||
            resource.instance.off("ResourceEventOccurred", this.#_instance_eventOccurred, this);
 | 
			
		||||
            resource.instance.off("ResourceModified", this.#_instance_propertyModified, this);
 | 
			
		||||
            resource.instance.off("ResourceDestroyed", this.#_instance_resourceDestroyed, this);    
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        this.subscriptions.clear();
 | 
			
		||||
@@ -1592,18 +1591,18 @@ 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("ResourceDestroyed", this._instance_resourceDestroyed, this);
 | 
			
		||||
        resource.instance.on("ResourceEventOccurred", this.#_instance_eventOccurred, this);
 | 
			
		||||
        resource.instance.on("ResourceModified", this.#_instance_propertyModified, this);
 | 
			
		||||
        resource.instance.on("ResourceDestroyed", this.#_instance_resourceDestroyed, this);
 | 
			
		||||
 | 
			
		||||
        this.subscriptions.set(resource, []);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _unsubscribe(resource)
 | 
			
		||||
    {
 | 
			
		||||
        resource.instance.off("ResourceEventOccurred", this._instance_eventOccurred, this);
 | 
			
		||||
        resource.instance.off("ResourceModified", this._instance_propertyModified, this);
 | 
			
		||||
        resource.instance.off("ResourceDestroyed", this._instance_resourceDestroyed, this);
 | 
			
		||||
        resource.instance.off("ResourceEventOccurred", this.#_instance_eventOccurred, this);
 | 
			
		||||
        resource.instance.off("ResourceModified", this.#_instance_propertyModified, this);
 | 
			
		||||
        resource.instance.off("ResourceDestroyed", this.#_instance_resourceDestroyed, this);
 | 
			
		||||
 | 
			
		||||
        this.subscriptions.delete(resource);
 | 
			
		||||
    }
 | 
			
		||||
@@ -2587,7 +2586,7 @@ export default class DistributedConnection extends IStore {
 | 
			
		||||
            return new AsyncReply(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _instance_resourceDestroyed(resource) {
 | 
			
		||||
    #_instance_resourceDestroyed = function(resource) {
 | 
			
		||||
 | 
			
		||||
        this._unsubscribe(resource);
 | 
			
		||||
        // compose the packet
 | 
			
		||||
@@ -2596,7 +2595,7 @@ export default class DistributedConnection extends IStore {
 | 
			
		||||
            .done();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _instance_propertyModified(resource, name, newValue) {
 | 
			
		||||
    #_instance_propertyModified = function(resource, name, newValue) {
 | 
			
		||||
        var pt = resource.instance.template.getPropertyTemplateByName(name);
 | 
			
		||||
 | 
			
		||||
        if (pt == null)
 | 
			
		||||
@@ -2609,7 +2608,7 @@ export default class DistributedConnection extends IStore {
 | 
			
		||||
            .done();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _instance_eventOccurred(resource, issuer, receivers, name, args) {
 | 
			
		||||
    #_instance_eventOccurred = function(resource, issuer, receivers, name, args) {
 | 
			
		||||
        var et = resource.instance.template.getEventTemplateByName(name);
 | 
			
		||||
 | 
			
		||||
        if (et == null)
 | 
			
		||||
 
 | 
			
		||||
@@ -65,6 +65,7 @@ export default class DistributedServer extends IResource
 | 
			
		||||
        this.connections = [];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    //@TODO: con.off("close", ...)
 | 
			
		||||
    add() {
 | 
			
		||||
        let self = this;
 | 
			
		||||
        let con = new DistributedConnection(this);
 | 
			
		||||
@@ -75,7 +76,7 @@ export default class DistributedServer extends IResource
 | 
			
		||||
 | 
			
		||||
    remove(connection){
 | 
			
		||||
        let i = this.connections.indexOf(connection);
 | 
			
		||||
        if (i > -1) 
 | 
			
		||||
        if (i > -1)
 | 
			
		||||
            this.connections.splice(i, 1);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +1,4 @@
 | 
			
		||||
import IResource from "../../Resource/IResource";
 | 
			
		||||
import IResource from "../../Resource/IResource.js";
 | 
			
		||||
 | 
			
		||||
export default class EntryPoint extends IResource
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
import IDestructible from "../Core/IDestructible";
 | 
			
		||||
import IDestructible from "../Core/IDestructible.js";
 | 
			
		||||
 | 
			
		||||
export default class INetworkReceiver extends IDestructible {
 | 
			
		||||
    networkClose(sender);
 | 
			
		||||
    networkReceive(sender, buffer);
 | 
			
		||||
    networkConnect(sender);
 | 
			
		||||
    networkClose(sender){}
 | 
			
		||||
    networkReceive(sender, buffer){}
 | 
			
		||||
    networkConnect(sender){}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,4 +1,6 @@
 | 
			
		||||
 | 
			
		||||
import INetworkReceiver from "./INetworkReceiver.js";
 | 
			
		||||
 | 
			
		||||
export default class NetowrkConnection extends INetworkReceiver
 | 
			
		||||
{
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
export default class NetworkServer
 | 
			
		||||
{
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,4 @@
 | 
			
		||||
export default class NetworkSession
 | 
			
		||||
{
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
@@ -250,7 +250,7 @@ export default class TypeTemplate {
 | 
			
		||||
                var pt = new PropertyTemplate();
 | 
			
		||||
                pt.name = pi[0];
 | 
			
		||||
                pt.index = i;
 | 
			
		||||
                pt.valueType = TemplateDataType.fromType(pi[1]),
 | 
			
		||||
                pt.valueType = TemplateDataType.fromType(pi[1]);
 | 
			
		||||
                pt.readExpansion = pi[2]?.read;
 | 
			
		||||
                pt.writeExpansion = pi[2]?.write;
 | 
			
		||||
                pt.recordable = pi[2]?.recordable;
 | 
			
		||||
 
 | 
			
		||||
@@ -210,8 +210,7 @@ export class WH extends IEventHandler
 | 
			
		||||
        var rt = new AsyncReply();
 | 
			
		||||
 | 
			
		||||
        resource.instance = new Instance(this.resourceCounter++, name, resource, store, customTemplate, age);
 | 
			
		||||
        //resource.instance.children.on("add", Warehouse._onChildrenAdd).on("remove", Warehouse._onChildrenRemove);
 | 
			
		||||
        //resource.instance.parents.on("add", Warehouse._onParentsAdd).on("remove", Warehouse._onParentsRemove);
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        if (attributes != null)
 | 
			
		||||
            resource.instance.setAttributes(attributes);
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,7 @@ export default class IndexedDBStore extends IStore
 | 
			
		||||
                 bag.seal();
 | 
			
		||||
                 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];
 | 
			
		||||
 | 
			
		||||
                     rt.trigger(s);
 | 
			
		||||
@@ -365,7 +365,7 @@ export default class IndexedDBStore extends IStore
 | 
			
		||||
     {
 | 
			
		||||
        var rt = [];
 | 
			
		||||
 | 
			
		||||
        if (structures == null || structures.Length == 0)
 | 
			
		||||
        if (structures == null || structures.length == 0)
 | 
			
		||||
             return rt;
 | 
			
		||||
 | 
			
		||||
        for(var i = 0; i < structures.length; i++)
 | 
			
		||||
 
 | 
			
		||||
@@ -116,7 +116,7 @@
 | 
			
		||||
                  bag.seal();
 | 
			
		||||
                  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];
 | 
			
		||||
 
 | 
			
		||||
                      rt.trigger(s);
 | 
			
		||||
@@ -378,7 +378,7 @@
 | 
			
		||||
      {
 | 
			
		||||
         var rt = [];
 | 
			
		||||
 
 | 
			
		||||
         if (structures == null || structures.Length == 0)
 | 
			
		||||
         if (structures == null || structures.length == 0)
 | 
			
		||||
              return rt;
 | 
			
		||||
 
 | 
			
		||||
         for(var i = 0; i < structures.length; i++)
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										118
									
								
								src/esiur.js
									
									
									
									
									
								
							
							
						
						
									
										118
									
								
								src/esiur.js
									
									
									
									
									
								
							@@ -1,5 +1,4 @@
 | 
			
		||||
 | 
			
		||||
import wh from './Resource/Warehouse.js';
 | 
			
		||||
import Structure from './Data/Structure.js';
 | 
			
		||||
import DistributedResource from './Net/IIP/DistributedResource.js'
 | 
			
		||||
import MemoryStore from './Stores/MemoryStore.js';
 | 
			
		||||
@@ -7,10 +6,118 @@ import IndexedDBStore from './Stores/IndexedDBStore.js';
 | 
			
		||||
import IResource from './Resource/IResource.js';
 | 
			
		||||
import ResourceProxy from './Proxy/ResourceProxy.js';
 | 
			
		||||
import DistributedConnection from './Net/IIP/DistributedConnection.js';
 | 
			
		||||
import IIPAuthPacket from './Net/Packets/IIPAuthPacket.js';
 | 
			
		||||
import IIPPacketCommand from './Net/Packets/IIPPacketCommand.js';
 | 
			
		||||
import IIPPacketEvent from './Net/Packets/IIPPacketEvent.js';
 | 
			
		||||
import IIPPacketReport from './Net/Packets/IIPPacketReport.js';
 | 
			
		||||
import ISocket from './Net/Sockets/ISocket.js';
 | 
			
		||||
import SocketState from './Net/Sockets/SocketState.js';
 | 
			
		||||
import WSocket from './Net/Sockets/WSocket.js';
 | 
			
		||||
import AsyncReply from './Core/AsyncReply.js';
 | 
			
		||||
import AsyncException from './Core/AsyncException.js';
 | 
			
		||||
import AsyncQueue from './Core/AsyncQueue.js';
 | 
			
		||||
import ErrorType from './Core/ErrorType.js';
 | 
			
		||||
import ExceptionCode from './Core/ExceptionCode.js';
 | 
			
		||||
import IDestructible from './Core/IDestructible.js';
 | 
			
		||||
import IEventHandler from './Core/IEventHandler.js';
 | 
			
		||||
import ProgressType from './Core/ProgressType.js';
 | 
			
		||||
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 DataType from './Data/DataType.js';
 | 
			
		||||
import Guid from './Data/Guid.js';
 | 
			
		||||
import IRecord from './Data/IRecord.js';
 | 
			
		||||
import KeyList from './Data/KeyList.js';
 | 
			
		||||
import NotModified from './Data/NotModified.js';
 | 
			
		||||
import PropertyValue from './Data/PropertyValue.js';
 | 
			
		||||
import Record from './Data/Record.js';
 | 
			
		||||
import ResourceComparisonResult from './Data/ResourceComparisonResult.js';
 | 
			
		||||
import ResourceArrayType from './Data/ResourceArrayType.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 NetworkBuffer from './Net/NetworkBuffer.js';
 | 
			
		||||
import NetworkConnections from './Net/NetworkConnections.js';
 | 
			
		||||
import NetworkServer from './Net/NetworkServer.js';
 | 
			
		||||
import NetworkSession from './Net/NetworkSession.js';
 | 
			
		||||
import SendList from './Net/SendList.js';
 | 
			
		||||
 | 
			
		||||
import DistributedPropertyContext from './Net/IIP/DistributedPropertyContext.js';
 | 
			
		||||
import DistributedResourceQueueItem from './Net/IIP/DistributedResourceQueueItem.js';
 | 
			
		||||
import DistributedResourceQueueItemType from './Net/IIP/DistributedResourceQueueItemType.js';
 | 
			
		||||
import DistributedServer from './Net/IIP/DistributedServer.js';
 | 
			
		||||
import EntryPoint from './Net/IIP/EntryPoint.js';
 | 
			
		||||
import IIPAuthePacketAction from './Net/Packets/IIPAuthPacketAction.js';
 | 
			
		||||
import IIPAuthPacketCommand from './Net/Packets/IIPAuthPacketCommand.js';
 | 
			
		||||
import IIPPacketAction from './Net/Packets/IIPPacketAction.js';
 | 
			
		||||
import IIPPacket from './Net/Packets/IIPPacket.js';
 | 
			
		||||
 | 
			
		||||
import CustomResourceEvent from './Resource/CustomResourceEvent.js';
 | 
			
		||||
import Instance from './Resource/Instance.js';
 | 
			
		||||
import IStore from './Resource/IStore.js';
 | 
			
		||||
import Warehouse from './Resource/Warehouse.js';
 | 
			
		||||
 | 
			
		||||
import ArgumentTemplate from './Resource/Template/ArgumentTemplate.js';
 | 
			
		||||
import EventTemplate from './Resource/Template/EventTemplate.js';
 | 
			
		||||
import FunctionTemplate from './Resource/Template/FunctionTemplate.js';
 | 
			
		||||
import MemberTemplate from './Resource/Template/MemberTemplate.js';
 | 
			
		||||
import MemberType from './Resource/Template/MemberType.js';
 | 
			
		||||
import PropertyTemplate from './Resource/Template/PropertyTemplate.js';
 | 
			
		||||
import TemplateDataType from './Resource/Template/TemplateDataType.js';
 | 
			
		||||
import TemplateType from './Resource/Template/TemplateType.js';
 | 
			
		||||
import TypeTemplate from './Resource/Template/TypeTemplate.js';
 | 
			
		||||
 | 
			
		||||
import Authentication from './Security/Authority/Authentication.js';
 | 
			
		||||
import AuthenticationMethod from './Security/Authority/AuthenticationMethod.js';
 | 
			
		||||
import AuthenticationType from './Security/Authority/AuthenticationType.js';
 | 
			
		||||
import ClientAuthentication from './Security/Authority/ClientAuthentication.js';
 | 
			
		||||
import HostAuthentication from './Security/Authority/HostAuthentication.js';
 | 
			
		||||
import Session from './Security/Authority/Session.js';
 | 
			
		||||
import SHA256 from './Security/Integrity/SHA256.js';
 | 
			
		||||
import IMembership from './Security/Membership/IMembership.js';
 | 
			
		||||
 | 
			
		||||
import ActionType from './Security/Permissions/ActionType.js';
 | 
			
		||||
import IPermissionsManager from './Security/Permissions/IPermissionsManager.js';
 | 
			
		||||
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, 
 | 
			
		||||
        PropertyValue, Record, RecordComparisonResult, ResourceArray, ResourceArrayType, ResourceComparisonResult, Structure,
 | 
			
		||||
         StructureArray, StructureComparisonResult },
 | 
			
		||||
    Net: {INetworkReceiver, NetworkBuffer, NetworkConnections, NetworkServer, NetworkSession, SendList,        
 | 
			
		||||
            IIP: {DistributedConnection, DistributedPropertyContext, DistributedResource, DistributedResourceQueueItem, 
 | 
			
		||||
                DistributedResourceQueueItemType, DistributedServer, EntryPoint},
 | 
			
		||||
            Packets: {IIPAuthPacket, IIPAuthePacketAction, IIPAuthPacketCommand, IIPPacket, IIPPacketAction, IIPPacketCommand, IIPPacketEvent, IIPPacketReport},
 | 
			
		||||
            Sockets: {ISocket, SocketState, WSocket}
 | 
			
		||||
        
 | 
			
		||||
    },
 | 
			
		||||
    Proxy: {ResourceProxy},
 | 
			
		||||
    Resource: {CustomResourceEvent, Instance, IResource, IStore, Warehouse,
 | 
			
		||||
                Template: {
 | 
			
		||||
                    ArgumentTemplate, EventTemplate, FunctionTemplate, MemberTemplate,
 | 
			
		||||
                    MemberType, PropertyTemplate, TemplateDataType, TemplateType, TypeTemplate
 | 
			
		||||
                }
 | 
			
		||||
              },
 | 
			
		||||
    Security: {
 | 
			
		||||
        Authority: {Authentication, AuthenticationMethod, AuthenticationType, ClientAuthentication, HostAuthentication,
 | 
			
		||||
                    Session},
 | 
			
		||||
        Integrity: {
 | 
			
		||||
            SHA256
 | 
			
		||||
        },
 | 
			
		||||
        Membership: {IMembership},
 | 
			
		||||
        Permissions: {ActionType, IPermissionsManager, Ruling},
 | 
			
		||||
    },
 | 
			
		||||
    Stores: {IndexedDBStore, MemoryStore},
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
if (typeof window !== 'undefined') 
 | 
			
		||||
{
 | 
			
		||||
    window.wh = wh;
 | 
			
		||||
    window.wh = Warehouse;
 | 
			
		||||
    window.Structure = Structure;
 | 
			
		||||
    window.DistributedResource = DistributedResource;
 | 
			
		||||
    window.MemoryStore = MemoryStore;
 | 
			
		||||
@@ -18,16 +125,19 @@ if (typeof window !== 'undefined')
 | 
			
		||||
    window.IResource = IResource;
 | 
			
		||||
    window.ResourceProxy = ResourceProxy;
 | 
			
		||||
    window.DistributedConnection = DistributedConnection;
 | 
			
		||||
 | 
			
		||||
    window.Esiur = namespace;
 | 
			
		||||
}
 | 
			
		||||
else if (typeof global !== 'undefined') 
 | 
			
		||||
{
 | 
			
		||||
    global.wh = wh;
 | 
			
		||||
    global.wh = Warehouse;
 | 
			
		||||
    global.Structure = Structure;
 | 
			
		||||
    global.DistributedResource = DistributedResource;
 | 
			
		||||
    global.MemoryStore = MemoryStore;
 | 
			
		||||
    global.IndexedDBStore = IndexedDBStore;
 | 
			
		||||
    global.IResource = IResource;
 | 
			
		||||
    global.DistributedConnection = DistributedConnection;
 | 
			
		||||
    global.Esiur = namespace;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default wh;
 | 
			
		||||
export default Warehouse;
 | 
			
		||||
		Reference in New Issue
	
	Block a user