@danielblomma/cortex-mcp 1.3.2 → 1.4.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 (153) hide show
  1. package/README.md +62 -14
  2. package/package.json +2 -2
  3. package/scaffold/mcp/package-lock.json +3 -7
  4. package/scaffold/mcp/package.json +1 -1
  5. package/scaffold/scripts/dashboard.mjs +15 -1
  6. package/scaffold/scripts/ingest.mjs +323 -50
  7. package/scaffold/scripts/parsers/bash-treesitter.mjs +229 -0
  8. package/scaffold/scripts/parsers/cpp-dispatch.mjs +56 -0
  9. package/scaffold/scripts/parsers/cpp-treesitter.mjs +333 -0
  10. package/scaffold/scripts/parsers/csharp.mjs +197 -10
  11. package/scaffold/scripts/parsers/dotnet/CSharpParser/CSharpParser.csproj +1 -0
  12. package/scaffold/scripts/parsers/dotnet/CSharpParser/Program.cs +126 -21
  13. package/scaffold/scripts/parsers/go-treesitter.mjs +283 -0
  14. package/scaffold/scripts/parsers/java-treesitter.mjs +250 -0
  15. package/scaffold/scripts/parsers/javascript/ast.mjs +118 -12
  16. package/scaffold/scripts/parsers/javascript/chunks.mjs +4 -0
  17. package/scaffold/scripts/parsers/javascript/patterns.mjs +6 -0
  18. package/scaffold/scripts/parsers/javascript.mjs +4 -19
  19. package/scaffold/scripts/parsers/node_modules/.package-lock.json +57 -0
  20. package/scaffold/scripts/parsers/node_modules/acorn/CHANGELOG.md +972 -0
  21. package/scaffold/scripts/parsers/node_modules/acorn/LICENSE +21 -0
  22. package/scaffold/scripts/parsers/node_modules/acorn/README.md +301 -0
  23. package/scaffold/scripts/parsers/node_modules/acorn/bin/acorn +4 -0
  24. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.d.mts +883 -0
  25. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.d.ts +883 -0
  26. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.js +6295 -0
  27. package/scaffold/scripts/parsers/node_modules/acorn/dist/acorn.mjs +6266 -0
  28. package/scaffold/scripts/parsers/node_modules/acorn/dist/bin.js +90 -0
  29. package/scaffold/scripts/parsers/node_modules/acorn/package.json +50 -0
  30. package/scaffold/scripts/parsers/node_modules/acorn-typescript/CHANGELOG.md +421 -0
  31. package/scaffold/scripts/parsers/node_modules/acorn-typescript/LICENSE +21 -0
  32. package/scaffold/scripts/parsers/node_modules/acorn-typescript/README.md +81 -0
  33. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.d.ts +103 -0
  34. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.js +78 -0
  35. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/error.js.map +1 -0
  36. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.d.ts +167 -0
  37. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.js +75 -0
  38. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/decorators.js.map +1 -0
  39. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.d.ts +177 -0
  40. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.js +56 -0
  41. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/import-assertions.js.map +1 -0
  42. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.d.ts +198 -0
  43. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.js +327 -0
  44. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/index.js.map +1 -0
  45. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.d.ts +256 -0
  46. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.js +256 -0
  47. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/extentions/jsx/xhtml.js.map +1 -0
  48. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.d.ts +472 -0
  49. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.js +1 -0
  50. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.js.map +1 -0
  51. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/index.mjs +1 -0
  52. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.d.ts +159 -0
  53. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.js +2 -0
  54. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/middleware.js.map +1 -0
  55. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.d.ts +10 -0
  56. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.js +38 -0
  57. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/parseutil.js.map +1 -0
  58. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.d.ts +12 -0
  59. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.js +29 -0
  60. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/scopeflags.js.map +1 -0
  61. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.d.ts +2 -0
  62. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.js +118 -0
  63. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/tokenType.js.map +1 -0
  64. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.d.ts +60 -0
  65. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.js +2 -0
  66. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/types.js.map +1 -0
  67. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.d.ts +2 -0
  68. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.js +19 -0
  69. package/scaffold/scripts/parsers/node_modules/acorn-typescript/lib/whitespace.js.map +1 -0
  70. package/scaffold/scripts/parsers/node_modules/acorn-typescript/package.json +53 -0
  71. package/scaffold/scripts/parsers/node_modules/acorn-typescript/tsconfig.json +19 -0
  72. package/scaffold/scripts/parsers/node_modules/acorn-walk/CHANGELOG.md +209 -0
  73. package/scaffold/scripts/parsers/node_modules/acorn-walk/LICENSE +21 -0
  74. package/scaffold/scripts/parsers/node_modules/acorn-walk/README.md +124 -0
  75. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.d.mts +152 -0
  76. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.d.ts +152 -0
  77. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.js +485 -0
  78. package/scaffold/scripts/parsers/node_modules/acorn-walk/dist/walk.mjs +467 -0
  79. package/scaffold/scripts/parsers/node_modules/acorn-walk/package.json +50 -0
  80. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/LICENSE +24 -0
  81. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/README.md +23 -0
  82. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-bash.wasm +0 -0
  83. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-c.wasm +0 -0
  84. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-c_sharp.wasm +0 -0
  85. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-cpp.wasm +0 -0
  86. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-css.wasm +0 -0
  87. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-dart.wasm +0 -0
  88. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elisp.wasm +0 -0
  89. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elixir.wasm +0 -0
  90. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-elm.wasm +0 -0
  91. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-embedded_template.wasm +0 -0
  92. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-go.wasm +0 -0
  93. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-html.wasm +0 -0
  94. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-java.wasm +0 -0
  95. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-javascript.wasm +0 -0
  96. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-json.wasm +0 -0
  97. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-kotlin.wasm +0 -0
  98. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-lua.wasm +0 -0
  99. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-objc.wasm +0 -0
  100. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ocaml.wasm +0 -0
  101. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-php.wasm +0 -0
  102. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-python.wasm +0 -0
  103. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ql.wasm +0 -0
  104. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-rescript.wasm +0 -0
  105. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm +0 -0
  106. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-rust.wasm +0 -0
  107. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-scala.wasm +0 -0
  108. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-solidity.wasm +0 -0
  109. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-swift.wasm +0 -0
  110. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-systemrdl.wasm +0 -0
  111. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-tlaplus.wasm +0 -0
  112. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-toml.wasm +0 -0
  113. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-tsx.wasm +0 -0
  114. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-typescript.wasm +0 -0
  115. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-vue.wasm +0 -0
  116. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-yaml.wasm +0 -0
  117. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/out/tree-sitter-zig.wasm +0 -0
  118. package/scaffold/scripts/parsers/node_modules/tree-sitter-wasms/package.json +64 -0
  119. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/LICENSE +21 -0
  120. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/README.md +198 -0
  121. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/package.json +37 -0
  122. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter-web.d.ts +242 -0
  123. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter.js +1 -0
  124. package/scaffold/scripts/parsers/node_modules/web-tree-sitter/tree-sitter.wasm +0 -0
  125. package/scaffold/scripts/parsers/package-lock.json +19 -1
  126. package/scaffold/scripts/parsers/package.json +3 -1
  127. package/scaffold/scripts/parsers/python-treesitter.mjs +271 -0
  128. package/scaffold/scripts/parsers/ruby-treesitter.mjs +271 -0
  129. package/scaffold/scripts/parsers/rust-dispatch.mjs +43 -0
  130. package/scaffold/scripts/parsers/rust-treesitter.mjs +291 -0
  131. package/scaffold/scripts/parsers/tree-sitter/base.mjs +163 -0
  132. package/scaffold/scripts/parsers/tree-sitter/queries/bash.calls.scm +7 -0
  133. package/scaffold/scripts/parsers/tree-sitter/queries/bash.chunks.scm +6 -0
  134. package/scaffold/scripts/parsers/tree-sitter/queries/bash.imports.scm +5 -0
  135. package/scaffold/scripts/parsers/tree-sitter/queries/cpp.calls.scm +17 -0
  136. package/scaffold/scripts/parsers/tree-sitter/queries/cpp.chunks.scm +30 -0
  137. package/scaffold/scripts/parsers/tree-sitter/queries/cpp.imports.scm +6 -0
  138. package/scaffold/scripts/parsers/tree-sitter/queries/go.calls.scm +11 -0
  139. package/scaffold/scripts/parsers/tree-sitter/queries/go.chunks.scm +19 -0
  140. package/scaffold/scripts/parsers/tree-sitter/queries/go.imports.scm +6 -0
  141. package/scaffold/scripts/parsers/tree-sitter/queries/java.calls.scm +6 -0
  142. package/scaffold/scripts/parsers/tree-sitter/queries/java.chunks.scm +23 -0
  143. package/scaffold/scripts/parsers/tree-sitter/queries/java.imports.scm +6 -0
  144. package/scaffold/scripts/parsers/tree-sitter/queries/python.calls.scm +11 -0
  145. package/scaffold/scripts/parsers/tree-sitter/queries/python.chunks.scm +11 -0
  146. package/scaffold/scripts/parsers/tree-sitter/queries/python.imports.scm +13 -0
  147. package/scaffold/scripts/parsers/tree-sitter/queries/ruby.calls.scm +6 -0
  148. package/scaffold/scripts/parsers/tree-sitter/queries/ruby.chunks.scm +16 -0
  149. package/scaffold/scripts/parsers/tree-sitter/queries/ruby.imports.scm +8 -0
  150. package/scaffold/scripts/parsers/tree-sitter/queries/rust.calls.scm +31 -0
  151. package/scaffold/scripts/parsers/tree-sitter/queries/rust.chunks.scm +29 -0
  152. package/scaffold/scripts/parsers/tree-sitter/queries/rust.imports.scm +5 -0
  153. package/scaffold/scripts/parsers/vb6.mjs +395 -0
