sveld 0.28.0 → 0.29.1

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.
@@ -80,7 +80,7 @@ interface ComponentSlot {
80
80
  fallback?: string;
81
81
  /** TypeScript type definition for slot props (e.g., "{ title: string }") */
82
82
  slot_props?: string;
83
- /** Description extracted from JSDoc `@slot` tags */
83
+ /** Description extracted from JSDoc `@slot` or `@snippet` tags */
84
84
  description?: string;
85
85
  }
86
86
  /**
@@ -262,6 +262,8 @@ export interface ParsedComponent {
262
262
  export default class ComponentParser {
263
263
  /** Parser configuration options (e.g., verbose logging) */
264
264
  private options?;
265
+ /** Whether the component uses legacy or runes syntax according to compiler metadata */
266
+ private syntaxMode;
265
267
  /** Raw source code of the Svelte component being parsed */
266
268
  private source?;
267
269
  /** Compiled Svelte code containing extracted variables and AST */
@@ -300,17 +302,55 @@ export default class ComponentParser {
300
302
  private readonly contexts;
301
303
  /** Cache for variable type and description information to avoid redundant lookups */
302
304
  private variableInfoCache;
305
+ /** Maps local binding names back to their public prop names */
306
+ private readonly propLocalToPublicName;
307
+ /** Tracks `$props()` bindings that are used as spread/rest props */
308
+ private readonly restPropLocals;
309
+ /** Tracks prop locals that are used as snippet/render props */
310
+ private readonly snippetPropLocals;
311
+ /** Per-declarator type metadata extracted from modern AST `$props()` annotations */
312
+ private readonly runesPropTypeMetadataByDeclaratorStart;
313
+ /** Component-level lexical scope shared by instance script and template */
314
+ private readonly componentScope;
315
+ /** Precomputed lexical scopes for nested AST nodes */
316
+ private scopeDeclarations;
317
+ /** Active lexical scopes while walking the component AST */
318
+ private readonly activeScopes;
303
319
  /** Cached array of source code lines split by newline for efficient line-based operations */
304
320
  private sourceLinesCache?;
305
321
  constructor(options?: ComponentParserOptions);
306
322
  private static mapToArray;
307
323
  private static assignValue;
324
+ private resolvePublicPropName;
325
+ private trackPropLocalName;
326
+ private getPropByLocalOrPublic;
327
+ private getPropTypeByLocalOrPublic;
328
+ private getRunesPropTypeMetadata;
329
+ private declareScopeBinding;
330
+ private resolveIdentifierToReactiveProp;
331
+ private collectPatternIdentifiers;
332
+ private markReactivePropsFromMutationTarget;
333
+ private isScopeOwner;
334
+ private isFunctionScopeOwner;
335
+ private getOrCreateScope;
336
+ private declareVariableDeclaration;
337
+ private declareFunctionLikeScopeBindings;
338
+ private collectDirectBlockDeclarations;
339
+ private extractRunesScopeBindings;
340
+ private collectComponentScopeDeclarations;
341
+ private collectNestedScopeDeclarations;
342
+ private buildScopeDeclarations;
343
+ private createRestPropsFromParent;
344
+ private maybeSetRestProps;
345
+ private isCallExpressionNamed;
346
+ private getPropertyName;
347
+ private logUnsupportedRunesPattern;
308
348
  private static formatComment;
309
349
  /**
310
350
  * Extracts and categorizes JSDoc tags from a parsed comment.
311
351
  *
312
352
  * Separates tags into type, param, returns, and additional categories while
313
- * excluding tags that are handled separately (extends, restProps, slot, event, typedef).
353
+ * excluding tags that are handled separately (extends, restProps, slot/snippet, event, typedef).
314
354
  *
315
355
  * @param parsed - The parsed comment result from comment-parser
316
356
  * @returns An object containing categorized tags and the comment description
@@ -351,6 +391,9 @@ export default class ComponentParser {
351
391
  * ```
352
392
  */
353
393
  private static findJSDocComment;
394
+ private findAdjacentJSDocComment;
395
+ private processNodeJSDoc;
396
+ private processLeadingCommentsJSDoc;
354
397
  /**
355
398
  * Processes JSDoc comments from leadingComments and extracts structured information.
356
399
  *
@@ -384,6 +427,7 @@ export default class ComponentParser {
384
427
  * ```
385
428
  */
386
429
  private processJSDocComment;
430
+ private buildRunesPropTypeMetadata;
387
431
  /**
388
432
  * Checks if a MemberExpression represents a well-known numeric constant.
389
433
  *
@@ -446,12 +490,16 @@ export default class ComponentParser {
446
490
  */
447
491
  private processInitializer;
448
492
  /**
449
- * Collects reactive variables from the compiled Svelte component.
450
- *
451
- * Reactive variables are those that are both reassigned and writable,
452
- * indicating they can change and trigger reactivity in Svelte.
493
+ * Unwraps `$bindable(...)` calls so defaults are documented as their underlying values.
494
+ */
495
+ private unwrapBindableInitializer;
496
+ /**
497
+ * Extracts component props from top-level `$props()` declarations in runes components.
453
498
  */
454
- private collectReactiveVars;
499
+ private parseRunesPropsDeclaration;
500
+ private inferSlotPropValueFromExpression;
501
+ private buildSlotPropsFromObjectExpression;
502
+ private extractRenderTagInfo;
455
503
  /**
456
504
  * Adds or merges a component prop to the props map.
457
505
  *
@@ -597,6 +645,7 @@ export default class ComponentParser {
597
645
  * ```
598
646
  */
599
647
  private addDispatchedEvent;
648
+ private normalizeRunesCallbackProps;
600
649
  /**
601
650
  * Parses custom types, events, slots, and other JSDoc annotations from component comments.
602
651
  *