@algosail/parser 0.0.6 → 0.0.7

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/lib/load.js CHANGED
@@ -72,7 +72,7 @@ export async function resolveModulePath(execPath, packageImport) {
72
72
 
73
73
  const sailPath = resolveExportsCondition(packageJson.exports, path)
74
74
  if (sailPath) {
75
- return readFile(join(packageDir, sailPath), 'utf8')
75
+ return { type: 'js', path: join(packageDir, sailPath) }
76
76
  }
77
77
 
78
78
  const importId = path === '.' ? name : `${name}/${path.slice(2)}`
@@ -56,9 +56,12 @@ async function getModules(imports, uri, parser) {
56
56
 
57
57
  for (const imp of imports) {
58
58
  if (imp.type === 'package') {
59
- const moduleUri = await resolveModulePath(imp.path, uri)
59
+ const { type, path: moduleUri } = await resolveModulePath(uri, imp.path)
60
60
  const content = await readFile(moduleUri, 'utf8')
61
- const res = await parser.parseSail(moduleUri, content)
61
+ const res =
62
+ type === 'js'
63
+ ? await parser.parseJs(moduleUri, content)
64
+ : await parser.parseSail(moduleUri, content)
62
65
  modules[imp.module] = {
63
66
  ...res,
64
67
  uri: moduleUri,
@@ -68,7 +71,7 @@ async function getModules(imports, uri, parser) {
68
71
  }
69
72
 
70
73
  if (imp.type === 'file') {
71
- const { type, path: fileUri } = await resolveFilePath(imp.path, uri)
74
+ const { type, path: fileUri } = await resolveFilePath(uri, imp.path)
72
75
  const content = await readFile(fileUri, 'utf8')
73
76
  if (type === 'sail') {
74
77
  const res = await parser.parseSail(fileUri, content)
package/lib/tokens.js CHANGED
@@ -15,7 +15,7 @@ export const fieldDef = (node) => node?.text?.slice(1) ?? null
15
15
  export const fieldRef = (node) => {
16
16
  if (!node) return null
17
17
  const [map, field] = node.text.split('.')
18
- return { map: mapRef(map), field }
18
+ return { map: map.slice(1), field }
19
19
  }
20
20
 
21
21
  export const wordDef = (node) => node?.text?.slice(1) ?? null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@algosail/parser",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Parser for Sail language.",
5
5
  "license": "MIT",
6
6
  "author": "algosail",