@mnemonik/shared 7.142.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 +47 -1
- package/dist/ast/grammars.js.map +1 -1
- package/dist/codeScanner.d.ts +6 -0
- package/dist/codeScanner.d.ts.map +1 -1
- package/dist/codeScanner.js +12 -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 +1013 -21
- 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/sql.tags.scm +5 -0
- package/queries/swift.tags.scm +11 -0
- package/queries/terraform.tags.scm +8 -0
- package/scripts/jsx-bare-ampersand.patch +61 -0
- package/scripts/vendor-grammars.ts +731 -37
- package/src/ast/astChunker.ts +10 -1
- package/src/ast/grammars.ts +44 -2
- package/src/codeScanner.ts +12 -0
- package/src/index.ts +7 -0
- package/src/sourceRedaction.ts +1099 -21
- 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/javascript.wasm +0 -0
- package/wasm/lua.LICENSE +21 -0
- package/wasm/lua.tags.scm +36 -0
- package/wasm/lua.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.LICENSE +21 -0
- package/wasm/sql.tags.scm +5 -0
- package/wasm/sql.wasm +0 -0
- package/wasm/swift.LICENSE +21 -0
- package/wasm/swift.tags.scm +11 -0
- package/wasm/swift.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/astChunker.ts
CHANGED
|
@@ -57,7 +57,12 @@
|
|
|
57
57
|
|
|
58
58
|
import type { Node, Query, Tree } from 'web-tree-sitter';
|
|
59
59
|
import { Parser } from 'web-tree-sitter';
|
|
60
|
-
import {
|
|
60
|
+
import {
|
|
61
|
+
loadGrammar,
|
|
62
|
+
objcppSyntaxIssue,
|
|
63
|
+
type AstLanguageId,
|
|
64
|
+
type GrammarBinding,
|
|
65
|
+
} from './grammars.js';
|
|
61
66
|
|
|
62
67
|
export interface AstChunk {
|
|
63
68
|
/** Verbatim contiguous source: exactly the lines `startLine..endLine`. */
|
|
@@ -298,6 +303,10 @@ export async function chunkWithAst(
|
|
|
298
303
|
const parseMs = performance.now() - startedAt;
|
|
299
304
|
|
|
300
305
|
try {
|
|
306
|
+
if (languageId === 'objcpp') {
|
|
307
|
+
const issue = objcppSyntaxIssue(tree.rootNode);
|
|
308
|
+
if (issue) return { unsupported: 'parse_failed', detail: issue };
|
|
309
|
+
}
|
|
301
310
|
const lines = content.split('\n');
|
|
302
311
|
// A trailing newline TERMINATES the last line, it does not open a new one,
|
|
303
312
|
// but `split` yields a phantom '' for it. Dropping it here - before
|
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',
|
|
@@ -55,6 +56,12 @@ const AST_LANGUAGE_ID_LIST = [
|
|
|
55
56
|
'bash',
|
|
56
57
|
'groovy',
|
|
57
58
|
'powershell',
|
|
59
|
+
'swift',
|
|
60
|
+
'sql',
|
|
61
|
+
'lua',
|
|
62
|
+
'terraform',
|
|
63
|
+
'nix',
|
|
64
|
+
'cmake',
|
|
58
65
|
] as const;
|
|
59
66
|
|
|
60
67
|
/** A language this build can AST-parse. Exactly the vendored set, no aspirations. */
|
|
@@ -113,6 +120,7 @@ export const QUERY_CHAIN: Readonly<Record<AstLanguageId, readonly AstLanguageId[
|
|
|
113
120
|
java: ['java'],
|
|
114
121
|
c: ['c'],
|
|
115
122
|
cpp: ['c', 'cpp'],
|
|
123
|
+
objcpp: ['objcpp'],
|
|
116
124
|
csharp: ['csharp'],
|
|
117
125
|
ruby: ['ruby'],
|
|
118
126
|
php: ['php'],
|
|
@@ -123,6 +131,12 @@ export const QUERY_CHAIN: Readonly<Record<AstLanguageId, readonly AstLanguageId[
|
|
|
123
131
|
bash: ['bash'],
|
|
124
132
|
groovy: ['groovy'],
|
|
125
133
|
powershell: ['powershell'],
|
|
134
|
+
swift: ['swift'],
|
|
135
|
+
sql: ['sql'],
|
|
136
|
+
lua: ['lua'],
|
|
137
|
+
terraform: ['terraform'],
|
|
138
|
+
nix: ['nix'],
|
|
139
|
+
cmake: ['cmake'],
|
|
126
140
|
};
|
|
127
141
|
|
|
128
142
|
/**
|
|
@@ -135,8 +149,30 @@ export const QUERY_CHAIN: Readonly<Record<AstLanguageId, readonly AstLanguageId[
|
|
|
135
149
|
*/
|
|
136
150
|
const EXTENSION_GRAMMARS: Readonly<Record<string, AstLanguageId>> = {
|
|
137
151
|
'.tsx': 'tsx',
|
|
152
|
+
'.m': 'objcpp',
|
|
153
|
+
'.mm': 'objcpp',
|
|
138
154
|
};
|
|
139
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
|
+
|
|
140
176
|
/**
|
|
141
177
|
* Scanner language string -> grammar. Keyed on what `languageForExtension`
|
|
142
178
|
* actually returns, so this table and the extension table cannot disagree about
|
|
@@ -144,7 +180,7 @@ const EXTENSION_GRAMMARS: Readonly<Record<string, AstLanguageId>> = {
|
|
|
144
180
|
*
|
|
145
181
|
* Absences are deliberate answers, not gaps. `markdown` is missing because
|
|
146
182
|
* headers already are a document's semantic unit and 10,483 production chunks
|
|
147
|
-
* depend on `chunkMarkdown` keeping them; `kotlin`, `
|
|
183
|
+
* depend on `chunkMarkdown` keeping them; `kotlin`, `dart` and friends
|
|
148
184
|
* are missing because no loadable grammar is vendored yet. Both resolve to
|
|
149
185
|
* `null` and the heuristic chunker takes over.
|
|
150
186
|
*/
|
|
@@ -166,6 +202,12 @@ const LANGUAGE_GRAMMARS: Readonly<Record<string, AstLanguageId>> = {
|
|
|
166
202
|
shell: 'bash',
|
|
167
203
|
groovy: 'groovy',
|
|
168
204
|
powershell: 'powershell',
|
|
205
|
+
swift: 'swift',
|
|
206
|
+
sql: 'sql',
|
|
207
|
+
lua: 'lua',
|
|
208
|
+
terraform: 'terraform',
|
|
209
|
+
nix: 'nix',
|
|
210
|
+
cmake: 'cmake',
|
|
169
211
|
};
|
|
170
212
|
|
|
171
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
|
|
@@ -563,6 +564,13 @@ export function languageForExtension(filePathOrExt: string): string {
|
|
|
563
564
|
const isMigrationSqlAuthorityPath = (posixRelPath: string): boolean =>
|
|
564
565
|
/^migrations\/.*\.sql$/.test(posixRelPath);
|
|
565
566
|
|
|
567
|
+
/** Content-only build authority, shared by scanner collection and server admission. */
|
|
568
|
+
export const XCODE_AUTHORITY_PATH = /(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$|\.xcconfig$/;
|
|
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);
|
|
573
|
+
|
|
566
574
|
/**
|
|
567
575
|
* Predicates for paths whose verbatim content is ALREADY shipped by
|
|
568
576
|
* `collectAuthorityFiles` and that carry no additional value as embedded code
|
|
@@ -582,6 +590,8 @@ const isMigrationSqlAuthorityPath = (posixRelPath: string): boolean =>
|
|
|
582
590
|
*/
|
|
583
591
|
const AUTHORITY_ONLY_PATH_PREDICATES: readonly ((posixRelPath: string) => boolean)[] = [
|
|
584
592
|
isMigrationSqlAuthorityPath,
|
|
593
|
+
isXcodeAuthorityPath,
|
|
594
|
+
isCmakeListsPath,
|
|
585
595
|
];
|
|
586
596
|
|
|
587
597
|
/**
|
|
@@ -627,6 +637,8 @@ export const AUTHORITY_FILE_MATCHERS: Array<(relPath: string) => boolean> = [
|
|
|
627
637
|
// `AUTHORITY_ONLY_PATH_PREDICATES` by reference, not by a copied regex, so
|
|
628
638
|
// collection and the chunking exclusion cannot disagree.
|
|
629
639
|
isMigrationSqlAuthorityPath,
|
|
640
|
+
isXcodeAuthorityPath,
|
|
641
|
+
isCmakeListsPath,
|
|
630
642
|
];
|
|
631
643
|
|
|
632
644
|
/**
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,10 @@ export {
|
|
|
26
26
|
isFixturePath,
|
|
27
27
|
isSecretFile,
|
|
28
28
|
isAuthorityOnlyPath,
|
|
29
|
+
XCODE_AUTHORITY_PATH,
|
|
30
|
+
isXcodeAuthorityPath,
|
|
31
|
+
isCmakeListsPath,
|
|
32
|
+
CMAKE_LISTS_PATH,
|
|
29
33
|
isCursorRulePath,
|
|
30
34
|
logAstCapabilityOnce,
|
|
31
35
|
type CodeChunk,
|
|
@@ -75,6 +79,7 @@ export {
|
|
|
75
79
|
loadGrammar,
|
|
76
80
|
loadedGrammarIds,
|
|
77
81
|
resolveAstLanguage,
|
|
82
|
+
objcppSyntaxIssue,
|
|
78
83
|
type AstLanguageId,
|
|
79
84
|
type GrammarBinding,
|
|
80
85
|
type GrammarLoad,
|
|
@@ -175,3 +180,5 @@ export {
|
|
|
175
180
|
} from './systemdControl.js';
|
|
176
181
|
|
|
177
182
|
export { pidIsScanner } from './scannerPid.js';
|
|
183
|
+
|
|
184
|
+
export { parseVueSource, walkVueTemplate, VUE_FIDELITY_MARKER } from './vueSource.js';
|