@ddd-qc/profiles-dvm 0.29.3 → 0.30.3

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 +1 @@
1
- {"version":3,"file":"edit-profile.d.ts","sourceRoot":"","sources":["../../src/elements/edit-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAC,MAAM,KAAK,CAAC;AAK1C,OAAO,6DAA6D,CAAC;AACrE,OAAO,EAAC,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAoBtD,qBAEa,WAAY,SAAQ,UAAU;IAKzC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAQvB,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAwBlD,gBAAgB,CAAC,EAAE,EAAE,GAAG;IAWrB,MAAM;IA8Cf,OAAgB,MAAM,0DA6DhB;CACP"}
1
+ {"version":3,"file":"edit-profile.d.ts","sourceRoot":"","sources":["../../src/elements/edit-profile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,UAAU,EAAC,MAAM,KAAK,CAAC;AAK1C,OAAO,6DAA6D,CAAC;AACrE,OAAO,EAAC,OAAO,EAAC,MAAM,+BAA+B,CAAC;AAiBtD,qBAEa,WAAY,SAAQ,UAAU;IAKzC,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAQvB,eAAe,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAwBlD,gBAAgB,CAAC,EAAE,EAAE,GAAG;IAWrB,MAAM;IA8Cf,OAAgB,MAAM,0DA6DhB;CACP"}
@@ -1 +1 @@
1
- {"version":3,"file":"edit-profile.js","sourceRoot":"","sources":["../../src/elements/edit-profile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,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0BAA0B,EAAE,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxG,CAAC;IAIQ,MAAM;QACb,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAG9D,OAAO,IAAI,CAAA;;UAEL,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAW,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;;;;;;;yBAO3C,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,IAAI,SAAS;;;;;;qBAM/C,GAAG,CAAC,UAAU,CAAC;;wBAEZ,mBAAmB;qBACtB,IAAI,CAAC,OAAO,EAAE,QAAQ,IAAI,EAAE;wBACzB,GAAG,CAAC,GAAG,CAAA,QAAQ,mBAAmB,aAAa,CAAC;;;;;;6DAMX,GAAG,CAAC,UAAU,CAAC;uDACrB,IAAI,CAAC,gBAAgB,WAAW,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;;;;;;;;eAQpG,GAAG,CAAC,cAAc,CAAC;;;;KAI7B,CAAC;IACJ,CAAC;;AAGe,kBAAM,GAAG,CAAC,YAAY,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6DvC,CAAC,AA7DiB,CA6DhB;AAtJN;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACE;AALlB,WAAW;IAFvB,SAAS,EAAE;IACX,aAAa,CAAC,uBAAuB,CAAC;GAC1B,WAAW,CA4JvB","sourcesContent":["import {css, html, LitElement} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { localized, msg, str } from '@lit/localize';\nimport { onSubmit, sharedStyles } from '@holochain-open-dev/elements';\n\nimport '@holochain-open-dev/elements/dist/elements/select-avatar.js';\nimport {Profile} from \"../bindings/profilesAlt.types\";\n\n\n\n//import \"@shoelace-style/shoelace/dist/components/avatar/avatar.js\";\n//import \"@shoelace-style/shoelace/dist/components/button/button.js\";\n//import \"@shoelace-style/shoelace/dist/components/icon/icon.js\";\n//import \"@shoelace-style/shoelace/dist/components/input/input.js\";\n//import \"@shoelace-style/shoelace/dist/components/radio/radio.js\";\n//import \"@shoelace-style/shoelace/dist/components/radio-group/radio-group.js\";\n//import \"@shoelace-style/shoelace/dist/components/tooltip/tooltip.js\";\n\n\n\nconst MIN_NICKNAME_LENGTH = 2\n\n\n/**\n * @fires save-profile - Fired when the save profile button is clicked\n */\n@localized()\n@customElement('profiles-edit-profile')\nexport class EditProfile extends LitElement {\n\n\n /** The profile to be edited. */\n @property({ type: Object })\n profile: Profile | undefined;\n\n\n /** -- Methods -- */\n\n /**\n * Seperate Mailgun token from other fields as we don't want it to be saved in Profiles\n */\n async fireSaveProfile(formFields: Record<string, string>) {\n console.log(\"fireSaveProfile()\", formFields);\n const nickname = formFields['nickname'];\n delete formFields['nickname'];\n\n const fields: Record<string, string> = {}\n //fields['email'] = formFields['email'];\n fields['avatar'] = formFields['avatar']? formFields['avatar'] : \"\";\n fields['lang'] = formFields['option']? formFields['option'] : \"\";\n\n\n /** */\n this.dispatchEvent(\n new CustomEvent<Profile>('save-profile', {\n detail: {nickname, fields} as Profile,\n bubbles: true,\n composed: true,\n })\n );\n\n }\n\n\n /** */\n async handleLangChange(_e: any) {\n //console.log({langChangeEvent: e});\n const langRadioGroup = this.shadowRoot!.getElementById(\"langRadioGroup\") as any;\n console.log({langRadioGroup});\n const lang = langRadioGroup.value;\n console.log(\"handleLangChange: lang =\", lang);\n this.dispatchEvent(new CustomEvent('lang-selected', { detail: lang, bubbles: true, composed: true }));\n }\n\n\n /** */\n override render() {\n console.log(\"<profiles-edit-profile>.render()\", this.profile);\n\n /** */\n return html`\n <form id=\"profile-form\" class=\"column\"\n ${onSubmit(fields => /*await*/ this.fireSaveProfile(fields))}>\n \n <div class=\"row\"\n style=\"justify-content: center; align-self: start; margin-bottom: 16px; width: 100%;\">\n <select-avatar\n style=\"cursor:pointer\"\n name=\"avatar\"\n .value=${this.profile?.fields['avatar'] || undefined}\n ></select-avatar>\n <label for=\"nickname\">Nickname:</label>\n <input\n type=\"text\"\n name=\"nickname\"\n .label=${msg('Nickname')}\n required\n minLength=${MIN_NICKNAME_LENGTH}\n .value=${this.profile?.nickname || ''}\n .helpText=${msg(str`Min. ${MIN_NICKNAME_LENGTH} characters`)}\n style=\"margin-left: 16px;\"\n >\n </div>\n \n <div class=\"row\" style=\"justify-content: center; margin-bottom: 8px; align-self: start;\" >\n <span style=\"font-size:18px;padding-right:10px;\">${msg('Language')}:</span>\n <sl-radio-group id=\"langRadioGroup\" @click=${this.handleLangChange} .value=${this.profile?.fields['lang']}>\n <sl-radio value=\"en\">🇬🇧</sl-radio>\n <sl-radio value=\"fr-fr\">🇫🇷</sl-radio>\n </sl-radio-group>\n </div>\n \n <div class=\"row\" style=\"margin-top: 8px;\">\n <button style=\"flex: 1;\" variant=\"primary\" type=\"submit\"\n >${msg('Save Profile')}\n </button>\n </div>\n </form>\n `;\n }\n\n\n static override styles = [sharedStyles, css`\n\n sl-radio {\n font-size: larger;\n }\n .small-margin {\n margin-top: 6px;\n }\n .big-margin {\n margin-top: 23px;\n }\n\n .fill {\n flex: 1;\n height: 100%;\n }\n\n .title {\n font-size: 20px;\n }\n\n .center-content {\n align-items: center;\n justify-content: center;\n }\n\n .placeholder {\n color: rgba(0, 0, 0, 0.7);\n }\n\n .label {\n color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));\n font-family: var(\n --mdc-typography-caption-font-family,\n var(--mdc-typography-font-family, Roboto, sans-serif)\n );\n font-size: var(--mdc-typography-caption-font-size, 0.79rem);\n font-weight: var(--mdc-typography-caption-font-weight, 400);\n }\n\n .flex-scrollable-parent {\n position: relative;\n display: flex;\n flex: 1;\n }\n\n .flex-scrollable-container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .flex-scrollable-x {\n max-width: 100%;\n overflow-x: auto;\n }\n .flex-scrollable-y {\n max-height: 100%;\n overflow-y: auto;\n }`];\n}\n"]}
1
+ {"version":3,"file":"edit-profile.js","sourceRoot":"","sources":["../../src/elements/edit-profile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,GAAG,EAAE,IAAI,EAAE,UAAU,EAAC,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAEtE,OAAO,6DAA6D,CAAC;AAYrE,MAAM,mBAAmB,GAAG,CAAC,CAAA;AAQtB,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAazC,KAAK,CAAC,eAAe,CAAC,UAAkC;QACtD,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;QACxC,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC;QAE9B,MAAM,MAAM,GAA2B,EAAE,CAAA;QAEzC,MAAM,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAA,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAIjE,IAAI,CAAC,aAAa,CAChB,IA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B,CAAC;IACJ,CAAC;;AAGe,kBAAM,GAAG,CAAC,YAAY,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA6DvC,CAAC,AA7DiB,CA6DhB;AAtJN;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CACE;AALlB,WAAW;IAFvB,SAAS,EAAE;IACX,aAAa,CAAC,uBAAuB,CAAC;GAC1B,WAAW,CA4JvB","sourcesContent":["import {css, html, LitElement} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { localized, msg, str } from '@lit/localize';\nimport { onSubmit, sharedStyles } from '@holochain-open-dev/elements';\n\nimport '@holochain-open-dev/elements/dist/elements/select-avatar.js';\nimport {Profile} from \"../bindings/profilesAlt.types\";\n\n//import \"@shoelace-style/shoelace/dist/components/avatar/avatar.js\";\n//import \"@shoelace-style/shoelace/dist/components/button/button.js\";\n//import \"@shoelace-style/shoelace/dist/components/icon/icon.js\";\n//import \"@shoelace-style/shoelace/dist/components/input/input.js\";\n//import \"@shoelace-style/shoelace/dist/components/radio/radio.js\";\n//import \"@shoelace-style/shoelace/dist/components/radio-group/radio-group.js\";\n//import \"@shoelace-style/shoelace/dist/components/tooltip/tooltip.js\";\n\n\nconst MIN_NICKNAME_LENGTH = 2\n\n\n/**\n * @fires save-profile - Fired when the save profile button is clicked\n */\n@localized()\n@customElement('profiles-edit-profile')\nexport class EditProfile extends LitElement {\n\n\n /** The profile to be edited. */\n @property({ type: Object })\n profile: Profile | undefined;\n\n\n /** -- Methods -- */\n\n /**\n * Seperate Mailgun token from other fields as we don't want it to be saved in Profiles\n */\n async fireSaveProfile(formFields: Record<string, string>) {\n console.log(\"fireSaveProfile()\", formFields);\n const nickname = formFields['nickname'];\n delete formFields['nickname'];\n\n const fields: Record<string, string> = {}\n //fields['email'] = formFields['email'];\n fields['avatar'] = formFields['avatar']? formFields['avatar'] : \"\";\n fields['lang'] = formFields['option']? formFields['option'] : \"\";\n\n\n /** */\n this.dispatchEvent(\n new CustomEvent<Profile>('save-profile', {\n detail: {nickname, fields} as Profile,\n bubbles: true,\n composed: true,\n })\n );\n\n }\n\n\n /** */\n async handleLangChange(_e: any) {\n //console.log({langChangeEvent: e});\n const langRadioGroup = this.shadowRoot!.getElementById(\"langRadioGroup\") as any;\n console.log({langRadioGroup});\n const lang = langRadioGroup.value;\n console.log(\"handleLangChange: lang =\", lang);\n this.dispatchEvent(new CustomEvent('lang-selected', { detail: lang, bubbles: true, composed: true }));\n }\n\n\n /** */\n override render() {\n console.log(\"<profiles-edit-profile>.render()\", this.profile);\n\n /** */\n return html`\n <form id=\"profile-form\" class=\"column\"\n ${onSubmit(fields => /*await*/ this.fireSaveProfile(fields))}>\n \n <div class=\"row\"\n style=\"justify-content: center; align-self: start; margin-bottom: 16px; width: 100%;\">\n <select-avatar\n style=\"cursor:pointer\"\n name=\"avatar\"\n .value=${this.profile?.fields['avatar'] || undefined}\n ></select-avatar>\n <label for=\"nickname\">Nickname:</label>\n <input\n type=\"text\"\n name=\"nickname\"\n .label=${msg('Nickname')}\n required\n minLength=${MIN_NICKNAME_LENGTH}\n .value=${this.profile?.nickname || ''}\n .helpText=${msg(str`Min. ${MIN_NICKNAME_LENGTH} characters`)}\n style=\"margin-left: 16px;\"\n >\n </div>\n \n <div class=\"row\" style=\"justify-content: center; margin-bottom: 8px; align-self: start;\" >\n <span style=\"font-size:18px;padding-right:10px;\">${msg('Language')}:</span>\n <sl-radio-group id=\"langRadioGroup\" @click=${this.handleLangChange} .value=${this.profile?.fields['lang']}>\n <sl-radio value=\"en\">🇬🇧</sl-radio>\n <sl-radio value=\"fr-fr\">🇫🇷</sl-radio>\n </sl-radio-group>\n </div>\n \n <div class=\"row\" style=\"margin-top: 8px;\">\n <button style=\"flex: 1;\" variant=\"primary\" type=\"submit\"\n >${msg('Save Profile')}\n </button>\n </div>\n </form>\n `;\n }\n\n\n static override styles = [sharedStyles, css`\n\n sl-radio {\n font-size: larger;\n }\n .small-margin {\n margin-top: 6px;\n }\n .big-margin {\n margin-top: 23px;\n }\n\n .fill {\n flex: 1;\n height: 100%;\n }\n\n .title {\n font-size: 20px;\n }\n\n .center-content {\n align-items: center;\n justify-content: center;\n }\n\n .placeholder {\n color: rgba(0, 0, 0, 0.7);\n }\n\n .label {\n color: var(--mdc-text-field-label-ink-color, rgba(0, 0, 0, 0.6));\n font-family: var(\n --mdc-typography-caption-font-family,\n var(--mdc-typography-font-family, Roboto, sans-serif)\n );\n font-size: var(--mdc-typography-caption-font-size, 0.79rem);\n font-weight: var(--mdc-typography-caption-font-weight, 400);\n }\n\n .flex-scrollable-parent {\n position: relative;\n display: flex;\n flex: 1;\n }\n\n .flex-scrollable-container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n }\n\n .flex-scrollable-x {\n max-width: 100%;\n overflow-x: auto;\n }\n .flex-scrollable-y {\n max-height: 100%;\n overflow-y: auto;\n }`];\n}\n"]}
@@ -1,12 +1,12 @@
1
1
  import { DnaViewModel } from "@ddd-qc/lit-happ";
2
- import { AppSignal, AppSignalCb } from "@holochain/client";
2
+ import { Signal, SignalCb } from "@holochain/client";
3
3
  import { ProfilesZvm } from "./profiles.zvm";
4
4
  export declare class ProfilesDvm extends DnaViewModel {
5
5
  static readonly DEFAULT_BASE_ROLE_NAME = "profiles";
6
6
  static readonly ZVM_DEFS: (typeof ProfilesZvm)[];
7
- readonly signalHandler?: AppSignalCb;
7
+ readonly signalHandler?: SignalCb;
8
8
  get profilesZvm(): ProfilesZvm;
9
9
  get perspective(): Object;
10
- handleSignal(signal: AppSignal): void;
10
+ handleSignal(signal: Signal): void;
11
11
  }
12
12
  //# 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;IAKD,IAAI,WAAW,IAAI,MAAM,CAExB;IAMD,YAAY,CAAC,MAAM,EAAE,SAAS;CAQ/B"}
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,EAEL,MAAM,EAAE,QAAQ,EACjB,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,QAAQ,CAAqB;IAItD,IAAI,WAAW,IAAI,WAAW,CAE7B;IAKD,IAAI,WAAW,IAAI,MAAM,CAExB;IAMD,YAAY,CAAC,MAAM,EAAE,MAAM;CAY5B"}
@@ -1,4 +1,5 @@
1
1
  import { DnaViewModel } from "@ddd-qc/lit-happ";
2
+ import { SignalType, } from "@holochain/client";
2
3
  import { ProfilesZvm } from "./profiles.zvm";
3
4
  export class ProfilesDvm extends DnaViewModel {
4
5
  constructor() {
@@ -12,8 +13,11 @@ export class ProfilesDvm extends DnaViewModel {
12
13
  return {};
13
14
  }
14
15
  handleSignal(signal) {
15
- console.log("Received Signal", signal);
16
- if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {
16
+ if (!(SignalType.App in signal)) {
17
+ return;
18
+ }
19
+ const appSignal = signal.App;
20
+ if (appSignal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {
17
21
  return;
18
22
  }
19
23
  }
@@ -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;IA2B3D,CAAC;IAvBC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAC;IAC7E,CAAC;IAKD,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;;AA1BwB,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\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"]}
1
+ {"version":3,"file":"profiles.dvm.js","sourceRoot":"","sources":["../src/profiles.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAEa,UAAU,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAY3C,MAAM,OAAO,WAAY,SAAQ,YAAY;IAA7C;;QAIW,kBAAa,GAAc,IAAI,CAAC,YAAY,CAAC;IA+BxD,CAAC;IA3BC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,iBAAiB,CAAgB,CAAC;IAC7E,CAAC;IAKD,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAMD,YAAY,CAAC,MAAc;QAEzB,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;YAC/B,OAAO;SACR;QACD,MAAM,SAAS,GAAc,MAAM,CAAC,GAAG,CAAC;QACxC,IAAI,SAAS,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACzD,OAAO;SACR;IACH,CAAC;;AA9BwB,kCAAsB,GAAG,UAAU,AAAb,CAAc;AACpC,oBAAQ,GAAG,CAAC,WAAW,CAAC,AAAhB,CAAgB","sourcesContent":["import {DnaViewModel} from \"@ddd-qc/lit-happ\";\nimport {\n AppSignal,\n Signal, SignalCb, SignalType,\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?: SignalCb = 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\n get perspective(): Object {\n return {}\n }\n\n\n /** -- Signaling -- */\n\n /** */\n handleSignal(signal: Signal) {\n //console.log(\"profilesZvm Received Signal\", signal);\n if (!(SignalType.App in signal)) {\n return;\n }\n const appSignal: AppSignal = signal.App;\n if (appSignal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {\n return;\n }\n }\n\n\n}\n"]}
@@ -1,13 +1,13 @@
1
1
  import { DnaViewModel } from "@ddd-qc/lit-happ";
2
- import { AppSignal, AppSignalCb } from "@holochain/client";
2
+ import { Signal, SignalCb } from "@holochain/client";
3
3
  import { ProfilesAltZvm } from "./profilesAlt.zvm";
4
4
  export declare class ProfilesAltDvm extends DnaViewModel {
5
5
  static readonly DEFAULT_BASE_ROLE_NAME = "profiles";
6
6
  static readonly ZVM_DEFS: (typeof ProfilesAltZvm)[];
7
- readonly signalHandler?: AppSignalCb;
7
+ readonly signalHandler?: SignalCb;
8
8
  get profilesZvm(): ProfilesAltZvm;
9
9
  get perspective(): Object;
10
- handleSignal(signal: AppSignal): void;
10
+ handleSignal(signal: Signal): void;
11
11
  exportPerspective(): string;
12
12
  importPerspective(json: string, canPublish: boolean): Promise<void>;
13
13
  }
@@ -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;AAMjD,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,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
+ {"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,EAEL,MAAM,EAAE,QAAQ,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAMjD,qBAAa,cAAe,SAAQ,YAAY;IAE9C,gBAAyB,sBAAsB,cAAc;IAC7D,gBAAyB,QAAQ,4BAAmB;IACpD,QAAQ,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAqB;IAItD,IAAI,WAAW,IAAI,cAAc,CAEhC;IAID,IAAI,WAAW,IAAI,MAAM,CAExB;IAMD,YAAY,CAAC,MAAM,EAAE,MAAM;IAe3B,iBAAiB,IAAI,MAAM;IASrB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO;CAQ1D"}
@@ -1,4 +1,5 @@
1
1
  import { DnaViewModel, holoIdReviver } from "@ddd-qc/lit-happ";
2
+ import { SignalType, } from "@holochain/client";
2
3
  import { ProfilesZvm } from "./profiles.zvm";
3
4
  import { ProfilesAltZvm } from "./profilesAlt.zvm";
4
5
  export class ProfilesAltDvm extends DnaViewModel {
@@ -13,8 +14,11 @@ export class ProfilesAltDvm extends DnaViewModel {
13
14
  return {};
14
15
  }
15
16
  handleSignal(signal) {
16
- console.log("Received Signal", signal);
17
- if (signal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {
17
+ if (!(SignalType.App in signal)) {
18
+ return;
19
+ }
20
+ const appSignal = signal.App;
21
+ if (appSignal.zome_name !== ProfilesZvm.DEFAULT_ZOME_NAME) {
18
22
  return;
19
23
  }
20
24
  }
@@ -1 +1 @@
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;AAMjD,MAAM,OAAO,cAAe,SAAQ,YAAY;IAAhD;;QAIW,kBAAa,GAAiB,IAAI,CAAC,YAAY,CAAC;IA8C3D,CAAC;IA1CC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,iBAAiB,CAAmB,CAAA;IAClF,CAAC;IAID,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;;AA7CwB,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/**\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 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
+ {"version":3,"file":"profilesAlt.dvm.js","sourceRoot":"","sources":["../src/profilesAlt.dvm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAEa,UAAU,GAC7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AAMjD,MAAM,OAAO,cAAe,SAAQ,YAAY;IAAhD;;QAIW,kBAAa,GAAc,IAAI,CAAC,YAAY,CAAC;IAkDxD,CAAC;IA9CC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,iBAAiB,CAAmB,CAAA;IAClF,CAAC;IAID,IAAI,WAAW;QACb,OAAO,EAAE,CAAA;IACX,CAAC;IAMD,YAAY,CAAC,MAAc;QAEzB,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,EAAE;YAC/B,OAAO;SACR;QACD,MAAM,SAAS,GAAc,MAAM,CAAC,GAAG,CAAC;QACxC,IAAI,SAAS,CAAC,SAAS,KAAK,WAAW,CAAC,iBAAiB,EAAE;YACzD,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,\n Signal, SignalCb, SignalType,\n} from \"@holochain/client\";\nimport {ProfilesZvm} from \"./profiles.zvm\";\nimport {ProfilesAltZvm} from \"./profilesAlt.zvm\";\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?: SignalCb = 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 get perspective(): Object {\n return {}\n }\n\n\n /** -- Signaling -- */\n\n /** */\n handleSignal(signal: Signal) {\n //console.log(\"ProfilesAltDvm Received Signal\", signal);\n if (!(SignalType.App in signal)) {\n return;\n }\n const appSignal: AppSignal = signal.App;\n if (appSignal.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 +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;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;YA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,CAAC;IAMD,KAAK,CAAC,qBAAqB,CAAC,QAAgB,EAAE,EAAc,EAAE,MAA+B;QAC3F,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAY,EAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAC,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"]}
1
+ {"version":3,"file":"profil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IdMap, AgentId, AgentIdMap, assertAllDefined} from \"@ddd-qc/cell-proxy\";\nimport {Profile} from \"./bindings/profiles.types\";\nimport {Timestamp} from \"@holochain/client\";\n\n\n/** */\nexport type ProfilesAltSnapshot = {\n all: [AgentId, ActionId, Profile, Timestamp][];\n}\n\n\nexport type ProfilesAltComparable = {\n profileCount: number,\n profiles: Profile[],\n}\n\n/** */\nexport class ProfilesAltPerspective {\n /* ActionId -> Profile */\n profiles: ActionIdMap<[Profile, Timestamp]> = new ActionIdMap();\n /* AgentId -> ActionId */\n profileByAgent: AgentIdMap<ActionId> = new AgentIdMap();\n\n /** -- Extra -- */\n /* Name -> AgentId */\n agentByName: Record<string, AgentId> = {};\n\n\n /** -- Getters -- */\n\n get agents(): AgentId[] { return Array.from(this.profileByAgent.keys())}\n get names(): string[] { return Object.keys(this.agentByName)}\n\n /** */\n getProfileAgent(profileId: ActionId): AgentId | undefined {\n for (const [agentId, profId] of this.profileByAgent.entries()) {\n if (profileId.b64 == profId.b64) {\n return agentId;\n }\n }\n return undefined;\n }\n\n\n /** AgentId or Name */\n getProfile(agent: AgentId | string): Profile | undefined {\n if (typeof agent == \"string\") {\n const maybe = this.agentByName[agent];\n if (!maybe) {\n return;\n }\n agent = maybe;\n }\n const profileAh = this.profileByAgent.get(agent);\n //console.log(\"ProfilesAltZvm.getProfile()\", agent, profileAh);\n if (!profileAh) {\n return undefined;\n }\n const pair = this.profiles.get(profileAh);\n //console.log(\"ProfilesAltZvm.getProfile() pair\", pair);\n if (!pair) {\n return undefined;\n }\n return pair[0];\n }\n\n\n /** */\n getProfileTs(agent: AgentId | string): Timestamp | undefined {\n if (typeof agent == \"string\") {\n const maybe = this.agentByName[agent];\n if (!maybe) {\n return;\n }\n agent = maybe;\n }\n const profileAh = this.profileByAgent.get(agent);\n if (!profileAh) {\n return undefined;\n }\n const pair = this.profiles.get(profileAh);\n if (!pair) {\n return undefined;\n }\n return pair[1];\n }\n\n /** */\n getAgent(nickname: string): AgentId | undefined {\n return this.agentByName[nickname];\n }\n\n\n /** -- Memento -- */\n\n /** TODO: deep copy */\n makeSnapshot(): ProfilesAltSnapshot {\n let all: [AgentId, ActionId, Profile, Timestamp][] = [];\n for (const [agentId, profileAh] of this.profileByAgent.entries()) {\n const pair = this.profiles.get(profileAh);\n if (pair) {\n all.push([agentId, profileAh, pair[0], pair[1]])\n }\n }\n /** */\n return {all};\n }\n}\n\n\n/** */\nexport class ProfilesAltPerspectiveMutable extends ProfilesAltPerspective {\n\n get readonly(): ProfilesAltPerspective {\n return this;\n }\n\n /** -- Store -- */\n\n /** */\n storeProfile(profileAh: ActionId, profile: Profile, ts: Timestamp) {\n console.debug(\"ProfilesAltZvm.storeProfile()\", profileAh.short, profile.nickname);\n assertAllDefined(profileAh, profile, ts);\n this.profiles.set(profileAh, [profile, ts]);\n const agentId = this.getProfileAgent(profileAh);\n if (agentId) {\n this.agentByName[profile.nickname] = agentId;\n }\n }\n\n /** */\n storeAgentProfile(agentId: AgentId, profileAh: ActionId) {\n console.debug(\"ProfilesAltZvm.storeAgentProfile()\", agentId.short, profileAh.short);\n assertAllDefined(agentId, profileAh);\n this.profileByAgent.set(agentId, profileAh);\n const pair = this.profiles.get(profileAh);\n if (pair) {\n this.agentByName[pair[0].nickname] = agentId;\n }\n }\n\n /** */\n unstoreAgentProfile(agentId: AgentId, profileAh: ActionId) {\n console.debug(\"ProfilesAltZvm.unstoreAgentProfile()\", agentId.short, profileAh.short);\n assertAllDefined(agentId, profileAh);\n this.profileByAgent.delete(agentId);\n const pair = this.profiles.get(profileAh);\n if (pair) {\n delete this.agentByName[pair[0].nickname];\n }\n }\n\n\n /** -- Memento -- */\n\n /** */\n restore(snapshot: ProfilesAltSnapshot) {\n /** Clear */\n this.profiles.clear();\n this.profileByAgent.clear();\n this.agentByName = {};\n /** Store */\n for (const [agentId, profileAh, profile, ts] of snapshot.all) {\n this.storeAgentProfile(agentId, profileAh);\n this.storeProfile(profileAh, profile, ts);\n }\n }\n\n\n /** -- Generate -- */\n\n /** */\n async generateRandomProfile(nickname: string, ts?: Timestamp, fields?: Record<string, string>) {\n const agentId = await AgentId.random();\n const profileAh = await ActionId.random();\n const profile: Profile = {nickname, fields: {}};\n if (fields) profile.fields = fields;\n this.storeAgentProfile(agentId, profileAh);\n this.storeProfile(profileAh, profile, ts? ts : 0);\n }\n\n}\n"]}
@@ -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,EAGL,6BAA6B,EAE9B,MAAM,2BAA2B,CAAC;AAMnC,MAAM,OAAO,cAAe,SAAQ,wBAAwB;IAA5D;;QAkDU,iBAAY,GAAkC,IAAI,6BAA6B,EAAE,CAAC;IAqI5F,CAAC;IAlLC,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAItE,UAAU;QACjB,MAAM,GAAG,GAA0B;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI;YACnD,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAChF,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;IAGQ,UAAU;QACjB,MAAM,OAAO,GAA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AI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAID,MAAM,CAAC,IAAY,EAAE,UAAmB;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAwB,CAAC;QACxE,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE;gBAC9D,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,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;;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 override 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 (JSON.stringify(current.profiles[i]) != JSON.stringify(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"]}
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,CAAC;AAMnC,MAAM,OAAO,cAAe,SAAQ,wBAAwB;IAA5D;;QAkDU,iBAAY,GAAkC,IAAI,6BAA6B,EAAE,CAAC;IAqI5F,CAAC;IAlLC,IAAI,SAAS,KAAsB,OAAO,IAAI,CAAC,UAA8B,CAAC,CAAA,CAAC;IAItE,UAAU;QACjB,MAAM,GAAG,GAA0B;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,IAAI;YACnD,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAChF,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC;IAGQ,U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AAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAC3C,CAAC;IAID,MAAM,CAAC,IAAY,EAAE,UAAmB;QACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,aAAa,CAAwB,CAAC;QACxE,IAAI,UAAU,EAAE;YACd,KAAK,MAAM,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,IAAI,QAAQ,CAAC,GAAG,EAAE;gBAC9D,OAAO,CAAC,GAAG,CAAC,yCAAyC,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC,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;;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 override 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 (JSON.stringify(current.profiles[i]) != JSON.stringify(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 it's 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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/profiles-dvm",
3
- "version": "0.29.3",
3
+ "version": "0.30.3",
4
4
  "description": "DnaViewModel implementation for the Profiles zome.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -32,7 +32,8 @@
32
32
  "dependencies": {
33
33
  "@ddd-qc/lit-happ": "file:../lit-happ",
34
34
  "@holochain-open-dev/core-types": "0.7.0",
35
- "@holochain/client": "=0.18.0-dev.4",
35
+ "@holochain-open-dev/elements": "0.400.0-rc.0",
36
+ "@holochain/client": "=0.18.0-rc.1",
36
37
  "@msgpack/msgpack": "^2.7.2",
37
38
  "lit": "3.0.2"
38
39
  },