Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@evergis/react

Package Overview
Dependencies
Maintainers
6
Versions
357
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@evergis/react - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

6

dist/hooks/useUpdate.d.ts

@@ -1,7 +0,7 @@

export declare function useUpdate({ onUpdate, shouldUpdate, deps }: UseUpdateOptions): void;
declare type UseUpdateOptions = {
export declare function useUpdate<Deps extends Array<unknown>>({ onUpdate, shouldUpdate, deps, }: UseUpdateOptions<Deps>): void;
declare type UseUpdateOptions<Deps> = {
onUpdate: () => void;
shouldUpdate?: () => boolean;
deps?: any[];
deps?: Deps;
};
export {};

@@ -292,2 +292,3 @@ 'use strict';

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
function ShadowedPointSymbol(options) {

@@ -370,2 +371,3 @@ _classCallCheck(this, ShadowedPointSymbol);

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
function ShadowedPolySymbol(options) {

@@ -1127,3 +1129,4 @@ _classCallCheck(this, ShadowedPolySymbol);

updateMapResolution(map, currentPosition, currentResolution);
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);

@@ -1196,3 +1199,4 @@ };

});
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);

@@ -1220,3 +1224,3 @@ }

onMount && onMount();
return onUnmount;
return onUnmount; // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

@@ -1247,3 +1251,3 @@ }

var handleBboxChange = React.useCallback(function () {
onBboxChange && onBboxChange(getMapState(map));
onBboxChange && onBboxChange(getMapState(map)); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);

@@ -1254,3 +1258,3 @@ React.useEffect(function () {

map.off(event.type, handleBboxChange);
};
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);

@@ -1334,3 +1338,3 @@ }

return propRef.current;
return propRef.current; // eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

@@ -1364,3 +1368,4 @@ }

onUpdate();
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

@@ -1562,3 +1567,4 @@ }

});
}, [map]);
}, // eslint-disable-next-line react-hooks/exhaustive-deps
[map]);
useMount({

@@ -1629,4 +1635,5 @@ onMount: function onMount() {

if (index === void 0 && index === null) return;
return map.tileScheme.levels[index].zIndex;
}, [resolution]);
return map.tileScheme.levels[index].zIndex; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolution]); // eslint-disable-next-line react-hooks/exhaustive-deps
var bbox = React.useMemo(function () {

@@ -1652,3 +1659,3 @@ return painter.bbox;

if (index === void 0 && index === null) return;
return map.tileScheme.levels[index].zIndex;
return map.tileScheme.levels[index].zIndex; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolution]);

@@ -1683,3 +1690,3 @@ }

var b = painter.getPointFromPxPosition(segmentLength, height / 2);
return geotools.distance(a, b) / segmentLength;
return geotools.distance(a, b) / segmentLength; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [height, width, xMin, xMax, yMin, yMax, crs.wkid, resolution, painter]);

@@ -1686,0 +1693,0 @@ }

@@ -285,2 +285,3 @@ import React__default, { useMemo, createElement, useContext, createContext, useEffect, useCallback, useRef, useState, useReducer } from 'react';

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
function ShadowedPointSymbol(options) {

@@ -363,2 +364,3 @@ _classCallCheck(this, ShadowedPointSymbol);

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
function ShadowedPolySymbol(options) {

@@ -1120,3 +1122,4 @@ _classCallCheck(this, ShadowedPolySymbol);

updateMapResolution(map, currentPosition, currentResolution);
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);

@@ -1189,3 +1192,4 @@ };

});
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);

@@ -1213,3 +1217,3 @@ }

onMount && onMount();
return onUnmount;
return onUnmount; // eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

@@ -1240,3 +1244,3 @@ }

var handleBboxChange = useCallback(function () {
onBboxChange && onBboxChange(getMapState(map));
onBboxChange && onBboxChange(getMapState(map)); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);

@@ -1247,3 +1251,3 @@ useEffect(function () {

map.off(event.type, handleBboxChange);
};
}; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);

@@ -1327,3 +1331,3 @@ }

return propRef.current;
return propRef.current; // eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

@@ -1357,3 +1361,4 @@ }

onUpdate();
}
} // eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

@@ -1555,3 +1560,4 @@ }

});
}, [map]);
}, // eslint-disable-next-line react-hooks/exhaustive-deps
[map]);
useMount({

@@ -1622,4 +1628,5 @@ onMount: function onMount() {

if (index === void 0 && index === null) return;
return map.tileScheme.levels[index].zIndex;
}, [resolution]);
return map.tileScheme.levels[index].zIndex; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolution]); // eslint-disable-next-line react-hooks/exhaustive-deps
var bbox = useMemo(function () {

@@ -1645,3 +1652,3 @@ return painter.bbox;

if (index === void 0 && index === null) return;
return map.tileScheme.levels[index].zIndex;
return map.tileScheme.levels[index].zIndex; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolution]);

