@travetto/runtime 8.0.0-alpha.19 → 8.0.0-alpha.20
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/README.md +23 -20
- package/__index__.ts +6 -5
- package/package.json +3 -3
- package/src/binary-metadata.ts +33 -19
- package/src/binary.ts +18 -10
- package/src/codec.ts +6 -6
- package/src/console.ts +20 -12
- package/src/context.ts +18 -15
- package/src/debug.ts +1 -2
- package/src/env.ts +40 -20
- package/src/error.ts +4 -15
- package/src/exec.ts +30 -28
- package/src/file-loader.ts +2 -3
- package/src/function.ts +14 -6
- package/src/json.ts +42 -22
- package/src/manifest-index.ts +1 -1
- package/src/queue.ts +1 -2
- package/src/resources.ts +1 -1
- package/src/shutdown.ts +21 -14
- package/src/time.ts +54 -19
- package/src/types.ts +29 -25
- package/src/util.ts +20 -22
- package/src/watch.ts +21 -17
- package/support/patch.js +11 -4
- package/support/transformer/metadata.ts +15 -28
- package/support/transformer.concrete-type.ts +19 -21
- package/support/transformer.console-log.ts +13 -19
- package/support/transformer.debug-method.ts +13 -9
- package/support/transformer.dynamic-import.ts +1 -2
- package/support/transformer.function-metadata.ts +6 -4
- package/support/transformer.rewrite-path-import.ts +9 -12
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { CoreUtil, TransformerHandler, type TransformerState } from '@travetto/transformer';
|
|
4
4
|
|
|
5
5
|
import type { FunctionMetadataTag } from '../src/function.ts';
|
|
6
6
|
import { MetadataRegistrationUtil } from './transformer/metadata.ts';
|
|
@@ -17,7 +17,6 @@ interface MetadataInfo {
|
|
|
17
17
|
* Providing metadata for classes
|
|
18
18
|
*/
|
|
19
19
|
export class RegisterTransformer {
|
|
20
|
-
|
|
21
20
|
static {
|
|
22
21
|
TransformerHandler(this, this.collectClassMetadata, 'before', 'class');
|
|
23
22
|
TransformerHandler(this, this.collectMethodMetadata, 'before', 'method');
|
|
@@ -64,7 +63,10 @@ export class RegisterTransformer {
|
|
|
64
63
|
/**
|
|
65
64
|
* Register proper functions
|
|
66
65
|
*/
|
|
67
|
-
static registerFunctionMetadata(
|
|
66
|
+
static registerFunctionMetadata(
|
|
67
|
+
state: TransformerState & MetadataInfo,
|
|
68
|
+
node: ts.FunctionDeclaration | ts.FunctionExpression
|
|
69
|
+
): typeof node {
|
|
68
70
|
if (!MetadataRegistrationUtil.isValid(state) || !ts.isFunctionDeclaration(node)) {
|
|
69
71
|
return node;
|
|
70
72
|
}
|
|
@@ -74,4 +76,4 @@ export class RegisterTransformer {
|
|
|
74
76
|
}
|
|
75
77
|
return node;
|
|
76
78
|
}
|
|
77
|
-
}
|
|
79
|
+
}
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
2
|
|
|
3
|
-
import { type TransformerState
|
|
3
|
+
import { TransformerHandler, type TransformerState } from '@travetto/transformer';
|
|
4
4
|
|
|
5
5
|
const PATH_IMPORT = '@travetto/manifest/src/path.ts';
|
|
6
6
|
|
|
7
7
|
const isImport = (node: ts.Node): node is ts.ImportDeclaration =>
|
|
8
|
-
ts.isImportDeclaration(node)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
node.moduleSpecifier.text === 'node:path'
|
|
12
|
-
|| node.moduleSpecifier.text === 'path'
|
|
13
|
-
);
|
|
8
|
+
ts.isImportDeclaration(node) &&
|
|
9
|
+
ts.isStringLiteral(node.moduleSpecifier) &&
|
|
10
|
+
(node.moduleSpecifier.text === 'node:path' || node.moduleSpecifier.text === 'path');
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Rewriting path imports to use manifest's path
|
|
17
14
|
*/
|
|
18
15
|
export class PathImportTransformer {
|
|
19
|
-
|
|
20
16
|
static {
|
|
21
17
|
TransformerHandler(this, this.rewritePathImport, 'before', 'file');
|
|
22
18
|
}
|
|
@@ -31,10 +27,11 @@ export class PathImportTransformer {
|
|
|
31
27
|
state.factory.createStringLiteral(PATH_IMPORT),
|
|
32
28
|
statement.attributes
|
|
33
29
|
);
|
|
34
|
-
return state.factory.updateSourceFile(
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
return state.factory.updateSourceFile(
|
|
31
|
+
node,
|
|
32
|
+
node.statements.map(item => (item === statement ? updated : item))
|
|
33
|
+
);
|
|
37
34
|
}
|
|
38
35
|
return node;
|
|
39
36
|
}
|
|
40
|
-
}
|
|
37
|
+
}
|