@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.
@@ -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';
@@ -117,7 +118,6 @@ interface BaseNodeMetaData {
117
118
  interface FunctionMetaData extends BaseNodeMetaData {
118
119
  native_tsrx?: boolean;
119
120
  native_tsrx_function?: boolean;
120
- hook_split?: boolean;
121
121
  is_method?: boolean;
122
122
  tracked?: boolean;
123
123
  has_lazy_descendants?: boolean;
@@ -182,7 +182,6 @@ declare module 'estree' {
182
182
 
183
183
  interface BlockStatement {
184
184
  metadata: BaseNodeMetaData & {
185
- hook_split_block?: boolean;
186
185
  native_return_block?: boolean;
187
186
  native_tsrx_template_block?: boolean;
188
187
  allows_native_return?: boolean;
@@ -231,8 +230,7 @@ declare module 'estree' {
231
230
  lazy?: boolean;
232
231
  }
233
232
 
234
- // We mark the whole node as marked when member is @[expression]
235
- // Otherwise, we only mark Identifier nodes
233
+ // Ripple analysis may mark a whole member expression as tracked metadata.
236
234
  interface MemberExpression {
237
235
  tracked?: boolean;
238
236
  }
@@ -700,7 +698,6 @@ declare module 'estree-jsx' {
700
698
  }
701
699
 
702
700
  interface JSXIdentifier {
703
- tracked?: boolean;
704
701
  metadata: BaseNodeMetaData & {
705
702
  is_component?: boolean;
706
703
  };
@@ -1292,7 +1289,6 @@ export interface Binding {
1292
1289
  is_called: boolean;
1293
1290
  /** Additional metadata for this binding */
1294
1291
  metadata: {
1295
- is_dynamic_component?: boolean;
1296
1292
  pattern?: AST.Identifier;
1297
1293
  is_ripple_object?: boolean;
1298
1294
  is_template_value?: boolean;
@@ -1450,7 +1446,6 @@ export interface TransformServerState extends BaseState {
1450
1446
  namespace: NameSpace;
1451
1447
  server_block_locals: AST.VariableDeclaration[];
1452
1448
  server_exported_names: string[];
1453
- dynamicElementName?: AST.TemplateLiteral;
1454
1449
  applyParentCssScope?: AST.CSS.StyleSheet['hash'];
1455
1450
  dev?: boolean;
1456
1451
  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;
@@ -100,7 +102,7 @@ export interface JsxTransformOptions {
100
102
  comments?: AST.CommentWithLocation[];
101
103
  /**
102
104
  * Override whether hook-isolation helper components are emitted directly at
103
- * module scope. React runtime compilation enables this, while editor tooling
105
+ * module scope. Some runtime targets enable this, while editor tooling
104
106
  * can disable it to preserve lexical `typeof` helper prop types.
105
107
  */
106
108
  moduleScopedHookComponents?: boolean;
@@ -158,15 +160,10 @@ export interface JsxPlatformHooks {
158
160
  /**
159
161
  * Emit hook-isolation helper components as unique module-scope declarations
160
162
  * instead of lazily creating and caching them from the parent component body.
161
- * React enables this so generated branches stay compatible with the React
162
- * Compiler's Rules of Hooks validation.
163
+ * Targets that use compiler-generated branch helpers enable this so helper
164
+ * declarations are shared across renders.
163
165
  */
164
166
  moduleScopedHookComponents?: boolean;
165
- /**
166
- * Split ordinary uppercase function component bodies when an early
167
- * conditional return would make later React/Preact hooks conditional.
168
- */
169
- componentBodyHookHelpers?: boolean;
170
167
  /**
171
168
  * Inject module-level imports after the main walk. Default: import
172
169
  * `Suspense` from `platform.imports.suspense` and `TsrxErrorBoundary`
@@ -318,6 +315,12 @@ export interface JsxPlatform {
318
315
  * block appears. React: `'react'`. Preact: `'preact/compat'`.
319
316
  */
320
317
  suspense: string;
318
+ /**
319
+ * Module that exports the target runtime `Dynamic` component. When set,
320
+ * the shared JSX transform treats imported `Dynamic` elements with an
321
+ * `is` prop as runtime-dynamic for scoped CSS pruning.
322
+ */
323
+ dynamic?: string;
321
324
  /**
322
325
  * Module to import `TsrxErrorBoundary` from when an `@try { ... } @catch (...)`
323
326
  * 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>;