mirror of
https://github.com/esiur/esiur-js.git
synced 2025-05-06 04:22:58 +00:00
TemplateType.Wrapper Removed
This commit is contained in:
parent
b04ff2b5a4
commit
3cbfd2eab0
@ -47,7 +47,7 @@ else if (cmd == "get-template")
|
|||||||
|
|
||||||
let url = args[0];
|
let url = args[0];
|
||||||
|
|
||||||
console.log(`Getting ${url} ${username} ${password} ${dir}`);
|
// console.log(`Getting template '${url}' username: '${username ?? ''}' password '${password ?? ''}' dir '${dir ?? ''}'`);
|
||||||
|
|
||||||
let getTemplate = async () => {
|
let getTemplate = async () => {
|
||||||
let Esiur = (await import('../src/esiur.js')).default;
|
let Esiur = (await import('../src/esiur.js')).default;
|
||||||
|
1785
build/esiur.js
1785
build/esiur.js
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "esiur",
|
"name": "esiur",
|
||||||
"version": "2.1.10",
|
"version": "2.2.0",
|
||||||
"description": "Distributed Object Framework",
|
"description": "Distributed Object Framework",
|
||||||
"main": "esiur.js",
|
"main": "esiur.js",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
@ -138,7 +138,7 @@ export default class RepresentationType {
|
|||||||
if (IdentifierToTypeMap[this.identifier] != undefined)
|
if (IdentifierToTypeMap[this.identifier] != undefined)
|
||||||
runtimeType = IdentifierToTypeMap[this.identifier]
|
runtimeType = IdentifierToTypeMap[this.identifier]
|
||||||
if (this.identifier == RepresentationTypeIdentifier.TypedResource) {
|
if (this.identifier == RepresentationTypeIdentifier.TypedResource) {
|
||||||
runtimeType = Warehouse.getTemplateByClassId(this.guid)?.definedType;
|
runtimeType = Warehouse.getTemplateByClassId(this.guid, TemplateType.Resource)?.definedType;
|
||||||
} else if (this.identifier == RepresentationTypeIdentifier.TypedRecord) {
|
} else if (this.identifier == RepresentationTypeIdentifier.TypedRecord) {
|
||||||
runtimeType = Warehouse.getTemplateByClassId(this.guid, TemplateType.Record)?.definedType;
|
runtimeType = Warehouse.getTemplateByClassId(this.guid, TemplateType.Record)?.definedType;
|
||||||
} else if (this.identifier == RepresentationTypeIdentifier.Enum) {
|
} else if (this.identifier == RepresentationTypeIdentifier.Enum) {
|
||||||
|
@ -2584,8 +2584,8 @@ export default class DistributedConnection extends IStore {
|
|||||||
|
|
||||||
if (resource == null)
|
if (resource == null)
|
||||||
{
|
{
|
||||||
template = Warehouse.getTemplateByClassId(classId, TemplateType.Wrapper);
|
template = Warehouse.getTemplateByClassId(classId, TemplateType.Resource);
|
||||||
if (template?.definedType != null)
|
if (template?.definedType != null && template?.isWrapper)
|
||||||
dr = new template.definedType(self, id, rt[1], rt[2]);
|
dr = new template.definedType(self, id, rt[1], rt[2]);
|
||||||
else
|
else
|
||||||
dr = new DistributedResource(self, id, rt[1], rt[2]);
|
dr = new DistributedResource(self, id, rt[1], rt[2]);
|
||||||
|
@ -119,8 +119,7 @@ export default class TemplateGenerator {
|
|||||||
let className = templates
|
let className = templates
|
||||||
.find((x) =>
|
.find((x) =>
|
||||||
x.classId.valueOf() == representationType.guid.valueOf() &&
|
x.classId.valueOf() == representationType.guid.valueOf() &&
|
||||||
(x.type == TemplateType.Resource ||
|
(x.type == TemplateType.Resource))
|
||||||
x.type == TemplateType.Wrapper))
|
|
||||||
.className;
|
.className;
|
||||||
if (!dependencies?.includes(className)) dependencies?.push(className);
|
if (!dependencies?.includes(className)) dependencies?.push(className);
|
||||||
name = this._translateClassName(className);
|
name = this._translateClassName(className);
|
||||||
@ -386,8 +385,7 @@ export default class TemplateGenerator {
|
|||||||
let parentClassName = templates
|
let parentClassName = templates
|
||||||
.find((x) =>
|
.find((x) =>
|
||||||
(x.classId.valueOf() == template.parentId.valueOf()) &&
|
(x.classId.valueOf() == template.parentId.valueOf()) &&
|
||||||
(x.type == TemplateType.Resource ||
|
(x.type == TemplateType.Resource))
|
||||||
x.type == TemplateType.Wrapper))
|
|
||||||
.className;
|
.className;
|
||||||
parentName = this._translateClassName(parentClassName);
|
parentName = this._translateClassName(parentClassName);
|
||||||
dependencies.push(parentClassName);
|
dependencies.push(parentClassName);
|
||||||
|
@ -39,6 +39,7 @@ import TypedList from '../Data/TypedList.js';
|
|||||||
import EventOccurredInfo from './EventOccurredInfo.js';
|
import EventOccurredInfo from './EventOccurredInfo.js';
|
||||||
import PropertyModificationInfo from './PropertyModificationInfo.js';
|
import PropertyModificationInfo from './PropertyModificationInfo.js';
|
||||||
import PropertyValueArray from '../Data/PropertyValueArray.js';
|
import PropertyValueArray from '../Data/PropertyValueArray.js';
|
||||||
|
import DistributedResource from '../Net/IIP/DistributedResource.js';
|
||||||
|
|
||||||
export default class Instance extends IEventHandler
|
export default class Instance extends IEventHandler
|
||||||
{
|
{
|
||||||
@ -265,9 +266,10 @@ export default class Instance extends IEventHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
// connect events
|
// connect events
|
||||||
for (let i = 0; i < this.template.events.length; i++)
|
if (!(resource instanceof DistributedResource)) {
|
||||||
resource.on(this.template.events[i].name, this._makeHandler(this.template.events[i]));
|
for (let i = 0; i < this.template.events.length; i++)
|
||||||
|
resource.on(this.template.events[i].name, this._makeHandler(this.template.events[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_makeHandler(eventTemplate)
|
_makeHandler(eventTemplate)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
export default
|
export default
|
||||||
{
|
{
|
||||||
Unspecified: 0,
|
Resource: 0,
|
||||||
Resource: 1,
|
Record: 1,
|
||||||
Record: 2,
|
Enum: 2
|
||||||
Wrapper: 3,
|
|
||||||
Enum: 4
|
|
||||||
}
|
}
|
@ -42,6 +42,13 @@ import Codec from '../../Data/Codec.js';
|
|||||||
|
|
||||||
export default class TypeTemplate {
|
export default class TypeTemplate {
|
||||||
|
|
||||||
|
isWrapper = false;
|
||||||
|
properties = [];
|
||||||
|
events = [];
|
||||||
|
functions = [];
|
||||||
|
members = [];
|
||||||
|
constants = [];
|
||||||
|
|
||||||
getEventTemplateByName(eventName) {
|
getEventTemplateByName(eventName) {
|
||||||
for (var i = 0; i < this.events.length; i++)
|
for (var i = 0; i < this.events.length; i++)
|
||||||
if (this.events[i].name == eventName)
|
if (this.events[i].name == eventName)
|
||||||
@ -222,7 +229,8 @@ export default class TypeTemplate {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getDependenciesFunc(template, list);
|
getDependenciesFunc(template, list);
|
||||||
return list;
|
|
||||||
|
return list.filter((value, index, self) => self.indexOf(value) === index);
|
||||||
}
|
}
|
||||||
|
|
||||||
get type() {
|
get type() {
|
||||||
@ -231,20 +239,12 @@ export default class TypeTemplate {
|
|||||||
|
|
||||||
constructor(type, addToWarehouse) {
|
constructor(type, addToWarehouse) {
|
||||||
|
|
||||||
|
|
||||||
this.properties = [];
|
|
||||||
this.events = [];
|
|
||||||
this.functions = [];
|
|
||||||
this.members = [];
|
|
||||||
this.constants = [];
|
|
||||||
|
|
||||||
|
|
||||||
if (type === undefined)
|
if (type === undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (type.prototype instanceof DistributedResource)
|
|
||||||
this.templateType = TemplateType.Wrapper;
|
if (type.prototype instanceof IRecord)
|
||||||
else if (type.prototype instanceof IRecord)
|
|
||||||
this.templateType = TemplateType.Record;
|
this.templateType = TemplateType.Record;
|
||||||
else if (type.prototype instanceof IResource)
|
else if (type.prototype instanceof IResource)
|
||||||
this.templateType = TemplateType.Resource;
|
this.templateType = TemplateType.Resource;
|
||||||
@ -253,6 +253,8 @@ export default class TypeTemplate {
|
|||||||
else
|
else
|
||||||
throw new Error("Type must implement IResource, IRecord, IEnum or a subtype of DistributedResource.");
|
throw new Error("Type must implement IResource, IRecord, IEnum or a subtype of DistributedResource.");
|
||||||
|
|
||||||
|
this.isWrapper = (type.prototype instanceof DistributedResource);
|
||||||
|
|
||||||
this.definedType = type;
|
this.definedType = type;
|
||||||
|
|
||||||
let describer = type.template;
|
let describer = type.template;
|
||||||
|
@ -55,18 +55,16 @@ export class WH extends IEventHandler
|
|||||||
this.resourceCounter = 0;
|
this.resourceCounter = 0;
|
||||||
this.templates = new KeyList();
|
this.templates = new KeyList();
|
||||||
|
|
||||||
this.templates.add(TemplateType.Unspecified, new KeyList());
|
|
||||||
this.templates.add(TemplateType.Resource, new KeyList());
|
this.templates.add(TemplateType.Resource, new KeyList());
|
||||||
this.templates.add(TemplateType.Record, new KeyList());
|
this.templates.add(TemplateType.Record, new KeyList());
|
||||||
this.templates.add(TemplateType.Wrapper, new KeyList());
|
|
||||||
this.templates.add(TemplateType.Enum, new KeyList());
|
this.templates.add(TemplateType.Enum, new KeyList());
|
||||||
|
|
||||||
this.protocols = new KeyList();
|
this.protocols = new KeyList();
|
||||||
|
|
||||||
this._register("connected");
|
this._register("connected");
|
||||||
this._register("disconnected");
|
this._register("disconnected");
|
||||||
///this._urlRegex = /^(?:([\S]*):\/\/([^\/]*)\/?)/;
|
|
||||||
// this._urlRegex = /^(?:([^\s|:]*):\/\/([^\/]*)\/?)/;
|
|
||||||
this._urlRegex = /^(?:([^\s|:]*):\/\/([^/]*)\/?)/;
|
this._urlRegex = /^(?:([^\s|:]*):\/\/([^/]*)\/?)/;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -306,6 +304,9 @@ export class WH extends IEventHandler
|
|||||||
|
|
||||||
putTemplate(template)
|
putTemplate(template)
|
||||||
{
|
{
|
||||||
|
if (this.templates.get(template.type).containsKey(template.classId))
|
||||||
|
throw new Error("Template with same class Id already exists.");
|
||||||
|
|
||||||
this.templates.get(template.type).add(template.classId, template);
|
this.templates.get(template.type).add(template.classId, template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,11 +315,9 @@ export class WH extends IEventHandler
|
|||||||
if (type == null)
|
if (type == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var templateType = TemplateType.Unspecified;
|
let templateType;
|
||||||
|
|
||||||
if (type.prototype instanceof DistributedResource)
|
if (type.prototype instanceof IResource)
|
||||||
templateType = TemplateType.Wrapper;
|
|
||||||
else if (type.prototype instanceof IResource)
|
|
||||||
templateType = TemplateType.Resource;
|
templateType = TemplateType.Resource;
|
||||||
else if (type.prototype instanceof IRecord)
|
else if (type.prototype instanceof IRecord)
|
||||||
templateType = TemplateType.Record;
|
templateType = TemplateType.Record;
|
||||||
@ -355,44 +354,44 @@ export class WH extends IEventHandler
|
|||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplateByClassId(classId, templateType = TemplateType.Unspecified)
|
getTemplateByClassId(classId, templateType = null)
|
||||||
{
|
{
|
||||||
if (templateType == TemplateType.Unspecified)
|
if (templateType == null)
|
||||||
{
|
{
|
||||||
// look in resources
|
// look into resources
|
||||||
var template = this.templates.get(TemplateType.Resource).get(classId);
|
var template = this.templates.get(TemplateType.Resource).get(classId);
|
||||||
if (template != null)
|
if (template != null)
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
// look in records
|
// look into records
|
||||||
template = this.templates.get(TemplateType.Record).get(classId);
|
template = this.templates.get(TemplateType.Record).get(classId);
|
||||||
if (template != null)
|
if (template != null)
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
// look in wrappers
|
// look into enums
|
||||||
template = this.templates.get(TemplateType.Wrapper).get(classId);
|
template = this.templates.get(TemplateType.Enum).get(classId);
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return this.templates.get(templateType).get(classId);
|
return this.templates.get(templateType).get(classId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getTemplateByClassName(className, templateType = TemplateType.Unspecified)
|
getTemplateByClassName(className, templateType = null)
|
||||||
{
|
{
|
||||||
if (templateType == TemplateType.Unspecified)
|
if (templateType == null)
|
||||||
{
|
{
|
||||||
// look in resources
|
// look into resources
|
||||||
var template = this.templates.get(TemplateType.Resource).values.find(x => x.className == className);
|
var template = this.templates.get(TemplateType.Resource).values.find(x => x.className == className);
|
||||||
if (template != null)
|
if (template != null)
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
// look in records
|
// look into records
|
||||||
template = this.templates.get(TemplateType.Record).values.find(x => x.className == className);
|
template = this.templates.get(TemplateType.Record).values.find(x => x.className == className);
|
||||||
if (template != null)
|
if (template != null)
|
||||||
return template;
|
return template;
|
||||||
|
|
||||||
// look in wrappers
|
// look into enums
|
||||||
template = this.templates.get(TemplateType.Wrapper).values.find(x => x.className == className);
|
template = this.templates.get(TemplateType.Enum).values.find(x => x.className == className);
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user