@tsrx/core 0.1.61 → 0.1.62
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
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core compiler infrastructure for TSRX syntax",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Dominic Gannaway",
|
|
6
|
-
"version": "0.1.
|
|
6
|
+
"version": "0.1.62",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"is-reference": "^3.0.3",
|
|
80
80
|
"magic-string": "^0.30.18",
|
|
81
81
|
"zimmerframe": "^1.1.2",
|
|
82
|
-
"@tsrx/runtime": "0.1.
|
|
82
|
+
"@tsrx/runtime": "0.1.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/node": "^24.3.0",
|
package/src/parse/index.js
CHANGED
|
@@ -809,6 +809,10 @@ export function get_comment_handlers(source, comments, index = 0) {
|
|
|
809
809
|
const hasBlankLine = /\n\s*\n/.test(slice);
|
|
810
810
|
const nodeEndLine = node.loc?.end?.line ?? null;
|
|
811
811
|
const commentStartLine = comments[0].loc?.start?.line ?? null;
|
|
812
|
+
const commentOnSameLine =
|
|
813
|
+
nodeEndLine !== null &&
|
|
814
|
+
commentStartLine !== null &&
|
|
815
|
+
nodeEndLine === commentStartLine;
|
|
812
816
|
const isImmediateNextLine =
|
|
813
817
|
nodeEndLine !== null &&
|
|
814
818
|
commentStartLine !== null &&
|
|
@@ -853,10 +857,7 @@ export function get_comment_handlers(source, comments, index = 0) {
|
|
|
853
857
|
// For function parameters, only attach as trailing comment if it's on the same line
|
|
854
858
|
// Comments on next line after comma should be leading comments of next parameter
|
|
855
859
|
if (isParam) {
|
|
856
|
-
|
|
857
|
-
const nodeEndLine = source.slice(0, node.end).split('\n').length;
|
|
858
|
-
const commentStartLine = source.slice(0, comments[0].start).split('\n').length;
|
|
859
|
-
if (nodeEndLine === commentStartLine) {
|
|
860
|
+
if (commentOnSameLine) {
|
|
860
861
|
node.trailingComments = [
|
|
861
862
|
/** @type {AST.CommentWithLocation} */ (comments.shift()),
|
|
862
863
|
];
|
|
@@ -868,11 +869,6 @@ export function get_comment_handlers(source, comments, index = 0) {
|
|
|
868
869
|
// Only attach as trailing if:
|
|
869
870
|
// 1. It's on the same line as this node, OR
|
|
870
871
|
// 2. This is the last item in the array (no next sibling to attach to)
|
|
871
|
-
const commentOnSameLine =
|
|
872
|
-
nodeEndLine !== null &&
|
|
873
|
-
commentStartLine !== null &&
|
|
874
|
-
nodeEndLine === commentStartLine;
|
|
875
|
-
|
|
876
872
|
if (commentOnSameLine || is_last_in_array) {
|
|
877
873
|
node.trailingComments = [
|
|
878
874
|
/** @type {AST.CommentWithLocation} */ (comments.shift()),
|
|
@@ -391,14 +391,17 @@ export function flatten_switch_consequent(consequent) {
|
|
|
391
391
|
export function clone_ast_node(node, with_locations = true) {
|
|
392
392
|
if (!node || typeof node !== 'object') return node;
|
|
393
393
|
if (Array.isArray(node)) {
|
|
394
|
-
|
|
394
|
+
const clone = new Array(node.length);
|
|
395
|
+
for (let i = 0; i < node.length; i++) {
|
|
396
|
+
clone[i] = clone_ast_node(node[i], with_locations);
|
|
397
|
+
}
|
|
398
|
+
return /** @type {T} */ (clone);
|
|
395
399
|
}
|
|
396
|
-
const clone = { ...node };
|
|
400
|
+
const clone = /** @type {T} */ (with_locations ? { ...node } : {});
|
|
397
401
|
const clone_record = /** @type {Record<string, unknown>} */ (clone);
|
|
398
402
|
|
|
399
403
|
for (const key of Object.keys(node)) {
|
|
400
404
|
if (!with_locations && (key === 'loc' || key === 'start' || key === 'end')) {
|
|
401
|
-
delete clone_record[key];
|
|
402
405
|
continue;
|
|
403
406
|
}
|
|
404
407
|
if (key === 'metadata') {
|
|
@@ -517,6 +517,11 @@ export function convert_source_map_to_mappings(
|
|
|
517
517
|
function set_bracket_computed_mapping(node, mappings) {
|
|
518
518
|
if (has_location(node.key)) {
|
|
519
519
|
const key = node.key;
|
|
520
|
+
const start_key = `${key.loc.start.line}:${key.loc.start.column - 1}`;
|
|
521
|
+
const end_key = `${key.loc.end.line}:${key.loc.end.column + 1}`;
|
|
522
|
+
if (!src_to_gen_map.get(start_key)?.length || !src_to_gen_map.get(end_key)?.length) {
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
520
525
|
mappings.push(
|
|
521
526
|
get_mapping_from_node(
|
|
522
527
|
/** @type {AST.NodeWithLocation} */ ({
|