@tsrx/react 0.2.69 → 0.2.71
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/package.json +3 -3
- package/src/index.js +21 -4
- package/types/index.d.ts +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "React compiler built on @tsrx/core",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.71",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"access": "public"
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"esrap": "^2.3.2",
|
|
39
39
|
"zimmerframe": "^1.1.2",
|
|
40
|
-
"@tsrx/core": "0.1.
|
|
41
|
-
"@tsrx/react-runtime": "0.1.
|
|
40
|
+
"@tsrx/core": "0.1.71",
|
|
41
|
+
"@tsrx/react-runtime": "0.1.7"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react": ">=18"
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
/** @import { BaseCompileOptions, CompileError, CompileResult, ParseOptions, VolarMappingsResult } from '@tsrx/core/types' */
|
|
3
3
|
/** @import { NonEmptyString } from '@tsrx/core/types/helpers' */
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
analyzeTsrx,
|
|
7
|
+
createVolarMappingsResult,
|
|
8
|
+
dedupeMappings,
|
|
9
|
+
hasPlatformNamespace,
|
|
10
|
+
parseModule,
|
|
11
|
+
specializePlatform,
|
|
12
|
+
withPlatformTypes,
|
|
13
|
+
} from '@tsrx/core';
|
|
6
14
|
import { transform } from './transform.js';
|
|
7
15
|
|
|
8
16
|
export { isRefProp } from './ref.js';
|
|
@@ -33,11 +41,17 @@ export function compile(source, filename, options) {
|
|
|
33
41
|
const errors = /** @type {CompileError[]} */ ([]);
|
|
34
42
|
const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
|
|
35
43
|
const collect = !!(options?.collect || options?.loose);
|
|
36
|
-
|
|
44
|
+
let ast = parseModule(
|
|
37
45
|
source,
|
|
38
46
|
filename,
|
|
39
47
|
collect ? { collect: true, loose: !!options?.loose, errors, comments } : undefined,
|
|
40
48
|
);
|
|
49
|
+
ast = specializePlatform(
|
|
50
|
+
ast,
|
|
51
|
+
options?.platform,
|
|
52
|
+
filename,
|
|
53
|
+
collect ? { errors, comments } : undefined,
|
|
54
|
+
);
|
|
41
55
|
analyzeTsrx(
|
|
42
56
|
ast,
|
|
43
57
|
filename,
|
|
@@ -64,7 +78,7 @@ export function compile(source, filename, options) {
|
|
|
64
78
|
export function compile_to_volar_mappings(source, filename, options) {
|
|
65
79
|
const errors = /** @type {CompileError[]} */ ([]);
|
|
66
80
|
const comments = /** @type {AST.CommentWithLocation[]} */ ([]);
|
|
67
|
-
|
|
81
|
+
let ast = parseModule(source, filename, {
|
|
68
82
|
...options,
|
|
69
83
|
collect: true,
|
|
70
84
|
loose: !!options?.loose,
|
|
@@ -73,6 +87,8 @@ export function compile_to_volar_mappings(source, filename, options) {
|
|
|
73
87
|
errors,
|
|
74
88
|
comments,
|
|
75
89
|
});
|
|
90
|
+
const uses_platform_flags = hasPlatformNamespace(ast);
|
|
91
|
+
ast = specializePlatform(ast, options?.platform, filename, { errors, comments });
|
|
76
92
|
analyzeTsrx(ast, filename, {
|
|
77
93
|
collect: true,
|
|
78
94
|
loose: !!options?.loose,
|
|
@@ -97,8 +113,9 @@ export function compile_to_volar_mappings(source, filename, options) {
|
|
|
97
113
|
errors,
|
|
98
114
|
});
|
|
99
115
|
|
|
100
|
-
|
|
116
|
+
const deduped = {
|
|
101
117
|
...result,
|
|
102
118
|
mappings: dedupeMappings(result.mappings),
|
|
103
119
|
};
|
|
120
|
+
return uses_platform_flags ? withPlatformTypes(deduped, options?.platform) : deduped;
|
|
104
121
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Program } from 'estree';
|
|
2
2
|
import type { BaseCompileOptions, CompileFn, ParseOptions, VolarCompileFn } from '@tsrx/core/types';
|
|
3
3
|
|
|
4
|
-
export type { RuntimeImportMode } from '@tsrx/core/types';
|
|
4
|
+
export type { Platform, RuntimeImportMode, TsrxPlatformFlags } from '@tsrx/core/types';
|
|
5
5
|
|
|
6
6
|
export function parse(source: string, filename?: string, options?: ParseOptions): Program;
|
|
7
7
|
|