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

@fxhash/project-sdk

v0.0.13

Published

The `@fxhash/project-sdk` is the library to create generatives artworks on fx(hash).

Downloads

84

Readme

@fxhash/project-sdk

The @fxhash/project-sdk is the library to create generatives artworks on fx(hash).

This packages is intended to be used in the browser and therefore exposes a IIFE (Immediately Invoked Function Expression) that exposes the $fx API on the window.

API

The window.$fx exposes the following API.

{
  hash: String, // a random 64 characters hexadecimal string. This particular variable will be hardcoded with a static hash when someone mints a token from your GT
  rand: () => Number, // a PRNG function seeded with the hash, that generates deterministic PRN between 0 and 1
  minter: String, // The string of the wallet address of the minter injected into the iteration
  randminter: () => Number, // a PRNG function seeded with the minter address that generates deterministic PRN between 0 and 1
  preview: () => void, // trigger for capture module
  isPreview: Boolean, // is TRUE when capture module is running the project
  params: (definitions) => void, // sets your projects fx(params) definitions
  getParam: (id: String) => any, // get transformed fx(params) value by id
  getParams: () => any, // get all transformed fx(params) values
  getRawParam: (id: String) => any, // get raw fx(params) value by id
  getRawParams: () => any, // get all raw fx(params) values
  getDefinitions: () => any, // get all fx(params) definitions
  features: (features) => void, // sets your projects features
  getFeature: (id: String) => any, // get feature by id
  getFeatures: () => any, // get all features
  stringifyParams: (definitions) => string, // JSON.stringify that can handle bigint
}

fx(params)

The following fx(params) types are available. All types share the same attributes but have different options available to e.g. constrain your parameters to your needs.

The available fx(params) types are:

  • number: Number aka float64
  • bigint: BigInt aka int64
  • boolean: boolean
  • color: Color in 8-hexdigit and abbreviations
  • string: String with max 64 characters
  • select: Selection of provided options options

The index.js of this boilerplate quickly demonstrates a meaningfull configuration for each fx(params) type.

Base Attributes

All param share a few base attributes and have each param has a type specific options attribute to adjust the param to your needs.

{
  id: string, // required
  name?: string, // optional, if not defined name == id
  type: "number" | "bigint" | "boolean" | "color" | "string" | "select", // required
  default?: string | number | bigint | boolean, // optional (see Randomization)
  options: TYPE_SPECIFIC_OPTIONS, // different options per type (see below)
}

Randomization

The fxhash snippet generates a random value for each parameter. The random value generation happens within the defined constrains of the parameter definition. Each parameter has the possibility to define a default value. Setting the default will prevent the parameter to be initialised with a random value. This can be relevant during the development stage but is also relevant to consider for the final minting flow, when the user will define the final parameter configuration for the uniquely minted token.

Type specific options

number

All options are optional.

Options:

{
  min?: number,
  max?: number,
  step?: number,
}

bigint

All options are optional.

Options:

{
  min?: number | bigint,
  max?: number | bigint,
}

boolean

No options.

Options:

undefined

color

No options.

Options:

undefined

string

All options are optional.

Options:

{
  minLength?: number,
  maxLength?: number,
}

select

Options are required. They define the options of the select

Options:

{
  options: string[],
}

Transformation

For ease of usage the fx(params) are being transformed into their type specific representation.

number

getFloat64

bigint

getBigInt64

boolean

not transformed

string

not transformed

color

{
 hex: {
  rgb: '#ff0000',
  rgba: '#ff0000ff',
 },
 obj: {
  rgb: { r, g, b},
  rgba: { r, g, b, a },
 },
 arr: {
  rgb: [r,g,b],
  rgba: [r,g,b,a],
 },
}

The fx(snippet) exposes two different way to retrieve fx(params) values:

  • getParam and getParams will return the transformed values as described above
  • getRawParam and getRawParams will return the raw values after being serialized from the bytestring and without any transformation