@ddd-qc/profiles-dvm 0.29.0 → 0.29.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/profiles.dvm.d.ts +1 -1
- package/dist/profiles.dvm.d.ts.map +1 -1
- package/dist/profiles.dvm.js.map +1 -1
- package/dist/profiles.zvm.d.ts +2 -2
- package/dist/profiles.zvm.d.ts.map +1 -1
- package/dist/profiles.zvm.js +2 -1
- package/dist/profiles.zvm.js.map +1 -1
- package/dist/profilesAlt.dvm.d.ts +1 -1
- package/dist/profilesAlt.dvm.d.ts.map +1 -1
- package/dist/profilesAlt.dvm.js.map +1 -1
- package/dist/profilesAlt.perspective.d.ts +6 -3
- package/dist/profilesAlt.perspective.d.ts.map +1 -1
- package/dist/profilesAlt.perspective.js +0 -3
- package/dist/profilesAlt.perspective.js.map +1 -1
- package/dist/profilesAlt.zvm.d.ts +1 -0
- package/dist/profilesAlt.zvm.d.ts.map +1 -1
- package/dist/profilesAlt.zvm.js +35 -7
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/package.json +1 -1
package/dist/profiles.dvm.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class ProfilesDvm extends DnaViewModel {
|
|
|
7
7
|
readonly signalHandler?: AppSignalCb;
|
|
8
8
|
get profilesZvm(): ProfilesZvm;
|
|
9
9
|
protected hasChanged(): boolean;
|
|
10
|
-
get perspective():
|
|
10
|
+
get perspective(): Object;
|
|
11
11
|
handleSignal(signal: AppSignal): void;
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=profiles.dvm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.dvm.d.ts","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,SAAS,EAAE,WAAW,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAY3C,qBAAa,WAAY,SAAQ,YAAY;IAE3C,gBAAyB,sBAAsB,cAAc;IAC7D,gBAAyB,QAAQ,yBAAgB;IACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAqB;IAIzD,IAAI,WAAW,IAAI,WAAW,CAE7B;IAID,SAAS,CAAC,UAAU,IAAI,OAAO;IAI/B,IAAI,WAAW,IAAI,
|
|
1
|
+
{"version":3,"file":"profiles.dvm.d.ts","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EACL,SAAS,EAAE,WAAW,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAY3C,qBAAa,WAAY,SAAQ,YAAY;IAE3C,gBAAyB,sBAAsB,cAAc;IAC7D,gBAAyB,QAAQ,yBAAgB;IACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAqB;IAIzD,IAAI,WAAW,IAAI,WAAW,CAE7B;IAID,SAAS,CAAC,UAAU,IAAI,OAAO;IAI/B,IAAI,WAAW,IAAI,MAAM,CAExB;IAMD,YAAY,CAAC,MAAM,EAAE,SAAS;CAQ/B"}
|
package/dist/profiles.dvm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.dvm.js","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAY3C,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8B3D,CAAC;IA1BC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAC;IAC7E,CAAC;IAIS,UAAU;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAMD,YAAY,CAAC,MAAiB;QAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACtD,OAAO;SACR;IACH,CAAC;;AA7BwB,kCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,oBAAQ,GAAG,CAAC,WAAW,CAAC,AAAhB,CAAgB","sourcesContent":["import {DnaViewModel} from \"@ddd-qc/lit-happ\";\nimport {\n AppSignal, AppSignalCb,\n} from \"@holochain/client\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\n\n\n/** */\n// export interface ProfilesDnaPerspective {\n// agentPresences: Record<string, number>,\n// }\n\n\n/**\n * ViewModel fo a DNA holding a Profiles zome\n */\nexport class ProfilesDvm extends DnaViewModel {\n\n static override readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static override readonly ZVM_DEFS = [ProfilesZvm]\n readonly signalHandler?: AppSignalCb = this.handleSignal;\n\n\n /** QoL Helpers */\n get profilesZvm(): ProfilesZvm {\n return this.getZomeViewModel(ProfilesZvm.DEFAULT_ZOME_NAME) as ProfilesZvm;\n }\n\n /** -- Perspective -- */\n\n protected hasChanged(): boolean {\n return true\n }\n\n get perspective():
|
|
1
|
+
{"version":3,"file":"profiles.dvm.js","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAI9C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAY3C,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8B3D,CAAC;IA1BC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAC;IAC7E,CAAC;IAIS,UAAU;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAMD,YAAY,CAAC,MAAiB;QAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACtD,OAAO;SACR;IACH,CAAC;;AA7BwB,kCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,oBAAQ,GAAG,CAAC,WAAW,CAAC,AAAhB,CAAgB","sourcesContent":["import {DnaViewModel} from \"@ddd-qc/lit-happ\";\nimport {\n AppSignal, AppSignalCb,\n} from \"@holochain/client\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\n\n\n/** */\n// export interface ProfilesDnaPerspective {\n// agentPresences: Record<string, number>,\n// }\n\n\n/**\n * ViewModel fo a DNA holding a Profiles zome\n */\nexport class ProfilesDvm extends DnaViewModel {\n\n static override readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static override readonly ZVM_DEFS = [ProfilesZvm]\n readonly signalHandler?: AppSignalCb = this.handleSignal;\n\n\n /** QoL Helpers */\n get profilesZvm(): ProfilesZvm {\n return this.getZomeViewModel(ProfilesZvm.DEFAULT_ZOME_NAME) as ProfilesZvm;\n }\n\n /** -- Perspective -- */\n\n protected hasChanged(): boolean {\n return true\n }\n\n get perspective(): Object {\n return {}\n }\n\n\n /** -- Signaling -- */\n\n /** */\n handleSignal(signal: AppSignal) {\n console.log(\"Received Signal\", signal);\n if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {\n return;\n }\n }\n\n\n}\n"]}
|
package/dist/profiles.zvm.d.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { ZomeViewModel } from "@ddd-qc/lit-happ";
|
|
|
2
2
|
import { Profile } from "./bindings/profiles.types";
|
|
3
3
|
import { AgentPubKeyB64 } from "@holochain/client";
|
|
4
4
|
import { ProfilesProxy } from "./bindings/profiles.proxy";
|
|
5
|
-
export
|
|
5
|
+
export type ProfilesPerspective = {
|
|
6
6
|
profiles: Record<AgentPubKeyB64, Profile>;
|
|
7
7
|
reversed: Record<string, AgentPubKeyB64>;
|
|
8
|
-
}
|
|
8
|
+
};
|
|
9
9
|
export declare class ProfilesZvm extends ZomeViewModel {
|
|
10
10
|
static readonly ZOME_PROXY: typeof ProfilesProxy;
|
|
11
11
|
get zomeProxy(): ProfilesProxy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.zvm.d.ts","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,cAAc,EAA2C,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAKxD,MAAM,
|
|
1
|
+
{"version":3,"file":"profiles.zvm.d.ts","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,cAAc,EAA2C,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAKxD,MAAM,MAAM,mBAAmB,GAAG;IAEhC,QAAQ,EAAE,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAK1C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CAC1C,CAAA;AAMD,qBAAa,WAAY,SAAQ,aAAa;IAE5C,gBAAyB,UAAU,uBAAiB;IACpD,IAAI,SAAS,IAAI,aAAa,CAA2C;IAIzE,SAAS,CAAC,UAAU,IAAI,OAAO;IAOhB,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlD,aAAa;IAOtB,IAAI,WAAW,IAAI,mBAAmB,CAOrC;IAED,OAAO,CAAC,SAAS,CAAuC;IAExD,OAAO,CAAC,SAAS,CAAsC;IAGvD,YAAY,IAAI,OAAO,GAAG,SAAS;IAEnC,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,GAAG,SAAS;IAItD,SAAS,IAAI,cAAc,EAAE;IAE7B,QAAQ,IAAI,MAAM,EAAE;IAIpB,iBAAiB,IAAI,MAAM;IAO3B,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAUjD,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,cAAc,EAAE;IAYzC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAsBlE,YAAY,CAAC,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO;IAQlD,YAAY,CAAC,SAAS,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAiBrE,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAOhD,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAKvD"}
|
package/dist/profiles.zvm.js
CHANGED
|
@@ -19,10 +19,11 @@ export class ProfilesZvm extends ZomeViewModel {
|
|
|
19
19
|
this.probeAllProfiles();
|
|
20
20
|
}
|
|
21
21
|
get perspective() {
|
|
22
|
-
|
|
22
|
+
const pers = {
|
|
23
23
|
profiles: this._profiles,
|
|
24
24
|
reversed: this._reversed,
|
|
25
25
|
};
|
|
26
|
+
return pers;
|
|
26
27
|
}
|
|
27
28
|
getMyProfile() { return this._profiles[this.cell.address.agentId.b64]; }
|
|
28
29
|
getProfile(agent) { return this._profiles[agent]; }
|
package/dist/profiles.zvm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profiles.zvm.js","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAkBxC,MAAM,OAAO,WAAY,SAAQ,aAAa;IAA9C;;
|
|
1
|
+
{"version":3,"file":"profiles.zvm.js","sourceRoot":"","sources":["../src/profiles.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAiB,oBAAoB,EAAE,kBAAkB,EAAC,MAAM,mBAAmB,CAAC;AAC3F,OAAO,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AAkBxC,MAAM,OAAO,WAAY,SAAQ,aAAa;IAA9C;;QAmCU,cAAS,GAAoC,EAAE,CAAC;QAEhD,cAAS,GAAmC,EAAE,CAAC;IAuGzD,CAAC;IAzIC,IAAI,SAAS,KAAmB,OAAO,IAAI,CAAC,UAA2B,CAAC,CAAA,CAAC;IAI/D,UAAU;QAElB,OAAO,IAAI,CAAC;IACd,CAAC;IAIQ,KAAK,CAAC,2BAA2B;QACxC,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAChC,CAAC;IAGQ,aAAa;QACpB,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAKD,IAAI,WAAW;QACb,MAAM,IAAI,GAAwB;YAChC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G,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC;IACjB,CAAC;IAID,KAAK,CAAC,eAAe,CAAC,OAAgB;QACjB,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAID,KAAK,CAAC,eAAe,CAAC,OAAgB;QACjB,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QAC/D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;;AAxIwB,sBAAU,GAAG,aAAa,AAAhB,CAAiB","sourcesContent":["import {ZomeViewModel} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {AgentPubKeyB64, decodeHashFromBase64, encodeHashToBase64} from \"@holochain/client\";\nimport {ProfilesProxy} from \"./bindings/profiles.proxy\";\nimport {decode} from \"@msgpack/msgpack\";\n\n\n/** */\nexport type ProfilesPerspective = {\n /* AgentPubKeyB64 -> Profile */\n profiles: Record<AgentPubKeyB64, Profile>,\n ///* AgentPubKeyB64 -> Profile hash */\n //profile_ahs: Record<AgentPubKeyB64, ActionHashB64>,\n\n /** Nickname -> AgentPubKeyB64 */\n reversed: Record<string, AgentPubKeyB64>,\n}\n\n\n/**\n *\n */\nexport class ProfilesZvm extends ZomeViewModel {\n\n static override readonly ZOME_PROXY = ProfilesProxy;\n get zomeProxy(): ProfilesProxy {return this._zomeProxy as ProfilesProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n override async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n override probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesPerspective {\n const pers: ProfilesPerspective = {\n profiles: this._profiles,\n reversed: this._reversed,\n //profile_ahs: this._profile_ahs,\n };\n return pers;\n }\n\n private _profiles: Record<AgentPubKeyB64, Profile> = {};\n //private _profile_ahs: Record<AgentPubKeyB64, ActionHashB64> = {};\n private _reversed: Record<string, AgentPubKeyB64> = {};\n\n\n getMyProfile(): Profile | undefined { return this._profiles[this.cell.address.agentId.b64] }\n\n getProfile(agent: AgentPubKeyB64): Profile | undefined {return this._profiles[agent]}\n\n //getProfileHash(agent: AgentPubKeyB64): ActionHashB64 | undefined {return this._profile_ahs[agent]}\n\n getAgents(): AgentPubKeyB64[] { return Object.keys(this._profiles)}\n\n getNames(): string[] { return Object.keys(this._reversed)}\n\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n //console.log(\"exportPerspective()\", perspMat);\n return JSON.stringify(this._profiles, null, 2);\n }\n\n\n /** */\n importPerspective(json: string, _mapping?: Object) {\n const profiles = JSON.parse(json) as Record<AgentPubKeyB64, Profile>;\n for (const [pubKey, profileMat] of Object.entries(profiles)) {\n this.storeProfile(pubKey, profileMat);\n }\n }\n\n /** -- Methods -- */\n\n /* */\n findProfiles(names: string[]): AgentPubKeyB64[] {\n let res: AgentPubKeyB64[] = []\n for (const name of names) {\n if (this._reversed[name]) {\n res.push(this._reversed[name]!)\n }\n }\n return res;\n }\n\n\n /** */\n async probeAllProfiles(): Promise<Record<AgentPubKeyB64, Profile>> {\n let allAgents;\n /** Attempt a retry on fail as this can create an entry (path anchor) and generate a 'head has moved' error */\n try {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n } catch(e) {\n allAgents = await this.zomeProxy.getAgentsWithProfile();\n }\n for (const agentPubKey of allAgents) {\n const maybeProfile = await this.zomeProxy.getAgentProfile(agentPubKey);\n if (!maybeProfile) {\n continue;\n }\n const profile: Profile = decode((maybeProfile.entry as any).Present.entry) as Profile;\n this.storeProfile(encodeHashToBase64(agentPubKey), profile);\n }\n this.notifySubscribers();\n return this._profiles;\n }\n\n\n /** */\n storeProfile(pubKeyB64: AgentPubKeyB64, profile: Profile) {\n this._profiles[pubKeyB64] = profile;\n this._reversed[profile.nickname] = pubKeyB64;\n this.notifySubscribers();\n }\n\n\n /** */\n async probeProfile(pubKeyB64: AgentPubKeyB64): Promise<Profile | undefined> {\n const maybeProfile = await this.zomeProxy.getAgentProfile(decodeHashFromBase64(pubKeyB64));\n console.log(\"probeProfile() maybeProfile\", maybeProfile);\n if (!maybeProfile) {\n return;\n }\n // const profileEntry: any = decode((maybeProfile.entry as any).Present.entry);\n // console.log(\"probeProfile() profileEntry\", profileEntry);\n //const profile: Profile = decode(profileEntry.record.entry.Present.entry) as Profile;\n const profile: Profile = decode((maybeProfile.entry as any).Present.entry) as Profile;\n console.log(\"probeProfile() profile\", profile);\n this.storeProfile(pubKeyB64, profile);\n return profile;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n /*const record =*/ await this.zomeProxy.createProfile(profile);\n this.storeProfile(this.cell.address.agentId.b64, profile);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n /*const record =*/ await this.zomeProxy.updateProfile(profile);\n this.storeProfile(this.cell.address.agentId.b64, profile);\n }\n\n}\n"]}
|
|
@@ -7,7 +7,7 @@ export declare class ProfilesAltDvm extends DnaViewModel {
|
|
|
7
7
|
readonly signalHandler?: AppSignalCb;
|
|
8
8
|
get profilesZvm(): ProfilesAltZvm;
|
|
9
9
|
protected hasChanged(): boolean;
|
|
10
|
-
get perspective():
|
|
10
|
+
get perspective(): Object;
|
|
11
11
|
handleSignal(signal: AppSignal): void;
|
|
12
12
|
exportPerspective(): string;
|
|
13
13
|
importPerspective(json: string, canPublish: boolean): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.dvm.d.ts","sourceRoot":"","sources":["../src/profilesAlt.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAgB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,SAAS,EAAE,WAAW,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAWjD,qBAAa,cAAe,SAAQ,YAAY;IAE9C,gBAAyB,sBAAsB,cAAc;IAC7D,gBAAyB,QAAQ,4BAAmB;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAqB;IAIzD,IAAI,WAAW,IAAI,cAAc,CAEhC;IAID,SAAS,CAAC,UAAU,IAAI,OAAO;IAI/B,IAAI,WAAW,IAAI,
|
|
1
|
+
{"version":3,"file":"profilesAlt.dvm.d.ts","sourceRoot":"","sources":["../src/profilesAlt.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAgB,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,SAAS,EAAE,WAAW,EACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAWjD,qBAAa,cAAe,SAAQ,YAAY;IAE9C,gBAAyB,sBAAsB,cAAc;IAC7D,gBAAyB,QAAQ,4BAAmB;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,WAAW,CAAqB;IAIzD,IAAI,WAAW,IAAI,cAAc,CAEhC;IAID,SAAS,CAAC,UAAU,IAAI,OAAO;IAI/B,IAAI,WAAW,IAAI,MAAM,CAExB;IAMD,YAAY,CAAC,MAAM,EAAE,SAAS;IAW9B,iBAAiB,IAAI,MAAM;IASrB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;CAQ1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.dvm.js","sourceRoot":"","sources":["../src/profilesAlt.d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SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;;AAjDwB,qCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,uBAAQ,GAAG,CAAC,cAAc,CAAC,AAAnB,CAAmB","sourcesContent":["import {DnaViewModel, holoIdReviver} from \"@ddd-qc/lit-happ\";\nimport {\n AppSignal, AppSignalCb,\n} from \"@holochain/client\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\nimport {ProfilesAltZvm} from \"./profilesAlt.zvm\";\n\n/** */\n// export interface ProfilesDnaPerspective {\n// agentPresences: Record<string, number>,\n// }\n\n\n/**\n * ViewModel fo a DNA holding a Profiles zome\n */\nexport class ProfilesAltDvm extends DnaViewModel {\n\n static override readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static override readonly ZVM_DEFS = [ProfilesAltZvm]\n readonly signalHandler?: AppSignalCb = this.handleSignal;\n\n\n /** QoL Helpers */\n get profilesZvm(): ProfilesAltZvm {\n return this.getZomeViewModel(ProfilesAltZvm.DEFAULT_ZOME_NAME) as ProfilesAltZvm\n }\n\n /** -- Perspective -- */\n\n protected hasChanged(): boolean {\n return true\n }\n\n get perspective():
|
|
1
|
+
{"version":3,"file":"profilesAlt.dvm.js","sourceRoot":"","sources":["../src/profilesAlt.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAI7D,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAWjD,MAAM,OAAO,cAAe,SAAQ,YAAY;IAAhD;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IAkD3D,CAAC;IA9CC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,iBAAiB,CAAmB,CAAA;IAClF,CAAC;IAIS,UAAU;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAMD,YAAY,CAAC,MAAiB;QAC5B,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACtD,OAAO;SACR;IACH,CAAC;IAMD,iBAAiB;QACf,MAAM,SAAS,GAAQ,EAAE,CAAC;QAC1B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;QACxC,SAAS,CAAC,WAAW,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7D,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC5C,CAAC;IAID,KAAK,CAAC,iBAAiB,CAAC,IAAY,EAAE,UAAmB;QACvD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAQ,CAAC;QACxD,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC;QACzD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC,CAAC;QAC9D,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;;AAjDwB,qCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,uBAAQ,GAAG,CAAC,cAAc,CAAC,AAAnB,CAAmB","sourcesContent":["import {DnaViewModel, holoIdReviver} from \"@ddd-qc/lit-happ\";\nimport {\n AppSignal, AppSignalCb,\n} from \"@holochain/client\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\nimport {ProfilesAltZvm} from \"./profilesAlt.zvm\";\n\n/** */\n// export interface ProfilesDnaPerspective {\n// agentPresences: Record<string, number>,\n// }\n\n\n/**\n * ViewModel fo a DNA holding a Profiles zome\n */\nexport class ProfilesAltDvm extends DnaViewModel {\n\n static override readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static override readonly ZVM_DEFS = [ProfilesAltZvm]\n readonly signalHandler?: AppSignalCb = this.handleSignal;\n\n\n /** QoL Helpers */\n get profilesZvm(): ProfilesAltZvm {\n return this.getZomeViewModel(ProfilesAltZvm.DEFAULT_ZOME_NAME) as ProfilesAltZvm\n }\n\n /** -- Perspective -- */\n\n protected hasChanged(): boolean {\n return true\n }\n\n get perspective(): Object {\n return {}\n }\n\n\n /** -- Signaling -- */\n\n /** */\n handleSignal(signal: AppSignal) {\n console.log(\"Received Signal\", signal);\n if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {\n return;\n }\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n const dvmExport: any = {};\n const tJson = this.profilesZvm.export();\n dvmExport[ProfilesZvm.DEFAULT_ZOME_NAME] = JSON.parse(tJson);\n return JSON.stringify(dvmExport, null, 2);\n }\n\n\n /** */\n async importPerspective(json: string, canPublish: boolean) {\n const external = JSON.parse(json, holoIdReviver) as any;\n const profiles = external[ProfilesZvm.DEFAULT_ZOME_NAME];\n this.profilesZvm.import(JSON.stringify(profiles), canPublish);\n this.notifySubscribers();\n }\n\n\n}\n"]}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { ActionId, ActionIdMap, AgentId, AgentIdMap } from "@ddd-qc/cell-proxy";
|
|
2
2
|
import { Profile } from "./bindings/profiles.types";
|
|
3
3
|
import { Timestamp } from "@holochain/client";
|
|
4
|
-
export
|
|
4
|
+
export type ProfilesAltSnapshot = {
|
|
5
5
|
all: [AgentId, ActionId, Profile, Timestamp][];
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
|
+
export type ProfilesAltComparable = {
|
|
8
|
+
profileCount: number;
|
|
9
|
+
profiles: Profile[];
|
|
10
|
+
};
|
|
7
11
|
export declare class ProfilesAltPerspective {
|
|
8
12
|
profiles: ActionIdMap<[Profile, Timestamp]>;
|
|
9
13
|
profileByAgent: AgentIdMap<ActionId>;
|
|
10
14
|
agentByName: Record<string, AgentId>;
|
|
11
|
-
equals(_other: ProfilesAltPerspective): boolean;
|
|
12
15
|
get agents(): AgentId[];
|
|
13
16
|
get names(): string[];
|
|
14
17
|
getProfileAgent(profileId: ActionId): AgentId | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.perspective.d.ts","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAI5C,MAAM,
|
|
1
|
+
{"version":3,"file":"profilesAlt.perspective.d.ts","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAI5C,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,CAAC;CAChD,CAAA;AAGD,MAAM,MAAM,qBAAqB,GAAG;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB,CAAA;AAGD,qBAAa,sBAAsB;IAEjC,QAAQ,EAAE,WAAW,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAqB;IAEhE,cAAc,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAoB;IAIxD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM;IAK1C,IAAI,MAAM,IAAI,OAAO,EAAE,CAAiD;IACxE,IAAI,KAAK,IAAI,MAAM,EAAE,CAAwC;IAG7D,eAAe,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,GAAG,SAAS;IAWzD,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS;IAuBxD,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS;IAoB5D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAQ/C,YAAY,IAAI,mBAAmB;CAWpC;AAID,qBAAa,6BAA8B,SAAQ,sBAAsB;IAEvE,IAAI,QAAQ,IAAI,sBAAsB,CAErC;IAKD,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS;IAWjE,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ;IAWvD,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ;IAczD,OAAO,CAAC,QAAQ,EAAE,mBAAmB;IAgB/B,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAS9F"}
|
|
@@ -5,9 +5,6 @@ export class ProfilesAltPerspective {
|
|
|
5
5
|
this.profileByAgent = new AgentIdMap();
|
|
6
6
|
this.agentByName = {};
|
|
7
7
|
}
|
|
8
|
-
equals(_other) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
8
|
get agents() { return Array.from(this.profileByAgent.keys()); }
|
|
12
9
|
get names() { return Object.keys(this.agentByName); }
|
|
13
10
|
getProfileAgent(profileId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.perspective.js","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"profilesAlt.perspective.js","sourceRoot":"","sources":["../src/profilesAlt.perspective.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAiBhG,MAAM,OAAO,sBAAsB;IAAnC;QAEE,aAAQ,GAAsC,IAAI,WAAW,EAAE,CAAC;QAEhE,mBAAc,GAAyB,IAAI,UAAU,EAAE,CAAC;QAIxD,gBAAW,GAA4B,EAAE,CAAC;IAkF5C,CAAC;IA7EC,IAAI,MAAM,KAAgB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,CAAA,CAAA,CAAC;IACxE,IAAI,KAAK,KAAe,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA,CAAA,CAAC;IAG7D,eAAe,CAAC,SAAmB;QACjC,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE;YAC7D,IAAI,SAAS,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE;gBAC/B,OAAO,OAAO,CAAC;aAChB;SACF;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAID,UAAU,CAAC,KAAuB;QAChC,IAAI,OAAO,KAAK,IAAI,QAAQ,EAAE;YAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,C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C,CAAC;QAChD,IAAI,MAAM;YAAE,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;QACpC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3C,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAA,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACpD,CAAC;CAEF","sourcesContent":["import {ActionId, ActionIdMap, AgentId, AgentIdMap, assertAllDefined} from \"@ddd-qc/cell-proxy\";\r\nimport {Profile} from \"./bindings/profiles.types\";\r\nimport {Timestamp} from \"@holochain/client\";\r\n\r\n\r\n/** */\r\nexport type ProfilesAltSnapshot = {\r\n all: [AgentId, ActionId, Profile, Timestamp][];\r\n}\r\n\r\n\r\nexport type ProfilesAltComparable = {\r\n profileCount: number,\r\n profiles: Profile[],\r\n}\r\n\r\n/** */\r\nexport class ProfilesAltPerspective {\r\n /* ActionId -> Profile */\r\n profiles: ActionIdMap<[Profile, Timestamp]> = new ActionIdMap();\r\n /* AgentId -> ActionId */\r\n profileByAgent: AgentIdMap<ActionId> = new AgentIdMap();\r\n\r\n /** -- Extra -- */\r\n /* Name -> AgentId */\r\n agentByName: Record<string, AgentId> = {};\r\n\r\n\r\n /** -- Getters -- */\r\n\r\n get agents(): AgentId[] { return Array.from(this.profileByAgent.keys())}\r\n get names(): string[] { return Object.keys(this.agentByName)}\r\n\r\n /** */\r\n getProfileAgent(profileId: ActionId): AgentId | undefined {\r\n for (const [agentId, profId] of this.profileByAgent.entries()) {\r\n if (profileId.b64 == profId.b64) {\r\n return agentId;\r\n }\r\n }\r\n return undefined;\r\n }\r\n\r\n\r\n /** AgentId or Name */\r\n getProfile(agent: AgentId | string): Profile | undefined {\r\n if (typeof agent == \"string\") {\r\n const maybe = this.agentByName[agent];\r\n if (!maybe) {\r\n return;\r\n }\r\n agent = maybe;\r\n }\r\n const profileAh = this.profileByAgent.get(agent);\r\n //console.log(\"ProfilesAltZvm.getProfile()\", agent, profileAh);\r\n if (!profileAh) {\r\n return undefined;\r\n }\r\n const pair = this.profiles.get(profileAh);\r\n //console.log(\"ProfilesAltZvm.getProfile() pair\", pair);\r\n if (!pair) {\r\n return undefined;\r\n }\r\n return pair[0];\r\n }\r\n\r\n\r\n /** */\r\n getProfileTs(agent: AgentId | string): Timestamp | undefined {\r\n if (typeof agent == \"string\") {\r\n const maybe = this.agentByName[agent];\r\n if (!maybe) {\r\n return;\r\n }\r\n agent = maybe;\r\n }\r\n const profileAh = this.profileByAgent.get(agent);\r\n if (!profileAh) {\r\n return undefined;\r\n }\r\n const pair = this.profiles.get(profileAh);\r\n if (!pair) {\r\n return undefined;\r\n }\r\n return pair[1];\r\n }\r\n\r\n /** */\r\n getAgent(nickname: string): AgentId | undefined {\r\n return this.agentByName[nickname];\r\n }\r\n\r\n\r\n /** -- Memento -- */\r\n\r\n /** TODO: deep copy */\r\n makeSnapshot(): ProfilesAltSnapshot {\r\n let all: [AgentId, ActionId, Profile, Timestamp][] = [];\r\n for (const [agentId, profileAh] of this.profileByAgent.entries()) {\r\n const pair = this.profiles.get(profileAh);\r\n if (pair) {\r\n all.push([agentId, profileAh, pair[0], pair[1]])\r\n }\r\n }\r\n /** */\r\n return {all};\r\n }\r\n}\r\n\r\n\r\n/** */\r\nexport class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {\r\n\r\n get readonly(): ProfilesAltPerspective {\r\n return this;\r\n }\r\n\r\n /** -- Store -- */\r\n\r\n /** */\r\n storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp) {\r\n console.debug(\"ProfilesAltZvm.storeProfile()\", profileAh.short, profile.nickname);\r\n assertAllDefined(profileAh, profile, ts);\r\n this.profiles.set(profileAh, [profile, ts]);\r\n const agentId = this.getProfileAgent(profileAh);\r\n if (agentId) {\r\n this.agentByName[profile.nickname] = agentId;\r\n }\r\n }\r\n\r\n /** */\r\n storeAgentProfile(agentId: AgentId, profileAh: ActionId) {\r\n console.debug(\"ProfilesAltZvm.storeAgentProfile()\", agentId.short, profileAh.short);\r\n assertAllDefined(agentId, profileAh);\r\n this.profileByAgent.set(agentId, profileAh);\r\n const pair = this.profiles.get(profileAh);\r\n if (pair) {\r\n this.agentByName[pair[0].nickname] = agentId;\r\n }\r\n }\r\n\r\n /** */\r\n unstoreAgentProfile(agentId: AgentId, profileAh: ActionId) {\r\n console.debug(\"ProfilesAltZvm.unstoreAgentProfile()\", agentId.short, profileAh.short);\r\n assertAllDefined(agentId, profileAh);\r\n this.profileByAgent.delete(agentId);\r\n const pair = this.profiles.get(profileAh);\r\n if (pair) {\r\n delete this.agentByName[pair[0].nickname];\r\n }\r\n }\r\n\r\n\r\n /** -- Memento -- */\r\n\r\n /** */\r\n restore(snapshot: ProfilesAltSnapshot) {\r\n /** Clear */\r\n this.profiles.clear();\r\n this.profileByAgent.clear();\r\n this.agentByName = {};\r\n /** Store */\r\n for (const [agentId, profileAh, profile, ts] of snapshot.all) {\r\n this.storeAgentProfile(agentId, profileAh);\r\n this.storeProfile(profileAh, profile, ts);\r\n }\r\n }\r\n\r\n\r\n /** -- Generate -- */\r\n\r\n /** */\r\n async generateRandomProfile(nickname: string, ts?: Timestamp, fields?: Record<string, string>) {\r\n const agentId = await AgentId.random();\r\n const profileAh = await ActionId.random();\r\n const profile: Profile = {nickname, fields: {}};\r\n if (fields) profile.fields = fields;\r\n this.storeAgentProfile(agentId, profileAh);\r\n this.storeProfile(profileAh, profile, ts? ts : 0);\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -6,6 +6,7 @@ import { ProfilesAltPerspective } from "./profilesAlt.perspective";
|
|
|
6
6
|
export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
7
7
|
static readonly ZOME_PROXY: typeof ProfilesAltProxy;
|
|
8
8
|
get zomeProxy(): ProfilesAltProxy;
|
|
9
|
+
comparable(): Object;
|
|
9
10
|
protected hasChanged(): boolean;
|
|
10
11
|
initializePerspectiveOnline(): Promise<void>;
|
|
11
12
|
probeAllInner(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.d.ts","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EAEP,YAAY,EAEZ,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,gDAAgD,CAAC;AAG7E,OAAO,
|
|
1
|
+
{"version":3,"file":"profilesAlt.zvm.d.ts","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,OAAO,EAEP,YAAY,EAEZ,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAC,OAAO,EAAC,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,aAAa,EAAC,MAAM,gDAAgD,CAAC;AAG7E,OAAO,EAEL,sBAAsB,EAGvB,MAAM,2BAA2B,CAAC;AAMnC,qBAAa,cAAe,SAAQ,wBAAwB;IAI1D,gBAAyB,UAAU,0BAAoB;IACvD,IAAI,SAAS,IAAI,gBAAgB,CAA8C;IAItE,UAAU,IAAI,MAAM;IAS7B,SAAS,CAAC,UAAU,IAAI,OAAO;IAahB,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC;IAMlD,aAAa;IAMtB,IAAI,WAAW,IAAI,sBAAsB,CAExC;IAKD,OAAO,CAAC,YAAY,CAAsE;IAK1F,YAAY,IAAI,OAAO,GAAG,SAAS;IASpB,eAAe,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BnE,gBAAgB,CAAC,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO;IAe9D,gBAAgB;IAQhB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC;IAgB3D,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhD,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAMhE,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtE,MAAM,IAAI,MAAM;IAOhB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;CAoBzC"}
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -10,8 +10,27 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
10
10
|
this._perspective = new ProfilesAltPerspectiveMutable();
|
|
11
11
|
}
|
|
12
12
|
get zomeProxy() { return this._zomeProxy; }
|
|
13
|
+
comparable() {
|
|
14
|
+
const res = {
|
|
15
|
+
profileCount: this._perspective.profileByAgent.size,
|
|
16
|
+
profiles: Array.from(this.perspective.profiles.values()).map((pair) => pair[0]),
|
|
17
|
+
};
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
13
20
|
hasChanged() {
|
|
14
|
-
|
|
21
|
+
const current = this.comparable();
|
|
22
|
+
const prev = this._previousPerspective;
|
|
23
|
+
if (!prev) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
if (current.profileCount != prev.profileCount)
|
|
27
|
+
return true;
|
|
28
|
+
for (let i = 0; i < current.profileCount; i += 1) {
|
|
29
|
+
if (current.profiles[i] != prev.profiles[i]) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return false;
|
|
15
34
|
}
|
|
16
35
|
async initializePerspectiveOnline() {
|
|
17
36
|
await this.probeAllProfiles();
|
|
@@ -63,15 +82,24 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
63
82
|
}
|
|
64
83
|
}
|
|
65
84
|
async probeAllProfiles() {
|
|
66
|
-
|
|
85
|
+
try {
|
|
86
|
+
await this.zomeProxy.probeProfiles();
|
|
87
|
+
}
|
|
88
|
+
catch (e) { }
|
|
67
89
|
}
|
|
68
90
|
async findProfile(agentId) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
91
|
+
try {
|
|
92
|
+
const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);
|
|
93
|
+
console.log("findProfile()", agentId, maybeProfilePair);
|
|
94
|
+
if (!maybeProfilePair) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
return maybeProfilePair[1];
|
|
98
|
+
}
|
|
99
|
+
catch (e) {
|
|
100
|
+
return undefined;
|
|
73
101
|
}
|
|
74
|
-
return
|
|
102
|
+
return undefined;
|
|
75
103
|
}
|
|
76
104
|
async createMyProfile(profile) {
|
|
77
105
|
await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EAAE,aAAa,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAEL,6BAA6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AC,CAAC;gBACxF,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;gBACpD,IAAI,CAAC,KAAK,EAAE;oBACA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;iBAChD;qBAAM;oBACL,IAAI,KAAK,IAAI,OAAO,EAAE;wBACpB,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;qBACtC;iBACF;aACF;YACD,OAAO;SACR;QAED,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;;AA3JwB,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId,\n AgentId,\n EntryId, holoIdReviver,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static override readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n return !this.perspective.equals(this._previousPerspective as ProfilesAltPerspective);\n }\n\n\n /** */\n override async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n\n /** */\n override probeAllInner() {\n this.probeAllProfiles();\n }\n\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective.readonly;\n }\n\n\n /** -- */\n\n private _perspective: ProfilesAltPerspectiveMutable = new ProfilesAltPerspectiveMutable();\n\n\n /** -- Getters -- */\n\n getMyProfile(): Profile | undefined {\n return this._perspective.getProfile(this.cell.address.agentId);\n }\n\n\n\n /** -- Signals -- */\n\n /** */\n override async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n if (pulse.state != StateChangeType.Delete) {\n await this.findProfile(agentId);\n }\n }\n break;\n case ProfilesLinkType.AgentToProfile: {\n const agentEh = new EntryId(pulse.base.b64); // Make sure its an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n override async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles()/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n await this.zomeProxy.probeProfiles();\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.updateProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, canPublish: boolean) {\n const snapshot = JSON.parse(json, holoIdReviver) as ProfilesAltSnapshot;\n if (canPublish) {\n for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {\n console.log(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n const maybe = this._perspective.getProfile(agentId);\n if (!maybe) {\n /*await*/ this.createProfile(profile, agentId);\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId);\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,OAAO,EACP,OAAO,EAAE,aAAa,EAEtB,eAAe,EACf,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAGL,6BAA6B,EAE9B,MAAM,2BAA2B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,CAAC,CAAC;QACpC,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;;AAlLwB,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId,\n AgentId,\n EntryId, holoIdReviver,\n LinkPulseMat,\n StateChangeType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {decode} from \"@msgpack/msgpack\";\nimport {ProfilesAltProxy} from \"./bindings/profilesAlt.proxy\";\nimport {EntryPulseMat} from \"@ddd-qc/lit-happ/dist/ZomeViewModelWithSignals\";\nimport {ProfilesLinkType} from \"./bindings/profiles.integrity\";\nimport {ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\nimport {\n ProfilesAltComparable,\n ProfilesAltPerspective,\n ProfilesAltPerspectiveMutable,\n ProfilesAltSnapshot\n} from \"./profilesAlt.perspective\";\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n /** -- Concret -- */\n\n static override readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /** */\n override comparable(): Object {\n const res: ProfilesAltComparable = {\n profileCount: this._perspective.profileByAgent.size,\n profiles: Array.from(this.perspective.profiles.values()).map((pair) => pair[0]),\n };\n return res;\n }\n\n /* */\n protected hasChanged(): boolean {\n const current = this.comparable() as ProfilesAltComparable;\n const prev = this._previousPerspective as ProfilesAltComparable;\n if (!prev) { return true }\n if (current.profileCount != prev.profileCount) return true;\n for (let i = 0; i < current.profileCount; i+= 1) {\n if (current.profiles[i] != prev.profiles[i]) { return true }\n }\n return false;\n }\n\n\n /** */\n override async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n\n /** */\n override probeAllInner() {\n this.probeAllProfiles();\n }\n\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective.readonly;\n }\n\n\n /** -- */\n\n private _perspective: ProfilesAltPerspectiveMutable = new ProfilesAltPerspectiveMutable();\n\n\n /** -- Getters -- */\n\n getMyProfile(): Profile | undefined {\n return this._perspective.getProfile(this.cell.address.agentId);\n }\n\n\n\n /** -- Signals -- */\n\n /** */\n override async handleLinkPulse(pulse: LinkPulseMat, _from: AgentId): Promise<void> {\n switch (pulse.link_type) {\n case ProfilesLinkType.PrefixPath:\n case ProfilesLinkType.PathToAgent: {\n const agentEh = new EntryId(pulse.target.b64);\n const agentId = AgentId.from(agentEh);\n if (pulse.state != StateChangeType.Delete) {\n await this.findProfile(agentId);\n }\n }\n break;\n case ProfilesLinkType.AgentToProfile: {\n const agentEh = new EntryId(pulse.base.b64); // Make sure its an EntryHash\n const agentId = AgentId.from(agentEh);\n const profileAh = ActionId.from(pulse.target);\n if (pulse.state == StateChangeType.Delete) {\n this._perspective.unstoreAgentProfile(agentId, profileAh)\n } else {\n this._perspective.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n override async handleEntryPulse(pulse: EntryPulseMat, _from: AgentId) {\n switch (pulse.entryType) {\n case ProfilesAltUnitEnum.Profile:\n const profile = decode(pulse.bytes) as Profile;\n if (pulse.state != StateChangeType.Delete) {\n this._perspective.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** -- Methods -- */\n\n /** */\n async probeAllProfiles()/*: Promise<Record<AgentPubKeyB64, ProfileMat>>*/ {\n try {\n await this.zomeProxy.probeProfiles();\n } catch(e) {}\n }\n\n\n /** */\n async findProfile(agentId: AgentId): Promise<Profile | undefined> {\n try {\n const maybeProfilePair = await this.zomeProxy.findProfile(agentId.hash);\n console.log(\"findProfile()\", agentId, maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n } catch(e) {\n return undefined;\n }\n return undefined;\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.createProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n await this.zomeProxy.updateProfile([profile, this.cell.address.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n export(): string {\n const snapshot = this._perspective.makeSnapshot();\n return JSON.stringify(snapshot, null, 2);\n }\n\n\n /** */\n import(json: string, canPublish: boolean) {\n const snapshot = JSON.parse(json, holoIdReviver) as ProfilesAltSnapshot;\n if (canPublish) {\n for (const [agentId, _profileAh, profile, _ts] of snapshot.all) {\n console.log(\"ProfilesAltZvm.import() publish profile\", agentId.short, profile.nickname);\n const maybe = this._perspective.getProfile(agentId);\n if (!maybe) {\n /*await*/ this.createProfile(profile, agentId);\n } else {\n if (maybe != profile) {\n this.updateProfile(profile, agentId);\n }\n }\n }\n return;\n }\n /** */\n this._perspective.restore(snapshot);\n this.notifySubscribers();\n }\n}\n"]}
|