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

@appsemble/sdk

v0.28.6

Published

Build your own blocks

Downloads

3,098

Readme

Appsemble SDK

Build your own blocks

npm GitLab CI Prettier

Table of Contents

Installation

npm install @appsemble/sdk

Usage

bootstrap

The bootstrap function registers a function which gets called every time a new instance of the block is created. If the block returns a DOM Node, it’s attached to the block’s shadow root.

The function may be asynchronous, but should not wait for actions to have finished, as actions are delayed until all blocks on a page are ready.

import { bootstrap } from '@appsemble/sdk';

bootstrap(({ utils }) => {
  const root = document.createElement('span');
  root.textContent = utils.formatMessage('hello');
  return root;
});

TypeScript interfaces

Various block settings can be defined by augmenting interfaces in @appsemble/sdk. This allows you as a block developer to work in a type safe manner, while providing validation and documentation for users implementing your block in their app.

Parameters

Block parameters can be defined by augmenting the @appsemble/sdk#Parameters interface. The Appsemble CLI will automatically create a JSON schema from these type definitions. This includes the TSDoc comments. It’s highly recommended to properly document this interface, as generated documentation is user-facing. JSON schema properties can be written as TSDoc tags. Markdown is supported in descriptions.

declare module '@appsemble/sdk' {
  interface Parameters {
    /**
     * This is an example string parameter.
     *
     * @format email
     * @maxLength 50
     * @minLength 10
     * @pattern ^.+@.*+\..+$
     * @example 'Example string'
     */
    exampleString: string;

    /**
     * This is an number parameter.
     *
     * @type integer
     * @maximum 1337
     * @minimum 42
     * @multipleOf 3
     * @example 123
     */
    exampleNumber: number;
  }
}

Actions

Block actions can be defined by augmenting the @appsemble/sdk#Action interface. Only the action keys and TSDoc descriptions are used. Markdown is supported in descriptions.

declare module '@appsemble/sdk' {
  interface Action {
    /**
     * This is an example action.
     */
    onClick: never;
  }
}

Events

Block event emitters can be defined by augmenting the @appsemble/sdk#EventEmitters interface. Block event listeners can be defined by augmenting the @appsemble/sdk#EventListeners interface. For both emitters and listeners, only the keys and TSDoc descriptions are used. Markdown is supported in descriptions.

declare module '@appsemble/sdk' {
  interface EventEmitters {
    /**
     * This is an example event emitter.
     */
    data: never;
  }

  interface EventListeners {
    /**
     * This is an example event listener.
     */
    refresh: never;
  }
}

Messages

Block messages can be defined by augmenting the @appsemble/sdk#Messages interface. The values of these properties are used for type safety when calling utils.formatMessage(). Markdown is supported in descriptions.

declare module '@appsemble/sdk' {
  interface Messages {
    /**
     * This message doesn’t support variables
     */
    bye: never;

    /**
     * This message accepts a variable named `name`.
     */
    hello: {
      name: string;
    };
  }
}

License

LGPL-3.0-only © Appsemble