@@ -0,0 +1,118 @@
1
+ // @ts-ignore
2
+ import { TokenType, keywordTypes, tokTypes, TokContext } from 'acorn';
3
+ const startsExpr = true;
4
+ // Succinct definitions of keyword token types
5
+ function kwLike(_name, options = {}) {
6
+ return new TokenType('name', options);
7
+ }
8
+ const acornTypeScriptMap = new WeakMap();
9
+ export function generateAcornTypeScript(_acorn) {
10
+ const acorn = _acorn.Parser.acorn || _acorn;
11
+ let acornTypeScript = acornTypeScriptMap.get(acorn);
12
+ if (!acornTypeScript) {
13
+ const tsKwTokenType = generateTsKwTokenType();
14
+ const tsTokenType = generateTsTokenType();
15
+ const tsTokenContext = generateTsTokenContext();
16
+ const tsKeywordsRegExp = new RegExp(`^(?:${Object.keys(tsKwTokenType).join('|')})$`);
17
+ tsTokenType.jsxTagStart.updateContext = function () {
18
+ this.context.push(tsTokenContext.tc_expr); // treat as beginning of
19
+ // JSX expression
20
+ this.context.push(tsTokenContext.tc_oTag); // start opening tag context
21
+ this.exprAllowed = false;
22
+ };
23
+ tsTokenType.jsxTagEnd.updateContext = function (prevType) {
24
+ let out = this.context.pop();
25
+ if (out === tsTokenContext.tc_oTag && prevType === tokTypes.slash || out === tsTokenContext.tc_cTag) {
26
+ this.context.pop();
27
+ this.exprAllowed = this.curContext() === tsTokenContext.tc_expr;
28
+ }
29
+ else {
30
+ this.exprAllowed = true;
31
+ }
32
+ };
33
+ function tokenIsLiteralPropertyName(token) {
34
+ return [
35
+ ...[tokTypes.name, tokTypes.string, tokTypes.num],
36
+ ...Object.values(keywordTypes),
37
+ ...Object.values(tsKwTokenType)
38
+ ].includes(token);
39
+ }
40
+ function tokenIsKeywordOrIdentifier(token) {
41
+ return [
42
+ ...[tokTypes.name],
43
+ ...Object.values(keywordTypes),
44
+ ...Object.values(tsKwTokenType)
45
+ ].includes(token);
46
+ }
47
+ function tokenIsIdentifier(token) {
48
+ return [...Object.values(tsKwTokenType), tokTypes.name].includes(token);
49
+ }
50
+ function tokenIsTSDeclarationStart(token) {
51
+ return [
52
+ tsKwTokenType.abstract,
53
+ tsKwTokenType.declare,
54
+ tsKwTokenType.enum,
55
+ tsKwTokenType.module,
56
+ tsKwTokenType.namespace,
57
+ tsKwTokenType.interface,
58
+ tsKwTokenType.type
59
+ ].includes(token);
60
+ }
61
+ function tokenIsTSTypeOperator(token) {
62
+ return [
63
+ tsKwTokenType.keyof,
64
+ tsKwTokenType.readonly,
65
+ tsKwTokenType.unique
66
+ ].includes(token);
67
+ }
68
+ function tokenIsTemplate(token) {
69
+ return token === tokTypes.invalidTemplate;
70
+ }
71
+ acornTypeScript = {
72
+ tokTypes: Object.assign(Object.assign({}, tsKwTokenType), tsTokenType),
73
+ tokContexts: Object.assign({}, tsTokenContext),
74
+ keywordsRegExp: tsKeywordsRegExp,
75
+ tokenIsLiteralPropertyName,
76
+ tokenIsKeywordOrIdentifier,
77
+ tokenIsIdentifier,
78
+ tokenIsTSDeclarationStart,
79
+ tokenIsTSTypeOperator,
80
+ tokenIsTemplate
81
+ };
82
+ }
83
+ return acornTypeScript;
84
+ }
85
+ function generateTsTokenContext() {
86
+ return {
87
+ tc_oTag: new TokContext('<tag', false, false),
88
+ tc_cTag: new TokContext('</tag', false, false),
89
+ tc_expr: new TokContext('<tag>...</tag>', true, true)
90
+ };
91
+ }
92
+ function generateTsTokenType() {
93
+ return {
94
+ at: new TokenType('@'),
95
+ jsxName: new TokenType('jsxName'),
96
+ jsxText: new TokenType('jsxText', { beforeExpr: true }),
97
+ jsxTagStart: new TokenType('jsxTagStart', { startsExpr: true }),
98
+ jsxTagEnd: new TokenType('jsxTagEnd')
99
+ };
100
+ }
101
+ function generateTsKwTokenType() {
102
+ return {
103
+ assert: kwLike('assert', { startsExpr }),
104
+ asserts: kwLike('asserts', { startsExpr }),
105
+ global: kwLike('global', { startsExpr }),
106
+ keyof: kwLike('keyof', { startsExpr }),
107
+ readonly: kwLike('readonly', { startsExpr }),
108
+ unique: kwLike('unique', { startsExpr }),
109
+ abstract: kwLike('abstract', { startsExpr }),
110
+ declare: kwLike('declare', { startsExpr }),
111
+ enum: kwLike('enum', { startsExpr }),
112
+ module: kwLike('module', { startsExpr }),
113
+ namespace: kwLike('namespace', { startsExpr }),
114
+ interface: kwLike('interface', { startsExpr }),
115
+ type: kwLike('type', { startsExpr })
116
+ };
117
+ }
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a,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC;QAC/D,SAAS,EAAE,IAAI,SAAS,CAAC,WAAW,CAAC;KACtC,CAAA;AACH,CAAC;AAED,SAAS,qBAAqB;IAC5B,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC;QACxC,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC;QAC1C,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC;QACxC,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,CAAC;QACtC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC;QAC5C,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC;QACxC,QAAQ,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,UAAU,EAAE,CAAC;QAC5C,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,EAAE,UAAU,EAAE,CAAC;QAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC;QACpC,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE,EAAE,UAAU,EAAE,CAAC;QACxC,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;QAC9C,SAAS,EAAE,MAAM,CAAC,WAAW,EAAE,EAAE,UAAU,EAAE,CAAC;QAC9C,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC;KACrC,CAAA;AACH,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { Position, TokContext, TokenType } from 'acorn';
2
+ export declare type Accessibility = 'public' | 'protected' | 'private';
3
+ export declare type VarianceAnnotations = 'in' | 'out';
4
+ export declare type ClassAccessor = 'accessor';
5
+ export declare type TsModifier = 'readonly' | 'abstract' | 'declare' | 'static' | 'override' | Accessibility | VarianceAnnotations | ClassAccessor;
6
+ export declare type LookaheadState = {
7
+ pos: number;
8
+ value: any;
9
+ type: TokenType;
10
+ start: number;
11
+ end: number;
12
+ context: TokContext[];
13
+ startLoc: any;
14
+ endLoc: any;
15
+ lastTokEndLoc: any;
16
+ lastTokStartLoc: any;
17
+ lastTokStart: any;
18
+ lastTokEnd: any;
19
+ curLine: number;
20
+ lineStart: number;
21
+ curPosition: () => Position;
22
+ containsEsc: boolean;
23
+ };
24
+ export declare type ParsingContext = 'EnumMembers' | 'HeritageClauseElement' | 'TupleElementTypes' | 'TypeMembers' | 'TypeParametersOrArguments';
25
+ export declare type ModifierBase = {
26
+ accessibility?: Accessibility;
27
+ } & {
28
+ [key in TsModifier]?: boolean | undefined | null;
29
+ };
30
+ export declare type TryParse<Node, Error, Thrown, Aborted, FailState> = {
31
+ node: Node;
32
+ error: Error;
33
+ thrown: Thrown;
34
+ aborted: Aborted;
35
+ failState: FailState;
36
+ };
37
+ export declare type AcornTypeScript = {
38
+ tokTypes: Record<string, TokenType>;
39
+ tokContexts: Record<string, TokenType>;
40
+ keywordsRegExp: RegExp;
41
+ tokenIsLiteralPropertyName(token: TokenType): boolean;
42
+ tokenIsKeywordOrIdentifier(token: TokenType): boolean;
43
+ tokenIsIdentifier(token: TokenType): boolean;
44
+ tokenIsTSDeclarationStart(token: TokenType): boolean;
45
+ tokenIsTSTypeOperator(token: TokenType): boolean;
46
+ tokenIsTemplate(token: TokenType): boolean;
47
+ };
48
+ export declare type AcornJsx = {
49
+ tokTypes: {
50
+ jsxName: TokenType;
51
+ jsxText: TokenType;
52
+ jsxTagEnd: TokenType;
53
+ jsxTagStart: TokenType;
54
+ };
55
+ tokContexts: {
56
+ tc_oTag: TokContext;
57
+ tc_cTag: TokContext;
58
+ tc_expr: TokContext;
59
+ };
60
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const skipWhiteSpaceInLine: RegExp;
2
+ export declare const skipWhiteSpaceToLineBreak: RegExp;
@@ -0,0 +1,19 @@
1
+ export const skipWhiteSpaceInLine = /(?:[^\S\n\r\u2028\u2029]|\/\/.*|\/\*.*?\*\/)*/y;
2
+ // Skip whitespace and single-line comments, including /* no newline here */.
3
+ // After this RegExp matches, its lastIndex points to a line terminator, or
4
+ // the start of multi-line comment (which is effectively a line terminator),
5
+ // or the end of string.
6
+ export const skipWhiteSpaceToLineBreak = new RegExp(
7
+ // Unfortunately JS doesn't support Perl's atomic /(?>pattern)/ or
8
+ // possessive quantifiers, so we use a trick to prevent backtracking
9
+ // when the look-ahead for line terminator fails.
10
+ '(?=(' +
11
+ // Capture the whitespace and comments that should be skipped inside
12
+ // a look-ahead assertion, and then re-match the group as a unit.
13
+ skipWhiteSpaceInLine.source +
14
+ '))\\1' +
15
+ // Look-ahead for either line terminator, start of multi-line comment,
16
+ // or end of string.
17
+ /(?=[\n\r\u2028\u2029]|\/\*(?!.*?\*\/)|$)/.source, 'y' // sticky
18
+ );
19
+ //# sourceMappingURL=whitespace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whitespace.js","sourceRoot":"","sources":["../src/whitespace.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAC/B,gDAAgD,CAAA;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,4EAA4E;AAC5E,wBAAwB;AACxB,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,MAAM;AACjD,kEAAkE;AAClE,oEAAoE;AACpE,iDAAiD;AACjD,MAAM;IACN,oEAAoE;IACpE,iEAAiE;IACjE,oBAAoB,CAAC,MAAM;IAC3B,OAAO;IACP,sEAAsE;IACtE,oBAAoB;IACpB,0CAA0C,CAAC,MAAM,EACjD,GAAG,CAAC,SAAS;CACd,CAAA"}
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "acorn-typescript",
3
+ "version": "1.4.13",
4
+ "description": "Alternative, TypeScript parser",
5
+ "source": "src/index.ts",
6
+ "main": "lib/index.js",
7
+ "module": "lib/index.mjs",
8
+ "types": "lib/index.d.ts",
9
+ "scripts": {
10
+ "build": "microbundle --define process.env.NODE_ENV=production --no-sourcemap --tsconfig ./tsconfig.json --format esm,cjs",
11
+ "test": "jest --collect-coverage --silent",
12
+ "test:test262": "ts-node -T __test__/run_test262.ts",
13
+ "release-major": "yarn build && yarn test && standard-version --release-as major",
14
+ "release-minor": "yarn build && yarn test && standard-version --release-as minor",
15
+ "release-patch": "yarn build && yarn test && standard-version --release-as patch"
16
+ },
17
+ "exports": {
18
+ ".": [
19
+ {
20
+ "import": "./lib/index.mjs",
21
+ "require": "./lib/index.js",
22
+ "default": "./lib/index.js"
23
+ },
24
+ "./lib/index.js"
25
+ ]
26
+ },
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/TyrealHu/acorn-typescript.git"
30
+ },
31
+ "author": "tyrealhu",
32
+ "license": "MIT",
33
+ "bugs": {
34
+ "url": "https://github.com/TyrealHu/acorn-typescript/issues"
35
+ },
36
+ "homepage": "https://github.com/TyrealHu/acorn-typescript#readme",
37
+ "devDependencies": {
38
+ "@types/jest": "^24.1.0",
39
+ "acorn": "^8.9.0",
40
+ "acorn-jsx": "^5.3.2",
41
+ "jest": "^24.1.0",
42
+ "microbundle": "^0.15.1",
43
+ "standard-version": "^9.5.0",
44
+ "ts-jest": "^26.0.0",
45
+ "ts-node": "^10.9.1",
46
+ "typescript": "^4.8.4",
47
+ "test262": "git+https://github.com/tc39/test262.git#dac69563480b9f22709fd49d61a32b3a0513b6b1",
48
+ "test262-parser-runner": "^0.5.0"
49
+ },
50
+ "peerDependencies": {
51
+ "acorn": ">=8.9.0"
52
+ }
53
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": false,
4
+ "target": "es6",
5
+ "allowSyntheticDefaultImports": true,
6
+ "moduleResolution": "node",
7
+ "outDir": "lib",
8
+ "experimentalDecorators": true,
9
+ "lib": ["es2017", "dom"],
10
+ "noUnusedLocals": true,
11
+ "noUnusedParameters": true,
12
+ "preserveConstEnums": true,
13
+ "removeComments": false,
14
+ "sourceMap": true,
15
+ "strict": false
16
+ },
17
+ "include": ["./src/*", "./types/*"],
18
+ "exclude": ["node_modules", "lib"]
19
+ }
@@ -0,0 +1,209 @@
1
+ ## 8.3.5 (2026-02-19)
2
+
3
+ ### Bug fixes
4
+
5
+ Emit a more informative error message when trying to walk a node type that has no walker function.
6
+
7
+ Specify callbacks in types to receive `AnyNode` type, so that they can be narrowed more easily.
8
+
9
+ Support import attributes.
10
+
11
+ ## 8.3.4 (2024-09-09)
12
+
13
+ ### Bug fixes
14
+
15
+ Walk SwitchCase nodes as separate nodes.
16
+
17
+ ## 8.3.3 (2024-01-11)
18
+
19
+ ### Bug fixes
20
+
21
+ Make acorn a dependency because acorn-walk uses the types from that package.
22
+
23
+ ## 8.3.2 (2024-01-11)
24
+
25
+ ### Bug fixes
26
+
27
+ Add missing type for `findNodeBefore`.
28
+
29
+ ## 8.3.1 (2023-12-06)
30
+
31
+ ### Bug fixes
32
+
33
+ Add `Function` and `Class` to the `AggregateType` type, so that they can be used in walkers without raising a type error.
34
+
35
+ Visitor functions are now called in such a way that their `this` refers to the object they are part of.
36
+
37
+ ## 8.3.0 (2023-10-26)
38
+
39
+ ### New features
40
+
41
+ Use a set of new, much more precise, TypeScript types.
42
+
43
+ ## 8.2.0 (2021-09-06)
44
+
45
+ ### New features
46
+
47
+ Add support for walking ES2022 class static blocks.
48
+
49
+ ## 8.1.1 (2021-06-29)
50
+
51
+ ### Bug fixes
52
+
53
+ Include `base` in the type declarations.
54
+
55
+ ## 8.1.0 (2021-04-24)
56
+
57
+ ### New features
58
+
59
+ Support node types for class fields and private methods.
60
+
61
+ ## 8.0.2 (2021-01-25)
62
+
63
+ ### Bug fixes
64
+
65
+ Adjust package.json to work with Node 12.16.0 and 13.0-13.6.
66
+
67
+ ## 8.0.0 (2021-01-05)
68
+
69
+ ### Bug fixes
70
+
71
+ Fix a bug where `full` and `fullAncestor` would skip nodes with overridden types.
72
+
73
+ ## 8.0.0 (2020-08-12)
74
+
75
+ ### New features
76
+
77
+ The package can now be loaded directly as an ECMAScript module in node 13+.
78
+
79
+ ## 7.2.0 (2020-06-17)
80
+
81
+ ### New features
82
+
83
+ Support optional chaining and nullish coalescing.
84
+
85
+ Support `import.meta`.
86
+
87
+ Add support for `export * as ns from "source"`.
88
+
89
+ ## 7.1.1 (2020-02-13)
90
+
91
+ ### Bug fixes
92
+
93
+ Clean up the type definitions to actually work well with the main parser.
94
+
95
+ ## 7.1.0 (2020-02-11)
96
+
97
+ ### New features
98
+
99
+ Add a TypeScript definition file for the library.
100
+
101
+ ## 7.0.0 (2017-08-12)
102
+
103
+ ### New features
104
+
105
+ Support walking `ImportExpression` nodes.
106
+
107
+ ## 6.2.0 (2017-07-04)
108
+
109
+ ### New features
110
+
111
+ Add support for `Import` nodes.
112
+
113
+ ## 6.1.0 (2018-09-28)
114
+
115
+ ### New features
116
+
117
+ The walker now walks `TemplateElement` nodes.
118
+
119
+ ## 6.0.1 (2018-09-14)
120
+
121
+ ### Bug fixes
122
+
123
+ Fix bad "main" field in package.json.
124
+
125
+ ## 6.0.0 (2018-09-14)
126
+
127
+ ### Breaking changes
128
+
129
+ This is now a separate package, `acorn-walk`, rather than part of the main `acorn` package.
130
+
131
+ The `ScopeBody` and `ScopeExpression` meta-node-types are no longer supported.
132
+
133
+ ## 5.7.1 (2018-06-15)
134
+
135
+ ### Bug fixes
136
+
137
+ Make sure the walker and bin files are rebuilt on release (the previous release didn't get the up-to-date versions).
138
+
139
+ ## 5.7.0 (2018-06-15)
140
+
141
+ ### Bug fixes
142
+
143
+ Fix crash in walker when walking a binding-less catch node.
144
+
145
+ ## 5.6.2 (2018-06-05)
146
+
147
+ ### Bug fixes
148
+
149
+ In the walker, go back to allowing the `baseVisitor` argument to be null to default to the default base everywhere.
150
+
151
+ ## 5.6.1 (2018-06-01)
152
+
153
+ ### Bug fixes
154
+
155
+ Fix regression when passing `null` as fourth argument to `walk.recursive`.
156
+
157
+ ## 5.6.0 (2018-05-31)
158
+
159
+ ### Bug fixes
160
+
161
+ Fix a bug in the walker that caused a crash when walking an object pattern spread.
162
+
163
+ ## 5.5.1 (2018-03-06)
164
+
165
+ ### Bug fixes
166
+
167
+ Fix regression in walker causing property values in object patterns to be walked as expressions.
168
+
169
+ ## 5.5.0 (2018-02-27)
170
+
171
+ ### Bug fixes
172
+
173
+ Support object spread in the AST walker.
174
+
175
+ ## 5.4.1 (2018-02-02)
176
+
177
+ ### Bug fixes
178
+
179
+ 5.4.0 somehow accidentally included an old version of walk.js.
180
+
181
+ ## 5.2.0 (2017-10-30)
182
+
183
+ ### Bug fixes
184
+
185
+ The `full` and `fullAncestor` walkers no longer visit nodes multiple times.
186
+
187
+ ## 5.1.0 (2017-07-05)
188
+
189
+ ### New features
190
+
191
+ New walker functions `full` and `fullAncestor`.
192
+
193
+ ## 3.2.0 (2016-06-07)
194
+
195
+ ### New features
196
+
197
+ Make it possible to use `visit.ancestor` with a walk state.
198
+
199
+ ## 3.1.0 (2016-04-18)
200
+
201
+ ### New features
202
+
203
+ The walker now allows defining handlers for `CatchClause` nodes.
204
+
205
+ ## 2.5.2 (2015-10-27)
206
+
207
+ ### Fixes
208
+
209
+ Fix bug where the walker walked an exported `let` statement as an expression.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2012-2020 by various contributors (see AUTHORS)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,124 @@
1
+ # Acorn AST walker
2
+
3
+ An abstract syntax tree walker for the
4
+ [ESTree](https://github.com/estree/estree) format.
5
+
6
+ ## Community
7
+
8
+ Acorn is open source software released under an
9
+ [MIT license](https://github.com/acornjs/acorn/blob/master/acorn-walk/LICENSE).
10
+
11
+ You are welcome to
12
+ [report bugs](https://github.com/acornjs/acorn/issues) or create pull
13
+ requests on [github](https://github.com/acornjs/acorn).
14
+
15
+ ## Installation
16
+
17
+ The easiest way to install acorn is from [`npm`](https://www.npmjs.com/):
18
+
19
+ ```sh
20
+ npm install acorn-walk
21
+ ```
22
+
23
+ Alternately, you can download the source and build acorn yourself:
24
+
25
+ ```sh
26
+ git clone https://github.com/acornjs/acorn.git
27
+ cd acorn
28
+ npm install
29
+ ```
30
+
31
+ ## Interface
32
+
33
+ An algorithm for recursing through a syntax tree is stored as an
34
+ object, with a property for each tree node type holding a function
35
+ that will recurse through such a node. There are several ways to run
36
+ such a walker.
37
+
38
+ **simple**`(node, visitors, base, state)` does a 'simple' walk over a
39
+ tree. `node` should be the AST node to walk, and `visitors` an object
40
+ with properties whose names correspond to node types in the [ESTree
41
+ spec](https://github.com/estree/estree). The properties should contain
42
+ functions that will be called with the node object and, if applicable
43
+ the state at that point. The last two arguments are optional. `base`
44
+ is a walker algorithm, and `state` is a start state. The default
45
+ walker will simply visit all statements and expressions and not
46
+ produce a meaningful state. (An example of a use of state is to track
47
+ scope at each point in the tree.)
48
+
49
+ ```js
50
+ import * as acorn from "acorn"
51
+ import * as walk from "acorn-walk"
52
+
53
+ walk.simple(acorn.parse("let x = 10"), {
54
+ Literal(node) {
55
+ console.log(`Found a literal: ${node.value}`)
56
+ }
57
+ })
58
+ ```
59
+
60
+ **ancestor**`(node, visitors, base, state)` does a 'simple' walk over
61
+ a tree, building up an array of ancestor nodes (including the current node)
62
+ and passing the array to the callbacks as a third parameter.
63
+
64
+ ```js
65
+ import * as acorn from "acorn"
66
+ import * as walk from "acorn-walk"
67
+
68
+ walk.ancestor(acorn.parse("foo('hi')"), {
69
+ Literal(_node, _state, ancestors) {
70
+ console.log("This literal's ancestors are:", ancestors.map(n => n.type))
71
+ }
72
+ })
73
+ ```
74
+
75
+ **recursive**`(node, state, functions, base)` does a 'recursive'
76
+ walk, where the walker functions are responsible for continuing the
77
+ walk on the child nodes of their target node. `state` is the start
78
+ state, and `functions` should contain an object that maps node types
79
+ to walker functions. Such functions are called with `(node, state, c)`
80
+ arguments, and can cause the walk to continue on a sub-node by calling
81
+ the `c` argument on it with `(node, state)` arguments. The optional
82
+ `base` argument provides the fallback walker functions for node types
83
+ that aren't handled in the `functions` object. If not given, the
84
+ default walkers will be used.
85
+
86
+ **make**`(functions, base)` builds a new walker object by using the
87
+ walker functions in `functions` and filling in the missing ones by
88
+ taking defaults from `base`.
89
+
90
+ **full**`(node, callback, base, state)` does a 'full' walk over a
91
+ tree, calling the callback with the arguments (node, state, type) for
92
+ each node
93
+
94
+ **fullAncestor**`(node, callback, base, state)` does a 'full' walk
95
+ over a tree, building up an array of ancestor nodes (including the
96
+ current node) and passing the array to the callbacks as a third
97
+ parameter.
98
+
99
+ ```js
100
+ import * as acorn from "acorn"
101
+ import * as walk from "acorn-walk"
102
+
103
+ walk.full(acorn.parse("1 + 1"), node => {
104
+ console.log(`There's a ${node.type} node at ${node.ch}`)
105
+ })
106
+ ```
107
+
108
+ **findNodeAt**`(node, start, end, test, base, state)` tries to locate
109
+ a node in a tree at the given start and/or end offsets, which
110
+ satisfies the predicate `test`. `start` and `end` can be either `null`
111
+ (as wildcard) or a number. `test` may be a string (indicating a node
112
+ type) or a function that takes `(nodeType, node)` arguments and
113
+ returns a boolean indicating whether this node is interesting. `base`
114
+ and `state` are optional, and can be used to specify a custom walker.
115
+ Nodes are tested from inner to outer, so if two nodes match the
116
+ boundaries, the inner one will be preferred.
117
+
118
+ **findNodeAround**`(node, pos, test, base, state)` is a lot like
119
+ `findNodeAt`, but will match any node that exists 'around' (spanning)
120
+ the given position.
121
+
122
+ **findNodeAfter**`(node, pos, test, base, state)` is similar to
123
+ `findNodeAround`, but will match all nodes *after* the given position
124
+ (testing outer nodes before inner nodes).