@ddd-qc/agent-directory 1.165.3 → 2.165.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/README.md +3 -3
- package/dist/ZomeViewModel.d.ts +22 -0
- package/dist/ZomeViewModel.js +49 -0
- package/dist/ZomeViewModel.js.map +1 -0
- package/dist/agent_directory.bridge.d.ts +5 -9
- package/dist/agent_directory.bridge.js +4 -22
- package/dist/agent_directory.bridge.js.map +1 -1
- package/dist/agent_directory.vm.d.ts +13 -15
- package/dist/agent_directory.vm.js +23 -27
- package/dist/agent_directory.vm.js.map +1 -1
- package/dist/agent_directory.zome.d.ts +13 -0
- package/dist/agent_directory.zome.js +15 -0
- package/dist/agent_directory.zome.js.map +1 -0
- package/dist/elements/agent-directory-list.d.ts +3 -2
- package/dist/elements/agent-directory-list.js +13 -10
- package/dist/elements/agent-directory-list.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
@@ -6,9 +6,9 @@ A holochain zome module that registers agents to a known directory path on agent
|
|
6
6
|
# API
|
7
7
|
|
8
8
|
## ViewModel
|
9
|
-
- `subscribe(
|
10
|
-
- `pullAllFromDht()`: Check the DHT for any kind of new data
|
11
|
-
- `pullAllRegisteredAgents()`: Check the DHT for new registered agents
|
9
|
+
- `subscribe(fn)`: Host can provide a function to be called when data store has been updated.
|
10
|
+
- `pullAllFromDht()`: Check the DHT for any kind of new data.
|
11
|
+
- `pullAllRegisteredAgents()`: Check the DHT for new registered agents.
|
12
12
|
- `agents()`: Getter for the list of registered agents.
|
13
13
|
|
14
14
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* Represents the ViewModel of a zome.
|
3
|
+
* It is an Observable meant to be a singleton passed around with a LitContext.
|
4
|
+
* It queries a cell's zome to get the agent's perspective (by callind a Zome Bridge).
|
5
|
+
* LitElement hosts can subscribe to it in order to get updated when the perspective changes.
|
6
|
+
* Hosts can also trigger probing in order to get an updated perspective.
|
7
|
+
* It is expected from child classes to implement the ZomeViewModelInterface.
|
8
|
+
*/
|
9
|
+
export declare class ZomeViewModel<T extends {}> {
|
10
|
+
/** Dummy implementation ZomeViewModelInterface */
|
11
|
+
get perspective(): T;
|
12
|
+
protected hasChanged(): boolean;
|
13
|
+
probeDht(): Promise<void>;
|
14
|
+
protected _previousPerspective?: any;
|
15
|
+
protected _hosts: [any, PropertyKey][];
|
16
|
+
/** */
|
17
|
+
subscribe(host: any, propName: PropertyKey): void;
|
18
|
+
/** */
|
19
|
+
unsubscribe(candidat: any): void;
|
20
|
+
/** */
|
21
|
+
protected notify(): void;
|
22
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
// export interface ZomeViewModelInterface<T extends {}> {
|
2
|
+
// hasChanged(): boolean;
|
3
|
+
// get perspective(): T | {};
|
4
|
+
// probeDht(): Promise<void>;
|
5
|
+
// }
|
6
|
+
/**
|
7
|
+
* Represents the ViewModel of a zome.
|
8
|
+
* It is an Observable meant to be a singleton passed around with a LitContext.
|
9
|
+
* It queries a cell's zome to get the agent's perspective (by callind a Zome Bridge).
|
10
|
+
* LitElement hosts can subscribe to it in order to get updated when the perspective changes.
|
11
|
+
* Hosts can also trigger probing in order to get an updated perspective.
|
12
|
+
* It is expected from child classes to implement the ZomeViewModelInterface.
|
13
|
+
*/
|
14
|
+
export class ZomeViewModel {
|
15
|
+
constructor() {
|
16
|
+
this._hosts = [];
|
17
|
+
}
|
18
|
+
/** Dummy implementation ZomeViewModelInterface */
|
19
|
+
get perspective() { return {}; }
|
20
|
+
hasChanged() { return true; }
|
21
|
+
async probeDht() { }
|
22
|
+
/** */
|
23
|
+
subscribe(host, propName) {
|
24
|
+
host[propName] = this.perspective;
|
25
|
+
this._hosts.push([host, propName]);
|
26
|
+
}
|
27
|
+
/** */
|
28
|
+
unsubscribe(candidat) {
|
29
|
+
let index = 0;
|
30
|
+
for (const [host, _propName] of this._hosts) {
|
31
|
+
if (host === candidat)
|
32
|
+
break;
|
33
|
+
index += 1;
|
34
|
+
}
|
35
|
+
if (index > -1) {
|
36
|
+
this._hosts.splice(index, 1);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
/** */
|
40
|
+
notify() {
|
41
|
+
if (!this.hasChanged())
|
42
|
+
return;
|
43
|
+
for (const [host, propName] of this._hosts) {
|
44
|
+
host[propName] = this.perspective;
|
45
|
+
}
|
46
|
+
this._previousPerspective = this.perspective;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
//# sourceMappingURL=ZomeViewModel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ZomeViewModel.js","sourceRoot":"","sources":["../src/ZomeViewModel.ts"],"names":[],"mappings":"AAGA,0DAA0D;AAC1D,6BAA6B;AAC7B,iCAAiC;AACjC,iCAAiC;AACjC,IAAI;AAGJ;;;;;;;GAOG;AACH,MAAM,OAAO,aAAa;IAA1B;QAQc,WAAM,GAAyB,EAAE,CAAC;IA+BhD,CAAC;IArCG,kDAAkD;IAClD,IAAI,WAAW,KAAQ,OAAO,EAAO,CAAA,CAAC,CAAC;IAC7B,UAAU,KAAc,OAAO,IAAI,CAAA,CAAC,CAAC;IAC/C,KAAK,CAAC,QAAQ,KAAmB,CAAC;IAMlC,MAAM;IACN,SAAS,CAAC,IAAS,EAAE,QAAqB;QACtC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAA;IACtC,CAAC;IAGD,MAAM;IACN,WAAW,CAAC,QAAa;QACrB,IAAI,KAAK,GAAI,CAAC,CAAC;QACf,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;YACzC,IAAI,IAAI,KAAK,QAAQ;gBAAE,MAAM;YAC7B,KAAK,IAAI,CAAC,CAAC;SACd;QACD,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACZ,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAChC;IACL,CAAC;IAGD,MAAM;IACI,MAAM;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,OAAO;QAC/B,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;YACxC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;SACrC;QACD,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAA;IAChD,CAAC;CACJ","sourcesContent":["\r\n\r\n\r\n// export interface ZomeViewModelInterface<T extends {}> {\r\n// hasChanged(): boolean;\r\n// get perspective(): T | {};\r\n// probeDht(): Promise<void>;\r\n// }\r\n\r\n\r\n/**\r\n * Represents the ViewModel of a zome.\r\n * It is an Observable meant to be a singleton passed around with a LitContext.\r\n * It queries a cell's zome to get the agent's perspective (by callind a Zome Bridge).\r\n * LitElement hosts can subscribe to it in order to get updated when the perspective changes.\r\n * Hosts can also trigger probing in order to get an updated perspective.\r\n * It is expected from child classes to implement the ZomeViewModelInterface.\r\n */\r\nexport class ZomeViewModel<T extends {}> /*implements ZomeViewModelInterface<T>*/ {\r\n\r\n /** Dummy implementation ZomeViewModelInterface */\r\n get perspective(): T { return {} as T }\r\n protected hasChanged(): boolean { return true }\r\n async probeDht(): Promise<void> {}\r\n\r\n protected _previousPerspective?: any;\r\n protected _hosts: [any, PropertyKey][] = [];\r\n\r\n\r\n /** */\r\n subscribe(host: any, propName: PropertyKey) {\r\n host[propName] = this.perspective;\r\n this._hosts.push([host, propName])\r\n }\r\n\r\n\r\n /** */\r\n unsubscribe(candidat: any) {\r\n let index = 0;\r\n for (const [host, _propName] of this._hosts) {\r\n if (host === candidat) break;\r\n index += 1;\r\n }\r\n if (index > -1) {\r\n this._hosts.splice(index, 1);\r\n }\r\n }\r\n\r\n\r\n /** */\r\n protected notify() {\r\n if (!this.hasChanged()) return;\r\n for (const [host, propName] of this._hosts) {\r\n host[propName] = this.perspective;\r\n }\r\n this._previousPerspective = this.perspective\r\n }\r\n}"]}
|
@@ -1,17 +1,13 @@
|
|
1
|
-
import { AgentPubKey
|
2
|
-
import {
|
1
|
+
import { AgentPubKey } from "@holochain/client";
|
2
|
+
import { DnaClient } from "@ddd-qc/dna-client";
|
3
3
|
/**
|
4
4
|
*
|
5
5
|
*/
|
6
6
|
export declare class AgentDirectoryBridge {
|
7
|
-
|
8
|
-
cellId: CellId;
|
7
|
+
protected dnaClient: DnaClient;
|
9
8
|
/** Ctor */
|
10
|
-
constructor(
|
11
|
-
|
9
|
+
constructor(dnaClient: DnaClient);
|
10
|
+
private _zomeName;
|
12
11
|
/** Zome API */
|
13
12
|
getAllAgents(): Promise<AgentPubKey[]>;
|
14
|
-
/** Private */
|
15
|
-
/** */
|
16
|
-
private callZome;
|
17
13
|
}
|
@@ -3,31 +3,13 @@
|
|
3
3
|
*/
|
4
4
|
export class AgentDirectoryBridge {
|
5
5
|
/** Ctor */
|
6
|
-
constructor(
|
7
|
-
this.
|
8
|
-
this.
|
9
|
-
this.defaultTimeout = defaultTimeout ? defaultTimeout : 10 * 1000;
|
6
|
+
constructor(dnaClient) {
|
7
|
+
this.dnaClient = dnaClient;
|
8
|
+
this._zomeName = 'agent_directory';
|
10
9
|
}
|
11
10
|
/** Zome API */
|
12
11
|
async getAllAgents() {
|
13
|
-
return this.callZome('get_registered_agents', null);
|
14
|
-
}
|
15
|
-
/** Private */
|
16
|
-
/** */
|
17
|
-
callZome(fn_name, payload) {
|
18
|
-
//console.log("callZome: agent_directory." + fn_name + "() ", payload)
|
19
|
-
//console.info({payload})
|
20
|
-
try {
|
21
|
-
const result = this.agnosticClient.callZome(this.cellId, "agent_directory", fn_name, payload, this.defaultTimeout);
|
22
|
-
//console.log("callZome: agent_directory." + fn_name + "() result")
|
23
|
-
//console.info({result})
|
24
|
-
return result;
|
25
|
-
}
|
26
|
-
catch (e) {
|
27
|
-
console.error("Calling zome agent_directory." + fn_name + "() failed: ");
|
28
|
-
console.error({ e });
|
29
|
-
}
|
30
|
-
return Promise.reject("callZome failed");
|
12
|
+
return this.dnaClient.callZome(this._zomeName, 'get_registered_agents', null);
|
31
13
|
}
|
32
14
|
}
|
33
15
|
//# sourceMappingURL=agent_directory.bridge.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"agent_directory.bridge.js","sourceRoot":"","sources":["../src/agent_directory.bridge.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC/B,WAAW;IACX,
|
1
|
+
{"version":3,"file":"agent_directory.bridge.js","sourceRoot":"","sources":["../src/agent_directory.bridge.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC/B,WAAW;IACX,YAAsB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QAElC,cAAS,GAAG,iBAAiB,CAAC;IAFM,CAAC;IAI7C,eAAe;IAEf,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAG,uBAAuB,EAAE,IAAI,CAAC,CAAC;IACjF,CAAC;CACF","sourcesContent":["import {AgentPubKey} from \"@holochain/client\";\nimport {DnaClient} from \"@ddd-qc/dna-client\";\n\n\n/**\n *\n */\nexport class AgentDirectoryBridge {\n /** Ctor */\n constructor(protected dnaClient: DnaClient){}\n\n private _zomeName = 'agent_directory';\n\n /** Zome API */\n\n async getAllAgents(): Promise<AgentPubKey[]> {\n return this.dnaClient.callZome(this._zomeName, 'get_registered_agents', null);\n }\n}\n"]}
|
@@ -1,31 +1,29 @@
|
|
1
|
-
import { LitElement } from "lit";
|
2
|
-
import { CellId } from "@holochain/client";
|
3
1
|
import { AgentPubKeyB64 } from '@holochain-open-dev/core-types';
|
4
|
-
import {
|
2
|
+
import { DnaClient, ZomeViewModel } from "@ddd-qc/dna-client";
|
5
3
|
/** Global Context */
|
6
4
|
export declare const agentDirectoryContext: {
|
7
5
|
__context__: AgentDirectoryViewModel;
|
8
6
|
};
|
7
|
+
/** */
|
8
|
+
export interface AgentDirectoryPerspective {
|
9
|
+
agents: AgentPubKeyB64[];
|
10
|
+
}
|
9
11
|
/**
|
10
12
|
*
|
11
13
|
*/
|
12
|
-
export declare class AgentDirectoryViewModel {
|
13
|
-
protected
|
14
|
+
export declare class AgentDirectoryViewModel extends ZomeViewModel<AgentDirectoryPerspective> {
|
15
|
+
protected dnaClient: DnaClient;
|
14
16
|
/** Ctor */
|
15
|
-
constructor(
|
17
|
+
constructor(dnaClient: DnaClient);
|
16
18
|
/** -- Fields -- */
|
17
|
-
/** Private */
|
18
19
|
private _bridge;
|
19
|
-
private
|
20
|
-
/** Public */
|
21
|
-
myAgentPubKey: AgentPubKeyB64;
|
20
|
+
private _agents;
|
22
21
|
/** -- Methods -- */
|
22
|
+
get perspective(): AgentDirectoryPerspective;
|
23
23
|
/** */
|
24
|
-
|
25
|
-
/** */
|
26
|
-
subscribe(parent: LitElement): void;
|
24
|
+
protected hasChanged(): boolean;
|
27
25
|
/** */
|
28
|
-
|
26
|
+
probeDht(): Promise<void>;
|
29
27
|
/** */
|
30
|
-
|
28
|
+
probeRegisteredAgents(): Promise<void>;
|
31
29
|
}
|
@@ -1,47 +1,43 @@
|
|
1
1
|
import { createContext } from "@lit-labs/context";
|
2
|
-
import { writable, get } from "svelte/store";
|
3
2
|
import { serializeHash } from "@holochain-open-dev/utils";
|
4
3
|
import { AgentDirectoryBridge } from "./agent_directory.bridge";
|
4
|
+
import { ZomeViewModel } from "@ddd-qc/dna-client";
|
5
5
|
/** Global Context */
|
6
|
-
export const agentDirectoryContext = createContext('agent_directory
|
6
|
+
export const agentDirectoryContext = createContext('zome_view_model/agent_directory');
|
7
7
|
/**
|
8
8
|
*
|
9
9
|
*/
|
10
|
-
export class AgentDirectoryViewModel {
|
10
|
+
export class AgentDirectoryViewModel extends ZomeViewModel {
|
11
11
|
/** Ctor */
|
12
|
-
constructor(
|
13
|
-
|
14
|
-
|
15
|
-
this.
|
16
|
-
this._bridge = new AgentDirectoryBridge(
|
17
|
-
this.myAgentPubKey = serializeHash(cellId[1]);
|
18
|
-
// this.bridge.getProperties().then((properties) => {
|
19
|
-
// this.latestBucketIndex = Math.floor(properties.startTime / properties.bucketSizeSec) - 1;
|
20
|
-
// });
|
12
|
+
constructor(dnaClient) {
|
13
|
+
super();
|
14
|
+
this.dnaClient = dnaClient;
|
15
|
+
this._agents = [];
|
16
|
+
this._bridge = new AgentDirectoryBridge(dnaClient);
|
21
17
|
}
|
22
18
|
/** -- Methods -- */
|
23
|
-
|
24
|
-
|
25
|
-
return
|
19
|
+
/* */
|
20
|
+
get perspective() {
|
21
|
+
return { agents: this._agents };
|
26
22
|
}
|
27
23
|
/** */
|
28
|
-
|
29
|
-
this.
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
hasChanged() {
|
25
|
+
if (!this._previousPerspective)
|
26
|
+
return true;
|
27
|
+
let hasChanged = JSON.stringify(this.perspective.agents) !== JSON.stringify(this._previousPerspective.agents);
|
28
|
+
return hasChanged;
|
33
29
|
}
|
34
30
|
/** */
|
35
|
-
async
|
36
|
-
await this.
|
31
|
+
async probeDht() {
|
32
|
+
await this.probeRegisteredAgents();
|
37
33
|
}
|
38
34
|
/** */
|
39
|
-
async
|
35
|
+
async probeRegisteredAgents() {
|
40
36
|
let agents = await this._bridge.getAllAgents();
|
41
|
-
this.
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
this._agents = agents.map((agentKey) => serializeHash(agentKey));
|
38
|
+
// Debug add a random string to the perspective
|
39
|
+
// this._agents.push(String.fromCharCode("A".charCodeAt(0) + Math.floor(Math.random() * 26)))
|
40
|
+
this.notify();
|
45
41
|
}
|
46
42
|
}
|
47
43
|
//# sourceMappingURL=agent_directory.vm.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"agent_directory.vm.js","sourceRoot":"","sources":["../src/agent_directory.vm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,
|
1
|
+
{"version":3,"file":"agent_directory.vm.js","sourceRoot":"","sources":["../src/agent_directory.vm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAY,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAE5D,qBAAqB;AACrB,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAA0B,iCAAiC,CAAC,CAAC;AAU/G;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAAwC;IACnF,WAAW;IACX,YAAsB,SAAoB;QACxC,KAAK,EAAE,CAAC;QADY,cAAS,GAAT,SAAS,CAAW;QAQlC,YAAO,GAAqB,EAAE,CAAC;QANrC,IAAI,CAAC,OAAO,GAAG,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAQD,oBAAoB;IAEpB,KAAK;IACL,IAAI,WAAW;QACb,OAAO,EAAC,MAAM,EAAE,IAAI,CAAC,OAAO,EAAC,CAAA;IAC/B,CAAC;IAGD,MAAM;IACI,UAAU;QAClB,IAAI,CAAC,IAAI,CAAC,oBAAoB;YAAE,OAAO,IAAI,CAAC;QAC5C,IAAI,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAA;QAC7G,OAAO,UAAU,CAAA;IACnB,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,QAAQ;QACZ,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAA;IACpC,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,qBAAqB;QACzB,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjE,+CAA+C;QAC/C,6FAA6F;QAC7F,IAAI,CAAC,MAAM,EAAE,CAAA;IACf,CAAC;CAEF","sourcesContent":["import {createContext} from \"@lit-labs/context\";\nimport {AgentPubKeyB64} from '@holochain-open-dev/core-types';\nimport {serializeHash} from \"@holochain-open-dev/utils\";\n\nimport {AgentDirectoryBridge} from \"./agent_directory.bridge\";\nimport {DnaClient, ZomeViewModel} from \"@ddd-qc/dna-client\";\n\n/** Global Context */\nexport const agentDirectoryContext = createContext<AgentDirectoryViewModel>('zome_view_model/agent_directory');\n\n\n/** */\nexport interface AgentDirectoryPerspective {\n agents: AgentPubKeyB64[],\n}\n\n\n\n/**\n *\n */\nexport class AgentDirectoryViewModel extends ZomeViewModel<AgentDirectoryPerspective> {\n /** Ctor */\n constructor(protected dnaClient: DnaClient) {\n super();\n this._bridge = new AgentDirectoryBridge(dnaClient);\n }\n\n /** -- Fields -- */\n\n private _bridge : AgentDirectoryBridge\n private _agents: AgentPubKeyB64[] = [];\n\n\n /** -- Methods -- */\n\n /* */\n get perspective(): AgentDirectoryPerspective {\n return {agents: this._agents}\n }\n\n\n /** */\n protected hasChanged(): boolean {\n if (!this._previousPerspective) return true;\n let hasChanged = JSON.stringify(this.perspective.agents) !== JSON.stringify(this._previousPerspective.agents)\n return hasChanged\n }\n\n\n /** */\n async probeDht(): Promise<void> {\n await this.probeRegisteredAgents()\n }\n\n\n /** */\n async probeRegisteredAgents() {\n let agents = await this._bridge.getAllAgents();\n this._agents = agents.map((agentKey) => serializeHash(agentKey));\n // Debug add a random string to the perspective\n // this._agents.push(String.fromCharCode(\"A\".charCodeAt(0) + Math.floor(Math.random() * 26)))\n this.notify()\n }\n\n}\n"]}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { AgentPubKey } from "@holochain/client";
|
2
|
+
import { DnaClient } from "@ddd-qc/dna-client";
|
3
|
+
/**
|
4
|
+
*
|
5
|
+
*/
|
6
|
+
export declare class AgentDirectoryBridge {
|
7
|
+
dnaClient: DnaClient;
|
8
|
+
/** Ctor */
|
9
|
+
constructor(dnaClient: DnaClient);
|
10
|
+
private _zomeName;
|
11
|
+
/** Zome API */
|
12
|
+
getAllAgents(): Promise<AgentPubKey[]>;
|
13
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
*/
|
4
|
+
export class AgentDirectoryBridge {
|
5
|
+
/** Ctor */
|
6
|
+
constructor(dnaClient) {
|
7
|
+
this.dnaClient = dnaClient;
|
8
|
+
this._zomeName = 'agent_directory';
|
9
|
+
}
|
10
|
+
/** Zome API */
|
11
|
+
async getAllAgents() {
|
12
|
+
return this.dnaClient.callZome(this._zomeName, 'get_registered_agents', null);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=agent_directory.zome.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"agent_directory.zome.js","sourceRoot":"","sources":["../src/agent_directory.zome.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC/B,WAAW;IACX,YAAmB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;QAE/B,cAAS,GAAG,iBAAiB,CAAC;IAFG,CAAC;IAI1C,eAAe;IAEf,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAG,uBAAuB,EAAE,IAAI,CAAC,CAAC;IACjF,CAAC;CACF","sourcesContent":["import {AgentPubKey} from \"@holochain/client\";\nimport {DnaClient} from \"@ddd-qc/dna-client\";\n\n\n/**\n *\n */\nexport class AgentDirectoryBridge {\n /** Ctor */\n constructor(public dnaClient: DnaClient){}\n\n private _zomeName = 'agent_directory';\n\n /** Zome API */\n\n async getAllAgents(): Promise<AgentPubKey[]> {\n return this.dnaClient.callZome(this._zomeName, 'get_registered_agents', null);\n }\n}\n"]}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { LitElement } from "lit";
|
2
|
-
import { AgentDirectoryViewModel } from "../agent_directory.vm";
|
2
|
+
import { AgentDirectoryPerspective, AgentDirectoryViewModel } from "../agent_directory.vm";
|
3
3
|
declare const AgentDirectoryList_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
4
4
|
/**
|
5
5
|
* @element agent-directory-list
|
@@ -8,8 +8,9 @@ export declare class AgentDirectoryList extends AgentDirectoryList_base {
|
|
8
8
|
/** Ctor */
|
9
9
|
constructor();
|
10
10
|
/** -- Fields -- */
|
11
|
-
|
11
|
+
private _initialized;
|
12
12
|
_viewModel: AgentDirectoryViewModel;
|
13
|
+
perspective: AgentDirectoryPerspective;
|
13
14
|
/** -- Methods -- */
|
14
15
|
/** After first call to render() */
|
15
16
|
firstUpdated(): Promise<void>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { __decorate } from "tslib";
|
2
2
|
import { html, LitElement } from "lit";
|
3
|
-
import { state } from "lit/decorators.js";
|
3
|
+
import { property, state } from "lit/decorators.js";
|
4
4
|
import { contextProvided } from '@lit-labs/context';
|
5
5
|
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
6
6
|
import { agentDirectoryContext } from "../agent_directory.vm";
|
@@ -12,14 +12,14 @@ export class AgentDirectoryList extends ScopedElementsMixin(LitElement) {
|
|
12
12
|
constructor() {
|
13
13
|
super();
|
14
14
|
/** -- Fields -- */
|
15
|
-
this.
|
15
|
+
this._initialized = false;
|
16
16
|
}
|
17
17
|
/** -- Methods -- */
|
18
18
|
/** After first call to render() */
|
19
19
|
async firstUpdated() {
|
20
|
-
this._viewModel.subscribe(this);
|
20
|
+
this._viewModel.subscribe(this, 'perspective');
|
21
21
|
await this.refresh();
|
22
|
-
this.
|
22
|
+
this._initialized = true;
|
23
23
|
}
|
24
24
|
/** After each call to render() */
|
25
25
|
async updated(changedProperties) {
|
@@ -28,17 +28,16 @@ export class AgentDirectoryList extends ScopedElementsMixin(LitElement) {
|
|
28
28
|
/** */
|
29
29
|
async refresh(_e) {
|
30
30
|
//console.log("refresh(): Pulling data from DHT")
|
31
|
-
await this._viewModel.
|
31
|
+
await this._viewModel.probeDht();
|
32
32
|
}
|
33
33
|
/** */
|
34
34
|
render() {
|
35
35
|
console.log("agent-directory-list render() START");
|
36
|
-
if (!this.
|
36
|
+
if (!this._initialized) {
|
37
37
|
return html `<span>Loading...</span>`;
|
38
38
|
}
|
39
|
-
let agents = this._viewModel.agents();
|
40
39
|
/* Agents */
|
41
|
-
const agentLi = Object.entries(agents).map(([_index, agentIdB64]) => {
|
40
|
+
const agentLi = Object.entries(this.perspective.agents).map(([_index, agentIdB64]) => {
|
42
41
|
//console.log("" + index + ". " + agentIdB64)
|
43
42
|
return html `<li value="${agentIdB64}">${agentIdB64}</li>`;
|
44
43
|
});
|
@@ -52,8 +51,12 @@ export class AgentDirectoryList extends ScopedElementsMixin(LitElement) {
|
|
52
51
|
}
|
53
52
|
__decorate([
|
54
53
|
state()
|
55
|
-
], AgentDirectoryList.prototype, "
|
54
|
+
], AgentDirectoryList.prototype, "_initialized", void 0);
|
56
55
|
__decorate([
|
57
|
-
contextProvided({ context: agentDirectoryContext })
|
56
|
+
contextProvided({ context: agentDirectoryContext, subscribe: true }),
|
57
|
+
property({ type: Object, attribute: false })
|
58
58
|
], AgentDirectoryList.prototype, "_viewModel", void 0);
|
59
|
+
__decorate([
|
60
|
+
property({ type: Object, attribute: false, hasChanged: (_v, _old) => true })
|
61
|
+
], AgentDirectoryList.prototype, "perspective", void 0);
|
59
62
|
//# sourceMappingURL=agent-directory-list.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"agent-directory-list.js","sourceRoot":"","sources":["../../src/elements/agent-directory-list.ts"],"names":[],"mappings":";AAAA,OAAO,
|
1
|
+
{"version":3,"file":"agent-directory-list.js","sourceRoot":"","sources":["../../src/elements/agent-directory-list.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,qBAAqB,EAAqD,MAAM,uBAAuB,CAAC;AAGhH;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,mBAAmB,CAAC,UAAU,CAAC;IACrE,WAAW;IACX;QACE,KAAK,EAAE,CAAC;QAIV,mBAAmB;QAEF,iBAAY,GAAG,KAAK,CAAC;IALtC,CAAC;IAgBD,oBAAoB;IAEpB,mCAAmC;IACnC,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;QAC/C,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAGD,kCAAkC;IAClC,KAAK,CAAC,OAAO,CAAC,iBAAsB;QAClC,MAAM;IACR,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,OAAO,CAAC,EAAQ;QACpB,iDAAiD;QACjD,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;IAGD,MAAM;IACN,MAAM;QACJ,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QAEnD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,OAAO,IAAI,CAAA,yBAAyB,CAAC;SACtC;QAED,YAAY;QACZ,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,CACvD,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,EAAE;YACvB,6CAA6C;YAC7C,OAAO,IAAI,CAAC,cAAc,UAAU,KAAK,UAAU,OAAO,CAAA;QAC5D,CAAC,CACJ,CAAA;QAED,iBAAiB;QACjB,OAAO,IAAI,CAAA;;YAEH,OAAO;;KAEd,CAAC;IACJ,CAAC;CACF;AAzDU;IAAR,KAAK,EAAE;wDAA8B;AAItC;IAFC,eAAe,CAAC,EAAE,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACpE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;sDACR;AAIrC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAC,CAAC;uDACnC","sourcesContent":["import {html, LitElement} from \"lit\";\nimport {property, state} from \"lit/decorators.js\";\nimport { contextProvided } from '@lit-labs/context';\nimport {ScopedElementsMixin} from \"@open-wc/scoped-elements\";\nimport {agentDirectoryContext, AgentDirectoryPerspective, AgentDirectoryViewModel} from \"../agent_directory.vm\";\n\n\n/**\n * @element agent-directory-list\n */\nexport class AgentDirectoryList extends ScopedElementsMixin(LitElement) {\n /** Ctor */\n constructor() {\n super();\n }\n\n\n /** -- Fields -- */\n\n @state() private _initialized = false;\n\n @contextProvided({ context: agentDirectoryContext, subscribe: true })\n @property({ type: Object, attribute: false })\n _viewModel!: AgentDirectoryViewModel; // WARN: is actually undefined at startup\n\n\n @property({type: Object, attribute: false, hasChanged: (_v, _old) => true})\n perspective!: AgentDirectoryPerspective;\n\n\n /** -- Methods -- */\n\n /** After first call to render() */\n async firstUpdated() {\n this._viewModel.subscribe(this, 'perspective');\n await this.refresh();\n this._initialized = true;\n }\n\n\n /** After each call to render() */\n async updated(changedProperties: any) {\n // n/a\n }\n\n\n /** */\n async refresh(_e?: any) {\n //console.log(\"refresh(): Pulling data from DHT\")\n await this._viewModel.probeDht();\n }\n\n\n /** */\n render() {\n console.log(\"agent-directory-list render() START\");\n\n if (!this._initialized) {\n return html`<span>Loading...</span>`;\n }\n\n /* Agents */\n const agentLi = Object.entries(this.perspective.agents).map(\n ([_index, agentIdB64]) => {\n //console.log(\"\" + index + \". \" + agentIdB64)\n return html `<li value=\"${agentIdB64}\">${agentIdB64}</li>`\n }\n )\n\n /** render all */\n return html` \n <ul>\n ${agentLi}\n </ul>\n `;\n }\n}\n"]}
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './agent_directory.vm';\nexport * from './elements/agent-directory-list'
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,iCAAiC,CAAC","sourcesContent":["export * from './agent_directory.vm';\nexport * from './elements/agent-directory-list';\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ddd-qc/agent-directory",
|
3
|
-
"version": "
|
3
|
+
"version": "2.165.1",
|
4
4
|
"license" : "CAL-1.0",
|
5
5
|
"keywords": ["holochain", "zome"],
|
6
6
|
"main": "./dist/index.js",
|
@@ -31,8 +31,8 @@
|
|
31
31
|
"@holochain-open-dev/utils": "0.4.0",
|
32
32
|
"@lit-labs/context": "^0.1.2",
|
33
33
|
"@open-wc/scoped-elements": "^2.0.1",
|
34
|
-
"
|
35
|
-
"
|
34
|
+
"@ddd-qc/dna-client": "^0.1.6",
|
35
|
+
"lit": "^2.2.0"
|
36
36
|
},
|
37
37
|
"type": "module",
|
38
38
|
"publishConfig": {
|