@master/css-language-service 2.0.0-rc.19 → 2.0.0-rc.20
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/position-check.cjs +16 -36
- package/dist/position-check.d.ts +5 -18
- package/dist/position-check.mjs +16 -36
- package/dist/providers/hover.cjs +9 -7
- package/dist/providers/hover.mjs +9 -7
- package/package.json +1 -1
package/dist/position-check.cjs
CHANGED
|
@@ -3,55 +3,35 @@
|
|
|
3
3
|
var regex = require('./utils/regex.cjs');
|
|
4
4
|
|
|
5
5
|
function positionCheck(text, positionIndex, startIndex, RegExpList) {
|
|
6
|
-
|
|
7
|
-
IsMatch: false,
|
|
8
|
-
classStartIndex: 0,
|
|
9
|
-
classEndIndex: 0,
|
|
10
|
-
classString: '',
|
|
11
|
-
instance: {
|
|
12
|
-
index: {
|
|
13
|
-
start: 0,
|
|
14
|
-
end: 0
|
|
15
|
-
},
|
|
16
|
-
instanceString: ''
|
|
17
|
-
},
|
|
18
|
-
instanceList: []
|
|
19
|
-
};
|
|
6
|
+
let result;
|
|
20
7
|
let instanceMatch;
|
|
21
8
|
let classMatch;
|
|
22
|
-
RegExpList
|
|
23
|
-
const classPattern = new RegExp(
|
|
9
|
+
for (const classRegexString of RegExpList){
|
|
10
|
+
const classPattern = new RegExp(classRegexString, 'g');
|
|
24
11
|
while((classMatch = classPattern.exec(text)) !== null){
|
|
25
|
-
if ((classMatch.index <= positionIndex - startIndex && classMatch.index + classMatch[0].length
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
result.classEndIndex = classMatch.index + classMatch[0].length - 1;
|
|
29
|
-
result.classString = classMatch[0];
|
|
12
|
+
if ((classMatch.index <= positionIndex - startIndex && classMatch.index + classMatch[0].length >= positionIndex - startIndex) == true) {
|
|
13
|
+
const classContentStartIndex = classMatch.index + classMatch[1].length;
|
|
14
|
+
regex.instancePattern.lastIndex = 0;
|
|
30
15
|
while((instanceMatch = regex.instancePattern.exec(classMatch[2])) !== null){
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
instanceString: instanceMatch[0]
|
|
37
|
-
});
|
|
38
|
-
if ((classMatch.index + classMatch[1].length + instanceMatch.index <= positionIndex && classMatch.index + classMatch[1].length + instanceMatch.index + instanceMatch[0].length >= positionIndex) == true) {
|
|
39
|
-
result.instance = {
|
|
16
|
+
const instanceStartIndex = classContentStartIndex + instanceMatch.index;
|
|
17
|
+
const instanceEndIndex = classContentStartIndex + instanceMatch.index + instanceMatch[0].length;
|
|
18
|
+
if (instanceStartIndex <= positionIndex - startIndex && instanceEndIndex >= positionIndex - startIndex) {
|
|
19
|
+
result = {
|
|
40
20
|
index: {
|
|
41
|
-
start:
|
|
42
|
-
end:
|
|
21
|
+
start: instanceStartIndex,
|
|
22
|
+
end: instanceEndIndex
|
|
43
23
|
},
|
|
44
|
-
|
|
24
|
+
instanceContent: instanceMatch[0]
|
|
45
25
|
};
|
|
26
|
+
return result;
|
|
46
27
|
}
|
|
47
28
|
}
|
|
48
|
-
return result;
|
|
49
29
|
} else if (classMatch.index > positionIndex - startIndex) {
|
|
50
30
|
break;
|
|
51
31
|
}
|
|
52
32
|
}
|
|
53
|
-
}
|
|
54
|
-
return
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
55
35
|
}
|
|
56
36
|
|
|
57
37
|
exports.positionCheck = positionCheck;
|
package/dist/position-check.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
export declare function positionCheck(text: string, positionIndex: number, startIndex: number, RegExpList: string[]): {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
classString: string;
|
|
6
|
-
instance: {
|
|
7
|
-
index: {
|
|
8
|
-
start: number;
|
|
9
|
-
end: number;
|
|
10
|
-
};
|
|
11
|
-
instanceString: string;
|
|
2
|
+
index: {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
12
5
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
start: number;
|
|
16
|
-
end: number;
|
|
17
|
-
};
|
|
18
|
-
instanceString: string;
|
|
19
|
-
}[];
|
|
20
|
-
};
|
|
6
|
+
instanceContent: string;
|
|
7
|
+
} | null;
|
package/dist/position-check.mjs
CHANGED
|
@@ -1,55 +1,35 @@
|
|
|
1
1
|
import { instancePattern } from './utils/regex.mjs';
|
|
2
2
|
|
|
3
3
|
function positionCheck(text, positionIndex, startIndex, RegExpList) {
|
|
4
|
-
|
|
5
|
-
IsMatch: false,
|
|
6
|
-
classStartIndex: 0,
|
|
7
|
-
classEndIndex: 0,
|
|
8
|
-
classString: '',
|
|
9
|
-
instance: {
|
|
10
|
-
index: {
|
|
11
|
-
start: 0,
|
|
12
|
-
end: 0
|
|
13
|
-
},
|
|
14
|
-
instanceString: ''
|
|
15
|
-
},
|
|
16
|
-
instanceList: []
|
|
17
|
-
};
|
|
4
|
+
let result;
|
|
18
5
|
let instanceMatch;
|
|
19
6
|
let classMatch;
|
|
20
|
-
RegExpList
|
|
21
|
-
const classPattern = new RegExp(
|
|
7
|
+
for (const classRegexString of RegExpList){
|
|
8
|
+
const classPattern = new RegExp(classRegexString, 'g');
|
|
22
9
|
while((classMatch = classPattern.exec(text)) !== null){
|
|
23
|
-
if ((classMatch.index <= positionIndex - startIndex && classMatch.index + classMatch[0].length
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
result.classEndIndex = classMatch.index + classMatch[0].length - 1;
|
|
27
|
-
result.classString = classMatch[0];
|
|
10
|
+
if ((classMatch.index <= positionIndex - startIndex && classMatch.index + classMatch[0].length >= positionIndex - startIndex) == true) {
|
|
11
|
+
const classContentStartIndex = classMatch.index + classMatch[1].length;
|
|
12
|
+
instancePattern.lastIndex = 0;
|
|
28
13
|
while((instanceMatch = instancePattern.exec(classMatch[2])) !== null){
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
instanceString: instanceMatch[0]
|
|
35
|
-
});
|
|
36
|
-
if ((classMatch.index + classMatch[1].length + instanceMatch.index <= positionIndex && classMatch.index + classMatch[1].length + instanceMatch.index + instanceMatch[0].length >= positionIndex) == true) {
|
|
37
|
-
result.instance = {
|
|
14
|
+
const instanceStartIndex = classContentStartIndex + instanceMatch.index;
|
|
15
|
+
const instanceEndIndex = classContentStartIndex + instanceMatch.index + instanceMatch[0].length;
|
|
16
|
+
if (instanceStartIndex <= positionIndex - startIndex && instanceEndIndex >= positionIndex - startIndex) {
|
|
17
|
+
result = {
|
|
38
18
|
index: {
|
|
39
|
-
start:
|
|
40
|
-
end:
|
|
19
|
+
start: instanceStartIndex,
|
|
20
|
+
end: instanceEndIndex
|
|
41
21
|
},
|
|
42
|
-
|
|
22
|
+
instanceContent: instanceMatch[0]
|
|
43
23
|
};
|
|
24
|
+
return result;
|
|
44
25
|
}
|
|
45
26
|
}
|
|
46
|
-
return result;
|
|
47
27
|
} else if (classMatch.index > positionIndex - startIndex) {
|
|
48
28
|
break;
|
|
49
29
|
}
|
|
50
30
|
}
|
|
51
|
-
}
|
|
52
|
-
return
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
53
33
|
}
|
|
54
34
|
|
|
55
35
|
export { positionCheck };
|
package/dist/providers/hover.cjs
CHANGED
|
@@ -11,21 +11,23 @@ function doHover(instance, range, config) {
|
|
|
11
11
|
css$1.add(instance);
|
|
12
12
|
const contents = [];
|
|
13
13
|
if (css$1.text) {
|
|
14
|
-
const cssPreview = getCssPreview(
|
|
14
|
+
const cssPreview = getCssPreview(css$1.text);
|
|
15
15
|
if (cssPreview) {
|
|
16
16
|
contents.push(cssPreview);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if (css$1.rules.length > 0) {
|
|
20
|
+
const cssHoverInfo = getCssHoverInfo(css$1.rules[0]);
|
|
21
|
+
if (cssHoverInfo) {
|
|
22
|
+
contents.push(cssHoverInfo);
|
|
23
|
+
}
|
|
22
24
|
}
|
|
23
25
|
return {
|
|
24
26
|
contents,
|
|
25
27
|
range: range
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
function getCssPreview(
|
|
30
|
+
function getCssPreview(renderText) {
|
|
29
31
|
return {
|
|
30
32
|
language: 'css',
|
|
31
33
|
value: beautifyCss.css_beautify(renderText, {
|
|
@@ -34,13 +36,13 @@ function getCssPreview(instance, renderText) {
|
|
|
34
36
|
})
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
|
-
function getCssHoverInfo(
|
|
39
|
+
function getCssHoverInfo(rule) {
|
|
38
40
|
const cssDataProvider = new dataProvider.CSSDataProvider(webCustomData.cssData);
|
|
39
41
|
const cssProperties = cssDataProvider.provideProperties();
|
|
40
42
|
let cssHoverInfo = null;
|
|
41
43
|
const fullKey = rule.id;
|
|
42
44
|
const originalCssProperty = cssProperties.find((x)=>x.name == fullKey);
|
|
43
|
-
if ([
|
|
45
|
+
if (rule?.layer && [
|
|
44
46
|
css.Layer.Core,
|
|
45
47
|
css.Layer.CoreNative,
|
|
46
48
|
css.Layer.CoreShorthand,
|
package/dist/providers/hover.mjs
CHANGED
|
@@ -9,21 +9,23 @@ function doHover(instance, range, config) {
|
|
|
9
9
|
css.add(instance);
|
|
10
10
|
const contents = [];
|
|
11
11
|
if (css.text) {
|
|
12
|
-
const cssPreview = getCssPreview(
|
|
12
|
+
const cssPreview = getCssPreview(css.text);
|
|
13
13
|
if (cssPreview) {
|
|
14
14
|
contents.push(cssPreview);
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
if (css.rules.length > 0) {
|
|
18
|
+
const cssHoverInfo = getCssHoverInfo(css.rules[0]);
|
|
19
|
+
if (cssHoverInfo) {
|
|
20
|
+
contents.push(cssHoverInfo);
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return {
|
|
22
24
|
contents,
|
|
23
25
|
range: range
|
|
24
26
|
};
|
|
25
27
|
}
|
|
26
|
-
function getCssPreview(
|
|
28
|
+
function getCssPreview(renderText) {
|
|
27
29
|
return {
|
|
28
30
|
language: 'css',
|
|
29
31
|
value: css_beautify(renderText, {
|
|
@@ -32,13 +34,13 @@ function getCssPreview(instance, renderText) {
|
|
|
32
34
|
})
|
|
33
35
|
};
|
|
34
36
|
}
|
|
35
|
-
function getCssHoverInfo(
|
|
37
|
+
function getCssHoverInfo(rule) {
|
|
36
38
|
const cssDataProvider = new CSSDataProvider(cssData);
|
|
37
39
|
const cssProperties = cssDataProvider.provideProperties();
|
|
38
40
|
let cssHoverInfo = null;
|
|
39
41
|
const fullKey = rule.id;
|
|
40
42
|
const originalCssProperty = cssProperties.find((x)=>x.name == fullKey);
|
|
41
|
-
if ([
|
|
43
|
+
if (rule?.layer && [
|
|
42
44
|
Layer.Core,
|
|
43
45
|
Layer.CoreNative,
|
|
44
46
|
Layer.CoreShorthand,
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@master/css-language-service","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint src"},"description":"Master CSS Language Service","author":"Aoyue Design LLC.","license":"MIT","repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/language-service"},"dependencies":{"@babel/parser":"^7.23.9","@master/css":"^2.0.0-rc.
|
|
1
|
+
{"name":"@master/css-language-service","type":"module","scripts":{"build":"techor build \"src/**/*.ts\"","dev":"pnpm build --watch","type-check":"tsc --noEmit","lint":"eslint src"},"description":"Master CSS Language Service","author":"Aoyue Design LLC.","license":"MIT","repository":{"type":"git","url":"https://github.com/master-co/css.git","directory":"packages/language-service"},"dependencies":{"@babel/parser":"^7.23.9","@master/css":"^2.0.0-rc.20","color-convert":"^2.0.1","js-beautify":"^1.15.1","vscode-css-languageservice":"^6.2.12"},"devDependencies":{"@types/color-convert":"^2.0.3","vscode-languageserver-types":"^3.17.5"},"sideEffects":false,"main":"./dist/index.cjs","module":"./dist/index.mjs","jsnext:main":"./dist/index.mjs","esnext":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.cjs","types":"./dist/index.d.ts"},"./settings":{"import":"./dist/settings/index.mjs","require":"./dist/settings/index.cjs","types":"./dist/settings/index.d.ts"}},"typesVersions":{"*":{"./":["./dist/index.d.ts"],"./settings":["./dist/settings.d.ts"]}},"files":["dist"],"publishConfig":{"access":"public","provenance":true},"version":"2.0.0-rc.20"}
|