@xyo-network/node 2.66.9 → 2.67.0-rc.2
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/cjs/AbstractNode.js +5 -35
- package/dist/cjs/AbstractNode.js.map +1 -1
- package/dist/cjs/MemoryNode.js +0 -3
- package/dist/cjs/MemoryNode.js.map +1 -1
- package/dist/esm/AbstractNode.js +7 -26
- package/dist/esm/AbstractNode.js.map +1 -1
- package/dist/esm/MemoryNode.js +0 -3
- package/dist/esm/MemoryNode.js.map +1 -1
- package/dist/types/AbstractNode.d.ts +7 -11
- package/dist/types/AbstractNode.d.ts.map +1 -1
- package/dist/types/MemoryNode.d.ts +4 -6
- package/dist/types/MemoryNode.d.ts.map +1 -1
- package/package.json +17 -17
- package/src/AbstractNode.ts +29 -45
- package/src/MemoryNode.ts +8 -15
- package/dist/docs.json +0 -44531
package/src/MemoryNode.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/assert'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { AddressPreviousHashPayload, AnyConfigSchema, EventListener, Module, ModuleDescriptionPayload, ModuleResolver } from '@xyo-network/module'
|
|
5
|
-
import { isNodeModule, NodeConfig, NodeConfigSchema, NodeInstance, NodeModule, NodeModuleEventData, NodeModuleParams } from '@xyo-network/node-model'
|
|
6
|
-
import { Payload } from '@xyo-network/payload-model'
|
|
2
|
+
import { AnyConfigSchema, CompositeModuleResolver, EventListener, Module, ModuleInstance, ModuleResolver } from '@xyo-network/module'
|
|
3
|
+
import { isNodeModule, NodeConfig, NodeConfigSchema, NodeInstance, NodeModuleEventData, NodeModuleParams } from '@xyo-network/node-model'
|
|
7
4
|
import compact from 'lodash/compact'
|
|
8
5
|
|
|
9
6
|
import { AbstractNode } from './AbstractNode'
|
|
@@ -16,7 +13,7 @@ export class MemoryNode<TParams extends MemoryNodeParams = MemoryNodeParams, TEv
|
|
|
16
13
|
{
|
|
17
14
|
static override configSchemas = [NodeConfigSchema]
|
|
18
15
|
|
|
19
|
-
private registeredModuleMap: Record<string,
|
|
16
|
+
private registeredModuleMap: Record<string, ModuleInstance> = {}
|
|
20
17
|
|
|
21
18
|
override async attach(nameOrAddress: string, external?: boolean) {
|
|
22
19
|
await this.started('throw')
|
|
@@ -28,7 +25,7 @@ export class MemoryNode<TParams extends MemoryNodeParams = MemoryNodeParams, TEv
|
|
|
28
25
|
return (await this.detachUsingAddress(nameOrAddress)) ?? (await this.detachUsingName(nameOrAddress))
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
override async register(module:
|
|
28
|
+
override async register(module: ModuleInstance) {
|
|
32
29
|
await this.started('throw')
|
|
33
30
|
assertEx(!this.registeredModuleMap[module.address], `Module already registered at that address[${module.address}]`)
|
|
34
31
|
this.registeredModuleMap[module.address] = module
|
|
@@ -48,11 +45,7 @@ export class MemoryNode<TParams extends MemoryNodeParams = MemoryNodeParams, TEv
|
|
|
48
45
|
})
|
|
49
46
|
}
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
return super.subscribeHandler()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
override async unregister(module: Module) {
|
|
48
|
+
override async unregister(module: ModuleInstance) {
|
|
56
49
|
await this.started('throw')
|
|
57
50
|
await this.detach(module.address)
|
|
58
51
|
delete this.registeredModuleMap[module.address]
|
|
@@ -76,7 +69,7 @@ export class MemoryNode<TParams extends MemoryNodeParams = MemoryNodeParams, TEv
|
|
|
76
69
|
|
|
77
70
|
const notifiedAddresses: string[] = []
|
|
78
71
|
|
|
79
|
-
const getModulesToNotifyAbout = async (node:
|
|
72
|
+
const getModulesToNotifyAbout = async (node: ModuleInstance) => {
|
|
80
73
|
//send attach events for all existing attached modules
|
|
81
74
|
const childModules = await node.resolve(undefined, { direction: 'down' })
|
|
82
75
|
return compact(
|
|
@@ -104,7 +97,7 @@ export class MemoryNode<TParams extends MemoryNodeParams = MemoryNodeParams, TEv
|
|
|
104
97
|
module.upResolver.addResolver?.(this.privateResolver)
|
|
105
98
|
|
|
106
99
|
//give it public access
|
|
107
|
-
module.upResolver.addResolver?.(this.downResolver)
|
|
100
|
+
module.upResolver.addResolver?.(this.downResolver as CompositeModuleResolver)
|
|
108
101
|
|
|
109
102
|
//give it outside access
|
|
110
103
|
module.upResolver.addResolver?.(this.upResolver)
|
|
@@ -175,7 +168,7 @@ export class MemoryNode<TParams extends MemoryNodeParams = MemoryNodeParams, TEv
|
|
|
175
168
|
//notify of all sub node children detach
|
|
176
169
|
const notifiedAddresses: string[] = []
|
|
177
170
|
if (isNodeModule(module)) {
|
|
178
|
-
const notifyOfExistingModules = async (node:
|
|
171
|
+
const notifyOfExistingModules = async (node: ModuleInstance) => {
|
|
179
172
|
//send attach events for all existing attached modules
|
|
180
173
|
const childModules = await node.resolve(undefined, { direction: 'down' })
|
|
181
174
|
await Promise.all(
|