@ddd-qc/profiles-dvm 0.26.6 → 0.26.8
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.js.map +1 -1
- package/dist/profilesAlt.zvm.d.ts +2 -4
- package/dist/profilesAlt.zvm.js +47 -46
- package/dist/profilesAlt.zvm.js.map +1 -1
- package/dist/utils.js +6 -1
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
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,EAAQ,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAIrD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAG3C,MAAM;AACN,4CAA4C;AAC5C,4CAA4C;AAC5C,IAAI;AAGJ;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8B3D,CAAC;IA3BC,kBAAkB;IAClB,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,
|
|
1
|
+
{"version":3,"file":"profiles.dvm.js","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAIrD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAG3C,MAAM;AACN,4CAA4C;AAC5C,4CAA4C;AAC5C,IAAI;AAGJ;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8B3D,CAAC;IA3BC,kBAAkB;IAClB,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAC;IAC7E,CAAC;IAED,wBAAwB;IAEd,UAAU;QAClB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAGD,sBAAsB;IAEtB,MAAM;IACN,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;;AA7Be,kCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,oBAAQ,GAAG,CAAC,WAAW,CAAC,AAAhB,CAAgB","sourcesContent":["import {delay, 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 readonly DEFAULT_BASE_ROLE_NAME = \"profiles\";\n static 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(): unknown {\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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionId, ActionIdMap, AgentId, AgentIdMap, LinkPulseMat,
|
|
1
|
+
import { ActionId, ActionIdMap, AgentId, AgentIdMap, LinkPulseMat, ZomeViewModelWithSignals } from "@ddd-qc/lit-happ";
|
|
2
2
|
import { Profile } from "./bindings/profiles.types";
|
|
3
3
|
import { Timestamp } from "@holochain/client";
|
|
4
4
|
import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
|
|
@@ -39,8 +39,6 @@ export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
39
39
|
handleLinkPulse(pulse: LinkPulseMat, from: AgentId): Promise<void>;
|
|
40
40
|
/** */
|
|
41
41
|
handleEntryPulse(pulse: EntryPulseMat, from: AgentId): Promise<void>;
|
|
42
|
-
/** */
|
|
43
|
-
dumpSignalLogs(signalLogs: SignalLog[]): void;
|
|
44
42
|
/** -- Store -- */
|
|
45
43
|
/** */
|
|
46
44
|
storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp): void;
|
|
@@ -65,5 +63,5 @@ export declare class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
65
63
|
/** Dump perspective as JSON */
|
|
66
64
|
exportPerspective(): string;
|
|
67
65
|
/** */
|
|
68
|
-
importPerspective(json: string,
|
|
66
|
+
importPerspective(json: string, _canPublish: boolean): Promise<void>;
|
|
69
67
|
}
|
package/dist/profilesAlt.zvm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ActionIdMap, AgentId, AgentIdMap,
|
|
1
|
+
import { ActionId, ActionIdMap, AgentId, AgentIdMap, EntryId, StateChangeType, ZomeViewModelWithSignals } from "@ddd-qc/lit-happ";
|
|
2
2
|
import { decode } from "@msgpack/msgpack";
|
|
3
3
|
import { ProfilesAltProxy } from "./bindings/profilesAlt.proxy";
|
|
4
4
|
import { ProfilesLinkType } from "./bindings/profiles.integrity";
|
|
5
|
-
import {
|
|
5
|
+
import { ProfilesAltUnitEnum } from "./bindings/profilesAlt.integrity";
|
|
6
6
|
function createProfilesAltPerspective() {
|
|
7
7
|
return {
|
|
8
8
|
profiles: new ActionIdMap(),
|
|
@@ -91,11 +91,12 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
91
91
|
{
|
|
92
92
|
const agentEh = new EntryId(pulse.base.b64); // Make sure its an EntryHash
|
|
93
93
|
const agentId = AgentId.from(agentEh);
|
|
94
|
+
const profileAh = ActionId.from(pulse.target);
|
|
94
95
|
if (pulse.state == StateChangeType.Delete) {
|
|
95
|
-
this.unstoreAgentProfile(agentId,
|
|
96
|
+
this.unstoreAgentProfile(agentId, profileAh);
|
|
96
97
|
}
|
|
97
98
|
else {
|
|
98
|
-
this.storeAgentProfile(agentId,
|
|
99
|
+
this.storeAgentProfile(agentId, profileAh);
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
break;
|
|
@@ -112,37 +113,37 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
112
113
|
break;
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
/** */
|
|
116
|
-
dumpSignalLogs(signalLogs) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
116
|
+
// /** */
|
|
117
|
+
// dumpSignalLogs(signalLogs: SignalLog[]) {
|
|
118
|
+
// this.dumpCastLogs();
|
|
119
|
+
// console.warn(`Signals received from zome "${this.zomeName}"`);
|
|
120
|
+
// let appSignals: any[] = [];
|
|
121
|
+
// signalLogs
|
|
122
|
+
// .filter((log) => log.type == SignalType.Zome)
|
|
123
|
+
// .map((log) => {
|
|
124
|
+
// const signal = log.zomeSignal as ZomeSignal;
|
|
125
|
+
// const pulses = signal.pulses as ZomeSignalProtocol[];
|
|
126
|
+
// const timestamp = prettyDate(new Date(log.ts));
|
|
127
|
+
// const from = enc64(signal.from) == this.cell.agentId.b64? "self" : new AgentId(signal.from);
|
|
128
|
+
// for (const pulse of pulses) {
|
|
129
|
+
// if (ZomeSignalProtocolType.Tip in pulse) {
|
|
130
|
+
// const tip: TipProtocol = pulse.Tip;
|
|
131
|
+
// const type = Object.keys(tip)[0];
|
|
132
|
+
// appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Tip, type, payload: tip});
|
|
133
|
+
// }
|
|
134
|
+
// if (ZomeSignalProtocolType.Entry in pulse) {
|
|
135
|
+
// const entryPulse = materializeEntryPulse(pulse.Entry, Object.values(ProfilesAltUnitEnum));
|
|
136
|
+
// const typedEntry = decode(entryPulse.bytes);
|
|
137
|
+
// appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Entry, state: prettyState(pulse.Entry.state), type: entryPulse.entryType, payload: typedEntry, ah_base: entryPulse.ah.short, eh_target: entryPulse.eh.short});
|
|
138
|
+
// }
|
|
139
|
+
// if (ZomeSignalProtocolType.Link in pulse) {
|
|
140
|
+
// const linkPulse = materializeLinkPulse(pulse.Link, Object.values(ProfilesAltLinkType));
|
|
141
|
+
// appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Link, state: prettyState(pulse.Link.state), type: linkPulse.link_type, payload: linkPulse.tag, ah_base: linkPulse.base.print(), eh_target: linkPulse.target.print()});
|
|
142
|
+
// }
|
|
143
|
+
// }
|
|
144
|
+
// });
|
|
145
|
+
// console.table(appSignals);
|
|
146
|
+
// }
|
|
146
147
|
/** -- Store -- */
|
|
147
148
|
/** */
|
|
148
149
|
storeProfile(profileAh, profile, ts) {
|
|
@@ -209,20 +210,20 @@ export class ProfilesAltZvm extends ZomeViewModelWithSignals {
|
|
|
209
210
|
return JSON.stringify(core, null, 2);
|
|
210
211
|
}
|
|
211
212
|
/** */
|
|
212
|
-
async importPerspective(json,
|
|
213
|
+
async importPerspective(json, _canPublish) {
|
|
213
214
|
const perspective = JSON.parse(json);
|
|
214
|
-
if (canPublish) {
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
215
|
+
// if (canPublish) {
|
|
216
|
+
// for (const [profileAh, [profile, _ts]] of perspective.profiles.entries()) {
|
|
217
|
+
// await this.createProfile(profile, agentId);
|
|
218
|
+
// }
|
|
219
|
+
// return;
|
|
220
|
+
// }
|
|
220
221
|
/** */
|
|
221
|
-
for (const [
|
|
222
|
-
this.storeProfile(
|
|
222
|
+
for (const [profileAh, [profile, ts]] of perspective.profiles.entries()) {
|
|
223
|
+
this.storeProfile(profileAh, profile, ts);
|
|
223
224
|
}
|
|
224
|
-
for (const [agentId,
|
|
225
|
-
this.storeAgentProfile(agentId,
|
|
225
|
+
for (const [agentId, profileAh] of perspective.profileByAgent.entries()) {
|
|
226
|
+
this.storeAgentProfile(agentId, profileAh);
|
|
226
227
|
}
|
|
227
228
|
}
|
|
228
229
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,OAAO,EACP,UAAU,EACV,KAAK,EACL,OAAO,EACO,qBAAqB,EAAE,oBAAoB,EACzD,UAAU,EACV,WAAW,EAEX,UAAU,EAAE,eAAe,EAI3B,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,kBAAkB,CAAC;AAG1B,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,EAAE,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAmB1F,SAAS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;QACvD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA+B,CAAC;QACnE,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE;gBACtE,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;aAC5C;YACD,OAAO;SACR;QACD,MAAM;QACN,KAAK,MAAM,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE;YACtE,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;SAC1C;QACD,KAAK,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE;YACtE,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;SAC3C;IACH,CAAC;;AA5Pe,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId,\n ActionIdMap,\n AgentId,\n AgentIdMap,\n enc64,\n EntryId,\n LinkPulseMat, materializeEntryPulse, materializeLinkPulse,\n prettyDate,\n prettyState,\n SignalLog,\n SignalType, StateChangeType,\n TipProtocol,\n ZomeSignal,\n ZomeSignalProtocol,\n ZomeSignalProtocolType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {Timestamp} from \"@holochain/client\";\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 {ProfilesAltLinkType, ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\n\n\n/** */\nexport interface ProfilesAltPerspectiveCore {\n /* ActionId -> Profile */\n profiles: ActionIdMap<[Profile, Timestamp]>,\n /* AgentId -> ActionId */\n profileByAgent: AgentIdMap<ActionId>,\n}\n\nexport interface ProfilesAltPerspectiveLive {\n /** Nickname -> AgentId */\n agentByName: Record<string, AgentId>,\n}\n\nexport type ProfilesAltPerspective = ProfilesAltPerspectiveCore & ProfilesAltPerspectiveLive;\n\n\nfunction createProfilesAltPerspective(): ProfilesAltPerspective {\n return {\n profiles: new ActionIdMap(),\n profileByAgent: new AgentIdMap(),\n agentByName: {},\n }\n}\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n static readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective;\n }\n\n private _perspective: ProfilesAltPerspective = createProfilesAltPerspective();\n\n\n /** -- Getters -- */\n\n getProfileAgent(profileId: ActionId): AgentId | undefined {\n for (const [agentId, profId] of this._perspective.profileByAgent.entries()) {\n if (profileId.b64 == profId.b64) {\n return agentId;\n }\n }\n return undefined;\n }\n\n getMyProfile(): Profile | undefined {\n return this.getProfile(this.cell.agentId);\n }\n\n getProfile(agent: AgentId): Profile | undefined {\n const profileAh = this._perspective.profileByAgent.get(agent);\n console.log(\"ProfilesAltZvm.getProfile()\", agent, profileAh);\n if (!profileAh) {\n return undefined;\n }\n const pair = this._perspective.profiles.get(profileAh);\n console.log(\"ProfilesAltZvm.getProfile() pair\", pair);\n if (!pair) {\n return undefined;\n }\n return pair[0];\n }\n\n getProfileTs(agent: AgentId): Timestamp | undefined {\n const profileAh = this._perspective.profileByAgent.get(agent);\n if (!profileAh) {\n return undefined;\n }\n const pair = this._perspective.profiles.get(profileAh);\n return pair[1];\n }\n\n getAgents(): AgentId[] { return Array.from(this._perspective.profileByAgent.keys())}\n\n getNames(): string[] { return Object.keys(this._perspective.agentByName)}\n\n\n /** -- Signals -- */\n\n /** */\n async handleLinkPulse(pulse: LinkPulseMat, from: AgentId): Promise<void> {\n /** */\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 if (pulse.state == StateChangeType.Delete) {\n this.unstoreAgentProfile(agentId, pulse.target)\n } else {\n this.storeAgentProfile(agentId, pulse.target)\n }\n }\n break;\n }\n }\n\n\n /** */\n 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.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n /** */\n dumpSignalLogs(signalLogs: SignalLog[]) {\n this.dumpCastLogs();\n console.warn(`Signals received from zome \"${this.zomeName}\"`);\n let appSignals: any[] = [];\n signalLogs\n .filter((log) => log.type == SignalType.Zome)\n .map((log) => {\n const signal = log.zomeSignal as ZomeSignal;\n const pulses = signal.pulses as ZomeSignalProtocol[];\n const timestamp = prettyDate(new Date(log.ts));\n const from = enc64(signal.from) == this.cell.agentId.b64? \"self\" : new AgentId(signal.from);\n for (const pulse of pulses) {\n if (ZomeSignalProtocolType.Tip in pulse) {\n const tip: TipProtocol = pulse.Tip;\n const type = Object.keys(tip)[0];\n appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Tip, type, payload: tip});\n }\n if (ZomeSignalProtocolType.Entry in pulse) {\n const entryPulse = materializeEntryPulse(pulse.Entry, Object.values(ProfilesAltUnitEnum));\n const typedEntry = decode(entryPulse.bytes);\n appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Entry, state: prettyState(pulse.Entry.state), type: entryPulse.entryType, payload: typedEntry, ah_base: entryPulse.ah.short, eh_target: entryPulse.eh.short});\n }\n if (ZomeSignalProtocolType.Link in pulse) {\n const linkPulse = materializeLinkPulse(pulse.Link, Object.values(ProfilesAltLinkType));\n appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Link, state: prettyState(pulse.Link.state), type: linkPulse.link_type, payload: linkPulse.tag, ah_base: linkPulse.base.print(), eh_target: linkPulse.target.print()});\n }\n }\n });\n console.table(appSignals);\n }\n\n\n /** -- Store -- */\n\n /** */\n storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp) {\n console.log(\"ProfilesAltZvm.storeProfile()\", profileAh, profile.nickname);\n this._perspective.profiles.set(profileAh, [profile, ts]);\n const agentId = this.getProfileAgent(profileAh);\n if (agentId) {\n this._perspective.agentByName[profile.nickname] = agentId;\n }\n }\n\n /** */\n storeAgentProfile(agentId: AgentId, profileAh: ActionId) {\n console.log(\"ProfilesAltZvm.storeAgentProfile()\", agentId, profileAh);\n this._perspective.profileByAgent.set(agentId, profileAh);\n const pair = this._perspective.profiles.get(profileAh);\n if (pair) {\n this._perspective.agentByName[pair[0].nickname] = agentId;\n }\n }\n\n /** */\n unstoreAgentProfile(agentId: AgentId, profileAh: ActionId) {\n console.log(\"ProfilesAltZvm.unstoreAgentProfile()\", agentId, profileAh);\n this._perspective.profileByAgent.delete(agentId);\n const pair = this._perspective.profiles.get(profileAh);\n if (pair) {\n delete this._perspective.agentByName[pair[0].nickname];\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() maybeProfilePair\", maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, this.cell.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, this.cell.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n //console.log(\"exportPerspective()\", perspMat);\n const core = this._perspective as ProfilesAltPerspectiveCore; // FIXME: check if this actually works as expected\n return JSON.stringify(core, null, 2);\n }\n\n\n /** */\n async importPerspective(json: string, canPublish: boolean) {\n const perspective = JSON.parse(json) as ProfilesAltPerspectiveCore;\n if (canPublish) {\n for (const [agentId, [profile, _ts]] of perspective.profiles.entries()) {\n await this.createProfile(profile, agentId);\n }\n return;\n }\n /** */\n for (const [actionId, [profile, ts]] of perspective.profiles.entries()) {\n this.storeProfile(actionId, profile, ts);\n }\n for (const [agentId, actionId] of perspective.profileByAgent.entries()) {\n this.storeAgentProfile(agentId, actionId);\n }\n }\n\n\n}\n"]}
|
|
1
|
+
{"version":3,"file":"profilesAlt.zvm.js","sourceRoot":"","sources":["../src/profilesAlt.zvm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,WAAW,EACX,OAAO,EACP,U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,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;SAC3C;QACD,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,WAAW,CAAC,cAAc,CAAC,OAAO,EAAE,EAAE;YACvE,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;SAC5C;IACH,CAAC;;AA7Pe,yBAAU,GAAG,gBAAgB,AAAnB,CAAoB","sourcesContent":["import {\n ActionId,\n ActionIdMap,\n AgentId,\n AgentIdMap,\n enc64,\n EntryId,\n LinkPulseMat, materializeEntryPulse, materializeLinkPulse,\n prettyDate,\n prettyState,\n SignalLog,\n SignalType, StateChangeType,\n TipProtocol,\n ZomeSignal,\n ZomeSignalProtocol,\n ZomeSignalProtocolType,\n ZomeViewModelWithSignals\n} from \"@ddd-qc/lit-happ\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {Timestamp} from \"@holochain/client\";\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 {ProfilesAltLinkType, ProfilesAltUnitEnum} from \"./bindings/profilesAlt.integrity\";\n\n\n/** */\nexport interface ProfilesAltPerspectiveCore {\n /* ActionId -> Profile */\n profiles: ActionIdMap<[Profile, Timestamp]>,\n /* AgentId -> ActionId */\n profileByAgent: AgentIdMap<ActionId>,\n}\n\nexport interface ProfilesAltPerspectiveLive {\n /** Nickname -> AgentId */\n agentByName: Record<string, AgentId>,\n}\n\nexport type ProfilesAltPerspective = ProfilesAltPerspectiveCore & ProfilesAltPerspectiveLive;\n\n\nfunction createProfilesAltPerspective(): ProfilesAltPerspective {\n return {\n profiles: new ActionIdMap(),\n profileByAgent: new AgentIdMap(),\n agentByName: {},\n }\n}\n\n\n/**\n *\n */\nexport class ProfilesAltZvm extends ZomeViewModelWithSignals {\n\n static readonly ZOME_PROXY = ProfilesAltProxy;\n get zomeProxy(): ProfilesAltProxy {return this._zomeProxy as ProfilesAltProxy;}\n\n\n /* */\n protected hasChanged(): boolean {\n // TODO\n return true;\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n await this.probeAllProfiles();\n }\n\n /** */\n probeAllInner() {\n this.probeAllProfiles();\n }\n\n /** -- Perspective -- */\n\n /* */\n get perspective(): ProfilesAltPerspective {\n return this._perspective;\n }\n\n private _perspective: ProfilesAltPerspective = createProfilesAltPerspective();\n\n\n /** -- Getters -- */\n\n getProfileAgent(profileId: ActionId): AgentId | undefined {\n for (const [agentId, profId] of this._perspective.profileByAgent.entries()) {\n if (profileId.b64 == profId.b64) {\n return agentId;\n }\n }\n return undefined;\n }\n\n getMyProfile(): Profile | undefined {\n return this.getProfile(this.cell.agentId);\n }\n\n getProfile(agent: AgentId): Profile | undefined {\n const profileAh = this._perspective.profileByAgent.get(agent);\n console.log(\"ProfilesAltZvm.getProfile()\", agent, profileAh);\n if (!profileAh) {\n return undefined;\n }\n const pair = this._perspective.profiles.get(profileAh);\n console.log(\"ProfilesAltZvm.getProfile() pair\", pair);\n if (!pair) {\n return undefined;\n }\n return pair[0];\n }\n\n getProfileTs(agent: AgentId): Timestamp | undefined {\n const profileAh = this._perspective.profileByAgent.get(agent);\n if (!profileAh) {\n return undefined;\n }\n const pair = this._perspective.profiles.get(profileAh);\n return pair[1];\n }\n\n getAgents(): AgentId[] { return Array.from(this._perspective.profileByAgent.keys())}\n\n getNames(): string[] { return Object.keys(this._perspective.agentByName)}\n\n\n /** -- Signals -- */\n\n /** */\n async handleLinkPulse(pulse: LinkPulseMat, from: AgentId): Promise<void> {\n /** */\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.unstoreAgentProfile(agentId, profileAh)\n } else {\n this.storeAgentProfile(agentId, profileAh)\n }\n }\n break;\n }\n }\n\n\n /** */\n 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.storeProfile(pulse.ah, profile, pulse.ts);\n }\n break;\n }\n }\n\n\n // /** */\n // dumpSignalLogs(signalLogs: SignalLog[]) {\n // this.dumpCastLogs();\n // console.warn(`Signals received from zome \"${this.zomeName}\"`);\n // let appSignals: any[] = [];\n // signalLogs\n // .filter((log) => log.type == SignalType.Zome)\n // .map((log) => {\n // const signal = log.zomeSignal as ZomeSignal;\n // const pulses = signal.pulses as ZomeSignalProtocol[];\n // const timestamp = prettyDate(new Date(log.ts));\n // const from = enc64(signal.from) == this.cell.agentId.b64? \"self\" : new AgentId(signal.from);\n // for (const pulse of pulses) {\n // if (ZomeSignalProtocolType.Tip in pulse) {\n // const tip: TipProtocol = pulse.Tip;\n // const type = Object.keys(tip)[0];\n // appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Tip, type, payload: tip});\n // }\n // if (ZomeSignalProtocolType.Entry in pulse) {\n // const entryPulse = materializeEntryPulse(pulse.Entry, Object.values(ProfilesAltUnitEnum));\n // const typedEntry = decode(entryPulse.bytes);\n // appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Entry, state: prettyState(pulse.Entry.state), type: entryPulse.entryType, payload: typedEntry, ah_base: entryPulse.ah.short, eh_target: entryPulse.eh.short});\n // }\n // if (ZomeSignalProtocolType.Link in pulse) {\n // const linkPulse = materializeLinkPulse(pulse.Link, Object.values(ProfilesAltLinkType));\n // appSignals.push({timestamp, from, pulse: ZomeSignalProtocolType.Link, state: prettyState(pulse.Link.state), type: linkPulse.link_type, payload: linkPulse.tag, ah_base: linkPulse.base.print(), eh_target: linkPulse.target.print()});\n // }\n // }\n // });\n // console.table(appSignals);\n // }\n\n\n /** -- Store -- */\n\n /** */\n storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp) {\n console.log(\"ProfilesAltZvm.storeProfile()\", profileAh, profile.nickname);\n this._perspective.profiles.set(profileAh, [profile, ts]);\n const agentId = this.getProfileAgent(profileAh);\n if (agentId) {\n this._perspective.agentByName[profile.nickname] = agentId;\n }\n }\n\n /** */\n storeAgentProfile(agentId: AgentId, profileAh: ActionId) {\n console.log(\"ProfilesAltZvm.storeAgentProfile()\", agentId, profileAh);\n this._perspective.profileByAgent.set(agentId, profileAh);\n const pair = this._perspective.profiles.get(profileAh);\n if (pair) {\n this._perspective.agentByName[pair[0].nickname] = agentId;\n }\n }\n\n /** */\n unstoreAgentProfile(agentId: AgentId, profileAh: ActionId) {\n console.log(\"ProfilesAltZvm.unstoreAgentProfile()\", agentId, profileAh);\n this._perspective.profileByAgent.delete(agentId);\n const pair = this._perspective.profiles.get(profileAh);\n if (pair) {\n delete this._perspective.agentByName[pair[0].nickname];\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() maybeProfilePair\", maybeProfilePair);\n if (!maybeProfilePair) {\n return;\n }\n return maybeProfilePair[1];\n }\n\n\n /** */\n async createMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, this.cell.agentId.hash]);\n }\n\n\n /** */\n async updateMyProfile(profile: Profile): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, this.cell.agentId.hash]);\n }\n\n\n /** */\n async createProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.createProfile([profile, agentId.hash]);\n }\n\n\n /** */\n async updateProfile(profile: Profile, agentId: AgentId): Promise<void> {\n const _ah = await this.zomeProxy.updateProfile([profile, agentId.hash]);\n }\n\n\n\n /** -- Import / Export -- */\n\n /** Dump perspective as JSON */\n exportPerspective(): string {\n //console.log(\"exportPerspective()\", perspMat);\n const core = this._perspective as ProfilesAltPerspectiveCore; // FIXME: check if this actually works as expected\n return JSON.stringify(core, null, 2);\n }\n\n\n /** */\n async importPerspective(json: string, _canPublish: boolean) {\n const perspective = JSON.parse(json) as ProfilesAltPerspectiveCore;\n // if (canPublish) {\n // for (const [profileAh, [profile, _ts]] of perspective.profiles.entries()) {\n // await this.createProfile(profile, agentId);\n // }\n // return;\n // }\n /** */\n for (const [profileAh, [profile, ts]] of perspective.profiles.entries()) {\n this.storeProfile(profileAh, profile, ts);\n }\n for (const [agentId, profileAh] of perspective.profileByAgent.entries()) {\n this.storeAgentProfile(agentId, profileAh);\n }\n }\n\n\n}\n"]}
|
package/dist/utils.js
CHANGED
|
@@ -13,8 +13,13 @@ export function getInitials(nickname) {
|
|
|
13
13
|
}
|
|
14
14
|
/** */
|
|
15
15
|
export function agent2avatar(key, profilesPerspective) {
|
|
16
|
+
const maybeProfileId = profilesPerspective.profileByAgent.get(key);
|
|
17
|
+
if (!maybeProfileId) {
|
|
18
|
+
console.log("ProfileAh not found for agent", key, profilesPerspective.profiles);
|
|
19
|
+
throw Error("ProfileAh not found for agent");
|
|
20
|
+
}
|
|
16
21
|
let profile = { nickname: "unknown", fields: {} };
|
|
17
|
-
const maybeProfilePair = profilesPerspective.profiles.get(
|
|
22
|
+
const maybeProfilePair = profilesPerspective.profiles.get(maybeProfileId);
|
|
18
23
|
if (maybeProfilePair) {
|
|
19
24
|
profile = maybeProfilePair[0];
|
|
20
25
|
}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,IAAI,EAAiB,MAAM,KAAK,CAAC;AAGzC,MAAM;AACN,MAAM,UAAU,WAAW,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACtD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAClB,QAAQ,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;KACrE;SAAM;QACH,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KACxC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAID,MAAM;AACN,MAAM,UAAU,YAAY,CAAC,GAAY,EAAE,mBAA2C;IAClF,IAAI,OAAO,GAAG,EAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAe,CAAC;IAC9D,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,IAAI,EAAiB,MAAM,KAAK,CAAC;AAGzC,MAAM;AACN,MAAM,UAAU,WAAW,CAAC,QAAgB;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAA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A;;yBAEE,SAAS;;aAErB,CAAC,CAAC,CAAC,IAAI,CAAA;oEACgD,QAAQ;iBAC3D,CAAC;IACd,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import {ProfilesAltPerspective} from \"./profilesAlt.zvm\";\nimport {Profile as ProfileMat} from \"./bindings/profiles.types\";\nimport {html, TemplateResult} from \"lit\";\nimport {AgentId} from \"@ddd-qc/cell-proxy\";\n\n/** */\nexport function getInitials(nickname: string): string {\n const names = nickname.split(' ');\n let initials = names[0].substring(0, 1).toUpperCase();\n if (names.length > 1) {\n initials += names[names.length - 1].substring(0, 1).toUpperCase();\n } else {\n initials += names[0].substring(1, 2);\n }\n return initials;\n}\n\n\n\n/** */\nexport function agent2avatar(key: AgentId, profilesPerspective: ProfilesAltPerspective): [ProfileMat, TemplateResult<1>] {\n const maybeProfileId = profilesPerspective.profileByAgent.get(key);\n if (!maybeProfileId) {\n console.log(\"ProfileAh not found for agent\", key, profilesPerspective.profiles);\n throw Error(\"ProfileAh not found for agent\")\n }\n let profile = {nickname: \"unknown\", fields: {}} as ProfileMat;\n const maybeProfilePair = profilesPerspective.profiles.get(maybeProfileId);\n if (maybeProfilePair) {\n profile = maybeProfilePair[0]\n } else {\n console.log(\"Profile not found for agent\", key, profilesPerspective.profiles);\n }\n const initials = getInitials(profile.nickname);\n const avatarUrl = profile.fields['avatar'];\n const avatar =\n avatarUrl? html`\n <sl-avatar class=\"activityAvatar\" style=\"box-shadow: 1px 1px 1px 1px rgba(130, 122, 122, 0.88)\">\n <img src=${avatarUrl}>\n </sl-avatar> \n ` : html`\n <sl-avatar class=\"activityAvatar\" shape=\"circle\" initials=${initials} color-scheme=\"Accent2\"></sl-avatar>\n `;\n return [profile, avatar];\n}\n"]}
|