@elliots/typical-compiler 0.2.0 → 0.2.3
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/client.d.ts +7 -2
- package/dist/client.js +22 -12
- package/dist/protocol.js +1 -1
- package/package.json +7 -7
package/dist/client.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare class TypicalCompiler {
|
|
|
16
16
|
start(): Promise<void>;
|
|
17
17
|
close(): Promise<void>;
|
|
18
18
|
loadProject(configFileName: string): Promise<ProjectHandle>;
|
|
19
|
-
transformFile(project: ProjectHandle | string, fileName: string): Promise<TransformResult>;
|
|
19
|
+
transformFile(project: ProjectHandle | string, fileName: string, ignoreTypes?: string[], maxGeneratedFunctions?: number, reusableValidators?: 'auto' | 'never' | 'always'): Promise<TransformResult>;
|
|
20
20
|
release(handle: ProjectHandle | string): Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* Transform a standalone TypeScript source string.
|
|
@@ -24,9 +24,14 @@ export declare class TypicalCompiler {
|
|
|
24
24
|
*
|
|
25
25
|
* @param fileName - Virtual filename for error messages (e.g., "test.ts")
|
|
26
26
|
* @param source - TypeScript source code
|
|
27
|
+
* @param options - Optional transform options
|
|
27
28
|
* @returns Transformed code with validation
|
|
28
29
|
*/
|
|
29
|
-
transformSource(fileName: string, source: string
|
|
30
|
+
transformSource(fileName: string, source: string, options?: {
|
|
31
|
+
ignoreTypes?: string[];
|
|
32
|
+
maxGeneratedFunctions?: number;
|
|
33
|
+
reusableValidators?: 'auto' | 'never' | 'always';
|
|
34
|
+
}): Promise<TransformResult>;
|
|
30
35
|
private request;
|
|
31
36
|
private handleData;
|
|
32
37
|
}
|
package/dist/client.js
CHANGED
|
@@ -12,20 +12,23 @@ function debugLog(...args) {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
function getBinaryPath() {
|
|
15
|
-
//
|
|
16
|
-
const
|
|
17
|
-
const arch = process.arch; // arm64, x64
|
|
18
|
-
const pkgName = `@elliots/typical-compiler-${platform}-${arch}`;
|
|
15
|
+
// try local binary first (for development)
|
|
16
|
+
const localBinPath = join(__dirname, '..', 'bin', 'typical');
|
|
19
17
|
try {
|
|
20
|
-
|
|
21
|
-
debugLog(`[CLIENT] Using
|
|
22
|
-
return
|
|
18
|
+
require('fs').accessSync(localBinPath);
|
|
19
|
+
debugLog(`[CLIENT] Using local binary at ${localBinPath}`);
|
|
20
|
+
return localBinPath;
|
|
23
21
|
}
|
|
24
22
|
catch {
|
|
25
|
-
//
|
|
26
|
-
debugLog(`[CLIENT] Platform package ${pkgName} not found, falling back to local bin`);
|
|
27
|
-
return join(__dirname, '..', 'bin', 'typical');
|
|
23
|
+
// continue to platform-specific package
|
|
28
24
|
}
|
|
25
|
+
// Then use platform-specific package
|
|
26
|
+
const platform = process.platform; // darwin, linux, win32
|
|
27
|
+
const arch = process.arch; // arm64, x64
|
|
28
|
+
const pkgName = `@elliots/typical-compiler-${platform}-${arch}`;
|
|
29
|
+
const pkg = require(pkgName);
|
|
30
|
+
debugLog(`[CLIENT] Using platform binary from ${pkgName}`);
|
|
31
|
+
return pkg.binaryPath;
|
|
29
32
|
}
|
|
30
33
|
export class TypicalCompiler {
|
|
31
34
|
process = null;
|
|
@@ -80,11 +83,14 @@ export class TypicalCompiler {
|
|
|
80
83
|
async loadProject(configFileName) {
|
|
81
84
|
return this.request('loadProject', { configFileName });
|
|
82
85
|
}
|
|
83
|
-
async transformFile(project, fileName) {
|
|
86
|
+
async transformFile(project, fileName, ignoreTypes, maxGeneratedFunctions, reusableValidators) {
|
|
84
87
|
const projectId = typeof project === 'string' ? project : project.id;
|
|
85
88
|
return this.request('transformFile', {
|
|
86
89
|
project: projectId,
|
|
87
90
|
fileName,
|
|
91
|
+
ignoreTypes,
|
|
92
|
+
maxGeneratedFunctions,
|
|
93
|
+
reusableValidators,
|
|
88
94
|
});
|
|
89
95
|
}
|
|
90
96
|
async release(handle) {
|
|
@@ -97,12 +103,16 @@ export class TypicalCompiler {
|
|
|
97
103
|
*
|
|
98
104
|
* @param fileName - Virtual filename for error messages (e.g., "test.ts")
|
|
99
105
|
* @param source - TypeScript source code
|
|
106
|
+
* @param options - Optional transform options
|
|
100
107
|
* @returns Transformed code with validation
|
|
101
108
|
*/
|
|
102
|
-
async transformSource(fileName, source) {
|
|
109
|
+
async transformSource(fileName, source, options) {
|
|
103
110
|
return this.request('transformSource', {
|
|
104
111
|
fileName,
|
|
105
112
|
source,
|
|
113
|
+
ignoreTypes: options?.ignoreTypes,
|
|
114
|
+
maxGeneratedFunctions: options?.maxGeneratedFunctions,
|
|
115
|
+
reusableValidators: options?.reusableValidators,
|
|
106
116
|
});
|
|
107
117
|
}
|
|
108
118
|
async request(method, payload) {
|
package/dist/protocol.js
CHANGED
|
@@ -36,7 +36,7 @@ export function decodeResponse(data) {
|
|
|
36
36
|
let offset = 0;
|
|
37
37
|
// Check array marker
|
|
38
38
|
if (data[offset++] !== MessagePackTypeFixedArray3) {
|
|
39
|
-
throw new Error(`Expected 0x93, got 0x${data[0].toString(16)}`);
|
|
39
|
+
throw new Error(`Expected 0x93, got 0x${data[0].toString(16)}: first 200 of data: ${data.subarray(0, 200).toString('utf8')}`);
|
|
40
40
|
}
|
|
41
41
|
// Read message type
|
|
42
42
|
if (data[offset++] !== MessagePackTypeU8) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliots/typical-compiler",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "TypeScript compiler powered by tsgo for typical validation",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compiler",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"typescript": "^5.7.0"
|
|
27
27
|
},
|
|
28
28
|
"optionalDependencies": {
|
|
29
|
-
"@elliots/typical-compiler-darwin-arm64": "0.2.
|
|
30
|
-
"@elliots/typical-compiler-darwin-x64": "0.2.
|
|
31
|
-
"@elliots/typical-compiler-linux-arm64": "0.2.
|
|
32
|
-
"@elliots/typical-compiler-linux-x64": "0.2.
|
|
33
|
-
"@elliots/typical-compiler-win32-arm64": "0.2.
|
|
34
|
-
"@elliots/typical-compiler-win32-x64": "0.2.
|
|
29
|
+
"@elliots/typical-compiler-darwin-arm64": "0.2.3",
|
|
30
|
+
"@elliots/typical-compiler-darwin-x64": "0.2.3",
|
|
31
|
+
"@elliots/typical-compiler-linux-arm64": "0.2.3",
|
|
32
|
+
"@elliots/typical-compiler-linux-x64": "0.2.3",
|
|
33
|
+
"@elliots/typical-compiler-win32-arm64": "0.2.3",
|
|
34
|
+
"@elliots/typical-compiler-win32-x64": "0.2.3"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsc",
|