@stillwind/host 0.10.1 → 0.11.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @stillwind/host
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies:
8
+ - @stillwind/config@0.11.0
9
+ - @stillwind/native@0.11.0
10
+ - @stillwind/projection@0.11.0
11
+
3
12
  ## 0.10.1
4
13
 
5
14
  ### Patch Changes
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as fileSourceKind, E as CompilationProject, F as prepareSourcePlugins, M as attachPlugins, _ as defaultPluginExport, a as pluginDirectory, b as analyzeModule, c as CheckerSource, d as queryDesignSystem, f as isStylesheet, h as loadEditorCssGraph, i as completePluginPaths, j as TypeFactsError, l as checkerId, m as loadCssGraph, n as cssEntrypoint, o as queryPluginPaths, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, y as finalizeCss } from "./options-CHkqG1Gc.js";
1
+ import { A as fileSourceKind, E as CompilationProject, F as prepareSourcePlugins, M as attachPlugins, _ as defaultPluginExport, a as pluginDirectory, b as analyzeModule, c as CheckerSource, d as queryDesignSystem, f as isStylesheet, h as loadEditorCssGraph, i as completePluginPaths, j as TypeFactsError, l as checkerId, m as loadCssGraph, n as cssEntrypoint, o as queryPluginPaths, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, y as finalizeCss } from "./options-CA4ymTHc.js";
2
2
  import { t as resolveVirtualModule } from "./resolution-C5o_tmY3.js";
3
3
  import { NativeProjectSession, fingerprint } from "@stillwind/native";
4
4
  import ts from "typescript-6";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as fileSourceKind, C as CompilationFailure, D as ResolutionMismatchError, E as CompilationProject, F as prepareSourcePlugins, M as attachPlugins, N as compileWithPlugins, O as sourceKey, P as pluginLoader, S as warnRejectedNames, T as tracePhase, _ as defaultPluginExport, a as pluginDirectory, b as analyzeModule, c as CheckerSource, d as queryDesignSystem, f as isStylesheet, g as PluginRuntime, h as loadEditorCssGraph, i as completePluginPaths, j as TypeFactsError, k as cleanModuleId, l as checkerId, m as loadCssGraph, n as cssEntrypoint, o as queryPluginPaths, p as lintsStylesheet, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, v as cssBannerPrefix, w as startPhase, x as compileModule, y as finalizeCss } from "./options-CHkqG1Gc.js";
1
+ import { A as fileSourceKind, C as CompilationFailure, D as ResolutionMismatchError, E as CompilationProject, F as prepareSourcePlugins, M as attachPlugins, N as compileWithPlugins, O as sourceKey, P as pluginLoader, S as warnRejectedNames, T as tracePhase, _ as defaultPluginExport, a as pluginDirectory, b as analyzeModule, c as CheckerSource, d as queryDesignSystem, f as isStylesheet, g as PluginRuntime, h as loadEditorCssGraph, i as completePluginPaths, j as TypeFactsError, k as cleanModuleId, l as checkerId, m as loadCssGraph, n as cssEntrypoint, o as queryPluginPaths, p as lintsStylesheet, r as StylesheetEditor, s as EditorSnapshot, t as compilerOptions, u as withRequestedProbes, v as cssBannerPrefix, w as startPhase, x as compileModule, y as finalizeCss } from "./options-CA4ymTHc.js";
2
2
  import { createRequire, syncBuiltinESMExports } from "node:module";
3
3
  import { NativeProjectSession, fingerprint } from "@stillwind/native";
4
4
  import path, { isAbsolute, relative, resolve } from "node:path";
