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

@stratumn/react-map-explorer

Package Overview
Dependencies
Maintainers
9
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@stratumn/react-map-explorer - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

23

lib/mapExplorer.d.ts

@@ -8,5 +8,25 @@ import { Segment } from '@stratumn/js-chainscript';

export interface Props {
/**
* Map process.
*/
process: string;
/**
* Id of the map you want to display.
*/
mapId: string;
/**
* Hash of a known link that should be in the map.
* If no link with this hash is currently loaded, the component will re-fetch
* the map from the server.
* You can use this prop to automatically refresh the map when creating new
* links.
*/
includeHash?: string;
/**
* Object that actually loads the whole map.
*/
mapLoader: IMapLoader;
/**
* Callback when a segment is selected.
*/
onSegmentSelected?: (s: Segment) => void;

@@ -28,4 +48,7 @@ }

componentDidMount(): Promise<void>;
componentDidUpdate(prevProps: Props): Promise<void>;
render(): JSX.Element;
private shouldReloadMap;
private loadMap;
}
//# sourceMappingURL=mapExplorer.d.ts.map

34

lib/mapExplorer.js

@@ -42,5 +42,21 @@ "use strict";

this.state = { isLoaded: false };
}
componentDidMount() {
return __awaiter(this, void 0, void 0, function* () {
this.shouldReloadMap = (prevProps) => {
// If the map we want to display has changed, refresh.
if (prevProps.process !== this.props.process ||
prevProps.mapId !== this.props.mapId) {
return true;
}
// If an unknown link should be included, refresh.
if (this.props.includeHash &&
prevProps.includeHash !== this.props.includeHash) {
if (!this.state.segments) {
return true;
}
if (!this.state.segments.find((s) => Buffer.from(s.linkHash()).toString('hex') === this.props.includeHash)) {
return true;
}
}
return false;
};
this.loadMap = () => __awaiter(this, void 0, void 0, function* () {
try {

@@ -61,2 +77,14 @@ const segments = yield this.props.mapLoader.load(this.props.process, this.props.mapId);

}
componentDidMount() {
return __awaiter(this, void 0, void 0, function* () {
yield this.loadMap();
});
}
componentDidUpdate(prevProps) {
return __awaiter(this, void 0, void 0, function* () {
if (this.shouldReloadMap(prevProps)) {
yield this.loadMap();
}
});
}
render() {

@@ -63,0 +91,0 @@ const { mapId } = this.props;

6

package.json
{
"name": "@stratumn/react-map-explorer",
"version": "0.1.1",
"version": "0.1.2",
"description": "A React component to load and display Chainscript process maps.",

@@ -48,4 +48,4 @@ "keywords": [

"dependencies": {
"@stratumn/js-chainscript": "^1.0.2",
"@stratumn/store-client": "^0.1.0",
"@stratumn/js-chainscript": "^1.0.3",
"@stratumn/store-client": "^0.1.2",
"buffer": "^5.2.1",

@@ -52,0 +52,0 @@ "react": "^16.6.0",

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