@mnemonik/shared 7.143.0 → 7.144.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.
- package/dist/ast/astChunker.d.ts.map +1 -1
- package/dist/ast/astChunker.js +6 -1
- package/dist/ast/astChunker.js.map +1 -1
- package/dist/ast/grammars.d.ts +4 -2
- package/dist/ast/grammars.d.ts.map +1 -1
- package/dist/ast/grammars.js +37 -0
- package/dist/ast/grammars.js.map +1 -1
- package/dist/codeScanner.d.ts +3 -0
- package/dist/codeScanner.d.ts.map +1 -1
- package/dist/codeScanner.js +7 -0
- package/dist/codeScanner.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/sourceRedaction.d.ts.map +1 -1
- package/dist/sourceRedaction.js +667 -37
- package/dist/sourceRedaction.js.map +1 -1
- package/dist/vueSource.d.ts +17 -0
- package/dist/vueSource.d.ts.map +1 -0
- package/dist/vueSource.js +63 -0
- package/dist/vueSource.js.map +1 -0
- package/package.json +3 -1
- package/queries/cmake.tags.scm +6 -0
- package/queries/nix.tags.scm +4 -0
- package/queries/objcpp.tags.scm +4 -0
- package/queries/terraform.tags.scm +8 -0
- package/scripts/vendor-grammars.ts +468 -40
- package/src/ast/astChunker.ts +10 -1
- package/src/ast/grammars.ts +34 -1
- package/src/codeScanner.ts +6 -0
- package/src/index.ts +5 -0
- package/src/sourceRedaction.ts +726 -37
- package/src/vueSource.ts +77 -0
- package/wasm/bash.wasm +0 -0
- package/wasm/cmake.LICENSE +21 -0
- package/wasm/cmake.tags.scm +6 -0
- package/wasm/cmake.wasm +0 -0
- package/wasm/cpp.LICENSE +21 -0
- package/wasm/cpp.wasm +0 -0
- package/wasm/groovy.LICENSE +25 -0
- package/wasm/groovy.wasm +0 -0
- package/wasm/nix.LICENSE +21 -0
- package/wasm/nix.tags.scm +4 -0
- package/wasm/nix.wasm +0 -0
- package/wasm/objcpp.LICENSE +28 -0
- package/wasm/objcpp.tags.scm +4 -0
- package/wasm/objcpp.wasm +0 -0
- package/wasm/sql.wasm +0 -0
- package/wasm/terraform.LICENSE +201 -0
- package/wasm/terraform.tags.scm +8 -0
- package/wasm/terraform.wasm +0 -0
- package/wasm/tsx.wasm +0 -0
- package/wasm/typescript.wasm +0 -0
package/src/ast/grammars.ts
CHANGED
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
import { existsSync, readFileSync, statSync } from 'node:fs';
|
|
34
34
|
import { dirname, extname, join } from 'node:path';
|
|
35
35
|
import { fileURLToPath } from 'node:url';
|
|
36
|
-
import { Language, Parser, Query } from 'web-tree-sitter';
|
|
36
|
+
import { Language, Parser, Query, type Node } from 'web-tree-sitter';
|
|
37
37
|
import { warn } from '../logger.js';
|
|
38
38
|
|
|
39
39
|
const AST_LANGUAGE_ID_LIST = [
|
|
@@ -45,6 +45,7 @@ const AST_LANGUAGE_ID_LIST = [
|
|
|
45
45
|
'java',
|
|
46
46
|
'c',
|
|
47
47
|
'cpp',
|
|
48
|
+
'objcpp',
|
|
48
49
|
'csharp',
|
|
49
50
|
'ruby',
|
|
50
51
|
'php',
|
|
@@ -58,6 +59,9 @@ const AST_LANGUAGE_ID_LIST = [
|
|
|
58
59
|
'swift',
|
|
59
60
|
'sql',
|
|
60
61
|
'lua',
|
|
62
|
+
'terraform',
|
|
63
|
+
'nix',
|
|
64
|
+
'cmake',
|
|
61
65
|
] as const;
|
|
62
66
|
|
|
63
67
|
/** A language this build can AST-parse. Exactly the vendored set, no aspirations. */
|
|
@@ -116,6 +120,7 @@ export const QUERY_CHAIN: Readonly<Record<AstLanguageId, readonly AstLanguageId[
|
|
|
116
120
|
java: ['java'],
|
|
117
121
|
c: ['c'],
|
|
118
122
|
cpp: ['c', 'cpp'],
|
|
123
|
+
objcpp: ['objcpp'],
|
|
119
124
|
csharp: ['csharp'],
|
|
120
125
|
ruby: ['ruby'],
|
|
121
126
|
php: ['php'],
|
|
@@ -129,6 +134,9 @@ export const QUERY_CHAIN: Readonly<Record<AstLanguageId, readonly AstLanguageId[
|
|
|
129
134
|
swift: ['swift'],
|
|
130
135
|
sql: ['sql'],
|
|
131
136
|
lua: ['lua'],
|
|
137
|
+
terraform: ['terraform'],
|
|
138
|
+
nix: ['nix'],
|
|
139
|
+
cmake: ['cmake'],
|
|
132
140
|
};
|
|
133
141
|
|
|
134
142
|
/**
|
|
@@ -141,8 +149,30 @@ export const QUERY_CHAIN: Readonly<Record<AstLanguageId, readonly AstLanguageId[
|
|
|
141
149
|
*/
|
|
142
150
|
const EXTENSION_GRAMMARS: Readonly<Record<string, AstLanguageId>> = {
|
|
143
151
|
'.tsx': 'tsx',
|
|
152
|
+
'.m': 'objcpp',
|
|
153
|
+
'.mm': 'objcpp',
|
|
144
154
|
};
|
|
145
155
|
|
|
156
|
+
/** Upstream permits a bodyless else for highlighting across preprocessor boundaries. */
|
|
157
|
+
export function objcppSyntaxIssue(root: Node): string | null {
|
|
158
|
+
if (root.hasError) return 'Objective-C++ contains ERROR or MISSING nodes';
|
|
159
|
+
const cursor = root.walk();
|
|
160
|
+
try {
|
|
161
|
+
for (;;) {
|
|
162
|
+
const node = cursor.currentNode;
|
|
163
|
+
if (node.type === 'else_clause' && node.namedChildCount === 0)
|
|
164
|
+
return 'Objective-C++ else clause has no body; conditional-source recovery is not admitted';
|
|
165
|
+
if (cursor.gotoFirstChild()) continue;
|
|
166
|
+
for (;;) {
|
|
167
|
+
if (cursor.gotoNextSibling()) break;
|
|
168
|
+
if (!cursor.gotoParent()) return null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} finally {
|
|
172
|
+
cursor.delete();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
146
176
|
/**
|
|
147
177
|
* Scanner language string -> grammar. Keyed on what `languageForExtension`
|
|
148
178
|
* actually returns, so this table and the extension table cannot disagree about
|
|
@@ -175,6 +205,9 @@ const LANGUAGE_GRAMMARS: Readonly<Record<string, AstLanguageId>> = {
|
|
|
175
205
|
swift: 'swift',
|
|
176
206
|
sql: 'sql',
|
|
177
207
|
lua: 'lua',
|
|
208
|
+
terraform: 'terraform',
|
|
209
|
+
nix: 'nix',
|
|
210
|
+
cmake: 'cmake',
|
|
178
211
|
};
|
|
179
212
|
|
|
180
213
|
/** A loaded grammar plus its compiled query. Compiled once, reused per file. */
|
package/src/codeScanner.ts
CHANGED
|
@@ -532,6 +532,7 @@ const EXTENSION_LANGUAGES: Readonly<Record<string, string>> = {
|
|
|
532
532
|
* preference) need the same answer without constructing a scanner.
|
|
533
533
|
*/
|
|
534
534
|
export function languageForExtension(filePathOrExt: string): string {
|
|
535
|
+
if (isCmakeListsPath(filePathOrExt)) return 'cmake';
|
|
535
536
|
// `extname` FIRST. A dotfile that carries a real extension ('.eslintrc.js',
|
|
536
537
|
// '.mocharc.cjs', '.prettierrc.ts') starts with '.' and contains no '/', so
|
|
537
538
|
// a bare-extension-first reading swallowed the whole name and answered
|
|
@@ -566,6 +567,9 @@ const isMigrationSqlAuthorityPath = (posixRelPath: string): boolean =>
|
|
|
566
567
|
/** Content-only build authority, shared by scanner collection and server admission. */
|
|
567
568
|
export const XCODE_AUTHORITY_PATH = /(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$|\.xcconfig$/;
|
|
568
569
|
export const isXcodeAuthorityPath = (path: string): boolean => XCODE_AUTHORITY_PATH.test(path);
|
|
570
|
+
/** Exact CMake build entrypoint; ordinary .txt files remain outside collection. */
|
|
571
|
+
export const CMAKE_LISTS_PATH = /(?:^|\/)CMakeLists\.txt$/;
|
|
572
|
+
export const isCmakeListsPath = (path: string): boolean => CMAKE_LISTS_PATH.test(path);
|
|
569
573
|
|
|
570
574
|
/**
|
|
571
575
|
* Predicates for paths whose verbatim content is ALREADY shipped by
|
|
@@ -587,6 +591,7 @@ export const isXcodeAuthorityPath = (path: string): boolean => XCODE_AUTHORITY_P
|
|
|
587
591
|
const AUTHORITY_ONLY_PATH_PREDICATES: readonly ((posixRelPath: string) => boolean)[] = [
|
|
588
592
|
isMigrationSqlAuthorityPath,
|
|
589
593
|
isXcodeAuthorityPath,
|
|
594
|
+
isCmakeListsPath,
|
|
590
595
|
];
|
|
591
596
|
|
|
592
597
|
/**
|
|
@@ -633,6 +638,7 @@ export const AUTHORITY_FILE_MATCHERS: Array<(relPath: string) => boolean> = [
|
|
|
633
638
|
// collection and the chunking exclusion cannot disagree.
|
|
634
639
|
isMigrationSqlAuthorityPath,
|
|
635
640
|
isXcodeAuthorityPath,
|
|
641
|
+
isCmakeListsPath,
|
|
636
642
|
];
|
|
637
643
|
|
|
638
644
|
/**
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ export {
|
|
|
28
28
|
isAuthorityOnlyPath,
|
|
29
29
|
XCODE_AUTHORITY_PATH,
|
|
30
30
|
isXcodeAuthorityPath,
|
|
31
|
+
isCmakeListsPath,
|
|
32
|
+
CMAKE_LISTS_PATH,
|
|
31
33
|
isCursorRulePath,
|
|
32
34
|
logAstCapabilityOnce,
|
|
33
35
|
type CodeChunk,
|
|
@@ -77,6 +79,7 @@ export {
|
|
|
77
79
|
loadGrammar,
|
|
78
80
|
loadedGrammarIds,
|
|
79
81
|
resolveAstLanguage,
|
|
82
|
+
objcppSyntaxIssue,
|
|
80
83
|
type AstLanguageId,
|
|
81
84
|
type GrammarBinding,
|
|
82
85
|
type GrammarLoad,
|
|
@@ -177,3 +180,5 @@ export {
|
|
|
177
180
|
} from './systemdControl.js';
|
|
178
181
|
|
|
179
182
|
export { pidIsScanner } from './scannerPid.js';
|
|
183
|
+
|
|
184
|
+
export { parseVueSource, walkVueTemplate, VUE_FIDELITY_MARKER } from './vueSource.js';
|