@stacksjs/stx-vscode 0.2.353 → 0.2.355

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.
@@ -41,8 +41,9 @@
41
41
  "category": "stx"
42
42
  },
43
43
  {
44
- "command": "css.reload",
45
- "title": "Css: Reload Configuration"
44
+ "command": "stx.reloadUtilityClasses",
45
+ "title": "Reload Utility Class Configuration",
46
+ "category": "stx"
46
47
  }
47
48
  ],
48
49
  "configuration": {
@@ -158,10 +159,11 @@
158
159
  "default": true,
159
160
  "description": "Enable autocomplete for utility classes"
160
161
  },
161
- "css.remToPxRatio": {
162
+ "stx.utilityClasses.remToPxRatio": {
162
163
  "type": "number",
163
164
  "default": 16,
164
- "description": "Rem to px conversion ratio for hover previews"
165
+ "minimum": 0,
166
+ "markdownDescription": "Pixels per `rem` for the px values utility-class hovers show next to `rem` values. `0` hides them. Replaces `css.remToPxRatio`, which is still read when this is not set."
165
167
  }
166
168
  }
167
169
  }
package/dist/index.d.ts CHANGED
@@ -35,7 +35,7 @@ export interface StxLanguageOptions {
35
35
  * Register all of stx's runtime language support: hovers, completions,
36
36
  * diagnostics, go to definition, document links, folding, semantic tokens,
37
37
  * code actions, utility-class previews, and the `stx.sortClasses` and
38
- * `css.reload` commands. Everything is added to `context.subscriptions`.
38
+ * `stx.reloadUtilityClasses` commands. Everything is added to `context.subscriptions`.
39
39
  *
40
40
  * Call it at most once per window. The stx extension stands down only for
41
41
  * `Stacks.vscode-stacks`, and only once that extension's `activate` resolves
package/dist/index.js CHANGED
@@ -21,8 +21,7 @@ function extractClassesFromDocument(document, position) {
21
21
  const text = document.getText();
22
22
  const matches = [];
23
23
  const classRegex = /class(?:Name)?=["']([^"']*)["']/g;
24
- let match = classRegex.exec(text);
25
- while (match !== null) {
24
+ for (let match = classRegex.exec(text);match !== null; match = classRegex.exec(text)) {
26
25
  const classContent = match[1];
27
26
  const classStartOffset = match.index + match[0].indexOf(classContent);
28
27
  if (position) {
@@ -44,7 +43,6 @@ function extractClassesFromDocument(document, position) {
44
43
  currentOffset = classIndex + className.length;
45
44
  }
46
45
  }
47
- match = classRegex.exec(text);
48
46
  }
49
47
  return matches;
50
48
  }
@@ -574,12 +572,13 @@ var CSSGenerator, parseClass, builtInRules, cssLoaded = false;
574
572
  // ../vscode/src/ts-css/utils/css-parser.ts
575
573
  import parserCSS from "prettier/parser-postcss";
576
574
  import prettier from "prettier/standalone";
577
- function prettifyCSS(css) {
575
+ async function prettifyCSS(css) {
578
576
  try {
579
- return prettier.format(css, {
577
+ const formatted = await prettier.format(css, {
580
578
  parser: "css",
581
579
  plugins: [parserCSS]
582
- }).trim();
580
+ });
581
+ return formatted.trim();
583
582
  } catch {
584
583
  return css;
585
584
  }
@@ -608,6 +607,17 @@ function addRemToPxComment(css, remToPxRatio = 16) {
608
607
  var init_css_parser = () => {};
609
608
 
610
609
  // ../vscode/src/ts-css/hover-provider.ts
610
+ function remToPxRatio(vscodeModule) {
611
+ const settings = vscodeModule.workspace.getConfiguration("stx.utilityClasses");
612
+ const set = settings.inspect("remToPxRatio");
613
+ const configured = set?.workspaceFolderValue ?? set?.workspaceValue ?? set?.globalValue;
614
+ if (typeof configured === "number")
615
+ return configured;
616
+ const legacy = vscodeModule.workspace.getConfiguration("css").get("remToPxRatio");
617
+ if (typeof legacy === "number")
618
+ return legacy;
619
+ return settings.get("remToPxRatio", DEFAULT_REM_TO_PX_RATIO);
620
+ }
611
621
  function createCssHoverProvider(vscodeModule, context) {
612
622
  return {
613
623
  async provideHover(document, position, _token) {
@@ -629,9 +639,8 @@ function createCssHoverProvider(vscodeModule, context) {
629
639
  if (!css) {
630
640
  return null;
631
641
  }
632
- const remToPxRatio = vscodeModule.workspace.getConfiguration("css").get("remToPxRatio", 16);
633
- const processedCSS = addRemToPxComment(css, remToPxRatio);
634
- const prettyCSS = prettifyCSS(processedCSS);
642
+ const processedCSS = addRemToPxComment(css, remToPxRatio(vscodeModule));
643
+ const prettyCSS = await prettifyCSS(processedCSS);
635
644
  const markdown = new vscodeModule.MarkdownString;
636
645
  markdown.supportHtml = true;
637
646
  markdown.isTrusted = true;
@@ -647,6 +656,7 @@ function createCssHoverProvider(vscodeModule, context) {
647
656
  }
648
657
  };
649
658
  }
659
+ var DEFAULT_REM_TO_PX_RATIO = 16;
650
660
  var init_hover_provider = __esm(() => {
651
661
  init_css_parser();
652
662
  });
@@ -749,11 +759,11 @@ async function activateCss(extensionContext) {
749
759
  await registerColorDecorations(vscode13, cssContext, extensionContext);
750
760
  const sortCommand = createSortClassesCommand(vscode13);
751
761
  extensionContext.subscriptions.push(sortCommand);
752
- const reloadCommand = vscode13.commands.registerCommand("css.reload", async () => {
762
+ const reloadCommand = vscode13.commands.registerCommand("stx.reloadUtilityClasses", async () => {
753
763
  console.log("[ts-css] Reloading configuration...");
754
764
  const newConfig = await loadCssEngineConfig(vscode13);
755
765
  await cssContext?.reload(newConfig);
756
- vscode13.window.showInformationMessage("Css configuration reloaded");
766
+ vscode13.window.showInformationMessage("Utility class configuration reloaded");
757
767
  });
758
768
  extensionContext.subscriptions.push(reloadCommand);
759
769
  console.log("[ts-css] Successfully activated utility class features");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx-vscode",
3
3
  "type": "module",
4
- "version": "0.2.353",
4
+ "version": "0.2.355",
5
5
  "description": "stx language support for VS Code extensions to embed: the hovers, completions, diagnostics, grammar, snippets and language configuration behind the stx extension.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",