@grundyjs/algiviz 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.2 — 2026-10-27
4
+
5
+ - Add a self-contained minimal usage example to both English and Russian READMEs.
6
+ - Link an interactive walkthrough of generator states, playback and custom drawing.
7
+ - Add repository examples with sequential code highlighting and explicit startup.
8
+ - No runtime API or behavior changes; examples remain outside the npm package.
9
+
3
10
  ## 0.8.1 — 2026-10-26
4
11
 
5
12
  - Use Array-prefixed internal types in public declarations and make
package/README.md CHANGED
@@ -30,26 +30,61 @@ renderer help you get started.
30
30
 
31
31
  Use it for educational demos, interactive articles and algorithm walkthroughs.
32
32
  Algorithms and layouts belong to your application; AlgiViz provides the playback
33
- and rendering API. This README describes version 0.8.1.
33
+ and rendering API. This README describes version 0.8.2.
34
34
 
35
35
  ## Start with one custom object
36
36
 
37
- The [standalone page](https://github.com/urffin/algiviz/blob/master/examples/minimal.html)
38
- moves one token with a generator and a custom Canvas handler. It uses only public
39
- package imports, without the shared demo controller. Copy its
40
- [complete module](https://github.com/urffin/algiviz/blob/master/examples/minimal.mjs)
41
- into your application and connect a canvas:
37
+ Four states of one circle: `40 → 200 → 360 → 560`. The generator supplies
38
+ coordinates, the `dot` handler draws the circle, and the player requests the next
39
+ state. Add a canvas and button to your HTML, then load the JavaScript below as a
40
+ module through a bundler that resolves imports from the installed npm package.
42
41
 
43
- ```js
44
- import { createTokenPlayer } from './minimal.mjs';
42
+ ```html
43
+ <canvas width="600" height="160"></canvas>
44
+ <button id="next">Next state</button>
45
+ ```
45
46
 
46
- const canvas = document.querySelector('canvas');
47
- const player = createTokenPlayer(canvas.getContext('2d'));
48
- player.advance(100); // Advance playback by 100 ms.
49
- // Call advance(deltaMs) from your controls or animation loop.
50
- // Call player.dispose() when removing the visualization.
47
+ ```js
48
+ import { createPlayer } from '@grundyjs/algiviz/playback';
49
+ import { createSceneRenderer } from '@grundyjs/algiviz/scene';
50
+
51
+ const ctx = document.querySelector('canvas').getContext('2d');
52
+ function* steps() {
53
+ for (const [index, x] of [40, 200, 360, 560].entries()) {
54
+ const state = { objects: [{ id: 'circle', type: 'dot', data: { x } }] };
55
+ yield { index, state, event: index === 3 ? 'done' : 'position' };
56
+ }
57
+ }
58
+ const renderer = createSceneRenderer({
59
+ dot(ctx, { current }) {
60
+ ctx.beginPath();
61
+ ctx.arc(current.data.x, 80, 18, 0, Math.PI * 2);
62
+ ctx.fillStyle = '#b39bff';
63
+ ctx.fill();
64
+ },
65
+ });
66
+ const player = createPlayer(steps(), {
67
+ stepDurationMs: 1000, finalHoldMs: 0,
68
+ isTerminal: step => step.event === 'done',
69
+ render(frame) {
70
+ ctx.clearRect(0, 0, 600, 160);
71
+ renderer.render(ctx, frame);
72
+ },
73
+ });
74
+ document.querySelector('#next').onclick = () => player.advance(1000);
51
75
  ```
52
76
 
77
+ The first frame (`x = 40`) is drawn immediately inside `createPlayer(...)`. Each
78
+ click advances one 1000 ms step: the player resumes the loop until the next
79
+ `yield`, then renders. There is no interpolation here: the handler draws only
80
+ `current`. Each snapshot is created afresh and never mutated. Call
81
+ `player.dispose()` when removing the visualization.
82
+
83
+ [Interactive walkthrough with sequential code highlighting](https://github.com/urffin/algiviz/blob/master/examples/visualization-pipeline.html)
84
+ shows initial rendering behind a Start button and the subsequent loop iterations
85
+ (Russian UI). This is an example page in the repository; run it locally using
86
+ the setup instructions below.
87
+
53
88
  [Follow the walkthrough](https://github.com/urffin/algiviz/blob/master/docs/minimal-example.md)
54
89
  for local setup, snapshot ownership and lifecycle. For a larger custom-object
55
90
  example, see the [graph BFS walkthrough](https://github.com/urffin/algiviz/blob/master/docs/custom-graph-example.md).
@@ -425,6 +460,7 @@ included in the npm archive.
425
460
 
426
461
  | Example | What it demonstrates |
427
462
  | --- | --- |
463
+ | [How a frame is made](https://github.com/urffin/algiviz/blob/master/examples/visualization-pipeline.html) | AlgiViz visualizes its own generator → player → scene → renderer pipeline (Russian walkthrough) |
428
464
  | [Sorting lab](examples/index.html) | Insertion and bubble sort using the array operations and renderer |
429
465
  | [Merge sort](examples/merge.html) | Custom state and a two-row scene for the main array and buffer |
430
466
  | [Quick sort partitions](examples/quick.html) | Lomuto and three-way partitioning with custom state and scene |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grundyjs/algiviz",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "TypeScript toolkit for custom algorithm visualizations with step-by-step playback and extensible rendering",
5
5
  "type": "module",
6
6
  "files": [
package/ru/README.md CHANGED
@@ -30,26 +30,60 @@ AlgiViz управляет воспроизведением и сопостав
30
30
 
31
31
  Используйте библиотеку для учебных примеров, интерактивных статей и пошаговых разборов.
32
32
  Алгоритмы и расположение объектов остаются в приложении; AlgiViz предоставляет API
33
- воспроизведения и отрисовки. Этот README описывает версию 0.8.1.
33
+ воспроизведения и отрисовки. Этот README описывает версию 0.8.2.
34
34
 
35
35
  ## Начните с одного собственного объекта
36
36
 
37
- [Отдельная страница](https://github.com/urffin/algiviz/blob/master/examples/minimal.html)
38
- перемещает один объект с помощью генератора и собственного Canvas-обработчика.
39
- Она использует только публичные импорты пакета, без общего контроллера демонстраций.
40
- Скопируйте [полный модуль](https://github.com/urffin/algiviz/blob/master/examples/minimal.mjs)
41
- в приложение и подключите canvas:
37
+ Четыре состояния одного круга: `40 → 200 → 360 → 560`. Генератор задаёт
38
+ координаты, обработчик `dot` рисует круг, а плеер запрашивает следующее состояние.
39
+ Добавьте Canvas и кнопку в HTML, а JavaScript ниже подключите как модуль через
40
+ сборщик, разрешающий импорты установленного npm-пакета.
42
41
 
43
- ```js
44
- import { createTokenPlayer } from './minimal.mjs';
42
+ ```html
43
+ <canvas width="600" height="160"></canvas>
44
+ <button id="next">Следующее состояние</button>
45
+ ```
45
46
 
46
- const canvas = document.querySelector('canvas');
47
- const player = createTokenPlayer(canvas.getContext('2d'));
48
- player.advance(100); // Advance playback by 100 ms.
49
- // Call advance(deltaMs) from your controls or animation loop.
50
- // Call player.dispose() when removing the visualization.
47
+ ```js
48
+ import { createPlayer } from '@grundyjs/algiviz/playback';
49
+ import { createSceneRenderer } from '@grundyjs/algiviz/scene';
50
+
51
+ const ctx = document.querySelector('canvas').getContext('2d');
52
+ function* steps() {
53
+ for (const [index, x] of [40, 200, 360, 560].entries()) {
54
+ const state = { objects: [{ id: 'circle', type: 'dot', data: { x } }] };
55
+ yield { index, state, event: index === 3 ? 'done' : 'position' };
56
+ }
57
+ }
58
+ const renderer = createSceneRenderer({
59
+ dot(ctx, { current }) {
60
+ ctx.beginPath();
61
+ ctx.arc(current.data.x, 80, 18, 0, Math.PI * 2);
62
+ ctx.fillStyle = '#b39bff';
63
+ ctx.fill();
64
+ },
65
+ });
66
+ const player = createPlayer(steps(), {
67
+ stepDurationMs: 1000, finalHoldMs: 0,
68
+ isTerminal: step => step.event === 'done',
69
+ render(frame) {
70
+ ctx.clearRect(0, 0, 600, 160);
71
+ renderer.render(ctx, frame);
72
+ },
73
+ });
74
+ document.querySelector('#next').onclick = () => player.advance(1000);
51
75
  ```
52
76
 
77
+ Первый кадр (`x = 40`) рисуется сразу внутри `createPlayer(...)`. Каждый клик
78
+ проходит один шаг длительностью 1000 мс: плеер возобновляет цикл до следующего
79
+ `yield`, затем вызывает отрисовку. Здесь нет плавного перехода: обработчик рисует
80
+ только `current`. Каждый снимок создаётся заново и больше не изменяется. При
81
+ удалении визуализации вызовите `player.dispose()`.
82
+
83
+ [Интерактивный разбор с последовательной подсветкой кода](https://github.com/urffin/algiviz/blob/master/examples/visualization-pipeline.html)
84
+ показывает создание первого кадра по кнопке «Начать» и последующие итерации цикла.
85
+ Это страница примера в репозитории; запускайте её локально по инструкции ниже.
86
+
53
87
  [Пошаговое руководство](https://github.com/urffin/algiviz/blob/master/docs/minimal-example.md)
54
88
  объясняет локальный запуск, владение снимками состояния и жизненный цикл.
55
89
  Более крупный пример с собственными объектами описан в
@@ -435,6 +469,7 @@ Canvas, передаваемые без CSS-проверки. Для пропу
435
469
 
436
470
  | Пример | Что демонстрирует |
437
471
  | --- | --- |
472
+ | [Как рождается кадр](https://github.com/urffin/algiviz/blob/master/examples/visualization-pipeline.html) | Путь от генератора через плеер и сцену к отрисовке, показанный средствами AlgiViz |
438
473
  | [Лаборатория сортировок](../examples/index.html) | Сортировки вставками и пузырьком с операциями массива и готовым рендерером |
439
474
  | [Сортировка слиянием](../examples/merge.html) | Собственное состояние и сцена из двух строк для основного массива и буфера |
440
475
  | [Разбиения быстрой сортировки](../examples/quick.html) | Разбиения Ломуто и трёхстороннее с собственными состоянием и сценой |