sh-ast 0.0.0 → 0.1.0

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.
Files changed (73) hide show
  1. package/README.md +147 -0
  2. package/dist/analyze/ansi-c-escapes.d.ts +53 -0
  3. package/dist/analyze/ansi-c-escapes.d.ts.map +1 -0
  4. package/dist/analyze/ansi-c-escapes.js +255 -0
  5. package/dist/analyze/ansi-c-escapes.js.map +1 -0
  6. package/dist/analyze/decode-lit.d.ts +74 -0
  7. package/dist/analyze/decode-lit.d.ts.map +1 -0
  8. package/dist/analyze/decode-lit.js +114 -0
  9. package/dist/analyze/decode-lit.js.map +1 -0
  10. package/dist/analyze/enumerate-commands.d.ts +159 -0
  11. package/dist/analyze/enumerate-commands.d.ts.map +1 -0
  12. package/dist/analyze/enumerate-commands.js +390 -0
  13. package/dist/analyze/enumerate-commands.js.map +1 -0
  14. package/dist/analyze/index.d.ts +18 -0
  15. package/dist/analyze/index.d.ts.map +1 -0
  16. package/dist/analyze/index.js +27 -0
  17. package/dist/analyze/index.js.map +1 -0
  18. package/dist/analyze/node-helpers.d.ts +28 -0
  19. package/dist/analyze/node-helpers.d.ts.map +1 -0
  20. package/dist/analyze/node-helpers.js +37 -0
  21. package/dist/analyze/node-helpers.js.map +1 -0
  22. package/dist/analyze/resolve-word.d.ts +146 -0
  23. package/dist/analyze/resolve-word.d.ts.map +1 -0
  24. package/dist/analyze/resolve-word.js +202 -0
  25. package/dist/analyze/resolve-word.js.map +1 -0
  26. package/dist/analyze.d.ts +390 -0
  27. package/dist/deep-freeze.d.ts +14 -0
  28. package/dist/deep-freeze.d.ts.map +1 -0
  29. package/dist/deep-freeze.js +25 -0
  30. package/dist/deep-freeze.js.map +1 -0
  31. package/dist/errors.d.ts +115 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +106 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/index.d.ts +18 -0
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +5 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/normalize.d.ts +52 -0
  40. package/dist/normalize.d.ts.map +1 -0
  41. package/dist/normalize.js +260 -0
  42. package/dist/normalize.js.map +1 -0
  43. package/dist/parse.d.ts +45 -0
  44. package/dist/parse.d.ts.map +1 -0
  45. package/dist/parse.js +118 -0
  46. package/dist/parse.js.map +1 -0
  47. package/dist/sh-ast.d.ts +1270 -0
  48. package/dist/types.d.ts +70 -0
  49. package/dist/types.d.ts.map +1 -0
  50. package/dist/types.js +2 -0
  51. package/dist/types.js.map +1 -0
  52. package/dist/visitor-keys.d.ts +21 -0
  53. package/dist/visitor-keys.d.ts.map +1 -0
  54. package/dist/visitor-keys.js +23 -0
  55. package/dist/visitor-keys.js.map +1 -0
  56. package/dist/walk.d.ts +18 -0
  57. package/dist/walk.d.ts.map +1 -0
  58. package/dist/walk.js +40 -0
  59. package/dist/walk.js.map +1 -0
  60. package/dist/wasm-instance.d.ts +13 -0
  61. package/dist/wasm-instance.d.ts.map +1 -0
  62. package/dist/wasm-instance.js +88 -0
  63. package/dist/wasm-instance.js.map +1 -0
  64. package/generated/child-type-schema.d.ts +14 -0
  65. package/generated/child-type-schema.js +188 -0
  66. package/generated/node-types.d.ts +958 -0
  67. package/generated/position-fields.d.ts +21 -0
  68. package/generated/position-fields.js +50 -0
  69. package/generated/visitor-keys.d.ts +11 -0
  70. package/generated/visitor-keys.js +50 -0
  71. package/package.json +93 -10
  72. package/shim/sh-ast.wasm +0 -0
  73. package/shim/wasm_exec.js +654 -0
