@xyo-network/node-view 5.3.22 → 5.3.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/node-view",
3
- "version": "5.3.22",
3
+ "version": "5.3.25",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -30,43 +30,39 @@
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "files": [
32
32
  "dist",
33
- "src",
34
33
  "!**/*.bench.*",
35
34
  "!**/*.spec.*",
36
35
  "!**/*.test.*",
37
36
  "README.md"
38
37
  ],
39
38
  "dependencies": {
40
- "@xyo-network/module-model": "~5.3.22",
41
- "@xyo-network/module-resolver": "~5.3.22",
42
- "@xyo-network/node-memory": "~5.3.22",
43
- "@xyo-network/node-model": "~5.3.22",
44
- "@xyo-network/payload-model": "~5.3.22",
45
- "async-mutex": "~0.5.0"
39
+ "async-mutex": "~0.5.0",
40
+ "@xyo-network/module-model": "~5.3.25",
41
+ "@xyo-network/module-resolver": "~5.3.25",
42
+ "@xyo-network/node-memory": "~5.3.25",
43
+ "@xyo-network/payload-model": "~5.3.25",
44
+ "@xyo-network/node-model": "~5.3.25"
46
45
  },
47
46
  "devDependencies": {
48
47
  "@opentelemetry/api": "^1.9.1",
49
48
  "@types/node": "^25.5.0",
50
- "@xylabs/sdk-js": "^5.0.91",
51
- "@xylabs/ts-scripts-common": "~7.6.8",
52
- "@xylabs/ts-scripts-yarn3": "~7.6.8",
53
- "@xylabs/tsconfig": "~7.6.8",
54
- "@xyo-network/module-model": "~5.3.22",
55
- "@xyo-network/module-resolver": "~5.3.22",
56
- "@xyo-network/node-memory": "~5.3.22",
57
- "@xyo-network/node-model": "~5.3.22",
58
- "@xyo-network/payload-model": "~5.3.22",
49
+ "@xylabs/sdk-js": "^5.0.93",
50
+ "@xylabs/ts-scripts-common": "~7.6.16",
51
+ "@xylabs/ts-scripts-pnpm": "~7.6.16",
52
+ "@xylabs/tsconfig": "~7.6.16",
59
53
  "acorn": "^8.16.0",
60
54
  "async-mutex": "~0.5.0",
61
55
  "axios": "^1.14.0",
62
- "cosmiconfig": "^9.0.1",
63
- "esbuild": "^0.27.4",
64
- "eslint": "^10.1.0",
56
+ "esbuild": "^0.28.0",
65
57
  "ethers": "^6.16.0",
66
- "rollup": "^4.60.1",
67
58
  "tslib": "^2.8.1",
68
59
  "typescript": "~5.9.3",
69
- "zod": "^4.3.6"
60
+ "zod": "^4.3.6",
61
+ "@xyo-network/module-model": "~5.3.25",
62
+ "@xyo-network/module-resolver": "~5.3.25",
63
+ "@xyo-network/node-memory": "~5.3.25",
64
+ "@xyo-network/node-model": "~5.3.25",
65
+ "@xyo-network/payload-model": "~5.3.25"
70
66
  },
