@stacksjs/stx-vscode 0.2.354 → 0.2.356
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/dist/contributes.json +7 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +48 -11
- package/package.json +1 -1
package/dist/contributes.json
CHANGED
|
@@ -41,8 +41,9 @@
|
|
|
41
41
|
"category": "stx"
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
|
-
"command": "
|
|
45
|
-
"title": "
|
|
44
|
+
"command": "stx.reloadUtilityClasses",
|
|
45
|
+
"title": "Reload Utility Class Configuration",
|
|
46
|
+
"category": "stx"
|
|
46
47
|
}
|
|
47
48
|
],
|
|
48
49
|
"configuration": {
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"stxTypescriptPlugin.enabled": {
|
|
52
53
|
"type": "boolean",
|
|
53
54
|
"default": true,
|
|
54
|
-
"description": "
|
|
55
|
+
"description": "Type-check the TypeScript in stx files (script blocks and template expressions) with the TypeScript server, and offer its hovers, completions and go to definition there"
|
|
55
56
|
},
|
|
56
57
|
"stx.diagnostics.enable": {
|
|
57
58
|
"type": "boolean",
|
|
@@ -158,10 +159,11 @@
|
|
|
158
159
|
"default": true,
|
|
159
160
|
"description": "Enable autocomplete for utility classes"
|
|
160
161
|
},
|
|
161
|
-
"
|
|
162
|
+
"stx.utilityClasses.remToPxRatio": {
|
|
162
163
|
"type": "number",
|
|
163
164
|
"default": 16,
|
|
164
|
-
"
|
|
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
|
-
* `
|
|
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
|
-
|
|
577
|
+
const formatted = await prettier.format(css, {
|
|
580
578
|
parser: "css",
|
|
581
579
|
plugins: [parserCSS]
|
|
582
|
-
})
|
|
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
|
|
633
|
-
const
|
|
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("
|
|
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("
|
|
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");
|
|
@@ -6915,8 +6925,35 @@ async function stacksProvidesStx(api) {
|
|
|
6915
6925
|
}
|
|
6916
6926
|
}
|
|
6917
6927
|
|
|
6928
|
+
// ../vscode/src/ts-plugin-config.ts
|
|
6929
|
+
var TS_PLUGIN_NAME = "@stacksjs/stx-typescript-plugin";
|
|
6930
|
+
var TYPESCRIPT_EXTENSION_ID = "vscode.typescript-language-features";
|
|
6931
|
+
var TS_PLUGIN_SETTINGS = "stxTypescriptPlugin";
|
|
6932
|
+
function tsPluginConfiguration(api) {
|
|
6933
|
+
return { enabled: api.workspace.getConfiguration(TS_PLUGIN_SETTINGS).get("enabled", true) };
|
|
6934
|
+
}
|
|
6935
|
+
async function configureTypeScriptPlugin(api, subscriptions) {
|
|
6936
|
+
const extension = api.extensions.getExtension(TYPESCRIPT_EXTENSION_ID);
|
|
6937
|
+
if (!extension)
|
|
6938
|
+
return false;
|
|
6939
|
+
const exports = extension.isActive ? extension.exports : await extension.activate();
|
|
6940
|
+
const typescript = exports?.getAPI?.(0);
|
|
6941
|
+
if (!typescript)
|
|
6942
|
+
return false;
|
|
6943
|
+
const send = () => typescript.configurePlugin(TS_PLUGIN_NAME, tsPluginConfiguration(api));
|
|
6944
|
+
send();
|
|
6945
|
+
subscriptions.push(api.workspace.onDidChangeConfiguration((event) => {
|
|
6946
|
+
if (event.affectsConfiguration(TS_PLUGIN_SETTINGS))
|
|
6947
|
+
send();
|
|
6948
|
+
}));
|
|
6949
|
+
return true;
|
|
6950
|
+
}
|
|
6951
|
+
|
|
6918
6952
|
// ../vscode/src/extension.ts
|
|
6919
6953
|
async function activate(context) {
|
|
6954
|
+
configureTypeScriptPlugin(vscode16, context.subscriptions).catch((error) => {
|
|
6955
|
+
console.error("stx Extension - could not configure the TypeScript plugin:", error);
|
|
6956
|
+
});
|
|
6920
6957
|
if (await stacksProvidesStx(vscode16)) {
|
|
6921
6958
|
console.log(`stx Extension - ${STACKS_EXTENSION_ID} provides stx support in this window; not registering it twice`);
|
|
6922
6959
|
return;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx-vscode",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.356",
|
|
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",
|