@blockprotocol/graph
Advanced tools
Comparing version
@@ -6,3 +6,3 @@ import { LitElement } from "lit"; | ||
export declare abstract class BlockElementBase<BlockEntityProperties extends Record<string, unknown> | null> extends LitElement { | ||
protected graphService: GraphBlockHandler; | ||
protected graphService?: GraphBlockHandler; | ||
static properties: { | ||
@@ -13,3 +13,2 @@ graph: { | ||
}; | ||
constructor(); | ||
connectedCallback(): void; | ||
@@ -16,0 +15,0 @@ disconnectedCallback(): void; |
@@ -7,9 +7,5 @@ "use strict"; | ||
class BlockElementBase extends lit_1.LitElement { | ||
constructor() { | ||
super(); | ||
this.graphService = new index_1.GraphBlockHandler({ element: this }); | ||
} | ||
connectedCallback() { | ||
super.connectedCallback(); | ||
if (this.graphService.destroyed) { | ||
if (!this.graphService || this.graphService.destroyed) { | ||
this.graphService = new index_1.GraphBlockHandler({ element: this }); | ||
@@ -20,3 +16,3 @@ } | ||
super.disconnectedCallback(); | ||
if (!this.graphService.destroyed) { | ||
if (this.graphService && !this.graphService.destroyed) { | ||
this.graphService.destroy(); | ||
@@ -37,2 +33,5 @@ } | ||
updateSelf(properties) { | ||
if (!this.graphService) { | ||
throw new Error("Cannot updateSelf – graphService not yet connected."); | ||
} | ||
if (!this.graph) { | ||
@@ -39,0 +38,0 @@ throw new Error("Cannot update self: no 'graph' property object passed to block."); |
@@ -175,3 +175,3 @@ import { MessageCallback, UnknownRecord } from "@blockprotocol/core"; | ||
updateEntity: MessageCallback<UpdateEntityData, null, Entity, ReadOrModifyResourceError>; | ||
deleteEntity: MessageCallback<DeleteEntityData, null, boolean, ReadOrModifyResourceError>; | ||
deleteEntity: MessageCallback<DeleteEntityData, null, true, ReadOrModifyResourceError>; | ||
getEntity: MessageCallback<GetEntityData, null, Entity, ReadOrModifyResourceError>; | ||
@@ -181,3 +181,3 @@ aggregateEntities: MessageCallback<AggregateEntitiesData, null, AggregateEntitiesResult<Entity>, ReadOrModifyResourceError>; | ||
updateEntityType: MessageCallback<UpdateEntityTypeData, null, EntityType, ReadOrModifyResourceError>; | ||
deleteEntityType: MessageCallback<DeleteEntityTypeData, null, boolean, ReadOrModifyResourceError>; | ||
deleteEntityType: MessageCallback<DeleteEntityTypeData, null, true, ReadOrModifyResourceError>; | ||
getEntityType: MessageCallback<GetEntityTypeData, null, EntityType, ReadOrModifyResourceError>; | ||
@@ -187,7 +187,7 @@ aggregateEntityTypes: MessageCallback<AggregateEntityTypesData, null, AggregateEntitiesResult<EntityType>, ReadOrModifyResourceError>; | ||
updateLink: MessageCallback<UpdateLinkData, null, Link, ReadOrModifyResourceError>; | ||
deleteLink: MessageCallback<DeleteLinkData, null, boolean, ReadOrModifyResourceError>; | ||
deleteLink: MessageCallback<DeleteLinkData, null, true, ReadOrModifyResourceError>; | ||
getLink: MessageCallback<GetLinkData, null, Link, ReadOrModifyResourceError>; | ||
createLinkedAggregation: MessageCallback<CreateLinkedAggregationData, null, LinkedAggregationDefinition, CreateResourceError>; | ||
updateLinkedAggregation: MessageCallback<UpdateLinkedAggregationData, null, LinkedAggregationDefinition, ReadOrModifyResourceError>; | ||
deleteLinkedAggregation: MessageCallback<DeleteLinkedAggregationData, null, boolean, ReadOrModifyResourceError>; | ||
deleteLinkedAggregation: MessageCallback<DeleteLinkedAggregationData, null, true, ReadOrModifyResourceError>; | ||
getLinkedAggregation: MessageCallback<GetLinkedAggregationData, null, LinkedAggregationDefinition, ReadOrModifyResourceError>; | ||
@@ -194,0 +194,0 @@ uploadFile: MessageCallback<UploadFileData, null, UploadFileReturn, CreateResourceError>; |
@@ -6,3 +6,3 @@ import { LitElement } from "lit"; | ||
export declare abstract class BlockElementBase<BlockEntityProperties extends Record<string, unknown> | null> extends LitElement { | ||
protected graphService: GraphBlockHandler; | ||
protected graphService?: GraphBlockHandler; | ||
static properties: { | ||
@@ -13,3 +13,2 @@ graph: { | ||
}; | ||
constructor(); | ||
connectedCallback(): void; | ||
@@ -16,0 +15,0 @@ disconnectedCallback(): void; |
import { LitElement } from "lit"; | ||
import { GraphBlockHandler, } from "./index"; | ||
export class BlockElementBase extends LitElement { | ||
constructor() { | ||
super(); | ||
this.graphService = new GraphBlockHandler({ element: this }); | ||
} | ||
connectedCallback() { | ||
super.connectedCallback(); | ||
if (this.graphService.destroyed) { | ||
if (!this.graphService || this.graphService.destroyed) { | ||
this.graphService = new GraphBlockHandler({ element: this }); | ||
@@ -16,3 +12,3 @@ } | ||
super.disconnectedCallback(); | ||
if (!this.graphService.destroyed) { | ||
if (this.graphService && !this.graphService.destroyed) { | ||
this.graphService.destroy(); | ||
@@ -33,2 +29,5 @@ } | ||
updateSelf(properties) { | ||
if (!this.graphService) { | ||
throw new Error("Cannot updateSelf – graphService not yet connected."); | ||
} | ||
if (!this.graph) { | ||
@@ -35,0 +34,0 @@ throw new Error("Cannot update self: no 'graph' property object passed to block."); |
@@ -175,3 +175,3 @@ import { MessageCallback, UnknownRecord } from "@blockprotocol/core"; | ||
updateEntity: MessageCallback<UpdateEntityData, null, Entity, ReadOrModifyResourceError>; | ||
deleteEntity: MessageCallback<DeleteEntityData, null, boolean, ReadOrModifyResourceError>; | ||
deleteEntity: MessageCallback<DeleteEntityData, null, true, ReadOrModifyResourceError>; | ||
getEntity: MessageCallback<GetEntityData, null, Entity, ReadOrModifyResourceError>; | ||
@@ -181,3 +181,3 @@ aggregateEntities: MessageCallback<AggregateEntitiesData, null, AggregateEntitiesResult<Entity>, ReadOrModifyResourceError>; | ||
updateEntityType: MessageCallback<UpdateEntityTypeData, null, EntityType, ReadOrModifyResourceError>; | ||
deleteEntityType: MessageCallback<DeleteEntityTypeData, null, boolean, ReadOrModifyResourceError>; | ||
deleteEntityType: MessageCallback<DeleteEntityTypeData, null, true, ReadOrModifyResourceError>; | ||
getEntityType: MessageCallback<GetEntityTypeData, null, EntityType, ReadOrModifyResourceError>; | ||
@@ -187,7 +187,7 @@ aggregateEntityTypes: MessageCallback<AggregateEntityTypesData, null, AggregateEntitiesResult<EntityType>, ReadOrModifyResourceError>; | ||
updateLink: MessageCallback<UpdateLinkData, null, Link, ReadOrModifyResourceError>; | ||
deleteLink: MessageCallback<DeleteLinkData, null, boolean, ReadOrModifyResourceError>; | ||
deleteLink: MessageCallback<DeleteLinkData, null, true, ReadOrModifyResourceError>; | ||
getLink: MessageCallback<GetLinkData, null, Link, ReadOrModifyResourceError>; | ||
createLinkedAggregation: MessageCallback<CreateLinkedAggregationData, null, LinkedAggregationDefinition, CreateResourceError>; | ||
updateLinkedAggregation: MessageCallback<UpdateLinkedAggregationData, null, LinkedAggregationDefinition, ReadOrModifyResourceError>; | ||
deleteLinkedAggregation: MessageCallback<DeleteLinkedAggregationData, null, boolean, ReadOrModifyResourceError>; | ||
deleteLinkedAggregation: MessageCallback<DeleteLinkedAggregationData, null, true, ReadOrModifyResourceError>; | ||
getLinkedAggregation: MessageCallback<GetLinkedAggregationData, null, LinkedAggregationDefinition, ReadOrModifyResourceError>; | ||
@@ -194,0 +194,0 @@ uploadFile: MessageCallback<UploadFileData, null, UploadFileReturn, CreateResourceError>; |
{ | ||
"name": "@blockprotocol/graph", | ||
"version": "0.0.5", | ||
"description": "Implementation of the Block Protocol Graph services specification for blocks and embedding applications", | ||
"version": "0.0.6", | ||
"description": "Implementation of the Block Protocol Graph service specification for blocks and embedding applications", | ||
"keywords": [ | ||
@@ -40,3 +40,3 @@ "blockprotocol", | ||
"@blockprotocol/core": "0.0.4", | ||
"lit": "2.2.5", | ||
"lit": "^2.2.5", | ||
"react": "^17.0.2" | ||
@@ -43,0 +43,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
139445
0.06%2918
-0.14%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
Updated