@tsrx/core 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/plugin.js +26 -1
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.1",
6
+ "version": "0.1.2",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
package/src/plugin.js CHANGED
@@ -202,6 +202,7 @@ export function TSRXPlugin(config) {
202
202
  // Some parser constructors (e.g. via TS plugins) expose `tokContexts` without `b_stat`.
203
203
  // If we push an undefined context, Acorn's tokenizer will later crash reading `.override`.
204
204
  const b_stat = tc.b_stat || acorn.tokContexts.b_stat;
205
+ const b_expr = tc.b_expr || acorn.tokContexts.b_expr;
205
206
  const tstt = Parser.acornTypeScript.tokTypes;
206
207
  const tstc = Parser.acornTypeScript.tokContexts;
207
208
 
@@ -319,6 +320,21 @@ export function TSRXPlugin(config) {
319
320
  }
320
321
  }
321
322
 
323
+ #popJsxAttributeExpressionContextAfterTemplateElement() {
324
+ if (this.type !== tt.braceR) {
325
+ return;
326
+ }
327
+
328
+ const context_index = this.context.length - 1;
329
+ if (
330
+ this.context[context_index] === b_expr &&
331
+ this.context[context_index - 1] === tstc.tc_oTag
332
+ ) {
333
+ this.context.pop();
334
+ this.exprAllowed = false;
335
+ }
336
+ }
337
+
322
338
  #isDoubleQuotedTextChildStart() {
323
339
  if (this.#path.findLast((n) => n.type === 'TsxCompat' || n.type === 'Tsx')) {
324
340
  return false;
@@ -1910,9 +1926,18 @@ export function TSRXPlugin(config) {
1910
1926
  // Use Ripple's parseElement to create a Tsx/Tsrx/TsxCompat node.
1911
1927
  // Bare fragments (<></>) are shorthand for <tsx>...</tsx>.
1912
1928
  this.next();
1913
- return /** @type {import('estree-jsx').JSXElement} */ (
1929
+ const parsed = /** @type {import('estree-jsx').JSXElement} */ (
1914
1930
  /** @type {unknown} */ (this.parseElement())
1915
1931
  );
1932
+ this.#popJsxAttributeExpressionContextAfterTemplateElement();
1933
+ return parsed;
1934
+ }
1935
+
1936
+ if (
1937
+ !this.#path.findLast((node) => node.type === 'Component') &&
1938
+ !this.#functionStack.findLast(is_pascal_case_function)
1939
+ ) {
1940
+ return super.jsx_parseElement();
1916
1941
  }
1917
1942
 
1918
1943
  const code = this.#functionStack.findLast(is_pascal_case_function)