@ddd-qc/lit-happ 0.20.0 → 0.20.5

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,7 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { LitElement } from "lit";
3
3
  import { property, state } from "lit/decorators.js";
4
- import { ContextConsumer, consume, createContext } from "@lit-labs/context";
4
+ import { ContextConsumer, consume, createContext } from "@lit/context";
5
5
  import { CellMixin } from "@ddd-qc/cell-proxy";
6
6
  import { cellContext } from "./elements/cell-context";
7
7
  import { RoleMixin } from "./roleMixin";
@@ -1 +1 @@
1
- {"version":3,"file":"DnaElement.js","sourceRoot":"","sources":["../src/DnaElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,eAAe,EAAE,OAAO,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAqB,SAAS,EAAC,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,OAAO,UAAwC,SAAQ,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3F,mFAAmF;IACnF,YAAY,YAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;SAClC;IACH,CAAC;IAaD,oBAAoB;IAEpB,MAAM;IACI,UAAU;QAClB,6CAA6C;QAC7C,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,OAAO,CAAC,KAAK,CAAC,0DAA0D,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;YAC5F,OAAO;SACR;QACD,MAA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AAK,EAAE;wCAAsB;AAI9B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACjD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;qDAClB;AAGzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAC,CAAC;+CAC3D","sourcesContent":["import {LitElement, PropertyValues} from \"lit\";\nimport {property, state} from \"lit/decorators.js\";\nimport {ContextConsumer, consume, createContext} from \"@lit-labs/context\";\nimport {DnaViewModel} from \"./DnaViewModel\";\nimport {BaseRoleName, Cell, CellMixin} from \"@ddd-qc/cell-proxy\";\nimport {cellContext} from \"./elements/cell-context\";\nimport {RoleMixin} from \"./roleMixin\";\n\n/**\n * A LitElement that is bound to a specific DnaViewModel, e.g. a View for the ViewModel\n */\nexport class DnaElement<P, DVM extends DnaViewModel> extends CellMixin(RoleMixin(LitElement)) {\n\n /** if BaseRoleName is not provided, subclass must call requestDvm() in its Ctor */\n constructor(baseRoleName?: BaseRoleName) {\n super();\n if (baseRoleName) {\n this.baseRoleName = baseRoleName;\n }\n }\n\n /** Provided by Context depending on BaseRoleName */\n @state() protected _dvm!: DVM;\n\n @consume({ context: cellContext, subscribe: true})\n @property({type: Object, attribute: false})\n _cell_via_context!: Cell;\n\n @property({type: Object, attribute: false, hasChanged: (_v, _old) => true})\n perspective!: P;\n\n\n /** -- Methods -- */\n\n /** */\n protected requestDvm() {\n /** Consume Context based on given dnaHash */\n if (!this._cell_via_context) {\n console.error(\"No Cell info found via context in a DnaElement for role:\", this.baseRoleName)\n return;\n }\n const contextType = createContext<DVM>('dvm/'+ this.cell.name);\n console.log(`\\t\\t Requesting context \"${contextType}\"`)\n /*const consumer =*/ new ContextConsumer(\n this,\n contextType,\n async (value: DVM, dispose?: () => void): Promise<void> => {\n console.log(`\\t\\t Received value for context \"${contextType}\"`)\n await this.dvmUpdated(value, this._dvm);\n if (this._dvm) {\n this._dvm.unsubscribe(this);\n }\n this._dvm = value;\n this._dvm.subscribe(this, 'perspective');\n },\n false, // true will call twice at init\n );\n //console.log({consumer})\n }\n\n\n /**\n * To be overriden by subclasses\n * Example: Have a subclass unsubscribe to oldDvm's zvms and subscribe to the new ones\n */\n protected async dvmUpdated(newDvm: DVM, oldDvm?: DVM): Promise<void> {\n //console.log(`\\t\\t Default dvmUpdated() called`)\n }\n\n\n /** */\n shouldUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has(\"_cell_via_context\")) {\n this._cell = this._cell_via_context;\n }\n if (!this._dvm) {\n this.requestDvm();\n }\n return !!this._dvm;\n }\n\n\n /** */\n protected willUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has(\"_cell_via_context\")) {\n this.requestDvm();\n }\n }\n}\n"]}
1
+ {"version":3,"file":"DnaElement.js","sourceRoot":"","sources":["../src/DnaElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,eAAe,EAAE,OAAO,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAErE,OAAO,EAAqB,SAAS,EAAC,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,OAAO,UAAwC,SAAQ,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAE3F,mFAAmF;IACnF,YAAY,YAA2B;QACrC,KAAK,EAAE,CAAC;QACR,IAAI,YAAY,EAAE;YAChB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;SACl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AAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAGD,MAAM;IACI,UAAU,CAAC,iBAAuC;QAC1D,IAAI,iBAAiB,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;YAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;IACH,CAAC;CACF;AAlEoB;IAAlB,KAAK,EAAE;wCAAsB;AAI9B;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACjD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;qDAClB;AAGzB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAC,CAAC;+CAC3D","sourcesContent":["import {LitElement, PropertyValues} from \"lit\";\nimport {property, state} from \"lit/decorators.js\";\nimport {ContextConsumer, consume, createContext} from \"@lit/context\";\nimport {DnaViewModel} from \"./DnaViewModel\";\nimport {BaseRoleName, Cell, CellMixin} from \"@ddd-qc/cell-proxy\";\nimport {cellContext} from \"./elements/cell-context\";\nimport {RoleMixin} from \"./roleMixin\";\n\n/**\n * A LitElement that is bound to a specific DnaViewModel, e.g. a View for the ViewModel\n */\nexport class DnaElement<P, DVM extends DnaViewModel> extends CellMixin(RoleMixin(LitElement)) {\n\n /** if BaseRoleName is not provided, subclass must call requestDvm() in its Ctor */\n constructor(baseRoleName?: BaseRoleName) {\n super();\n if (baseRoleName) {\n this.baseRoleName = baseRoleName;\n }\n }\n\n /** Provided by Context depending on BaseRoleName */\n @state() protected _dvm!: DVM;\n\n @consume({ context: cellContext, subscribe: true})\n @property({type: Object, attribute: false})\n _cell_via_context!: Cell;\n\n @property({type: Object, attribute: false, hasChanged: (_v, _old) => true})\n perspective!: P;\n\n\n /** -- Methods -- */\n\n /** */\n protected requestDvm() {\n /** Consume Context based on given dnaHash */\n if (!this._cell_via_context) {\n console.error(\"No Cell info found via context in a DnaElement for role:\", this.baseRoleName)\n return;\n }\n const contextType = createContext<DVM>('dvm/'+ this.cell.name);\n console.log(`\\t\\t Requesting context \"${contextType}\"`)\n /*const consumer =*/ new ContextConsumer(\n this,\n contextType,\n async (value: DVM, dispose?: () => void): Promise<void> => {\n console.log(`\\t\\t Received value for context \"${contextType}\"`)\n await this.dvmUpdated(value, this._dvm);\n if (this._dvm) {\n this._dvm.unsubscribe(this);\n }\n this._dvm = value;\n this._dvm.subscribe(this, 'perspective');\n },\n false, // true will call twice at init\n );\n //console.log({consumer})\n }\n\n\n /**\n * To be overriden by subclasses\n * Example: Have a subclass unsubscribe to oldDvm's zvms and subscribe to the new ones\n */\n protected async dvmUpdated(newDvm: DVM, oldDvm?: DVM): Promise<void> {\n //console.log(`\\t\\t Default dvmUpdated() called`)\n }\n\n\n /** */\n shouldUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has(\"_cell_via_context\")) {\n this._cell = this._cell_via_context;\n }\n if (!this._dvm) {\n this.requestDvm();\n }\n return !!this._dvm;\n }\n\n\n /** */\n protected willUpdate(changedProperties: PropertyValues<this>) {\n if (changedProperties.has(\"_cell_via_context\")) {\n this.requestDvm();\n }\n }\n}\n"]}
@@ -3,7 +3,7 @@ import { ReactiveElement } from "lit";
3
3
  import { ViewModel } from "./ViewModel";
4
4
  import { AdminWebsocket, InstalledAppId, ZomeName } from "@holochain/client";
5
5
  import { DnaModifiersOptions, ZvmDef } from "./definitions";
6
- import { Context } from "@lit-labs/context";
6
+ import { Context } from "@lit/context";
7
7
  import { CellProxy, AppProxy, HCL, Dictionary } from "@ddd-qc/cell-proxy";
8
8
  import { RoleSpecific } from "./roleMixin";
9
9
  /** Interface specific to DnaViewModel class */
@@ -1,6 +1,6 @@
1
1
  import { ViewModel } from "./ViewModel";
2
2
  import { GrantedFunctionsType, } from "@holochain/client";
3
- import { createContext } from "@lit-labs/context";
3
+ import { createContext } from "@lit/context";
4
4
  import { HCL, CellMixin } from "@ddd-qc/cell-proxy";
5
5
  import { RoleMixin } from "./roleMixin";
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DnaViewModel.js","sourceRoot":"","sources":["../src/DnaViewModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAEL,oBAAoB,GAGrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAU,aAAa,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAGL,GAAG,EACS,SAAS,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,SAAS,EAAe,MAAM,aAAa,CAAC;AAoBpD;;;;;GAKG;AACH,MAAM,OAAgB,YAAa,SAAQ,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAMxE,WAAW;IACX,YAA4B,IAAqB,EAAE,QAAkB,EAAE,OAA6B;QAClG,KAAK,EAAE,CAAC;QADkB,SAAI,GAAJ,IAAI,CAAiB;QAgCjD,qBAAqB;QACX,oBAAe,GAA8B,EAAE,CAAC;QAC1D,6BAA6B;QACnB,eAAU,GAAyB,EAAE,CAAC;QAChD,8CAA8C;QACtC,kBAAa,GAAoC,EAAE,CAAC;QAnC1D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;YACzC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC;SACpB;aAAM;YACL,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;SAChD;QACD,MAAM,OAAO,GAAI,IAAI,CAAC,WAAmC,CAAA;QACzD,MAAM,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,G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,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,gBAAgB;gBAC5E,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAA;aACpC;YAAC,OAAO,CAAC,EAAE;gBACV,OAAO,CAAC,IAAI,CAAC,0CAA0C,QAAQ,iEAAiE,CAAC,CAAA;gBACjI,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC;aACnC;SACF;QACD,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAID,MAAM;IACN,QAAQ,CAAC,QAAmB;QAC1B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACnC,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;CACF","sourcesContent":["import {ZomeViewModel} from \"./ZomeViewModel\";\nimport {ReactiveElement} from \"lit\";\nimport {ViewModel} from \"./ViewModel\";\nimport {\n AdminWebsocket,\n GrantedFunctionsType,\n InstalledAppId,\n ZomeName,\n} from \"@holochain/client\";\nimport {DnaModifiersOptions, ZvmDef} from \"./definitions\";\nimport {Context, createContext} from \"@lit-labs/context\";\nimport {\n CellProxy,\n AppProxy,\n HCL,\n Dictionary, CellMixin\n} from \"@ddd-qc/cell-proxy\";\nimport {RoleMixin, RoleSpecific} from \"./roleMixin\";\n\n\n//export type IDnaViewModel = _DnaViewModel & ICellDef & typeof RoleSpecific;\n\n/** Interface specific to DnaViewModel class */\ninterface IDnaViewModel {\n dumpLogs(zomeName?: ZomeName): void;\n /** zomeName -> (AppEntryName, isPublic)[]*/\n fetchAllEntryDefs(): Promise<Dictionary<[string, boolean][]>>;\n //get entryTypes(): Dictionary<[string, boolean][]>;\n //getZomeEntryDefs(zomeName: ZomeName): [string, boolean][] | undefined;\n //getZomeViewModel(zomeName: ZomeName): ZomeViewModel | undefined\n}\n\nexport type DvmConstructor = typeof RoleSpecific & {DNA_MODIFIERS: DnaModifiersOptions} & {\n new(host: ReactiveElement, proxy: AppProxy, idOrHcl: HCL | InstalledAppId): DnaViewModel;\n};\n\n\n/**\n * Abstract ViewModel for a DNA.\n * It holds the CellProxy and all the ZomeViewModels of the DNA.\n * It is expected to derive this class for each DNA and add extra logic at the DNA level.\n * TODO: Split into RoleViewModel and CellViewModel (e.g. have call logs separated by role)\n */\nexport abstract class DnaViewModel extends CellMixin(RoleMixin(ViewModel)) implements IDnaViewModel {\n\n /* private */ static ZVM_DEFS: ZvmDef[];\n static DNA_MODIFIERS: DnaModifiersOptions;\n\n\n /** Ctor */\n constructor(public readonly host: ReactiveElement, appProxy: AppProxy, idOrHcl: HCL | InstalledAppId) {\n super();\n if (typeof idOrHcl === 'object') {\n this.baseRoleName = idOrHcl.baseRoleName;\n this.hcl = idOrHcl;\n } else {\n this.hcl = new HCL(idOrHcl, this.baseRoleName);\n }\n const dvmCtor = (this.constructor as typeof DnaViewModel)\n const zvmDefs = dvmCtor.ZVM_DEFS;\n this._cellProxy = appProxy.getCellProxy(this.hcl); // WARN can throw error\n this._cell = this._cellProxy.cell;\n console.log(`DVM.ctor of ${this.baseRoleName}`, this._cellProxy.cell);\n /** Create all ZVMs for this DNA */\n for (const zvmDef of zvmDefs) {\n let zvm;\n if (Array.isArray(zvmDef)) {\n zvm = new zvmDef[0](this._cellProxy, this, zvmDef[1]);\n } else {\n zvm = new zvmDef(this._cellProxy, this);\n }\n // TODO check zvm.zomeName exists in _cellProxy\n this._zomeViewModels[zvm.zomeName] = zvm;\n this._zomeNames[zvmDef.constructor.name] = zvm.zomeName;\n }\n this.provideContext(host); // TODO move this to host.connectedCallback? e.g. change ViewModel to a ReactiveController\n }\n\n\n /** -- Fields -- */\n\n protected _cellProxy: CellProxy;\n /* ZomeName -> Zvm */\n protected _zomeViewModels: Dictionary<ZomeViewModel> = {};\n /* ZvmCtorName -> ZomeName */\n protected _zomeNames: Dictionary<ZomeName> = {};\n /* ZomeName -> [EntryName, EntryVisibility] */\n private _allEntryDefs: Dictionary<[string, boolean][]> = {};\n\n public readonly hcl: HCL;\n\n\n /** -- Getters -- */\n\n getZomeEntryDefs(zomeName: ZomeName): [string, boolean][] | undefined {return this._allEntryDefs[zomeName]}\n getZomeViewModel(zomeName: ZomeName): ZomeViewModel | undefined {return this._zomeViewModels[zomeName]}\n getZomeName(zvm: typeof ZomeViewModel): ZomeName | undefined { return this._zomeNames[zvm.constructor.name]}\n\n /** -- Methods -- */\n\n /** Override so we can provide context of all zvms */\n /*private*/ provideContext(host: ReactiveElement): void {\n //console.log(\"DVM.provideContext()\", host, this)\n super.provideContext(host);\n for (const zvm of Object.values(this._zomeViewModels)) {\n zvm.provideContext(host)\n }\n }\n\n\n getContext(): Context<unknown, unknown> {return createContext<typeof this>('dvm/' + this.cell.name)};\n\n\n /** */\n async authorizeZomeCalls(adminWs: AdminWebsocket): Promise<void> {\n let allFnNames = [];\n for (const [_zomeName, zvm] of Object.entries(this._zomeViewModels)) {\n allFnNames = allFnNames.concat(zvm.zomeProxy.fnNames)\n }\n const grantedFns = { [GrantedFunctionsType.Listed]: allFnNames }\n try {\n console.log(\"authorizeSigningCredentials: \" + this.cell.hcl().toString(), allFnNames);\n console.log(\"authorizeSigningCredentials. cell_id = [\" + this.cell.dnaHash + \" ; \" + this.cell.agentPubKey + \"]\");\n //await adminWs.authorizeSigningCredentials(this.cell.id, grantedFns);\n await adminWs.authorizeSigningCredentials(this.cell.id);\n } catch(e) {\n console.warn(\"authorizeSigningCredentials FAILED.\", e);\n }\n // this._signingProps = getSigningCredentials(this.cellId);\n // console.log({signProps: this._signingProps})\n //\n // for (const [zomeName, zvm] of Object.entries(this._zomeViewModels)) {\n // zvm.zomeProxy.setSigningProps(this._signingProps);\n // }\n }\n\n\n /** Not async on purpose as we except this to be long. Post-processing should be done via Observer pattern */\n protected probeAllInner(): void {\n for (const [_name, zvm] of Object.entries(this._zomeViewModels)) {\n //console.log(\"Dvm.probeAll()\", name)\n zvm.probeAll();\n }\n }\n\n\n /** */\n zvmChanged(zvm: ZomeViewModel): void {}\n\n\n /** */\n async initializePerspectiveOffline(): Promise<void> {\n const all = [];\n for (const [_name, zvm] of Object.entries(this._zomeViewModels)) {\n const p = zvm.initializePerspectiveOffline();\n all.push(p);\n }\n await Promise.all(all);\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n const all = [];\n for (const [_name, zvm] of Object.entries(this._zomeViewModels)) {\n const p = zvm.initializePerspectiveOnline();\n all.push(p);\n }\n await Promise.all(all);\n }\n\n\n /** Maybe useless since the entry defs are in the integrity zome which is not represented here */\n async fetchAllEntryDefs(): Promise<Dictionary<[string, boolean][]>> {\n for (const zvm of Object.values(this._zomeViewModels)) {\n const zomeName = zvm.zomeName;\n try {\n const defs = await this._cellProxy.callEntryDefs(zomeName); // TODO optimize\n this._allEntryDefs[zomeName] = defs\n } catch (e) {\n console.warn(`Calling \"entry_defs()\" failed on zome \"${zomeName}\". Possibly because zome does not have any entry types defined.`)\n this._allEntryDefs[zomeName] = [];\n }\n }\n return this._allEntryDefs;\n }\n\n\n\n /** */\n dumpLogs(zomeName?: ZomeName): void {\n this._cellProxy.dumpLogs(zomeName);\n this._cellProxy.dumpSignals();\n }\n}\n"]}
1
+ {"version":3,"file":"DnaViewModel.js","sourceRoot":"","sources":["../src/DnaViewModel.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAEL,oBAAoB,GAGrB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAU,aAAa,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAGL,GAAG,EACS,SAAS,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,SAAS,EAAe,MAAM,aAAa,CAAC;AAoBpD;;;;;GAKG;AACH,MAAM,OAAgB,YAAa,SAAQ,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAMxE,WAAW;IACX,YAA4B,IAAqB,EAAE,QAAkB,EAAE,OAA6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\n GrantedFunctionsType,\n InstalledAppId,\n ZomeName,\n} from \"@holochain/client\";\nimport {DnaModifiersOptions, ZvmDef} from \"./definitions\";\nimport {Context, createContext} from \"@lit/context\";\nimport {\n CellProxy,\n AppProxy,\n HCL,\n Dictionary, CellMixin\n} from \"@ddd-qc/cell-proxy\";\nimport {RoleMixin, RoleSpecific} from \"./roleMixin\";\n\n\n//export type IDnaViewModel = _DnaViewModel & ICellDef & typeof RoleSpecific;\n\n/** Interface specific to DnaViewModel class */\ninterface IDnaViewModel {\n dumpLogs(zomeName?: ZomeName): void;\n /** zomeName -> (AppEntryName, isPublic)[]*/\n fetchAllEntryDefs(): Promise<Dictionary<[string, boolean][]>>;\n //get entryTypes(): Dictionary<[string, boolean][]>;\n //getZomeEntryDefs(zomeName: ZomeName): [string, boolean][] | undefined;\n //getZomeViewModel(zomeName: ZomeName): ZomeViewModel | undefined\n}\n\nexport type DvmConstructor = typeof RoleSpecific & {DNA_MODIFIERS: DnaModifiersOptions} & {\n new(host: ReactiveElement, proxy: AppProxy, idOrHcl: HCL | InstalledAppId): DnaViewModel;\n};\n\n\n/**\n * Abstract ViewModel for a DNA.\n * It holds the CellProxy and all the ZomeViewModels of the DNA.\n * It is expected to derive this class for each DNA and add extra logic at the DNA level.\n * TODO: Split into RoleViewModel and CellViewModel (e.g. have call logs separated by role)\n */\nexport abstract class DnaViewModel extends CellMixin(RoleMixin(ViewModel)) implements IDnaViewModel {\n\n /* private */ static ZVM_DEFS: ZvmDef[];\n static DNA_MODIFIERS: DnaModifiersOptions;\n\n\n /** Ctor */\n constructor(public readonly host: ReactiveElement, appProxy: AppProxy, idOrHcl: HCL | InstalledAppId) {\n super();\n if (typeof idOrHcl === 'object') {\n this.baseRoleName = idOrHcl.baseRoleName;\n this.hcl = idOrHcl;\n } else {\n this.hcl = new HCL(idOrHcl, this.baseRoleName);\n }\n const dvmCtor = (this.constructor as typeof DnaViewModel)\n const zvmDefs = dvmCtor.ZVM_DEFS;\n this._cellProxy = appProxy.getCellProxy(this.hcl); // WARN can throw error\n this._cell = this._cellProxy.cell;\n console.log(`DVM.ctor of ${this.baseRoleName}`, this._cellProxy.cell);\n /** Create all ZVMs for this DNA */\n for (const zvmDef of zvmDefs) {\n let zvm;\n if (Array.isArray(zvmDef)) {\n zvm = new zvmDef[0](this._cellProxy, this, zvmDef[1]);\n } else {\n zvm = new zvmDef(this._cellProxy, this);\n }\n // TODO check zvm.zomeName exists in _cellProxy\n this._zomeViewModels[zvm.zomeName] = zvm;\n this._zomeNames[zvmDef.constructor.name] = zvm.zomeName;\n }\n this.provideContext(host); // TODO move this to host.connectedCallback? e.g. change ViewModel to a ReactiveController\n }\n\n\n /** -- Fields -- */\n\n protected _cellProxy: CellProxy;\n /* ZomeName -> Zvm */\n protected _zomeViewModels: Dictionary<ZomeViewModel> = {};\n /* ZvmCtorName -> ZomeName */\n protected _zomeNames: Dictionary<ZomeName> = {};\n /* ZomeName -> [EntryName, EntryVisibility] */\n private _allEntryDefs: Dictionary<[string, boolean][]> = {};\n\n public readonly hcl: HCL;\n\n\n /** -- Getters -- */\n\n getZomeEntryDefs(zomeName: ZomeName): [string, boolean][] | undefined {return this._allEntryDefs[zomeName]}\n getZomeViewModel(zomeName: ZomeName): ZomeViewModel | undefined {return this._zomeViewModels[zomeName]}\n getZomeName(zvm: typeof ZomeViewModel): ZomeName | undefined { return this._zomeNames[zvm.constructor.name]}\n\n /** -- Methods -- */\n\n /** Override so we can provide context of all zvms */\n /*private*/ provideContext(host: ReactiveElement): void {\n //console.log(\"DVM.provideContext()\", host, this)\n super.provideContext(host);\n for (const zvm of Object.values(this._zomeViewModels)) {\n zvm.provideContext(host)\n }\n }\n\n\n getContext(): Context<unknown, unknown> {return createContext<typeof this>('dvm/' + this.cell.name)};\n\n\n /** */\n async authorizeZomeCalls(adminWs: AdminWebsocket): Promise<void> {\n let allFnNames = [];\n for (const [_zomeName, zvm] of Object.entries(this._zomeViewModels)) {\n allFnNames = allFnNames.concat(zvm.zomeProxy.fnNames)\n }\n const grantedFns = { [GrantedFunctionsType.Listed]: allFnNames }\n try {\n console.log(\"authorizeSigningCredentials: \" + this.cell.hcl().toString(), allFnNames);\n console.log(\"authorizeSigningCredentials. cell_id = [\" + this.cell.dnaHash + \" ; \" + this.cell.agentPubKey + \"]\");\n //await adminWs.authorizeSigningCredentials(this.cell.id, grantedFns);\n await adminWs.authorizeSigningCredentials(this.cell.id);\n } catch(e) {\n console.warn(\"authorizeSigningCredentials FAILED.\", e);\n }\n // this._signingProps = getSigningCredentials(this.cellId);\n // console.log({signProps: this._signingProps})\n //\n // for (const [zomeName, zvm] of Object.entries(this._zomeViewModels)) {\n // zvm.zomeProxy.setSigningProps(this._signingProps);\n // }\n }\n\n\n /** Not async on purpose as we except this to be long. Post-processing should be done via Observer pattern */\n protected probeAllInner(): void {\n for (const [_name, zvm] of Object.entries(this._zomeViewModels)) {\n //console.log(\"Dvm.probeAll()\", name)\n zvm.probeAll();\n }\n }\n\n\n /** */\n zvmChanged(zvm: ZomeViewModel): void {}\n\n\n /** */\n async initializePerspectiveOffline(): Promise<void> {\n const all = [];\n for (const [_name, zvm] of Object.entries(this._zomeViewModels)) {\n const p = zvm.initializePerspectiveOffline();\n all.push(p);\n }\n await Promise.all(all);\n }\n\n\n /** */\n async initializePerspectiveOnline(): Promise<void> {\n const all = [];\n for (const [_name, zvm] of Object.entries(this._zomeViewModels)) {\n const p = zvm.initializePerspectiveOnline();\n all.push(p);\n }\n await Promise.all(all);\n }\n\n\n /** Maybe useless since the entry defs are in the integrity zome which is not represented here */\n async fetchAllEntryDefs(): Promise<Dictionary<[string, boolean][]>> {\n for (const zvm of Object.values(this._zomeViewModels)) {\n const zomeName = zvm.zomeName;\n try {\n const defs = await this._cellProxy.callEntryDefs(zomeName); // TODO optimize\n this._allEntryDefs[zomeName] = defs\n } catch (e) {\n console.warn(`Calling \"entry_defs()\" failed on zome \"${zomeName}\". Possibly because zome does not have any entry types defined.`)\n this._allEntryDefs[zomeName] = [];\n }\n }\n return this._allEntryDefs;\n }\n\n\n\n /** */\n dumpLogs(zomeName?: ZomeName): void {\n this._cellProxy.dumpLogs(zomeName);\n this._cellProxy.dumpSignals();\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { Context } from "@lit-labs/context";
1
+ import { Context } from "@lit/context";
2
2
  import { ReactiveControllerHost, ReactiveElement } from "lit";
3
3
  import { AppSignalCb } from "@holochain/client";
4
4
  import { Mutex } from 'async-mutex';
package/dist/ViewModel.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ContextProvider } from "@lit-labs/context";
1
+ import { ContextProvider } from "@lit/context";
2
2
  import { Mutex } from 'async-mutex';
3
3
  var InitializationState;
4
4
  (function (InitializationState) {
@@ -79,7 +79,8 @@ export class ViewModel {
79
79
  notifySubscribers() {
80
80
  if (!this.hasChanged())
81
81
  return false;
82
- this._previousPerspective = structuredClone(this.perspective);
82
+ //this._previousPerspective = structuredClone(this.perspective);
83
+ this._previousPerspective = this.perspective;
83
84
  for (const [host, propName] of this._providedHosts) {
84
85
  host[propName] = this._previousPerspective;
85
86
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ViewModel.js","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAI3D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,IAAK,mBAKJ;AALD,WAAK,mBAAmB;IACtB,sDAA+B,CAAA;IAC/B,kEAA2C,CAAA;IAC3C,gEAAyC,CAAA;IACzC,kDAA2B,CAAA;AAC7B,CAAC,EALI,mBAAmB,KAAnB,mBAAmB,QAKvB;AAED;;;;;;;;;;GAUG;AACF,MAAM,OAAgB,SAAS;IAA/B;QAIW,mBAAc,GAA4C,EAAE,CAAC;QAGvE,0FAA0F;QAGhF,gBAAW,GAAG,IAAI,KAAK,EAAE,CAAC;IAuFtC,CAAC;IA1EC,qEAAqE;IACrE,KAAK,CAAC,4BAA4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IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACZ,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACxC;IACL,CAAC;IAED,MAAM;IACI,iBAAiB;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,OAAO,KAAK,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC9D,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YACjD,IAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC;SACrD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAEF","sourcesContent":["import {Context, ContextProvider} from \"@lit-labs/context\";\nimport {ReactiveControllerHost, ReactiveElement} from \"lit\";\nimport {AppSignalCb} from \"@holochain/client\";\n\nimport { Mutex } from 'async-mutex';\n\n\nenum InitializationState {\n Uninitialized = \"Uninitialized\",\n InitializingOffline = \"InitializingOffline\",\n InitializingOnline = \"InitializingOnline\",\n Initialized = \"Initialized\",\n}\n\n/**\n * ABC of a ViewModel.\n * It mediates the interaction between a View (CustomElements) and a Model (Zome / DNA).\n * It is an Observable meant to be observed by (Lit) ReactiveElements.\n * It is meant to be a singleton passed around by a (Lit) Context.\n * The ViewModel contains a perspective: All the data that a view can observe.\n * To update subscribers, it makes use of Lit's reactive properties.\n * When subscribing, a host must provide a reactive property that has the ViewModel's perspestives's type.\n * Hosts can trigger probing in order to get an updated perspective.\n * The perspective can be automatically updated by internal events.\n */\n export abstract class ViewModel {\n\n /** -- Fields -- */\n protected _previousPerspective?: unknown;\n protected _providedHosts: [ReactiveControllerHost, PropertyKey][] = [];\n protected _provider?: unknown; // FIXME type: ContextProvider<this.getContext()>;\n\n //protected _initializationState: InitializationState = InitializationState.Uninitialized;\n\n\n protected _probeMutex = new Mutex();\n\n /** -- Abstract fields -- */\n\n abstract signalHandler?: AppSignalCb;\n\n\n /** -- Abstract methods -- */\n\n abstract getContext(): Context<unknown, unknown>;\n /* Child class should implement with specific type */\n abstract get perspective(): unknown;\n\n /* (optional) Set perspective with data from the source-chain only */\n async initializePerspectiveOffline(): Promise<void> {}\n /* (optional) Set perspective with data from the DHT */\n async initializePerspectiveOnline(): Promise<void> {}\n /* (optional) Lets the observer trigger probing into the network in order to get an updated perspective */\n protected probeAllInner(): void {};\n\n /**\n * Mutex wrapping of probeAllInner: Don't call probeAll() during a probeAll()\n * Should not be async as we expect this to be long, so happs are expected to use signals instead if something changed.\n */\n probeAll(): void {\n // if (this._initializationState !== InitializationState.Initialized) {\n // console.warn(\"probeAll() called on unitialized ViewModel\");\n // return;\n // }\n if (this._probeMutex.isLocked()) {\n console.log(\"probeAll() call skipped. Reason: Already running.\");\n return;\n }\n this._probeMutex\n .acquire()\n .then(async (release) => {\n this.probeAllInner();\n release();\n });\n }\n\n /**\n * Return true if the perspective has changed. This will trigger an update on the observers\n * Child classes are expected to compare their latest constructed perspective (the one returned by this.perspective())\n * with this._previousPerspective.\n */\n protected abstract hasChanged(): boolean;\n\n\n /** -- Final methods -- */\n\n /** Set ContextProvider for host */\n provideContext(providerHost: ReactiveElement): void {\n console.log(`\\t\\tProviding context \"${this.getContext()}\" | in host `, providerHost);\n this._provider = new ContextProvider(providerHost, this.getContext(), this);\n }\n\n /** -- Observer pattern -- */\n\n /** */\n subscribe(providedHost: ReactiveControllerHost, propName: PropertyKey): void {\n (providedHost as any)[propName] = this.perspective;\n this._providedHosts.push([providedHost, propName])\n }\n\n /** */\n unsubscribe(candidate: ReactiveControllerHost): void {\n let index = 0;\n for (const [host, _propName] of this._providedHosts) {\n if (host === candidate) break;\n index += 1;\n }\n if (index > -1) {\n this._providedHosts.splice(index, 1);\n }\n }\n\n /** */\n protected notifySubscribers(): boolean {\n if (!this.hasChanged()) return false;\n this._previousPerspective = structuredClone(this.perspective);\n for (const [host, propName] of this._providedHosts) {\n (host as any)[propName] = this._previousPerspective;\n }\n return true;\n }\n\n}\n"]}
1
+ {"version":3,"file":"ViewModel.js","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,eAAe,EAAC,MAAM,cAAc,CAAC;AAItD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAGpC,IAAK,mBAKJ;AALD,WAAK,mBAAmB;IACtB,sDAA+B,CAAA;IAC/B,kEAA2C,CAAA;IAC3C,gEAAyC,CAAA;IACzC,kDAA2B,CAAA;AAC7B,CAAC,EALI,mBAAmB,KAAnB,mBAAmB,QAKvB;AAED;;;;;;;;;;GAUG;AACF,MAAM,OAAgB,SAAS;IAA/B;QAIW,mBAAc,GAA4C,EAAE,CAAC;QAGvE,0FAA0F;QAGhF,gBAAW,GAAG,IAAI,KAAK,EAAE,CAAC;IAwFtC,CAAC;IA3EC,qEAAqE;IACrE,KAAK,CAAC,4BAA4B,KAAmB,CAAC;IACtD,uDAAuD;IACvD,KAAK,CAAC,2BAA2B,KAAmB,CAAC;IACrD,0GAA0G;IAChG,aAAa,KAAU,CAAC;IAAA,CAAC;IAEnC;;;OAGG;IACH,QAAQ;QACN,uEAAuE;QACvE,gEAAgE;QAChE,YAAY;QACZ,IAAI;QACJ,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;YAC/B,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;YACjE,OAAO;SACR;QACD,IAAI,CAAC,WAAW;aACb,OAAO,EAAE;aACT,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YACtB,IAAI,CAAC,aAAa,EAAE,CAAC;YACrB,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC,CAAC;IACP,CAAC;IAUD,0BAA0B;IAE1B,mCAAmC;IACnC,cAAc,CAAC,YAA6B;QAC1C,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,UAAU,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,GAAG,IAAI,eAAe,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;IAED,6BAA6B;IAE7B,MAAM;IACN,SAAS,CAAC,YAAoC,EAAE,QAAqB;QAChE,YAAoB,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QACnD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAA;IACtD,CAAC;IAED,MAAM;IACN,WAAW,CAAC,SAAiC;QACzC,IAAI,KAAK,GAAI,CAAC,CAAC;QACf,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YACjD,IAAI,IAAI,KAAK,SAAS;gBAAE,MAAM;YAC9B,KAAK,IAAI,CAAC,CAAC;SACd;QACD,IAAI,KAAK,GAAG,CAAC,CAAC,EAAE;YACZ,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SACxC;IACL,CAAC;IAED,MAAM;IACI,iBAAiB;QACzB,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YAAE,OAAO,KAAK,CAAC;QACnC,gEAAgE;QAChE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAC;QAC7C,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YACnD,IAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC;SACrD;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CAEF","sourcesContent":["import {Context, ContextProvider} from \"@lit/context\";\nimport {ReactiveControllerHost, ReactiveElement} from \"lit\";\nimport {AppSignalCb} from \"@holochain/client\";\n\nimport { Mutex } from 'async-mutex';\n\n\nenum InitializationState {\n Uninitialized = \"Uninitialized\",\n InitializingOffline = \"InitializingOffline\",\n InitializingOnline = \"InitializingOnline\",\n Initialized = \"Initialized\",\n}\n\n/**\n * ABC of a ViewModel.\n * It mediates the interaction between a View (CustomElements) and a Model (Zome / DNA).\n * It is an Observable meant to be observed by (Lit) ReactiveElements.\n * It is meant to be a singleton passed around by a (Lit) Context.\n * The ViewModel contains a perspective: All the data that a view can observe.\n * To update subscribers, it makes use of Lit's reactive properties.\n * When subscribing, a host must provide a reactive property that has the ViewModel's perspestives's type.\n * Hosts can trigger probing in order to get an updated perspective.\n * The perspective can be automatically updated by internal events.\n */\n export abstract class ViewModel {\n\n /** -- Fields -- */\n protected _previousPerspective?: unknown;\n protected _providedHosts: [ReactiveControllerHost, PropertyKey][] = [];\n protected _provider?: unknown; // FIXME type: ContextProvider<this.getContext()>;\n\n //protected _initializationState: InitializationState = InitializationState.Uninitialized;\n\n\n protected _probeMutex = new Mutex();\n\n /** -- Abstract fields -- */\n\n abstract signalHandler?: AppSignalCb;\n\n\n /** -- Abstract methods -- */\n\n abstract getContext(): Context<unknown, unknown>;\n /* Child class should implement with specific type */\n abstract get perspective(): unknown;\n\n /* (optional) Set perspective with data from the source-chain only */\n async initializePerspectiveOffline(): Promise<void> {}\n /* (optional) Set perspective with data from the DHT */\n async initializePerspectiveOnline(): Promise<void> {}\n /* (optional) Lets the observer trigger probing into the network in order to get an updated perspective */\n protected probeAllInner(): void {};\n\n /**\n * Mutex wrapping of probeAllInner: Don't call probeAll() during a probeAll()\n * Should not be async as we expect this to be long, so happs are expected to use signals instead if something changed.\n */\n probeAll(): void {\n // if (this._initializationState !== InitializationState.Initialized) {\n // console.warn(\"probeAll() called on unitialized ViewModel\");\n // return;\n // }\n if (this._probeMutex.isLocked()) {\n console.log(\"probeAll() call skipped. Reason: Already running.\");\n return;\n }\n this._probeMutex\n .acquire()\n .then(async (release) => {\n this.probeAllInner();\n release();\n });\n }\n\n /**\n * Return true if the perspective has changed. This will trigger an update on the observers\n * Child classes are expected to compare their latest constructed perspective (the one returned by this.perspective())\n * with this._previousPerspective.\n */\n protected abstract hasChanged(): boolean;\n\n\n /** -- Final methods -- */\n\n /** Set ContextProvider for host */\n provideContext(providerHost: ReactiveElement): void {\n console.log(`\\t\\tProviding context \"${this.getContext()}\" | in host `, providerHost);\n this._provider = new ContextProvider(providerHost, this.getContext(), this);\n }\n\n /** -- Observer pattern -- */\n\n /** */\n subscribe(providedHost: ReactiveControllerHost, propName: PropertyKey): void {\n (providedHost as any)[propName] = this.perspective;\n this._providedHosts.push([providedHost, propName])\n }\n\n /** */\n unsubscribe(candidate: ReactiveControllerHost): void {\n let index = 0;\n for (const [host, _propName] of this._providedHosts) {\n if (host === candidate) break;\n index += 1;\n }\n if (index > -1) {\n this._providedHosts.splice(index, 1);\n }\n }\n\n /** */\n protected notifySubscribers(): boolean {\n if (!this.hasChanged()) return false;\n //this._previousPerspective = structuredClone(this.perspective);\n this._previousPerspective = this.perspective;\n for (const [host, propName] of this._providedHosts) {\n (host as any)[propName] = this._previousPerspective;\n }\n return true;\n }\n\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { LitElement } from "lit";
3
3
  import { property, state } from "lit/decorators.js";
4
- import { consume, ContextConsumer, createContext } from "@lit-labs/context";
4
+ import { consume, ContextConsumer, createContext } from "@lit/context";
5
5
  import { cellContext } from "./elements/cell-context";
6
6
  import { CellMixin } from "@ddd-qc/cell-proxy";
7
7
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ZomeElement.js","sourceRoot":"","sources":["../src/ZomeElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAE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,aAAa,CAAC,CAAC;QAC3C,CAAC,EACD,KAAK,CACN,CAAC;IACJ,CAAC;IAGD,kFAAkF;IACxE,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,MAAY;QAClD,iDAAiD;IACnD,CAAC;IAGD,MAAM;IACN,YAAY,CAAC,iBAAuC;QAClD,mFAAmF;QACnF,IAAI,iBAAiB,CAAC,GAAG,CAAC,mBAAmB,CAAC,EAAE;YAC9C,mEAAmE;YACnE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC;YACpC,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;SACd;QACD,yCAAyC;QACzC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACd,IAAI,CAAC,UAAU,EAAE,CAAC;SACnB;QACD,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;CAWF;AAtEC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACjD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;sDAClB;AAMN;IAAlB,KAAK,EAAE;yCAAsB;AAG9B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAC,CAAC;gDAC3D","sourcesContent":["import {LitElement, PropertyValues} from \"lit\";\nimport {property, state} from \"lit/decorators.js\";\nimport {consume, ContextConsumer, createContext} from \"@lit-labs/context\";\nimport {ZomeName} from \"@holochain/client\";\nimport {cellContext} from \"./elements/cell-context\";\nimport { ZomeViewModel } from \"./ZomeViewModel\";\nimport {Cell, CellMixin} from \"@ddd-qc/cell-proxy\";\n\n\n/**\n * LitElement that is bound to a specific ZomeViewModel, e.g. a View for the ViewModel\n */\nexport class ZomeElement<P, ZVM extends ZomeViewModel> extends CellMixin(LitElement) {\n\n constructor(public readonly defaultZomeName: ZomeName) {\n super();\n // const nameAttr = this.getAttribute(\"zomeName\");\n // if (nameAttr) {\n // this.zomeName = nameAttr;\n // }\n }\n\n @consume({ context: cellContext, subscribe: true})\n @property({type: Object, attribute: false})\n _cell_via_context!: Cell;\n\n protected _zomeName!: ZomeName;\n get zomeName(): ZomeName {return this._zomeName};\n\n /** Provided by Context depending on cellData.dnaHash */\n @state() protected _zvm!: ZVM;\n\n @property({type: Object, attribute: false, hasChanged: (_v, _old) => true})\n perspective!: P;\n\n\n /** -- Methods -- */\n\n /** Request zvm from Context based on current CellId */\n private requestZvm() {\n if (!this._cell_via_context) {\n throw Error(`Context \"${cellContext}\" not found from ZomeElement \"${this.constructor.name}\"`)\n }\n const contextType = createContext<ZVM>('zvm/'+ this.defaultZomeName + '/' + this.cell.dnaHash)\n console.log(`\\t\\t Requesting context \"${contextType}\"`)\n /*const consumer =*/ new ContextConsumer(\n this,\n contextType,\n async (value: ZVM, dispose?: () => void): Promise<void> => {\n console.log(`\\t\\t Received value for context \"${contextType}\"`)\n await this.zvmUpdated(value, this._zvm);\n if (this._zvm) {\n this._zvm.unsubscribe(this);\n }\n this._zvm = value;\n this._zomeName = this._zvm.zomeName;\n this._zvm.subscribe(this, 'perspective');\n },\n false, // true will call twice at init\n );\n }\n\n\n /** Subclass can override this to get notified when a new ZVM has been received */\n protected async zvmUpdated(newZvm: ZVM, oldZvm?: ZVM): Promise<void> {\n //console.log(`\\t\\t Default zvmUpdated() called`)\n }\n\n\n /** */\n shouldUpdate(changedProperties: PropertyValues<this>) {\n //console.log(\"ZomeElement.shouldUpdate() start\", !!this._zvm, this.installedCell);\n if (changedProperties.has(\"_cell_via_context\")) {\n //console.log(\"ZomeElement.shouldUpdate()\", this._cell_via_context)\n this._cell = this._cell_via_context;\n this.requestZvm();\n return false;\n }\n /** RequestZvm on first \"shouldUpdate\" */\n if (!this._zvm) {\n this.requestZvm();\n }\n return !!this._zvm;\n }\n\n\n // /** Request ZVM if cell changed */\n // protected willUpdate(changedProperties: PropertyValues<this>) {\n // //console.log(\"ZomeElement.willUpdate()\", changedProperties)\n // if (changedProperties.has(\"_cell_via_context\")) {\n // this.requestZvm();\n // }\n // }\n\n}\n\n"]}
1
+ {"version":3,"file":"ZomeElement.js","sourceRoot":"","sources":["../src/ZomeElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAiB,MAAM,KAAK,CAAC;AAC/C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAErE,OAAO,EAAC,WAAW,EAAC,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAO,SAAS,EAAC,MAAM,oBAAoB,CAAC;AAGnD;;GAEG;AACH,MAAM,OAAO,WAA0C,SAAQ,SAAS,CAAC,UAAU,CAAC;IAElF,YAA4B,eAAyB;QACnD,KAAK,EAAE,CAAC;QADkB,oBAAe,GAAf,eAAe,CAAU;QAEnD,kDAAkD;QAClD,kBAAkB;QAClB,8BAA8B;QAC9B,IAAI;IACN,CAAC;IAOD,IAAI,QAAQ,KAAc,OAAO,IAAI,CAAC,SAAS,CAAA,CAAA,CAAC;IAAA,CAAC;IASjD,oBAAoB;IAEpB,uDAAuD;IAC/C,UAAU;QAChB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE;YAC3B,MAAM,KAAK,CAAC,YAAY,WAAW,iCAAiC,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,CAAA;SAC9F;QACD,MAAM,WAAW,GAAG,aAAa,CAAM,MAAM,GAAE,IAAI,CAAC,eAAe,GAAG,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9F,OAAO,CAAC,GAAG,CAAC,4BAA4B,WAAW,GAAG,CAAC,CAAA;QACvD,oBAAo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AClB;AAMN;IAAlB,KAAK,EAAE;yCAAsB;AAG9B;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,EAAC,CAAC;gDAC3D","sourcesContent":["import {LitElement, PropertyValues} from \"lit\";\nimport {property, state} from \"lit/decorators.js\";\nimport {consume, ContextConsumer, createContext} from \"@lit/context\";\nimport {ZomeName} from \"@holochain/client\";\nimport {cellContext} from \"./elements/cell-context\";\nimport { ZomeViewModel } from \"./ZomeViewModel\";\nimport {Cell, CellMixin} from \"@ddd-qc/cell-proxy\";\n\n\n/**\n * LitElement that is bound to a specific ZomeViewModel, e.g. a View for the ViewModel\n */\nexport class ZomeElement<P, ZVM extends ZomeViewModel> extends CellMixin(LitElement) {\n\n constructor(public readonly defaultZomeName: ZomeName) {\n super();\n // const nameAttr = this.getAttribute(\"zomeName\");\n // if (nameAttr) {\n // this.zomeName = nameAttr;\n // }\n }\n\n @consume({ context: cellContext, subscribe: true})\n @property({type: Object, attribute: false})\n _cell_via_context!: Cell;\n\n protected _zomeName!: ZomeName;\n get zomeName(): ZomeName {return this._zomeName};\n\n /** Provided by Context depending on cellData.dnaHash */\n @state() protected _zvm!: ZVM;\n\n @property({type: Object, attribute: false, hasChanged: (_v, _old) => true})\n perspective!: P;\n\n\n /** -- Methods -- */\n\n /** Request zvm from Context based on current CellId */\n private requestZvm() {\n if (!this._cell_via_context) {\n throw Error(`Context \"${cellContext}\" not found from ZomeElement \"${this.constructor.name}\"`)\n }\n const contextType = createContext<ZVM>('zvm/'+ this.defaultZomeName + '/' + this.cell.dnaHash)\n console.log(`\\t\\t Requesting context \"${contextType}\"`)\n /*const consumer =*/ new ContextConsumer(\n this,\n contextType,\n async (value: ZVM, dispose?: () => void): Promise<void> => {\n console.log(`\\t\\t Received value for context \"${contextType}\"`)\n await this.zvmUpdated(value, this._zvm);\n if (this._zvm) {\n this._zvm.unsubscribe(this);\n }\n this._zvm = value;\n this._zomeName = this._zvm.zomeName;\n this._zvm.subscribe(this, 'perspective');\n },\n false, // true will call twice at init\n );\n }\n\n\n /** Subclass can override this to get notified when a new ZVM has been received */\n protected async zvmUpdated(newZvm: ZVM, oldZvm?: ZVM): Promise<void> {\n //console.log(`\\t\\t Default zvmUpdated() called`)\n }\n\n\n /** */\n shouldUpdate(changedProperties: PropertyValues<this>) {\n //console.log(\"ZomeElement.shouldUpdate() start\", !!this._zvm, this.installedCell);\n if (changedProperties.has(\"_cell_via_context\")) {\n //console.log(\"ZomeElement.shouldUpdate()\", this._cell_via_context)\n this._cell = this._cell_via_context;\n this.requestZvm();\n return false;\n }\n /** RequestZvm on first \"shouldUpdate\" */\n if (!this._zvm) {\n this.requestZvm();\n }\n return !!this._zvm;\n }\n\n\n // /** Request ZVM if cell changed */\n // protected willUpdate(changedProperties: PropertyValues<this>) {\n // //console.log(\"ZomeElement.willUpdate()\", changedProperties)\n // if (changedProperties.has(\"_cell_via_context\")) {\n // this.requestZvm();\n // }\n // }\n\n}\n\n"]}
@@ -1,4 +1,4 @@
1
- import { Context } from "@lit-labs/context";
1
+ import { Context } from "@lit/context";
2
2
  import { CellProxy, ZomeProxy, ZomeProxyConstructor } from "@ddd-qc/cell-proxy";
3
3
  import { ViewModel } from "./ViewModel";
4
4
  import { AppSignalCb, ZomeName } from "@holochain/client";
@@ -1,4 +1,4 @@
1
- import { createContext } from "@lit-labs/context";
1
+ import { createContext } from "@lit/context";
2
2
  import { CellMixin } from "@ddd-qc/cell-proxy";
3
3
  import { ViewModel } from "./ViewModel";
4
4
  /** (EXPERIMENTAL) Class Decorator */
@@ -1 +1 @@
1
- {"version":3,"file":"ZomeViewModel.js","sourceRoot":"","sources":["../src/ZomeViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAC,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAA6C,SAAS,EAAC,MAAM,oBAAoB,CAAC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B,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IACtF,CAAC;IAGD,wBAAwB;IACd,iBAAiB;QACvB,MAAM,UAAU,GAAG,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAC7C,IAAI,UAAU,EAAE;YACZ,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;SACpC;QACD,OAAO,UAAU,CAAC;IACtB,CAAC;IAED,iCAAiC;IACzB,gBAAgB,CAAC,MAAiB;QACtC,wFAAwF;QACxF,IAAI,IAAI,CAAC,aAAa,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;YACzD,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;SAC9B;IACL,CAAC;IAED,MAAM;IACN,UAAU;QACN,MAAM,OAAO,GAAG,aAAa,CAAc,MAAM,GAAE,IAAI,CAAC,UAAU,CAAC,eAAe,GAAE,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC5G,4CAA4C;QAC5C,OAAO,OAAO,CAAA;IAClB,CAAC;CACJ","sourcesContent":["import {Context, createContext} from \"@lit-labs/context\";\nimport {CellProxy, ZomeProxy, ZomeProxyConstructor, CellMixin} from \"@ddd-qc/cell-proxy\";\nimport {ViewModel} from \"./ViewModel\";\nimport {AppSignalCb, ZomeName} from \"@holochain/client\";\nimport {AppSignal} from \"@holochain/client/lib/api/app/types\";\nimport {DnaViewModel} from \"./DnaViewModel\";\n\nexport type ZvmConstructor = {new(proxy: CellProxy, dvmParent: DnaViewModel, zomeName?: ZomeName): ZomeViewModel} /*& typeof ZomeSpecific;*/\n\n/** (EXPERIMENTAL) Class Decorator */\nexport function zvm(zProxyCtor: typeof ZomeProxy) {\n return (ctor: Function) => {\n //let zvmCtor = (ctor as typeof ZomeViewModel);\n (ctor as any).ZOME_PROXY = zProxyCtor;\n //get zomeProxy(): DummyZomeProxy {return this._zomeProxy as DummyZomeProxy;}\n //(ctor as any).zomeProxy = function() {return (ctor as any)._zomeProxy as typeof zProxyFactory;}\n //(ctor as any).zomeProxy = (ctor as any)._zomeProxy as typeof zProxyFactory;\n }\n}\n\n\n/**\n * Abstract ViewModel for a Zome.\n * It extends a ViewModel by adding a ZomeProxy.\n * Views are required to use this in order to interact with the ZomeProxy.\n * The perspective is the data from the Zome that is transformed and enhanced in order to be consumed by a View.\n * It can be automatically updated by Signals or the Zome Scheduler.\n */\nexport abstract class ZomeViewModel extends CellMixin(ViewModel) {\n\n /** Zome proxy constructor */\n static ZOME_PROXY: ZomeProxyConstructor;\n protected _zomeProxy: ZomeProxy;\n /* Child class should implement with child proxy class as return type */\n abstract get zomeProxy(): ZomeProxy;\n getProxyConstructor(): ZomeProxyConstructor {\n return (this.constructor as typeof ZomeViewModel).ZOME_PROXY;\n }\n\n signalHandler?: AppSignalCb;\n\n /** Zome name */\n static get DEFAULT_ZOME_NAME(): string {\n return this.ZOME_PROXY.DEFAULT_ZOME_NAME;\n }\n zomeName!: ZomeName;\n\n protected _dvmParent: DnaViewModel;\n\n\n /** Ctor */\n constructor(cellProxy: CellProxy, dvmParent: DnaViewModel, zomeName?: ZomeName) {\n super();\n this._dvmParent = dvmParent;\n const zProxyCtor = this.getProxyConstructor();\n if (!zProxyCtor) {\n throw Error(\"ZOME_PROXY static field undefined in ZVM subclass \" + this.constructor.name);\n }\n if (zomeName) {\n this.zomeName = zomeName;\n this._zomeProxy = new zProxyCtor(cellProxy, this.zomeName);\n } else {\n this._zomeProxy = new zProxyCtor(cellProxy);\n this.zomeName = this._zomeProxy.defaultZomeName;\n }\n this._cell = cellProxy.cell;\n cellProxy.addSignalHandler( (signal: AppSignal) => this.handleZomeSignal(signal));\n }\n\n\n /** Notify DVM parent */\n protected notifySubscribers(): boolean {\n const hasChanged = super.notifySubscribers();\n if (hasChanged) {\n this._dvmParent.zvmChanged(this);\n }\n return hasChanged;\n }\n\n /** Filter signal by zome name */\n private handleZomeSignal(signal: AppSignal) {\n //console.log(\"handleZomeSignal()\", this.signalHandler, this.zomeName, signal.zome_name)\n if (this.signalHandler && signal.zome_name == this.zomeName) {\n this.signalHandler(signal);\n }\n }\n\n /** */\n getContext(): Context<unknown, unknown> {\n const context = createContext<typeof this>('zvm/'+ this._zomeProxy.defaultZomeName +'/' + this.cell.dnaHash)\n //console.log({contextType: typeof context})\n return context\n }\n}\n\n"]}
1
+ {"version":3,"file":"ZomeViewModel.js","sourceRoot":"","sources":["../src/ZomeViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,aAAa,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,EAA6C,SAAS,EAAC,MAAM,oBAAoB,CAAC;AACzF,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AAOtC,qCAAqC;AACrC,MAAM,UAAU,GAAG,CAAC,UAA4B;IAC5C,OAAO,CAAC,IAAc,EAAE,EAAE;QACtB,+CAA+C;QAC9C,IAAY,CAAC,UAAU,GAAG,UAAU,CAAC;QACtC,6EAA6E;QAC7E,iGAAiG;QACjG,6EAA6E;IACjF,CAAC,CAAA;AACL,CAAC;AAGD;;;;;;GAMG;AACH,MAAM,OAAgB,aAAc,SAAQ,SAAS,CAAC,SAAS,CAAC;IAO5D,mBAAmB;QACf,OAAQ,IAAI,CAAC,WAAoC,CAAC,UAAU,CAAC;IACjE,CAAC;IAID,gBAAgB;IAChB,MAAM,KAAK,iBAAiB;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC;IAC7C,CAAC;IAMD,WAAW;IACX,YAAY,SAAoB,EAAE,SAAuB,EAAE,QAAmB;QAC1E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC9C,IAAI,CAAC,UAAU,EAAE;YACb,MAAM,KAAK,CAAC,oDAAoD,GAAG,IAAI,CAAC,WAAW,C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in} from \"@ddd-qc/cell-proxy\";\nimport {ViewModel} from \"./ViewModel\";\nimport {AppSignalCb, ZomeName} from \"@holochain/client\";\nimport {AppSignal} from \"@holochain/client/lib/api/app/types\";\nimport {DnaViewModel} from \"./DnaViewModel\";\n\nexport type ZvmConstructor = {new(proxy: CellProxy, dvmParent: DnaViewModel, zomeName?: ZomeName): ZomeViewModel} /*& typeof ZomeSpecific;*/\n\n/** (EXPERIMENTAL) Class Decorator */\nexport function zvm(zProxyCtor: typeof ZomeProxy) {\n return (ctor: Function) => {\n //let zvmCtor = (ctor as typeof ZomeViewModel);\n (ctor as any).ZOME_PROXY = zProxyCtor;\n //get zomeProxy(): DummyZomeProxy {return this._zomeProxy as DummyZomeProxy;}\n //(ctor as any).zomeProxy = function() {return (ctor as any)._zomeProxy as typeof zProxyFactory;}\n //(ctor as any).zomeProxy = (ctor as any)._zomeProxy as typeof zProxyFactory;\n }\n}\n\n\n/**\n * Abstract ViewModel for a Zome.\n * It extends a ViewModel by adding a ZomeProxy.\n * Views are required to use this in order to interact with the ZomeProxy.\n * The perspective is the data from the Zome that is transformed and enhanced in order to be consumed by a View.\n * It can be automatically updated by Signals or the Zome Scheduler.\n */\nexport abstract class ZomeViewModel extends CellMixin(ViewModel) {\n\n /** Zome proxy constructor */\n static ZOME_PROXY: ZomeProxyConstructor;\n protected _zomeProxy: ZomeProxy;\n /* Child class should implement with child proxy class as return type */\n abstract get zomeProxy(): ZomeProxy;\n getProxyConstructor(): ZomeProxyConstructor {\n return (this.constructor as typeof ZomeViewModel).ZOME_PROXY;\n }\n\n signalHandler?: AppSignalCb;\n\n /** Zome name */\n static get DEFAULT_ZOME_NAME(): string {\n return this.ZOME_PROXY.DEFAULT_ZOME_NAME;\n }\n zomeName!: ZomeName;\n\n protected _dvmParent: DnaViewModel;\n\n\n /** Ctor */\n constructor(cellProxy: CellProxy, dvmParent: DnaViewModel, zomeName?: ZomeName) {\n super();\n this._dvmParent = dvmParent;\n const zProxyCtor = this.getProxyConstructor();\n if (!zProxyCtor) {\n throw Error(\"ZOME_PROXY static field undefined in ZVM subclass \" + this.constructor.name);\n }\n if (zomeName) {\n this.zomeName = zomeName;\n this._zomeProxy = new zProxyCtor(cellProxy, this.zomeName);\n } else {\n this._zomeProxy = new zProxyCtor(cellProxy);\n this.zomeName = this._zomeProxy.defaultZomeName;\n }\n this._cell = cellProxy.cell;\n cellProxy.addSignalHandler( (signal: AppSignal) => this.handleZomeSignal(signal));\n }\n\n\n /** Notify DVM parent */\n protected notifySubscribers(): boolean {\n const hasChanged = super.notifySubscribers();\n if (hasChanged) {\n this._dvmParent.zvmChanged(this);\n }\n return hasChanged;\n }\n\n /** Filter signal by zome name */\n private handleZomeSignal(signal: AppSignal) {\n //console.log(\"handleZomeSignal()\", this.signalHandler, this.zomeName, signal.zome_name)\n if (this.signalHandler && signal.zome_name == this.zomeName) {\n this.signalHandler(signal);\n }\n }\n\n /** */\n getContext(): Context<unknown, unknown> {\n const context = createContext<typeof this>('zvm/'+ this._zomeProxy.defaultZomeName +'/' + this.cell.dnaHash)\n //console.log({contextType: typeof context})\n return context\n }\n}\n\n"]}
@@ -1,5 +1,5 @@
1
1
  import { __decorate } from "tslib";
2
- import { ContextProvider, createContext } from '@lit-labs/context';
2
+ import { ContextProvider, createContext } from '@lit/context';
3
3
  import { LitElement, html } from "lit";
4
4
  import { property, state, customElement } from "lit/decorators.js";
5
5
  export const cellContext = createContext('lit-happ/cell');
@@ -1 +1 @@
1
- {"version":3,"file":"cell-context.js","sourceRoot":"","sources":["../../src/elements/cell-context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAC,UAAU,EAAE,IAAI,EAAiB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAIjE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAO,eAA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,IAAI,CAAC,YAAY,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;aAChF;SACF;IACH,CAAC;IAGD,MAAM;IACN,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,OAAO,IAAI,CAAA,EAAE,CAAC;SACf;QACD,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;CACF,CAAA;AAxDC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yCACb;AAGZ;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;wCACP;AAQD;IAAhB,KAAK,EAAE;iDAA8B;AAd3B,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA2DvB","sourcesContent":["import {ContextProvider, createContext} from '@lit-labs/context';\nimport {LitElement, html, PropertyValues} from \"lit\";\nimport {property, state, customElement} from \"lit/decorators.js\";\nimport {Cell} from \"@ddd-qc/cell-proxy\";\nimport {DnaViewModel} from \"../DnaViewModel\";\n\nexport const cellContext = createContext<Cell>('lit-happ/cell');\n//export const cellContext = createContext<Cell>('lit-happ/cell/default');\n\n\n/**\n *\n */\n@customElement(\"cell-context\")\nexport class CellContext extends LitElement {\n\n @property({type: Object})\n cell!: Cell;\n\n @property({type: Object})\n dvm: DnaViewModel;\n\n /* create a provider controller */\n /*@state()*/ private _cellProvider = new ContextProvider(this, cellContext, this.cell);\n\n private _dnaProvider?;\n\n\n @state() private _initialized = false;\n\n\n\n /** */\n firstUpdated() {\n /** Cell */\n if (!this.cell) throw Error('\"cell\" property not defined in <cell-context>')\n //this._provider = new ContextProvider(this, cellContext, this.cell);\n this._cellProvider.setValue(this.cell);\n this._initialized = true;\n console.log(`\\t Cell context set to \"${this.cell.name}\"`)\n\n /** DVM */\n if (this.dvm) {\n this._dnaProvider = new ContextProvider(this, this.dvm.getContext(), this.dvm);\n }\n }\n\n\n /** Set provider to cell */\n protected willUpdate(changedProperties: PropertyValues<this>) {\n //console.log(\"<cell-context>.willUpdate()\", changedProperties)\n if (changedProperties.has(\"cell\")) {\n //console.log(\"<cell-context>.willUpdate() changed installed cell\", this.cell.name)\n this._cellProvider.setValue(this.cell);\n console.log(`\\t Cell context changed to \"${this.cell.name}\"`)\n }\n\n if (changedProperties.has(\"dvm\")) {\n this._dnaProvider = undefined;\n if (this.dvm) {\n this._dnaProvider = new ContextProvider(this, this.dvm.getContext(), this.dvm);\n }\n }\n }\n\n\n /** */\n render() {\n if (!this._initialized) {\n return html``;\n }\n return html`<slot></slot>`;\n }\n}\n"]}
1
+ {"version":3,"file":"cell-context.js","sourceRoot":"","sources":["../../src/elements/cell-context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,eAAe,EAAE,aAAa,EAAC,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAC,UAAU,EAAE,IAAI,EAAiB,MAAM,KAAK,CAAC;AACrD,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAIjE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAO,eAAe,CAAC,CAAC;AAChE,0EAA0E;AAG1E;;GAEG;AAEI,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,UAAU;IAApC;;QAQL,kCAAkC;QAClC,YAAY,CAAS,kBAAa,GAAG,IAAI,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAKtE,iBAAY,GAAG,KAAK,CAAC;IA6CxC,CAAC;IAzCC,MAAM;IACN,YAAY;QACV,WAAW;QACX,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,MAAM,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAC5E,qEAAqE;QACrE,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,IA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A8B;AAd3B,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA2DvB","sourcesContent":["import {ContextProvider, createContext} from '@lit/context';\nimport {LitElement, html, PropertyValues} from \"lit\";\nimport {property, state, customElement} from \"lit/decorators.js\";\nimport {Cell} from \"@ddd-qc/cell-proxy\";\nimport {DnaViewModel} from \"../DnaViewModel\";\n\nexport const cellContext = createContext<Cell>('lit-happ/cell');\n//export const cellContext = createContext<Cell>('lit-happ/cell/default');\n\n\n/**\n *\n */\n@customElement(\"cell-context\")\nexport class CellContext extends LitElement {\n\n @property({type: Object})\n cell!: Cell;\n\n @property({type: Object})\n dvm: DnaViewModel;\n\n /* create a provider controller */\n /*@state()*/ private _cellProvider = new ContextProvider(this, cellContext, this.cell);\n\n private _dnaProvider?;\n\n\n @state() private _initialized = false;\n\n\n\n /** */\n firstUpdated() {\n /** Cell */\n if (!this.cell) throw Error('\"cell\" property not defined in <cell-context>')\n //this._provider = new ContextProvider(this, cellContext, this.cell);\n this._cellProvider.setValue(this.cell);\n this._initialized = true;\n console.log(`\\t Cell context set to \"${this.cell.name}\"`)\n\n /** DVM */\n if (this.dvm) {\n this._dnaProvider = new ContextProvider(this, this.dvm.getContext(), this.dvm);\n }\n }\n\n\n /** Set provider to cell */\n protected willUpdate(changedProperties: PropertyValues<this>) {\n //console.log(\"<cell-context>.willUpdate()\", changedProperties)\n if (changedProperties.has(\"cell\")) {\n //console.log(\"<cell-context>.willUpdate() changed installed cell\", this.cell.name)\n this._cellProvider.setValue(this.cell);\n console.log(`\\t Cell context changed to \"${this.cell.name}\"`)\n }\n\n if (changedProperties.has(\"dvm\")) {\n this._dnaProvider = undefined;\n if (this.dvm) {\n this._dnaProvider = new ContextProvider(this, this.dvm.getContext(), this.dvm);\n }\n }\n }\n\n\n /** */\n render() {\n if (!this._initialized) {\n return html``;\n }\n return html`<slot></slot>`;\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { LitElement, html } from "lit";
3
3
  import { property, customElement } from "lit/decorators.js";
4
- import { consume } from "@lit-labs/context";
4
+ import { consume } from "@lit/context";
5
5
  import { cellContext } from "./cell-context";
6
6
  /**
7
7
  * LitElement that shows the cellContext as a <div>
@@ -1 +1 @@
1
- {"version":3,"file":"view-cell-context.js","sourceRoot":"","sources":["../../src/elements/view-cell-context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAI3C;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAM7C,MAAM;QACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAA,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACvE,OAAO,IAAI,CAAA;;kCAEmB,QAAQ;;KAErC,CAAC;IACJ,CAAC;CACF,CAAA;AAVC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACjD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACb;AAJD,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAc3B","sourcesContent":["import {LitElement, html} from \"lit\";\nimport {property, customElement} from \"lit/decorators.js\";\nimport {consume} from \"@lit-labs/context\";\nimport {cellContext} from \"./cell-context\";\nimport {Cell} from \"@ddd-qc/cell-proxy\";\n\n\n/**\n * LitElement that shows the cellContext as a <div>\n * Used for debugging\n */\n@customElement(\"view-cell-context\")\nexport class ViewCellContext extends LitElement {\n\n @consume({ context: cellContext, subscribe: true})\n @property({type: Object})\n cell!: Cell;\n\n render() {\n const cellName = this.cell === undefined? \"undefined\" : this.cell.name;\n return html`\n <div>\n <span><b>(Cell set to: \"${cellName}\")</b></span>\n </div>\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"view-cell-context.js","sourceRoot":"","sources":["../../src/elements/view-cell-context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,KAAK,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAI3C;;;GAGG;AAEI,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAM7C,MAAM;QACJ,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,KAAK,SAAS,CAAA,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;QACvE,OAAO,IAAI,CAAA;;kCAEmB,QAAQ;;KAErC,CAAC;IACJ,CAAC;CACF,CAAA;AAVC;IAFC,OAAO,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACjD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACb;AAJD,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAc3B","sourcesContent":["import {LitElement, html} from \"lit\";\nimport {property, customElement} from \"lit/decorators.js\";\nimport {consume} from \"@lit/context\";\nimport {cellContext} from \"./cell-context\";\nimport {Cell} from \"@ddd-qc/cell-proxy\";\n\n\n/**\n * LitElement that shows the cellContext as a <div>\n * Used for debugging\n */\n@customElement(\"view-cell-context\")\nexport class ViewCellContext extends LitElement {\n\n @consume({ context: cellContext, subscribe: true})\n @property({type: Object})\n cell!: Cell;\n\n render() {\n const cellName = this.cell === undefined? \"undefined\" : this.cell.name;\n return html`\n <div>\n <span><b>(Cell set to: \"${cellName}\")</b></span>\n </div>\n `;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddd-qc/lit-happ",
3
- "version": "0.20.0",
3
+ "version": "0.20.5",
4
4
  "description": "MVVM Framework for holochain apps using Lit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "dependencies": {
31
31
  "@ddd-qc/cell-proxy": "file:../cell-proxy",
32
32
  "@holochain/client": "=0.16.2",
33
- "@lit-labs/context": "0.5.1",
33
+ "@lit/context": "1.0.1",
34
34
  "lit": "3.0.2",
35
35
  "async-mutex": "0.4.0"
36
36
  }