71
67
  "peerDependencies": {
72
68
  "@xylabs/sdk-js": "^5",
@@ -77,4 +73,4 @@
77
73
  "publishConfig": {
78
74
  "access": "public"
79
75
  }
80
- }
76
+ }
package/src/ViewNode.ts DELETED
@@ -1,154 +0,0 @@
1
- import type { Address, EventListener } from '@xylabs/sdk-js'
2
- import { assertEx } from '@xylabs/sdk-js'
3
- import type {
4
- AnyConfigSchema,
5
- ModuleFilterOptions,
6
- ModuleIdentifier,
7
- ModuleInstance,
8
- } from '@xyo-network/module-model'
9
- import { creatableModule, ModuleLimitationViewLabel } from '@xyo-network/module-model'
10
- import { SimpleModuleResolver } from '@xyo-network/module-resolver'
11
- import { MemoryNode, MemoryNodeHelper } from '@xyo-network/node-memory'
12
- import type {
13
- AttachableNodeInstance,
14
- NodeConfig,
15
- NodeModuleEventData,
16
- NodeParams,
17
- } from '@xyo-network/node-model'
18
- import {
19
- asNodeInstance,
20
- isNodeModule,
21
- NodeAttachQuerySchema,
22
- NodeDetachQuerySchema,
23
- NodeRegisteredQuerySchema,
24
- } from '@xyo-network/node-model'
25
- import { asSchema, type Schema } from '@xyo-network/payload-model'
26
- import { Mutex } from 'async-mutex'
27
-
28
- export const ViewNodeConfigSchema = asSchema('network.xyo.node.view.config', true)
29
- export type ViewNodeConfigSchema = typeof ViewNodeConfigSchema
30
-
31
- export type ViewNodeConfig = NodeConfig<
32
- {
33
- ids: ModuleIdentifier[]
34
- source: ModuleIdentifier
35
- },
36
- ViewNodeConfigSchema
37
- >
38
-
39
- export type ViewNodeParams = NodeParams<AnyConfigSchema<ViewNodeConfig>>
40
-
41
- @creatableModule()
42
- export class ViewNode<TParams extends ViewNodeParams = ViewNodeParams, TEventData extends NodeModuleEventData = NodeModuleEventData>
43
- extends MemoryNode<TParams, TEventData>
44
- implements AttachableNodeInstance<TParams, TEventData> {
45
- static override readonly configSchemas: Schema[] = [...super.configSchemas, ViewNodeConfigSchema]
46
- static override readonly defaultConfigSchema: Schema = ViewNodeConfigSchema
47
- static override readonly labels = { ...ModuleLimitationViewLabel }
48
-
49
- private _buildMutex = new Mutex()
50
- private _built = false
51
- private _limitedResolver = new SimpleModuleResolver({ root: this })
52
-
53
- get ids() {
54
- return this.config.ids
55
- }
56
-
57
- override get queries(): Schema[] {
58
- const disallowedQueries = new Set<Schema>([NodeAttachQuerySchema, NodeDetachQuerySchema, NodeRegisteredQuerySchema])
59
- const queries: Schema[] = [...super.queries]
60
- return queries.filter(query => !disallowedQueries.has(query))
61
- }
62
-
63
- get source() {
64
- return this.config.source
65
- }
66
-
67
- /** @deprecated do not pass undefined. If trying to get all, pass '*' */
68
- override async resolve(): Promise<ModuleInstance[]>
69
- override async resolve<T extends ModuleInstance = ModuleInstance>(all: '*', options?: ModuleFilterOptions<T>): Promise<T[]>
70
- override async resolve<T extends ModuleInstance = ModuleInstance>(id: ModuleIdentifier, options?: ModuleFilterOptions<T>): Promise<T | undefined>
71
- override async resolve<T extends ModuleInstance = ModuleInstance>(
72
- idOrFilter: ModuleIdentifier = '*',
73
- _options: ModuleFilterOptions<T> = {},
74
- ): Promise<T | T[] | undefined> {
75
- if (!this._built) {
76
- await this.build()
77
- }
78
- const mods = await this._limitedResolver.resolve('*')
79
- if (idOrFilter === '*') {
80
- return mods as unknown as T[]
81
- }
82
- switch (typeof idOrFilter) {
83
- case 'string': {
84
- const mod = mods.find(mod => mod.modName === idOrFilter || mod.address === idOrFilter)
85
- return mod as unknown as T
86
- }
87
- }
88
- }
89
-
90
- protected override async attachUsingAddress(address: Address) {
91
- const attached = await this.attached()
92
- const mods = this.registeredModules().filter(mod => attached.includes(mod.address))
93
- const existingModule = mods.find(mod => mod.address === address)
94
- if (existingModule) {
95
- this.logger?.warn(`ViewNode: Module [${existingModule?.modName ?? existingModule?.address}] already attached at address [${address}]`)
96
- }
97
- const mod = assertEx(this.registeredModuleMap[address], () => `Module [${address}] not found in registered mods`)
98
-
99
- mod.addParent(this)
100
-
101
- const args = { mod, name: mod.modName }
102
- await this.emit('moduleAttached', args)
103
-
104
- this._limitedResolver.add(mod)
105
-
106
- if (isNodeModule(mod)) {
107
- const attachedListener: EventListener<TEventData['moduleAttached']> = async (args: TEventData['moduleAttached']) =>
108
- await this.emit('moduleAttached', args)
109
-
110
- const detachedListener: EventListener<TEventData['moduleDetached']> = async (args: TEventData['moduleDetached']) =>
111
- await this.emit('moduleDetached', args)
112
-
113
- mod.on('moduleAttached', attachedListener)
114
- mod.on('moduleDetached', detachedListener)
115
- }
116
-
117
- return address
118
- }
119
-
120
- protected override async attachedPublicModules(): Promise<ModuleInstance[]> {
121
- return (await this._limitedResolver.resolve('*')).filter(mod => mod.address !== this.address)
122
- }
123
-
124
- protected override async detachUsingAddress(address: Address) {
125
- const mod = assertEx(await this.downResolver.resolve(address), () => `Module [${address}] not found in down resolver`)
126
- this._limitedResolver.remove(mod.address)
127
- return address
128
- }
129
-
130
- protected override async startHandler() {
131
- await super.startHandler()
132
- await this.build()
133
- }
134
-
135
- private async build() {
136
- if (this._buildMutex.isLocked()) {
137
- // throw new Error('ViewNode is already building, please wait for it to finish before calling build again')
138
- return
139
- }
140
- return await this._buildMutex.runExclusive(async () => {
141
- if (!this._built) {
142
- const source = this.source === undefined ? undefined : asNodeInstance(await super.resolve(this.source))
143
- if (source) {
144
- await Promise.all(
145
- this.ids?.map(async (id) => {
146
- await MemoryNodeHelper.attachToExistingNode(source, id, this)
147
- }) ?? [],
148
- )
149
- this._built = true
150
- }
151
- }
152
- })
153
- }
154
- }
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './ViewNode.ts'