New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mock-block-dock

Package Overview
Dependencies
Maintainers
5
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mock-block-dock - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

5

dist/cjs/MockBlockDock.d.ts
import { ReactElement, VoidFunctionComponent } from "react";
import { BlockProtocolEntityType } from "blockprotocol";
import { BlockProtocolEntity, BlockProtocolEntityType, BlockProtocolLink } from "blockprotocol";
declare type MockBlockDockProps = {
children: ReactElement;
blockSchema?: Partial<BlockProtocolEntityType>;
initialEntities?: BlockProtocolEntity[];
initialEntityTypes?: BlockProtocolEntityType[];
initialLinks?: BlockProtocolLink[];
};
export declare const MockBlockDock: VoidFunctionComponent<MockBlockDockProps>;
export {};

36

dist/cjs/MockBlockDock.jsx

@@ -13,11 +13,2 @@ "use strict";

};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -30,3 +21,3 @@ exports.MockBlockDock = void 0;

var MockBlockDock = function (_a) {
var children = _a.children, blockSchema = _a.blockSchema;
var children = _a.children, blockSchema = _a.blockSchema, initialEntities = _a.initialEntities, initialEntityTypes = _a.initialEntityTypes, initialLinks = _a.initialLinks;
var mockData = (0, react_1.useMemo)(function () {

@@ -46,12 +37,19 @@ var _a;

initialBlockEntity.entityTypeId = blockEntityType.entityTypeId;
var nextMockData = __assign({}, data_1.mockData);
// give the entities/types the same accountId as the root entity
nextMockData.entities = __spreadArray(__spreadArray([], data_1.mockData.entities.map(function (entity) { return (__assign(__assign({}, entity), { accountId: accountId })); }), true), [
initialBlockEntity,
], false);
nextMockData.entityTypes = __spreadArray(__spreadArray([], data_1.mockData.entityTypes.map(function (entityType) { return (__assign(__assign({}, entityType), { accountId: accountId })); }), true), [
blockEntityType,
], false);
var nextMockData = {
entities: initialEntities !== null && initialEntities !== void 0 ? initialEntities :
// give the entities/types the same accountId as the root entity if user not supplying their own mocks
data_1.mockData.entities.map(function (entity) { return (__assign(__assign({}, entity), { accountId: accountId })); }),
entityTypes: initialEntityTypes !== null && initialEntityTypes !== void 0 ? initialEntityTypes : data_1.mockData.entityTypes.map(function (entityType) { return (__assign(__assign({}, entityType), { accountId: accountId })); }),
links: initialLinks !== null && initialLinks !== void 0 ? initialLinks : data_1.mockData.links,
};
nextMockData.entities.push(initialBlockEntity);
nextMockData.entityTypes.push(blockEntityType);
return nextMockData;
}, [blockSchema, children.props]);
}, [
blockSchema,
initialEntities,
initialEntityTypes,
initialLinks,
children.props,
]);
var _b = (0, useMockDatastore_1.useMockDatastore)(mockData), entities = _b.entities, entityTypes = _b.entityTypes, links = _b.links, functions = _b.functions;

@@ -58,0 +56,0 @@ var latestBlockEntity = (0, react_1.useMemo)(function () {

@@ -69,2 +69,3 @@ "use strict";

}; }
var previousInitialEntitiesString = (0, react_1.useRef)(JSON.stringify(initialData.entities));
var _a = (0, react_1.useState)(initialData.entities), entities = _a[0], setEntities = _a[1];

@@ -74,3 +75,7 @@ var _b = (0, react_1.useState)(initialData.links), links = _b[0], setLinks = _b[1];

(0, react_1.useEffect)(function () {
setEntities(initialData.entities);
var initialEntitiesString = JSON.stringify(initialData.entities);
if (initialEntitiesString !== previousInitialEntitiesString.current) {
setEntities(initialData.entities);
previousInitialEntitiesString.current = initialEntitiesString;
}
}, [initialData.entities]);

