@kernlang/test 4.0.0 → 4.0.1-canary.224.1.1a92ac0a

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/dist/index.js CHANGED
@@ -1,9 +1,16 @@
1
- import { decompile, emitNativeKernBodyTS, generateCoreNode, importTypeScript, parseDocumentWithDiagnostics, validateSchema, validateSemantics, } from '@kernlang/core';
1
+ import { decompile, emitNativeKernBodyTS, generateCoreNode, parseDocumentWithDiagnostics, validateSchema, validateSemantics, } from '@kernlang/core';
2
+ import { importTypeScript, nativeEligibilityClassifier, typescriptClosureClassifier } from '@kernlang/core/node';
2
3
  import { execFileSync } from 'child_process';
3
4
  import { existsSync, readdirSync, readFileSync, statSync } from 'fs';
4
5
  import { dirname, join, relative, resolve } from 'path';
5
6
  import { inspect, isDeepStrictEqual } from 'util';
6
7
  import { createContext, Script } from 'vm';
8
+ // Slice 0.9 — Node-side: inject the TypeScript-backed classifiers so block-bodied
9
+ // arrows in expression props keep parsing (instead of fail-closing).
10
+ const NODE_PARSE_CAPS = {
11
+ closureClassifier: typescriptClosureClassifier,
12
+ nativeEligibilityClassifier,
13
+ };
7
14
  const DISCOVERY_SKIP_DIRS = new Set([
8
15
  '.git',
9
16
  '.next',
@@ -534,7 +541,7 @@ function loadKernDocument(file) {
534
541
  };
535
542
  }
536
543
  const source = readFileSync(file, 'utf-8');
537
- const parsed = parseDocumentWithDiagnostics(source);
544
+ const parsed = parseDocumentWithDiagnostics(source, undefined, NODE_PARSE_CAPS);
538
545
  const schemaViolations = validateSchema(parsed.root);
539
546
  const semanticViolations = validateSemantics(parsed.root).filter((violation) => !isMultiSourceTransitionFalsePositive(violation, parsed.root));
540
547
  return {
@@ -1940,7 +1947,7 @@ function evaluateRoundtripAssertion(_node, target) {
1940
1947
  if (decompiled.message || decompiled.code === undefined) {
1941
1948
  return { passed: false, message: `Target has decompile error: ${decompiled.message || 'unknown error'}` };
1942
1949
  }
1943
- const reparsed = parseDocumentWithDiagnostics(decompiled.code);
1950
+ const reparsed = parseDocumentWithDiagnostics(decompiled.code, undefined, NODE_PARSE_CAPS);
1944
1951
  const parseError = reparsed.diagnostics.find((diagnostic) => diagnostic.severity === 'error');
1945
1952
  if (parseError) {
1946
1953
  return {
@@ -2005,7 +2012,7 @@ function resolveImportAssertionSource(node, context) {
2005
2012
  }
2006
2013
  }
2007
2014
  function evaluateImportedKernRoundtrip(kern, options = {}) {
2008
- const reparsed = parseDocumentWithDiagnostics(kern);
2015
+ const reparsed = parseDocumentWithDiagnostics(kern, undefined, NODE_PARSE_CAPS);
2009
2016
  const parseError = reparsed.diagnostics.find((diagnostic) => diagnostic.severity === 'error');
2010
2017
  if (parseError) {
2011
2018
  return {
@@ -5871,7 +5878,7 @@ function evaluateNativeAssertion(node, target, context) {
5871
5878
  ];
5872
5879
  }
5873
5880
  export function hasNativeKernTests(source) {
5874
- return collectNodes(parseDocumentWithDiagnostics(source).root, 'test').length > 0;
5881
+ return collectNodes(parseDocumentWithDiagnostics(source, undefined, NODE_PARSE_CAPS).root, 'test').length > 0;
5875
5882
  }
5876
5883
  function isKernFile(file) {
5877
5884
  return file.endsWith('.kern');