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

@sanjo-addons/library

v0.5.1

Published

A library for registering libraries that can be used by add-ons. With this library multiple different versions of a library can be loaded and the same version of a library can be loaded only once and shared across add-ons.

Downloads

3

Readme

Library

A library for registering libraries that can be used by add-ons. With this library multiple different versions of a library can be loaded and the same version of a library can be loaded only once and shared across add-ons.

Functions included:

  • Library.create: a function to create a new library.
  • Library.register: a function to register a library.
  • Library.retrieve: a function to retrieve a library.
  • Library.isRegistered: a function for checking if a library is registered.

It is intended to use semantic versioning for versions and version constraints.

Supported version constraints:

  • The newest version with a specific major version. E.g. "^2.0.0"
  • A specific version. E.g. "1.0.0"

It is recommended to use a version constraint for the newest version with a specific version (i.e. "^2.0.0"), so that the add-on uses the version of the library that is available with the latest bug fixes.

How to use

In this section it is explained for how to ship the dependencies via embedding. With this approach, the library is included as part of the add-on. A benefit to the add-on user is, that only the add-on appears in the add-on list. So it can be easier to enable or disable an add-on and its library dependencies compared to an approach where the libraries are included as add-ons (in this case each library shows as an add-on in the add-ons list and the user potentially is required to tick multiple checkboxes to enable or disable an add-on and its library dependencies). Also with this approach it can be made sure that the exact versions of the libraries are used that has been tested with.

Providing a library

--- @class ALibrary
local ALibrary = {}

-- Here you can add things to ALibrary

Library.register('ALibrary', '1.0.0', ALibrary)

Using a library

local ALibrary = Library.retrieve('ALibrary', '^2.0.0')

Make it easy to embed a library

It is recommended to create an XML file which includes all files of the library. With this approach, libraries with multiple Lua files can also be included by library users by just referencing one file. Example:

ALibrary.xml

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd">
  <Include file="ALibrary.lua" />
</Ui>

Then the library can be loaded by referencing it in the TOC file of the add-on that uses the library. Example:

libs/ALibrary/ALibrary.xml

It's recommended to load the library files first, so that the libraries are available in the other Lua files.

If the library itself has dependencies, it is recommended that those dependencies are also loaded by the add-on who uses the library.

Support

You can support me on Patreon.