@master/css-language-service 2.0.0-rc.4 → 2.0.0-rc.40

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.
Files changed (93) hide show
  1. package/dist/common.cjs +57 -0
  2. package/dist/common.d.ts +9 -0
  3. package/dist/common.mjs +48 -0
  4. package/dist/core.cjs +248 -0
  5. package/dist/core.d.ts +30 -0
  6. package/dist/core.mjs +246 -0
  7. package/dist/features/edit-syntax-colors.cjs +19 -0
  8. package/dist/features/edit-syntax-colors.d.ts +4 -0
  9. package/dist/features/edit-syntax-colors.mjs +17 -0
  10. package/dist/features/inspect-syntax.cjs +70 -0
  11. package/dist/features/inspect-syntax.d.ts +4 -0
  12. package/dist/features/inspect-syntax.mjs +68 -0
  13. package/dist/features/render-syntax-colors.cjs +88 -0
  14. package/dist/features/render-syntax-colors.d.ts +4 -0
  15. package/dist/features/render-syntax-colors.mjs +86 -0
  16. package/dist/features/suggest-syntax.cjs +20 -0
  17. package/dist/features/suggest-syntax.d.ts +4 -0
  18. package/dist/features/suggest-syntax.mjs +18 -0
  19. package/dist/index.cjs +29 -0
  20. package/dist/index.d.ts +7 -5
  21. package/dist/index.mjs +7 -0
  22. package/dist/settings.cjs +84 -0
  23. package/dist/settings.d.ts +18 -8
  24. package/dist/settings.mjs +82 -0
  25. package/dist/utils/beautify-css.cjs +13 -0
  26. package/dist/utils/beautify-css.d.ts +1 -0
  27. package/dist/utils/beautify-css.mjs +11 -0
  28. package/dist/utils/convert-color-space.cjs +40 -0
  29. package/dist/utils/convert-color-space.d.ts +2 -0
  30. package/dist/utils/convert-color-space.mjs +38 -0
  31. package/dist/utils/convert-color-token.cjs +28 -0
  32. package/dist/utils/convert-color-token.d.ts +3 -0
  33. package/dist/utils/convert-color-token.mjs +26 -0
  34. package/dist/utils/create-doc.cjs +26 -0
  35. package/dist/utils/create-doc.d.ts +16 -0
  36. package/dist/utils/create-doc.mjs +21 -0
  37. package/dist/utils/css-data-provider.cjs +9 -0
  38. package/dist/utils/css-data-provider.d.ts +3 -0
  39. package/dist/utils/css-data-provider.mjs +7 -0
  40. package/dist/utils/find-matching-brackets.cjs +29 -0
  41. package/dist/utils/find-matching-brackets.d.ts +1 -0
  42. package/dist/utils/find-matching-brackets.mjs +27 -0
  43. package/dist/utils/get-color-completion-items.cjs +30 -0
  44. package/dist/utils/get-color-completion-items.d.ts +3 -0
  45. package/dist/utils/get-color-completion-items.mjs +28 -0
  46. package/dist/utils/get-css-data-documentation.cjs +90 -0
  47. package/dist/utils/get-css-data-documentation.d.ts +5 -0
  48. package/dist/utils/get-css-data-documentation.mjs +88 -0
  49. package/dist/utils/get-main-completion-items.cjs +105 -0
  50. package/dist/utils/get-main-completion-items.d.ts +3 -0
  51. package/dist/utils/get-main-completion-items.mjs +103 -0
  52. package/dist/utils/get-position.cjs +12 -0
  53. package/dist/utils/get-position.d.ts +1 -0
  54. package/dist/utils/get-position.mjs +10 -0
  55. package/dist/utils/get-pseudo-class-completion-items.cjs +65 -0
  56. package/dist/utils/get-pseudo-class-completion-items.d.ts +3 -0
  57. package/dist/utils/get-pseudo-class-completion-items.mjs +63 -0
  58. package/dist/utils/get-pseudo-element-completion-items.cjs +56 -0
  59. package/dist/utils/get-pseudo-element-completion-items.d.ts +3 -0
  60. package/dist/utils/get-pseudo-element-completion-items.mjs +54 -0
  61. package/dist/utils/get-query-completion-items.cjs +102 -0
  62. package/dist/utils/get-query-completion-items.d.ts +3 -0
  63. package/dist/utils/get-query-completion-items.mjs +100 -0
  64. package/dist/utils/get-range.cjs +21 -0
  65. package/dist/utils/get-range.d.ts +2 -0
  66. package/dist/utils/get-range.mjs +19 -0
  67. package/dist/utils/get-utility-info.cjs +32 -0
  68. package/dist/utils/get-utility-info.d.ts +7 -0
  69. package/dist/utils/get-utility-info.mjs +30 -0
  70. package/dist/utils/get-value-completion-items.cjs +185 -0
  71. package/dist/utils/get-value-completion-items.d.ts +3 -0
  72. package/dist/utils/get-value-completion-items.mjs +183 -0
  73. package/dist/utils/query-syntax-completions.cjs +115 -0
  74. package/dist/utils/query-syntax-completions.d.ts +3 -0
  75. package/dist/utils/query-syntax-completions.mjs +113 -0
  76. package/dist/utils/regex.cjs +5 -0
  77. package/dist/utils/regex.mjs +3 -0
  78. package/dist/utils/sort-completion-items.cjs +11 -0
  79. package/dist/utils/sort-completion-items.d.ts +2 -0
  80. package/dist/utils/sort-completion-items.mjs +9 -0
  81. package/package.json +1 -1
  82. package/dist/constant.d.ts +0 -33
  83. package/dist/index.bundle.js +0 -33
  84. package/dist/position-check.d.ts +0 -20
  85. package/dist/providers/color.d.ts +0 -5
  86. package/dist/providers/completion.d.ts +0 -14
  87. package/dist/providers/hover.d.ts +0 -2
  88. package/dist/settings.bundle.js +0 -1
  89. package/dist/utils/get-css-entry-markdown-description.d.ts +0 -1
  90. package/dist/utils/hex-to-rgb.d.ts +0 -2
  91. package/dist/utils/oklab-to-rgb.d.ts +0 -1
  92. package/dist/utils/oklch-to-oklab.d.ts +0 -1
  93. package/dist/utils/to-two-digit-hex.d.ts +0 -1
