@twohash/core 0.1.0-alpha.1
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/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/twohash.d.ts +5 -0
- package/dist/twohash.d.ts.map +1 -0
- package/dist/twohash.js +109 -0
- package/dist/twohash.js.map +1 -0
- package/dist/types.d.ts +103 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/which.d.ts +2 -0
- package/dist/which.d.ts.map +1 -0
- package/dist/which.js +17 -0
- package/dist/which.js.map +1 -0
- package/package.json +26 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { TwohashResult, TwohashHover, TwohashError, TwohashDisplayPart, TwohashMeta, TwohashOptions, TwohashCompletion, TwohashCompletionItem, TwohashDocComment, TwohashDocParam, TwohashDocException, TwohashHighlight } from './types.js';
|
|
2
|
+
export { createTwohash } from './twohash.js';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,eAAe,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AACjP,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twohash.d.ts","sourceRoot":"","sources":["../src/twohash.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAEtF,wBAAgB,aAAa,CAAC,OAAO,GAAE,cAAmB;oBAkB3B,qBAAqB,KAAG,OAAO,CAAC,aAAa,CAAC;EA6D5E"}
|
package/dist/twohash.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { which } from './which.js';
|
|
4
|
+
export function createTwohash(options = {}) {
|
|
5
|
+
const cache = new Map();
|
|
6
|
+
async function findExecutable() {
|
|
7
|
+
if (options.executable)
|
|
8
|
+
return { command: options.executable };
|
|
9
|
+
const found = await which('twohash');
|
|
10
|
+
if (found)
|
|
11
|
+
return { command: found };
|
|
12
|
+
// Fall back to local dotnet tool
|
|
13
|
+
const dotnet = await which('dotnet');
|
|
14
|
+
if (dotnet && await spawnCheck(dotnet, ['tool', 'list'])) {
|
|
15
|
+
return { command: dotnet, prefix: ['twohash'] };
|
|
16
|
+
}
|
|
17
|
+
throw new Error('twohash CLI not found. Install it with: dotnet tool install -g twohash\n' +
|
|
18
|
+
'Or as a local tool: dotnet tool install twohash --local --add-source .nupkg/');
|
|
19
|
+
}
|
|
20
|
+
async function process(opts) {
|
|
21
|
+
const cacheKey = opts.code
|
|
22
|
+
? createHash('sha256').update(opts.code).digest('hex')
|
|
23
|
+
: opts.file ?? '';
|
|
24
|
+
const cached = cache.get(cacheKey);
|
|
25
|
+
if (cached)
|
|
26
|
+
return cached;
|
|
27
|
+
const args = ['process'];
|
|
28
|
+
if (opts.file) {
|
|
29
|
+
args.push(opts.file);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
args.push('--stdin');
|
|
33
|
+
}
|
|
34
|
+
const framework = opts.framework ?? options.framework;
|
|
35
|
+
if (framework) {
|
|
36
|
+
args.push('--framework', framework);
|
|
37
|
+
}
|
|
38
|
+
if (opts.project) {
|
|
39
|
+
args.push('--project', opts.project);
|
|
40
|
+
}
|
|
41
|
+
if (opts.region) {
|
|
42
|
+
args.push('--region', opts.region);
|
|
43
|
+
}
|
|
44
|
+
if (opts.noRestore) {
|
|
45
|
+
args.push('--no-restore');
|
|
46
|
+
}
|
|
47
|
+
const cacheDir = opts.cacheDir ?? options.cacheDir;
|
|
48
|
+
if (cacheDir) {
|
|
49
|
+
args.push('--cache-dir', cacheDir);
|
|
50
|
+
}
|
|
51
|
+
const configFile = opts.configFile ?? options.configFile;
|
|
52
|
+
if (configFile) {
|
|
53
|
+
args.push('--config', configFile);
|
|
54
|
+
}
|
|
55
|
+
const complog = opts.complog ?? options.complog;
|
|
56
|
+
if (complog) {
|
|
57
|
+
args.push('--complog', complog);
|
|
58
|
+
}
|
|
59
|
+
const complogProject = opts.complogProject ?? options.complogProject;
|
|
60
|
+
if (complogProject) {
|
|
61
|
+
args.push('--complog-project', complogProject);
|
|
62
|
+
}
|
|
63
|
+
const { command, prefix } = await findExecutable();
|
|
64
|
+
const fullArgs = [...(prefix ?? []), ...args];
|
|
65
|
+
const result = await spawnCli(command, fullArgs, opts.code);
|
|
66
|
+
cache.set(cacheKey, result);
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
return { process };
|
|
70
|
+
}
|
|
71
|
+
function spawnCheck(command, args) {
|
|
72
|
+
return new Promise((resolve) => {
|
|
73
|
+
const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'ignore'] });
|
|
74
|
+
let stdout = '';
|
|
75
|
+
child.stdout.on('data', (data) => { stdout += data.toString(); });
|
|
76
|
+
child.on('error', () => resolve(false));
|
|
77
|
+
child.on('close', () => resolve(stdout.includes('twohash')));
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function spawnCli(executable, args, stdin) {
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
const child = spawn(executable, args, { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
83
|
+
let stdout = '';
|
|
84
|
+
let stderr = '';
|
|
85
|
+
child.stdout.on('data', (data) => { stdout += data.toString(); });
|
|
86
|
+
child.stderr.on('data', (data) => { stderr += data.toString(); });
|
|
87
|
+
child.on('error', (err) => {
|
|
88
|
+
reject(new Error(`Failed to spawn twohash CLI: ${err.message}`));
|
|
89
|
+
});
|
|
90
|
+
child.on('close', (code) => {
|
|
91
|
+
if (code !== 0) {
|
|
92
|
+
reject(new Error(`twohash CLI exited with code ${code}:\n${stderr}`));
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
const result = JSON.parse(stdout);
|
|
97
|
+
resolve(result);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
reject(new Error(`twohash CLI produced invalid JSON:\n${stdout}`));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
if (stdin) {
|
|
104
|
+
child.stdin.write(stdin);
|
|
105
|
+
}
|
|
106
|
+
child.stdin.end();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=twohash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twohash.js","sourceRoot":"","sources":["../src/twohash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC,MAAM,UAAU,aAAa,CAAC,UAA0B,EAAE;IACxD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;IAE9C,KAAK,UAAU,cAAc;QAC3B,IAAI,OAAO,CAAC,UAAU;YAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,CAAA;QAC9D,MAAM,KAAK,GAAG,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
|
2
|
+
kind: string;
|
|
3
|
+
text: string;
|
|
4
|
+
}
|
|
5
|
+
export interface TwohashDocParam {
|
|
6
|
+
name: string;
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export interface TwohashDocException {
|
|
10
|
+
type: string;
|
|
11
|
+
text: string;
|
|
12
|
+
}
|
|
13
|
+
export interface TwohashDocComment {
|
|
14
|
+
summary?: string | null;
|
|
15
|
+
params?: TwohashDocParam[];
|
|
16
|
+
returns?: string | null;
|
|
17
|
+
remarks?: string | null;
|
|
18
|
+
examples?: string[];
|
|
19
|
+
exceptions?: TwohashDocException[];
|
|
20
|
+
}
|
|
21
|
+
export interface TwohashHover {
|
|
22
|
+
line: number;
|
|
23
|
+
character: number;
|
|
24
|
+
length: number;
|
|
25
|
+
text: string;
|
|
26
|
+
parts: TwohashDisplayPart[];
|
|
27
|
+
docs: TwohashDocComment | null;
|
|
28
|
+
symbolKind: string;
|
|
29
|
+
targetText: string;
|
|
30
|
+
overloadCount?: number;
|
|
31
|
+
persistent?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export interface TwohashError {
|
|
34
|
+
line: number;
|
|
35
|
+
character: number;
|
|
36
|
+
length: number;
|
|
37
|
+
endLine?: number;
|
|
38
|
+
endCharacter?: number;
|
|
39
|
+
code: string;
|
|
40
|
+
message: string;
|
|
41
|
+
severity: 'error' | 'warning' | 'info' | 'hidden';
|
|
42
|
+
expected: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface TwohashMeta {
|
|
45
|
+
targetFramework: string;
|
|
46
|
+
packages: {
|
|
47
|
+
name: string;
|
|
48
|
+
version: string;
|
|
49
|
+
}[];
|
|
50
|
+
compileSucceeded: boolean;
|
|
51
|
+
sdk?: string | null;
|
|
52
|
+
langVersion?: string | null;
|
|
53
|
+
nullable?: string | null;
|
|
54
|
+
complog?: string | null;
|
|
55
|
+
}
|
|
56
|
+
export interface TwohashCompletionItem {
|
|
57
|
+
label: string;
|
|
58
|
+
kind: string;
|
|
59
|
+
detail: string | null;
|
|
60
|
+
}
|
|
61
|
+
export interface TwohashCompletion {
|
|
62
|
+
line: number;
|
|
63
|
+
character: number;
|
|
64
|
+
items: TwohashCompletionItem[];
|
|
65
|
+
}
|
|
66
|
+
export interface TwohashHighlight {
|
|
67
|
+
line: number;
|
|
68
|
+
character: number;
|
|
69
|
+
length: number;
|
|
70
|
+
kind: 'highlight' | 'focus' | 'add' | 'remove';
|
|
71
|
+
}
|
|
72
|
+
export interface TwohashResult {
|
|
73
|
+
code: string;
|
|
74
|
+
original: string;
|
|
75
|
+
lang: string;
|
|
76
|
+
hovers: TwohashHover[];
|
|
77
|
+
errors: TwohashError[];
|
|
78
|
+
completions: TwohashCompletion[];
|
|
79
|
+
highlights: TwohashHighlight[];
|
|
80
|
+
hidden: unknown[];
|
|
81
|
+
meta: TwohashMeta;
|
|
82
|
+
}
|
|
83
|
+
export interface TwohashOptions {
|
|
84
|
+
executable?: string;
|
|
85
|
+
framework?: string;
|
|
86
|
+
cacheDir?: string;
|
|
87
|
+
configFile?: string;
|
|
88
|
+
complog?: string;
|
|
89
|
+
complogProject?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface TwohashProcessOptions {
|
|
92
|
+
code?: string;
|
|
93
|
+
file?: string;
|
|
94
|
+
framework?: string;
|
|
95
|
+
project?: string;
|
|
96
|
+
region?: string;
|
|
97
|
+
noRestore?: boolean;
|
|
98
|
+
cacheDir?: string;
|
|
99
|
+
configFile?: string;
|
|
100
|
+
complog?: string;
|
|
101
|
+
complogProject?: string;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE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AM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;CACxB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/which.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"which.d.ts","sourceRoot":"","sources":["../src/which.ts"],"names":[],"mappings":"AAGA,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYhE"}
|
package/dist/which.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { access, constants } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
export async function which(name) {
|
|
4
|
+
const pathDirs = (process.env.PATH ?? '').split(':');
|
|
5
|
+
for (const dir of pathDirs) {
|
|
6
|
+
const fullPath = join(dir, name);
|
|
7
|
+
try {
|
|
8
|
+
await access(fullPath, constants.X_OK);
|
|
9
|
+
return fullPath;
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=which.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"which.js","sourceRoot":"","sources":["../src/which.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,IAAY;IACtC,MAAM,QAAQ,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACpD,KAAK,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;QAChC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;YACtC,OAAO,QAAQ,CAAA;QACjB,CAAC;QAAC,MAAM,CAAC;YACP,SAAQ;QACV,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twohash/core",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "Node.js bridge for the twohash C# type extraction CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@types/node": "^25.3.5",
|
|
23
|
+
"typescript": "^5.9.3",
|
|
24
|
+
"vitest": "^4.0.18"
|
|
25
|
+
}
|
|
26
|
+
}
|