@tsrx/core 0.1.22 → 0.1.25

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.22",
6
+ "version": "0.1.25",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -62,6 +62,14 @@ function get_attribute_value(attribute) {
62
62
  return value?.type === 'JSXExpressionContainer' ? value.expression : value;
63
63
  }
64
64
 
65
+ /**
66
+ * @param {AST.Node} node
67
+ * @returns {boolean}
68
+ */
69
+ function is_runtime_dynamic_element(node) {
70
+ return node?.metadata?.runtime_dynamic_element === true;
71
+ }
72
+
65
73
  /**
66
74
  * Returns true if node is a DOM element (not a component).
67
75
  * @param {AST.Node} node
@@ -73,23 +81,10 @@ function is_element_dom_element(node) {
73
81
  (id.type === 'Identifier' || id.type === 'JSXIdentifier') &&
74
82
  id.name[0].toLowerCase() === id.name[0] &&
75
83
  id.name !== 'children' &&
76
- !id.tracked &&
77
- !id.dynamic
84
+ !id.tracked
78
85
  );
79
86
  }
80
87
 
81
- /**
82
- * Returns true if element is dynamic.
83
- * @param {any} node
84
- * @returns {boolean}
85
- */
86
- function is_element_dynamic(node) {
87
- const id = get_element_name(node);
88
- return id?.type === 'Identifier' || id?.type === 'JSXIdentifier'
89
- ? !!(id.tracked || id.dynamic)
90
- : false;
91
- }
92
-
93
88
  // CSS selector constants
94
89
  /**
95
90
  * @param {number} start
@@ -395,13 +390,11 @@ function get_descendant_elements(node, adjacent_only) {
395
390
  * @returns {boolean}
396
391
  */
397
392
  function can_render_dynamic_content(element, check_classes = false) {
398
- if (!is_element_dom_element(element)) {
393
+ if (is_runtime_dynamic_element(element)) {
399
394
  return true;
400
395
  }
401
396
 
402
- // Either a dynamic element or component (only can tell at runtime)
403
- // But dynamic elements should return false ideally
404
- if (is_element_dynamic(element)) {
397
+ if (!is_element_dom_element(element)) {
405
398
  return true;
406
399
  }
407
400
 
@@ -1021,7 +1014,7 @@ function relative_selector_might_apply_to_node(relative_selector, rule, element,
1021
1014
  }
1022
1015
 
1023
1016
  case 'TypeSelector': {
1024
- if (is_element_dynamic(element)) {
1017
+ if (is_runtime_dynamic_element(element)) {
1025
1018
  break;
1026
1019
  }
1027
1020
 
@@ -1127,10 +1120,6 @@ export function prune_css(css, element, styleClasses, topScopedClasses) {
1127
1120
  style_identifier_classes = styleClasses;
1128
1121
  top_scoped_classes = topScopedClasses;
1129
1122
 
1130
- if (is_element_dynamic(element)) {
1131
- element.metadata.scoped = true;
1132
- }
1133
-
1134
1123
  /** @type {Visitors<AST.CSS.Node, null>} */
1135
1124
  const visitors = {
1136
1125
  Rule(node, context) {
@@ -9,7 +9,7 @@ import { DIAGNOSTIC_CODES } from '../diagnostics.js';
9
9
  export const TSRX_RETURN_STATEMENT_ERROR =
10
10
  'Return statements are not allowed inside TSRX templates. Move the return before the TSRX return value, or use conditional rendering instead.';
11
11
  export const TSRX_LOOP_RETURN_ERROR =
12
- 'Return statements are not allowed inside TSRX template for...of loops. Filter the iterable before rendering or use an @for empty fallback for empty lists.';
12
+ 'Return statements are not allowed inside TSRX template for...of loops. Filter the iterable before rendering or use an @empty fallback for empty lists.';
13
13
  export const TSRX_LOOP_BREAK_ERROR =
14
14
  'Break statements are not allowed inside TSRX template for...of loops.';
15
15
  export const TSRX_LOOP_CONTINUE_ERROR =
@@ -4,4 +4,5 @@ export const DIAGNOSTIC_CODES = {
4
4
  MISMATCHED_CLOSING_TAG: 'tsrx-mismatched-closing-tag',
5
5
  TEMPLATE_EXPRESSION_TRAILING_SEMICOLON: 'tsrx-template-expression-trailing-semicolon',
6
6
  TEMPLATE_RETURN_STATEMENT: 'tsrx-template-return-statement',
7
+ FORGOTTEN_STATEMENT_CONTAINER: 'tsrx-forgotten-statement-container',
7
8
  };
package/src/index.js CHANGED
@@ -185,9 +185,7 @@ export {
185
185
  identifier_to_jsx_name,
186
186
  is_bare_render_expression,
187
187
  is_component_jsx_name,
188
- is_dynamic_element_id,
189
188
  is_jsx_child,
190
- jsx_name_to_expression,
191
189
  set_loc,
192
190
  to_text_expression,
193
191
  } from './transform/jsx/ast-builders.js';