Some progress.
This commit is contained in:
@@ -24,11 +24,11 @@ export type CommonDataType =
|
||||
| CommonDataTypes.GraphData;
|
||||
|
||||
export module CommonDataTypes {
|
||||
export interface Text extends ExtractedData {
|
||||
export interface Text {
|
||||
kind: { text: true };
|
||||
text: string;
|
||||
// what should be used here? File type (.ts, .txt) or mime type?
|
||||
fileType?: string;
|
||||
mimeType?: string;
|
||||
fileName?: string;
|
||||
}
|
||||
|
||||
export interface GraphData {
|
||||
@@ -52,7 +52,7 @@ export module CommonDataTypes {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface TreeNodeData extends ExtractedData {
|
||||
export interface TreeNodeData {
|
||||
kind: { tree: true };
|
||||
root: TreeNode<{}>;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ export function selfContainedInitDataExtractorApi(): boolean {
|
||||
.filter(([key, value]) => key.startsWith(prefix))
|
||||
.map(([key, value]) => value as DataExtractor<ExtractedData>);
|
||||
}
|
||||
obj["$asData"] = (x: unknown) => x;
|
||||
obj[key] = api = {
|
||||
registerExtractor(extractor) {
|
||||
obj[prefix + extractor.id] = extractor;
|
||||
|
||||
@@ -18,7 +18,7 @@ export class AsIsDataExtractor implements DataExtractor<ExtractedData> {
|
||||
extractionCollector.addExtraction({
|
||||
id: "as-is",
|
||||
name: "As Is",
|
||||
priority: 100,
|
||||
priority: 500,
|
||||
extractData() {
|
||||
return obj;
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@ import * as ts from "typescript";
|
||||
import { DataExtractor, ExtractionCollector } from "../DataExtractor";
|
||||
import { CommonDataTypes } from "../../CommonDataTypes";
|
||||
|
||||
// This class is self contained and can be injected into both nodejs and browser environments.
|
||||
export class TypeScriptAstDataExtractor
|
||||
implements DataExtractor<CommonDataTypes.AstData> {
|
||||
readonly id = "TypeScriptAst";
|
||||
@@ -83,14 +84,12 @@ export class TypeScriptAstDataExtractor
|
||||
id: memberName,
|
||||
children: children,
|
||||
data: {
|
||||
length: 0,
|
||||
position: 0,
|
||||
length: node.end - node.pos,
|
||||
position: node.pos,
|
||||
},
|
||||
emphasizedValue: emphasizedValueFn(node),
|
||||
isMarked: marked.has(node),
|
||||
value,
|
||||
// startPos: node.pos,
|
||||
// endPos: node.end
|
||||
};
|
||||
}
|
||||
|
||||
@@ -139,7 +138,7 @@ export class TypeScriptAstDataExtractor
|
||||
kind: { text: true, tree: true, ast: true },
|
||||
root: toTreeNode(root, "root", marked, fn),
|
||||
text: root.text,
|
||||
fileType: "ts",
|
||||
fileName: "index.ts",
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user