Changelog

v 0.0.21

Feature: Decorations

Decorations are finally available! You can add highlights, gutter icons and underlines (and much more once you get creative with CSS) to your animations.

Breaking: auto-incrementing root class seed

This library auto-generates class names for the animations based on a seed value. This seed value can be changed via the option rootClassSeed when calling animateHTML() or toAnimationHTML(), but this was (and remains) optional:

import { animateHTML } from "@codemovie/code-movie";
import json from "@codemovie/code-movie/languages/json";

let html = animateHTML(
  [
    /* keyframes */
  ],
  {
    tabSize: 2,
    language: json(),
    rootClassSeed: 42, // optional
  },
);
12345678910111213
import { animateHTML } from "@codemovie/code-movie";
import json from "@codemovie/code-movie/languages/json";

let html = animateHTML(
  [
    /* keyframes */
  ],
  {
    tabSize: 2,
    language: json(),
    rootClassSeed: 42, // optional
  },
);

This seed value used to default to 0, which meant that (unless a custom seed value was provided) two animations in a single page would probably suffer from class collisions. This default value arguably did more harm than good, so 0.0.21 changes it to an auto-incrementing number, starting with a random large integer. If you rely on reproducing the same class names each time you call animateHTML() or toAnimationHTML(), be sure to pass the same number as the rootClassSeed option.

Bugfixes in 0.0.21

v 0.0.20

Feature: animateHTML(input, options)

This new function combines fromStringsToScene() and toAnimationHTML() into one slightly more convenient function. Where you previously had to wrangle two functions and two options objects...

import { fromStringsToScene, toAnimationHTML } from "@codemovie/code-movie";
import json from "@codemovie/code-movie/languages/json";

let keyframes = [
  /* keyframes go here */
];

let html = toAnimationHTML(
  fromStringsToScene(keyframes, {
    tabSize: 2,
    language: json(),
  }),
  {
    rootClassSeed: 42,
  },
);
12345678910111213141516
import { fromStringsToScene, toAnimationHTML } from "@codemovie/code-movie";
import json from "@codemovie/code-movie/languages/json";

let keyframes = [
  /* keyframes go here */
];

let html = toAnimationHTML(
  fromStringsToScene(keyframes, {
    tabSize: 2,
    language: json(),
  }),
  {
    rootClassSeed: 42,
  },
);

You can now just import and call a single function to get the same effect:

import { animateHTML } from "@codemovie/code-movie";
import json from "@codemovie/code-movie/languages/json";

let keyframes = [
  /* keyframes go here */
];

let html = animateHTML(keyframes, {
  tabSize: 2,
  language: json(),
  rootClassSeed: 42,
});
123456789101112
import { animateHTML } from "@codemovie/code-movie";
import json from "@codemovie/code-movie/languages/json";

let keyframes = [
  /* keyframes go here */
];

let html = animateHTML(keyframes, {
  tabSize: 2,
  language: json(),
  rootClassSeed: 42,
});

The options object combines the options available to fromStringsToScene() and toAnimationHTML() into a single object. The old functions fromStringsToScene() and toAnimationHTML() are still available and will remain supported for the forseeable future.

Bugfixes in 0.0.20

v 0.0.19

Bugfixes in 0.0.19

v 0.0.18

Breaking: theme object changes

The theme object has always contained some unused data for decorations (code underlines, gutter icons an similar). In preparation for the upcoming release of actual decoration support, the schema for this data has changed. If you have created your own theme object previously, you will need to perform the following modifications:

  1. set version to 1
  2. replace layers.decorations with the following:
Show the new content of layers.decorations
let myTheme = {
  version: 1,
  /* ... other things... */
  layers: {
    /* ... other things... */
    decorations: {
      gutter: {
        kind: "DECORATION_GUTTER",
        offset: [0, 0],
      },
      line: {
        kind: "DECORATION_LINE",
        background: {
          endLeft: "scene",
          endRight: "scene",
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#FFF2BC",
            },
          },
        },
        foreground: {
          endLeft: "scene",
          endRight: "scene",
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#00000000",
            },
          },
        },
      },
      text: {
        kind: "DECORATION_TEXT",
        background: {
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#FFFF00",
            },
          },
          underline: {
            kind: "UNDERLINE",
            offsetY: 0,
            style: "none",
            color: {
              kind: "COLOR",
              value: "#000000",
            },
            scale: 1,
            width: 1,
          },
        },
        foreground: {
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#00000000",
            },
          },
          underline: {
            kind: "UNDERLINE",
            offsetY: 0,
            style: "none",
            color: {
              kind: "COLOR",
              value: "#000000",
            },
            scale: 1,
            width: 1,
          },
        },
      },
    },
    /* ... other things... */
  },
};
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
let myTheme = {
  version: 1,
  /* ... other things... */
  layers: {
    /* ... other things... */
    decorations: {
      gutter: {
        kind: "DECORATION_GUTTER",
        offset: [0, 0],
      },
      line: {
        kind: "DECORATION_LINE",
        background: {
          endLeft: "scene",
          endRight: "scene",
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#FFF2BC",
            },
          },
        },
        foreground: {
          endLeft: "scene",
          endRight: "scene",
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#00000000",
            },
          },
        },
      },
      text: {
        kind: "DECORATION_TEXT",
        background: {
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#FFFF00",
            },
          },
          underline: {
            kind: "UNDERLINE",
            offsetY: 0,
            style: "none",
            color: {
              kind: "COLOR",
              value: "#000000",
            },
            scale: 1,
            width: 1,
          },
        },
        foreground: {
          backdrop: {
            kind: "BACKDROP",
            value: {
              kind: "COLOR",
              value: "#00000000",
            },
          },
          underline: {
            kind: "UNDERLINE",
            offsetY: 0,
            style: "none",
            color: {
              kind: "COLOR",
              value: "#000000",
            },
            scale: 1,
            width: 1,
          },
        },
      },
    },
    /* ... other things... */
  },
};

