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

endless-sky-bindings

v0.2.4

Published

JavaScript bindings for Endless Sky C++ code

Downloads

19

Readme

JavaScript bindings for Endless Sky C++ code

JavaScript wrapper for the C++ classes in Endless Sky, compiled to JavaScript + WebAssembly by Emscripten.

npm install endless-sky-bindings

Usage examples

Use as a ES6 Module in node:

import libFactory from "endless-sky-bindings/dist/es-node.js";

(async function () {
  const esLib = await libFactory();
  console.log(new esLib.Point(1, 2));
})();

Use in a browser script tag, without a bundler:

<script type="module">
(async function() {
  const {default: esLibFactory} = await import('https://unpkg.com/endless-sky-bindings/dist/es-web.mjs?module');
  const esLib = await esLibFactory();
  esLib.GameDataBeginLoad([]); // optional
  console.log(new esLib.Point(1, 2));
})();
</script>

Use in the node REPL (shown with top-level await which is on by default in node 16, for node <16 use node --experimental-repl-await):

> const {default: libFactory} = await import('endless-sky-bindings/dist/es-node.js');
> const esLib = await libFactory();
> p = new esLib.Point(1, 2));
Point {}
> p.X();
1

Use in an Observable Notebook

Wrapped classes

See lib.cpp for which classes are wrapped. It's not hard to add more, but there are some limitations:

  • only one constructor overload can be directly exposed
  • int64 conversions require manual wrapping to convert to int
  • I haven't figured out templates

How this works

This repository has a specific commit of Endless Sky as a submodule. A patch (patch.diff) is applied to it, mostly to make it compile with the Emscripten toolchain. This patch is based on the changes made to Endless Sky in the Endless Web fork.

These modified Endless Sky C++ files are compiled with Emscripten with bindings provided by the Emscripten embind macros in lib.cpp.

These distributed files include core Endless Sky game data but not images or sounds.

Potential Uses of this library

These aren't possible yet, but might influence design.

  • npm-installable command line data parser which exactly mirrors game loading logic
  • live preview of derived properties when making data file changes
  • GUI ship editor that produces data files for plugin authors
  • text editor tool providing autocompletion and syntax highlighting when writing data files
  • "fly this ship around" widget that embeds the full game on a webpage with tweakable stats/outfits
  • player assistance tools displaying game information live as it is played
  • online mission editor tool
  • deep linking to game situations more specific than a savefile
  • hooks into game logic for customization of https://play-endless-web.com from JavaScript