@sprig-and-prose/sprig-universe 0.4.1 → 0.4.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprig-and-prose/sprig-universe",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "Minimal universe parser for sprig",
6
6
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -5,6 +5,9 @@
5
5
  import { scan } from './scanner.js';
6
6
  import { parse } from './parser.js';
7
7
  import { buildGraph } from './graph.js';
8
+ import { scan as scanBeta } from './universe/scanner.js';
9
+ import { parseUniverse } from './universe/parser.js';
10
+ import { buildGraph as buildGraphBeta } from './universe/graph.js';
8
11
  import { convertToSceneManifest, convertFilesToSceneManifest } from './scene-manifest.js';
9
12
  import { validateScenes } from './validator.js';
10
13
 
@@ -34,6 +37,33 @@ export function parseFiles(files) {
34
37
  return buildGraph(fileASTs);
35
38
  }
36
39
 
40
+ /**
41
+ * Parses multiple files using the beta universe pipeline.
42
+ * @param {Array<{ text: string, file: string }>} files - Array of file contents
43
+ * @returns {UniverseGraph}
44
+ */
45
+ export function parseFilesBeta(files) {
46
+ const fileASTs = [];
47
+ const parserDiagnostics = [];
48
+ for (const file of files) {
49
+ const tokens = scanBeta(file.text, file.file);
50
+ const { ast, diags } = parseUniverse({
51
+ tokens,
52
+ sourceText: file.text,
53
+ filePath: file.file,
54
+ });
55
+ fileASTs.push({ ...ast, sourceText: file.text });
56
+ if (diags?.length) {
57
+ parserDiagnostics.push(...diags);
58
+ }
59
+ }
60
+ const graph = buildGraphBeta(fileASTs);
61
+ if (parserDiagnostics.length > 0) {
62
+ graph.diagnostics = [...parserDiagnostics, ...(graph.diagnostics || [])];
63
+ }
64
+ return graph;
65
+ }
66
+
37
67
  // Export scene-related functions
38
68
  export { convertToSceneManifest, convertFilesToSceneManifest, validateScenes };
39
69