# `@foxford/blockly`

Embeddable Blockly Legacy React component.

## Install

```bash
yarn add @foxford/blockly
```

## Standalone Archive Setup (No Registry)

Validated environment:

- `Node.js v24`
- `Yarn 4.1.1`

If you deliver this package as a source archive, prepare local `.tgz` archives for:

- `@foxford/blockly-games@1.1.13`
- `@foxford/js-interpreter@1.1.3`

Then run:

```bash
yarn add @foxford/blockly-games@file:./vendor/<blockly-games-archive>.tgz
yarn add @foxford/js-interpreter@file:./vendor/<js-interpreter-archive>.tgz
yarn install
yarn dev
yarn build:playground
```

## Usage

```tsx
import { Blockly } from '@foxford/blockly';

<Blockly
  config={{
    template: 'maze',
    commands: ['moveForward', 'turnLeft', 'turnRight'],
    map: [
      ['1', '1', '1'],
      ['1', '1', '1'],
      ['1', '1', '1'],
    ],
  }}
  configuration={{ basePath: '/' }}
  locale="ru-RU"
/>
```

### Props

- `config` — required mechanic config, includes `template` and mechanic-specific fields.
- `configuration` — required runtime config:
  - `basePath` — base URL for package static files (`img`, `createjs`, `static`).
- `locale` — current locale (`ru-RU`/`en-US`, other locales fallback to `en-US`).
- `savedCode` — optional XML code to restore.
- callbacks:
  - `onCodeChange(code)`
  - `onError(code)`
  - `onFinish(code)`
  - `onGameStatusChange(status)`
  - `onNextLevel()`

## Development

```bash
yarn dev
```
