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

spainter

v1.3.2

Published

Web browser painter, like mspaint.

Downloads

25

Readme

GitHub license npm version contributions welcome update:spainter.pychat.org

Spainter. Web browSer painter

DEMO spainter.akoidan.com

Integrating into you server:

  • If you use bundler like webpack:
npm i spainter lines-logger
import Painter from 'spainter';
import 'spainter/index.sass'; // you can import index.css if you don't have sass, ensure that you copy the fonts from the directory as well to production. Set `$FontelloPath: "../node_modules/spainter/font"`
import {LoggerFactory} from 'lines-logger'; // yarn install lines-logger
const containerPainter = document.createElement('div');
document.body.appendChild(containerPainter);
const p = new Painter(containerPainter, {logger: new LoggerFactory().getLogger('spainter')});

If you use fontello in your server, you can generate single font importing no-fonts.sass, joining it with config.json

  • If you use server rendering and cdn:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/index.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/index.css"/>
<div id="containerPainter"></div>
<script>
var p = new Painter(containerPainter);
</script>

Target the latest version instead of 1.2.10 npm version

  • You can find an example on pychat

  • Additional parameters

new Painter(containerPainer, {
  textClass: 'input-txt-class', // set class for all input[type=text] elements
  buttonClass: 'input-button-class', // set class for all input[type=button] elements
  rangeClass: 'input-range-class', // set class for all input[type=range]elements
  rangeFactory: (parentElement) => { // use this div for input[range], e.g. you can use material-design
    var input = document.createElement('input');
    input.type = 'range';
    // you can also do parentElement.
    return input;
  },
  onBlobPaste: function(blob) { // example of uploading image to server
    var formData = new FormData();
    formData.append('file', blob, 'specifyFileNameHereIfNeeded.png');
    fetch(`${host}/upload_file`, {
      method: "POST",
      body: formData,
    }).then(e => {
      console.log('server response', e);
    });
  },
  logger: { // better use lines-logger instead this constructions. If you don't wanna install it, use this ugly construction below
    debug: function log() {
      var args = Array.prototype.slice.call(arguments);
      var parts = args.shift().split('{}');
      var params = [window.console, '%c' + 'painter', 'red'];
      for (var i = 0; i < parts.length; i++) {
        params.push(parts[i]);
        if (typeof args[i] !== 'undefined') {
          params.push(args[i])
        }
      }
      return Function.prototype.bind.apply(console.log, params);
    }
  }
})

CAUTION

Spainter uses flexbox if you need to support browsers like IE 9 and below, you're free to create a pull request to remove flexbox.

Contribute

To build spainter you need

  • yarn run build
  • Open index.html in browser To modify icons use bash generate-fontello.sh. it will show you help. node sass requires a lot of libs to build as well as NODE max version of 14, you can use dockerfile inside docker directory if it's much of a pain.

I also intentionally leaved styles empty so you can easily override them according to your website design. If you want to prettify it a bit, you're wellcome to create a separate .css file with styles.

spainter.pychat.org

  • update npm package to upload new code. It should be updatged manually with npm publish

  • worked that upload/stores files with cloudflare workers

  • update index.html manually from cloudflare dashboard -> workers & pages -> settings -> variables and secrets Cloudflare workers js file should contain all the css/html/js. There's no way to pull data from local fs according to this answer. This is why static files are served with cdnjs

  • Go to main page, 'Worker & Pages' -> Create application, router spainter.pychat.org/* Note star in the end.

  • Go to your dns settings and create 'A' record pointing to any ip with a proxy status.

put this envs for local debugging CF_API_KEY can be got from Profile -> Api Tokens -. Api Keys Global API KEY

yarn global add wrangler@2
export CF_API_KEY=
export [email protected]
wrangler dev

Now you can debug in Webstorm by pressing debug on package.json dev script. In ordet for debug to work switch to local mode by pressing l

CSS compile

Either use yarn build

Webstorm

For webstorm you can setup File-watcher -> sass

  • Program: ~/.nvm/versions/node/v18.13.0/bin/node
  • arguments: node_modules/.bin/node-sass index.sass index.css
  • output files to refresh: index.css

Terraform

cd terraform
terraform apply
# enter token by instruction

Some actions are not doable via CF api. We have to do them manually: GO to CloudFlare Dashboard. From Home menu -> R2 -> Overview -> Select Spainter bucket -> Settings:

  • Custom Domains -> Connect Domain -> img.spainter.akoidan.com -> Continue -> Connect Domain
  • Object lifecycle rules -> Default Multipart Abort Rule -> Edit -> Set high number, e.g. 3650 days (10 years)
  • CORS Policy -> Add Cors policy ->
{
  "AllowedOrigins": [
    "https://spainter.akoidan.com"
  ]
}