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

webspice

v0.0.2

Published

webspice is an unofficial, experimental port of NASA's SPICE toolkit for astronomical observation geometry to WebAssembly.

Downloads

17

Readme

webspice

webspice is an unofficial, experimental port of NASA's SPICE toolkit for astronomical observation geometry to WebAssembly. The aim is to enable on-line, interactive computations of advanced space observation geometry in any modern web browser without expensive server-side infrastructure or unreliable proprietary browser plugins.

The port is based on NASA's official CSPICE implementation in C, compiled to WebAssembly using Emscripten.

Installation

Use the package manager npm to install the webspice package as a local dependency under your current working directory.

npm install webspice

Usage

webspice takes the form of a JavaScript module. To use the module in your own JavaScript code, import it using the import statement:

import webspice from "./node_modules/webspice/index.js";

The location specifier must point to the location of the module in your application. Provided the browser is able to load the module from the specified location, it will bind the module's default export to the webspice identifier.

Note that the import statement may only be used from scripts that are themselves marked as type="module"; refer to the JavaScript documentation for details.

To instantiate the module, invoke the instantiate static method:

let instantiateWebspice = webspice.instantiate();

The method returns a JavaScript promise that is fulfilled once the module instance has been created. By default, the module seeks to load the WebAssembly library from the path where the module was imported from.

If the promise resolves succesfully, it will pass an instance that you can use to invoke the functions of the library:

instantiateWebspice.then(
  function (instance) {
    console.log(instance.tkvrsn_c("TOOLKIT"));
  }
);

Building

Building the webspice package from source comprise two separate parts: the CSPICE static library and the webspice library itself.

Both parts are built using Emscripten, and the path of your Emscripten toolchain must be in your shell search path for the build scripts to work. Refer to the Emscripten documentation for more information on how to accomplish this using emsdk_env.sh.

Updating CSPICE

The webspice repo comes with a copy of the official CSPICE toolkit and source code. These files can be found under upstream/import. If this copy is sufficient for you, you can skip to the next section. Should you wish to update the copy of CSPICE from the NASA/NAIF website, however, this can be accomplished by using the two scripts in the upstream directory.

To download the latest CSPICE package from NAIF into the upstream/download directory, from the upstream directory, run:

./download.sh

To import (unpack) the downloaded package into the upstream/import directory, again from the upstream directory, run:

./import.sh

Building CSPICE

The official CSPICE toolkit contains scripts for compiling the CSPICE source code to native binaries, but these scripts are not used for webspice. Instead, a select subset of the CSPICE source code is compiled to a static LLVM IR library at lib/libwebspice.a with Emscripten. To build the library, from the top-level directory, run:

./build_lib.sh

The path of your Emscripten toolchain must be in your shell search path for the build script to work.

Building webspice

To build the webspice library itself into the dist directory, from the top-level directory, run:

./build_dist.sh

The path of your Emscripten toolchain must be in your shell search path for the build script to work, and the CSPICE static library must have already been built to lib/libwebspice.a (see previous section).