svelte-shaker 0.5.2 → 0.7.0

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.
@@ -1,6 +1,6 @@
1
- import { type AnyNode, type Parse, type ParseCache, type Root } from './parse';
2
- import { type AnalyzeInput, type ComponentId, type ComponentPlan, type Literal } from './ir';
3
- import { type Span } from './dead';
1
+ import { type AnyNode, type Parse, type ParseCache, type Root } from './parse.js';
2
+ import { type AnalyzeInput, type ComponentId, type ComponentPlan, type Literal } from './ir.js';
3
+ import { type Span } from './dead.js';
4
4
  export type Resolve = (source: string, importer: ComponentId) => Promise<ComponentId | null> | ComponentId | null;
5
5
  export type ReadFile = (id: ComponentId) => Promise<string> | string;
6
6
  /** One declared prop in a `$props()` destructuring. */
@@ -81,11 +81,15 @@ export interface ChildCall {
81
81
  }
82
82
  /**
83
83
  * One value passed explicitly to a prop at one call site, after last-write-wins
84
- * has been resolved (`{...obj}` aside). `dynamic` means the attribute had a
85
- * non-literal value (`bind:`, dynamic expression): used, value not statically
86
- * known. `afterLastSpread` records whether this explicit write happened after
87
- * the site's last `{...spread}` only then can a spread not silently override
88
- * it (docs §4.1, "後勝ち順序で救う").
84
+ * has been resolved. An explicit write is either a real attribute (`a={1}`) OR a
85
+ * key expanded out of a statically-known object-literal spread (`{...{a:1}}`,
86
+ * docs §4.1) both name a prop and a value the same way. `dynamic` means the
87
+ * value is non-literal (`bind:`, a dynamic expression, or a spread key whose
88
+ * value is non-literal): used, value not statically known. `afterLastSpread`
89
+ * records whether this write happened after the site's last *unknown* spread (one
90
+ * we could not expand) — only then can no spread silently override it (docs §4.1,
91
+ * "後勝ち順序で救う"). A known object-literal spread is expanded, not opaque, so
92
+ * it never counts as an "unknown spread" here.
89
93
  */
90
94
  export interface ExplicitProp {
91
95
  value: Literal;
@@ -94,7 +98,12 @@ export interface ExplicitProp {
94
98
  }
95
99
  /** How a child component is called at one `<Child .../>` site. */
96
100
  export interface CallSite {
97
- /** Did this site have at least one `{...spread}` attribute? */
101
+ /**
102
+ * Did this site have at least one spread we could NOT statically expand (an
103
+ * identifier / call / `{...{…computed/nested…}}`)? A fully-known object-literal
104
+ * spread is expanded into {@link ExplicitProp} writes instead, so it does not
105
+ * set this — only an opaque spread, which may set any prop, does (docs §4.1).
106
+ */
98
107
  hadSpread: boolean;
99
108
  /** Last-write-wins explicit props at this site, keyed by prop name. */
100
109
  explicit: Map<string, ExplicitProp>;
@@ -160,7 +169,11 @@ export declare function remapToLocalNames<V>(map: Map<string, V>, model: FileMod
160
169
  * Read one `<Child .../>` into a {@link CallSite}. Attributes are in source
161
170
  * order, so we resolve last-write-wins (a later `a={…}` overrides an earlier
162
171
  * one) and record, per prop, whether its winning write came *after* the last
163
- * spread — the only case a spread cannot silently override it (docs §4.1).
172
+ * *unknown* spread — the only case a spread cannot silently override it (docs
173
+ * §4.1). A statically-known object-literal spread (`{...{a:1, b:2}}`) is not
174
+ * opaque: we expand its keys into explicit writes at the spread's position, so it
175
+ * both contributes those literals AND does not poison props it cannot set (docs
176
+ * §4.1, "{...obj} が object literal ならキー展開").
164
177
  */
165
178
  export declare function readCallSite(component: AnyNode): CallSite;
166
179
  /** Decide what to fold for one component from its global usage. */