@ddd-qc/agent-directory 3.165.0 → 3.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.
@@ -1,10 +1,6 @@
|
|
1
1
|
import { AgentPubKeyB64 } from '@holochain-open-dev/core-types';
|
2
2
|
import { AgentDirectoryBridge } from "./agent_directory.bridge";
|
3
3
|
import { DnaClient, ZomeViewModel } from "@ddd-qc/dna-client";
|
4
|
-
/** Global Context */
|
5
|
-
export declare const agentDirectoryContext: {
|
6
|
-
__context__: AgentDirectoryViewModel;
|
7
|
-
};
|
8
4
|
/** */
|
9
5
|
export interface AgentDirectoryPerspective {
|
10
6
|
agents: AgentPubKeyB64[];
|
@@ -16,6 +12,10 @@ export declare class AgentDirectoryViewModel extends ZomeViewModel<AgentDirector
|
|
16
12
|
protected dnaClient: DnaClient;
|
17
13
|
/** Ctor */
|
18
14
|
constructor(dnaClient: DnaClient);
|
15
|
+
static context: {
|
16
|
+
__context__: AgentDirectoryViewModel;
|
17
|
+
};
|
18
|
+
getContext(): any;
|
19
19
|
/** -- Fields -- */
|
20
20
|
private _agents;
|
21
21
|
/** -- Methods -- */
|
@@ -1,9 +1,7 @@
|
|
1
|
-
import { createContext } from "@lit-labs/context";
|
2
1
|
import { serializeHash } from "@holochain-open-dev/utils";
|
3
2
|
import { AgentDirectoryBridge } from "./agent_directory.bridge";
|
4
3
|
import { ZomeViewModel } from "@ddd-qc/dna-client";
|
5
|
-
|
6
|
-
export const agentDirectoryContext = createContext('zome_view_model/agent_directory');
|
4
|
+
import { createContext } from "@lit-labs/context";
|
7
5
|
/**
|
8
6
|
*
|
9
7
|
*/
|
@@ -15,6 +13,7 @@ export class AgentDirectoryViewModel extends ZomeViewModel {
|
|
15
13
|
/** -- Fields -- */
|
16
14
|
this._agents = [];
|
17
15
|
}
|
16
|
+
getContext() { return AgentDirectoryViewModel.context; }
|
18
17
|
/** -- Methods -- */
|
19
18
|
/* */
|
20
19
|
get perspective() {
|
@@ -40,4 +39,5 @@ export class AgentDirectoryViewModel extends ZomeViewModel {
|
|
40
39
|
this.notify();
|
41
40
|
}
|
42
41
|
}
|
42
|
+
AgentDirectoryViewModel.context = createContext('AgentDirectory');
|
43
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":"
|
1
|
+
{"version":3,"file":"agent_directory.vm.js","sourceRoot":"","sources":["../src/agent_directory.vm.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAC,oBAAoB,EAAC,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAY,aAAa,EAAC,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAShD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,aAA8D;IACzG,WAAW;IACX,YAAsB,SAAoB;QACxC,KAAK,CAAC,IAAI,oBAAoB,CAAC,SAAS,CAAC,CAAC,CAAC;QADvB,cAAS,GAAT,SAAS,CAAW;QAO1C,mBAAmB;QAEX,YAAO,GAAqB,EAAE,CAAC;IAPvC,CAAC;IAGD,UAAU,KAAQ,OAAO,uBAAuB,CAAC,OAAO,CAAA,CAAA,CAAC;IAOzD,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;;AArCM,+BAAO,GAAG,aAAa,CAA0B,gBAAgB,CAAC,CAAC","sourcesContent":["import {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\";\nimport {createContext} from \"@lit-labs/context\";\n\n\n/** */\nexport interface AgentDirectoryPerspective {\n agents: AgentPubKeyB64[],\n}\n\n\n/**\n *\n */\nexport class AgentDirectoryViewModel extends ZomeViewModel<AgentDirectoryPerspective, AgentDirectoryBridge> {\n /** Ctor */\n constructor(protected dnaClient: DnaClient) {\n super(new AgentDirectoryBridge(dnaClient));\n }\n\n static context = createContext<AgentDirectoryViewModel>('AgentDirectory');\n getContext():any {return AgentDirectoryViewModel.context}\n\n /** -- Fields -- */\n\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"]}
|
@@ -3,7 +3,7 @@ import { html, LitElement } from "lit";
|
|
3
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
|
-
import {
|
6
|
+
import { AgentDirectoryViewModel } from "../agent_directory.vm";
|
7
7
|
/**
|
8
8
|
* @element agent-directory-list
|
9
9
|
*/
|
@@ -53,7 +53,7 @@ __decorate([
|
|
53
53
|
state()
|
54
54
|
], AgentDirectoryList.prototype, "_initialized", void 0);
|
55
55
|
__decorate([
|
56
|
-
contextProvided({ context:
|
56
|
+
contextProvided({ context: AgentDirectoryViewModel.context, subscribe: true }),
|
57
57
|
property({ type: Object, attribute: false })
|
58
58
|
], AgentDirectoryList.prototype, "_viewModel", void 0);
|
59
59
|
__decorate([
|
@@ -1 +1 @@
|
|
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,
|
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,OAA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,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,uBAAuB,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IAC9E,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 {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: AgentDirectoryViewModel.context, 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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ddd-qc/agent-directory",
|
3
|
-
"version": "3.165.
|
3
|
+
"version": "3.165.1",
|
4
4
|
"license" : "CAL-1.0",
|
5
5
|
"keywords": ["holochain", "zome"],
|
6
6
|
"main": "./dist/index.js",
|
@@ -31,7 +31,7 @@
|
|
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
|
-
"@ddd-qc/dna-client": "^0.3.
|
34
|
+
"@ddd-qc/dna-client": "^0.3.3",
|
35
35
|
"lit": "^2.2.0"
|
36
36
|
},
|
37
37
|
"type": "module",
|