@ball-lang/engine 1.5.3 → 1.5.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ball-lang/engine",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Ball language engine — interprets Ball programs in TypeScript/JavaScript. Runs in Node.js and browsers.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -16,7 +16,7 @@
16
16
  "scripts": {
17
17
  "build": "tsc",
18
18
  "test": "node --experimental-strip-types test/engine_test.ts && node --experimental-strip-types --test test/*.test.ts",
19
- "coverage": "c8 --reporter=text --reporter=lcov --include \"src/**\" --exclude \"src/compiled_engine.ts\" --check-coverage --lines 91 --branches 62 --functions 95 --statements 91 npm test",
19
+ "coverage": "c8 --reporter=text --reporter=lcov --include \"src/**\" --exclude \"src/compiled_engine.ts\" --check-coverage --lines 99 --branches 65 --functions 97 --statements 99 npm test",
20
20
  "prepublishOnly": "npm run build",
21
21
  "prepack": "npm run build"
22
22
  },
@@ -3736,6 +3736,7 @@ export class BallEngine {
3736
3736
  return e.key;
3737
3737
  }))];
3738
3738
  }
3739
+ throw new BallRuntimeError(('Cannot access field "keys" on ' + __ball_to_string(((__ball_eq(object, null) ? null : object.runtimeType) ?? 'null'))));
3739
3740
  }
3740
3741
  else if ((__sw === 'values')) {
3741
3742
  if ((typeof object === 'object' && object !== null && !Array.isArray(object) && !(object instanceof BallDouble) && !(object instanceof Set))) {
@@ -3753,6 +3754,7 @@ export class BallEngine {
3753
3754
  }
3754
3755
  return vals;
3755
3756
  }
3757
+ throw new BallRuntimeError(('Cannot access field "values" on ' + __ball_to_string(((__ball_eq(object, null) ? null : object.runtimeType) ?? 'null'))));
3756
3758
  }
3757
3759
  else if ((__sw === 'isNaN')) {
3758
3760
  return _ballNumIsNaN(object);
@@ -7450,19 +7452,27 @@ export class BallEngine {
7450
7452
  }), ['map_keys']: ((i) => {
7451
7453
  const input = i;
7452
7454
  let m = this._stdAsMap(i);
7453
- if (this._isBallSet(__ball_index(m, 'map'))) {
7455
+ let target = __ball_index(m, 'map');
7456
+ if (this._isBallSet(target)) {
7454
7457
  return [];
7455
7458
  }
7456
- let result = _ballMapKeysDyn(__ball_index(m, 'map'));
7459
+ if ((!((typeof target === 'object' && target !== null && !Array.isArray(target) && !(target instanceof BallDouble) && !(target instanceof Set))) && !(false /* BallMap is Map in TS */))) {
7460
+ throw new BallRuntimeError('map_keys: expected Map or Set');
7461
+ }
7462
+ let result = _ballMapKeysDyn(target);
7457
7463
  this._trackMemoryAllocation(__ball_mul(result.length, _ballPointerBytes));
7458
7464
  return result;
7459
7465
  }), ['map_values']: ((i) => {
7460
7466
  const input = i;
7461
7467
  let m = this._stdAsMap(i);
7462
- if (this._isBallSet(__ball_index(m, 'map'))) {
7468
+ let target = __ball_index(m, 'map');
7469
+ if (this._isBallSet(target)) {
7463
7470
  return [];
7464
7471
  }
7465
- let result = _ballMapValuesDyn(__ball_index(m, 'map'));
7472
+ if ((!((typeof target === 'object' && target !== null && !Array.isArray(target) && !(target instanceof BallDouble) && !(target instanceof Set))) && !(false /* BallMap is Map in TS */))) {
7473
+ throw new BallRuntimeError('map_values: expected Map or Set');
7474
+ }
7475
+ let result = _ballMapValuesDyn(target);
7466
7476
  this._trackMemoryAllocation(__ball_mul(result.length, _ballPointerBytes));
7467
7477
  return result;
7468
7478
  }), ['map_entries']: ((i) => {
@@ -1709,9 +1709,11 @@ export function createEngineSetup(mod: EngineModule) {
1709
1709
  };
1710
1710
  }
1711
1711
 
1712
- // Patch __bts (ball-to-string) to unwrap BallFuture/BallGenerator.
1713
- // The compiled engine sets globalThis.__bts during preamble execution.
1714
- // We wrap it after the engine runs its preamble.
1712
+ // Patch __bts (ball-to-string) to unwrap BallFuture/BallGenerator, IF the
1713
+ // compiled engine has installed one on globalThis. As of the current
1714
+ // compiled_engine.ts, it never does (grepped: zero assignments to
1715
+ // globalThis.__bts) — this is a defensive no-op guarding against a future
1716
+ // preamble that starts exposing one, not an active code path today.
1715
1717
  const origBts = (globalThis as any).__bts;
1716
1718
  if (typeof origBts === 'function') {
1717
1719
  (globalThis as any).__bts = function(v: any): string {