<commit_before># Stellerator Embedded

Stellerator embedded is a library that allows you to embed 6502.ts' VCS emulation
into other web pages. It offers most of the functionality provided by Stellerator,
minus some of the more exotic configuration options that are unlikely to be
useful in this context.

You can find the comprehensive API documentation (including this document)
[here](https://6502ts.github.io/typedoc/stellerator-embedded/).

# Example

You can find a example of the embedded emulator
[here](https://6502ts.github.io/stellerator-embedded).
The source code is available in the 6502.ts repository on GitHub
[here](https://github.com/6502ts/6502.ts/blob/master/template/stellerator-embedded.html).

The example exposes the Stellerator instance (see below) as `window.stellerator`, so
you can access and explore it in the developer console.

# Overview

Stellerator consists of two parts: a frontend that renders the emulation output and
provides interactivity and the actual emulation core that runs on a separate thread as a
[web worker](https://developer.mozilla.org/de/docs/Web/API/Web_Workers_API). This
separation improves emulation performance and avoids slowdowns caused by other
activity on the web page.

## Frontend

The frontend provides a single class called
[`Stellerator`](https://6502ts.github.io/typedoc/stellerator-embedded/classes/stellerator.stellerator-2.html).
It is available both as a prebuild bundle that can directly loaded via script tag
and in the `6502.ts` package on NPM. The prebuilt script is most suitable
for including the emulator in a web page, while the NPM package is mainly aimed at
more sophisticated JavaScript / Typescript applications which have their own build process.

## Backend

The emulation backend is available as a prebuilt script that is loaded by the frontend at runtime
and that needs to be hosted on the page / domain that embeds the emulation.

# Installation

## Prebuilt browser bundle

Download the `stellerator_embedded.zip` archive of the latest release from
[GitHub](https://github.com/6502ts/6502.ts/releases).
The archive contains two scripts that need to be hosted on your web server alonside
the page that embeds the emulator.

 * `stellerator_embedded.min.js`: The emulation frontend. Load this via a script tag
   in your HTML:

```html
<script src="js/stellerator_embedded.min.js"></script>
```

   The `Stellerator` class is available on the global `$6502` object after the script has
   been loaded.

 * `stellerator_worker.min.js`: The web worker. The path to this script must be passed
   to the constructor of the `Stellerator` instance:

```javascript
const stellerator = new $6502.Stellerator(canvasElement, 'js/stellerator_worker.min.js');
```

In addition to these two scripts, the archive also contains source maps for both. Place
these on you server and host them alongside the scripts in order to enable source-level
debugging and traces in the developer console.

## Installation via NPM

The emulation core of 6502.ts is available as `6502.ts` on
[NPM](https://www.npmjs.com). Install into your project e.g. using npm via

```
$ npm install 6502.ts
```

After installation, you can import the `Stellerator` class using an ES6 import

```javascript
import Stellerator from '6502.ts/lib/web/embedded/stellerator/Stellerator';
```

or via `require`

```javascript
var Stellerator = require('6502.ts/lib/web/embedded/stellerator/Stellerator').default;
```

The NPM module comes with
[TypeScript](https://www.typescriptlang.org)
typings, so you can use it directly in a TypeScript project.

Note that the NPM module provides only the frontend; you'll still have to download
the worker script and host it alongside your application.

# Usage

## Basic usage

In order to use the emulator, you need to include a
[canvas element](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
in your web
page (which will display the TIA image) and create an instance of the `Stellerator`
class:

```javascript
const stellerator = new Stellerator(canvasElement, 'js/stellerator_worker.min.js');
```

The second argument of the constructor is the URL from which the web worker will be loaded.

Emulation can then be started by invoking the `run` method

```javascript
stellerator.run(romImage, Stellerator.TvMode.ntsc);
```

ROM images can be provided as arrays, typed arrays or as base64 encoded strings. Both the
constructor and `run` support an optional argument that allows to adjust many properties
of the emulator to the requirements of the embedding page, including ROM type, rendering options
and input emulation. In addition, there are methods on the `Stellerator` class that
enable interaction with the emulator at runtime. Please check out the full
[API documentation](https://6502ts.github.io/typedoc/stellerator-embedded/classes/stellerator_.stellerator.html)
for details.

## The canvas element

The emulators requires a
[canvas element](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
on the embedding page in order to display the TIA image. The resolution of
the canvas is managed by stellerator and automatically adjusted for optimal
display given the on-screen dimensions of the canvas element and the device pixel
ratio when emulation starts or enters / leaves fullscreen mode. The `width` and
`height` attributes of the canvas element need not be specified and will be overridden
by stellerator (this does **not** apply to the actual on-screen size that is determined
by CSS).<commit_msg>Fix API link.<commit_after># Stellerator Embedded

Stellerator embedded is a library that allows you to embed 6502.ts' VCS emulation
into other web pages. It offers most of the functionality provided by Stellerator,
minus some of the more exotic configuration options that are unlikely to be
useful in this context.

You can find the comprehensive API documentation (including this document)
[here](https://6502ts.github.io/typedoc/stellerator-embedded/).

# Example

You can find a example of the embedded emulator
[here](https://6502ts.github.io/stellerator-embedded).
The source code is available in the 6502.ts repository on GitHub
[here](https://github.com/6502ts/6502.ts/blob/master/template/stellerator-embedded.html).

The example exposes the Stellerator instance (see below) as `window.stellerator`, so
you can access and explore it in the developer console.

# Overview

Stellerator consists of two parts: a frontend that renders the emulation output and
provides interactivity and the actual emulation core that runs on a separate thread as a
[web worker](https://developer.mozilla.org/de/docs/Web/API/Web_Workers_API). This
separation improves emulation performance and avoids slowdowns caused by other
activity on the web page.

## Frontend

The frontend provides a single class called
[`Stellerator`](https://6502ts.github.io/typedoc/stellerator-embedded/classes/stellerator.stellerator-2.html).
It is available both as a prebuild bundle that can directly loaded via script tag
and in the `6502.ts` package on NPM. The prebuilt script is most suitable
for including the emulator in a web page, while the NPM package is mainly aimed at
more sophisticated JavaScript / Typescript applications which have their own build process.

## Backend

The emulation backend is available as a prebuilt script that is loaded by the frontend at runtime
and that needs to be hosted on the page / domain that embeds the emulation.

# Installation

## Prebuilt browser bundle

Download the `stellerator_embedded.zip` archive of the latest release from
[GitHub](https://github.com/6502ts/6502.ts/releases).
The archive contains two scripts that need to be hosted on your web server alonside
the page that embeds the emulator.

 * `stellerator_embedded.min.js`: The emulation frontend. Load this via a script tag
   in your HTML:

```html
<script src="js/stellerator_embedded.min.js"></script>
```

   The `Stellerator` class is available on the global `$6502` object after the script has
   been loaded.

 * `stellerator_worker.min.js`: The web worker. The path to this script must be passed
   to the constructor of the `Stellerator` instance:

```javascript
const stellerator = new $6502.Stellerator(canvasElement, 'js/stellerator_worker.min.js');
```

In addition to these two scripts, the archive also contains source maps for both. Place
these on you server and host them alongside the scripts in order to enable source-level
debugging and traces in the developer console.

## Installation via NPM

The emulation core of 6502.ts is available as `6502.ts` on
[NPM](https://www.npmjs.com). Install into your project e.g. using npm via

```
$ npm install 6502.ts
```

After installation, you can import the `Stellerator` class using an ES6 import

```javascript
import Stellerator from '6502.ts/lib/web/embedded/stellerator/Stellerator';
```

or via `require`

```javascript
var Stellerator = require('6502.ts/lib/web/embedded/stellerator/Stellerator').default;
```

The NPM module comes with
[TypeScript](https://www.typescriptlang.org)
typings, so you can use it directly in a TypeScript project.

Note that the NPM module provides only the frontend; you'll still have to download
the worker script and host it alongside your application.

# Usage

## Basic usage

In order to use the emulator, you need to include a
[canvas element](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
in your web
page (which will display the TIA image) and create an instance of the `Stellerator`
class:

```javascript
const stellerator = new Stellerator(canvasElement, 'js/stellerator_worker.min.js');
```

The second argument of the constructor is the URL from which the web worker will be loaded.

Emulation can then be started by invoking the `run` method

```javascript
stellerator.run(romImage, Stellerator.TvMode.ntsc);
```

ROM images can be provided as arrays, typed arrays or as base64 encoded strings. Both the
constructor and `run` support an optional argument that allows to adjust many properties
of the emulator to the requirements of the embedding page, including ROM type, rendering options
and input emulation. In addition, there are methods on the `Stellerator` class that
enable interaction with the emulator at runtime. Please check out the full
[API documentation](https://6502ts.github.io/typedoc/stellerator-embedded/classes/stellerator.stellerator-2.html)
for details.

## The canvas element

The emulators requires a
[canvas element](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API)
on the embedding page in order to display the TIA image. The resolution of
the canvas is managed by stellerator and automatically adjusted for optimal
display given the on-screen dimensions of the canvas element and the device pixel
ratio when emulation starts or enters / leaves fullscreen mode. The `width` and
`height` attributes of the canvas element need not be specified and will be overridden
by stellerator (this does **not** apply to the actual on-screen size that is determined
by CSS).
{'fraction_non_alphanumeric': 0.07169434612941283, 'fraction_numerical': 0.013885107541519195, 'mean_word_length': 4.82760444209413, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 22, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3597629', 'n_tokens_mistral': 3125, 'n_tokens_neox': 2970, 'n_words': 1389}