ripple 0.2.138 → 0.2.139
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 +2 -2
- package/src/compiler/index.js +19 -19
- package/src/compiler/phases/2-analyze/index.js +15 -10
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ripple is an elegant TypeScript UI framework",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.139",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"module": "src/runtime/index-client.js",
|
|
9
9
|
"main": "src/runtime/index-client.js",
|
|
@@ -81,6 +81,6 @@
|
|
|
81
81
|
"typescript": "^5.9.2"
|
|
82
82
|
},
|
|
83
83
|
"peerDependencies": {
|
|
84
|
-
"ripple": "0.2.
|
|
84
|
+
"ripple": "0.2.139"
|
|
85
85
|
}
|
|
86
86
|
}
|
package/src/compiler/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { convert_source_map_to_mappings } from './phases/3-transform/segments.js
|
|
|
12
12
|
* @returns {Program}
|
|
13
13
|
*/
|
|
14
14
|
export function parse(source) {
|
|
15
|
-
|
|
15
|
+
return parse_module(source);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -23,13 +23,13 @@ export function parse(source) {
|
|
|
23
23
|
* @returns {object}
|
|
24
24
|
*/
|
|
25
25
|
export function compile(source, filename, options = {}) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
const ast = parse_module(source);
|
|
27
|
+
const analysis = analyze(ast, filename, options);
|
|
28
|
+
const result = options.mode === 'server'
|
|
29
|
+
? transform_server(filename, source, analysis)
|
|
30
|
+
: transform_client(filename, source, analysis, false);
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
return result;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/** @import { PostProcessingChanges, LineOffsets } from './phases/3-transform/client/index.js' */
|
|
@@ -41,17 +41,17 @@ export function compile(source, filename, options = {}) {
|
|
|
41
41
|
* @returns {object} Volar mappings object
|
|
42
42
|
*/
|
|
43
43
|
export function compile_to_volar_mappings(source, filename) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
const ast = parse_module(source);
|
|
45
|
+
const analysis = analyze(ast, filename, { to_ts: true });
|
|
46
|
+
const transformed = transform_client(filename, source, analysis, true);
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/** @type {PostProcessingChanges} */
|
|
55
|
-
/** @type {LineOffsets} */
|
|
56
|
-
|
|
48
|
+
// Create volar mappings with esrap source map for accurate positioning
|
|
49
|
+
return convert_source_map_to_mappings(
|
|
50
|
+
transformed.ast,
|
|
51
|
+
source,
|
|
52
|
+
transformed.js.code,
|
|
53
|
+
transformed.js.map,
|
|
54
|
+
/** @type {PostProcessingChanges} */(transformed.js.post_processing_changes),
|
|
55
|
+
/** @type {LineOffsets} */(transformed.js.line_offsets)
|
|
56
|
+
);
|
|
57
57
|
}
|
|
@@ -436,9 +436,13 @@ const visitors = {
|
|
|
436
436
|
const pattern = node.left.declarations[0].id;
|
|
437
437
|
const paths = extract_paths(pattern);
|
|
438
438
|
const scope = state.scopes.get(node);
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
let pattern_id;
|
|
440
|
+
if (state.to_ts) {
|
|
441
|
+
pattern_id = pattern;
|
|
442
|
+
} else {
|
|
443
|
+
pattern_id = b.id(scope.generate('pattern'));
|
|
444
|
+
node.left.declarations[0].id = pattern_id;
|
|
445
|
+
}
|
|
442
446
|
|
|
443
447
|
for (const path of paths) {
|
|
444
448
|
const name = path.node.name;
|
|
@@ -544,10 +548,10 @@ const visitors = {
|
|
|
544
548
|
}
|
|
545
549
|
},
|
|
546
550
|
/**
|
|
547
|
-
*
|
|
548
|
-
* @param {any} node
|
|
549
|
-
* @param {any} context
|
|
550
|
-
* @returns
|
|
551
|
+
*
|
|
552
|
+
* @param {any} node
|
|
553
|
+
* @param {any} context
|
|
554
|
+
* @returns
|
|
551
555
|
*/
|
|
552
556
|
TryStatement(node, context) {
|
|
553
557
|
if (!is_inside_component(context)) {
|
|
@@ -808,9 +812,9 @@ const visitors = {
|
|
|
808
812
|
},
|
|
809
813
|
|
|
810
814
|
/**
|
|
811
|
-
*
|
|
812
|
-
* @param {any} node
|
|
813
|
-
* @param {any} context
|
|
815
|
+
*
|
|
816
|
+
* @param {any} node
|
|
817
|
+
* @param {any} context
|
|
814
818
|
*/
|
|
815
819
|
AwaitExpression(node, context) {
|
|
816
820
|
if (is_inside_component(context)) {
|
|
@@ -862,6 +866,7 @@ export function analyze(ast, filename, options = {}) {
|
|
|
862
866
|
analysis,
|
|
863
867
|
inside_head: false,
|
|
864
868
|
inside_server_block: options.mode === 'server',
|
|
869
|
+
to_ts: options.to_ts ?? false,
|
|
865
870
|
},
|
|
866
871
|
visitors,
|
|
867
872
|
);
|