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

@haiku/core

v5.1.2

Published

Haiku Core is a JavaScript library for building user interfaces

Downloads

54

Readme

Animator Core

NPM

Animator Core is the runtime and rendering engine for Haiku Animator and the components you create with Animator. This engine is a dependency for any Haiku Animator components that are run on the web.

Note that for iOS and Android, Haiku Animator also supports exporting to Lottie. Animator Core is only used when rendering Animator components for the web.

Compatible with modern browsers

Animator Core is compatible with all major modern web browsers: Firefox, Chrome, Safari, and Edge. Its footprint is ~50kB gzipped.

Hackable + compatible with existing codebases

Animator Core provides a simple and familiar API for runtime manipulation of components that were built in Animator. You can play and pause animations, react to events, and even pass in dynamic data. (See the docs for more info.)

Getting started

Creating an Animator component begins in Haiku Animator:

  1. Design a component in Animator — or ask your designer for a component's Animator share URL
  2. Install the Haiku CLI: $ yarn global add @haiku/cli or $ npm i @haiku/cli --global
  3. Add that component to an existing React or web codebase: $ haiku install @haiku/yourusername-yourcomponent
  4. Seamlessly update the component as its design changes: $ haiku upgrade [projectname] [--version=rev]

Dev tip: If you have Animator installed, you can also $ npm link or $ yarn link your Animator components to make them available to your codebase toolchain's hot reloading hooks. Animator projects live in ~/.haiku/projects.

Direct installation

If you want to install and develop with Animator Core directly, you can do so with:

$ npm install @haiku/core

Or via yarn:

$ yarn add @haiku/core

Animator Core is also available via Haiku's CDN:

<!-- specific version -->
<script src="https://code.haiku.ai/scripts/core/HaikuCore.VERSION.js"></script>

API / Docs

For our full documentation (a work in progress), please see docs.haikuforteams.com. We welcome your contributions on Github.

Usage examples

Simple:

import AnimatorCore from "@haiku/core/dom";
const definition = {template: {elementName: 'div', children: ['Hello Animator!']}};
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"));

Animated:

import AnimatorCore from "@haiku/core/dom";
const definition = {
  timelines: {
    Default: {
      "#box": {
        "style.width": { 0: { value: "100px" }},
        "style.height": { 0: { value: "100px" }},
        "style.backgroundColor": { 0: { value: "red" }},
        "rotation.z": {
          0: { value: 0, curve: "linear" },
          1000: { value: 3.14159 },
        },
      },
    },
  },
  template: {
    elementName: 'div',
    attributes: {id: 'box'},
    children: ['Hello Animation!'],
  },
};
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"));

Interactive:

import AnimatorCore from "@haiku/core/dom";
const definition = {
  options: {
    autoplay: false,
  },
  states: {
    clicks: {
      value: 0,
    },
  },
  eventHandlers: {
    "#box": {
      "click": {
        handler: function () {
          this.state.clicks += 1;
          this.getTimeline("Default").play();
        },
      },
    },
  },
  timelines: {
    Default: {
      "#box": {
        "content": { 0: {
          value: function (clicks) {
            return clicks + "";
          },
        }},
        "style.width": { 0: { value: "100px" }},
        "style.height": { 0: { value: "100px" }},
        "style.backgroundColor": { 0: { value: "red" }},
        "rotation.z": {
          0: { value: 0, curve: "linear" },
          1000: { value: 3.14159 },
        },
      },
    },
  },
  template: {
    elementName: 'div',
    attributes: {id: 'box'},
  },
};
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"));

Tracking / Analytics

By default, Haiku tracks usage of published components by transmitting metadata to Haiku's Mixpanel account when components are initialized on the page. We send only public information: your component's name, its Haiku account username, the software version it was built with, and its share identifier.

To disable this, set the mixpanel option to false:

// ...
const factory = AnimatorCore(definition);
const component = factory(document.getElementById("mount"), {
  mixpanel: false // Or the string of your own Mixpanel API token
})

Bugs / Feature Requests / Troubleshooting

Please use GitHub Issues.

Contributing

Please send contributions via pull request.

Roadmap

Code improvements

  • Use arrow functions throughout (in progress!)
  • Improve test coverage
  • Inline source code docs
  • Types

Features

  • Alternative component formats
  • Improved Lottie integration
  • More comprehensive programmatic API

Development

To develop Animator Core locally:

  1. Fork the repo
  2. $ yarn install

Compile with:

$ yarn compile

Test with:

$ yarn test

Find formatting problems with:

$ yarn lint

Run demos in your browser:

$ yarn demos

License / Copyright

MIT. Please refer to LICENSE.txt. Copyright (c) 2016-2018 Haiku Systems Inc.