@turing-machine-js/machine 3.0.1 → 3.0.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
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [3.0.2] - 2026-05-04
8
+
9
+ ### Fixed
10
+
11
+ - **`Tape` constructor now normalises and validates `viewportWidth`** ([#95](https://github.com/mellonis/turing-machine-js/issues/95)). The constructor stored `viewportWidth` raw — the setter padded `#symbols` via `normalise()` and validated `>= 1` / bumped even values to odd, but the constructor did neither. As a result, `new Tape({ alphabet, symbols: ['a','b','a','b'], viewportWidth: 23 }).viewport.length` was `4` instead of `23`, and `viewportWidth: 0` or `viewportWidth: 4` silently produced an invalid tape. The constructor now defers to the setter, so a single source of truth handles validation + normalisation.
12
+
13
+ ### Changed (observable)
14
+
15
+ - A constructor call with an out-of-range `position` (e.g. `position: 5` with `symbols: ['x']`) now normalises at construction — the symbol array is padded with blanks so `position` lands inside the viewport. Previously the tape was left in a malformed state until the first head movement triggered `normalise()`. Strictly a fix, but observable if user code inspected `.symbols.length` immediately after construction.
16
+
7
17
  ## [3.0.1] - 2026-04-30
8
18
 
9
19
  ### Fixed
package/dist/index.cjs CHANGED
@@ -199,12 +199,13 @@ class Tape {
199
199
  }
200
200
  __classPrivateFieldSet$4(this, _Tape_alphabet, new Alphabet(alphabet), "f");
201
201
  __classPrivateFieldSet$4(this, _Tape_position, position, "f");
202
- __classPrivateFieldSet$4(this, _Tape_viewportWidth, viewportWidth, "f");
202
+ __classPrivateFieldSet$4(this, _Tape_viewportWidth, 1, "f");
203
203
  const symbolsCopy = Array.from(symbols);
204
204
  if (symbolsCopy.length === 0) {
205
205
  symbolsCopy.push(__classPrivateFieldGet$4(this, _Tape_alphabet, "f").blankSymbol);
206
206
  }
207
207
  __classPrivateFieldSet$4(this, _Tape_symbols, symbolsCopy.map((symbol) => __classPrivateFieldGet$4(this, _Tape_alphabet, "f").index(symbol)), "f");
208
+ this.viewportWidth = viewportWidth;
208
209
  }
209
210
  get alphabet() {
210
211
  return __classPrivateFieldGet$4(this, _Tape_alphabet, "f");
package/dist/index.mjs CHANGED
@@ -197,12 +197,13 @@ class Tape {
197
197
  }
198
198
  __classPrivateFieldSet$4(this, _Tape_alphabet, new Alphabet(alphabet), "f");
199
199
  __classPrivateFieldSet$4(this, _Tape_position, position, "f");
200
- __classPrivateFieldSet$4(this, _Tape_viewportWidth, viewportWidth, "f");
200
+ __classPrivateFieldSet$4(this, _Tape_viewportWidth, 1, "f");
201
201
  const symbolsCopy = Array.from(symbols);
202
202
  if (symbolsCopy.length === 0) {
203
203
  symbolsCopy.push(__classPrivateFieldGet$4(this, _Tape_alphabet, "f").blankSymbol);
204
204
  }
205
205
  __classPrivateFieldSet$4(this, _Tape_symbols, symbolsCopy.map((symbol) => __classPrivateFieldGet$4(this, _Tape_alphabet, "f").index(symbol)), "f");
206
+ this.viewportWidth = viewportWidth;
206
207
  }
207
208
  get alphabet() {
208
209
  return __classPrivateFieldGet$4(this, _Tape_alphabet, "f");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turing-machine-js/machine",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "A convenient Turing machine",
5
5
  "engines": {
6
6
  "npm": ">=7.0.0"
@@ -34,5 +34,5 @@
34
34
  "default": "./dist/index.mjs"
35
35
  }
36
36
  },
37
- "gitHead": "0a8d7ff87a3a73ea7ee1844f7f4602cbb23d20fe"
37
+ "gitHead": "0a78b4d0d40bbdbf79e3c53694adf930f0567b0a"
38
38
  }