@elliots/typical-compiler 0.2.1 → 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 -4
- package/dist/client.js +20 -16
- 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, ignoreTypes?: string[], maxGeneratedFunctions?: number): 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,11 +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
|
|
28
|
-
* @param maxGeneratedFunctions - Max helper functions before error (0 = default 50)
|
|
27
|
+
* @param options - Optional transform options
|
|
29
28
|
* @returns Transformed code with validation
|
|
30
29
|
*/
|
|
31
|
-
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>;
|
|
32
35
|
private request;
|
|
33
36
|
private handleData;
|
|
34
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,13 +83,14 @@ export class TypicalCompiler {
|
|
|
80
83
|
async loadProject(configFileName) {
|
|
81
84
|
return this.request('loadProject', { configFileName });
|
|
82
85
|
}
|
|
83
|
-
async transformFile(project, fileName, ignoreTypes, maxGeneratedFunctions) {
|
|
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,
|
|
88
91
|
ignoreTypes,
|
|
89
92
|
maxGeneratedFunctions,
|
|
93
|
+
reusableValidators,
|
|
90
94
|
});
|
|
91
95
|
}
|
|
92
96
|
async release(handle) {
|
|
@@ -99,16 +103,16 @@ export class TypicalCompiler {
|
|
|
99
103
|
*
|
|
100
104
|
* @param fileName - Virtual filename for error messages (e.g., "test.ts")
|
|
101
105
|
* @param source - TypeScript source code
|
|
102
|
-
* @param
|
|
103
|
-
* @param maxGeneratedFunctions - Max helper functions before error (0 = default 50)
|
|
106
|
+
* @param options - Optional transform options
|
|
104
107
|
* @returns Transformed code with validation
|
|
105
108
|
*/
|
|
106
|
-
async transformSource(fileName, source,
|
|
109
|
+
async transformSource(fileName, source, options) {
|
|
107
110
|
return this.request('transformSource', {
|
|
108
111
|
fileName,
|
|
109
112
|
source,
|
|
110
|
-
ignoreTypes,
|
|
111
|
-
maxGeneratedFunctions,
|
|
113
|
+
ignoreTypes: options?.ignoreTypes,
|
|
114
|
+
maxGeneratedFunctions: options?.maxGeneratedFunctions,
|
|
115
|
+
reusableValidators: options?.reusableValidators,
|
|
112
116
|
});
|
|
113
117
|
}
|
|
114
118
|
async request(method, payload) {
|
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",
|