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

adobe-animate-canvas-umd

v3.0.1

Published

A utility for wrapping Adobe Animate HTML5 canvas exports in modern web modules

Downloads

108

Readme

adobe-animate-canvas-umd

Build Status

Wraps Adobe Animate HTML5 canvas export files in UMD for use in modern JavaScript module ecosystems

Really old Animate CC export versions (2017.2 & below) have been removed from this version. Use [email protected] if you require this support.

Conversion example

Give it a try at novwhisky.github.io/adobe-animate-canvas-umd

Usage

CanvasUmd depends on a global reference to createjs (1.0.0 or higher). That variable must exist before loading in order to work. Despite my best efforts, there's no workable solution for shimming it into a module format.

This library only works in a browser environment currently, CanvasRenderingContext2D support in node sucks and CreateJS depends on specific DOM APIs

var umd = CanvasUmd({ 
    'class-name': 'my_animation'
    'parse-labels': true
}).convert(animateJS);

convert() appends a footer beneath your Animate export. The string it returns should be saved out in place of your original JS file. Then to import the UMD in the intended project, request the animation just like any other module

/**
* @typedef {Object} CanvasUmd
* @param {Object} composition
* @param {createjs.MovieClip} ExportRoot
* @param {Array<Object>} [frameLabels]
*/

/**
* @param {CanvasUmd} umd
* @return void
*/
const startAnimation = ({ ExportRoot }) => {
  const exportRoot = new ExportRoot();
  stage.addChild(exportRoot);
}
  
require(['path/to/animation'], startAnimation);

Options

  • class-name - The alphanumeric representation of your Animate project filename. Note that spaces, hyphens & special characters are filtered out.
  • parse-labels - Experimental Parse out top-level frame labels and add them to exports.frameLabels for static evaluation.

Enhancements

  • Better component organization and no global variables
  • Integrates with AMD loaders
  • Adds frameLabels as a static module property

How it works

CanvasUmd parses an original HTML5 canvas export from Animate CC (2017.5 - 2020) to determine the root animation name, composition id, and optionally keyframe labels by creating a temporary instance on intake. From these data an IIFE is appended to the bottom of the original definition, enabling UMD support.

// ... end of original Animate source ...

/* canvasumd:start */
(function (root, factory) {
  if(typeof define === 'function' && define.amd) define(['exports'], factory); /* AMD */
  else factory((root.amdWeb = {}));
  /* no CommonJS due to browser api dependencies (CreateJS) */
}(this, function(exports) {
  var c = (function AnimateCC_2017_5_plus(compId) {
    return AdobeAn.compositions[compId];
  })("D42F2973F03C46B7A7B10E96EF073291");
  var l = c.getLibrary();

  return {
    composition: c,
    ExportRoot: l["wombat"],
    frameLabels: [{"label":"On","position":0},{"label":"Off","position":29}]
  }
}));
/* canvasumd:end */

// EOF