@@ -0,0 +1,21 @@
1
+ // Code generated by tools/gen-visitor-keys from mvdan.cc/sh/v3 v3.13.1. DO NOT EDIT.
2
+ // See design/ARCHITECTURE.md, "The schema table is generated, not hand-written".
3
+ /**
4
+ * `nodeType -> fieldName[]` for every field whose static Go type is
5
+ * `syntax.Pos` — a real position (byte offset + line + column), never
6
+ * child data. Keyed by the exact, unlowercased Go field name, matching
7
+ * typedjson's raw JSON keys (the same convention `CHILD_TYPE_SCHEMA`
8
+ * uses) — `normalize()`'s `buildFields` looks fields up here by the raw
9
+ * key it sees in `Object.entries(node)`, before lowercasing.
10
+ *
11
+ * Scoped per (nodeType, fieldName) rather than a single global set of
12
+ * bare names: mvdan/sh reuses field names across unrelated struct
13
+ * shapes (`Do`, `Dollar`, `Select`, `Until`, `Unsigned`, ...), and a
14
+ * bare-name denylist can't tell a real position apart from real data
15
+ * that merely happens to share a field name with one, in a different
16
+ * node type. See design/ARCHITECTURE.md, "The schema table is
17
+ * generated, not hand-written", and issue #8.
18
+ *
19
+ * @internal
20
+ */
21
+ export declare const POSITION_FIELDS: Record<string, string[]>;
@@ -0,0 +1,50 @@
1
+ // Code generated by tools/gen-visitor-keys from mvdan.cc/sh/v3 v3.13.1. DO NOT EDIT.
2
+ // See design/ARCHITECTURE.md, "The schema table is generated, not hand-written".
3
+ export const POSITION_FIELDS = {
4
+ ArithmCmd: ['Left', 'Right'],
5
+ ArithmExp: ['Left', 'Right'],
6
+ ArrayElem: [],
7
+ ArrayExpr: ['Lparen', 'Rparen'],
8
+ Assign: [],
9
+ BinaryArithm: ['OpPos'],
10
+ BinaryCmd: ['OpPos'],
11
+ BinaryTest: ['OpPos'],
12
+ Block: ['Lbrace', 'Rbrace'],
13
+ BraceExp: [],
14
+ CStyleLoop: ['Lparen', 'Rparen'],
15
+ CallExpr: [],
16
+ CaseClause: ['Case', 'Esac', 'In'],
17
+ CaseItem: ['OpPos'],
18
+ CmdSubst: ['Left', 'Right'],
19
+ Comment: ['Hash'],
20
+ CoprocClause: ['Coproc'],
21
+ DblQuoted: ['Left', 'Right'],
22
+ DeclClause: [],
23
+ Expansion: [],
24
+ ExtGlob: ['OpPos'],
25
+ File: [],
26
+ FlagsArithm: [],
27
+ ForClause: ['DoPos', 'DonePos', 'ForPos'],
28
+ FuncDecl: ['Position'],
29
+ IfClause: ['FiPos', 'Position', 'ThenPos'],
30
+ LetClause: ['Let'],
31
+ Lit: ['ValueEnd', 'ValuePos'],
32
+ ParamExp: ['Dollar', 'Rbrace'],
33
+ ParenArithm: ['Lparen', 'Rparen'],
34
+ ParenTest: ['Lparen', 'Rparen'],
35
+ ProcSubst: ['OpPos', 'Rparen'],
36
+ Redirect: ['OpPos'],
37
+ Replace: [],
38
+ SglQuoted: ['Left', 'Right'],
39
+ Slice: [],
40
+ Stmt: ['Position', 'Semicolon'],
41
+ Subshell: ['Lparen', 'Rparen'],
42
+ TestClause: ['Left', 'Right'],
43
+ TestDecl: ['Position'],
44
+ TimeClause: ['Time'],
45
+ UnaryArithm: ['OpPos'],
46
+ UnaryTest: ['OpPos'],
47
+ WhileClause: ['DoPos', 'DonePos', 'WhilePos'],
48
+ Word: [],
49
+ WordIter: ['InPos'],
50
+ };
@@ -0,0 +1,11 @@
1
+ // Code generated by tools/gen-visitor-keys from mvdan.cc/sh/v3 v3.13.1. DO NOT EDIT.
2
+ // See design/ARCHITECTURE.md, "The schema table is generated, not hand-written".
3
+ /**
4
+ * Per-node-type traversal keys (lowercased field names, matching the
5
+ * normalizer's output shape). See design/ARCHITECTURE.md, "The schema
6
+ * table is generated, not hand-written" — re-exported publicly via
7
+ * `src/visitor-keys.ts`.
8
+ *
9
+ * @internal
10
+ */
11
+ export declare const visitorKeys: Record<string, string[]>;
@@ -0,0 +1,50 @@
1
+ // Code generated by tools/gen-visitor-keys from mvdan.cc/sh/v3 v3.13.1. DO NOT EDIT.
2
+ // See design/ARCHITECTURE.md, "The schema table is generated, not hand-written".
3
+ export const visitorKeys = {
4
+ ArithmCmd: ['x'],
5
+ ArithmExp: ['x'],
6
+ ArrayElem: ['comments', 'index', 'value'],
7
+ ArrayExpr: ['elems', 'last'],
8
+ Assign: ['array', 'index', 'name', 'value'],
9
+ BinaryArithm: ['x', 'y'],
10
+ BinaryCmd: ['x', 'y'],
11
+ BinaryTest: ['x', 'y'],
12
+ Block: ['last', 'stmts'],
13
+ BraceExp: ['elems'],
14
+ CStyleLoop: ['cond', 'init', 'post'],
15
+ CallExpr: ['args', 'assigns'],
16
+ CaseClause: ['items', 'last', 'word'],
17
+ CaseItem: ['comments', 'last', 'patterns', 'stmts'],
18
+ CmdSubst: ['last', 'stmts'],
19
+ Comment: [],
20
+ CoprocClause: ['name', 'stmt'],
21
+ DblQuoted: ['parts'],
22
+ DeclClause: ['args', 'variant'],
23
+ Expansion: ['word'],
24
+ ExtGlob: ['pattern'],
25
+ File: ['last', 'stmts'],
26
+ FlagsArithm: ['flags', 'x'],
27
+ ForClause: ['do', 'dolast', 'loop'],
28
+ FuncDecl: ['body', 'name', 'names'],
29
+ IfClause: ['cond', 'condlast', 'else', 'last', 'then', 'thenlast'],
30
+ LetClause: ['exprs'],
31
+ Lit: [],
32
+ ParamExp: ['exp', 'flags', 'index', 'modifiers', 'nestedparam', 'param', 'repl', 'slice'],
33
+ ParenArithm: ['x'],
34
+ ParenTest: ['x'],
35
+ ProcSubst: ['last', 'stmts'],
36
+ Redirect: ['hdoc', 'n', 'word'],
37
+ Replace: ['orig', 'with'],
38
+ SglQuoted: [],
39
+ Slice: ['length', 'offset'],
40
+ Stmt: ['cmd', 'comments', 'redirs'],
41
+ Subshell: ['last', 'stmts'],
42
+ TestClause: ['x'],
43
+ TestDecl: ['body', 'description'],
44
+ TimeClause: ['stmt'],
45
+ UnaryArithm: ['x'],
46
+ UnaryTest: ['x'],
47
+ WhileClause: ['cond', 'condlast', 'do', 'dolast'],
48
+ Word: ['parts'],
49
+ WordIter: ['items', 'name'],
50
+ };
package/package.json CHANGED
@@ -1,13 +1,96 @@
1
1
  {
2
2
  "name": "sh-ast",
3
- "version": "0.0.0",
4
- "description": "",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
3
+ "description": "Synchronous shell-script parser (mvdan/sh via WASM) with a normalized, UTF-16-safe AST.",
4
+ "version": "0.1.0",
5
+ "author": "Mike North <michael.l.north@gmail.com>",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/mike-north/sh-ast.git",
9
+ "directory": "packages/sh-ast"
10
+ },
11
+ "homepage": "https://github.com/mike-north/sh-ast/tree/main/packages/sh-ast#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/mike-north/sh-ast/issues"
14
+ },
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/sh-ast.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./analyze": {
21
+ "types": "./dist/analyze.d.ts",
22
+ "default": "./dist/analyze/index.js"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "generated/*.js",
28
+ "generated/*.d.ts",
29
+ "shim/sh-ast.wasm",
30
+ "shim/wasm_exec.js"
31
+ ],
32
+ "license": "MIT",
33
+ "main": "./dist/index.js",
34
+ "nx": {
35
+ "targets": {
36
+ "build": {
37
+ "outputs": [
38
+ "{projectRoot}/dist/**/*.js",
39
+ "{projectRoot}/dist/**/*.js.map",
40
+ "{projectRoot}/dist/**/*.d.ts",
41
+ "{projectRoot}/dist/**/*.d.ts.map",
42
+ "!{projectRoot}/dist/sh-ast.d.ts",
43
+ "!{projectRoot}/dist/analyze.d.ts"
44
+ ]
45
+ },
46
+ "check:api-report": {
47
+ "outputs": [
48
+ "{projectRoot}/api-report",
49
+ "{projectRoot}/temp",
50
+ "{projectRoot}/dist/sh-ast.d.ts",
51
+ "{projectRoot}/dist/analyze.d.ts"
52
+ ]
53
+ },
54
+ "uplevel-api-reports": {
55
+ "dependsOn": [
56
+ "check:api-report"
57
+ ],
58
+ "cache": true,
59
+ "inputs": [
60
+ "{projectRoot}/api-report/**",
61
+ "{projectRoot}/temp/**"
62
+ ],
63
+ "outputs": [
64
+ "{workspaceRoot}/api-report-combined/sh-ast.api.md",
65
+ "{workspaceRoot}/api-docs-temp/sh-ast.api.json",
66
+ "{workspaceRoot}/api-report-combined/sh-ast-analyze.api.md",
67
+ "{workspaceRoot}/api-docs-temp/sh-ast-analyze.api.json"
68
+ ]
69
+ }
70
+ }
8
71
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "type": "commonjs"
13
- }
72
+ "publishConfig": {
73
+ "access": "public"
74
+ },
75
+ "tsd": {
76
+ "compilerOptions": {
77
+ "composite": false
78
+ }
79
+ },
80
+ "type": "module",
81
+ "types": "./dist/sh-ast.d.ts",
82
+ "scripts": {
83
+ "build": "tsc -p tsconfig.json",
84
+ "check": "concurrently -n lint,types,api-report \"pnpm run check:lint-ts\" \"pnpm run check:typecheck\" \"pnpm run check:api-report\"",
85
+ "check:api-report": "api-extractor run && api-extractor run --config analyze/api-extractor.json",
86
+ "check:lint-ts": "eslint .",
87
+ "check:typecheck": "tsc --noEmit",
88
+ "clean": "rimraf --glob dist \"temp/*\" \"*.tsbuildinfo\"",
89
+ "fix:api-report": "api-extractor run --local && api-extractor run --local --config analyze/api-extractor.json",
90
+ "fix:lint-ts": "eslint . --fix",
91
+ "test": "concurrently -n vitest,tsd \"pnpm run test:ts\" \"pnpm run test:types\"",
92
+ "test:ts": "vitest run",
93
+ "test:types": "tsd",
94
+ "uplevel-api-reports": "mkdir -p ../../api-report-combined ../../api-docs-temp && cp api-report/sh-ast.api.md api-report/sh-ast-analyze.api.md ../../api-report-combined/ && cp temp/sh-ast.api.json temp/sh-ast-analyze.api.json ../../api-docs-temp/"
95
+ }
96
+ }
Binary file