@@ -77,0 +82,0 @@ var aggregateEntityTypes = (0, react_1.useCallback)(function (payload) { return __awaiter(void 0, void 0, void 0, function () {

import { ReactElement, VoidFunctionComponent } from "react";
import { BlockProtocolEntityType } from "blockprotocol";
import { BlockProtocolEntity, BlockProtocolEntityType, BlockProtocolLink } from "blockprotocol";
declare type MockBlockDockProps = {
children: ReactElement;
blockSchema?: Partial<BlockProtocolEntityType>;
initialEntities?: BlockProtocolEntity[];
initialEntityTypes?: BlockProtocolEntityType[];
initialLinks?: BlockProtocolLink[];
};
export declare const MockBlockDock: VoidFunctionComponent<MockBlockDockProps>;
export {};

@@ -12,11 +12,2 @@ var __assign = (this && this.__assign) || function () {

};
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
if (ar || !(i in from)) {
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
ar[i] = from[i];
}
}
return to.concat(ar || Array.prototype.slice.call(from));
};
import { Children, cloneElement, useEffect, useMemo, useRef, } from "react";

@@ -27,3 +18,3 @@ import { useMockDatastore } from "./useMockDatastore";

export var MockBlockDock = function (_a) {
var children = _a.children, blockSchema = _a.blockSchema;
var children = _a.children, blockSchema = _a.blockSchema, initialEntities = _a.initialEntities, initialEntityTypes = _a.initialEntityTypes, initialLinks = _a.initialLinks;
var mockData = useMemo(function () {

@@ -43,12 +34,19 @@ var _a;

initialBlockEntity.entityTypeId = blockEntityType.entityTypeId;
var nextMockData = __assign({}, initialMockData);
// give the entities/types the same accountId as the root entity
nextMockData.entities = __spreadArray(__spreadArray([], initialMockData.entities.map(function (entity) { return (__assign(__assign({}, entity), { accountId: accountId })); }), true), [
initialBlockEntity,
], false);
nextMockData.entityTypes = __spreadArray(__spreadArray([], initialMockData.entityTypes.map(function (entityType) { return (__assign(__assign({}, entityType), { accountId: accountId })); }), true), [
blockEntityType,
], false);
var nextMockData = {
entities: initialEntities !== null && initialEntities !== void 0 ? initialEntities :
// give the entities/types the same accountId as the root entity if user not supplying their own mocks
initialMockData.entities.map(function (entity) { return (__assign(__assign({}, entity), { accountId: accountId })); }),
entityTypes: initialEntityTypes !== null && initialEntityTypes !== void 0 ? initialEntityTypes : initialMockData.entityTypes.map(function (entityType) { return (__assign(__assign({}, entityType), { accountId: accountId })); }),
links: initialLinks !== null && initialLinks !== void 0 ? initialLinks : initialMockData.links,
};
nextMockData.entities.push(initialBlockEntity);
nextMockData.entityTypes.push(blockEntityType);
return nextMockData;
}, [blockSchema, children.props]);
}, [
blockSchema,
initialEntities,
initialEntityTypes,
initialLinks,
children.props,
]);
var _b = useMockDatastore(mockData), entities = _b.entities, entityTypes = _b.entityTypes, links = _b.links, functions = _b.functions;

@@ -55,0 +53,0 @@ var latestBlockEntity = useMemo(function () {

@@ -57,3 +57,3 @@ var __assign = (this && this.__assign) || function () {

};
import { useCallback, useEffect, useState } from "react";
import { useCallback, useEffect, useRef, useState } from "react";
import { v4 as uuid } from "uuid";

@@ -67,2 +67,3 @@ import { filterAndSortEntitiesOrTypes, matchIdentifiers } from "./util";

}; }
var previousInitialEntitiesString = useRef(JSON.stringify(initialData.entities));
var _a = useState(initialData.entities), entities = _a[0], setEntities = _a[1];

@@ -72,3 +73,7 @@ var _b = useState(initialData.links), links = _b[0], setLinks = _b[1];

useEffect(function () {
setEntities(initialData.entities);
var initialEntitiesString = JSON.stringify(initialData.entities);
if (initialEntitiesString !== previousInitialEntitiesString.current) {
setEntities(initialData.entities);
previousInitialEntitiesString.current = initialEntitiesString;
}
}, [initialData.entities]);

@@ -75,0 +80,0 @@ var aggregateEntityTypes = useCallback(function (payload) { return __awaiter(void 0, void 0, void 0, function () {

{
"name": "mock-block-dock",
"version": "0.0.7",
"version": "0.0.8",
"description": "A mock embedding application for Block Protocol blocks",

@@ -5,0 +5,0 @@ "keywords": [

@@ -17,2 +17,4 @@ # Mock Block Dock

- `aggregateEntities`
- `aggregateEntityTypes`
- `getEntities`

@@ -42,2 +44,26 @@ - `createEntities`

## Mock entities
`MockBlockDock` automatically supplies additional dummy entities and entity types in `src/data/entities.ts` and `src/data/entityTypes.ts`, and links between entities in `src/data/links.ts`.
These dummy entities/links will be in the data store, and your block can discover them by calling `aggregateEntityTypes` or `aggregateEntities`.
If you prefer, you can provide your own `initialEntities` and/or `initialEntityTypes` and/or `initialLinks` as props.
```jsx
<MockBlockDock
initialEntities={[
// other entities for your block to use can be loaded into the datastore here
{
entityId: "my-dummy-entity",
entityTypeId: "dummy",
myOtherEntitysProperty: "foo",
},
]}
>
<TestBlock myBlockProperty="bar" /> // starting properties for your block
should still be set here
</MockBlockDock>
```
## Note

@@ -44,0 +70,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc