@elliots/typical-tsc-plugin 0.2.3 → 0.2.4
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/LICENSE +21 -0
- package/dist/index.mjs +30 -12
- package/package.json +2 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Elliot Shepherd
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { createRequire } from "node:module";
|
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
5
6
|
import { loadConfig, validateConfig } from "@elliots/typical";
|
|
6
7
|
import deasync from "deasync";
|
|
7
8
|
|
|
@@ -106,12 +107,11 @@ function debugLog(...args) {
|
|
|
106
107
|
if (debug) console.error(...args);
|
|
107
108
|
}
|
|
108
109
|
function getBinaryPath() {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} catch {}
|
|
110
|
+
const devPath = join(__dirname, "../bin/typical");
|
|
111
|
+
if (existsSync(devPath)) {
|
|
112
|
+
debugLog(`[CLIENT] Using development binary at ${devPath}`);
|
|
113
|
+
return devPath;
|
|
114
|
+
}
|
|
115
115
|
const pkgName = `@elliots/typical-compiler-${process.platform}-${process.arch}`;
|
|
116
116
|
const pkg = require(pkgName);
|
|
117
117
|
debugLog(`[CLIENT] Using platform binary from ${pkgName}`);
|
|
@@ -162,14 +162,13 @@ var TypicalCompiler = class {
|
|
|
162
162
|
async loadProject(configFileName) {
|
|
163
163
|
return this.request("loadProject", { configFileName });
|
|
164
164
|
}
|
|
165
|
-
async transformFile(project, fileName, ignoreTypes, maxGeneratedFunctions
|
|
165
|
+
async transformFile(project, fileName, ignoreTypes, maxGeneratedFunctions) {
|
|
166
166
|
const projectId = typeof project === "string" ? project : project.id;
|
|
167
167
|
return this.request("transformFile", {
|
|
168
168
|
project: projectId,
|
|
169
169
|
fileName,
|
|
170
170
|
ignoreTypes,
|
|
171
|
-
maxGeneratedFunctions
|
|
172
|
-
reusableValidators
|
|
171
|
+
maxGeneratedFunctions
|
|
173
172
|
});
|
|
174
173
|
}
|
|
175
174
|
async release(handle) {
|
|
@@ -177,6 +176,26 @@ var TypicalCompiler = class {
|
|
|
177
176
|
await this.request("release", id);
|
|
178
177
|
}
|
|
179
178
|
/**
|
|
179
|
+
* Analyse a file for validation points without transforming it.
|
|
180
|
+
* Returns information about which parameters, returns, and casts will be validated.
|
|
181
|
+
* Used by the VSCode extension to show validation indicators.
|
|
182
|
+
*
|
|
183
|
+
* @param project - Project handle or ID
|
|
184
|
+
* @param fileName - Path to the file to analyse
|
|
185
|
+
* @param content - Optional file content for live updates (uses disk version if not provided)
|
|
186
|
+
* @param ignoreTypes - Optional glob patterns for types to skip
|
|
187
|
+
* @returns Analysis result with validation items
|
|
188
|
+
*/
|
|
189
|
+
async analyseFile(project, fileName, content, ignoreTypes) {
|
|
190
|
+
const projectId = typeof project === "string" ? project : project.id;
|
|
191
|
+
return this.request("analyseFile", {
|
|
192
|
+
project: projectId,
|
|
193
|
+
fileName,
|
|
194
|
+
content,
|
|
195
|
+
ignoreTypes
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
180
199
|
* Transform a standalone TypeScript source string.
|
|
181
200
|
* Creates a temporary project to enable type checking.
|
|
182
201
|
*
|
|
@@ -190,8 +209,7 @@ var TypicalCompiler = class {
|
|
|
190
209
|
fileName,
|
|
191
210
|
source,
|
|
192
211
|
ignoreTypes: options?.ignoreTypes,
|
|
193
|
-
maxGeneratedFunctions: options?.maxGeneratedFunctions
|
|
194
|
-
reusableValidators: options?.reusableValidators
|
|
212
|
+
maxGeneratedFunctions: options?.maxGeneratedFunctions
|
|
195
213
|
});
|
|
196
214
|
}
|
|
197
215
|
async request(method, payload) {
|
|
@@ -241,7 +259,7 @@ function transformFileSync(compiler, project, fileName, config) {
|
|
|
241
259
|
let result;
|
|
242
260
|
let error;
|
|
243
261
|
let done = false;
|
|
244
|
-
compiler.transformFile(project, fileName, config.ignoreTypes, config.maxGeneratedFunctions
|
|
262
|
+
compiler.transformFile(project, fileName, config.ignoreTypes, config.maxGeneratedFunctions).then((res) => {
|
|
245
263
|
result = res.code;
|
|
246
264
|
done = true;
|
|
247
265
|
}, (err) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elliots/typical-tsc-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "TSC plugin for typical - runtime safe TypeScript transformer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"runtime",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@elliots/typical": "0.2.
|
|
45
|
+
"@elliots/typical": "0.2.4",
|
|
46
46
|
"deasync": "0.1.30",
|
|
47
47
|
"strip-json-comments": "5.0.3"
|
|
48
48
|
},
|