@@ -1676,3 +1683,3 @@ }

var b = painter.getPointFromPxPosition(segmentLength, height / 2);
return distance(a, b) / segmentLength;
return distance(a, b) / segmentLength; // eslint-disable-next-line react-hooks/exhaustive-deps
}, [height, width, xMin, xMax, yMin, yMax, crs.wkid, resolution, painter]);

@@ -1679,0 +1686,0 @@ }

{
"version": "1.0.1",
"version": "1.0.2",
"license": "MIT",

@@ -44,3 +44,4 @@ "main": "dist/index.js",

"@babel/core": "^7.11.1",
"@evergis/api": "^1.0.1",
"@evergis/api": "^1.0.2",
"@evergis/sgis": "^0.5.0-alpha.8",
"@storybook/addon-actions": "^6.0.5",

@@ -65,3 +66,4 @@ "@storybook/addon-docs": "^6.0.5",

"typescript": "^3.9.7"
}
},
"gitHead": "a93521b3316ee00c7d8f190b1420ed0adde79f6c"
}

@@ -1,15 +0,5 @@

# TSDX React User Guide
# @evergis/react
Congrats! You just saved yourself hours of work by bootstrapping this project with TSDX. Let’s get you oriented with what’s here and how to use it.
> This TSDX setup is meant for developing React components (not apps!) that can be published to NPM. If you’re looking to build an app, you should use `create-react-app`, `razzle`, `nextjs`, `gatsby`, or `react-static`.
> If you’re new to TypeScript and React, checkout [this handy cheatsheet](https://github.com/sw-yx/react-typescript-cheatsheet/)
## Commands
TSDX scaffolds your new library inside `/src`, and also sets up a [Parcel-based](https://parceljs.org) playground for it inside `/example`.
The recommended workflow is to run TSDX in one terminal:
```

@@ -33,152 +23,6 @@ npm start # or yarn start

> NOTE: Stories should reference the components as if using the library, similar to the example playground. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
> NOTE: Stories should reference the components as if using the library. This means importing from the root project directory. This has been aliased in the tsconfig and the storybook webpack config as a helper.
### Example
### Tests
Then run the example inside another:
```
cd example
npm i # or yarn to install dependencies
npm start # or yarn start
```
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**, [we use Parcel's aliasing](https://github.com/palmerhq/tsdx/pull/88/files).
To do a one-off build, use `npm run build` or `yarn build`.
To run tests, use `npm test` or `yarn test`.
## Configuration
Code quality is [set up for you](https://github.com/palmerhq/tsdx/pull/45/files) with `prettier`, `husky`, and `lint-staged`. Adjust the respective fields in `package.json` accordingly.
### Jest
Jest tests are set up to run with `npm test` or `yarn test`. This runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
#### Setup Files
This is the folder structure we set up for you:
```
/example
index.html
index.tsx # test your component here in a demo app
package.json
tsconfig.json
/src
index.tsx # EDIT THIS
/test
unit.test.tsx # EDIT THIS
.gitignore
package.json
README.md # EDIT THIS
tsconfig.json
```
#### React Testing Library
We do not set up `react-testing-library` for you yet, we welcome contributions and documentation on this.
### Rollup
TSDX uses [Rollup v1.x](https://rollupjs.org) as a bundler and generates multiple rollup configs for various module formats and build settings. See [Optimizations](#optimizations) for details.
### TypeScript
`tsconfig.json` is set up to interpret `dom` and `esnext` types, as well as `react` for `jsx`. Adjust according to your needs.
## Continuous Integration
### Travis
_to be completed_
### Circle
_to be completed_
## Optimizations
Please see the main `tsdx` [optimizations docs](https://github.com/palmerhq/tsdx#optimizations). In particular, know that you can take advantage of development-only optimizations:
```js
// ./types/index.d.ts
declare var __DEV__: boolean;
// inside your code...
if (__DEV__) {
console.log('foo');
}
```
You can also choose to install and use [invariant](https://github.com/palmerhq/tsdx#invariant) and [warning](https://github.com/palmerhq/tsdx#warning) functions.
## Module Formats
CJS, ESModules, and UMD module formats are supported.
The appropriate paths are configured in `package.json` and `dist/index.js` accordingly. Please report if any issues are found.
## Using the Playground
```
cd example
npm i # or yarn to install dependencies
npm start # or yarn start
```
The default example imports and live reloads whatever is in `/dist`, so if you are seeing an out of date component, make sure TSDX is running in watch mode like we recommend above. **No symlinking required**!
## Deploying the Playground
The Playground is just a simple [Parcel](https://parceljs.org) app, you can deploy it anywhere you would normally deploy that. Here are some guidelines for **manually** deploying with the Netlify CLI (`npm i -g netlify-cli`):
```bash
cd example # if not already in the example folder
npm run build # builds to dist
netlify deploy # deploy the dist folder
```
Alternatively, if you already have a git repo connected, you can set up continuous deployment with Netlify:
```bash
netlify init
# build command: yarn build && cd example && yarn && yarn build
# directory to deploy: example/dist
# pick yes for netlify.toml
```
## Named Exports
Per Palmer Group guidelines, [always use named exports.](https://github.com/palmerhq/typescript#exports) Code split inside your React app instead of your React library.
## Including Styles
There are many ways to ship styles, including with CSS-in-JS. TSDX has no opinion on this, configure how you like.
For vanilla CSS, you can include it at the root directory and add it to the `files` section in your `package.json`, so that it can be imported separately by your users and run through their bundler's loader.
## Publishing to NPM
We recommend using https://github.com/sindresorhus/np.
## Usage with Lerna
When creating a new package with TSDX within a project set up with Lerna, you might encounter a `Cannot resolve dependency` error when trying to run the `example` project. To fix that you will need to make changes to the `package.json` file _inside the `example` directory_.
The problem is that due to the nature of how dependencies are installed in Lerna projects, the aliases in the example project's `package.json` might not point to the right place, as those dependencies might have been installed in the root of your Lerna project.
Change the `alias` to point to where those packages are actually installed. This depends on the directory structure of your Lerna project, so the actual path might be different from the diff below.
```diff
"alias": {
- "react": "../node_modules/react",
- "react-dom": "../node_modules/react-dom"
+ "react": "../../../node_modules/react",
+ "react-dom": "../../../node_modules/react-dom"
},
```
An alternative to fixing this problem would be to remove aliases altogether and define the dependencies referenced as aliases as dev dependencies instead. [However, that might cause other problems.](https://github.com/palmerhq/tsdx/issues/64)

@@ -16,2 +16,3 @@ import { BboxChangeEndEvent, BboxChangeEvent, Map } from '@evergis/sgis/es/Map';

onBboxChange && onBboxChange(getMapState(map));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [onBboxChange, map, event]);

@@ -25,2 +26,3 @@

};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [handleBboxChange, event]);

@@ -27,0 +29,0 @@ }

@@ -42,2 +42,3 @@ import { sGisClickEvent } from '@evergis/sgis/es/commonEvents';

},
// eslint-disable-next-line react-hooks/exhaustive-deps
[map]

@@ -44,0 +45,0 @@ );

@@ -17,4 +17,6 @@ import { useMapState } from './useMapState';

return map.tileScheme.levels[index].zIndex;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolution]);
// eslint-disable-next-line react-hooks/exhaustive-deps
const bbox = useMemo(() => painter.bbox, [position, resolution]);

@@ -40,2 +42,3 @@

return map.tileScheme.levels[index].zIndex;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [resolution]);

@@ -42,0 +45,0 @@ }

@@ -36,2 +36,3 @@ import { LevelDefinition } from '@evergis/sgis/es/TileScheme';

}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [map, minScale, maxScale]);

@@ -38,0 +39,0 @@ };

@@ -7,2 +7,3 @@ import { useEffect } from 'react';

return onUnmount;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

@@ -9,0 +10,0 @@ }

@@ -33,2 +33,3 @@ import { useMemo, useRef } from 'react';

return propRef.current;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);

@@ -35,0 +36,0 @@ }

@@ -30,2 +30,3 @@ import { useMemo } from 'react';

return distance(a, b) / segmentLength;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [height, width, xMin, xMax, yMin, yMax, crs.wkid, resolution, painter]);

@@ -32,0 +33,0 @@ }

import { useEffect } from 'react';
export function useUpdate({ onUpdate, shouldUpdate, deps }: UseUpdateOptions) {
export function useUpdate<Deps extends Array<unknown>>({
onUpdate,
shouldUpdate,
deps,
}: UseUpdateOptions<Deps>) {
useEffect(() => {

@@ -8,9 +12,10 @@ if (!shouldUpdate || shouldUpdate()) {

}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, deps);
}
type UseUpdateOptions = {
type UseUpdateOptions<Deps> = {
onUpdate: () => void;
shouldUpdate?: () => boolean;
deps?: any[];
deps?: Deps;
};

@@ -23,2 +23,3 @@ import { MapState } from './useMapBboxChange';

}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [position, resolution, force]);

@@ -25,0 +26,0 @@ }

@@ -20,2 +20,3 @@ import {

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(options: EditorPointSymbolParams) {

@@ -22,0 +23,0 @@ super(options);

@@ -33,2 +33,3 @@ import {

// eslint-disable-next-line @typescript-eslint/no-useless-constructor
constructor(options: EditorPolySymbolParams) {

@@ -35,0 +36,0 @@ super(options);

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