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

assetsm

v0.1.7

Published

Assets Manager. Tilemaps, tilesets, images and audio files loading and managing.

Downloads

54

Readme

assetsm

Assets Manager. Tilemaps(.tmj/.json), images and audio files loading and managing.

How to use

  1. Install module
npm i assetsm
  1. Import and create a class instance
import AssetsManager from "assetsm"

const assets = new AssetsManager()
  1. Register files
assets.addAudio(key, url)
assets.addImage(key, url)
assets.addTileMap(key, url)
  1. Subscribe for progress to track the loading progress status
assets.addEventListener("progress", (event) => {
    console.log("progress, loaded items: ", event.loaded);
    console.log("progress, items left: ", event.total);
});
  1. Get current pending uploads if necessary
assets.filesWaitingForUpload
  1. Preload all files you registered in the previous step
assets.preload().then(() => {
  1. Use files
{
    const audio = assets.getAudio(key)
    const image = assets.getImage(key)
    const tilemap = assets.getTileMap(key)
}
  1. To check the process you can subscribe for ProgressEvent.type event
// fires when uploading is starting
assets.addEventListener("loadstart", () =>
// fires when uploading is in progress
assets.addEventListener("progress", () =>
// fires when uploading is over
assets.addEventListener("load", () =>
// load errors
assets.addEventListener("error", (err) =>

Run examples from ./examples folder

npm i --save-dev
npm start

Other Notes

  • Images are loaded as ImageBitmaps
  • When loading tilemaps, it also process tileset files and loads images inside them, attached images could be retrieved by tileset.name key, check examples/index.js how to do that
  • ES6 only

Version 0.1.0 functionality:

adding new loaders

  1. Register a loader and uploadMethod using registerLoader(loaderType, loaderMethod)
  2. Add upload item to the queue using add[loaderName](fileKey, url), or addFile(loaderName, fileKey, url).
  3. Executing preload(), will upload all items where added in step2 with loaderMethod provided in step1 and save them temporary.
  4. After that uploadingResults will be available with getloaderName, or getFile(loaderName, fileKey, url)

Version 0.1.4

load tilesets separately

If you want to load tilesets separately, pass false as 3d parameter to addTileMap and then use addTileSet to add tileset to queue:

assets.addTileMap(key, url, false);
assets.addTileSet(key, url);
assets.preload().then(() => {
    assets.getTileMap(key);
    assets.getTileSet(key); 
    ...

Version 0.1.6

added xml atlas loader

Two new loaders added: AtlasXML, AtlasImageMap. After uploading atlas xml, atlasImageMap will be loaded, and individual images could be accessed with getImage():

assets.addAtlasXML(key, url);
assets.preload().then(() => {
    const atlasImageMap = assets.getAtlasImageMap(key),
        someImageFromAtlas = assets.getImage(imageKey),
        ;
    ...

Version 0.1.7

split upload errors

  • Critical errors. The behavior: stop upload and reject the promise.
    • addFileType() method, file key or url is incorrect
    • incorrect file extension
    • incorrect uploadMethod return type
    • upload recursion error
  • Non critical errors. The behavior: continue upload process, failed object will be assigned to the null value, warning will be shown in the console.
    • all other errors, such as 404

Notes

  • loaderMethod should return Promise with uploading result value
  • loaderMethod is optional, by default it will return fetch result