@ddd-qc/lit-happ 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/DnaElement.d.ts +2 -2
- package/dist/DnaElement.js +1 -2
- package/dist/DnaElement.js.map +1 -1
- package/dist/DnaViewModel.d.ts +2 -2
- package/dist/DnaViewModel.js.map +1 -1
- package/dist/HappElement.d.ts +1 -3
- package/dist/HappElement.js +1 -2
- package/dist/HappElement.js.map +1 -1
- package/dist/ViewModel.d.ts +2 -2
- package/dist/ViewModel.js.map +1 -1
- package/dist/ZomeElement.d.ts +1 -1
- package/dist/ZomeElement.js +1 -2
- package/dist/ZomeElement.js.map +1 -1
- package/dist/ZomeViewModel.d.ts +2 -2
- package/dist/ZomeViewModel.js.map +1 -1
- package/dist/elements/cell-context.d.ts +4 -3
- package/dist/elements/cell-context.js +10 -4
- package/dist/elements/cell-context.js.map +1 -1
- package/dist/elements/entry-def-select.d.ts +1 -3
- package/dist/elements/entry-def-select.js +7 -4
- package/dist/elements/entry-def-select.js.map +1 -1
- package/dist/elements/view-cell-context.d.ts +1 -3
- package/dist/elements/view-cell-context.js +9 -6
- package/dist/elements/view-cell-context.js.map +1 -1
- package/package.json +3 -4
package/dist/DnaElement.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ declare const DnaElement_base: (abstract new (...args: any[]) => {
|
|
|
7
7
|
}) & ((abstract new (...args: any[]) => {
|
|
8
8
|
baseRoleName: string;
|
|
9
9
|
}) & {
|
|
10
|
-
readonly DEFAULT_BASE_ROLE_NAME: string;
|
|
11
|
-
}) & typeof LitElement
|
|
10
|
+
readonly DEFAULT_BASE_ROLE_NAME: string;
|
|
11
|
+
}) & typeof LitElement;
|
|
12
12
|
/**
|
|
13
13
|
* A LitElement that is bound to a specific DnaViewModel, e.g. a View for the ViewModel
|
|
14
14
|
*/
|
package/dist/DnaElement.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
3
2
|
import { LitElement } from "lit";
|
|
4
3
|
import { property, state } from "lit/decorators.js";
|
|
5
4
|
import { ContextConsumer, contextProvided, createContext } from "@lit-labs/context";
|
|
@@ -9,7 +8,7 @@ import { RoleMixin } from "./roleMixin";
|
|
|
9
8
|
/**
|
|
10
9
|
* A LitElement that is bound to a specific DnaViewModel, e.g. a View for the ViewModel
|
|
11
10
|
*/
|
|
12
|
-
export class DnaElement extends CellMixin(RoleMixin(
|
|
11
|
+
export class DnaElement extends CellMixin(RoleMixin(LitElement)) {
|
|
13
12
|
/** if BaseRoleName is not provided, subclass must call requestDvm() in its Ctor */
|
|
14
13
|
constructor(baseRoleName) {
|
|
15
14
|
super();
|
package/dist/DnaElement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DnaElement.js","sourceRoot":"","sources":["../src/DnaElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
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,eAAe,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAElF,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,I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U,EAAE,CAAC;SACnB;QACD,OAAO,CAAC,CAAC,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;AAlEU;IAAR,KAAK,EAAE;wCAAsB;AAI9B;IAFC,eAAe,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACzD,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, contextProvided, 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 @contextProvided({ 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"]}
|
package/dist/DnaViewModel.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ 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
7
|
import { CellProxy, ConductorAppProxy, HCL, Dictionary } from "@ddd-qc/cell-proxy";
|
|
7
8
|
import { RoleSpecific } from "./roleMixin";
|
|
8
|
-
import { ContextKey } from "@lit-labs/context/src/lib/context-key";
|
|
9
9
|
/** Interface specific to DnaViewModel class */
|
|
10
10
|
interface IDnaViewModel {
|
|
11
11
|
dumpLogs(zomeName?: ZomeName): void;
|
|
@@ -49,7 +49,7 @@ export declare abstract class DnaViewModel extends DnaViewModel_base implements
|
|
|
49
49
|
/** -- Methods -- */
|
|
50
50
|
/** Override so we can provide context of all zvms */
|
|
51
51
|
provideContext(host: ReactiveElement): void;
|
|
52
|
-
getContext():
|
|
52
|
+
getContext(): Context<unknown, unknown>;
|
|
53
53
|
/** */
|
|
54
54
|
authorizeZomeCalls(adminWs: AdminWebsocket): Promise<void>;
|
|
55
55
|
/** */
|
package/dist/DnaViewModel.js.map
CHANGED
|
@@ -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,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAChD,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,iBAAoC,EAAE,OAA6B;QACpH,KAAK,EAAE,CAAC;QADkB,SAAI,GAAJ,IAAI,CAAiB;QAgCjD,qBAAqB;QACX,oBAAe,GAA8B,EAAE,CAAC;QAC1D,6BAA6B;QACnB,eAAU,GAAyB,EAAE,CAAC;QACxC,kBAAa,GAAoC,EAAE,CAAC;QAlC1D,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;YAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CA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AM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;YACrD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;YAC9B,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,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 {createContext} from \"@lit-labs/context\";\nimport {\n CellProxy,\n ConductorAppProxy,\n HCL,\n Dictionary, CellMixin\n} from \"@ddd-qc/cell-proxy\";\nimport {RoleMixin, RoleSpecific} from \"./roleMixin\";\nimport {ContextKey} from \"@lit-labs/context/src/lib/context-key\";\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 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: ConductorAppProxy, 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, conductorAppProxy: ConductorAppProxy, 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 = conductorAppProxy.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 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(): ContextKey<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 await adminWs.authorizeSigningCredentials(this.cell.id, grantedFns);\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 /** */\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 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,mBAAmB,CAAC;AACzD,OAAO,EAGL,GAAG,EACS,SAAS,EACtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAC,SAAS,EAAe,MAAM,aAAa,CAAC;AAmBpD;;;;;GAKG;AACH,MAAM,OAAgB,YAAa,SAAQ,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAMxE,WAAW;IACX,YAA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AE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;YAC/D,MAAM,CAAC,GAAG,GAAG,CAAC,2BAA2B,EAAE,CAAC;YAC5C,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACb;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAGD,iGAAiG;IACjG,KAAK,CAAC,iBAAiB;QACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE;YACrD,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC;YAC9B,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,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 ConductorAppProxy,\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 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: ConductorAppProxy, 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, conductorAppProxy: ConductorAppProxy, 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 = conductorAppProxy.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 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 await adminWs.authorizeSigningCredentials(this.cell.id, grantedFns);\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 /** */\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 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"]}
|
package/dist/HappElement.d.ts
CHANGED
|
@@ -4,11 +4,10 @@ import { HappViewModel } from "./HappViewModel";
|
|
|
4
4
|
import { CellDef, HvmDef } from "./definitions";
|
|
5
5
|
import { AppWebsocket, ClonedCell, InstalledAppId } from "@holochain/client";
|
|
6
6
|
import { DnaViewModel } from "./DnaViewModel";
|
|
7
|
-
declare const HappElement_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
8
7
|
/**
|
|
9
8
|
*
|
|
10
9
|
*/
|
|
11
|
-
export declare class HappElement extends
|
|
10
|
+
export declare class HappElement extends LitElement {
|
|
12
11
|
/** Must be defined by subclass */
|
|
13
12
|
static HVM_DEF: HvmDef;
|
|
14
13
|
/** Set during init triggered at ctor */
|
|
@@ -31,4 +30,3 @@ export declare class HappElement extends HappElement_base {
|
|
|
31
30
|
/** */
|
|
32
31
|
shouldUpdate(): boolean;
|
|
33
32
|
}
|
|
34
|
-
export {};
|
package/dist/HappElement.js
CHANGED
|
@@ -3,11 +3,10 @@ import { LitElement } from "lit";
|
|
|
3
3
|
import { state } from "lit/decorators.js";
|
|
4
4
|
import { ConductorAppProxy } from "@ddd-qc/cell-proxy";
|
|
5
5
|
import { HappViewModel } from "./HappViewModel";
|
|
6
|
-
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
7
6
|
/**
|
|
8
7
|
*
|
|
9
8
|
*/
|
|
10
|
-
export class HappElement extends
|
|
9
|
+
export class HappElement extends LitElement {
|
|
11
10
|
/** Ctor */
|
|
12
11
|
constructor(port_or_socket, appId) {
|
|
13
12
|
super();
|
package/dist/HappElement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HappElement.js","sourceRoot":"","sources":["../src/HappElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,KAAK,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAe,iBAAiB,EAAC,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"HappElement.js","sourceRoot":"","sources":["../src/HappElement.ts"],"names":[],"mappings":";AAAA,OA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AAG,CAAC,4BAA4B,EAAE,CAAC;QAC9C,MAAM,IAAI,CAAC,6BAA6B,EAAE,CAAC;QAC3C,kCAAkC;QAClC,MAAM,IAAI,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,4BAA4B,EAAE,CAAC;IAC5C,CAAC;IAGD,MAAM;IACN,KAAK,CAAC,WAAW,CAAC,YAA0B,EAAE,OAAiB;QAC7D,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;IAGD,MAAM;IACN,YAAY;QACV,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;CAEF;AAvDU;IAAR,KAAK,EAAE;wCAAqB","sourcesContent":["import {LitElement} from \"lit\";\nimport { state } from \"lit/decorators.js\";\nimport {BaseRoleName, ConductorAppProxy} from \"@ddd-qc/cell-proxy\";\nimport {HappViewModel} from \"./HappViewModel\";\nimport {CellDef, HvmDef} from \"./definitions\";\nimport {AppWebsocket, ClonedCell, InstalledAppId} from \"@holochain/client\";\nimport {DnaViewModel} from \"./DnaViewModel\";\n\n\n/**\n *\n */\nexport class HappElement extends LitElement {\n\n /** Must be defined by subclass */\n static HVM_DEF: HvmDef;\n\n /** Set during init triggered at ctor */\n conductorAppProxy!: ConductorAppProxy;\n @state() hvm!: HappViewModel;\n\n\n /** Ctor */\n protected constructor(port_or_socket: number | AppWebsocket, appId?: InstalledAppId) {\n super();\n /* await */ this.constructHvm(port_or_socket, appId);\n }\n\n /** */\n async hvmConstructed(): Promise<void> {}\n /** */\n async perspectiveInitializedOffline(): Promise<void> {}\n /** */\n async perspectiveInitializedOnline(): Promise<void> {}\n\n\n /** */\n protected async constructHvm(port_or_socket: number | AppWebsocket, appId?: InstalledAppId): Promise<void> {\n this.conductorAppProxy = await ConductorAppProxy.new(port_or_socket);\n const hvmDef = (this.constructor as typeof HappElement).HVM_DEF;\n if (!hvmDef) {\n throw Error(\"HVM_DEF static field undefined in HappElement subclass \" + this.constructor.name);\n }\n /** Override appId */\n if (appId) {\n hvmDef.id = appId;\n }\n this.hvm = await HappViewModel.new(this, this.conductorAppProxy, hvmDef);\n await this.hvmConstructed();\n await this.initializePerspective();\n }\n\n\n /** */\n async initializePerspective(): Promise<void> {\n await this.hvm.initializePerspectiveOffline();\n await this.perspectiveInitializedOffline();\n // TODO move this to a later stage\n await this.hvm.initializePerspectiveOnline();\n await this.perspectiveInitializedOnline();\n }\n\n\n /** */\n async createClone(baseRoleName: BaseRoleName, cellDef?: CellDef): Promise<[ClonedCell, DnaViewModel]> {\n return this.hvm.cloneDvm(baseRoleName, cellDef);\n }\n\n\n /** */\n shouldUpdate() {\n return !!this.hvm;\n }\n\n}\n"]}
|
package/dist/ViewModel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { Context } from "@lit-labs/context";
|
|
1
2
|
import { ReactiveControllerHost, ReactiveElement } from "lit";
|
|
2
3
|
import { AppSignalCb } from "@holochain/client";
|
|
3
|
-
import { ContextKey } from "@lit-labs/context/src/lib/context-key";
|
|
4
4
|
import { Mutex } from 'async-mutex';
|
|
5
5
|
declare enum InitializationState {
|
|
6
6
|
Uninitialized = "Uninitialized",
|
|
@@ -29,7 +29,7 @@ export declare abstract class ViewModel {
|
|
|
29
29
|
/** -- Abstract fields -- */
|
|
30
30
|
abstract signalHandler?: AppSignalCb;
|
|
31
31
|
/** -- Abstract methods -- */
|
|
32
|
-
abstract getContext():
|
|
32
|
+
abstract getContext(): Context<unknown, unknown>;
|
|
33
33
|
abstract get perspective(): unknown;
|
|
34
34
|
initializePerspectiveOffline(): Promise<void>;
|
|
35
35
|
initializePerspectiveOnline(): Promise<void>;
|
package/dist/ViewModel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViewModel.js","sourceRoot":"","sources":["../src/ViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+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rF,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;QACrC,KAAK,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,CAAC,cAAc,EAAE;YACjD,IAAY,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;SAC5C;QACD,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,WAAW,CAAA;QAC5C,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 for (const [host, propName] of this._providedHosts) {\n (host as any)[propName] = this.perspective;\n }\n this._previousPerspective = this.perspective\n return true;\n }\n\n}\n"]}
|
package/dist/ZomeElement.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { Cell } from "@ddd-qc/cell-proxy";
|
|
|
5
5
|
declare const ZomeElement_base: (abstract new (...args: any[]) => {
|
|
6
6
|
_cell?: Cell;
|
|
7
7
|
readonly cell: Cell;
|
|
8
|
-
}) & typeof LitElement
|
|
8
|
+
}) & typeof LitElement;
|
|
9
9
|
/**
|
|
10
10
|
* LitElement that is bound to a specific ZomeViewModel, e.g. a View for the ViewModel
|
|
11
11
|
*/
|
package/dist/ZomeElement.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
3
2
|
import { LitElement } from "lit";
|
|
4
3
|
import { property, state } from "lit/decorators.js";
|
|
5
4
|
import { ContextConsumer, contextProvided, createContext } from "@lit-labs/context";
|
|
@@ -8,7 +7,7 @@ import { CellMixin } from "@ddd-qc/cell-proxy";
|
|
|
8
7
|
/**
|
|
9
8
|
* LitElement that is bound to a specific ZomeViewModel, e.g. a View for the ViewModel
|
|
10
9
|
*/
|
|
11
|
-
export class ZomeElement extends CellMixin(
|
|
10
|
+
export class ZomeElement extends CellMixin(LitElement) {
|
|
12
11
|
constructor(defaultZomeName) {
|
|
13
12
|
super();
|
|
14
13
|
this.defaultZomeName = defaultZomeName;
|
package/dist/ZomeElement.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZomeElement.js","sourceRoot":"","sources":["../src/ZomeElement.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
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,eAAe,EAAE,eAAe,EAAE,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAElF,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,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ACrB,CAAC;CAWF;AAtEC;IAFC,eAAe,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,EAAC,CAAC;IACzD,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;sDAClB;AAMhB;IAAR,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 {ContextConsumer, contextProvided, 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 @contextProvided({ 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"]}
|
package/dist/ZomeViewModel.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Context } from "@lit-labs/context";
|
|
1
2
|
import { CellProxy, ZomeProxy, ZomeProxyConstructor } from "@ddd-qc/cell-proxy";
|
|
2
3
|
import { ViewModel } from "./ViewModel";
|
|
3
4
|
import { AppSignalCb, ZomeName } from "@holochain/client";
|
|
4
|
-
import { ContextKey } from "@lit-labs/context/src/lib/context-key";
|
|
5
5
|
import { DnaViewModel } from "./DnaViewModel";
|
|
6
6
|
export type ZvmConstructor = {
|
|
7
7
|
new (proxy: CellProxy, dvmParent: DnaViewModel, zomeName?: ZomeName): ZomeViewModel;
|
|
@@ -37,6 +37,6 @@ export declare abstract class ZomeViewModel extends ZomeViewModel_base {
|
|
|
37
37
|
/** Filter signal by zome name */
|
|
38
38
|
private handleZomeSignal;
|
|
39
39
|
/** */
|
|
40
|
-
getContext():
|
|
40
|
+
getContext(): Context<unknown, unknown>;
|
|
41
41
|
}
|
|
42
42
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ZomeViewModel.js","sourceRoot":"","sources":["../src/ZomeViewModel.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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;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;Q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AAC,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 private _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"]}
|
|
@@ -3,8 +3,10 @@ import { Cell } from "@ddd-qc/cell-proxy";
|
|
|
3
3
|
export declare const cellContext: {
|
|
4
4
|
__context__: Cell;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export declare class CellContext extends LitElement {
|
|
8
10
|
cell: Cell;
|
|
9
11
|
private _provider;
|
|
10
12
|
private _initialized;
|
|
@@ -15,4 +17,3 @@ export declare class CellContext extends CellContext_base {
|
|
|
15
17
|
/** */
|
|
16
18
|
render(): import("lit-html").TemplateResult<1>;
|
|
17
19
|
}
|
|
18
|
-
export {};
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { ContextProvider, createContext } from '@lit-labs/context';
|
|
3
3
|
import { LitElement, html } from "lit";
|
|
4
|
-
import { property, state } from "lit/decorators.js";
|
|
5
|
-
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
4
|
+
import { property, state, customElement } from "lit/decorators.js";
|
|
6
5
|
export const cellContext = createContext('lit-happ/cell');
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
let CellContext = class CellContext extends LitElement {
|
|
8
10
|
constructor() {
|
|
9
11
|
super(...arguments);
|
|
10
12
|
/* create a provider controller */
|
|
@@ -36,11 +38,15 @@ export class CellContext extends ScopedElementsMixin(LitElement) {
|
|
|
36
38
|
}
|
|
37
39
|
return html `<slot></slot>`;
|
|
38
40
|
}
|
|
39
|
-
}
|
|
41
|
+
};
|
|
40
42
|
__decorate([
|
|
41
43
|
property({ type: Object })
|
|
42
44
|
], CellContext.prototype, "cell", void 0);
|
|
43
45
|
__decorate([
|
|
44
46
|
state()
|
|
45
47
|
], CellContext.prototype, "_initialized", void 0);
|
|
48
|
+
CellContext = __decorate([
|
|
49
|
+
customElement("cell-context")
|
|
50
|
+
], CellContext);
|
|
51
|
+
export { CellContext };
|
|
46
52
|
//# sourceMappingURL=cell-context.js.map
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"cell-context.js","sourceRoot":"","sources":["../../src/elements/cell-context.ts"],"names":[],"mappings":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,EAAE,CAAC;SACf;QACD,OAAO,IAAI,CAAA,eAAe,CAAC;IAC7B,CAAC;CACF,CAAA;AAnCC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;yCACb;AAKH;IAAR,KAAK,EAAE;iDAA8B;AAR3B,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAsCvB;SAtCY,WAAW","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\";\n\nexport const cellContext = createContext<Cell>('lit-happ/cell');\n\n/**\n *\n */\n@customElement(\"cell-context\")\nexport class CellContext extends LitElement {\n\n @property({type: Object})\n cell!: Cell;\n\n /* create a provider controller */\n /*@state()*/ private _provider = new ContextProvider(this, cellContext, this.cell);\n\n @state() private _initialized = false;\n\n /** */\n firstUpdated() {\n if (!this.cell) throw Error('\"cell\" property not defined in <cell-context>')\n //this._provider = new ContextProvider(this, cellContext, this.cell);\n this._provider.setValue(this.cell);\n this._initialized = true;\n console.log(`\\t Cell context set to \"${this.cell.name}\"`)\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._provider.setValue(this.cell);\n console.log(`\\t Cell context changed to \"${this.cell.name}\"`)\n }\n }\n\n\n /** */\n render() {\n if (!this._initialized) {\n return html``;\n }\n return html`<slot></slot>`;\n }\n}\n"]}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { DnaViewModel } from "../DnaViewModel";
|
|
3
|
-
declare const EntryDefSelect_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
4
3
|
/**
|
|
5
4
|
*
|
|
6
5
|
*/
|
|
7
|
-
export declare class EntryDefSelect extends
|
|
6
|
+
export declare class EntryDefSelect extends LitElement {
|
|
8
7
|
/** -- Fields -- */
|
|
9
8
|
private _selectedZomeName;
|
|
10
9
|
private _allEntryDefs;
|
|
@@ -18,4 +17,3 @@ export declare class EntryDefSelect extends EntryDefSelect_base {
|
|
|
18
17
|
/** */
|
|
19
18
|
render(): import("lit-html").TemplateResult<1>;
|
|
20
19
|
}
|
|
21
|
-
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html } from "lit";
|
|
3
|
-
import { state, property } from "lit/decorators.js";
|
|
4
|
-
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
3
|
+
import { state, property, customElement } from "lit/decorators.js";
|
|
5
4
|
/**
|
|
6
5
|
*
|
|
7
6
|
*/
|
|
8
|
-
|
|
7
|
+
let EntryDefSelect = class EntryDefSelect extends LitElement {
|
|
9
8
|
constructor() {
|
|
10
9
|
super(...arguments);
|
|
11
10
|
/** -- Fields -- */
|
|
@@ -64,7 +63,7 @@ export class EntryDefSelect extends ScopedElementsMixin(LitElement) {
|
|
|
64
63
|
</select>
|
|
65
64
|
`;
|
|
66
65
|
}
|
|
67
|
-
}
|
|
66
|
+
};
|
|
68
67
|
__decorate([
|
|
69
68
|
state()
|
|
70
69
|
], EntryDefSelect.prototype, "_selectedZomeName", void 0);
|
|
@@ -74,4 +73,8 @@ __decorate([
|
|
|
74
73
|
__decorate([
|
|
75
74
|
property({ type: Object, attribute: false })
|
|
76
75
|
], EntryDefSelect.prototype, "dnaViewModel", void 0);
|
|
76
|
+
EntryDefSelect = __decorate([
|
|
77
|
+
customElement("entry-def-select")
|
|
78
|
+
], EntryDefSelect);
|
|
79
|
+
export { EntryDefSelect };
|
|
77
80
|
//# sourceMappingURL=entry-def-select.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entry-def-select.js","sourceRoot":"","sources":["../../src/elements/entry-def-select.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"entry-def-select.js","sourceRoot":"","sources":["../../src/elements/entry-def-select.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKnE;;GAEG;AAEI,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAEL,mBAAmB;QACF,sBAAiB,GAAG,EAAE,CAAA;QACtB,kBAAa,GAAoC,EAAE,CAAC;IAqEvE,CAAC;IA/DC,oBAAoB;IAEpB,KAAK,CAAC,YAAY;QAChB,IAAI,CAAC,aAAa,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,iBAAiB,EAAE,CAAA;IAClE,CAAC;IAED,MAAM;IACN,KAAK,CAAC,YAAY,CAAC,CAAM;QACvB,yCAAyC;QACzC,MAAM,YAAY,GAAG,IAAI,CAAC,UAAW,CAAC,cAAc,CAAC,cAAc,CAAsB,CAAC;QAC1F,IAAI,CAAC,iBAAiB,GAAG,YAAY,CAAC,KAAK,CAAC;IAC9C,CAAC;IAED,MAAM;IACN,KAAK,CAAC,aAAa,CAAC,CAAM;QACxB,2CAA2C;QAC3C,MAAM,aAAa,GAAG,IAAI,CAAC,UAAW,CAAC,cAAc,CAAC,mBAAmB,CAAsB,CAAC;QAChG,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,iBAAiB,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,EAAE;YACpE,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CA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KAAK,EAAE;yDAA+B;AAC9B;IAAR,KAAK,EAAE;qDAA6D;AAGrE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;oDACjB;AAPjB,cAAc;IAD1B,aAAa,CAAC,kBAAkB,CAAC;GACrB,cAAc,CAyE1B;SAzEY,cAAc","sourcesContent":["import { LitElement, html } from \"lit\";\nimport { state, property, customElement } from \"lit/decorators.js\";\nimport { DnaViewModel } from \"../DnaViewModel\";\nimport {Dictionary} from \"@ddd-qc/cell-proxy\";\n\n\n/**\n *\n */\n@customElement(\"entry-def-select\")\nexport class EntryDefSelect extends LitElement {\n\n /** -- Fields -- */\n @state() private _selectedZomeName = \"\"\n @state() private _allEntryDefs: Dictionary<[string, boolean][]> = {};\n\n @property({ type: Object, attribute: false })\n dnaViewModel!: DnaViewModel;\n\n\n /** -- Methods -- */\n\n async firstUpdated() {\n this._allEntryDefs = await this.dnaViewModel.fetchAllEntryDefs()\n }\n\n /** */\n async onZomeSelect(e: any) {\n //console.log(\"onZomeSelect() CALLED\", e)\n const zomeSelector = this.shadowRoot!.getElementById(\"selectedZome\") as HTMLSelectElement;\n this._selectedZomeName = zomeSelector.value;\n }\n\n /** */\n async onEntrySelect(e: any) {\n // console.log(\"onEntrySelect() CALLED\", e)\n const entrySelector = this.shadowRoot!.getElementById(\"selectedEntryType\") as HTMLSelectElement;\n const options = {\n detail: { zome: this._selectedZomeName, entry: entrySelector.value },\n bubbles: true,\n composed: true\n };\n this.dispatchEvent(new CustomEvent('entrySelected', options));\n }\n\n\n /** */\n render() {\n //console.log(\"<entry-def-select> render()\", this.dnaViewModel)\n // if (!this.dnaViewModel) {\n // return html`<span>Loading...</span>`;\n // }\n\n const zomeOptions = Object.entries(this._allEntryDefs).map(\n ([zomeName, _entryDef]) => {\n return html`<option>${zomeName}</option>`\n }\n )\n let zomeTypes = Object.entries(this._allEntryDefs)\n .filter((item) => { return item[0] == this._selectedZomeName; })\n .map((item) => { return item[1] });\n //console.log({zomeTypes})\n\n let entryTypeOptions = null;\n if (zomeTypes.length > 0) {\n entryTypeOptions = Object.entries(zomeTypes[0]).map(\n ([_zomeName, pair]) => {\n return html`<option>${pair[0]}</option>`;\n });\n }\n //console.log({entryTypeOptions})\n\n /** render all */\n return html`\n <select name=\"selectedZome\" id=\"selectedZome\" @click=${this.onZomeSelect}>\n ${zomeOptions}\n </select>\n <span>::</span>\n <select name=\"selectedEntryType\" id=\"selectedEntryType\" @click=${this.onEntrySelect}>\n ${entryTypeOptions}\n </select>\n `\n }\n}\n"]}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { LitElement } from "lit";
|
|
2
2
|
import { Cell } from "@ddd-qc/cell-proxy";
|
|
3
|
-
declare const ViewCellContext_base: typeof LitElement & import("@open-wc/dedupe-mixin").Constructor<import("@open-wc/scoped-elements/types/src/types").ScopedElementsHost>;
|
|
4
3
|
/**
|
|
5
4
|
* LitElement that shows the cellContext as a <div>
|
|
6
5
|
* Used for debugging
|
|
7
6
|
*/
|
|
8
|
-
export declare class ViewCellContext extends
|
|
7
|
+
export declare class ViewCellContext extends LitElement {
|
|
9
8
|
cell: Cell;
|
|
10
9
|
render(): import("lit-html").TemplateResult<1>;
|
|
11
10
|
}
|
|
12
|
-
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { ScopedElementsMixin } from "@open-wc/scoped-elements";
|
|
3
2
|
import { LitElement, html } from "lit";
|
|
4
|
-
import { property } from "lit/decorators.js";
|
|
5
|
-
import {
|
|
3
|
+
import { property, customElement } from "lit/decorators.js";
|
|
4
|
+
import { consume } from "@lit-labs/context";
|
|
6
5
|
import { cellContext } from "./cell-context";
|
|
7
6
|
/**
|
|
8
7
|
* LitElement that shows the cellContext as a <div>
|
|
9
8
|
* Used for debugging
|
|
10
9
|
*/
|
|
11
|
-
|
|
10
|
+
let ViewCellContext = class ViewCellContext extends LitElement {
|
|
12
11
|
render() {
|
|
13
12
|
const cellName = this.cell === undefined ? "undefined" : this.cell.name;
|
|
14
13
|
return html `
|
|
@@ -17,9 +16,13 @@ export class ViewCellContext extends ScopedElementsMixin(LitElement) {
|
|
|
17
16
|
</div>
|
|
18
17
|
`;
|
|
19
18
|
}
|
|
20
|
-
}
|
|
19
|
+
};
|
|
21
20
|
__decorate([
|
|
22
|
-
|
|
21
|
+
consume({ context: cellContext, subscribe: true }),
|
|
23
22
|
property({ type: Object })
|
|
24
23
|
], ViewCellContext.prototype, "cell", void 0);
|
|
24
|
+
ViewCellContext = __decorate([
|
|
25
|
+
customElement("view-cell-context")
|
|
26
|
+
], ViewCellContext);
|
|
27
|
+
export { ViewCellContext };
|
|
25
28
|
//# sourceMappingURL=view-cell-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view-cell-context.js","sourceRoot":"","sources":["../../src/elements/view-cell-context.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,
|
|
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;SAdY,eAAe","sourcesContent":["import {LitElement, html} from \"lit\";\r\nimport {property, customElement} from \"lit/decorators.js\";\r\nimport {consume} from \"@lit-labs/context\";\r\nimport {cellContext} from \"./cell-context\";\r\nimport {Cell} from \"@ddd-qc/cell-proxy\";\r\n\r\n\r\n/**\r\n * LitElement that shows the cellContext as a <div>\r\n * Used for debugging\r\n */\r\n@customElement(\"view-cell-context\")\r\nexport class ViewCellContext extends LitElement {\r\n\r\n @consume({ context: cellContext, subscribe: true})\r\n @property({type: Object})\r\n cell!: Cell;\r\n\r\n render() {\r\n const cellName = this.cell === undefined? \"undefined\" : this.cell.name;\r\n return html`\r\n <div>\r\n <span><b>(Cell set to: \"${cellName}\")</b></span>\r\n </div>\r\n `;\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-qc/lit-happ",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"description": "MVVM Framework for holochain apps using Lit",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -29,9 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@ddd-qc/cell-proxy": "file:../cell-proxy",
|
|
32
|
-
"@lit-labs/context": "^0.
|
|
33
|
-
"
|
|
34
|
-
"lit": "^2.3.0",
|
|
32
|
+
"@lit-labs/context": "^0.2.0",
|
|
33
|
+
"lit": "^2.6.0",
|
|
35
34
|
"async-mutex": "0.4.0"
|
|
36
35
|
}
|
|
37
36
|
}
|