@@ -2950,7 +2950,7 @@ function sortSource(source, index, candidates, options, seed = [], allows) {
2950
2950
  let edits = [...seed];
2951
2951
  const permits = allows ?? (() => true);
2952
2952
  if (options.stringLiterals !== false) {
2953
- const literals = index.literals.filter((literal) => literal.source === source && literal.context === "utility" && permits(literal.boundaries[0], literal.boundaries.at(-1))).map((literal) => {
2953
+ const literals = index.literals.filter((literal) => literal.source === source && literal.context === "utility" && !literal.key && permits(literal.boundaries[0], literal.boundaries.at(-1))).map((literal) => {
2954
2954
  const matches = [...literal.text.matchAll(/\S+/gu)];
2955
2955
  const original = matches.map((match) => match[0]);
2956
2956
  const spellings = matches.map((match) => {
@@ -3954,7 +3954,16 @@ var SourceIndex = class {
3954
3954
  this.#bindings = new SourceBindings(graph, session);
3955
3955
  for (const { source, ast } of this.#bindings.files.values()) {
3956
3956
  walk(ast, (node) => {
3957
+ if (ts.isTaggedTemplateExpression(node) && ts.isNoSubstitutionTemplateLiteral(node.template) && this.asset(source, node.tag)?.identity.kind === "ref") {
3958
+ this.#literal(source, node.template, "", "elementVariants");
3959
+ return;
3960
+ }
3957
3961
  if (!ts.isCallExpression(node)) return;
3962
+ if (this.asset(source, node.expression)?.identity.kind === "ref") {
3963
+ const [argument] = node.arguments;
3964
+ if (node.arguments.length === 1 && ts.isStringLiteralLike(argument)) this.#literal(source, argument, "", "elementVariants");
3965
+ return;
3966
+ }
3958
3967
  const asset = this.asset(source, node);
3959
3968
  if (asset?.identity.kind === "style" || this.#bindings.styleImport(node.expression)) {
3960
3969
  if (node.arguments.length > 1) this.#containers.push({
@@ -3997,6 +4006,14 @@ var SourceIndex = class {
3997
4006
  for (const argument of node.arguments) if (ts.isStringLiteralLike(argument)) this.#literal(source, argument, "", "mediaVariants");
3998
4007
  return;
3999
4008
  }
4009
+ if (this.#bindings.producer(node.expression, "when")) {
4010
+ for (const argument of node.arguments) if (ts.isStringLiteralLike(argument)) this.#literal(source, argument, "", "elementVariants");
4011
+ return;
4012
+ }
4013
+ if (this.#bindings.producer(node.expression, "cva")) {
4014
+ this.#cva(source, node);
4015
+ return;
4016
+ }
4000
4017
  if (this.asset(source, node.expression)?.identity.kind === "keyframes") {
4001
4018
  const options = node.arguments[0];
4002
4019
  if (options && ts.isStringLiteralLike(options)) this.#literal(source, options, "", "animationOptions");
@@ -4070,6 +4087,16 @@ var SourceIndex = class {
4070
4087
  return this.#bindings.asset(source, node);
4071
4088
  }
4072
4089
  /**
4090
+ * Recognizes a call of an imported Stillwind style producer or of one of its methods,
4091
+ * such as `style()` or `style.when()`.
4092
+ *
4093
+ * @param node - Call in one of this index's checker ASTs.
4094
+ * @returns Whether the callee is a supported `style` import or a method of one.
4095
+ */
4096
+ styleCall(node) {
4097
+ return this.#bindings.styleImport(node.expression) || ts.isPropertyAccessExpression(node.expression) && this.#bindings.styleImport(node.expression.expression);
4098
+ }
4099
+ /**
4073
4100
  * Returns the comments that contain `swlint-*` directives in `source`'s original buffer.
4074
4101
  *
4075
4102
  * @param source - Prepared source of this index.
@@ -4112,7 +4139,8 @@ var SourceIndex = class {
4112
4139
  }
4113
4140
  /**
4114
4141
  * Indexes the static utility literals of one `style.css()` input with their group keys.
4115
- * Runtime values and computed keys add no literals.
4142
+ * String-literal keys are recorded as variant keys. Runtime values and computed keys add
4143
+ * no literals.
4116
4144
  *
4117
4145
  * @param source - Prepared source stored in this index.
4118
4146
  * @param node - Input in that source's checker AST.
@@ -4135,6 +4163,7 @@ var SourceIndex = class {
4135
4163
  }
4136
4164
  if (ts.isObjectLiteralExpression(node)) for (const property of node.properties) {
4137
4165
  if (!ts.isPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) continue;
4166
+ this.#key(source, property, prefix, context);
4138
4167
  const name = propertyName(property);
4139
4168
  if (name === "" || name.endsWith(":")) this.#cssInput(source, property.initializer, name === ":" ? prefix : prefix + name, context);
4140
4169
  }
@@ -4147,6 +4176,7 @@ var SourceIndex = class {
4147
4176
  * @param source - Prepared source whose checker AST contains `node`.
4148
4177
  * @param node - Input expression to inspect. Object properties ending in `:` contribute
4149
4178
  * their values under the accumulated group variants. The keys `""` and `":"` add no variants.
4179
+ * String-literal keys are recorded as variant keys.
4150
4180
  * @param prefix - Decoded enclosing variants, including trailing colons. Nested group
4151
4181
  * names are appended before their literals are recorded.
4152
4182
  */
@@ -4196,7 +4226,8 @@ var SourceIndex = class {
4196
4226
  });
4197
4227
  for (const property of node.properties) {
4198
4228
  if (!ts.isPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) continue;
4199
- const name = ts.isStringLiteralLike(property.name) ? property.name.text : property.name.getText();
4229
+ this.#key(source, property, prefix, "utility");
4230
+ const name = propertyName(property);
4200
4231
  if (name !== "" && !name.endsWith(":")) continue;
4201
4232
  this.#input(source, property.initializer, name === ":" ? prefix : prefix + name);
4202
4233
  }
@@ -4222,6 +4253,71 @@ var SourceIndex = class {
4222
4253
  else if (ts.isStringLiteralLike(value)) this.#literal(source, value, prefix);
4223
4254
  }
4224
4255
  /**
4256
+ * Records a string-literal object key as a variant key. A key that is complete, incomplete,
4257
+ * empty, or `":"` is recorded, so completion can suggest variants while the key is written.
4258
+ * `class`, `className`, and custom-property keys are not variant keys.
4259
+ *
4260
+ * @param source - Prepared source whose checker AST contains `property`.
4261
+ * @param property - Property of an object written directly in a style input.
4262
+ * @param prefix - Decoded variants of the enclosing keys, each ending in `:`.
4263
+ * @param context - Input role of the values that the key applies to.
4264
+ */
4265
+ #key(source, property, prefix, context) {
4266
+ const name = property.name;
4267
+ if (!ts.isStringLiteralLike(name) || name.text === "class" || name.text === "className" || name.text.startsWith("--")) return;
4268
+ const literal = this.#literal(source, name, prefix, context);
4269
+ if (literal) literal.key = true;
4270
+ }
4271
+ /**
4272
+ * Records the variant keys of a `style.cva()` call. The compiler captures the utility
4273
+ * literals of the call, so this method adds only keys.
4274
+ *
4275
+ * @param source - Prepared source whose checker AST contains `call`.
4276
+ * @param call - Call whose callee is the `cva` method of a Stillwind style import.
4277
+ * Keys are read from the base input, from each option of `variants`, and from the
4278
+ * `class` and `className` inputs of `compoundVariants`. Other syntax adds nothing.
4279
+ */
4280
+ #cva(source, call) {
4281
+ const [base, config] = call.arguments;
4282
+ this.#cvaInput(source, base, "");
4283
+ if (!config || !ts.isObjectLiteralExpression(config)) return;
4284
+ for (const property of config.properties) {
4285
+ if (!ts.isPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) continue;
4286
+ const name = propertyName(property);
4287
+ const value = property.initializer;
4288
+ if (name === "variants" && ts.isObjectLiteralExpression(value)) {
4289
+ for (const axis of value.properties) if (ts.isPropertyAssignment(axis) && ts.isObjectLiteralExpression(axis.initializer)) {
4290
+ for (const option of axis.initializer.properties) if (ts.isPropertyAssignment(option)) this.#cvaInput(source, option.initializer, "");
4291
+ }
4292
+ } else if (name === "compoundVariants" && ts.isArrayLiteralExpression(value)) for (const compound of value.elements) {
4293
+ if (!ts.isObjectLiteralExpression(compound)) continue;
4294
+ for (const entry of compound.properties) if (ts.isPropertyAssignment(entry) && !ts.isComputedPropertyName(entry.name) && ["class", "className"].includes(propertyName(entry))) this.#cvaInput(source, entry.initializer, "");
4295
+ }
4296
+ }
4297
+ }
4298
+ /**
4299
+ * Records the variant keys in one CVA utility input, including keys in nested arrays and
4300
+ * variant groups.
4301
+ *
4302
+ * @param source - Prepared source whose checker AST contains `node`.
4303
+ * @param node - CVA input, or undefined for an omitted argument.
4304
+ * @param prefix - Decoded variants of the enclosing keys, each ending in `:`.
4305
+ */
4306
+ #cvaInput(source, node, prefix) {
4307
+ while (node && (ts.isParenthesizedExpression(node) || ts.isAsExpression(node) || ts.isSatisfiesExpression(node))) node = node.expression;
4308
+ if (!node) return;
4309
+ if (ts.isArrayLiteralExpression(node)) {
4310
+ for (const element of node.elements) this.#cvaInput(source, element, prefix);
4311
+ return;
4312
+ }
4313
+ if (ts.isObjectLiteralExpression(node)) for (const property of node.properties) {
4314
+ if (!ts.isPropertyAssignment(property) || ts.isComputedPropertyName(property.name)) continue;
4315
+ this.#key(source, property, prefix, "utility");
4316
+ const name = propertyName(property);
4317
+ if (name === "" || name.endsWith(":")) this.#cvaInput(source, property.initializer, name === ":" ? prefix : prefix + name);
4318
+ }
4319
+ }
4320
+ /**
4225
4321
  * Records decoded content and original UTF-16 boundaries for a literal in `source`'s AST.
4226
4322
  * A captured `site` overrides an existing entry's context and plan at the same content start.
4227
4323
  * Unmapped ranges or decoding that disagrees with the AST add nothing.
@@ -4232,6 +4328,8 @@ var SourceIndex = class {
4232
4328
  * @param context - Input role stored with a new entry. Defaults to ordinary utilities.
4233
4329
  * @param site - Optional captured input. An existing entry keeps its prefix and boundaries
4234
4330
  * when this site replaces its context and plan.
4331
+ * @returns The new entry, or undefined when the literal is unmapped, cannot be decoded, or
4332
+ * already has an entry.
4235
4333
  */
4236
4334
  #literal(source, node, prefix, context = "utility", site) {
4237
4335
  const range = this.range(source, node);
@@ -4248,14 +4346,16 @@ var SourceIndex = class {
4248
4346
  }
4249
4347
  return;
4250
4348
  }
4251
- this.#literals.push({
4349
+ const literal = {
4252
4350
  source,
4253
4351
  node,
4254
4352
  prefix,
4255
4353
  context,
4256
4354
  site,
4257
4355
  ...decoded
4258
- });
4356
+ };
4357
+ this.#literals.push(literal);
4358
+ return literal;
4259
4359
  }
4260
4360
  }
4261
4361
  };
@@ -4475,7 +4575,7 @@ var SourceQueries = class {
4475
4575
  return result;
4476
4576
  }
4477
4577
  if (request.kind === "previews") {
4478
- result.previews = this.#index.previews.sites(source).filter((site) => site.native.kind !== "input").flatMap((site) => {
4578
+ result.previews = this.#index.previews.sites(source).filter((site) => site.native.kind !== "input" && site.native.kind !== "variant").flatMap((site) => {
4479
4579
  const preview = this.#index.previews.assemble(site.native);
4480
4580
  const range = {
4481
4581
  start: site.start,
@@ -4504,7 +4604,7 @@ var SourceQueries = class {
4504
4604
  const tokens = this.#sourceTokens(source);
4505
4605
  if (request.kind === "colors") {
4506
4606
  result.colors = tokens.flatMap((token) => {
4507
- if (!this.#colorInput(token.literal) || !this.#preview(token.literal, token.text)) return [];
4607
+ if (!this.#colorInput(token.literal) || !this.#preview(token.literal, token.text, token.site)) return [];
4508
4608
  return this.#candidates.colors(token.literal.prefix + token.text).map(({ scheme, ...color }) => ({
4509
4609
  start: token.start,
4510
4610
  end: token.end,
@@ -4518,7 +4618,7 @@ var SourceQueries = class {
4518
4618
  const token = tokens.find((token) => token.start === request.start && token.end === request.end);
4519
4619
  if (!token || !this.#colorInput(token.literal)) return result;
4520
4620
  const candidate = colorReplacement(token.text, token.literal.prefix, request.color, this.#candidates);
4521
- if (candidate && this.#preview(token.literal, candidate)) result.edits = [{
4621
+ if (candidate && this.#preview(token.literal, candidate, token.site)) result.edits = [{
4522
4622
  start: token.start,
4523
4623
  end: token.end,
4524
4624
  newText: escapeContent(candidate, token.literal)
@@ -4527,9 +4627,15 @@ var SourceQueries = class {
4527
4627
  }
4528
4628
  const token = tokens.find((token) => token.start <= request.offset && request.offset <= token.end);
4529
4629
  if (request.kind === "hover") {
4630
+ const variant = this.#variantPreview(source, request.offset);
4631
+ if (variant !== false) {
4632
+ result.hover = variant;
4633
+ return result;
4634
+ }
4530
4635
  if (token) {
4531
- const css = this.#preview(token.literal, token.text);
4532
- const marker = this.#candidates.marker(token.literal.prefix + token.text, token.literal.context);
4636
+ const candidate = token.literal.prefix + token.text;
4637
+ const css = token.literal.key ? this.#candidates.variant(candidate, token.literal.context) : this.#preview(token.literal, token.text, token.site);
4638
+ const marker = token.literal.key ? null : this.#candidates.marker(candidate, token.literal.context);
4533
4639
  if (css || marker) result.hover = {
4534
4640
  start: token.start,
4535
4641
  end: token.end,
@@ -4542,9 +4648,10 @@ var SourceQueries = class {
4542
4648
  const input = this.#completionInput(source, request.offset);
4543
4649
  if (!input) return result;
4544
4650
  const { literal, start, end, prefix } = input;
4545
- const native = this.#candidates.complete(literal.prefix + prefix, literal.context, request.snippets === true).filter(({ label, marker }) => marker || label.endsWith(":") || !literal.site || this.#preview(literal, label.slice(literal.prefix.length)));
4651
+ const native = this.#candidates.complete(literal.prefix + prefix, literal.context, request.snippets === true).filter(({ label, marker }) => literal.key ? !marker && label.endsWith(":") : marker || label.endsWith(":") || !literal.site || this.#preview(literal, label.slice(literal.prefix.length)));
4546
4652
  const known = new Set(native.map(({ label }) => label));
4547
- result.completions = [...native, ...this.#catalogCompletions(literal.prefix + prefix, literal.context).filter((candidate) => !known.has(candidate)).map((label) => ({
4653
+ const catalog = literal.key ? [] : this.#catalogCompletions(literal.prefix + prefix, literal.context);
4654
+ result.completions = [...native, ...catalog.filter((candidate) => !known.has(candidate)).map((label) => ({
4548
4655
  label,
4549
4656
  marker: false
4550
4657
  }))].map(({ label: candidate, marker }) => {
@@ -4618,11 +4725,13 @@ var SourceQueries = class {
4618
4725
  *
4619
4726
  * @param literal - Indexed literal that supplies the input role, enclosing variants, and plan.
4620
4727
  * @param candidate - Decoded text without the literal's enclosing group prefix.
4728
+ * @param site - Captured input whose plan is rendered. Defaults to the literal's capture.
4729
+ * A template token can have its own capture.
4621
4730
  * @returns CSS for the replacement, or undefined for failed or unavailable emission.
4622
4731
  * @throws If a matching ordinary utility requirement is malformed in a standalone query.
4623
4732
  */
4624
- #preview(literal, candidate) {
4625
- if (literal.site) return this.#index.previews.previewInput(literal.source, literal.site.native.start, candidate);
4733
+ #preview(literal, candidate, site = literal.site) {
4734
+ if (site) return this.#index.previews.previewInput(literal.source, site.native.start, candidate);
4626
4735
  return this.#candidates.preview(literal.prefix + candidate, literal.context) ?? void 0;
4627
4736
  }
4628
4737
  /**
@@ -4663,7 +4772,8 @@ var SourceQueries = class {
4663
4772
  #sourceTokens(source) {
4664
4773
  return this.#index.literals.filter((literal) => literal.source === source).flatMap((literal) => this.#tokens(literal).map((token) => ({
4665
4774
  ...token,
4666
- literal
4775
+ literal,
4776
+ site: literal.site ?? (ts.isTemplateLiteralToken(literal.node) ? this.#index.previews.input(source, token.start, token.end) : void 0)
4667
4777
  })));
4668
4778
  }
4669
4779
  /**
@@ -4692,13 +4802,14 @@ var SourceQueries = class {
4692
4802
  }
4693
4803
  /**
4694
4804
  * Allows color operations only for input roles that emit utility declarations.
4695
- * Option and definition-prefix inputs use different value contracts.
4805
+ * Option and definition-prefix inputs use different value contracts, and variant keys
4806
+ * emit no declarations.
4696
4807
  *
4697
4808
  * @param literal - Indexed literal whose context supplies the input role.
4698
4809
  * @returns Whether its role supports a utility candidate's concrete color and replacement.
4699
4810
  */
4700
4811
  #colorInput(literal) {
4701
- return [
4812
+ return !literal.key && [
4702
4813
  "utility",
4703
4814
  "keyframesFrame",
4704
4815
  "viewTransitionUtilities"
@@ -4712,11 +4823,50 @@ var SourceQueries = class {
4712
4823
  * @returns Tokens in source order, without trimming or decoding them again.
4713
4824
  */
4714
4825
  #tokens(literal) {
4715
- return [...literal.text.matchAll(/\S+/gu)].map((match) => ({
4716
- text: match[0],
4717
- start: literal.boundaries[match.index],
4718
- end: literal.boundaries[match.index + match[0].length]
4719
- }));
4826
+ const continued = ts.isTemplateMiddle(literal.node) || ts.isTemplateTail(literal.node);
4827
+ return [...literal.text.matchAll(/\S+/gu)].flatMap((match) => {
4828
+ const skip = continued && match.index === 0 && match[0].startsWith(":") ? 1 : 0;
4829
+ const text = match[0].slice(skip);
4830
+ return text ? [{
4831
+ text,
4832
+ start: literal.boundaries[match.index + skip],
4833
+ end: literal.boundaries[match.index + match[0].length]
4834
+ }] : [];
4835
+ });
4836
+ }
4837
+ /**
4838
+ * Finds the ref or container variant expression at `offset`, such as `trigger("hover:")`,
4839
+ * ``trigger`hover:` ``, `trigger.at("width >= 40rem")`, or `trigger().in(card)`, and its
4840
+ * captured variant preview. The expression extends from the cursor through enclosing
4841
+ * property accesses, calls, and tags, and ends before a call of a style producer.
4842
+ *
4843
+ * @param source - Prepared source stored in this snapshot's index.
4844
+ * @param offset - Cursor offset in the original document's UTF-16 coordinates.
4845
+ * @returns The formatted selectors and conditions of the first captured variant in that
4846
+ * expression, with the expression's original range; undefined when the expression is a ref
4847
+ * variant without a valid capture, such as one whose stored variant has no use; or false when
4848
+ * the cursor is not in a ref variant expression.
4849
+ * @throws If the native formatter rejects the captured CSS.
4850
+ */
4851
+ #variantPreview(source, offset) {
4852
+ let node = this.#index.nodeAt(source, offset);
4853
+ let expression;
4854
+ let reference = false;
4855
+ while (node && (ts.isIdentifier(node) || ts.isStringLiteralLike(node) || ts.isPropertyAccessExpression(node) || ts.isParenthesizedExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isCallExpression(node) && !this.#index.styleCall(node))) {
4856
+ const callee = ts.isCallExpression(node) ? node.expression : ts.isTaggedTemplateExpression(node) ? node.tag : void 0;
4857
+ if (callee && (this.#index.asset(source, callee)?.identity.kind === "ref" || ts.isPropertyAccessExpression(callee) && ["at", "in"].includes(callee.name.text))) reference = true;
4858
+ expression = node;
4859
+ node = node.parent;
4860
+ }
4861
+ const range = expression && this.#index.range(source, expression);
4862
+ if (!reference || !range) return false;
4863
+ const site = this.#index.previews.sites(source).find((site) => site.native.kind === "variant" && range[0] <= site.start && site.end <= range[1]);
4864
+ const preview = site && this.#index.previews.preview(site.native);
4865
+ return preview ? {
4866
+ start: range[0],
4867
+ end: range[1],
4868
+ css: this.#query.formatCss(preview.css, this.#annotations)
4869
+ } : void 0;
4720
4870
  }
4721
4871
  };
4722
4872
  // src/editor/snapshot.ts
@@ -5368,4 +5518,4 @@ function compilerOptions(config) {
5368
5518
  }
5369
5519
  export { fileSourceKind as A, CompilationFailure as C, ResolutionMismatchError as D, CompilationProject as E, prepareSourcePlugins as F, attachPlugins as M, compileWithPlugins as N, sourceKey as O, pluginLoader as P, warnRejectedNames as S, tracePhase as T, defaultPluginExport as _, pluginDirectory as a, analyzeModule as b, CheckerSource as c, queryDesignSystem as d, isStylesheet as f, PluginRuntime as g, loadEditorCssGraph as h, completePluginPaths as i, TypeFactsError as j, cleanModuleId as k, checkerId as l, loadCssGraph as m, cssEntrypoint as n, queryPluginPaths as o, lintsStylesheet as p, StylesheetEditor as r, EditorSnapshot as s, compilerOptions as t, withRequestedProbes as u, cssBannerPrefix as v, startPhase as w, compileModule as x, finalizeCss as y };
5370
5520
 
5371
- //# sourceMappingURL=options-CHkqG1Gc.js.map
5521
+ //# sourceMappingURL=options-CA4ymTHc.js.map