@xyo-network/module-abstract 2.107.5 → 2.108.0
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/browser/AbstractModuleInstance.d.cts +2 -1
- package/dist/browser/AbstractModuleInstance.d.cts.map +1 -1
- package/dist/browser/AbstractModuleInstance.d.mts +2 -1
- package/dist/browser/AbstractModuleInstance.d.mts.map +1 -1
- package/dist/browser/AbstractModuleInstance.d.ts +2 -1
- package/dist/browser/AbstractModuleInstance.d.ts.map +1 -1
- package/dist/browser/index.cjs +49 -24
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +50 -25
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/AbstractModuleInstance.d.cts +2 -1
- package/dist/neutral/AbstractModuleInstance.d.cts.map +1 -1
- package/dist/neutral/AbstractModuleInstance.d.mts +2 -1
- package/dist/neutral/AbstractModuleInstance.d.mts.map +1 -1
- package/dist/neutral/AbstractModuleInstance.d.ts +2 -1
- package/dist/neutral/AbstractModuleInstance.d.ts.map +1 -1
- package/dist/neutral/index.cjs +49 -24
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +50 -25
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/AbstractModuleInstance.d.cts +2 -1
- package/dist/node/AbstractModuleInstance.d.cts.map +1 -1
- package/dist/node/AbstractModuleInstance.d.mts +2 -1
- package/dist/node/AbstractModuleInstance.d.mts.map +1 -1
- package/dist/node/AbstractModuleInstance.d.ts +2 -1
- package/dist/node/AbstractModuleInstance.d.ts.map +1 -1
- package/dist/node/index.cjs +49 -24
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +50 -25
- package/dist/node/index.js.map +1 -1
- package/package.json +30 -30
- package/src/AbstractModule.ts +3 -3
- package/src/AbstractModuleInstance.ts +52 -21
package/src/AbstractModule.ts
CHANGED
|
@@ -268,7 +268,7 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
268
268
|
async busy<R>(closure: () => Promise<R>) {
|
|
269
269
|
if (this._busyCount <= 0) {
|
|
270
270
|
this._busyCount = 0
|
|
271
|
-
const args: ModuleBusyEventArgs = { busy: true,
|
|
271
|
+
const args: ModuleBusyEventArgs = { busy: true, mod: this }
|
|
272
272
|
await this.emit('moduleBusy', args)
|
|
273
273
|
}
|
|
274
274
|
this._busyCount++
|
|
@@ -278,7 +278,7 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
278
278
|
this._busyCount--
|
|
279
279
|
if (this._busyCount <= 0) {
|
|
280
280
|
this._busyCount = 0
|
|
281
|
-
const args: ModuleBusyEventArgs = { busy: false,
|
|
281
|
+
const args: ModuleBusyEventArgs = { busy: false, mod: this }
|
|
282
282
|
await this.emit('moduleBusy', args)
|
|
283
283
|
}
|
|
284
284
|
}
|
|
@@ -339,7 +339,7 @@ export abstract class AbstractModule<TParams extends ModuleParams = ModuleParams
|
|
|
339
339
|
resultPayloads.push(timestamp)
|
|
340
340
|
}
|
|
341
341
|
const result = await this.bindQueryResult(sourceQuery, resultPayloads, queryAccount ? [queryAccount] : [], errorPayloads)
|
|
342
|
-
const args: ModuleQueriedEventArgs = {
|
|
342
|
+
const args: ModuleQueriedEventArgs = { mod: this, payloads, query: sourceQuery, result }
|
|
343
343
|
await this.emit('moduleQueried', args)
|
|
344
344
|
return result
|
|
345
345
|
})
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
AddressPreviousHashPayload,
|
|
12
12
|
AttachableModuleInstance,
|
|
13
13
|
duplicateModules,
|
|
14
|
+
isAddressModuleFilter,
|
|
15
|
+
isNameModuleFilter,
|
|
14
16
|
ModuleEventData,
|
|
15
17
|
ModuleFilter,
|
|
16
18
|
ModuleFilterOptions,
|
|
@@ -25,8 +27,11 @@ import {
|
|
|
25
27
|
ModuleStateQuery,
|
|
26
28
|
ModuleStateQuerySchema,
|
|
27
29
|
ObjectFilterOptions,
|
|
30
|
+
resolveAddressToInstance,
|
|
28
31
|
ResolveHelper,
|
|
29
32
|
ResolveHelperConfig,
|
|
33
|
+
resolveLocalNameToInstance,
|
|
34
|
+
resolvePathToInstance,
|
|
30
35
|
} from '@xyo-network/module-model'
|
|
31
36
|
import { CompositeModuleResolver } from '@xyo-network/module-resolver'
|
|
32
37
|
import { asNodeInstance, NodeInstance } from '@xyo-network/node-model'
|
|
@@ -40,6 +45,9 @@ export abstract class AbstractModuleInstance<TParams extends ModuleParams = Modu
|
|
|
40
45
|
{
|
|
41
46
|
static override readonly uniqueName = globallyUnique('AbstractModuleInstance', AbstractModuleInstance, 'xyo')
|
|
42
47
|
|
|
48
|
+
//switches between old and new resolution system
|
|
49
|
+
static readonly useNewResolver = false
|
|
50
|
+
|
|
43
51
|
private _downResolver?: CompositeModuleResolver
|
|
44
52
|
private _parents: NodeInstance[] = []
|
|
45
53
|
private _privateResolver?: CompositeModuleResolver
|
|
@@ -102,10 +110,10 @@ export abstract class AbstractModuleInstance<TParams extends ModuleParams = Modu
|
|
|
102
110
|
return this._upResolver
|
|
103
111
|
}
|
|
104
112
|
|
|
105
|
-
addParent(
|
|
106
|
-
const existingEntry = this._parents.find((parent) => parent.address ===
|
|
113
|
+
addParent(mod: ModuleInstance) {
|
|
114
|
+
const existingEntry = this._parents.find((parent) => parent.address === mod.address)
|
|
107
115
|
if (!existingEntry) {
|
|
108
|
-
this._parents.push(asNodeInstance(
|
|
116
|
+
this._parents.push(asNodeInstance(mod, 'Only NodeInstances can be parents'))
|
|
109
117
|
}
|
|
110
118
|
}
|
|
111
119
|
|
|
@@ -167,28 +175,51 @@ export abstract class AbstractModuleInstance<TParams extends ModuleParams = Modu
|
|
|
167
175
|
idOrFilter: ModuleFilter<T> | ModuleIdentifier = '*',
|
|
168
176
|
options: ModuleFilterOptions<T> = {},
|
|
169
177
|
): Promise<T | T[] | undefined> {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
downResolver: this.downResolver,
|
|
174
|
-
logger: this.logger,
|
|
175
|
-
module: this,
|
|
176
|
-
transformers: this.moduleIdentifierTransformers,
|
|
177
|
-
upResolver: this.upResolver,
|
|
178
|
-
}
|
|
179
|
-
if (idOrFilter === '*') {
|
|
180
|
-
return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address)
|
|
181
|
-
}
|
|
182
|
-
switch (typeof idOrFilter) {
|
|
183
|
-
case 'string': {
|
|
184
|
-
return await ResolveHelper.resolve(config, idOrFilter, options)
|
|
178
|
+
if (AbstractModuleInstance.useNewResolver) {
|
|
179
|
+
if (idOrFilter === '*') {
|
|
180
|
+
return (await this.publicChildren()) as T[]
|
|
185
181
|
}
|
|
186
|
-
|
|
187
|
-
|
|
182
|
+
switch (typeof idOrFilter) {
|
|
183
|
+
case 'string': {
|
|
184
|
+
return (await resolvePathToInstance(this, idOrFilter)) as T | undefined
|
|
185
|
+
}
|
|
186
|
+
case 'object': {
|
|
187
|
+
if (isNameModuleFilter(idOrFilter)) {
|
|
188
|
+
return (await Promise.all(idOrFilter.name.map(async (name) => await resolveLocalNameToInstance(this, name)))) as T[]
|
|
189
|
+
}
|
|
190
|
+
if (isAddressModuleFilter(idOrFilter)) {
|
|
191
|
+
return (await Promise.all(idOrFilter.address.map(async (address) => await resolveAddressToInstance(this, address)))) as T[]
|
|
192
|
+
}
|
|
193
|
+
throw new Error('Invalid filter type')
|
|
194
|
+
}
|
|
195
|
+
default: {
|
|
196
|
+
return (await this.publicChildren()) as T[]
|
|
197
|
+
}
|
|
188
198
|
}
|
|
189
|
-
|
|
199
|
+
} else {
|
|
200
|
+
const config: ResolveHelperConfig = {
|
|
201
|
+
address: this.address,
|
|
202
|
+
dead: this.dead,
|
|
203
|
+
downResolver: this.downResolver,
|
|
204
|
+
logger: this.logger,
|
|
205
|
+
mod: this,
|
|
206
|
+
transformers: this.moduleIdentifierTransformers,
|
|
207
|
+
upResolver: this.upResolver,
|
|
208
|
+
}
|
|
209
|
+
if (idOrFilter === '*') {
|
|
190
210
|
return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address)
|
|
191
211
|
}
|
|
212
|
+
switch (typeof idOrFilter) {
|
|
213
|
+
case 'string': {
|
|
214
|
+
return await ResolveHelper.resolve(config, idOrFilter, options)
|
|
215
|
+
}
|
|
216
|
+
case 'object': {
|
|
217
|
+
return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address)
|
|
218
|
+
}
|
|
219
|
+
default: {
|
|
220
|
+
return (await ResolveHelper.resolve(config, idOrFilter, options)).filter((mod) => mod.address !== this.address)
|
|
221
|
+
}
|
|
222
|
+
}
|
|
192
223
|
}
|
|
193
224
|
}
|
|
194
225
|
|