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

scripty-strokes

v0.5.3

Published

### This was made this for fun because I love StrokesPlus.net and I also love Javascript.

Downloads

6

Readme

ScriptyStrokes, a StrokesPlus.net Scripting Framework

This was made this for fun because I love StrokesPlus.net and I also love Javascript.

Initially I tried to use the load external script feature but when I moved the file on accident, it caused a crash loop where I couldn't even start the program anymore. I put the old file back and started thinking how to over come this, something more dynamic.

I like the require() function used in CommonJs to load other modules, so I put to work to try and make an implementation of this functionality for myself. I started with a little bootstrapper that sets up __dirname to reference the framework files, then a simple version of the code for the loader.

Adding The ScriptyStrokes Bootstrapper

Under Global Action, pick the Load/Unload tab, and check the box to enable the load script. Replace the path with the absolute path to the cloned repository.

function ScriptyStrokes() {
    var ROOT = String.raw`<PATH_TO_REPO>`;
    return eval("("+File.ReadAllText(`${ROOT}/bootstrap.js`)+")")(ROOT);
}

The bootstrapper takes care of providing a rich standard library that wraps many common sp.xxxx methods with simple APIs.

Examples

var { alert } = ScriptyStrokes();

alert("Hello World");
var { toast } = ScriptyStrokes();

toast("Hello World");
var { toast } = ScriptyStrokes();

var toaster = toast.factory("My Toaster is Fancy");

toaster("I MAKE TOAST!");
var { balloon } = ScriptyStrokes();

balloon("Hello World!", { title: "Custom Title" });

These are just a few of the many modules that come included. Check out the stdlib modules as well as application specific modules too.

Writing Modules

Scripty Modules look just like CJS modules, with a defined module.exports containing what you want to export from the module.

Classes

class Environment {
  expand(name) {
    return clr.System.Environment.GetEnvironmentVariable(name);
  }
}

module.exports = new Environment();

source of the env module

Functions

/**
 * Create a modal dialog box notification.
 *
 * @param message string
 * @param title   string
 */
function alert(message, title = "ScriptyStrokes") {
  sp.MessageBox(message, title);
}

module.exports = alert;

Complex Functionality & Multiple Exports

function queryString(obj) {
  return Object.keys(obj)
    .map(k => `${encodeURIComponent(k)}=${encodeURIComponent(obj[k])}`)
    .join("&");
}

function request({ baseUrl }) {
  var httpHandler = new HttpClientHandler();
  httpHandler.AutomaticDecompression = host.flags(
    DecompressionMethods.GZip,
    DecompressionMethods.Deflate
  );

  var client = new HttpClient(httpHandler);
  client.BaseAddress = new Uri(baseUrl);

  return (url, params) => {
    var endpoint = params ? `${url}?${queryString(params)}` : url;
    var response = client.GetAsync(endpoint).Result;
    var result = response.Content.ReadAsStringAsync().Result;

    httpHandler.Dispose();
    client.Dispose();

    return result;
  };
}

module.exports = { queryString, request };

With the simple StrokesPlus.net actions usage:

var { request } = ScriptyStrokes();

var stackExchange = request({ baseUrl: "https://api.stackexchange.com/2.2/" });

var res = stackExchange("answers", {
  order: "desc",
  sort: "activity",
  site: "stackoverflow"
});

clip.SetText(res);