@tsrx/core 0.1.59 → 0.1.61
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 +4 -3
- package/package.json +2 -2
- package/src/analyze/prune.js +7 -1
- package/src/constants.js +1 -1
- package/src/errors.js +1 -6
- package/src/plugin.js +4 -4
- package/src/transform/jsx/helpers.js +1 -1
- package/src/transform/jsx/index.js +77 -17
- package/src/transform/segments.js +5 -5
- package/types/index.d.ts +9 -5
- package/types/jsx-platform.d.ts +5 -5
- package/types/parse.d.ts +1 -7
package/README.md
CHANGED
|
@@ -5,9 +5,10 @@ infrastructure that powers TypeScript UI frameworks.
|
|
|
5
5
|
|
|
6
6
|
`@tsrx/core` is framework-agnostic. It provides the parser, AST definitions, scope
|
|
7
7
|
analysis, and code-generation utilities needed to target _any_ framework runtime
|
|
8
|
-
using
|
|
9
|
-
[`@tsrx/
|
|
10
|
-
|
|
8
|
+
using TSRX syntax. Framework-specific packages—such as
|
|
9
|
+
[`@tsrx/react`](../tsrx-react), [`@tsrx/solid`](../tsrx-solid), and the external
|
|
10
|
+
[`@tsrx/ripple`](https://github.com/Ripple-TS/ripple)—build on `@tsrx/core` to
|
|
11
|
+
produce target-runtime output.
|
|
11
12
|
|
|
12
13
|
## What is TSRX?
|
|
13
14
|
|
package/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
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.61",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/
|
|
10
|
+
"url": "git+https://github.com/tsrx-org/tsrx.git",
|
|
11
11
|
"directory": "packages/tsrx"
|
|
12
12
|
},
|
|
13
13
|
"exports": {
|
package/src/analyze/prune.js
CHANGED
|
@@ -15,6 +15,8 @@ const BACKWARD = 1;
|
|
|
15
15
|
// since the code is synchronous, this is safe
|
|
16
16
|
/** @type {string} */
|
|
17
17
|
let css_hash;
|
|
18
|
+
/** @type {string} */
|
|
19
|
+
let css_region_hash;
|
|
18
20
|
/** @type {StyleClasses} */
|
|
19
21
|
let style_identifier_classes;
|
|
20
22
|
/** @type {TopScopedClasses} */
|
|
@@ -300,6 +302,7 @@ function apply_selector(relative_selectors, rule, element, direction) {
|
|
|
300
302
|
start: selector.start,
|
|
301
303
|
end: selector.end,
|
|
302
304
|
selector: selector,
|
|
305
|
+
regionHash: css_region_hash,
|
|
303
306
|
});
|
|
304
307
|
}
|
|
305
308
|
}
|
|
@@ -1107,10 +1110,12 @@ function rule_has_animation(rule) {
|
|
|
1107
1110
|
* @param {AST.TSRXElementNode} element
|
|
1108
1111
|
* @param {StyleClasses} styleClasses
|
|
1109
1112
|
* @param {TopScopedClasses} topScopedClasses
|
|
1113
|
+
* @param {string} [regionHash]
|
|
1110
1114
|
* @return {void}
|
|
1111
1115
|
*/
|
|
1112
|
-
export function prune_css(css, element, styleClasses, topScopedClasses) {
|
|
1116
|
+
export function prune_css(css, element, styleClasses, topScopedClasses, regionHash = css.hash) {
|
|
1113
1117
|
css_hash = css.hash;
|
|
1118
|
+
css_region_hash = regionHash;
|
|
1114
1119
|
style_identifier_classes = styleClasses;
|
|
1115
1120
|
top_scoped_classes = topScopedClasses;
|
|
1116
1121
|
|
|
@@ -1152,6 +1157,7 @@ export function prune_css(css, element, styleClasses, topScopedClasses) {
|
|
|
1152
1157
|
start: class_selector.start,
|
|
1153
1158
|
end: class_selector.end,
|
|
1154
1159
|
selector: class_selector,
|
|
1160
|
+
regionHash: css_region_hash,
|
|
1155
1161
|
});
|
|
1156
1162
|
}
|
|
1157
1163
|
}
|
package/src/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ export const IS_CONTROLLED = 1 << 2;
|
|
|
4
4
|
export const IS_INDEXED = 1 << 3;
|
|
5
5
|
// A control-flow block that is its component's sole root: renders before the
|
|
6
6
|
// parent `__anchor` (sibling semantics, no `<!>` wrapper). Must match the value
|
|
7
|
-
// in
|
|
7
|
+
// in a target runtime's constants.
|
|
8
8
|
export const ROOT_CONTROLLED = 1 << 4;
|
|
9
9
|
export const TEMPLATE_SVG_NAMESPACE = 1 << 5;
|
|
10
10
|
export const TEMPLATE_MATHML_NAMESPACE = 1 << 6;
|
package/src/errors.js
CHANGED
|
@@ -57,12 +57,7 @@ export function error(message, filename, node, errors, comments, code) {
|
|
|
57
57
|
*/
|
|
58
58
|
function is_error_suppress_comment(comment) {
|
|
59
59
|
const text = comment.value.trim();
|
|
60
|
-
return (
|
|
61
|
-
text.startsWith('@tsrx-ignore') ||
|
|
62
|
-
text.startsWith('@tsrx-expect-error') ||
|
|
63
|
-
text.startsWith('@ripple-ignore') ||
|
|
64
|
-
text.startsWith('@ripple-expect-error')
|
|
65
|
-
);
|
|
60
|
+
return text.startsWith('@tsrx-ignore') || text.startsWith('@tsrx-expect-error');
|
|
66
61
|
}
|
|
67
62
|
|
|
68
63
|
/**
|
package/src/plugin.js
CHANGED
|
@@ -246,7 +246,7 @@ function looks_like_generic_arrow(input, pos) {
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
/**
|
|
249
|
-
* Acorn parser plugin for
|
|
249
|
+
* Acorn parser plugin for TSRX syntax extensions.
|
|
250
250
|
* Adds support for: native TSRX templates, &[]/&{} lazy destructuring,
|
|
251
251
|
* submodule imports, TSRX directives, and enhanced JSX handling.
|
|
252
252
|
*
|
|
@@ -358,7 +358,7 @@ export function TSRXPlugin(config) {
|
|
|
358
358
|
constructor(options, input) {
|
|
359
359
|
super(options, input);
|
|
360
360
|
this.context ??= [b_stat];
|
|
361
|
-
const tsrx_options = options?.tsrxOptions
|
|
361
|
+
const tsrx_options = options?.tsrxOptions;
|
|
362
362
|
this.#collect = tsrx_options?.collect === true || tsrx_options?.loose === true;
|
|
363
363
|
this.#loose = tsrx_options?.loose === true;
|
|
364
364
|
this.#errors = tsrx_options?.errors;
|
|
@@ -2222,7 +2222,7 @@ export function TSRXPlugin(config) {
|
|
|
2222
2222
|
* is exposed twice: verbatim on `content`, and as a single `JSXText` child so
|
|
2223
2223
|
* generic element paths (factory targets, static hoisting, printers) emit the
|
|
2224
2224
|
* body without knowing about raw-text elements. Consumers that handle
|
|
2225
|
-
* `content` directly (
|
|
2225
|
+
* `content` directly (target transforms, the Prettier plugin) must skip
|
|
2226
2226
|
* the children instead of emitting both.
|
|
2227
2227
|
*
|
|
2228
2228
|
* @param {ESTreeJSX.TSRXJSXOpeningElement & AST.NodeWithLocation} open
|
|
@@ -2956,7 +2956,7 @@ export function TSRXPlugin(config) {
|
|
|
2956
2956
|
}
|
|
2957
2957
|
|
|
2958
2958
|
/**
|
|
2959
|
-
* Get token from character code - handles
|
|
2959
|
+
* Get token from character code - handles TSRX-specific tokens
|
|
2960
2960
|
* @type {Parse.Parser['getTokenFromCode']}
|
|
2961
2961
|
*/
|
|
2962
2962
|
getTokenFromCode(code) {
|
|
@@ -41,7 +41,7 @@ export function is_empty_jsx_fragment(node) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
*
|
|
44
|
+
* Maintain TSRX transform path metadata: every node seen by the walker
|
|
45
45
|
* carries its current ancestor path for downstream CSS pruning and mapping
|
|
46
46
|
* helpers.
|
|
47
47
|
*
|
|
@@ -268,7 +268,7 @@ function wrap_in_native_tsrx_fragment(node) {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
|
-
* An AUTHORED `<> … </>` fragment (not a compiler-generated wrapper, nor a
|
|
271
|
+
* An AUTHORED `<> … </>` fragment (not a compiler-generated wrapper, nor a TSRX
|
|
272
272
|
* code-block-chain wrapper). These are kept verbatim in the output instead of
|
|
273
273
|
* being unwrapped to their single child.
|
|
274
274
|
* @param {AST.Node | null | undefined} node
|
|
@@ -728,9 +728,24 @@ export function createJsxTransform(platform) {
|
|
|
728
728
|
// hooks can inspect the original JSX child shape.
|
|
729
729
|
const raw_children = node_children(node).map((child) => ({ ...child }));
|
|
730
730
|
const inner = /** @type {AST.TSRXJSXElement} */ (next() ?? node);
|
|
731
|
+
const in_jsx_child = in_jsx_child_context(path);
|
|
731
732
|
const hook = platform.hooks?.transformElement;
|
|
732
|
-
|
|
733
|
-
|
|
733
|
+
const produced = hook
|
|
734
|
+
? hook(inner, state, raw_children)
|
|
735
|
+
: to_jsx_element(inner, state, raw_children, in_jsx_child);
|
|
736
|
+
// A host element carrying `ref` plus a spread lowers to a generated
|
|
737
|
+
// `let X = __normalize_spread_props_for_ref_attr(…)` that rides on the
|
|
738
|
+
// element's metadata for a later pass to hoist. Only the render-block
|
|
739
|
+
// statement builder and the native-directive path hoist it, so an
|
|
740
|
+
// element in plain-JS expression position — a ternary arm, a concise
|
|
741
|
+
// arrow body, a declarator init, a callback body, an attribute value, an
|
|
742
|
+
// array element — reaches neither: the declaration is dropped while the
|
|
743
|
+
// rewritten attributes still reference the name, and the type-only print
|
|
744
|
+
// carries an undefined identifier (TS2304). Wrap it in the same IIFE the
|
|
745
|
+
// native-directive path already uses.
|
|
746
|
+
return state.typeOnly && produced.type !== 'JSXSpreadChild' && produced.type !== 'JSXText'
|
|
747
|
+
? wrap_jsx_setup_declarations(produced, in_jsx_child)
|
|
748
|
+
: produced;
|
|
734
749
|
},
|
|
735
750
|
|
|
736
751
|
JSXExpressionContainer(node, { next, state }) {
|
|
@@ -791,7 +806,7 @@ export function createJsxTransform(platform) {
|
|
|
791
806
|
return visited;
|
|
792
807
|
}
|
|
793
808
|
const is_component = is_component_like_jsx_name(visited.name);
|
|
794
|
-
|
|
809
|
+
const lowered = b.jsx_opening_element(
|
|
795
810
|
visited.name,
|
|
796
811
|
merge_duplicate_refs(
|
|
797
812
|
normalize_host_ref_spreads(visited.attributes || [], !is_component, transform_context),
|
|
@@ -801,6 +816,17 @@ export function createJsxTransform(platform) {
|
|
|
801
816
|
visited.typeArguments,
|
|
802
817
|
has_location(visited) ? visited : undefined,
|
|
803
818
|
);
|
|
819
|
+
// `normalize_host_ref_spreads` is NOT idempotent: run twice it reads the
|
|
820
|
+
// `ref={[authored, __spread_props1.ref]}` array it just produced as an
|
|
821
|
+
// AUTHORED ref and lowers again, emitting a second helper binding and a
|
|
822
|
+
// nested ref array. The attribute list cannot answer "already lowered"
|
|
823
|
+
// on its own — `merge_duplicate_refs` rebuilds the merged `ref` without
|
|
824
|
+
// the `synthetic_ref` marker — so record it on the element instead.
|
|
825
|
+
lowered.metadata = {
|
|
826
|
+
...(lowered.metadata || {}),
|
|
827
|
+
host_ref_spread_lowered: true,
|
|
828
|
+
};
|
|
829
|
+
return lowered;
|
|
804
830
|
},
|
|
805
831
|
});
|
|
806
832
|
|
|
@@ -1065,6 +1091,7 @@ function inject_dynamic_import(program, transform_context) {
|
|
|
1065
1091
|
* @param {AST.CSS.StyleSheet} css
|
|
1066
1092
|
* @param {TransformContext} transform_context
|
|
1067
1093
|
* @param {boolean} [export_top_scoped_classes]
|
|
1094
|
+
* @param {string} [region_hash]
|
|
1068
1095
|
* @returns {void}
|
|
1069
1096
|
*/
|
|
1070
1097
|
function apply_css_definition_metadata(
|
|
@@ -1072,6 +1099,7 @@ function apply_css_definition_metadata(
|
|
|
1072
1099
|
css,
|
|
1073
1100
|
transform_context,
|
|
1074
1101
|
export_top_scoped_classes = false,
|
|
1102
|
+
region_hash = css.hash,
|
|
1075
1103
|
) {
|
|
1076
1104
|
analyze_css(css);
|
|
1077
1105
|
|
|
@@ -1082,7 +1110,7 @@ function apply_css_definition_metadata(
|
|
|
1082
1110
|
|
|
1083
1111
|
const prune = () => {
|
|
1084
1112
|
for (const element of elements) {
|
|
1085
|
-
prune_css(css, element, style_classes, top_scoped_classes);
|
|
1113
|
+
prune_css(css, element, style_classes, top_scoped_classes, region_hash);
|
|
1086
1114
|
}
|
|
1087
1115
|
};
|
|
1088
1116
|
|
|
@@ -2291,19 +2319,20 @@ function node_contains_native_tsrx_template(node) {
|
|
|
2291
2319
|
|
|
2292
2320
|
/**
|
|
2293
2321
|
* @param {AST.NativeTSRXNode} node
|
|
2294
|
-
* @
|
|
2322
|
+
* @param {boolean} allow_multiple
|
|
2323
|
+
* @returns {AST.CSS.StyleSheet[] | null}
|
|
2295
2324
|
*/
|
|
2296
|
-
function
|
|
2325
|
+
function collect_tsrx_stylesheets(node, allow_multiple) {
|
|
2297
2326
|
/** @type {AST.CSS.StyleSheet[]} */
|
|
2298
2327
|
const styles = [];
|
|
2299
2328
|
collect_style_elements(node_children(node), styles);
|
|
2300
2329
|
|
|
2301
2330
|
if (styles.length === 0) return null;
|
|
2302
|
-
if (styles.length > 1) {
|
|
2331
|
+
if (styles.length > 1 && !allow_multiple) {
|
|
2303
2332
|
throw new Error('TSRX fragments can only have one style tag');
|
|
2304
2333
|
}
|
|
2305
2334
|
|
|
2306
|
-
return styles
|
|
2335
|
+
return styles;
|
|
2307
2336
|
}
|
|
2308
2337
|
|
|
2309
2338
|
/**
|
|
@@ -2312,14 +2341,37 @@ function collect_tsrx_stylesheet(node) {
|
|
|
2312
2341
|
* @returns {JsxStyleContext | null}
|
|
2313
2342
|
*/
|
|
2314
2343
|
function prepare_tsrx_fragment_styles(node, transform_context) {
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2344
|
+
// Type-only output must stay analyzable: a throw here makes language hosts
|
|
2345
|
+
// (tsrx-tsc, editors) fall back to presenting the RAW source as the virtual
|
|
2346
|
+
// TSX, so every CSS brace in the file becomes a TSX parse error. Platforms
|
|
2347
|
+
// whose runtime dialect allows one scope to split its CSS across several
|
|
2348
|
+
// `<style>` tags are valid input here, and platforms that forbid it still
|
|
2349
|
+
// report the rule through their own runtime compiler.
|
|
2350
|
+
const sheets = collect_tsrx_stylesheets(node, transform_context.typeOnly);
|
|
2351
|
+
if (!sheets) return null;
|
|
2352
|
+
|
|
2353
|
+
const css = sheets[0];
|
|
2318
2354
|
const style_refs = collect_style_ref_attributes(node);
|
|
2319
|
-
//
|
|
2320
|
-
//
|
|
2321
|
-
|
|
2322
|
-
|
|
2355
|
+
// A component scope keeps ONE hash even when its CSS is split across
|
|
2356
|
+
// several `<style>` tags: rebase every sheet onto the first sheet's hash
|
|
2357
|
+
// before scoping, so selector rewriting and the DOM hash annotation below
|
|
2358
|
+
// agree. `apply_css_definition_metadata` accumulates into the component's
|
|
2359
|
+
// `styleClasses`/`topScopedClasses` metadata, so per-sheet calls compose
|
|
2360
|
+
// into one class map for style refs.
|
|
2361
|
+
for (const sheet of sheets) {
|
|
2362
|
+
const region_hash = sheet.hash;
|
|
2363
|
+
sheet.hash = css.hash;
|
|
2364
|
+
// `prune_css` inside marks the matching selectors as used/scoped; selectors
|
|
2365
|
+
// that match no element render commented out, matching target behavior.
|
|
2366
|
+
apply_css_definition_metadata(
|
|
2367
|
+
node,
|
|
2368
|
+
sheet,
|
|
2369
|
+
transform_context,
|
|
2370
|
+
style_refs.length > 0,
|
|
2371
|
+
region_hash,
|
|
2372
|
+
);
|
|
2373
|
+
transform_context.stylesheets.push(sheet);
|
|
2374
|
+
}
|
|
2323
2375
|
const fragment = annotate_tsrx_with_hash(
|
|
2324
2376
|
node,
|
|
2325
2377
|
css.hash,
|
|
@@ -6120,8 +6172,16 @@ function transform_element_attributes_dispatch(attrs, transform_context, element
|
|
|
6120
6172
|
}
|
|
6121
6173
|
const hook = transform_context.platform.hooks?.transformElementAttributes;
|
|
6122
6174
|
const result = hook ? hook(attrs, transform_context, element) : attrs;
|
|
6175
|
+
// An element in plain-JS expression position reaches BOTH lowering sites —
|
|
6176
|
+
// the JSXOpeningElement visitor above and this dispatch — so without the
|
|
6177
|
+
// marker its host ref/spread is lowered twice. Scoped to the type-only
|
|
6178
|
+
// print: runtime emit for the other platforms sharing this transform keeps
|
|
6179
|
+
// its existing output.
|
|
6180
|
+
const already_lowered =
|
|
6181
|
+
transform_context.typeOnly &&
|
|
6182
|
+
element?.openingElement?.metadata?.host_ref_spread_lowered === true;
|
|
6123
6183
|
return merge_duplicate_refs(
|
|
6124
|
-
normalize_host_ref_spreads(result, !is_component, transform_context),
|
|
6184
|
+
already_lowered ? result : normalize_host_ref_spreads(result, !is_component, transform_context),
|
|
6125
6185
|
transform_context,
|
|
6126
6186
|
);
|
|
6127
6187
|
}
|
|
@@ -625,7 +625,7 @@ export function convert_source_map_to_mappings(
|
|
|
625
625
|
if (node.name && node.loc) {
|
|
626
626
|
/** @type {MappingToken} */
|
|
627
627
|
let token;
|
|
628
|
-
// Check if this identifier was changed in metadata (
|
|
628
|
+
// Check if this identifier was changed in metadata (for example, #Map -> ReactiveMap)
|
|
629
629
|
// Or if it was capitalized during transformation
|
|
630
630
|
if (node.metadata?.source_name) {
|
|
631
631
|
token = {
|
|
@@ -885,7 +885,7 @@ export function convert_source_map_to_mappings(
|
|
|
885
885
|
definition: {
|
|
886
886
|
description: `CSS class selector for '.${name}'`,
|
|
887
887
|
location: {
|
|
888
|
-
embeddedId: get_style_region_id(css.hash),
|
|
888
|
+
embeddedId: get_style_region_id(cssLocation.regionHash ?? css.hash),
|
|
889
889
|
start: cssLocation.start,
|
|
890
890
|
end: cssLocation.end,
|
|
891
891
|
},
|
|
@@ -933,7 +933,7 @@ export function convert_source_map_to_mappings(
|
|
|
933
933
|
// text itself — and get_mapping_from_node just takes the first, so its generated length
|
|
934
934
|
// spans the wrong region and the editor can't map a completion's edit back to source
|
|
935
935
|
// (it then drops the item). The token resolves to the position whose generated text
|
|
936
|
-
// matches the node's value, giving a well-formed same-length mapping.
|
|
936
|
+
// matches the node's value, giving a well-formed same-length mapping. TSRX keeps text
|
|
937
937
|
// verbatim in to_ts, so `source` and `generated` are identical. Other text stays unmapped.
|
|
938
938
|
if (node.loc && typeof node.value === 'string' && node.value.trimStart().startsWith('@')) {
|
|
939
939
|
tokens.push({
|
|
@@ -1299,14 +1299,14 @@ export function convert_source_map_to_mappings(
|
|
|
1299
1299
|
);
|
|
1300
1300
|
return;
|
|
1301
1301
|
} else if (node.type === 'ForOfStatement' || node.type === 'ForInStatement') {
|
|
1302
|
-
// Visit in source order: left, right, index
|
|
1302
|
+
// Visit in source order: left, right, TSRX index extension, body
|
|
1303
1303
|
if (node.left) {
|
|
1304
1304
|
visit(node.left);
|
|
1305
1305
|
}
|
|
1306
1306
|
if (node.right) {
|
|
1307
1307
|
visit(node.right);
|
|
1308
1308
|
}
|
|
1309
|
-
//
|
|
1309
|
+
// TSRX index extension: index variable
|
|
1310
1310
|
if (/** @type {AST.ForOfStatement} */ (node).index) {
|
|
1311
1311
|
visit(/** @type {AST.Node} */ (/** @type {AST.ForOfStatement} */ (node).index));
|
|
1312
1312
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -352,7 +352,7 @@ declare module 'estree' {
|
|
|
352
352
|
lazy?: boolean;
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
//
|
|
355
|
+
// Target analysis may mark a whole member expression as tracked metadata.
|
|
356
356
|
interface MemberExpression {
|
|
357
357
|
tracked?: boolean;
|
|
358
358
|
}
|
|
@@ -425,7 +425,7 @@ declare module 'estree' {
|
|
|
425
425
|
* `#parseScriptElement` (analogous to {@link JSXStyleElement.css}). Present only
|
|
426
426
|
* on `<script>` elements that have a body. The parser also mirrors the body as
|
|
427
427
|
* a single `JSXText` child so generic element consumers emit it; consumers that
|
|
428
|
-
* handle `content` directly (
|
|
428
|
+
* handle `content` directly (target transforms, the Prettier plugin, the
|
|
429
429
|
* type-only editor output) skip the children instead of emitting both.
|
|
430
430
|
*/
|
|
431
431
|
content?: string;
|
|
@@ -989,6 +989,8 @@ declare module 'estree-jsx' {
|
|
|
989
989
|
interface JSXOpeningElement {
|
|
990
990
|
metadata: BaseNodeMetaData & {
|
|
991
991
|
native_tsrx_pretransformed?: boolean;
|
|
992
|
+
/** Type-only host ref/spread normalization has already run for this element. */
|
|
993
|
+
host_ref_spread_lowered?: boolean;
|
|
992
994
|
};
|
|
993
995
|
}
|
|
994
996
|
|
|
@@ -1628,7 +1630,7 @@ export interface Binding {
|
|
|
1628
1630
|
/** Additional metadata for this binding */
|
|
1629
1631
|
metadata: {
|
|
1630
1632
|
pattern?: AST.Identifier;
|
|
1631
|
-
|
|
1633
|
+
is_tsrx_object?: boolean;
|
|
1632
1634
|
is_template_value?: boolean;
|
|
1633
1635
|
lazy_array_source?: string;
|
|
1634
1636
|
lazy_array_index?: number;
|
|
@@ -2090,6 +2092,8 @@ export type TopScopedClasses = Map<
|
|
|
2090
2092
|
start: number;
|
|
2091
2093
|
end: number;
|
|
2092
2094
|
selector: AST.CSS.ClassSelector;
|
|
2095
|
+
/** Source `<style>` region for editor definition navigation. */
|
|
2096
|
+
regionHash?: string;
|
|
2093
2097
|
}
|
|
2094
2098
|
>;
|
|
2095
2099
|
|
|
@@ -2228,7 +2232,7 @@ export type RuntimeImportMode = 'compiler' | 'direct';
|
|
|
2228
2232
|
|
|
2229
2233
|
/**
|
|
2230
2234
|
* Common base options accepted by every TSRX target's `compile` entry point.
|
|
2231
|
-
* Targets that need extra knobs (
|
|
2235
|
+
* Targets that need extra knobs (for example Ripple's `mode`/`dev`/`hmr`, Preact's
|
|
2232
2236
|
* `suspenseSource`) intersect their own option type with this base when
|
|
2233
2237
|
* declaring their `compile` export.
|
|
2234
2238
|
*/
|
|
@@ -2252,7 +2256,7 @@ export interface BaseCompileOptions {
|
|
|
2252
2256
|
* @template TOptions Per-target options accepted as the third argument.
|
|
2253
2257
|
* Defaults to {@link BaseCompileOptions}.
|
|
2254
2258
|
* @template TResult Per-target result type. Must extend {@link CompileResult};
|
|
2255
|
-
* targets may add fields (
|
|
2259
|
+
* targets may add fields (for example Ripple's deprecated `js` compatibility field)
|
|
2256
2260
|
* via intersection.
|
|
2257
2261
|
*/
|
|
2258
2262
|
export type CompileFn<
|
package/types/jsx-platform.d.ts
CHANGED
|
@@ -158,7 +158,7 @@ export interface JsxTransformOptions {
|
|
|
158
158
|
export interface JsxPlatformHooks {
|
|
159
159
|
/**
|
|
160
160
|
* Per-statement control-flow rewrites. Each hook receives the original
|
|
161
|
-
*
|
|
161
|
+
* TSRX statement (with children already walked) and returns a JSX
|
|
162
162
|
* child (or an expression container wrapping one).
|
|
163
163
|
*/
|
|
164
164
|
controlFlow?: {
|
|
@@ -205,7 +205,7 @@ export interface JsxPlatformHooks {
|
|
|
205
205
|
*/
|
|
206
206
|
injectImports?: (program: AST.Program, ctx: JsxTransformContext, suspenseSource: string) => void;
|
|
207
207
|
/**
|
|
208
|
-
* Transform a
|
|
208
|
+
* Transform a TSRX element's parser-native JSX attributes. The result
|
|
209
209
|
* is passed through the shared multi-`ref` merge. Platforms that own a
|
|
210
210
|
* `transformElement` hook (e.g. Solid) run their own attribute pass inside
|
|
211
211
|
* that hook.
|
|
@@ -343,7 +343,7 @@ export interface JsxPlatformHooks {
|
|
|
343
343
|
|
|
344
344
|
/**
|
|
345
345
|
* A JSX platform descriptor is the parameter to `createJsxTransform`. It
|
|
346
|
-
* declares how to render a
|
|
346
|
+
* declares how to render a TSRX AST as valid TSX for the target platform
|
|
347
347
|
* (React, Preact, Solid). The shared transformer in `@tsrx/core` reads this
|
|
348
348
|
* descriptor at each platform-specific decision point instead of branching
|
|
349
349
|
* on the platform name.
|
|
@@ -432,7 +432,7 @@ export interface JsxPlatform {
|
|
|
432
432
|
|
|
433
433
|
jsx: {
|
|
434
434
|
/**
|
|
435
|
-
* Rewrite
|
|
435
|
+
* Rewrite TSRX's `class` attribute to `className` for targets
|
|
436
436
|
* that require it. First-party targets keep authored `class`.
|
|
437
437
|
*/
|
|
438
438
|
rewriteClassAttr: boolean;
|
|
@@ -527,7 +527,7 @@ export interface JsxPlatform {
|
|
|
527
527
|
|
|
528
528
|
/**
|
|
529
529
|
* Build a `transform()` function for a specific JSX platform. The returned
|
|
530
|
-
* function takes a parsed
|
|
530
|
+
* function takes a parsed TSRX AST and produces a TSX module plus source
|
|
531
531
|
* map and optional CSS.
|
|
532
532
|
*/
|
|
533
533
|
export function createJsxTransform(
|
package/types/parse.d.ts
CHANGED
|
@@ -193,12 +193,6 @@ export namespace Parse {
|
|
|
193
193
|
errors: CoreCompiler.CompileError[] | undefined;
|
|
194
194
|
filename: string | undefined;
|
|
195
195
|
};
|
|
196
|
-
rippleOptions?: {
|
|
197
|
-
collect: boolean;
|
|
198
|
-
loose: boolean;
|
|
199
|
-
errors: CoreCompiler.CompileError[] | undefined;
|
|
200
|
-
filename: string | undefined;
|
|
201
|
-
};
|
|
202
196
|
// The type has "latest" but it's converted to 1e8 at runtime
|
|
203
197
|
// and if (ecmaVersion >= 2015) { ecmaVersion -= 2009 }
|
|
204
198
|
// so we're making it always a number to reflect the runtime values
|
|
@@ -1666,7 +1660,7 @@ export namespace Parse {
|
|
|
1666
1660
|
/**
|
|
1667
1661
|
* Check if a local export refers to a defined variable.
|
|
1668
1662
|
* Acorn's default implementation only checks the top-level module scope,
|
|
1669
|
-
* but
|
|
1663
|
+
* but TSRX overrides this to check all scopes (for submodules).
|
|
1670
1664
|
* @param id The identifier being exported
|
|
1671
1665
|
*/
|
|
1672
1666
|
checkLocalExport(id: AST.Identifier): void;
|