@tsrx/core 0.1.17 → 0.1.19

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.17",
6
+ "version": "0.1.19",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -1095,7 +1095,7 @@ export function prune_css(css, element, styleClasses, topScopedClasses) {
1095
1095
  // A class is standalone only when the entire effective selector chain (after resolving
1096
1096
  // nesting and stripping :global) is a single RelativeSelector with a single ClassSelector.
1097
1097
  // This prevents classes from compound selectors like `.wrapper .nested` or selectors
1098
- // inside :global() from being exported through style refs.
1098
+ // inside :global() from being exported through style expression maps.
1099
1099
  if (selectors.length === 1) {
1100
1100
  const sole_selector = selectors[0];
1101
1101
  if (
package/src/index.js CHANGED
@@ -162,7 +162,6 @@ export {
162
162
  validate_at_most_one_ref_attribute as validateAtMostOneRefAttribute,
163
163
  } from './transform/jsx/index.js';
164
164
  export {
165
- ensure_function_metadata as ensureFunctionMetadata,
166
165
  in_jsx_child_context as inJsxChildContext,
167
166
  tsx_node_to_jsx_expression as tsxNodeToJsxExpression,
168
167
  tsx_with_ts_locations as tsxWithTsLocations,
@@ -170,7 +169,9 @@ export {
170
169
  export {
171
170
  collect_style_ref_attributes as collectStyleRefAttributes,
172
171
  create_style_class_map as createStyleClassMap,
172
+ create_style_class_map_from_stylesheet as createStyleClassMapFromStylesheet,
173
173
  create_style_ref_setup_statements as createStyleRefSetupStatements,
174
+ get_style_element_stylesheet as getStyleElementStylesheet,
174
175
  } from './transform/style-ref.js';
175
176
  export {
176
177
  clone_expression_node,
@@ -17,6 +17,23 @@ export function in_jsx_child_context(path) {
17
17
  return !!parent && parent.type === 'Element';
18
18
  }
19
19
 
20
+ /**
21
+ * Match Ripple's transform path metadata shape: every node seen by the walker
22
+ * carries its current ancestor path for downstream CSS pruning and mapping
23
+ * helpers.
24
+ *
25
+ * @param {any} node
26
+ * @param {any[]} path
27
+ * @returns {void}
28
+ */
29
+ export function set_node_path_metadata(node, path) {
30
+ if (!node.metadata) {
31
+ node.metadata = { path: [...path] };
32
+ } else {
33
+ node.metadata.path = [...path];
34
+ }
35
+ }
36
+
20
37
  /**
21
38
  * Flatten a `<tsx>` / fragment node's children into a single expression. In a
22
39
  * JSX-child position, a JSXExpressionContainer `{expr}` is valid and must stay
@@ -49,25 +66,6 @@ export function tsx_node_to_jsx_expression(node, in_jsx_child = false) {
49
66
  });
50
67
  }
51
68
 
52
- /**
53
- * Default `node.metadata` to `{ path: [] }` if missing, then continue the
54
- * walk. Use as the `FunctionDeclaration` / `FunctionExpression` /
55
- * `ArrowFunctionExpression` visitor in a zimmerframe walk so that downstream
56
- * consumers don't trip on an undefined metadata object.
57
- *
58
- * Ripple's analyze phase does this via `visit_function`; the tsrx-* targets
59
- * have no analyze phase, so we default metadata during the main walk.
60
- *
61
- * @param {any} node
62
- * @param {{ next: () => any }} ctx
63
- */
64
- export function ensure_function_metadata(node, { next }) {
65
- if (!node.metadata) {
66
- node.metadata = { path: [] };
67
- }
68
- return next();
69
- }
70
-
71
69
  /**
72
70
  * Wrap esrap's `tsx()` printer with location markers for nodes whose spans
73
71
  * (e.g. the leading `new ` of a NewExpression or the angle-bracket delimiters