@xyo-network/node-view 3.18.10 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/neutral/index.mjs +29 -8
- package/dist/neutral/index.mjs.map +1 -1
- package/dist/types/ViewNode.d.ts +4 -4
- package/dist/types/ViewNode.d.ts.map +1 -1
- package/package.json +13 -12
- package/src/ViewNode.ts +10 -7
package/dist/neutral/index.mjs
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __reflectGet = Reflect.get;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
7
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
8
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
9
|
+
if (decorator = decorators[i])
|
|
10
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
11
|
+
if (kind && result) __defProp(target, key, result);
|
|
12
|
+
return result;
|
|
13
|
+
};
|
|
14
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
15
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
16
|
+
|
|
1
17
|
// src/ViewNode.ts
|
|
2
18
|
import { assertEx } from "@xylabs/assert";
|
|
3
|
-
import { ModuleLimitationViewLabel } from "@xyo-network/module-model";
|
|
19
|
+
import { creatableModule, ModuleLimitationViewLabel } from "@xyo-network/module-model";
|
|
4
20
|
import { SimpleModuleResolver } from "@xyo-network/module-resolver";
|
|
5
21
|
import { MemoryNode, MemoryNodeHelper } from "@xyo-network/node-memory";
|
|
6
22
|
import {
|
|
@@ -13,9 +29,6 @@ import {
|
|
|
13
29
|
import { Mutex } from "async-mutex";
|
|
14
30
|
var ViewNodeConfigSchema = "network.xyo.node.view.config";
|
|
15
31
|
var ViewNode = class extends MemoryNode {
|
|
16
|
-
static configSchemas = [...super.configSchemas, ViewNodeConfigSchema];
|
|
17
|
-
static defaultConfigSchema = ViewNodeConfigSchema;
|
|
18
|
-
static labels = { ...ModuleLimitationViewLabel };
|
|
19
32
|
_buildMutex = new Mutex();
|
|
20
33
|
_built = false;
|
|
21
34
|
_limitedResolver = new SimpleModuleResolver({ root: this });
|
|
@@ -76,17 +89,19 @@ var ViewNode = class extends MemoryNode {
|
|
|
76
89
|
async startHandler() {
|
|
77
90
|
await super.startHandler();
|
|
78
91
|
await this.build();
|
|
79
|
-
return true;
|
|
80
92
|
}
|
|
81
93
|
async build() {
|
|
94
|
+
if (this._buildMutex.isLocked()) {
|
|
95
|
+
throw new Error("ViewNode is already building, please wait for it to finish before calling build again");
|
|
96
|
+
}
|
|
82
97
|
return await this._buildMutex.runExclusive(async () => {
|
|
83
98
|
if (!this._built) {
|
|
84
|
-
const source = asNodeInstance(await super.resolve(this.source));
|
|
99
|
+
const source = this.source === void 0 ? void 0 : asNodeInstance(await super.resolve(this.source));
|
|
85
100
|
if (source) {
|
|
86
101
|
await Promise.all(
|
|
87
|
-
this.ids
|
|
102
|
+
this.ids?.map(async (id) => {
|
|
88
103
|
await MemoryNodeHelper.attachToExistingNode(source, id, this);
|
|
89
|
-
})
|
|
104
|
+
}) ?? []
|
|
90
105
|
);
|
|
91
106
|
this._built = true;
|
|
92
107
|
}
|
|
@@ -94,6 +109,12 @@ var ViewNode = class extends MemoryNode {
|
|
|
94
109
|
});
|
|
95
110
|
}
|
|
96
111
|
};
|
|
112
|
+
__publicField(ViewNode, "configSchemas", [...__superGet(ViewNode, ViewNode, "configSchemas"), ViewNodeConfigSchema]);
|
|
113
|
+
__publicField(ViewNode, "defaultConfigSchema", ViewNodeConfigSchema);
|
|
114
|
+
__publicField(ViewNode, "labels", { ...ModuleLimitationViewLabel });
|
|
115
|
+
ViewNode = __decorateClass([
|
|
116
|
+
creatableModule()
|
|
117
|
+
], ViewNode);
|
|
97
118
|
export {
|
|
98
119
|
ViewNode,
|
|
99
120
|
ViewNodeConfigSchema
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ViewNode.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { EventListener } from '@xylabs/events'\nimport type { Address } from '@xylabs/hex'\nimport type {\n AnyConfigSchema,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n} from '@xyo-network/module-model'\nimport { ModuleLimitationViewLabel } from '@xyo-network/module-model'\nimport { SimpleModuleResolver } from '@xyo-network/module-resolver'\nimport { MemoryNode, MemoryNodeHelper } from '@xyo-network/node-memory'\nimport type {\n AttachableNodeInstance,\n NodeConfig,\n NodeModuleEventData,\n NodeParams,\n} from '@xyo-network/node-model'\nimport {\n asNodeInstance,\n isNodeModule,\n NodeAttachQuerySchema,\n NodeDetachQuerySchema,\n NodeRegisteredQuerySchema,\n} from '@xyo-network/node-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { Mutex } from 'async-mutex'\n\nexport const ViewNodeConfigSchema = 'network.xyo.node.view.config' as const\nexport type ViewNodeConfigSchema = typeof ViewNodeConfigSchema\n\nexport type ViewNodeConfig = NodeConfig<\n {\n ids: ModuleIdentifier[]\n source: ModuleIdentifier\n },\n ViewNodeConfigSchema\n>\n\nexport type ViewNodeParams = NodeParams<AnyConfigSchema<ViewNodeConfig>>\n\nexport class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventData extends NodeModuleEventData = NodeModuleEventData>\n extends MemoryNode<TParams, TEventData>\n implements AttachableNodeInstance {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ViewNodeConfigSchema]\n static override readonly defaultConfigSchema: Schema = ViewNodeConfigSchema\n static override readonly labels = { ...ModuleLimitationViewLabel }\n\n private _buildMutex = new Mutex()\n private _built = false\n private _limitedResolver = new SimpleModuleResolver({ root: this })\n\n get ids() {\n return this.config.ids\n }\n\n override get queries(): Schema[] {\n const disallowedQueries = new Set<Schema>([NodeAttachQuerySchema, NodeDetachQuerySchema, NodeRegisteredQuerySchema])\n const queries: Schema[] = [...super.queries]\n return queries.filter(query => !disallowedQueries.has(query))\n }\n\n get source() {\n return this.config.source\n }\n\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n override async resolve(): Promise<ModuleInstance[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T | undefined>\n override async resolve<T extends ModuleInstance = ModuleInstance>(\n idOrFilter: ModuleIdentifier = '*',\n _options: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n if (!this._built) {\n await this.build()\n }\n const mods = await this._limitedResolver.resolve('*')\n if (idOrFilter === '*') {\n return mods as unknown as T[]\n }\n switch (typeof idOrFilter) {\n case 'string': {\n const mod = mods.find(mod => mod.modName === idOrFilter || mod.address === idOrFilter)\n return mod as unknown as T\n }\n }\n }\n\n protected override async attachUsingAddress(address: Address) {\n const attached = await this.attached()\n const mods = this.registeredModules().filter(mod => attached.includes(mod.address))\n const existingModule = mods.find(mod => mod.address === address)\n if (existingModule) {\n this.logger?.warn(`ViewNode: Module [${existingModule?.modName ?? existingModule?.address}] already attached at address [${address}]`)\n }\n const mod = assertEx(this.registeredModuleMap[address], () => `Module [${address}] not found in registered mods`)\n\n mod.addParent(this)\n\n const args = { mod, name: mod.modName }\n await this.emit('moduleAttached', args)\n\n this._limitedResolver.add(mod)\n\n if (isNodeModule(mod)) {\n const attachedListener: EventListener<TEventData['moduleAttached']> = async (args: TEventData['moduleAttached']) =>\n await this.emit('moduleAttached', args)\n\n const detachedListener: EventListener<TEventData['moduleDetached']> = async (args: TEventData['moduleDetached']) =>\n await this.emit('moduleDetached', args)\n\n mod.on('moduleAttached', attachedListener)\n mod.on('moduleDetached', detachedListener)\n }\n\n return address\n }\n\n protected override async attachedPublicModules(): Promise<ModuleInstance[]> {\n return (await this._limitedResolver.resolve('*')).filter(mod => mod.address !== this.address)\n }\n\n protected override async detachUsingAddress(address: Address) {\n const mod = assertEx(await this.downResolver.resolve(address), () => `Module [${address}] not found in down resolver`)\n this._limitedResolver.remove(mod.address)\n return address\n }\n\n protected override async startHandler()
|
|
1
|
+
{"version":3,"sources":["../../src/ViewNode.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport type { EventListener } from '@xylabs/events'\nimport type { Address } from '@xylabs/hex'\nimport type {\n AnyConfigSchema,\n ModuleFilterOptions,\n ModuleIdentifier,\n ModuleInstance,\n} from '@xyo-network/module-model'\nimport { creatableModule, ModuleLimitationViewLabel } from '@xyo-network/module-model'\nimport { SimpleModuleResolver } from '@xyo-network/module-resolver'\nimport { MemoryNode, MemoryNodeHelper } from '@xyo-network/node-memory'\nimport type {\n AttachableNodeInstance,\n NodeConfig,\n NodeModuleEventData,\n NodeParams,\n} from '@xyo-network/node-model'\nimport {\n asNodeInstance,\n isNodeModule,\n NodeAttachQuerySchema,\n NodeDetachQuerySchema,\n NodeRegisteredQuerySchema,\n} from '@xyo-network/node-model'\nimport type { Schema } from '@xyo-network/payload-model'\nimport { Mutex } from 'async-mutex'\n\nexport const ViewNodeConfigSchema = 'network.xyo.node.view.config' as const\nexport type ViewNodeConfigSchema = typeof ViewNodeConfigSchema\n\nexport type ViewNodeConfig = NodeConfig<\n {\n ids: ModuleIdentifier[]\n source: ModuleIdentifier\n },\n ViewNodeConfigSchema\n>\n\nexport type ViewNodeParams = NodeParams<AnyConfigSchema<ViewNodeConfig>>\n\n@creatableModule()\nexport class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventData extends NodeModuleEventData = NodeModuleEventData>\n extends MemoryNode<TParams, TEventData>\n implements AttachableNodeInstance<TParams, TEventData> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ViewNodeConfigSchema]\n static override readonly defaultConfigSchema: Schema = ViewNodeConfigSchema\n static override readonly labels = { ...ModuleLimitationViewLabel }\n\n private _buildMutex = new Mutex()\n private _built = false\n private _limitedResolver = new SimpleModuleResolver({ root: this })\n\n get ids() {\n return this.config.ids\n }\n\n override get queries(): Schema[] {\n const disallowedQueries = new Set<Schema>([NodeAttachQuerySchema, NodeDetachQuerySchema, NodeRegisteredQuerySchema])\n const queries: Schema[] = [...super.queries]\n return queries.filter(query => !disallowedQueries.has(query))\n }\n\n get source() {\n return this.config.source\n }\n\n /** @deprecated do not pass undefined. If trying to get all, pass '*' */\n override async resolve(): Promise<ModuleInstance[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>\n override async resolve<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T | undefined>\n override async resolve<T extends ModuleInstance = ModuleInstance>(\n idOrFilter: ModuleIdentifier = '*',\n _options: ModuleFilterOptions<T> = {},\n ): Promise<T | T[] | undefined> {\n if (!this._built) {\n await this.build()\n }\n const mods = await this._limitedResolver.resolve('*')\n if (idOrFilter === '*') {\n return mods as unknown as T[]\n }\n switch (typeof idOrFilter) {\n case 'string': {\n const mod = mods.find(mod => mod.modName === idOrFilter || mod.address === idOrFilter)\n return mod as unknown as T\n }\n }\n }\n\n protected override async attachUsingAddress(address: Address) {\n const attached = await this.attached()\n const mods = this.registeredModules().filter(mod => attached.includes(mod.address))\n const existingModule = mods.find(mod => mod.address === address)\n if (existingModule) {\n this.logger?.warn(`ViewNode: Module [${existingModule?.modName ?? existingModule?.address}] already attached at address [${address}]`)\n }\n const mod = assertEx(this.registeredModuleMap[address], () => `Module [${address}] not found in registered mods`)\n\n mod.addParent(this)\n\n const args = { mod, name: mod.modName }\n await this.emit('moduleAttached', args)\n\n this._limitedResolver.add(mod)\n\n if (isNodeModule(mod)) {\n const attachedListener: EventListener<TEventData['moduleAttached']> = async (args: TEventData['moduleAttached']) =>\n await this.emit('moduleAttached', args)\n\n const detachedListener: EventListener<TEventData['moduleDetached']> = async (args: TEventData['moduleDetached']) =>\n await this.emit('moduleDetached', args)\n\n mod.on('moduleAttached', attachedListener)\n mod.on('moduleDetached', detachedListener)\n }\n\n return address\n }\n\n protected override async attachedPublicModules(): Promise<ModuleInstance[]> {\n return (await this._limitedResolver.resolve('*')).filter(mod => mod.address !== this.address)\n }\n\n protected override async detachUsingAddress(address: Address) {\n const mod = assertEx(await this.downResolver.resolve(address), () => `Module [${address}] not found in down resolver`)\n this._limitedResolver.remove(mod.address)\n return address\n }\n\n protected override async startHandler() {\n await super.startHandler()\n await this.build()\n }\n\n private async build() {\n if (this._buildMutex.isLocked()) {\n throw new Error('ViewNode is already building, please wait for it to finish before calling build again')\n }\n return await this._buildMutex.runExclusive(async () => {\n if (!this._built) {\n const source = this.source === undefined ? undefined : asNodeInstance(await super.resolve(this.source))\n if (source) {\n await Promise.all(\n this.ids?.map(async (id) => {\n await MemoryNodeHelper.attachToExistingNode(source, id, this)\n }) ?? [],\n )\n this._built = true\n }\n }\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAAS,gBAAgB;AASzB,SAAS,iBAAiB,iCAAiC;AAC3D,SAAS,4BAA4B;AACrC,SAAS,YAAY,wBAAwB;AAO7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,aAAa;AAEf,IAAM,uBAAuB;AAc7B,IAAM,WAAN,cACG,WAC+C;AAAA,EAK/C,cAAc,IAAI,MAAM;AAAA,EACxB,SAAS;AAAA,EACT,mBAAmB,IAAI,qBAAqB,EAAE,MAAM,KAAK,CAAC;AAAA,EAElE,IAAI,MAAM;AACR,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,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kBAAe,oBAAoB;AAChG,cAJW,UAIc,uBAA8B;AACvD,cALW,UAKc,UAAS,EAAE,GAAG,0BAA0B;AALtD,WAAN;AAAA,EADN,gBAAgB;AAAA,GACJ;","names":["mod","args"]}
|
package/dist/types/ViewNode.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type ViewNodeConfig = NodeConfig<{
|
|
|
10
10
|
source: ModuleIdentifier;
|
|
11
11
|
}, ViewNodeConfigSchema>;
|
|
12
12
|
export type ViewNodeParams = NodeParams<AnyConfigSchema<ViewNodeConfig>>;
|
|
13
|
-
export declare class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventData extends NodeModuleEventData = NodeModuleEventData> extends MemoryNode<TParams, TEventData> implements AttachableNodeInstance {
|
|
13
|
+
export declare class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventData extends NodeModuleEventData = NodeModuleEventData> extends MemoryNode<TParams, TEventData> implements AttachableNodeInstance<TParams, TEventData> {
|
|
14
14
|
static readonly configSchemas: Schema[];
|
|
15
15
|
static readonly defaultConfigSchema: Schema;
|
|
16
16
|
static readonly labels: {
|
|
@@ -19,9 +19,9 @@ export declare class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, T
|
|
|
19
19
|
private _buildMutex;
|
|
20
20
|
private _built;
|
|
21
21
|
private _limitedResolver;
|
|
22
|
-
get ids(): string[];
|
|
22
|
+
get ids(): string[] | undefined;
|
|
23
23
|
get queries(): Schema[];
|
|
24
|
-
get source(): string;
|
|
24
|
+
get source(): string | undefined;
|
|
25
25
|
/** @deprecated do not pass undefined. If trying to get all, pass '*' */
|
|
26
26
|
resolve(): Promise<ModuleInstance[]>;
|
|
27
27
|
resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>;
|
|
@@ -29,7 +29,7 @@ export declare class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, T
|
|
|
29
29
|
protected attachUsingAddress(address: Address): Promise<Lowercase<string>>;
|
|
30
30
|
protected attachedPublicModules(): Promise<ModuleInstance[]>;
|
|
31
31
|
protected detachUsingAddress(address: Address): Promise<Lowercase<string>>;
|
|
32
|
-
protected startHandler(): Promise<
|
|
32
|
+
protected startHandler(): Promise<void>;
|
|
33
33
|
private build;
|
|
34
34
|
}
|
|
35
35
|
//# sourceMappingURL=ViewNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewNode.d.ts","sourceRoot":"","sources":["../../src/ViewNode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,UAAU,EAAoB,MAAM,0BAA0B,CAAA;AACvE,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,mBAAmB,EACnB,UAAU,EACX,MAAM,yBAAyB,CAAA;AAQhC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAGxD,eAAO,MAAM,oBAAoB,EAAG,8BAAuC,CAAA;AAC3E,MAAM,MAAM,oBAAoB,GAAG,OAAO,oBAAoB,CAAA;AAE9D,MAAM,MAAM,cAAc,GAAG,UAAU,CACrC;IACE,GAAG,EAAE,gBAAgB,EAAE,CAAA;IACvB,MAAM,EAAE,gBAAgB,CAAA;CACzB,EACD,oBAAoB,CACrB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC,CAAA;AAExE,
|
|
1
|
+
{"version":3,"file":"ViewNode.d.ts","sourceRoot":"","sources":["../../src/ViewNode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACf,MAAM,2BAA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AC,CAAC,EAAE,CAAC;IAC5G,OAAO,CAAC,CAAC,SAAS,cAAc,GAAG,cAAc,EAAE,EAAE,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;cAoBxH,kBAAkB,CAAC,OAAO,EAAE,OAAO;cA8BnC,qBAAqB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;cAIlD,kBAAkB,CAAC,OAAO,EAAE,OAAO;cAMnC,YAAY;YAKvB,KAAK;CAkBpB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/node-view",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Primary SDK for using XYO Protocol 2.0",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -29,20 +29,21 @@
|
|
|
29
29
|
"module": "dist/neutral/index.mjs",
|
|
30
30
|
"types": "dist/types/index.d.ts",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@xylabs/assert": "^4.
|
|
33
|
-
"@xylabs/
|
|
34
|
-
"@
|
|
35
|
-
"@xyo-network/module-
|
|
36
|
-
"@xyo-network/
|
|
37
|
-
"@xyo-network/node-
|
|
38
|
-
"@xyo-network/
|
|
32
|
+
"@xylabs/assert": "^4.12.30",
|
|
33
|
+
"@xylabs/creatable": "^4.12.30",
|
|
34
|
+
"@xylabs/hex": "^4.12.30",
|
|
35
|
+
"@xyo-network/module-model": "^4.0.1",
|
|
36
|
+
"@xyo-network/module-resolver": "^4.0.1",
|
|
37
|
+
"@xyo-network/node-memory": "^4.0.1",
|
|
38
|
+
"@xyo-network/node-model": "^4.0.1",
|
|
39
|
+
"@xyo-network/payload-model": "^4.0.1",
|
|
39
40
|
"async-mutex": "^0.5.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@xylabs/events": "^4.
|
|
43
|
-
"@xylabs/ts-scripts-yarn3": "^6.5.
|
|
44
|
-
"@xylabs/tsconfig": "^6.5.
|
|
45
|
-
"@xyo-network/module-events": "^
|
|
43
|
+
"@xylabs/events": "^4.12.30",
|
|
44
|
+
"@xylabs/ts-scripts-yarn3": "^6.5.12",
|
|
45
|
+
"@xylabs/tsconfig": "^6.5.12",
|
|
46
|
+
"@xyo-network/module-events": "^4.0.1",
|
|
46
47
|
"typescript": "^5.8.3"
|
|
47
48
|
},
|
|
48
49
|
"publishConfig": {
|
package/src/ViewNode.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
ModuleIdentifier,
|
|
8
8
|
ModuleInstance,
|
|
9
9
|
} from '@xyo-network/module-model'
|
|
10
|
-
import { ModuleLimitationViewLabel } from '@xyo-network/module-model'
|
|
10
|
+
import { creatableModule, ModuleLimitationViewLabel } from '@xyo-network/module-model'
|
|
11
11
|
import { SimpleModuleResolver } from '@xyo-network/module-resolver'
|
|
12
12
|
import { MemoryNode, MemoryNodeHelper } from '@xyo-network/node-memory'
|
|
13
13
|
import type {
|
|
@@ -39,9 +39,10 @@ export type ViewNodeConfig = NodeConfig<
|
|
|
39
39
|
|
|
40
40
|
export type ViewNodeParams = NodeParams<AnyConfigSchema<ViewNodeConfig>>
|
|
41
41
|
|
|
42
|
+
@creatableModule()
|
|
42
43
|
export class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventData extends NodeModuleEventData = NodeModuleEventData>
|
|
43
44
|
extends MemoryNode<TParams, TEventData>
|
|
44
|
-
implements AttachableNodeInstance {
|
|
45
|
+
implements AttachableNodeInstance<TParams, TEventData> {
|
|
45
46
|
static override readonly configSchemas: Schema[] = [...super.configSchemas, ViewNodeConfigSchema]
|
|
46
47
|
static override readonly defaultConfigSchema: Schema = ViewNodeConfigSchema
|
|
47
48
|
static override readonly labels = { ...ModuleLimitationViewLabel }
|
|
@@ -127,21 +128,23 @@ export class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventDat
|
|
|
127
128
|
return address
|
|
128
129
|
}
|
|
129
130
|
|
|
130
|
-
protected override async startHandler()
|
|
131
|
+
protected override async startHandler() {
|
|
131
132
|
await super.startHandler()
|
|
132
133
|
await this.build()
|
|
133
|
-
return true
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
private async build() {
|
|
137
|
+
if (this._buildMutex.isLocked()) {
|
|
138
|
+
throw new Error('ViewNode is already building, please wait for it to finish before calling build again')
|
|
139
|
+
}
|
|
137
140
|
return await this._buildMutex.runExclusive(async () => {
|
|
138
141
|
if (!this._built) {
|
|
139
|
-
const source = asNodeInstance(await super.resolve(this.source))
|
|
142
|
+
const source = this.source === undefined ? undefined : asNodeInstance(await super.resolve(this.source))
|
|
140
143
|
if (source) {
|
|
141
144
|
await Promise.all(
|
|
142
|
-
this.ids
|
|
145
|
+
this.ids?.map(async (id) => {
|
|
143
146
|
await MemoryNodeHelper.attachToExistingNode(source, id, this)
|
|
144
|
-
}),
|
|
147
|
+
}) ?? [],
|
|
145
148
|
)
|
|
146
149
|
this._built = true
|
|
147
150
|
}
|