@elliots/typical 0.2.3 → 0.2.5
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/README.md +102 -33
- package/bin/typical +0 -0
- package/dist/src/cli.js +15 -15
- package/dist/src/cli.js.map +1 -1
- package/dist/src/config.d.ts +0 -7
- package/dist/src/config.js +6 -7
- package/dist/src/config.js.map +1 -1
- package/dist/src/esm-loader-register.js +2 -2
- package/dist/src/esm-loader-register.js.map +1 -1
- package/dist/src/esm-loader.js +11 -11
- package/dist/src/esm-loader.js.map +1 -1
- package/dist/src/index.d.ts +5 -5
- package/dist/src/index.js +3 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/timing.d.ts +18 -11
- package/dist/src/timing.js +39 -51
- package/dist/src/timing.js.map +1 -1
- package/dist/src/transformer.d.ts +3 -3
- package/dist/src/transformer.js +8 -8
- package/dist/src/transformer.js.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +31 -31
- package/src/config.ts +28 -36
- package/src/esm-loader-register.ts +2 -2
- package/src/esm-loader.ts +26 -26
- package/src/index.ts +5 -5
- package/src/patch-fs.cjs +14 -14
- package/src/timing.ts +43 -57
- package/src/transformer.ts +35 -30
- package/dist/src/cli.typical.ts +0 -136
- package/dist/src/config.typical.ts +0 -287
- package/dist/src/file-filter.d.ts +0 -13
- package/dist/src/file-filter.js +0 -42
- package/dist/src/file-filter.js.map +0 -1
- package/dist/src/program-manager.d.ts +0 -27
- package/dist/src/program-manager.js +0 -121
- package/dist/src/program-manager.js.map +0 -1
- package/dist/src/regex-hoister.d.ts +0 -11
- package/dist/src/regex-hoister.js +0 -150
- package/dist/src/regex-hoister.js.map +0 -1
- package/dist/src/setup.d.ts +0 -2
- package/dist/src/setup.js +0 -20
- package/dist/src/setup.js.map +0 -1
- package/dist/src/source-map.d.ts +0 -78
- package/dist/src/source-map.js +0 -133
- package/dist/src/source-map.js.map +0 -1
- package/dist/src/source-map.typical.ts +0 -216
- package/dist/src/transformer.typical.ts +0 -2552
- package/dist/src/tsc-plugin.d.ts +0 -10
- package/dist/src/tsc-plugin.js +0 -13
- package/dist/src/tsc-plugin.js.map +0 -1
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/README.md
CHANGED
|
@@ -294,7 +294,6 @@ Create a `typical.json` file in your project root (optional):
|
|
|
294
294
|
| `validateCasts` | `false` | Validate type assertions (`as Type`) |
|
|
295
295
|
| `transformJSONParse` | `true` | Transform `JSON.parse` to validate and filter to typed properties |
|
|
296
296
|
| `transformJSONStringify` | `true` | Transform `JSON.stringify` to only include typed properties |
|
|
297
|
-
| `reusableValidators` | `true` | Hoist validators to module scope for reduced code size |
|
|
298
297
|
|
|
299
298
|
---
|
|
300
299
|
|
|
@@ -357,6 +356,50 @@ The generated validation code is optimised for runtime performance:
|
|
|
357
356
|
- **Union early bail-out** - Union type checks use if-else chains so the first matching type succeeds immediately
|
|
358
357
|
- **Skip comments** - Add `// @typical-ignore` before a function to skip all validation for it
|
|
359
358
|
|
|
359
|
+
## VSCode Extension
|
|
360
|
+
|
|
361
|
+
A VSCode extension is available that shows runtime validation indicators directly in your editor. It's not yet published to the marketplace, but you can build and install it locally.
|
|
362
|
+
|
|
363
|
+
### Features
|
|
364
|
+
|
|
365
|
+
- **Subtle underlines** on validated parameters, return values, type casts, and JSON operations
|
|
366
|
+
- Green dotted underline = validated at runtime
|
|
367
|
+
- Grey dotted underline = skipped (e.g., generic types)
|
|
368
|
+
- **Hover tooltips** explaining what's being validated and why
|
|
369
|
+
- **Optional inlay hints** showing validation status inline
|
|
370
|
+
- **Preview command** to see the compiled output with validation code
|
|
371
|
+
|
|
372
|
+
### Building and Installing
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Navigate to the extension directory
|
|
376
|
+
cd packages/vscode-extension
|
|
377
|
+
|
|
378
|
+
# Install dependencies
|
|
379
|
+
pnpm install
|
|
380
|
+
|
|
381
|
+
# Build and package the extension
|
|
382
|
+
pnpm run build
|
|
383
|
+
pnpm run package
|
|
384
|
+
|
|
385
|
+
# Install the .vsix file
|
|
386
|
+
code --install-extension typical-vscode-0.0.1.vsix
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Or use the convenience script:
|
|
390
|
+
|
|
391
|
+
```bash
|
|
392
|
+
cd packages/vscode-extension
|
|
393
|
+
pnpm run dev-install
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Requirements
|
|
397
|
+
|
|
398
|
+
- Your project must have `@elliots/typical` or `@elliots/typical-compiler` as a dependency
|
|
399
|
+
- The extension uses the compiler binary from your project's `node_modules`
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
360
403
|
## Debugging
|
|
361
404
|
|
|
362
405
|
Set `DEBUG=1` for verbose logging:
|
|
@@ -367,10 +410,42 @@ DEBUG=1 npm run build
|
|
|
367
410
|
|
|
368
411
|
## Limitations
|
|
369
412
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
413
|
+
### Types that cannot be validated at runtime
|
|
414
|
+
|
|
415
|
+
These TypeScript features have no runtime representation and are skipped:
|
|
416
|
+
|
|
417
|
+
| Feature | Why | Example |
|
|
418
|
+
| ----------------------- | -------------------------------- | -------------------------------------- |
|
|
419
|
+
| Generic type parameters | No runtime type info for `T` | `function process<T>(x: T): T` |
|
|
420
|
+
| Conditional types | Compile-time only | `T extends string ? A : B` |
|
|
421
|
+
| `infer` keyword | Compile-time type inference | `T extends Array<infer U> ? U : never` |
|
|
422
|
+
| `keyof` operator | Compile-time key extraction | `keyof User` |
|
|
423
|
+
| Indexed access types | Compile-time type lookup | `User['name']` |
|
|
424
|
+
| Unique symbols | Symbol identity not checkable | `declare const id: unique symbol` |
|
|
425
|
+
| Index signature values | Would require iterating all keys | `{ [key: string]: number }` |
|
|
426
|
+
|
|
427
|
+
### Other limitations
|
|
428
|
+
|
|
429
|
+
- **Type-only imports** - `import type { MyClass }` can't use instanceof (class doesn't exist at runtime)
|
|
430
|
+
- **Function signatures** - Only validates `typeof === 'function'`, not parameter/return types
|
|
431
|
+
- **Function overloads** - Validates the implementation signature, not individual overload signatures
|
|
432
|
+
- **Complex library types** - DOM types, React types, etc. may exceed complexity limits (configurable via `maxGeneratedFunctions`)
|
|
433
|
+
|
|
434
|
+
### What IS validated
|
|
435
|
+
|
|
436
|
+
Despite these limitations, Typical validates most practical TypeScript patterns:
|
|
437
|
+
|
|
438
|
+
- All primitive types (string, number, boolean, bigint, symbol, null, undefined)
|
|
439
|
+
- Object properties and nested objects
|
|
440
|
+
- Arrays and tuples (including variadic tuples)
|
|
441
|
+
- Union and intersection types
|
|
442
|
+
- Literal types and template literal types
|
|
443
|
+
- Enums (string and numeric)
|
|
444
|
+
- Utility types (Partial, Required, Pick, Omit, Record, Extract, Exclude)
|
|
445
|
+
- Mapped and conditional types (when resolved to concrete types)
|
|
446
|
+
- Branded/opaque types (validates the underlying primitive)
|
|
447
|
+
- Class instances (via instanceof)
|
|
448
|
+
- Built-in types (Date, Map, Set, URL, Error, etc.)
|
|
374
449
|
|
|
375
450
|
---
|
|
376
451
|
|
|
@@ -378,34 +453,28 @@ DEBUG=1 npm run build
|
|
|
378
453
|
|
|
379
454
|
Runtime validation performance comparing Typical vs Zod vs no validation:
|
|
380
455
|
|
|
381
|
-
| Scenario | Nothing | Typical | Zod |
|
|
382
|
-
| ---------------------------------- | --------: | --------: | --------: |
|
|
383
|
-
| string | 23.91M/s | 24.86M/s | 24.80M/s |
|
|
384
|
-
| number | 24.33M/s | 25.44M/s | 24.44M/s |
|
|
385
|
-
| boolean | 24.49M/s | 24.49M/s | 24.19M/s |
|
|
386
|
-
| object w/ template literals | 24.53M/s | 21.39M/s | 7.71M/s |
|
|
387
|
-
| nested w/ template literals | 24.69M/s | 8.05M/s | 2.31M/s |
|
|
388
|
-
| array w/ templates (10) | 29.89M/s | 7.10M/s | 1.54M/s |
|
|
389
|
-
| array w/ templates (100) | 30.18M/s | 795.31K/s | 150.09K/s |
|
|
390
|
-
| union types | 29.77M/s | 30.69M/s | 10.76M/s |
|
|
391
|
-
| template literals | 30.09M/s | 17.23M/s | 1.71M/s |
|
|
392
|
-
| complex config | 30.56M/s | 29.14M/s | 3.51M/s |
|
|
393
|
-
| JSON.parse (small) | 4.61M/s | 4.37M/s | 3.85M/s |
|
|
394
|
-
| JSON.parse (small+filtered extras) | 4.65M/s | 4.32M/s | 3.79M/s |
|
|
395
|
-
| JSON.parse (medium) | 2.85M/s | 2.26M/s | 928.42K/s |
|
|
396
|
-
| JSON.parse (large) | 209.41K/s | 186.91K/s | 99.28K/s |
|
|
397
|
-
| JSON.parse (1000 large) | 211/s | 212/s | 104/s |
|
|
398
|
-
| JSON.stringify (small) | 9.99M/s | 9.30M/s | 6.70M/s |
|
|
399
|
-
| JSON.stringify (small+extras) | 2.85M/s | 9.20M/s | 6.98M/s |
|
|
400
|
-
| JSON.stringify (medium) | 5.09M/s | 3.82M/s | 1.16M/s |
|
|
401
|
-
| JSON.stringify (large) | 392.53K/s | 330.45K/s | 132.50K/s |
|
|
402
|
-
| JSON.stringify (1000 large) | 362/s | 339/s | 128/s |
|
|
456
|
+
| Scenario | Nothing | Typical | Zod | vs Nothing | vs Zod |
|
|
457
|
+
| ---------------------------------- | --------: | --------: | --------: | ---------: | -------: |
|
|
458
|
+
| string | 23.91M/s | 24.86M/s | 24.80M/s | 🟡 1.0x | 🟡 1.0x |
|
|
459
|
+
| number | 24.33M/s | 25.44M/s | 24.44M/s | 🟡 1.0x | 🟡 1.0x |
|
|
460
|
+
| boolean | 24.49M/s | 24.49M/s | 24.19M/s | 🟡 1.0x | 🟡 1.0x |
|
|
461
|
+
| object w/ template literals | 24.53M/s | 21.39M/s | 7.71M/s | 🟡 0.9x | 🟢 2.8x |
|
|
462
|
+
| nested w/ template literals | 24.69M/s | 8.05M/s | 2.31M/s | 🔴 0.3x | 🟢 3.5x |
|
|
463
|
+
| array w/ templates (10) | 29.89M/s | 7.10M/s | 1.54M/s | 🔴 0.2x | 🟢 4.6x |
|
|
464
|
+
| array w/ templates (100) | 30.18M/s | 795.31K/s | 150.09K/s | 🔴 0.0x | 🟢 5.3x |
|
|
465
|
+
| union types | 29.77M/s | 30.69M/s | 10.76M/s | 🟡 1.0x | 🟢 2.9x |
|
|
466
|
+
| template literals | 30.09M/s | 17.23M/s | 1.71M/s | 🔴 0.6x | 🟢 10.1x |
|
|
467
|
+
| complex config | 30.56M/s | 29.14M/s | 3.51M/s | 🟡 1.0x | 🟢 8.3x |
|
|
468
|
+
| JSON.parse (small) | 4.61M/s | 4.37M/s | 3.85M/s | 🟡 0.9x | 🟢 1.1x |
|
|
469
|
+
| JSON.parse (small+filtered extras) | 4.65M/s | 4.32M/s | 3.79M/s | 🟡 0.9x | 🟢 1.1x |
|
|
470
|
+
| JSON.parse (medium) | 2.85M/s | 2.26M/s | 928.42K/s | 🔴 0.8x | 🟢 2.4x |
|
|
471
|
+
| JSON.parse (large) | 209.41K/s | 186.91K/s | 99.28K/s | 🟡 0.9x | 🟢 1.9x |
|
|
472
|
+
| JSON.parse (1000 large) | 211/s | 212/s | 104/s | 🟡 1.0x | 🟢 2.0x |
|
|
473
|
+
| JSON.stringify (small) | 9.99M/s | 9.30M/s | 6.70M/s | 🟡 0.9x | 🟢 1.4x |
|
|
474
|
+
| JSON.stringify (small+extras) | 2.85M/s | 9.20M/s | 6.98M/s | 🟢 3.2x | 🟢 1.3x |
|
|
475
|
+
| JSON.stringify (medium) | 5.09M/s | 3.82M/s | 1.16M/s | 🔴 0.8x | 🟢 3.3x |
|
|
476
|
+
| JSON.stringify (large) | 392.53K/s | 330.45K/s | 132.50K/s | 🔴 0.8x | 🟢 2.5x |
|
|
477
|
+
| JSON.stringify (1000 large) | 362/s | 339/s | 128/s | 🟡 0.9x | 🟢 2.7x |
|
|
403
478
|
|
|
404
479
|
- **vs Nothing**: Speed relative to no validation or filtering (1.0x = same speed)
|
|
405
480
|
- **vs Zod**: Speed relative to Zod (1.0x = same speed)
|
|
406
|
-
|
|
407
|
-
Key findings:
|
|
408
|
-
|
|
409
|
-
- Primitives and simple types have near-zero overhead
|
|
410
|
-
- Typical is **2-10x faster than Zod** for complex types
|
|
411
|
-
- JSON operations have minimal overhead while providing full type safety
|
package/bin/typical
CHANGED
|
Binary file
|
package/dist/src/cli.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Command } from
|
|
3
|
-
import * as fs from
|
|
4
|
-
import * as path from
|
|
5
|
-
import { TypicalTransformer } from
|
|
6
|
-
import { loadConfig, validateConfig } from
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
import * as fs from "fs";
|
|
4
|
+
import * as path from "path";
|
|
5
|
+
import { TypicalTransformer } from "./transformer.js";
|
|
6
|
+
import { loadConfig, validateConfig } from "./config.js";
|
|
7
7
|
const program = new Command();
|
|
8
|
-
program.name(
|
|
8
|
+
program.name("typical").description("Runtime safe TypeScript transformer").version("0.1.0");
|
|
9
9
|
program
|
|
10
|
-
.command(
|
|
11
|
-
.description(
|
|
12
|
-
.argument(
|
|
13
|
-
.option(
|
|
14
|
-
.option(
|
|
15
|
-
.option(
|
|
10
|
+
.command("transform")
|
|
11
|
+
.description("Transform a TypeScript file with runtime validation")
|
|
12
|
+
.argument("<file>", "TypeScript file to transform")
|
|
13
|
+
.option("-o, --output <file>", "Output file")
|
|
14
|
+
.option("-c, --config <file>", "Config file path", "typical.json")
|
|
15
|
+
.option("-p, --project <file>", "TypeScript config file path", "tsconfig.json")
|
|
16
16
|
.action(async (file, options) => {
|
|
17
17
|
let transformer = null;
|
|
18
18
|
try {
|
|
@@ -23,14 +23,14 @@ program
|
|
|
23
23
|
process.exit(1);
|
|
24
24
|
}
|
|
25
25
|
console.log(`Transforming ${file}...`);
|
|
26
|
-
const result = await transformer.transform(path.resolve(file),
|
|
26
|
+
const result = await transformer.transform(path.resolve(file), "ts");
|
|
27
27
|
// Determine output file path
|
|
28
|
-
const outputFile = options.output ? path.resolve(options.output) : file +
|
|
28
|
+
const outputFile = options.output ? path.resolve(options.output) : file + ".transformed.ts";
|
|
29
29
|
fs.writeFileSync(outputFile, result.code);
|
|
30
30
|
console.log(`Transformed code written to ${outputFile}`);
|
|
31
31
|
}
|
|
32
32
|
catch (error) {
|
|
33
|
-
console.error(
|
|
33
|
+
console.error("Transformation failed:", error);
|
|
34
34
|
process.exit(1);
|
|
35
35
|
}
|
|
36
36
|
finally {
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js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mB,IAAI,EAAE,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,KAAK,CAAC,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;QAErE,6BAA6B;QAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAE5F,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1C,OAAO,CAAC,GAAG,CAAC,+BAA+B,UAAU,EAAE,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;YAAS,CAAC;QACT,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,WAAW,CAAC,KAAK,EAAE,CAAC;QAC5B,CAAC;IACH,CAAC;AACH,CAAC,CACF,CAAC;AAEJ,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/src/config.d.ts
CHANGED
|
@@ -21,13 +21,6 @@ export interface TypicalSourceMapConfig {
|
|
|
21
21
|
export interface TypicalConfig {
|
|
22
22
|
include?: string[];
|
|
23
23
|
exclude?: string[];
|
|
24
|
-
/**
|
|
25
|
-
* Controls whether validators are hoisted to module scope for reuse.
|
|
26
|
-
* - 'auto' (default): Hoist only validators used more than once
|
|
27
|
-
* - 'never': Never hoist, always generate inline validators
|
|
28
|
-
* - 'always': Always hoist validators, even if only used once
|
|
29
|
-
*/
|
|
30
|
-
reusableValidators?: 'auto' | 'never' | 'always';
|
|
31
24
|
validateCasts?: boolean;
|
|
32
25
|
hoistRegex?: boolean;
|
|
33
26
|
debug?: TypicalDebugConfig;
|
package/dist/src/config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export const defaultConfig = {
|
|
2
|
-
include: [
|
|
3
|
-
exclude: [
|
|
4
|
-
reusableValidators: 'auto', // Hoists validators to module scope for reduced code size
|
|
2
|
+
include: ["**/*.ts", "**/*.tsx"],
|
|
3
|
+
exclude: ["node_modules/**", "**/*.d.ts", "dist/**", "build/**"],
|
|
5
4
|
validateCasts: false,
|
|
6
5
|
validateFunctions: true,
|
|
7
6
|
transformJSONParse: true,
|
|
@@ -16,13 +15,13 @@ export const defaultConfig = {
|
|
|
16
15
|
inline: false,
|
|
17
16
|
},
|
|
18
17
|
};
|
|
19
|
-
import fs from
|
|
20
|
-
import path from
|
|
18
|
+
import fs from "fs";
|
|
19
|
+
import path from "path";
|
|
21
20
|
export function loadConfig(configPath) {
|
|
22
|
-
const configFile = configPath || path.join(process.cwd(),
|
|
21
|
+
const configFile = configPath || path.join(process.cwd(), "typical.json");
|
|
23
22
|
if (fs.existsSync(configFile)) {
|
|
24
23
|
try {
|
|
25
|
-
const configContent = fs.readFileSync(configFile,
|
|
24
|
+
const configContent = fs.readFileSync(configFile, "utf8");
|
|
26
25
|
const userConfig = JSON.parse(configContent);
|
|
27
26
|
return {
|
|
28
27
|
...defaultConfig,
|
package/dist/src/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAmEA,MAAM,CAAC,MAAM,aAAa,GAAkB;IAC1C,OAAO,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;IAChC,OAAO,EAAE,CAAC,iBAAiB,EAAE,WAAW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
register("./esm-loader.js", { parentURL: import.meta.url });
|
|
3
3
|
//# sourceMappingURL=esm-loader-register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esm-loader-register.js","sourceRoot":"","sources":["../../src/esm-loader-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"esm-loader-register.js","sourceRoot":"","sources":["../../src/esm-loader-register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,QAAQ,CAAC,iBAAiB,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
package/dist/src/esm-loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { fileURLToPath, pathToFileURL } from
|
|
2
|
-
import { existsSync } from
|
|
3
|
-
import { TypicalTransformer } from
|
|
4
|
-
import { loadConfig, validateConfig } from
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from "url";
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import { TypicalTransformer } from "./transformer.js";
|
|
4
|
+
import { loadConfig, validateConfig } from "./config.js";
|
|
5
5
|
const config = validateConfig(loadConfig());
|
|
6
6
|
// Shared transformer - stays alive for the lifetime of the process
|
|
7
7
|
let transformer = null;
|
|
@@ -16,12 +16,12 @@ async function getTransformer() {
|
|
|
16
16
|
*/
|
|
17
17
|
export async function resolve(specifier, context, nextResolve) {
|
|
18
18
|
// Only handle relative imports ending in .js
|
|
19
|
-
if (specifier.startsWith(
|
|
19
|
+
if (specifier.startsWith(".") && specifier.endsWith(".js")) {
|
|
20
20
|
const { parentURL } = context;
|
|
21
21
|
if (parentURL) {
|
|
22
22
|
const parentPath = fileURLToPath(parentURL);
|
|
23
|
-
const dir = parentPath.substring(0, parentPath.lastIndexOf(
|
|
24
|
-
const tsPath = dir +
|
|
23
|
+
const dir = parentPath.substring(0, parentPath.lastIndexOf("/"));
|
|
24
|
+
const tsPath = dir + "/" + specifier.slice(0, -3) + ".ts";
|
|
25
25
|
if (existsSync(tsPath)) {
|
|
26
26
|
return {
|
|
27
27
|
url: pathToFileURL(tsPath).href,
|
|
@@ -37,17 +37,17 @@ export async function resolve(specifier, context, nextResolve) {
|
|
|
37
37
|
* Note: Source maps not yet supported in v2
|
|
38
38
|
*/
|
|
39
39
|
export async function load(url, context, nextLoad) {
|
|
40
|
-
if (!url.endsWith(
|
|
40
|
+
if (!url.endsWith(".ts")) {
|
|
41
41
|
return nextLoad(url, context);
|
|
42
42
|
}
|
|
43
43
|
const filePath = fileURLToPath(url);
|
|
44
44
|
try {
|
|
45
45
|
const t = await getTransformer();
|
|
46
|
-
const result = await t.transform(filePath,
|
|
46
|
+
const result = await t.transform(filePath, "ts");
|
|
47
47
|
// For now, output is TypeScript - need to transpile to JS
|
|
48
48
|
// TODO: Add JS transpilation in Go or here
|
|
49
49
|
// For now, use TypeScript's transpileModule as fallback
|
|
50
|
-
const ts = await import(
|
|
50
|
+
const ts = await import("typescript");
|
|
51
51
|
const transpiled = ts.default.transpileModule(result.code, {
|
|
52
52
|
compilerOptions: {
|
|
53
53
|
module: ts.default.ModuleKind.ESNext,
|
|
@@ -57,7 +57,7 @@ export async function load(url, context, nextLoad) {
|
|
|
57
57
|
fileName: filePath,
|
|
58
58
|
});
|
|
59
59
|
return {
|
|
60
|
-
format:
|
|
60
|
+
format: "module",
|
|
61
61
|
source: transpiled.outputText,
|
|
62
62
|
shortCircuit: true,
|
|
63
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esm-loader.js","sourceRoot":"","sources":["../../src/esm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"esm-loader.js","sourceRoot":"","sources":["../../src/esm-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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|
|
1
|
-
export { TypicalTransformer } from
|
|
2
|
-
export type { TransformResult } from
|
|
3
|
-
export { loadConfig, validateConfig, defaultConfig } from
|
|
4
|
-
export type { TypicalConfig, TypicalSourceMapConfig } from
|
|
5
|
-
export { BuildTimer, buildTimer } from
|
|
1
|
+
export { TypicalTransformer } from "./transformer.js";
|
|
2
|
+
export type { TransformResult } from "./transformer.js";
|
|
3
|
+
export { loadConfig, validateConfig, defaultConfig } from "./config.js";
|
|
4
|
+
export type { TypicalConfig, TypicalSourceMapConfig } from "./config.js";
|
|
5
|
+
export { BuildTimer, buildTimer } from "./timing.js";
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { TypicalTransformer } from
|
|
2
|
-
export { loadConfig, validateConfig, defaultConfig } from
|
|
3
|
-
export { BuildTimer, buildTimer } from
|
|
1
|
+
export { TypicalTransformer } from "./transformer.js";
|
|
2
|
+
export { loadConfig, validateConfig, defaultConfig } from "./config.js";
|
|
3
|
+
export { BuildTimer, buildTimer } from "./timing.js";
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/src/timing.d.ts
CHANGED
|
@@ -1,19 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Simple build timing utility for debugging performance.
|
|
3
3
|
*/
|
|
4
4
|
export declare class BuildTimer {
|
|
5
5
|
private timings;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Reset all timing data.
|
|
8
|
+
*/
|
|
9
9
|
reset(): void;
|
|
10
|
+
/**
|
|
11
|
+
* Start timing a named section.
|
|
12
|
+
*/
|
|
13
|
+
start(name: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* End timing a named section.
|
|
16
|
+
*/
|
|
17
|
+
end(name: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Print a timing report to console.
|
|
20
|
+
*/
|
|
10
21
|
report(prefix?: string): void;
|
|
11
|
-
getTimings(): Map<string, {
|
|
12
|
-
count: number;
|
|
13
|
-
total: number;
|
|
14
|
-
avg: number;
|
|
15
|
-
min: number;
|
|
16
|
-
max: number;
|
|
17
|
-
}>;
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Shared build timer instance.
|
|
25
|
+
*/
|
|
19
26
|
export declare const buildTimer: BuildTimer;
|
package/dist/src/timing.js
CHANGED
|
@@ -1,65 +1,53 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Simple build timing utility for debugging performance.
|
|
3
3
|
*/
|
|
4
4
|
export class BuildTimer {
|
|
5
5
|
timings = new Map();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
end(stage) {
|
|
11
|
-
const start = this.starts.get(stage);
|
|
12
|
-
if (start !== undefined) {
|
|
13
|
-
const duration = performance.now() - start;
|
|
14
|
-
const existing = this.timings.get(stage) ?? [];
|
|
15
|
-
existing.push(duration);
|
|
16
|
-
this.timings.set(stage, existing);
|
|
17
|
-
this.starts.delete(stage);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
6
|
+
/**
|
|
7
|
+
* Reset all timing data.
|
|
8
|
+
*/
|
|
20
9
|
reset() {
|
|
21
10
|
this.timings.clear();
|
|
22
|
-
this.starts.clear();
|
|
23
11
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const max = Math.max(...times);
|
|
35
|
-
const count = times.length;
|
|
36
|
-
totalTime += total;
|
|
37
|
-
console.log(`${stage}:`);
|
|
38
|
-
console.log(` Count: ${count}`);
|
|
39
|
-
console.log(` Total: ${total.toFixed(2)}ms`);
|
|
40
|
-
console.log(` Avg: ${avg.toFixed(2)}ms`);
|
|
41
|
-
console.log(` Min: ${min.toFixed(2)}ms`);
|
|
42
|
-
console.log(` Max: ${max.toFixed(2)}ms`);
|
|
12
|
+
/**
|
|
13
|
+
* Start timing a named section.
|
|
14
|
+
*/
|
|
15
|
+
start(name) {
|
|
16
|
+
const existing = this.timings.get(name);
|
|
17
|
+
if (existing) {
|
|
18
|
+
existing.start = performance.now();
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.timings.set(name, { start: performance.now(), total: 0, count: 0 });
|
|
43
22
|
}
|
|
44
|
-
console.log('─'.repeat(60));
|
|
45
|
-
console.log(`Total transform time: ${totalTime.toFixed(2)}ms`);
|
|
46
|
-
console.log('');
|
|
47
23
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
24
|
+
/**
|
|
25
|
+
* End timing a named section.
|
|
26
|
+
*/
|
|
27
|
+
end(name) {
|
|
28
|
+
const timing = this.timings.get(name);
|
|
29
|
+
if (timing && timing.start > 0) {
|
|
30
|
+
timing.total += performance.now() - timing.start;
|
|
31
|
+
timing.count++;
|
|
32
|
+
timing.start = 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Print a timing report to console.
|
|
37
|
+
*/
|
|
38
|
+
report(prefix = "[typical]") {
|
|
39
|
+
if (this.timings.size === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
console.log(`${prefix} Timing report:`);
|
|
43
|
+
for (const [name, timing] of this.timings) {
|
|
44
|
+
const avg = timing.count > 0 ? timing.total / timing.count : 0;
|
|
45
|
+
console.log(` ${name}: ${timing.total.toFixed(2)}ms total, ${timing.count} calls, ${avg.toFixed(2)}ms avg`);
|
|
59
46
|
}
|
|
60
|
-
return result;
|
|
61
47
|
}
|
|
62
48
|
}
|
|
63
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Shared build timer instance.
|
|
51
|
+
*/
|
|
64
52
|
export const buildTimer = new BuildTimer();
|
|
65
53
|
//# sourceMappingURL=timing.js.map
|
package/dist/src/timing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/timing.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"timing.js","sourceRoot":"","sources":["../../src/timing.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,UAAU;IACb,OAAO,GAAiE,IAAI,GAAG,EAAE,CAAC;IAE1F;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAY;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxC,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,MAAM,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;YAC/B,MAAM,CAAC,KAAK,IAAI,WAAW,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC;YACjD,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,SAAiB,WAAW;QACjC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YAC5B,OAAO;QACT,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,iBAAiB,CAAC,CAAC;QACxC,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/D,OAAO,CAAC,GAAG,CACT,KAAK,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,KAAK,WAAW,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAChG,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,UAAU,EAAE,CAAC"}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* and validation code generation. This class just manages the lifecycle
|
|
6
6
|
* and communication with the Go process.
|
|
7
7
|
*/
|
|
8
|
-
import { type RawSourceMap } from
|
|
9
|
-
import type { TypicalConfig } from
|
|
8
|
+
import { type RawSourceMap } from "@elliots/typical-compiler";
|
|
9
|
+
import type { TypicalConfig } from "./config.js";
|
|
10
10
|
export interface TransformResult {
|
|
11
11
|
code: string;
|
|
12
12
|
map: RawSourceMap | null;
|
|
@@ -30,7 +30,7 @@ export declare class TypicalTransformer {
|
|
|
30
30
|
* @param mode - Output mode: 'ts' returns TypeScript, 'js' would transpile (not yet supported)
|
|
31
31
|
* @returns Transformed code with validation
|
|
32
32
|
*/
|
|
33
|
-
transform(fileName: string, mode?:
|
|
33
|
+
transform(fileName: string, mode?: "ts" | "js"): Promise<TransformResult>;
|
|
34
34
|
/**
|
|
35
35
|
* Close the Go compiler process and release resources.
|
|
36
36
|
* This immediately kills the process without waiting for pending operations.
|