npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nasapds/pds-wds-react

v0.3.0

Published

PDS widget library for react and embeddable js

Downloads

19

Readme

pds-wds-react

A library of Planetary Data System web widgets and components in react.

Installation

Run in a terminal:

npm i @nasapds/pds-wds-react

Usage

Doi Search Widget In React

Import the Doi Search into your component:

import {DoiSearch} from 'pds-wds-react';

Then include the component in your react render code:

<DoiSearch api="{api}" ... />

Parameters:

  • api The endpoint to the search API. By default this is pointing to http://localhost:8085/PDS_APIs/pds_doi_api/0.2/

  • showActions Hides or shows action buttons next to each search result. False by default.

  • useClientRouter If set to true will disable the widget's internal react-router. Set this to true if your app uses react-router. False by default.

  • history A history object from react-router. If your app uses react-router pass the history here. Null by default.

  • store A Redux store object. If you want to customize the behavior of the widget action buttons or the call process you can pass your own store. This is null by default.

In react the doi search could look like this with the parameters changed:

<DoiSearch
    api={'http//localhost:8085/PDS_APIs/pds_doi_api/0.2/'}
    useClientRouter={true}
    showActions={true}
/>

Doi Search Widget As Embeddable JS

In your project create a directory for example:

pds-widgets/

Drop the contents of the /embedbuild directory into the newly created directory.

Link the library into your project HTML using the script tag. Change the directory to the one that you created:

<script src="pds-widgets/index.js"></script>

Add a div with the ID of the component set as DoiSearch:

<div id="DoiSearch"></div>

Parameters:

  • data-api Point this to your doi api. It is set to localhost 8085 by default.

In your html page the doi search could look like this with the parameters changed:

`<div id="DoiSearch" data-api='http//localhost:8085/PDS_APIs/pds_doi_api/0.2/'></div>`

Code Base Development Instructions

Source

Clone this repository into your workspace first.

The components are found inside /src/pds/

Each component has an index.js and a .js file. index.js is for building the embeddable js widget. <name>.js is for building the npm package.

There are three index files inside /src/pds/ that need to be updated with an import of a new component when one is created. These are embedBuildIndex.js, embedIndex.js and npmBuildIndex.js

Development Scripts

For testing embeddable widgets run the script npm run embeddev This will run a server with /public/embedIndex.html as the entry point. You can update this file to show the component that you want to test.

For testing the NPM package run the script npm run npmbuild Then run npm link you can then create a client app and import using npm link pds-wds-react

Import the component into your client app using the Usage section.

There are sometimes problems with multiple instances of react caused by npm link. If this happens, delete node_modules/react inside the pds-wds-react source. Then stop and restart the client test app again.

Building

Prerequisite

Install nvm to manage the nodejs environments.

Use Node.js version 18.16.0 (LTS):

nvm install 16.20.2
nvm use 16.20.2

Build the packages

npm install --legacy-peer-deps

npm run build Two directories will be created /build and /embedbuild.

/build will the contain the ready to deploy npm files. This is what is deployed to the NPM JS website.

/embedbuild will contain the ready to deploy embeddable widget files. This is what can be dropped into a website that is not built with React.

Publishing to NPM

Update the version in the /package.json file.

Use the X.X.X semver syntax to set a version or X.X.X-beta.X semver syntax for a beta version.

Use npm publish to publish a stable version or use npm publish --tag beta to publish a beta version.

If you want to test a beta version make sure to install the beta version instead of the latest version. Use npm install @nasapds/pds-wds-react@beta for the latest beta version or npm install @nasapds/[email protected] for a specific version.

Search Prototype

The search prototype is in the search-prototype directory.

cd search-prototype

npm install

npm start

Open an internet browser to localhost:3000

If a CORS issue occurs when trying to search through the search box.

Go to http://localhost.jpl.nasa.gov:3000/ in your browser.

Then use an extension to get around CORS.

For example in chrome use https://chrome.google.com/webstore/detail/moesif-origin-cors-change/digfbfaphojjndkpccljibejjbppifbc

In Firefox you can you use https://addons.mozilla.org/en-US/firefox/addon/cors-everywhere/

Just make sure to turn off the extension when not in use.