@colbymchenry/codegraph 0.6.8 → 0.7.2
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/README.md +179 -476
- package/dist/bin/codegraph.d.ts +0 -5
- package/dist/bin/codegraph.d.ts.map +1 -1
- package/dist/bin/codegraph.js +217 -237
- package/dist/bin/codegraph.js.map +1 -1
- package/dist/bin/uninstall.d.ts +0 -1
- package/dist/bin/uninstall.d.ts.map +1 -1
- package/dist/bin/uninstall.js +3 -29
- package/dist/bin/uninstall.js.map +1 -1
- package/dist/context/index.d.ts +3 -5
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js +497 -46
- package/dist/context/index.js.map +1 -1
- package/dist/db/migrations.d.ts +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +10 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/queries.d.ts +53 -0
- package/dist/db/queries.d.ts.map +1 -1
- package/dist/db/queries.js +244 -14
- package/dist/db/queries.js.map +1 -1
- package/dist/db/schema.sql +1 -16
- package/dist/extraction/dfm-extractor.d.ts +31 -0
- package/dist/extraction/dfm-extractor.d.ts.map +1 -0
- package/dist/extraction/dfm-extractor.js +151 -0
- package/dist/extraction/dfm-extractor.js.map +1 -0
- package/dist/extraction/grammars.d.ts +9 -1
- package/dist/extraction/grammars.d.ts.map +1 -1
- package/dist/extraction/grammars.js +34 -2
- package/dist/extraction/grammars.js.map +1 -1
- package/dist/extraction/index.d.ts +7 -1
- package/dist/extraction/index.d.ts.map +1 -1
- package/dist/extraction/index.js +373 -22
- package/dist/extraction/index.js.map +1 -1
- package/dist/extraction/languages/c-cpp.d.ts +4 -0
- package/dist/extraction/languages/c-cpp.d.ts.map +1 -0
- package/dist/extraction/languages/c-cpp.js +126 -0
- package/dist/extraction/languages/c-cpp.js.map +1 -0
- package/dist/extraction/languages/csharp.d.ts +3 -0
- package/dist/extraction/languages/csharp.d.ts.map +1 -0
- package/dist/extraction/languages/csharp.js +72 -0
- package/dist/extraction/languages/csharp.js.map +1 -0
- package/dist/extraction/languages/dart.d.ts +3 -0
- package/dist/extraction/languages/dart.d.ts.map +1 -0
- package/dist/extraction/languages/dart.js +192 -0
- package/dist/extraction/languages/dart.js.map +1 -0
- package/dist/extraction/languages/go.d.ts +3 -0
- package/dist/extraction/languages/go.d.ts.map +1 -0
- package/dist/extraction/languages/go.js +58 -0
- package/dist/extraction/languages/go.js.map +1 -0
- package/dist/extraction/languages/index.d.ts +10 -0
- package/dist/extraction/languages/index.d.ts.map +1 -0
- package/dist/extraction/languages/index.js +43 -0
- package/dist/extraction/languages/index.js.map +1 -0
- package/dist/extraction/languages/java.d.ts +3 -0
- package/dist/extraction/languages/java.d.ts.map +1 -0
- package/dist/extraction/languages/java.js +64 -0
- package/dist/extraction/languages/java.js.map +1 -0
- package/dist/extraction/languages/javascript.d.ts +3 -0
- package/dist/extraction/languages/javascript.d.ts.map +1 -0
- package/dist/extraction/languages/javascript.js +90 -0
- package/dist/extraction/languages/javascript.js.map +1 -0
- package/dist/extraction/languages/kotlin.d.ts +3 -0
- package/dist/extraction/languages/kotlin.d.ts.map +1 -0
- package/dist/extraction/languages/kotlin.js +253 -0
- package/dist/extraction/languages/kotlin.js.map +1 -0
- package/dist/extraction/languages/pascal.d.ts +3 -0
- package/dist/extraction/languages/pascal.d.ts.map +1 -0
- package/dist/extraction/languages/pascal.js +66 -0
- package/dist/extraction/languages/pascal.js.map +1 -0
- package/dist/extraction/languages/php.d.ts +3 -0
- package/dist/extraction/languages/php.d.ts.map +1 -0
- package/dist/extraction/languages/php.js +107 -0
- package/dist/extraction/languages/php.js.map +1 -0
- package/dist/extraction/languages/python.d.ts +3 -0
- package/dist/extraction/languages/python.d.ts.map +1 -0
- package/dist/extraction/languages/python.js +56 -0
- package/dist/extraction/languages/python.js.map +1 -0
- package/dist/extraction/languages/ruby.d.ts +3 -0
- package/dist/extraction/languages/ruby.d.ts.map +1 -0
- package/dist/extraction/languages/ruby.js +114 -0
- package/dist/extraction/languages/ruby.js.map +1 -0
- package/dist/extraction/languages/rust.d.ts +3 -0
- package/dist/extraction/languages/rust.d.ts.map +1 -0
- package/dist/extraction/languages/rust.js +109 -0
- package/dist/extraction/languages/rust.js.map +1 -0
- package/dist/extraction/languages/swift.d.ts +3 -0
- package/dist/extraction/languages/swift.d.ts.map +1 -0
- package/dist/extraction/languages/swift.js +91 -0
- package/dist/extraction/languages/swift.js.map +1 -0
- package/dist/extraction/languages/typescript.d.ts +3 -0
- package/dist/extraction/languages/typescript.d.ts.map +1 -0
- package/dist/extraction/languages/typescript.js +129 -0
- package/dist/extraction/languages/typescript.js.map +1 -0
- package/dist/extraction/liquid-extractor.d.ts +52 -0
- package/dist/extraction/liquid-extractor.d.ts.map +1 -0
- package/dist/extraction/liquid-extractor.js +313 -0
- package/dist/extraction/liquid-extractor.js.map +1 -0
- package/dist/extraction/parse-worker.d.ts +8 -0
- package/dist/extraction/parse-worker.d.ts.map +1 -0
- package/dist/extraction/parse-worker.js +57 -0
- package/dist/extraction/parse-worker.js.map +1 -0
- package/dist/extraction/svelte-extractor.d.ts +47 -0
- package/dist/extraction/svelte-extractor.d.ts.map +1 -0
- package/dist/extraction/svelte-extractor.js +230 -0
- package/dist/extraction/svelte-extractor.js.map +1 -0
- package/dist/extraction/tree-sitter-helpers.d.ts +28 -0
- package/dist/extraction/tree-sitter-helpers.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-helpers.js +103 -0
- package/dist/extraction/tree-sitter-helpers.js.map +1 -0
- package/dist/extraction/tree-sitter-types.d.ts +179 -0
- package/dist/extraction/tree-sitter-types.d.ts.map +1 -0
- package/dist/extraction/tree-sitter-types.js +10 -0
- package/dist/extraction/tree-sitter-types.js.map +1 -0
- package/dist/extraction/tree-sitter.d.ts +67 -125
- package/dist/extraction/tree-sitter.d.ts.map +1 -1
- package/dist/extraction/tree-sitter.js +1052 -1855
- package/dist/extraction/tree-sitter.js.map +1 -1
- package/dist/graph/traversal.d.ts.map +1 -1
- package/dist/graph/traversal.js +20 -2
- package/dist/graph/traversal.js.map +1 -1
- package/dist/index.d.ts +29 -53
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -114
- package/dist/index.js.map +1 -1
- package/dist/installer/claude-md-template.d.ts +1 -1
- package/dist/installer/claude-md-template.d.ts.map +1 -1
- package/dist/installer/claude-md-template.js +15 -15
- package/dist/installer/config-writer.d.ts +1 -10
- package/dist/installer/config-writer.d.ts.map +1 -1
- package/dist/installer/config-writer.js +0 -79
- package/dist/installer/config-writer.js.map +1 -1
- package/dist/installer/index.d.ts +3 -4
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +118 -116
- package/dist/installer/index.js.map +1 -1
- package/dist/mcp/index.d.ts +5 -0
- package/dist/mcp/index.d.ts.map +1 -1
- package/dist/mcp/index.js +25 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/tools.d.ts +33 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +405 -21
- package/dist/mcp/tools.js.map +1 -1
- package/dist/resolution/frameworks/csharp.js +29 -84
- package/dist/resolution/frameworks/csharp.js.map +1 -1
- package/dist/resolution/frameworks/express.js +44 -48
- package/dist/resolution/frameworks/express.js.map +1 -1
- package/dist/resolution/frameworks/go.js +34 -70
- package/dist/resolution/frameworks/go.js.map +1 -1
- package/dist/resolution/frameworks/java.js +29 -87
- package/dist/resolution/frameworks/java.js.map +1 -1
- package/dist/resolution/frameworks/laravel.js +6 -6
- package/dist/resolution/frameworks/laravel.js.map +1 -1
- package/dist/resolution/frameworks/python.js +33 -98
- package/dist/resolution/frameworks/python.js.map +1 -1
- package/dist/resolution/frameworks/react.js +53 -76
- package/dist/resolution/frameworks/react.js.map +1 -1
- package/dist/resolution/frameworks/ruby.js +12 -24
- package/dist/resolution/frameworks/ruby.js.map +1 -1
- package/dist/resolution/frameworks/rust.js +26 -66
- package/dist/resolution/frameworks/rust.js.map +1 -1
- package/dist/resolution/frameworks/svelte.js +11 -31
- package/dist/resolution/frameworks/svelte.js.map +1 -1
- package/dist/resolution/frameworks/swift.js +42 -160
- package/dist/resolution/frameworks/swift.js.map +1 -1
- package/dist/resolution/index.d.ts +19 -6
- package/dist/resolution/index.d.ts.map +1 -1
- package/dist/resolution/index.js +300 -141
- package/dist/resolution/index.js.map +1 -1
- package/dist/resolution/name-matcher.d.ts +5 -0
- package/dist/resolution/name-matcher.d.ts.map +1 -1
- package/dist/resolution/name-matcher.js +148 -8
- package/dist/resolution/name-matcher.js.map +1 -1
- package/dist/resolution/types.d.ts +1 -1
- package/dist/resolution/types.d.ts.map +1 -1
- package/dist/search/query-utils.d.ts +26 -1
- package/dist/search/query-utils.d.ts.map +1 -1
- package/dist/search/query-utils.js +209 -9
- package/dist/search/query-utils.js.map +1 -1
- package/dist/sync/index.d.ts +2 -4
- package/dist/sync/index.d.ts.map +1 -1
- package/dist/sync/index.js +4 -3
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/watcher.d.ts +81 -0
- package/dist/sync/watcher.d.ts.map +1 -0
- package/dist/sync/watcher.js +184 -0
- package/dist/sync/watcher.js.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/ui/shimmer-progress.d.ts +11 -0
- package/dist/ui/shimmer-progress.d.ts.map +1 -0
- package/dist/ui/shimmer-progress.js +90 -0
- package/dist/ui/shimmer-progress.js.map +1 -0
- package/dist/ui/shimmer-worker.d.ts +2 -0
- package/dist/ui/shimmer-worker.d.ts.map +1 -0
- package/dist/ui/shimmer-worker.js +112 -0
- package/dist/ui/shimmer-worker.js.map +1 -0
- package/dist/ui/types.d.ts +17 -0
- package/dist/ui/types.d.ts.map +1 -0
- package/dist/ui/types.js +3 -0
- package/dist/ui/types.js.map +1 -0
- package/dist/vectors/embedder.js +1 -1
- package/dist/vectors/embedder.js.map +1 -1
- package/package.json +7 -12
- package/scripts/postinstall.js +0 -68
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.d.ts","sourceRoot":"","sources":["../../../src/extraction/languages/typescript.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,eAAO,MAAM,mBAAmB,EAAE,iBAkHjC,CAAC"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typescriptExtractor = void 0;
|
|
4
|
+
const tree_sitter_helpers_1 = require("../tree-sitter-helpers");
|
|
5
|
+
exports.typescriptExtractor = {
|
|
6
|
+
functionTypes: ['function_declaration', 'arrow_function', 'function_expression'],
|
|
7
|
+
classTypes: ['class_declaration', 'abstract_class_declaration'],
|
|
8
|
+
methodTypes: ['method_definition', 'public_field_definition'],
|
|
9
|
+
interfaceTypes: ['interface_declaration'],
|
|
10
|
+
structTypes: [],
|
|
11
|
+
enumTypes: ['enum_declaration'],
|
|
12
|
+
enumMemberTypes: ['property_identifier', 'enum_assignment'],
|
|
13
|
+
typeAliasTypes: ['type_alias_declaration'],
|
|
14
|
+
importTypes: ['import_statement'],
|
|
15
|
+
callTypes: ['call_expression'],
|
|
16
|
+
variableTypes: ['lexical_declaration', 'variable_declaration'],
|
|
17
|
+
nameField: 'name',
|
|
18
|
+
bodyField: 'body',
|
|
19
|
+
resolveBody: (node, bodyField) => {
|
|
20
|
+
// public_field_definition (arrow function class fields) nest the body inside
|
|
21
|
+
// an arrow_function or function_expression child:
|
|
22
|
+
// public_field_definition → arrow_function → body (statement_block)
|
|
23
|
+
// Also handles wrapper patterns like: field = withBatchedUpdates((e) => { ... })
|
|
24
|
+
// public_field_definition → call_expression → arguments → arrow_function → body
|
|
25
|
+
if (node.type === 'public_field_definition') {
|
|
26
|
+
for (let i = 0; i < node.namedChildCount; i++) {
|
|
27
|
+
const child = node.namedChild(i);
|
|
28
|
+
if (!child)
|
|
29
|
+
continue;
|
|
30
|
+
if (child.type === 'arrow_function' || child.type === 'function_expression') {
|
|
31
|
+
return (0, tree_sitter_helpers_1.getChildByField)(child, bodyField);
|
|
32
|
+
}
|
|
33
|
+
// Check inside call_expression arguments (HOF wrappers like throttle, debounce)
|
|
34
|
+
if (child.type === 'call_expression') {
|
|
35
|
+
const args = (0, tree_sitter_helpers_1.getChildByField)(child, 'arguments');
|
|
36
|
+
if (args) {
|
|
37
|
+
for (let j = 0; j < args.namedChildCount; j++) {
|
|
38
|
+
const arg = args.namedChild(j);
|
|
39
|
+
if (arg && (arg.type === 'arrow_function' || arg.type === 'function_expression')) {
|
|
40
|
+
return (0, tree_sitter_helpers_1.getChildByField)(arg, bodyField);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
},
|
|
49
|
+
paramsField: 'parameters',
|
|
50
|
+
returnField: 'return_type',
|
|
51
|
+
getSignature: (node, source) => {
|
|
52
|
+
const params = (0, tree_sitter_helpers_1.getChildByField)(node, 'parameters');
|
|
53
|
+
const returnType = (0, tree_sitter_helpers_1.getChildByField)(node, 'return_type');
|
|
54
|
+
if (!params)
|
|
55
|
+
return undefined;
|
|
56
|
+
let sig = (0, tree_sitter_helpers_1.getNodeText)(params, source);
|
|
57
|
+
if (returnType) {
|
|
58
|
+
sig += ': ' + (0, tree_sitter_helpers_1.getNodeText)(returnType, source).replace(/^:\s*/, '');
|
|
59
|
+
}
|
|
60
|
+
return sig;
|
|
61
|
+
},
|
|
62
|
+
getVisibility: (node) => {
|
|
63
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
64
|
+
const child = node.child(i);
|
|
65
|
+
if (child?.type === 'accessibility_modifier') {
|
|
66
|
+
const text = child.text;
|
|
67
|
+
if (text === 'public')
|
|
68
|
+
return 'public';
|
|
69
|
+
if (text === 'private')
|
|
70
|
+
return 'private';
|
|
71
|
+
if (text === 'protected')
|
|
72
|
+
return 'protected';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return undefined;
|
|
76
|
+
},
|
|
77
|
+
isExported: (node, _source) => {
|
|
78
|
+
// Walk the parent chain to find an export_statement ancestor.
|
|
79
|
+
// This correctly handles deeply nested nodes like arrow functions
|
|
80
|
+
// inside variable declarations: `export const X = () => { ... }`
|
|
81
|
+
// where the arrow_function is 3 levels deep under export_statement.
|
|
82
|
+
let current = node.parent;
|
|
83
|
+
while (current) {
|
|
84
|
+
if (current.type === 'export_statement')
|
|
85
|
+
return true;
|
|
86
|
+
current = current.parent;
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
},
|
|
90
|
+
isAsync: (node) => {
|
|
91
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
92
|
+
const child = node.child(i);
|
|
93
|
+
if (child?.type === 'async')
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
return false;
|
|
97
|
+
},
|
|
98
|
+
isStatic: (node) => {
|
|
99
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
100
|
+
const child = node.child(i);
|
|
101
|
+
if (child?.type === 'static')
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
},
|
|
106
|
+
isConst: (node) => {
|
|
107
|
+
// For lexical_declaration, check if it's 'const' or 'let'
|
|
108
|
+
// For variable_declaration, it's always 'var'
|
|
109
|
+
if (node.type === 'lexical_declaration') {
|
|
110
|
+
for (let i = 0; i < node.childCount; i++) {
|
|
111
|
+
const child = node.child(i);
|
|
112
|
+
if (child?.type === 'const')
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return false;
|
|
117
|
+
},
|
|
118
|
+
extractImport: (node, source) => {
|
|
119
|
+
const sourceField = node.childForFieldName('source');
|
|
120
|
+
if (sourceField) {
|
|
121
|
+
const moduleName = source.substring(sourceField.startIndex, sourceField.endIndex).replace(/['"]/g, '');
|
|
122
|
+
if (moduleName) {
|
|
123
|
+
return { moduleName, signature: source.substring(node.startIndex, node.endIndex).trim() };
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=typescript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript.js","sourceRoot":"","sources":["../../../src/extraction/languages/typescript.ts"],"names":[],"mappings":";;;AAAA,gEAAsE;AAGzD,QAAA,mBAAmB,GAAsB;IACpD,aAAa,EAAE,CAAC,sBAAsB,EAAE,gBAAgB,EAAE,qBAAqB,CAAC;IAChF,UAAU,EAAE,CAAC,mBAAmB,EAAE,4BAA4B,CAAC;IAC/D,WAAW,EAAE,CAAC,mBAAmB,EAAE,yBAAyB,CAAC;IAC7D,cAAc,EAAE,CAAC,uBAAuB,CAAC;IACzC,WAAW,EAAE,EAAE;IACf,SAAS,EAAE,CAAC,kBAAkB,CAAC;IAC/B,eAAe,EAAE,CAAC,qBAAqB,EAAE,iBAAiB,CAAC;IAC3D,cAAc,EAAE,CAAC,wBAAwB,CAAC;IAC1C,WAAW,EAAE,CAAC,kBAAkB,CAAC;IACjC,SAAS,EAAE,CAAC,iBAAiB,CAAC;IAC9B,aAAa,EAAE,CAAC,qBAAqB,EAAE,sBAAsB,CAAC;IAC9D,SAAS,EAAE,MAAM;IACjB,SAAS,EAAE,MAAM;IACjB,WAAW,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;QAC/B,6EAA6E;QAC7E,kDAAkD;QAClD,sEAAsE;QACtE,iFAAiF;QACjF,kFAAkF;QAClF,IAAI,IAAI,CAAC,IAAI,KAAK,yBAAyB,EAAE,CAAC;YAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,C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AAE,CAAC,CAAC;YACvG,IAAI,UAAU,EAAE,CAAC;gBACf,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC5F,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ExtractionResult } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* LiquidExtractor - Extracts relationships from Liquid template files
|
|
4
|
+
*
|
|
5
|
+
* Liquid is a templating language (used by Shopify, Jekyll, etc.) that doesn't
|
|
6
|
+
* have traditional functions or classes. Instead, we extract:
|
|
7
|
+
* - Section references ({% section 'name' %})
|
|
8
|
+
* - Snippet references ({% render 'name' %} and {% include 'name' %})
|
|
9
|
+
* - Schema blocks ({% schema %}...{% endschema %})
|
|
10
|
+
*/
|
|
11
|
+
export declare class LiquidExtractor {
|
|
12
|
+
private filePath;
|
|
13
|
+
private source;
|
|
14
|
+
private nodes;
|
|
15
|
+
private edges;
|
|
16
|
+
private unresolvedReferences;
|
|
17
|
+
private errors;
|
|
18
|
+
constructor(filePath: string, source: string);
|
|
19
|
+
/**
|
|
20
|
+
* Extract from Liquid source
|
|
21
|
+
*/
|
|
22
|
+
extract(): ExtractionResult;
|
|
23
|
+
/**
|
|
24
|
+
* Create a file node for the Liquid template
|
|
25
|
+
*/
|
|
26
|
+
private createFileNode;
|
|
27
|
+
/**
|
|
28
|
+
* Extract {% render 'snippet' %} and {% include 'snippet' %} references
|
|
29
|
+
*/
|
|
30
|
+
private extractSnippetReferences;
|
|
31
|
+
/**
|
|
32
|
+
* Extract {% section 'name' %} references
|
|
33
|
+
*/
|
|
34
|
+
private extractSectionReferences;
|
|
35
|
+
/**
|
|
36
|
+
* Extract {% schema %}...{% endschema %} blocks
|
|
37
|
+
*/
|
|
38
|
+
private extractSchema;
|
|
39
|
+
/**
|
|
40
|
+
* Extract {% assign var = value %} statements
|
|
41
|
+
*/
|
|
42
|
+
private extractAssignments;
|
|
43
|
+
/**
|
|
44
|
+
* Get the line number for a character index
|
|
45
|
+
*/
|
|
46
|
+
private getLineNumber;
|
|
47
|
+
/**
|
|
48
|
+
* Get the character index of the start of a line
|
|
49
|
+
*/
|
|
50
|
+
private getLineStart;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=liquid-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquid-extractor.d.ts","sourceRoot":"","sources":["../../src/extraction/liquid-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,gBAAgB,EAAwC,MAAM,UAAU,CAAC;AAG9F;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,MAAM,CAAyB;gBAE3B,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK5C;;OAEG;IACH,OAAO,IAAI,gBAAgB;IAmC3B;;OAEG;IACH,OAAO,CAAC,cAAc;IAsBtB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAuEhC;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAuEhC;;OAEG;IACH,OAAO,CAAC,aAAa;IAqDrB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAqC1B;;OAEG;IACH,OAAO,CAAC,aAAa;IAKrB;;OAEG;IACH,OAAO,CAAC,YAAY;CAQrB"}
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiquidExtractor = void 0;
|
|
4
|
+
const tree_sitter_helpers_1 = require("./tree-sitter-helpers");
|
|
5
|
+
/**
|
|
6
|
+
* LiquidExtractor - Extracts relationships from Liquid template files
|
|
7
|
+
*
|
|
8
|
+
* Liquid is a templating language (used by Shopify, Jekyll, etc.) that doesn't
|
|
9
|
+
* have traditional functions or classes. Instead, we extract:
|
|
10
|
+
* - Section references ({% section 'name' %})
|
|
11
|
+
* - Snippet references ({% render 'name' %} and {% include 'name' %})
|
|
12
|
+
* - Schema blocks ({% schema %}...{% endschema %})
|
|
13
|
+
*/
|
|
14
|
+
class LiquidExtractor {
|
|
15
|
+
filePath;
|
|
16
|
+
source;
|
|
17
|
+
nodes = [];
|
|
18
|
+
edges = [];
|
|
19
|
+
unresolvedReferences = [];
|
|
20
|
+
errors = [];
|
|
21
|
+
constructor(filePath, source) {
|
|
22
|
+
this.filePath = filePath;
|
|
23
|
+
this.source = source;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Extract from Liquid source
|
|
27
|
+
*/
|
|
28
|
+
extract() {
|
|
29
|
+
const startTime = Date.now();
|
|
30
|
+
try {
|
|
31
|
+
// Create file node
|
|
32
|
+
const fileNode = this.createFileNode();
|
|
33
|
+
// Extract render/include statements (snippet references)
|
|
34
|
+
this.extractSnippetReferences(fileNode.id);
|
|
35
|
+
// Extract section references
|
|
36
|
+
this.extractSectionReferences(fileNode.id);
|
|
37
|
+
// Extract schema block
|
|
38
|
+
this.extractSchema(fileNode.id);
|
|
39
|
+
// Extract assign statements as variables
|
|
40
|
+
this.extractAssignments(fileNode.id);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.errors.push({
|
|
44
|
+
message: `Liquid extraction error: ${error instanceof Error ? error.message : String(error)}`,
|
|
45
|
+
severity: 'error',
|
|
46
|
+
code: 'parse_error',
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
nodes: this.nodes,
|
|
51
|
+
edges: this.edges,
|
|
52
|
+
unresolvedReferences: this.unresolvedReferences,
|
|
53
|
+
errors: this.errors,
|
|
54
|
+
durationMs: Date.now() - startTime,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a file node for the Liquid template
|
|
59
|
+
*/
|
|
60
|
+
createFileNode() {
|
|
61
|
+
const lines = this.source.split('\n');
|
|
62
|
+
const id = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'file', this.filePath, 1);
|
|
63
|
+
const fileNode = {
|
|
64
|
+
id,
|
|
65
|
+
kind: 'file',
|
|
66
|
+
name: this.filePath.split('/').pop() || this.filePath,
|
|
67
|
+
qualifiedName: this.filePath,
|
|
68
|
+
filePath: this.filePath,
|
|
69
|
+
language: 'liquid',
|
|
70
|
+
startLine: 1,
|
|
71
|
+
endLine: lines.length,
|
|
72
|
+
startColumn: 0,
|
|
73
|
+
endColumn: lines[lines.length - 1]?.length || 0,
|
|
74
|
+
updatedAt: Date.now(),
|
|
75
|
+
};
|
|
76
|
+
this.nodes.push(fileNode);
|
|
77
|
+
return fileNode;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Extract {% render 'snippet' %} and {% include 'snippet' %} references
|
|
81
|
+
*/
|
|
82
|
+
extractSnippetReferences(fileNodeId) {
|
|
83
|
+
// Match {% render 'name' %} or {% include 'name' %} with optional parameters
|
|
84
|
+
const renderRegex = /\{%[-]?\s*(render|include)\s+['"]([^'"]+)['"]/g;
|
|
85
|
+
let match;
|
|
86
|
+
while ((match = renderRegex.exec(this.source)) !== null) {
|
|
87
|
+
const [fullMatch, tagType, snippetName] = match;
|
|
88
|
+
const line = this.getLineNumber(match.index);
|
|
89
|
+
// Create an import node for searchability
|
|
90
|
+
const importNodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'import', snippetName, line);
|
|
91
|
+
const importNode = {
|
|
92
|
+
id: importNodeId,
|
|
93
|
+
kind: 'import',
|
|
94
|
+
name: snippetName,
|
|
95
|
+
qualifiedName: `${this.filePath}::import:${snippetName}`,
|
|
96
|
+
filePath: this.filePath,
|
|
97
|
+
language: 'liquid',
|
|
98
|
+
signature: fullMatch,
|
|
99
|
+
startLine: line,
|
|
100
|
+
endLine: line,
|
|
101
|
+
startColumn: match.index - this.getLineStart(line),
|
|
102
|
+
endColumn: match.index - this.getLineStart(line) + fullMatch.length,
|
|
103
|
+
updatedAt: Date.now(),
|
|
104
|
+
};
|
|
105
|
+
this.nodes.push(importNode);
|
|
106
|
+
// Add containment edge from file to import
|
|
107
|
+
this.edges.push({
|
|
108
|
+
source: fileNodeId,
|
|
109
|
+
target: importNodeId,
|
|
110
|
+
kind: 'contains',
|
|
111
|
+
});
|
|
112
|
+
// Create a component node for the snippet reference
|
|
113
|
+
const nodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'component', `${tagType}:${snippetName}`, line);
|
|
114
|
+
const node = {
|
|
115
|
+
id: nodeId,
|
|
116
|
+
kind: 'component',
|
|
117
|
+
name: snippetName,
|
|
118
|
+
qualifiedName: `${this.filePath}::${tagType}:${snippetName}`,
|
|
119
|
+
filePath: this.filePath,
|
|
120
|
+
language: 'liquid',
|
|
121
|
+
startLine: line,
|
|
122
|
+
endLine: line,
|
|
123
|
+
startColumn: match.index - this.getLineStart(line),
|
|
124
|
+
endColumn: match.index - this.getLineStart(line) + fullMatch.length,
|
|
125
|
+
updatedAt: Date.now(),
|
|
126
|
+
};
|
|
127
|
+
this.nodes.push(node);
|
|
128
|
+
// Add containment edge from file
|
|
129
|
+
this.edges.push({
|
|
130
|
+
source: fileNodeId,
|
|
131
|
+
target: nodeId,
|
|
132
|
+
kind: 'contains',
|
|
133
|
+
});
|
|
134
|
+
// Add unresolved reference to the snippet file
|
|
135
|
+
this.unresolvedReferences.push({
|
|
136
|
+
fromNodeId: fileNodeId,
|
|
137
|
+
referenceName: `snippets/${snippetName}.liquid`,
|
|
138
|
+
referenceKind: 'references',
|
|
139
|
+
line,
|
|
140
|
+
column: match.index - this.getLineStart(line),
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Extract {% section 'name' %} references
|
|
146
|
+
*/
|
|
147
|
+
extractSectionReferences(fileNodeId) {
|
|
148
|
+
// Match {% section 'name' %}
|
|
149
|
+
const sectionRegex = /\{%[-]?\s*section\s+['"]([^'"]+)['"]/g;
|
|
150
|
+
let match;
|
|
151
|
+
while ((match = sectionRegex.exec(this.source)) !== null) {
|
|
152
|
+
const [fullMatch, sectionName] = match;
|
|
153
|
+
const line = this.getLineNumber(match.index);
|
|
154
|
+
// Create an import node for searchability
|
|
155
|
+
const importNodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'import', sectionName, line);
|
|
156
|
+
const importNode = {
|
|
157
|
+
id: importNodeId,
|
|
158
|
+
kind: 'import',
|
|
159
|
+
name: sectionName,
|
|
160
|
+
qualifiedName: `${this.filePath}::import:${sectionName}`,
|
|
161
|
+
filePath: this.filePath,
|
|
162
|
+
language: 'liquid',
|
|
163
|
+
signature: fullMatch,
|
|
164
|
+
startLine: line,
|
|
165
|
+
endLine: line,
|
|
166
|
+
startColumn: match.index - this.getLineStart(line),
|
|
167
|
+
endColumn: match.index - this.getLineStart(line) + fullMatch.length,
|
|
168
|
+
updatedAt: Date.now(),
|
|
169
|
+
};
|
|
170
|
+
this.nodes.push(importNode);
|
|
171
|
+
// Add containment edge from file to import
|
|
172
|
+
this.edges.push({
|
|
173
|
+
source: fileNodeId,
|
|
174
|
+
target: importNodeId,
|
|
175
|
+
kind: 'contains',
|
|
176
|
+
});
|
|
177
|
+
// Create a component node for the section reference
|
|
178
|
+
const nodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'component', `section:${sectionName}`, line);
|
|
179
|
+
const node = {
|
|
180
|
+
id: nodeId,
|
|
181
|
+
kind: 'component',
|
|
182
|
+
name: sectionName,
|
|
183
|
+
qualifiedName: `${this.filePath}::section:${sectionName}`,
|
|
184
|
+
filePath: this.filePath,
|
|
185
|
+
language: 'liquid',
|
|
186
|
+
startLine: line,
|
|
187
|
+
endLine: line,
|
|
188
|
+
startColumn: match.index - this.getLineStart(line),
|
|
189
|
+
endColumn: match.index - this.getLineStart(line) + fullMatch.length,
|
|
190
|
+
updatedAt: Date.now(),
|
|
191
|
+
};
|
|
192
|
+
this.nodes.push(node);
|
|
193
|
+
// Add containment edge from file
|
|
194
|
+
this.edges.push({
|
|
195
|
+
source: fileNodeId,
|
|
196
|
+
target: nodeId,
|
|
197
|
+
kind: 'contains',
|
|
198
|
+
});
|
|
199
|
+
// Add unresolved reference to the section file
|
|
200
|
+
this.unresolvedReferences.push({
|
|
201
|
+
fromNodeId: fileNodeId,
|
|
202
|
+
referenceName: `sections/${sectionName}.liquid`,
|
|
203
|
+
referenceKind: 'references',
|
|
204
|
+
line,
|
|
205
|
+
column: match.index - this.getLineStart(line),
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Extract {% schema %}...{% endschema %} blocks
|
|
211
|
+
*/
|
|
212
|
+
extractSchema(fileNodeId) {
|
|
213
|
+
// Match {% schema %}...{% endschema %}
|
|
214
|
+
const schemaRegex = /\{%[-]?\s*schema\s*[-]?%\}([\s\S]*?)\{%[-]?\s*endschema\s*[-]?%\}/g;
|
|
215
|
+
let match;
|
|
216
|
+
while ((match = schemaRegex.exec(this.source)) !== null) {
|
|
217
|
+
const [fullMatch, schemaContent] = match;
|
|
218
|
+
const startLine = this.getLineNumber(match.index);
|
|
219
|
+
const endLine = this.getLineNumber(match.index + fullMatch.length);
|
|
220
|
+
// Try to parse the schema JSON to get the name
|
|
221
|
+
let schemaName = 'schema';
|
|
222
|
+
try {
|
|
223
|
+
const schemaJson = JSON.parse(schemaContent);
|
|
224
|
+
if (schemaJson.name) {
|
|
225
|
+
// Shopify schema names can be translation objects like {"en": "...", "fr": "..."}
|
|
226
|
+
schemaName = typeof schemaJson.name === 'string'
|
|
227
|
+
? schemaJson.name
|
|
228
|
+
: schemaJson.name.en || Object.values(schemaJson.name)[0] || 'schema';
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
// Schema isn't valid JSON, use default name
|
|
233
|
+
}
|
|
234
|
+
// Create a node for the schema
|
|
235
|
+
const nodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'constant', `schema:${schemaName}`, startLine);
|
|
236
|
+
const node = {
|
|
237
|
+
id: nodeId,
|
|
238
|
+
kind: 'constant',
|
|
239
|
+
name: schemaName,
|
|
240
|
+
qualifiedName: `${this.filePath}::schema:${schemaName}`,
|
|
241
|
+
filePath: this.filePath,
|
|
242
|
+
language: 'liquid',
|
|
243
|
+
startLine,
|
|
244
|
+
endLine,
|
|
245
|
+
startColumn: match.index - this.getLineStart(startLine),
|
|
246
|
+
endColumn: 0,
|
|
247
|
+
docstring: schemaContent?.trim().substring(0, 200), // Store first 200 chars as docstring
|
|
248
|
+
updatedAt: Date.now(),
|
|
249
|
+
};
|
|
250
|
+
this.nodes.push(node);
|
|
251
|
+
// Add containment edge from file
|
|
252
|
+
this.edges.push({
|
|
253
|
+
source: fileNodeId,
|
|
254
|
+
target: nodeId,
|
|
255
|
+
kind: 'contains',
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Extract {% assign var = value %} statements
|
|
261
|
+
*/
|
|
262
|
+
extractAssignments(fileNodeId) {
|
|
263
|
+
// Match {% assign variable_name = ... %}
|
|
264
|
+
const assignRegex = /\{%[-]?\s*assign\s+(\w+)\s*=/g;
|
|
265
|
+
let match;
|
|
266
|
+
while ((match = assignRegex.exec(this.source)) !== null) {
|
|
267
|
+
const [, variableName] = match;
|
|
268
|
+
const line = this.getLineNumber(match.index);
|
|
269
|
+
// Create a variable node
|
|
270
|
+
const nodeId = (0, tree_sitter_helpers_1.generateNodeId)(this.filePath, 'variable', variableName, line);
|
|
271
|
+
const node = {
|
|
272
|
+
id: nodeId,
|
|
273
|
+
kind: 'variable',
|
|
274
|
+
name: variableName,
|
|
275
|
+
qualifiedName: `${this.filePath}::${variableName}`,
|
|
276
|
+
filePath: this.filePath,
|
|
277
|
+
language: 'liquid',
|
|
278
|
+
startLine: line,
|
|
279
|
+
endLine: line,
|
|
280
|
+
startColumn: match.index - this.getLineStart(line),
|
|
281
|
+
endColumn: match.index - this.getLineStart(line) + match[0].length,
|
|
282
|
+
updatedAt: Date.now(),
|
|
283
|
+
};
|
|
284
|
+
this.nodes.push(node);
|
|
285
|
+
// Add containment edge from file
|
|
286
|
+
this.edges.push({
|
|
287
|
+
source: fileNodeId,
|
|
288
|
+
target: nodeId,
|
|
289
|
+
kind: 'contains',
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get the line number for a character index
|
|
295
|
+
*/
|
|
296
|
+
getLineNumber(index) {
|
|
297
|
+
const substring = this.source.substring(0, index);
|
|
298
|
+
return (substring.match(/\n/g) || []).length + 1;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Get the character index of the start of a line
|
|
302
|
+
*/
|
|
303
|
+
getLineStart(lineNumber) {
|
|
304
|
+
const lines = this.source.split('\n');
|
|
305
|
+
let index = 0;
|
|
306
|
+
for (let i = 0; i < lineNumber - 1 && i < lines.length; i++) {
|
|
307
|
+
index += lines[i].length + 1; // +1 for newline
|
|
308
|
+
}
|
|
309
|
+
return index;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
exports.LiquidExtractor = LiquidExtractor;
|
|
313
|
+
//# sourceMappingURL=liquid-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liquid-extractor.js","sourceRoot":"","sources":["../../src/extraction/liquid-extractor.ts"],"names":[],"mappings":";;;AACA,+DAAuD;AAEvD;;;;;;;;GAQG;AACH,MAAa,eAAe;IAClB,QAAQ,CAAS;IACjB,MAAM,CAAS;IACf,KAAK,GAAW,EAAE,CAAC;I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,CAAC,IAAI,CAAC;gBACd,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,UAAU;aACjB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,KAAa;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;QAClD,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IACnD,CAAC;IAED;;OAEG;IACK,YAAY,CAAC,UAAkB;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC5D,KAAK,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,iBAAiB;QAClD,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnVD,0CAmVC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-worker.d.ts","sourceRoot":"","sources":["../../src/extraction/parse-worker.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Parse Worker
|
|
4
|
+
*
|
|
5
|
+
* Runs tree-sitter parsing in a separate thread so the main thread
|
|
6
|
+
* stays unblocked and the UI animation renders smoothly.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const worker_threads_1 = require("worker_threads");
|
|
10
|
+
const tree_sitter_1 = require("./tree-sitter");
|
|
11
|
+
const grammars_1 = require("./grammars");
|
|
12
|
+
const PARSER_RESET_INTERVAL = 5000;
|
|
13
|
+
const parseCounts = new Map();
|
|
14
|
+
worker_threads_1.parentPort.on('message', async (msg) => {
|
|
15
|
+
if (msg.type === 'load-grammars') {
|
|
16
|
+
await (0, grammars_1.loadGrammarsForLanguages)(msg.languages);
|
|
17
|
+
worker_threads_1.parentPort.postMessage({ type: 'grammars-loaded' });
|
|
18
|
+
}
|
|
19
|
+
else if (msg.type === 'parse') {
|
|
20
|
+
const { id, filePath, content } = msg;
|
|
21
|
+
try {
|
|
22
|
+
const language = (0, grammars_1.detectLanguage)(filePath, content);
|
|
23
|
+
const result = (0, tree_sitter_1.extractFromSource)(filePath, content, language);
|
|
24
|
+
// Periodic parser reset to reclaim WASM heap memory
|
|
25
|
+
const count = (parseCounts.get(language) ?? 0) + 1;
|
|
26
|
+
parseCounts.set(language, count);
|
|
27
|
+
if (count % PARSER_RESET_INTERVAL === 0) {
|
|
28
|
+
(0, grammars_1.resetParser)(language);
|
|
29
|
+
}
|
|
30
|
+
worker_threads_1.parentPort.postMessage({ type: 'parse-result', id, result });
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
34
|
+
// WASM memory errors leave the module in a corrupted state — all
|
|
35
|
+
// subsequent parses would also fail (cascading failures). Crash the
|
|
36
|
+
// worker so the main thread spawns a fresh one with a clean heap.
|
|
37
|
+
if (message.includes('memory access out of bounds') || message.includes('out of memory')) {
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
worker_threads_1.parentPort.postMessage({
|
|
41
|
+
type: 'parse-result',
|
|
42
|
+
id,
|
|
43
|
+
result: {
|
|
44
|
+
nodes: [],
|
|
45
|
+
edges: [],
|
|
46
|
+
unresolvedReferences: [],
|
|
47
|
+
errors: [{ message: `Parse worker error: ${message}`, filePath: filePath, severity: 'error', code: 'parse_error' }],
|
|
48
|
+
durationMs: 0,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (msg.type === 'shutdown') {
|
|
54
|
+
worker_threads_1.parentPort.postMessage({ type: 'shutdown-ack' });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=parse-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-worker.js","sourceRoot":"","sources":["../../src/extraction/parse-worker.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,mDAA4C;AAC5C,+CAAkD;AAClD,yCAAmF;AAGnF,MAAM,qBAAqB,GAAG,IAAI,CAAC;AACnC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAoB,CAAC;AAEhD,2BAAW,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,GAA+F,EAAE,EAAE;IAClI,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;QACjC,MAAM,IAAA,mCAAwB,EAAC,GAAG,CAAC,SAAU,CAAC,CAAC;QAC/C,2BAAW,CAAC,WAAW,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;IACvD,CAAC;SAAM,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAChC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAA,yBAAc,EAAC,QAAS,EAAE,OAAO,CAAC,CAAC;YACpD,MAAM,MAAM,GAAqB,IAAA,+BAAiB,EAAC,QAAS,EAAE,OAAQ,EAAE,QAAQ,CAAC,CAAC;YAElF,oDAAoD;YACpD,MAAM,KAAK,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;YACnD,WAAW,CAAC,GAAG,CAAC,Q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2
|
+
/**
|
|
3
|
+
* SvelteExtractor - Extracts code relationships from Svelte component files
|
|
4
|
+
*
|
|
5
|
+
* Svelte files are multi-language (script + template + style). Rather than
|
|
6
|
+
* parsing the full Svelte grammar, we extract the <script> block content
|
|
7
|
+
* and delegate it to the TypeScript/JavaScript TreeSitterExtractor.
|
|
8
|
+
*
|
|
9
|
+
* Also extracts function calls from template expressions (`{fn(...)}`) so
|
|
10
|
+
* cross-file call edges are captured even when calls live in markup.
|
|
11
|
+
*
|
|
12
|
+
* Every .svelte file produces a component node (Svelte components are always importable).
|
|
13
|
+
*/
|
|
14
|
+
export declare class SvelteExtractor {
|
|
15
|
+
private filePath;
|
|
16
|
+
private source;
|
|
17
|
+
private nodes;
|
|
18
|
+
private edges;
|
|
19
|
+
private unresolvedReferences;
|
|
20
|
+
private errors;
|
|
21
|
+
constructor(filePath: string, source: string);
|
|
22
|
+
/**
|
|
23
|
+
* Extract from Svelte source
|
|
24
|
+
*/
|
|
25
|
+
extract(): ExtractionResult;
|
|
26
|
+
/**
|
|
27
|
+
* Create a component node for the .svelte file
|
|
28
|
+
*/
|
|
29
|
+
private createComponentNode;
|
|
30
|
+
/**
|
|
31
|
+
* Extract <script> blocks from the Svelte source
|
|
32
|
+
*/
|
|
33
|
+
private extractScriptBlocks;
|
|
34
|
+
/**
|
|
35
|
+
* Process a script block by delegating to TreeSitterExtractor
|
|
36
|
+
*/
|
|
37
|
+
private processScriptBlock;
|
|
38
|
+
/**
|
|
39
|
+
* Extract function calls from Svelte template expressions.
|
|
40
|
+
*
|
|
41
|
+
* In Svelte, many function calls happen in markup (e.g., `class={cn(...)}`),
|
|
42
|
+
* not inside `<script>` blocks. We scan the template portion for `{expression}`
|
|
43
|
+
* blocks and extract call patterns from them.
|
|
44
|
+
*/
|
|
45
|
+
private extractTemplateCalls;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=svelte-extractor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svelte-extractor.d.ts","sourceRoot":"","sources":["../../src/extraction/svelte-extractor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,gBAAgB,EAAkD,MAAM,UAAU,CAAC;AAWxG;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,oBAAoB,CAA6B;IACzD,OAAO,CAAC,MAAM,CAAyB;gBAE3B,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK5C;;OAEG;IACH,OAAO,IAAI,gBAAgB;IAsC3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAyB3B;;OAEG;IACH,OAAO,CAAC,mBAAmB;IA6C3B;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA4D1B;;;;;;OAMG;IACH,OAAO,CAAC,oBAAoB;CAoD7B"}
|