@tsrx/core 0.1.22 → 0.1.24

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.
@@ -83,7 +83,7 @@ export function annotate_with_hash(
83
83
  }
84
84
 
85
85
  if (node.type === 'JSXElement') {
86
- if (!is_composite_jsx_element(node)) {
86
+ if (!is_composite_jsx_element(node) || node.metadata?.runtime_dynamic_element) {
87
87
  add_hash_class_to_jsx_element(node, hash, jsx_class_attr_name);
88
88
  }
89
89
  if (Array.isArray(node.children)) {
@@ -1128,6 +1128,19 @@ export function convert_source_map_to_mappings(
1128
1128
  visit(node.body);
1129
1129
  }
1130
1130
 
1131
+ if (node.type === 'ForOfStatement' && node.empty) {
1132
+ mappings.push(
1133
+ get_mapping_from_node(
1134
+ node.empty,
1135
+ src_to_gen_map,
1136
+ gen_line_offsets,
1137
+ mapping_data_verify_only,
1138
+ ),
1139
+ );
1140
+
1141
+ visit(node.empty);
1142
+ }
1143
+
1131
1144
  if (node.loc) {
1132
1145
  mappings.push(
1133
1146
  get_mapping_from_node(node, src_to_gen_map, gen_line_offsets, mapping_data_verify_only),
@@ -1176,49 +1189,6 @@ export function convert_source_map_to_mappings(
1176
1189
  ),
1177
1190
  );
1178
1191
 
1179
- // Add a special token for the 'pending' keyword with customData
1180
- // to suppress TypeScript diagnostics and provide custom hover/definition
1181
- const pending = /** @type {(typeof node.pending) & AST.NodeWithLocation} */ (
1182
- node.pending
1183
- );
1184
- const pendingKeywordLoc = {
1185
- start: {
1186
- line: pending.loc.start.line,
1187
- column: pending.loc.start.column - 'pending '.length,
1188
- },
1189
- end: {
1190
- line: pending.loc.start.line,
1191
- column: pending.loc.start.column - 1,
1192
- },
1193
- };
1194
- tokens.push({
1195
- source: 'pending',
1196
- generated: 'pending',
1197
- loc: pendingKeywordLoc,
1198
- metadata: {
1199
- wordHighlight: {
1200
- /** @type {DocumentHighlightKind} */
1201
- kind: 1,
1202
- },
1203
- suppressedDiagnostics: [
1204
- 1472, // 'catch' or 'finally' expected
1205
- 2304, // Cannot find name 'pending'
1206
- ],
1207
- // suppress all hovers
1208
- hover: false,
1209
-
1210
- // Example of a custom hover contents (uses markdown)
1211
- // hover: '```ripple\npending\n```\n\nRipple-specific keyword for try/pending blocks.\n\nThe `pending` block executes while async operations inside the `try` block are awaiting. This provides a built-in loading state for async components.',
1212
-
1213
- // Example of a custom definition and its type definition file
1214
- // definition: {
1215
- // typeReplace: {
1216
- // name: 'SomeType',
1217
- // path: 'types/index.d.ts',
1218
- // },
1219
- // },
1220
- },
1221
- });
1222
1192
  visit(node.pending);
1223
1193
  }
1224
1194
  if (node.handler) {
package/types/index.d.ts CHANGED
@@ -84,6 +84,7 @@ interface BaseNodeMetaData {
84
84
  parenthesized?: boolean;
85
85
  native_tsrx?: boolean;
86
86
  native_tsrx_template_block?: boolean;
87
+ runtime_dynamic_element?: boolean;
87
88
  templateMode?: 'script' | 'template';
88
89
  script_only?: boolean;
89
90
  tsrxDirective?: 'if' | 'for' | 'switch' | 'try';
@@ -231,8 +232,7 @@ declare module 'estree' {
231
232
  lazy?: boolean;
232
233
  }
233
234
 
234
- // We mark the whole node as marked when member is @[expression]
235
- // Otherwise, we only mark Identifier nodes
235
+ // Ripple analysis may mark a whole member expression as tracked metadata.
236
236
  interface MemberExpression {
237
237
  tracked?: boolean;
238
238
  }
@@ -700,7 +700,6 @@ declare module 'estree-jsx' {
700
700
  }
701
701
 
702
702
  interface JSXIdentifier {
703
- tracked?: boolean;
704
703
  metadata: BaseNodeMetaData & {
705
704
  is_component?: boolean;
706
705
  };
@@ -1292,7 +1291,6 @@ export interface Binding {
1292
1291
  is_called: boolean;
1293
1292
  /** Additional metadata for this binding */
1294
1293
  metadata: {
1295
- is_dynamic_component?: boolean;
1296
1294
  pattern?: AST.Identifier;
1297
1295
  is_ripple_object?: boolean;
1298
1296
  is_template_value?: boolean;
@@ -1450,7 +1448,6 @@ export interface TransformServerState extends BaseState {
1450
1448
  namespace: NameSpace;
1451
1449
  server_block_locals: AST.VariableDeclaration[];
1452
1450
  server_exported_names: string[];
1453
- dynamicElementName?: AST.TemplateLiteral;
1454
1451
  applyParentCssScope?: AST.CSS.StyleSheet['hash'];
1455
1452
  dev?: boolean;
1456
1453
  return_flags?: Map<AST.ReturnStatement, { name: string; tracked: boolean }>;
@@ -53,6 +53,8 @@ export interface JsxTransformContext {
53
53
  hook_helpers_enabled: boolean;
54
54
  available_bindings: Map<string, AST.Identifier>;
55
55
  lazy_next_id: number;
56
+ /** Scope map used to resolve runtime Dynamic imports for scoped CSS pruning. */
57
+ runtime_dynamic_scopes: Map<any, any> | null;
56
58
  inside_element_child?: boolean;
57
59
  /** Full source text for source-aware diagnostics. */
58
60
  source: string;
@@ -318,6 +320,12 @@ export interface JsxPlatform {
318
320
  * block appears. React: `'react'`. Preact: `'preact/compat'`.
319
321
  */
320
322
  suspense: string;
323
+ /**
324
+ * Module that exports the target runtime `Dynamic` component. When set,
325
+ * the shared JSX transform treats imported `Dynamic` elements with an
326
+ * `is` prop as runtime-dynamic for scoped CSS pruning.
327
+ */
328
+ dynamic?: string;
321
329
  /**
322
330
  * Module to import `TsrxErrorBoundary` from when an `@try { ... } @catch (...)`
323
331
  * block appears. Usually `'@tsrx/<platform>/error-boundary'`.
@@ -1,4 +1,5 @@
1
1
  export function escape<V>(value: V, is_attr?: boolean): string;
2
2
  export function escape_script(str: string): string;
3
3
  export function is_boolean_attribute(name: string): boolean;
4
+ export function is_void_element(name: string): boolean;
4
5
  export function normalize_css_property_name(str: string): string;
@@ -19,3 +19,7 @@ export function iterable_array_from<T>(
19
19
  iterable: Iterable<T> | Iterator<T> | ArrayLike<T>,
20
20
  index?: number,
21
21
  ): T[];
22
+ export function exclude_prop_from_object(
23
+ props: Record<PropertyKey, any> | null | undefined,
24
+ exclude_prop: PropertyKey,
25
+ ): Record<PropertyKey, any>;