@@ -0,0 +1,17 @@
1
+ import convertColorByToken from '../utils/convert-color-token.mjs';
2
+
3
+ function editSyntaxColors(document, color, range) {
4
+ const colorPresentations = [];
5
+ const selectedColorToken = document.getText(range);
6
+ const targetColorToken = convertColorByToken(color, selectedColorToken, this.css);
7
+ if (targetColorToken) colorPresentations.push({
8
+ label: targetColorToken,
9
+ textEdit: {
10
+ range,
11
+ newText: targetColorToken
12
+ }
13
+ });
14
+ return colorPresentations;
15
+ }
16
+
17
+ export { editSyntaxColors as default };
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+
3
+ var getCssDataDocumentation = require('../utils/get-css-data-documentation.cjs');
4
+ var css = require('@master/css');
5
+ var cssDataProvider = require('../utils/css-data-provider.cjs');
6
+ var getUtilityInfo = require('../utils/get-utility-info.cjs');
7
+
8
+ function inspectSyntax(document, position) {
9
+ const classPosition = this.getClassPosition(document, position);
10
+ if (!classPosition) return;
11
+ const { token } = classPosition;
12
+ const range = {
13
+ start: document.positionAt(classPosition.range.start),
14
+ end: document.positionAt(classPosition.range.end)
15
+ };
16
+ const styleClasses = this.css.styles[token];
17
+ if (styleClasses) {
18
+ const documentation = getCssDataDocumentation.getCSSDataDocumentation({}, {
19
+ generatedCSS: css.generateCSS([
20
+ token
21
+ ], this.css),
22
+ docs: '/reference/styles'
23
+ });
24
+ if (documentation) {
25
+ return {
26
+ contents: {
27
+ kind: documentation.kind,
28
+ value: `(style) ` + styleClasses.join(' ') + '\n' + documentation.value
29
+ }
30
+ };
31
+ }
32
+ } else {
33
+ const rules = this.css.generate(token);
34
+ const rule = rules[0];
35
+ if (rule) {
36
+ if (rule.layer === css.Layer.Utility) {
37
+ const { data, docs } = getUtilityInfo(rule.RegisteredRule, this.css);
38
+ const documentation = getCssDataDocumentation.getCSSDataDocumentation(data, {
39
+ generatedCSS: css.generateCSS([
40
+ token
41
+ ], this.css),
42
+ docs
43
+ });
44
+ if (documentation) {
45
+ return {
46
+ contents: documentation,
47
+ range
48
+ };
49
+ }
50
+ } else {
51
+ const nativeProperties = cssDataProvider.provideProperties();
52
+ const nativeCSSPropertyData = nativeProperties.find(({ name })=>name === rule.id);
53
+ const documentation = getCssDataDocumentation.getCSSDataDocumentation(nativeCSSPropertyData, {
54
+ generatedCSS: css.generateCSS([
55
+ token
56
+ ], this.css),
57
+ docs: '/reference/' + (css.isCoreRule(rule.id) && rule.id)
58
+ });
59
+ if (documentation) {
60
+ return {
61
+ contents: documentation,
62
+ range
63
+ };
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+
70
+ module.exports = inspectSyntax;
@@ -0,0 +1,4 @@
1
+ import type { Hover, HoverParams } from 'vscode-languageserver-protocol';
2
+ import type CSSLanguageService from '../core';
3
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
4
+ export default function inspectSyntax(this: CSSLanguageService, document: TextDocument, position: HoverParams['position']): Hover | undefined;
@@ -0,0 +1,68 @@
1
+ import { getCSSDataDocumentation } from '../utils/get-css-data-documentation.mjs';
2
+ import { generateCSS, Layer, isCoreRule } from '@master/css';
3
+ import cssDataProvider from '../utils/css-data-provider.mjs';
4
+ import getUtilityInfo from '../utils/get-utility-info.mjs';
5
+
6
+ function inspectSyntax(document, position) {
7
+ const classPosition = this.getClassPosition(document, position);
8
+ if (!classPosition) return;
9
+ const { token } = classPosition;
10
+ const range = {
11
+ start: document.positionAt(classPosition.range.start),
12
+ end: document.positionAt(classPosition.range.end)
13
+ };
14
+ const styleClasses = this.css.styles[token];
15
+ if (styleClasses) {
16
+ const documentation = getCSSDataDocumentation({}, {
17
+ generatedCSS: generateCSS([
18
+ token
19
+ ], this.css),
20
+ docs: '/reference/styles'
21
+ });
22
+ if (documentation) {
23
+ return {
24
+ contents: {
25
+ kind: documentation.kind,
26
+ value: `(style) ` + styleClasses.join(' ') + '\n' + documentation.value
27
+ }
28
+ };
29
+ }
30
+ } else {
31
+ const rules = this.css.generate(token);
32
+ const rule = rules[0];
33
+ if (rule) {
34
+ if (rule.layer === Layer.Utility) {
35
+ const { data, docs } = getUtilityInfo(rule.RegisteredRule, this.css);
36
+ const documentation = getCSSDataDocumentation(data, {
37
+ generatedCSS: generateCSS([
38
+ token
39
+ ], this.css),
40
+ docs
41
+ });
42
+ if (documentation) {
43
+ return {
44
+ contents: documentation,
45
+ range
46
+ };
47
+ }
48
+ } else {
49
+ const nativeProperties = cssDataProvider.provideProperties();
50
+ const nativeCSSPropertyData = nativeProperties.find(({ name })=>name === rule.id);
51
+ const documentation = getCSSDataDocumentation(nativeCSSPropertyData, {
52
+ generatedCSS: generateCSS([
53
+ token
54
+ ], this.css),
55
+ docs: '/reference/' + (isCoreRule(rule.id) && rule.id)
56
+ });
57
+ if (documentation) {
58
+ return {
59
+ contents: documentation,
60
+ range
61
+ };
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+
68
+ export { inspectSyntax as default };
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+
3
+ var regex = require('../utils/regex.cjs');
4
+ var culori = require('culori');
5
+ var css = require('@master/css');
6
+
7
+ async function renderSyntaxColors(document) {
8
+ const text = document.getText() ?? '';
9
+ const colorInformations = [];
10
+ for (const instanceMatch of text.matchAll(regex.instancePattern)){
11
+ if (instanceMatch.index === undefined) break;
12
+ const instanceStartIndex = instanceMatch.index;
13
+ const syntax = instanceMatch[0];
14
+ const rule = this.css.generate(syntax)[0];
15
+ if (rule && rule.layer !== css.Layer.Utility) {
16
+ const keyTokenLength = rule.keyToken?.length ?? 0;
17
+ let currentLength = 0;
18
+ const resolveValueComponent = (valueComponent)=>{
19
+ if (valueComponent.text === undefined) return; // text is always existing, just for type
20
+ const startOffset = instanceStartIndex + keyTokenLength + currentLength;
21
+ // TODO: check number mt:30
22
+ const valueComponentTokenLength = valueComponent.token.length;
23
+ let color;
24
+ switch(valueComponent.type){
25
+ case 'function':
26
+ if ([
27
+ 'rgb',
28
+ 'rgba',
29
+ 'hsl',
30
+ 'hsla',
31
+ 'hwb',
32
+ 'lab',
33
+ 'lch',
34
+ 'oklab',
35
+ 'oklch',
36
+ 'color'
37
+ ].includes(valueComponent.name)) {
38
+ color = culori.parse(valueComponent.text);
39
+ } else if (valueComponent.children.length) {
40
+ currentLength += valueComponent.name.length + 1 // function name + '('
41
+ ;
42
+ valueComponent.children.forEach(resolveValueComponent);
43
+ }
44
+ break;
45
+ case 'variable':
46
+ if (valueComponent.variable?.type === 'color') {
47
+ color = culori.parse(valueComponent.text);
48
+ }
49
+ break;
50
+ case 'string':
51
+ if (valueComponent.text !== '#' && valueComponent.text?.startsWith('#')) {
52
+ color = culori.parse(valueComponent.text);
53
+ }
54
+ break;
55
+ }
56
+ // check if rgba is valid
57
+ if (color) {
58
+ const rgbaColor = color.mode !== 'rgb' ? culori.converter('rgb')(color) : color;
59
+ colorInformations.push({
60
+ range: {
61
+ start: document.positionAt(startOffset),
62
+ end: document.positionAt(startOffset + valueComponentTokenLength)
63
+ },
64
+ color: {
65
+ red: rgbaColor.r,
66
+ green: rgbaColor.g,
67
+ blue: rgbaColor.b,
68
+ alpha: rgbaColor.alpha === undefined ? 1 : rgbaColor.alpha
69
+ }
70
+ });
71
+ }
72
+ currentLength += valueComponentTokenLength || 0;
73
+ };
74
+ rule.valueComponents.forEach(resolveValueComponent);
75
+ }
76
+ }
77
+ const colorIndexSet = new Set();
78
+ return colorInformations.filter((item)=>{
79
+ if (colorIndexSet.has(item.range.start)) {
80
+ return false;
81
+ } else {
82
+ colorIndexSet.add(item.range.start);
83
+ return true;
84
+ }
85
+ });
86
+ }
87
+
88
+ module.exports = renderSyntaxColors;
@@ -0,0 +1,4 @@
1
+ import type { ColorInformation } from 'vscode-languageserver-protocol';
2
+ import CSSLanguageService from '../core';
3
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
4
+ export default function renderSyntaxColors(this: CSSLanguageService, document: TextDocument): Promise<ColorInformation[] | undefined>;
@@ -0,0 +1,86 @@
1
+ import { instancePattern } from '../utils/regex.mjs';
2
+ import { parse, converter } from 'culori';
3
+ import { Layer } from '@master/css';
4
+
5
+ async function renderSyntaxColors(document) {
6
+ const text = document.getText() ?? '';
7
+ const colorInformations = [];
8
+ for (const instanceMatch of text.matchAll(instancePattern)){
9
+ if (instanceMatch.index === undefined) break;
10
+ const instanceStartIndex = instanceMatch.index;
11
+ const syntax = instanceMatch[0];
12
+ const rule = this.css.generate(syntax)[0];
13
+ if (rule && rule.layer !== Layer.Utility) {
14
+ const keyTokenLength = rule.keyToken?.length ?? 0;
15
+ let currentLength = 0;
16
+ const resolveValueComponent = (valueComponent)=>{
17
+ if (valueComponent.text === undefined) return; // text is always existing, just for type
18
+ const startOffset = instanceStartIndex + keyTokenLength + currentLength;
19
+ // TODO: check number mt:30
20
+ const valueComponentTokenLength = valueComponent.token.length;
21
+ let color;
22
+ switch(valueComponent.type){
23
+ case 'function':
24
+ if ([
25
+ 'rgb',
26
+ 'rgba',
27
+ 'hsl',
28
+ 'hsla',
29
+ 'hwb',
30
+ 'lab',
31
+ 'lch',
32
+ 'oklab',
33
+ 'oklch',
34
+ 'color'
35
+ ].includes(valueComponent.name)) {
36
+ color = parse(valueComponent.text);
37
+ } else if (valueComponent.children.length) {
38
+ currentLength += valueComponent.name.length + 1 // function name + '('
39
+ ;
40
+ valueComponent.children.forEach(resolveValueComponent);
41
+ }
42
+ break;
43
+ case 'variable':
44
+ if (valueComponent.variable?.type === 'color') {
45
+ color = parse(valueComponent.text);
46
+ }
47
+ break;
48
+ case 'string':
49
+ if (valueComponent.text !== '#' && valueComponent.text?.startsWith('#')) {
50
+ color = parse(valueComponent.text);
51
+ }
52
+ break;
53
+ }
54
+ // check if rgba is valid
55
+ if (color) {
56
+ const rgbaColor = color.mode !== 'rgb' ? converter('rgb')(color) : color;
57
+ colorInformations.push({
58
+ range: {
59
+ start: document.positionAt(startOffset),
60
+ end: document.positionAt(startOffset + valueComponentTokenLength)
61
+ },
62
+ color: {
63
+ red: rgbaColor.r,
64
+ green: rgbaColor.g,
65
+ blue: rgbaColor.b,
66
+ alpha: rgbaColor.alpha === undefined ? 1 : rgbaColor.alpha
67
+ }
68
+ });
69
+ }
70
+ currentLength += valueComponentTokenLength || 0;
71
+ };
72
+ rule.valueComponents.forEach(resolveValueComponent);
73
+ }
74
+ }
75
+ const colorIndexSet = new Set();
76
+ return colorInformations.filter((item)=>{
77
+ if (colorIndexSet.has(item.range.start)) {
78
+ return false;
79
+ } else {
80
+ colorIndexSet.add(item.range.start);
81
+ return true;
82
+ }
83
+ });
84
+ }
85
+
86
+ export { renderSyntaxColors as default };
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ var querySyntaxCompletions = require('../utils/query-syntax-completions.cjs');
4
+
5
+ function suggestSyntax(document, position, context) {
6
+ const classPosition = this.getClassPosition(document, position);
7
+ if (classPosition !== undefined) {
8
+ const q = context?.triggerCharacter === ' ' ? '' : document.getText({
9
+ start: document.positionAt(classPosition.range.start),
10
+ end: position
11
+ });
12
+ return querySyntaxCompletions(q, this.css);
13
+ }
14
+ // todo
15
+ // else if (isInstance === true && checkConfigColorsBlock(document, position) === true) {
16
+ // return getColorCompletionItems(this.css)
17
+ // }
18
+ }
19
+
20
+ module.exports = suggestSyntax;
@@ -0,0 +1,4 @@
1
+ import type { CompletionItem, CompletionParams } from 'vscode-languageserver-protocol';
2
+ import type { TextDocument } from 'vscode-languageserver-textdocument';
3
+ import CSSLanguageService from '../core';
4
+ export default function suggestSyntax(this: CSSLanguageService, document: TextDocument, position: CompletionParams['position'], context: CompletionParams['context']): CompletionItem[] | undefined;
@@ -0,0 +1,18 @@
1
+ import querySyntaxCompletions from '../utils/query-syntax-completions.mjs';
2
+
3
+ function suggestSyntax(document, position, context) {
4
+ const classPosition = this.getClassPosition(document, position);
5
+ if (classPosition !== undefined) {
6
+ const q = context?.triggerCharacter === ' ' ? '' : document.getText({
7
+ start: document.positionAt(classPosition.range.start),
8
+ end: position
9
+ });
10
+ return querySyntaxCompletions(q, this.css);
11
+ }
12
+ // todo
13
+ // else if (isInstance === true && checkConfigColorsBlock(document, position) === true) {
14
+ // return getColorCompletionItems(this.css)
15
+ // }
16
+ }
17
+
18
+ export { suggestSyntax as default };
package/dist/index.cjs ADDED
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('./core.cjs');
6
+ var settings = require('./settings.cjs');
7
+ var common = require('./common.cjs');
8
+ var inspectSyntax = require('./features/inspect-syntax.cjs');
9
+ var renderSyntaxColors = require('./features/render-syntax-colors.cjs');
10
+ var editSyntaxColors = require('./features/edit-syntax-colors.cjs');
11
+ var suggestSyntax = require('./features/suggest-syntax.cjs');
12
+
13
+
14
+
15
+ exports.CSSLanguageService = core;
16
+ exports.default = core;
17
+ exports.settings = settings;
18
+ exports.AT_TRIGGER_CHARACTER = common.AT_TRIGGER_CHARACTER;
19
+ exports.DECLARATION_SEPARATOR_TRIGGER_CHARACTER = common.DECLARATION_SEPARATOR_TRIGGER_CHARACTER;
20
+ exports.GROUP_TRIGGER_CHARACTER = common.GROUP_TRIGGER_CHARACTER;
21
+ exports.INVOKED_TRIGGER_CHARACTERS = common.INVOKED_TRIGGER_CHARACTERS;
22
+ exports.QUERY_TRIGGER_CHARACTERS = common.QUERY_TRIGGER_CHARACTERS;
23
+ exports.SELECTOR_TRIGGER_CHARACTERS = common.SELECTOR_TRIGGER_CHARACTERS;
24
+ exports.SERVER_CAPABILITIES = common.SERVER_CAPABILITIES;
25
+ exports.VALUE_TRIGGER_CHARACTERS = common.VALUE_TRIGGER_CHARACTERS;
26
+ exports.inspectSyntax = inspectSyntax;
27
+ exports.renderSyntaxColors = renderSyntaxColors;
28
+ exports.editSyntaxColors = editSyntaxColors;
29
+ exports.suggestSyntax = suggestSyntax;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- export { getDocumentColors, getColorValue, getColorPresentation } from './providers/color';
2
- export { checkConfigColorsBlock, getLastInstance, getConfigColorsCompletionItem, getCompletionItem, getReturnItem } from './providers/completion';
3
- export { doHover } from './providers/hover';
4
- export { positionCheck } from './position-check';
5
- export { settings } from './settings';
1
+ export { default, default as CSSLanguageService } from './core';
2
+ export { default as settings, type Settings } from './settings';
3
+ export * from './common';
4
+ export { default as inspectSyntax } from './features/inspect-syntax';
5
+ export { default as renderSyntaxColors } from './features/render-syntax-colors';
6
+ export { default as editSyntaxColors } from './features/edit-syntax-colors';
7
+ export { default as suggestSyntax } from './features/suggest-syntax';
package/dist/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ export { default as CSSLanguageService, default } from './core.mjs';
2
+ export { default as settings } from './settings.mjs';
3
+ export { AT_TRIGGER_CHARACTER, DECLARATION_SEPARATOR_TRIGGER_CHARACTER, GROUP_TRIGGER_CHARACTER, INVOKED_TRIGGER_CHARACTERS, QUERY_TRIGGER_CHARACTERS, SELECTOR_TRIGGER_CHARACTERS, SERVER_CAPABILITIES, VALUE_TRIGGER_CHARACTERS } from './common.mjs';
4
+ export { default as inspectSyntax } from './features/inspect-syntax.mjs';
5
+ export { default as renderSyntaxColors } from './features/render-syntax-colors.mjs';
6
+ export { default as editSyntaxColors } from './features/edit-syntax-colors.mjs';
7
+ export { default as suggestSyntax } from './features/suggest-syntax.mjs';
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ var css = require('@master/css');
4
+
5
+ /**
6
+ * @example styles https://regex101.com/r/HLPdsw/1
7
+ **/ const settings = {
8
+ includedLanguages: [
9
+ "html",
10
+ "php",
11
+ "javascript",
12
+ "typescript",
13
+ "javascriptreact",
14
+ "typescriptreact",
15
+ "vue",
16
+ "svelte",
17
+ "rust",
18
+ "astro",
19
+ "markdown",
20
+ "mdx",
21
+ "astro"
22
+ ],
23
+ /**
24
+ * @example <div class="a b">
25
+ * @example <div className="a b">
26
+ */ classAttributes: css.CLASS_ATTRIBUTES,
27
+ /**
28
+ * @example <div class={active ? 'a' : 'b'}>
29
+ * @example <div className={active ? 'a' : 'b'}>
30
+ */ classAttributeBindings: {
31
+ "className": [
32
+ "{",
33
+ "}"
34
+ ],
35
+ "class": [
36
+ "{",
37
+ "}"
38
+ ],
39
+ "class:list": [
40
+ "{",
41
+ "}"
42
+ ],
43
+ ":class": [
44
+ "\"",
45
+ "\""
46
+ ],
47
+ "v-bind:class": [
48
+ "\"",
49
+ "\""
50
+ ],
51
+ "[class]": [
52
+ "\"",
53
+ "\""
54
+ ],
55
+ "[className]": [
56
+ "\"",
57
+ "\""
58
+ ],
59
+ "[ngClass]": [
60
+ "\"",
61
+ "\""
62
+ ]
63
+ },
64
+ /**
65
+ * @example const styles = 'a b'
66
+ * @example { styles: { btn: 'a b' } }
67
+ */ classDeclarations: css.CLASS_DECLARATIONS,
68
+ /**
69
+ * @example clsx('a b')
70
+ * @example styled`a b`
71
+ * @example .classList.add('a')
72
+ */ classFunctions: css.CLASS_FUNCTIONS,
73
+ exclude: [
74
+ "**/.git/**",
75
+ "**/node_modules/**",
76
+ "**/.hg/**"
77
+ ],
78
+ suggestSyntax: true,
79
+ inspectSyntax: true,
80
+ renderSyntaxColors: true,
81
+ editSyntaxColors: true
82
+ };
83
+
84
+ module.exports = settings;
@@ -1,9 +1,19 @@
1
- export declare const settings: {
2
- languages: string[];
3
- classMatch: string[];
4
- exclude: string[];
5
- suggestions: boolean;
6
- inspect: boolean;
7
- previewColors: boolean;
8
- config: string;
1
+ import { Config } from '@master/css';
2
+ /**
3
+ * @example styles https://regex101.com/r/HLPdsw/1
4
+ **/
5
+ declare const settings: Settings;
6
+ export default settings;
7
+ export declare type Settings = {
8
+ includedLanguages?: string[];
9
+ classAttributes?: string[];
10
+ classFunctions?: string[];
11
+ classDeclarations?: string[];
12
+ classAttributeBindings?: Record<string, [string, string] | false>;
13
+ exclude?: string[];
14
+ config?: Config;
15
+ suggestSyntax?: boolean;
16
+ inspectSyntax?: boolean;
17
+ renderSyntaxColors?: boolean;
18
+ editSyntaxColors?: boolean;
9
19
  };
@@ -0,0 +1,82 @@
1
+ import { CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS } from '@master/css';
2
+
3
+ /**
4
+ * @example styles https://regex101.com/r/HLPdsw/1
5
+ **/ const settings = {
6
+ includedLanguages: [
7
+ "html",
8
+ "php",
9
+ "javascript",
10
+ "typescript",
11
+ "javascriptreact",
12
+ "typescriptreact",
13
+ "vue",
14
+ "svelte",
15
+ "rust",
16
+ "astro",
17
+ "markdown",
18
+ "mdx",
19
+ "astro"
20
+ ],
21
+ /**
22
+ * @example <div class="a b">
23
+ * @example <div className="a b">
24
+ */ classAttributes: CLASS_ATTRIBUTES,
25
+ /**
26
+ * @example <div class={active ? 'a' : 'b'}>
27
+ * @example <div className={active ? 'a' : 'b'}>
28
+ */ classAttributeBindings: {
29
+ "className": [
30
+ "{",
31
+ "}"
32
+ ],
33
+ "class": [
34
+ "{",
35
+ "}"
36
+ ],
37
+ "class:list": [
38
+ "{",
39
+ "}"
40
+ ],
41
+ ":class": [
42
+ "\"",
43
+ "\""
44
+ ],
45
+ "v-bind:class": [
46
+ "\"",
47
+ "\""
48
+ ],
49
+ "[class]": [
50
+ "\"",
51
+ "\""
52
+ ],
53
+ "[className]": [
54
+ "\"",
55
+ "\""
56
+ ],
57
+ "[ngClass]": [
58
+ "\"",
59
+ "\""
60
+ ]
61
+ },
62
+ /**
63
+ * @example const styles = 'a b'
64
+ * @example { styles: { btn: 'a b' } }
65
+ */ classDeclarations: CLASS_DECLARATIONS,
66
+ /**
67
+ * @example clsx('a b')
68
+ * @example styled`a b`
69
+ * @example .classList.add('a')
70
+ */ classFunctions: CLASS_FUNCTIONS,
71
+ exclude: [
72
+ "**/.git/**",
73
+ "**/node_modules/**",
74
+ "**/.hg/**"
75
+ ],
76
+ suggestSyntax: true,
77
+ inspectSyntax: true,
78
+ renderSyntaxColors: true,
79
+ editSyntaxColors: true
80
+ };
81
+
82
+ export { settings as default };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var beautifyCss = require('js-beautify/js/lib/beautify-css');
4
+
5
+ // @ts-expect-error
6
+ function beautifyCSS(text) {
7
+ return beautifyCss.css_beautify(text, {
8
+ newline_between_rules: false,
9
+ indent_size: 2
10
+ });
11
+ }
12
+
13
+ module.exports = beautifyCSS;
@@ -0,0 +1 @@
1
+ export default function beautifyCSS(text: string): any;
@@ -0,0 +1,11 @@
1
+ import { css_beautify } from 'js-beautify/js/lib/beautify-css';
2
+
3
+ // @ts-expect-error
4
+ function beautifyCSS(text) {
5
+ return css_beautify(text, {
6
+ newline_between_rules: false,
7
+ indent_size: 2
8
+ });
9
+ }
10
+
11
+ export { beautifyCSS as default };