Other improvements in 0.0.18

Bugfixes in 0.0.18

v 0.0.17

New language: Rust

Support for Rust has landed! Simply import the language module @codemovie code-movie/languages/rust and go from there. Rust is a complex language that I personally know next to nothing about, so you can expect this first version to maybe miss some syntax and definitely have some sub-par animation heuristics. You can also expect this to improve over time.

Improvement: Code Splitting

Languages modules now benefit from code splitting, which removes a lot of previously duplicated code. This only applies to ESM modules but should greatly reduce the overall bundle size for all projects. All language modules that leverage the common parsing infrastructure or that make use of other languages modules (like JS and CSS being used in HTML to support <style> and <script>) will benefit from this change.

Bugfixes in 0.0.17

Other changes in 0.0.17

v 0.0.16

Bugfixes in 0.0.16

v 0.0.15

Breaking: language modules

Adding support for Elixir in 0.0.13 increased the bundle size considerably, which made modularizing the entire project necessary. Languages are now modules that need to be imported and instantiated explicitly:

// Main module imports like before
import { fromStringsToScene, toAnimationHTML } from "@codemovie/code-movie";

// NEW: import the language module you want to use
import json from "@codemovie/code-movie/languages/json";

// NEW: instantiate the language. Some languages can be configured to support
// certain features by passing options to the language function (eg. enable JSX
// support in ECMAScript by passing `{ jsx: true }`)
const language = json();

let sceneData = fromStringsToScene(
  [
    /* ...keyframes... */
  ],
  {
    tabSize: 2,
    language, // NEW: now the language object instead of a string
  },
);

let html = toAnimationHTML(sceneData);
12345678910111213141516171819202122
// Main module imports like before
import { fromStringsToScene, toAnimationHTML } from "@codemovie/code-movie";

// NEW: import the language module you want to use
import json from "@codemovie/code-movie/languages/json";

// NEW: instantiate the language. Some languages can be configured to support
// certain features by passing options to the language function (eg. enable JSX
// support in ECMAScript by passing `{ jsx: true }`)
const language = json();

let sceneData = fromStringsToScene(
  [
    /* ...keyframes... */
  ],
  {
    tabSize: 2,
    language, // NEW: now the language object instead of a string
  },
);

let html = toAnimationHTML(sceneData);

This change breaks the following APIs:

The following language modules are currently available:

Improvement: JSX support for JavaScript and TypeScript

The language module @codemovie/code-movie/languages/ecmascript enables support for JSX in both TypeScript and vanilla JavaScript:

import ecmascript from "@codemovie/code-movie/languages/ecmascript";

let regularJavaScript = ecmascript();
let typeScript = ecmascript({ ts: true });
let javaScriptWithJSX = ecmascript({ jsx: true });
let typeScriptWithJSX = ecmascript({ ts: true, jsx: true });
123456
import ecmascript from "@codemovie/code-movie/languages/ecmascript";

let regularJavaScript = ecmascript();
let typeScript = ecmascript({ ts: true });
let javaScriptWithJSX = ecmascript({ jsx: true });
let typeScriptWithJSX = ecmascript({ ts: true, jsx: true });

Improvement: optional ranges and decorations

The fields ranges and decorations on InputFrames (the first argument to fromStringsToScene()) are now optional and default to empty arrays. They will be empty for most frames anyway and filling in the blanks is trivial. Plus it makes the tutorial shorter!

Bugfixes in 0.0.15

The bugfixes all revolve around plugging small to medium-sized holes in language support:

Other changes in in 0.0.15

Adjusted some magic numbers in the token matchup functions. This should provide an overall improved diffing behavior.

v 0.0.14

Improve stability and add support for Elixir.

v 0.0.13

Initial public release.