# Changelog

## UNRELEASED

### Other improvements

- A new styling hook `--line-numbers-width` contains the width of the line number column (if line numbers are enabled)
- Fix a whole class of bugs related to coordinate computation when astral symbols, emoji and CJK characters are involved
- Document typographic edge cases

### Bugfixes

- ECMAScript: add proper highlighting support for generator functions and associated features
- ECMAScript: add proper highlighting support for the `typeof` operator, the `?.` operator the `as` keyword (in both TS and JS contexts)
- ECMAScript: fix several omissions around operators and literals like `Infinity`

## 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](https://esbuild.github.io/api/#splitting) but should [greatly](https://mastodon.social/@sir_pepe/112926132118960987) 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

- ECMAScript: add support the ancient and deprecated `with` statement

### Other

- Playground: add a way to change the tab size
- Elixir: improve diffing heuristics

## v 0.0.16

### Bugfixes

- General: most language parsers crashed when encountering certain non-terminated string-like language constructs
- CSS: the value set by `--cm-content-margin-left` was erroneously always multiplied by two
- TypeScript: add support for the `declare` keyword and associated syntax, like namespaces
- ECMAScript: add proper support for regular expressions and the `accessor` keyword
- Docs: fixed various typos and missing words, add missing docs for Elixir
- [Work around chrome's inability to deal with long selector lists](https://issues.chromium.org/issues/357017323)

## 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:

```javascript
// 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 `InputOptions` passed to **`fromStringsToScene()`** as its second argument
  must now be an object returned from a language function instead of a string
  referring to the language name
- **`fromStringsToScene()`** now returns an object containing the `Scene` object
  _and_ the language object that was originally passed in the `InputOptions`
- The first argument to **`toAnimationHTML()`** must now be an object containing
  the `scene` object _and_ the language object used to create the scene (in
  other words, it still takes the output of `fromStringsToScene()` as its first
  argument, but the actual object is slightly different)
- The main module exports `SUPPORTED_LANGUAGES` (set of language names) and
  `Language` (TypeScript union type of language names) do no longer exist

The following language modules are currently available:

- `@codemovie/code-movie/languages/css`
- `@codemovie/code-movie/languages/ecmascript` (for JavaScript and TypeScript)
- `@codemovie/code-movie/languages/elixir`
- `@codemovie/code-movie/languages/html`
- `@codemovie/code-movie/languages/json`
- `@codemovie/code-movie/languages/plaintext`

### 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:

```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 });
```

### 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

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

- Elixir:
  - an empty string as input was causing exceptions
  - the diff algorithm had too little meta information on `do` blocks to
    reliably produce non-confusing results
- TypeScript:
  - template literal types with interpolations inside were missing their
    non-interpolation bits (the actual string parts of a template literal type)
  - `readonly` in index signatures and the `infer` keyword were not properly
    detected
- ECMAScript:
  - curly braces for object literals and `switch` bodies were not properly
    detected
  - the `break` and `continue` keywords were not properly detected

### Other

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.
