@unocss/language-server 66.6.3
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/LICENSE +21 -0
- package/bin/unocss-language-server.js +2 -0
- package/dist/babel.cjs +246 -0
- package/dist/chunk-C9ebiww4.mjs +32 -0
- package/dist/dist-BUrt6dYo.cjs +193 -0
- package/dist/dist-Dwf-d4OE.mjs +175 -0
- package/dist/index.d.mts +156 -0
- package/dist/index.mjs +12482 -0
- package/dist/jiti-B459FbZV.cjs +4477 -0
- package/dist/loader-CxlILAbz.mjs +572 -0
- package/dist/multipart-parser-D3zGHRx2.mjs +168 -0
- package/dist/multipart-parser-s9tbX9e1.cjs +178 -0
- package/dist/node-B8nS8lcG.cjs +313 -0
- package/dist/node-CautW6cw.cjs +4024 -0
- package/dist/node-DvibxqDE.mjs +302 -0
- package/dist/node-loader-BO0uvH6Z.cjs +7151 -0
- package/dist/node-loader-DpZIWCu9.mjs +7144 -0
- package/dist/node-rKyHxxpg.mjs +3973 -0
- package/dist/prompt-BJqhZQ-_.cjs +851 -0
- package/dist/server.cjs +55261 -0
- package/dist/server.d.cts +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
14
|
+
key = keys[i];
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
__defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: true
|
|
28
|
+
}) : target, mod));
|
|
29
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { __require as n, __toESM as r, __commonJSMin as t };
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/.pnpm/ufo@1.6.2/node_modules/ufo/dist/index.mjs
|
|
3
|
+
const r = String.fromCharCode;
|
|
4
|
+
const HASH_RE = /#/g;
|
|
5
|
+
const AMPERSAND_RE = /&/g;
|
|
6
|
+
const SLASH_RE = /\//g;
|
|
7
|
+
const EQUAL_RE = /=/g;
|
|
8
|
+
const PLUS_RE = /\+/g;
|
|
9
|
+
const ENC_CARET_RE = /%5e/gi;
|
|
10
|
+
const ENC_BACKTICK_RE = /%60/gi;
|
|
11
|
+
const ENC_PIPE_RE = /%7c/gi;
|
|
12
|
+
const ENC_SPACE_RE = /%20/gi;
|
|
13
|
+
function encode(text) {
|
|
14
|
+
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
15
|
+
}
|
|
16
|
+
function encodeQueryValue(input) {
|
|
17
|
+
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
18
|
+
}
|
|
19
|
+
function encodeQueryKey(text) {
|
|
20
|
+
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
21
|
+
}
|
|
22
|
+
function decode(text = "") {
|
|
23
|
+
try {
|
|
24
|
+
return decodeURIComponent("" + text);
|
|
25
|
+
} catch {
|
|
26
|
+
return "" + text;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function decodeQueryKey(text) {
|
|
30
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
31
|
+
}
|
|
32
|
+
function decodeQueryValue(text) {
|
|
33
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
34
|
+
}
|
|
35
|
+
function parseQuery(parametersString = "") {
|
|
36
|
+
const object = /* @__PURE__ */ Object.create(null);
|
|
37
|
+
if (parametersString[0] === "?") parametersString = parametersString.slice(1);
|
|
38
|
+
for (const parameter of parametersString.split("&")) {
|
|
39
|
+
const s = parameter.match(/([^=]+)=?(.*)/) || [];
|
|
40
|
+
if (s.length < 2) continue;
|
|
41
|
+
const key = decodeQueryKey(s[1]);
|
|
42
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
43
|
+
const value = decodeQueryValue(s[2] || "");
|
|
44
|
+
if (object[key] === void 0) object[key] = value;
|
|
45
|
+
else if (Array.isArray(object[key])) object[key].push(value);
|
|
46
|
+
else object[key] = [object[key], value];
|
|
47
|
+
}
|
|
48
|
+
return object;
|
|
49
|
+
}
|
|
50
|
+
function encodeQueryItem(key, value) {
|
|
51
|
+
if (typeof value === "number" || typeof value === "boolean") value = String(value);
|
|
52
|
+
if (!value) return encodeQueryKey(key);
|
|
53
|
+
if (Array.isArray(value)) return value.map((_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`).join("&");
|
|
54
|
+
return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
|
|
55
|
+
}
|
|
56
|
+
function stringifyQuery(query) {
|
|
57
|
+
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
|
|
58
|
+
}
|
|
59
|
+
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
60
|
+
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
61
|
+
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
62
|
+
const TRAILING_SLASH_RE = /\/$|\/\?|\/#/;
|
|
63
|
+
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
64
|
+
function hasProtocol(inputString, opts = {}) {
|
|
65
|
+
if (typeof opts === "boolean") opts = { acceptRelative: opts };
|
|
66
|
+
if (opts.strict) return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
67
|
+
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
68
|
+
}
|
|
69
|
+
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
70
|
+
if (!respectQueryAndFragment) return input.endsWith("/");
|
|
71
|
+
return TRAILING_SLASH_RE.test(input);
|
|
72
|
+
}
|
|
73
|
+
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
74
|
+
if (!respectQueryAndFragment) return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
75
|
+
if (!hasTrailingSlash(input, true)) return input || "/";
|
|
76
|
+
let path = input;
|
|
77
|
+
let fragment = "";
|
|
78
|
+
const fragmentIndex = input.indexOf("#");
|
|
79
|
+
if (fragmentIndex !== -1) {
|
|
80
|
+
path = input.slice(0, fragmentIndex);
|
|
81
|
+
fragment = input.slice(fragmentIndex);
|
|
82
|
+
}
|
|
83
|
+
const [s0, ...s] = path.split("?");
|
|
84
|
+
return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
85
|
+
}
|
|
86
|
+
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
87
|
+
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
88
|
+
if (hasTrailingSlash(input, true)) return input || "/";
|
|
89
|
+
let path = input;
|
|
90
|
+
let fragment = "";
|
|
91
|
+
const fragmentIndex = input.indexOf("#");
|
|
92
|
+
if (fragmentIndex !== -1) {
|
|
93
|
+
path = input.slice(0, fragmentIndex);
|
|
94
|
+
fragment = input.slice(fragmentIndex);
|
|
95
|
+
if (!path) return fragment;
|
|
96
|
+
}
|
|
97
|
+
const [s0, ...s] = path.split("?");
|
|
98
|
+
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
99
|
+
}
|
|
100
|
+
function withBase(input, base) {
|
|
101
|
+
if (isEmptyURL(base) || hasProtocol(input)) return input;
|
|
102
|
+
const _base = withoutTrailingSlash(base);
|
|
103
|
+
if (input.startsWith(_base)) return input;
|
|
104
|
+
return joinURL(_base, input);
|
|
105
|
+
}
|
|
106
|
+
function withQuery(input, query) {
|
|
107
|
+
const parsed = parseURL(input);
|
|
108
|
+
parsed.search = stringifyQuery({
|
|
109
|
+
...parseQuery(parsed.search),
|
|
110
|
+
...query
|
|
111
|
+
});
|
|
112
|
+
return stringifyParsedURL(parsed);
|
|
113
|
+
}
|
|
114
|
+
function isEmptyURL(url) {
|
|
115
|
+
return !url || url === "/";
|
|
116
|
+
}
|
|
117
|
+
function isNonEmptyURL(url) {
|
|
118
|
+
return url && url !== "/";
|
|
119
|
+
}
|
|
120
|
+
function joinURL(base, ...input) {
|
|
121
|
+
let url = base || "";
|
|
122
|
+
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) if (url) {
|
|
123
|
+
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
|
124
|
+
url = withTrailingSlash(url) + _segment;
|
|
125
|
+
} else url = segment;
|
|
126
|
+
return url;
|
|
127
|
+
}
|
|
128
|
+
const protocolRelative = Symbol.for("ufo:protocolRelative");
|
|
129
|
+
function parseURL(input = "", defaultProto) {
|
|
130
|
+
const _specialProtoMatch = input.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);
|
|
131
|
+
if (_specialProtoMatch) {
|
|
132
|
+
const [, _proto, _pathname = ""] = _specialProtoMatch;
|
|
133
|
+
return {
|
|
134
|
+
protocol: _proto.toLowerCase(),
|
|
135
|
+
pathname: _pathname,
|
|
136
|
+
href: _proto + _pathname,
|
|
137
|
+
auth: "",
|
|
138
|
+
host: "",
|
|
139
|
+
search: "",
|
|
140
|
+
hash: ""
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
if (!hasProtocol(input, { acceptRelative: true })) return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
|
|
144
|
+
const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
145
|
+
let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
|
|
146
|
+
if (protocol === "file:") path = path.replace(/\/(?=[A-Za-z]:)/, "");
|
|
147
|
+
const { pathname, search, hash } = parsePath(path);
|
|
148
|
+
return {
|
|
149
|
+
protocol: protocol.toLowerCase(),
|
|
150
|
+
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
|
151
|
+
host,
|
|
152
|
+
pathname,
|
|
153
|
+
search,
|
|
154
|
+
hash,
|
|
155
|
+
[protocolRelative]: !protocol
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
function parsePath(input = "") {
|
|
159
|
+
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
160
|
+
return {
|
|
161
|
+
pathname,
|
|
162
|
+
search,
|
|
163
|
+
hash
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function stringifyParsedURL(parsed) {
|
|
167
|
+
const pathname = parsed.pathname || "";
|
|
168
|
+
const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
|
|
169
|
+
const hash = parsed.hash || "";
|
|
170
|
+
const auth = parsed.auth ? parsed.auth + "@" : "";
|
|
171
|
+
const host = parsed.host || "";
|
|
172
|
+
return (parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "") + auth + host + pathname + search + hash;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
//#endregion
|
|
176
|
+
Object.defineProperty(exports, 'joinURL', {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () {
|
|
179
|
+
return joinURL;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(exports, 'withBase', {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function () {
|
|
185
|
+
return withBase;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, 'withQuery', {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () {
|
|
191
|
+
return withQuery;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/ufo@1.6.2/node_modules/ufo/dist/index.mjs
|
|
2
|
+
const r = String.fromCharCode;
|
|
3
|
+
const HASH_RE = /#/g;
|
|
4
|
+
const AMPERSAND_RE = /&/g;
|
|
5
|
+
const SLASH_RE = /\//g;
|
|
6
|
+
const EQUAL_RE = /=/g;
|
|
7
|
+
const PLUS_RE = /\+/g;
|
|
8
|
+
const ENC_CARET_RE = /%5e/gi;
|
|
9
|
+
const ENC_BACKTICK_RE = /%60/gi;
|
|
10
|
+
const ENC_PIPE_RE = /%7c/gi;
|
|
11
|
+
const ENC_SPACE_RE = /%20/gi;
|
|
12
|
+
function encode(text) {
|
|
13
|
+
return encodeURI("" + text).replace(ENC_PIPE_RE, "|");
|
|
14
|
+
}
|
|
15
|
+
function encodeQueryValue(input) {
|
|
16
|
+
return encode(typeof input === "string" ? input : JSON.stringify(input)).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CARET_RE, "^").replace(SLASH_RE, "%2F");
|
|
17
|
+
}
|
|
18
|
+
function encodeQueryKey(text) {
|
|
19
|
+
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
20
|
+
}
|
|
21
|
+
function decode(text = "") {
|
|
22
|
+
try {
|
|
23
|
+
return decodeURIComponent("" + text);
|
|
24
|
+
} catch {
|
|
25
|
+
return "" + text;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function decodeQueryKey(text) {
|
|
29
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
30
|
+
}
|
|
31
|
+
function decodeQueryValue(text) {
|
|
32
|
+
return decode(text.replace(PLUS_RE, " "));
|
|
33
|
+
}
|
|
34
|
+
function parseQuery(parametersString = "") {
|
|
35
|
+
const object = /* @__PURE__ */ Object.create(null);
|
|
36
|
+
if (parametersString[0] === "?") parametersString = parametersString.slice(1);
|
|
37
|
+
for (const parameter of parametersString.split("&")) {
|
|
38
|
+
const s = parameter.match(/([^=]+)=?(.*)/) || [];
|
|
39
|
+
if (s.length < 2) continue;
|
|
40
|
+
const key = decodeQueryKey(s[1]);
|
|
41
|
+
if (key === "__proto__" || key === "constructor") continue;
|
|
42
|
+
const value = decodeQueryValue(s[2] || "");
|
|
43
|
+
if (object[key] === void 0) object[key] = value;
|
|
44
|
+
else if (Array.isArray(object[key])) object[key].push(value);
|
|
45
|
+
else object[key] = [object[key], value];
|
|
46
|
+
}
|
|
47
|
+
return object;
|
|
48
|
+
}
|
|
49
|
+
function encodeQueryItem(key, value) {
|
|
50
|
+
if (typeof value === "number" || typeof value === "boolean") value = String(value);
|
|
51
|
+
if (!value) return encodeQueryKey(key);
|
|
52
|
+
if (Array.isArray(value)) return value.map((_value) => `${encodeQueryKey(key)}=${encodeQueryValue(_value)}`).join("&");
|
|
53
|
+
return `${encodeQueryKey(key)}=${encodeQueryValue(value)}`;
|
|
54
|
+
}
|
|
55
|
+
function stringifyQuery(query) {
|
|
56
|
+
return Object.keys(query).filter((k) => query[k] !== void 0).map((k) => encodeQueryItem(k, query[k])).filter(Boolean).join("&");
|
|
57
|
+
}
|
|
58
|
+
const PROTOCOL_STRICT_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{1,2})/;
|
|
59
|
+
const PROTOCOL_REGEX = /^[\s\w\0+.-]{2,}:([/\\]{2})?/;
|
|
60
|
+
const PROTOCOL_RELATIVE_REGEX = /^([/\\]\s*){2,}[^/\\]/;
|
|
61
|
+
const TRAILING_SLASH_RE = /\/$|\/\?|\/#/;
|
|
62
|
+
const JOIN_LEADING_SLASH_RE = /^\.?\//;
|
|
63
|
+
function hasProtocol(inputString, opts = {}) {
|
|
64
|
+
if (typeof opts === "boolean") opts = { acceptRelative: opts };
|
|
65
|
+
if (opts.strict) return PROTOCOL_STRICT_REGEX.test(inputString);
|
|
66
|
+
return PROTOCOL_REGEX.test(inputString) || (opts.acceptRelative ? PROTOCOL_RELATIVE_REGEX.test(inputString) : false);
|
|
67
|
+
}
|
|
68
|
+
function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
69
|
+
if (!respectQueryAndFragment) return input.endsWith("/");
|
|
70
|
+
return TRAILING_SLASH_RE.test(input);
|
|
71
|
+
}
|
|
72
|
+
function withoutTrailingSlash(input = "", respectQueryAndFragment) {
|
|
73
|
+
if (!respectQueryAndFragment) return (hasTrailingSlash(input) ? input.slice(0, -1) : input) || "/";
|
|
74
|
+
if (!hasTrailingSlash(input, true)) return input || "/";
|
|
75
|
+
let path = input;
|
|
76
|
+
let fragment = "";
|
|
77
|
+
const fragmentIndex = input.indexOf("#");
|
|
78
|
+
if (fragmentIndex !== -1) {
|
|
79
|
+
path = input.slice(0, fragmentIndex);
|
|
80
|
+
fragment = input.slice(fragmentIndex);
|
|
81
|
+
}
|
|
82
|
+
const [s0, ...s] = path.split("?");
|
|
83
|
+
return ((s0.endsWith("/") ? s0.slice(0, -1) : s0) || "/") + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
84
|
+
}
|
|
85
|
+
function withTrailingSlash(input = "", respectQueryAndFragment) {
|
|
86
|
+
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
87
|
+
if (hasTrailingSlash(input, true)) return input || "/";
|
|
88
|
+
let path = input;
|
|
89
|
+
let fragment = "";
|
|
90
|
+
const fragmentIndex = input.indexOf("#");
|
|
91
|
+
if (fragmentIndex !== -1) {
|
|
92
|
+
path = input.slice(0, fragmentIndex);
|
|
93
|
+
fragment = input.slice(fragmentIndex);
|
|
94
|
+
if (!path) return fragment;
|
|
95
|
+
}
|
|
96
|
+
const [s0, ...s] = path.split("?");
|
|
97
|
+
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
98
|
+
}
|
|
99
|
+
function withBase(input, base) {
|
|
100
|
+
if (isEmptyURL(base) || hasProtocol(input)) return input;
|
|
101
|
+
const _base = withoutTrailingSlash(base);
|
|
102
|
+
if (input.startsWith(_base)) return input;
|
|
103
|
+
return joinURL(_base, input);
|
|
104
|
+
}
|
|
105
|
+
function withQuery(input, query) {
|
|
106
|
+
const parsed = parseURL(input);
|
|
107
|
+
parsed.search = stringifyQuery({
|
|
108
|
+
...parseQuery(parsed.search),
|
|
109
|
+
...query
|
|
110
|
+
});
|
|
111
|
+
return stringifyParsedURL(parsed);
|
|
112
|
+
}
|
|
113
|
+
function isEmptyURL(url) {
|
|
114
|
+
return !url || url === "/";
|
|
115
|
+
}
|
|
116
|
+
function isNonEmptyURL(url) {
|
|
117
|
+
return url && url !== "/";
|
|
118
|
+
}
|
|
119
|
+
function joinURL(base, ...input) {
|
|
120
|
+
let url = base || "";
|
|
121
|
+
for (const segment of input.filter((url2) => isNonEmptyURL(url2))) if (url) {
|
|
122
|
+
const _segment = segment.replace(JOIN_LEADING_SLASH_RE, "");
|
|
123
|
+
url = withTrailingSlash(url) + _segment;
|
|
124
|
+
} else url = segment;
|
|
125
|
+
return url;
|
|
126
|
+
}
|
|
127
|
+
const protocolRelative = Symbol.for("ufo:protocolRelative");
|
|
128
|
+
function parseURL(input = "", defaultProto) {
|
|
129
|
+
const _specialProtoMatch = input.match(/^[\s\0]*(blob:|data:|javascript:|vbscript:)(.*)/i);
|
|
130
|
+
if (_specialProtoMatch) {
|
|
131
|
+
const [, _proto, _pathname = ""] = _specialProtoMatch;
|
|
132
|
+
return {
|
|
133
|
+
protocol: _proto.toLowerCase(),
|
|
134
|
+
pathname: _pathname,
|
|
135
|
+
href: _proto + _pathname,
|
|
136
|
+
auth: "",
|
|
137
|
+
host: "",
|
|
138
|
+
search: "",
|
|
139
|
+
hash: ""
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
if (!hasProtocol(input, { acceptRelative: true })) return defaultProto ? parseURL(defaultProto + input) : parsePath(input);
|
|
143
|
+
const [, protocol = "", auth, hostAndPath = ""] = input.replace(/\\/g, "/").match(/^[\s\0]*([\w+.-]{2,}:)?\/\/([^/@]+@)?(.*)/) || [];
|
|
144
|
+
let [, host = "", path = ""] = hostAndPath.match(/([^#/?]*)(.*)?/) || [];
|
|
145
|
+
if (protocol === "file:") path = path.replace(/\/(?=[A-Za-z]:)/, "");
|
|
146
|
+
const { pathname, search, hash } = parsePath(path);
|
|
147
|
+
return {
|
|
148
|
+
protocol: protocol.toLowerCase(),
|
|
149
|
+
auth: auth ? auth.slice(0, Math.max(0, auth.length - 1)) : "",
|
|
150
|
+
host,
|
|
151
|
+
pathname,
|
|
152
|
+
search,
|
|
153
|
+
hash,
|
|
154
|
+
[protocolRelative]: !protocol
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function parsePath(input = "") {
|
|
158
|
+
const [pathname = "", search = "", hash = ""] = (input.match(/([^#?]*)(\?[^#]*)?(#.*)?/) || []).splice(1);
|
|
159
|
+
return {
|
|
160
|
+
pathname,
|
|
161
|
+
search,
|
|
162
|
+
hash
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function stringifyParsedURL(parsed) {
|
|
166
|
+
const pathname = parsed.pathname || "";
|
|
167
|
+
const search = parsed.search ? (parsed.search.startsWith("?") ? "" : "?") + parsed.search : "";
|
|
168
|
+
const hash = parsed.hash || "";
|
|
169
|
+
const auth = parsed.auth ? parsed.auth + "@" : "";
|
|
170
|
+
const host = parsed.host || "";
|
|
171
|
+
return (parsed.protocol || parsed[protocolRelative] ? (parsed.protocol || "") + "//" : "") + auth + host + pathname + search + hash;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
export { withBase as n, withQuery as r, joinURL as t };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import * as _unocss_core0 from "@unocss/core";
|
|
2
|
+
import { UnoGenerator, UnocssPluginContext, UserConfig } from "@unocss/core";
|
|
3
|
+
import { Connection } from "vscode-languageserver";
|
|
4
|
+
|
|
5
|
+
//#region src/core/cache.d.ts
|
|
6
|
+
declare function clearDocumentCache(uri: string): void;
|
|
7
|
+
declare function getMatchedPositionsFromDoc(uno: UnoGenerator, code: string, id: string, strictAnnotationMatch?: boolean, force?: boolean): any;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/core/context.d.ts
|
|
10
|
+
type UnoContext$1 = UnocssPluginContext<UserConfig<any>> | null | undefined;
|
|
11
|
+
declare class ContextManager {
|
|
12
|
+
cwd: string;
|
|
13
|
+
private connection;
|
|
14
|
+
ready: Promise<void>;
|
|
15
|
+
contextsMap: Map<string, UnoContext$1>;
|
|
16
|
+
configSources: string[];
|
|
17
|
+
private fileContextCache;
|
|
18
|
+
private configExistsCache;
|
|
19
|
+
private loadingContexts;
|
|
20
|
+
private discoveredConfigs;
|
|
21
|
+
private readonly defaultUnocssConfig;
|
|
22
|
+
events: _unocss_core0.Emitter<{
|
|
23
|
+
reload: () => void;
|
|
24
|
+
unload: (context: UnocssPluginContext<UserConfig<any>>) => void;
|
|
25
|
+
contextLoaded: (context: UnocssPluginContext<UserConfig<any>>) => void;
|
|
26
|
+
contextReload: (context: UnocssPluginContext<UserConfig<any>>) => void;
|
|
27
|
+
contextUnload: (context: UnocssPluginContext<UserConfig<any>>) => void;
|
|
28
|
+
}>;
|
|
29
|
+
constructor(cwd: string, connection: Connection);
|
|
30
|
+
private log;
|
|
31
|
+
private warn;
|
|
32
|
+
isTarget(id: string): boolean;
|
|
33
|
+
get contexts(): UnocssPluginContext<UserConfig<any>>[];
|
|
34
|
+
reload(): Promise<void>;
|
|
35
|
+
unloadContext(configDir: string): Promise<void>;
|
|
36
|
+
unload(configDir: string): Promise<void>;
|
|
37
|
+
private clearFileContextCache;
|
|
38
|
+
loadContextInDirectory(dir: string): Promise<UnoContext$1>;
|
|
39
|
+
private loadContext;
|
|
40
|
+
private setupYarnPnp;
|
|
41
|
+
private setupContextReload;
|
|
42
|
+
private logConfigInfo;
|
|
43
|
+
private finishLoading;
|
|
44
|
+
resolveClosestContext(code: string, file: string): Promise<UnoContext$1 | undefined>;
|
|
45
|
+
private discoverAndLoadConfig;
|
|
46
|
+
private findConfigDirectory;
|
|
47
|
+
private hasConfigFiles;
|
|
48
|
+
private cacheSearchPath;
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
//#region src/types.d.ts
|
|
52
|
+
interface ServerSettings {
|
|
53
|
+
languageIds: string[];
|
|
54
|
+
root: string | string[] | undefined;
|
|
55
|
+
include: string | string[] | undefined;
|
|
56
|
+
exclude: string | string[] | undefined;
|
|
57
|
+
underline: boolean;
|
|
58
|
+
colorPreview: boolean;
|
|
59
|
+
colorPreviewRadius: string;
|
|
60
|
+
remToPxPreview: boolean;
|
|
61
|
+
remToPxRatio: number;
|
|
62
|
+
selectionStyle: boolean;
|
|
63
|
+
strictAnnotationMatch: boolean;
|
|
64
|
+
autocompleteMatchType: 'prefix' | 'fuzzy';
|
|
65
|
+
autocompleteStrict: boolean;
|
|
66
|
+
autocompleteMaxItems: number;
|
|
67
|
+
}
|
|
68
|
+
declare const defaultSettings: ServerSettings;
|
|
69
|
+
type UnoContext = UnocssPluginContext<UserConfig<any>>;
|
|
70
|
+
interface MatchedPosition {
|
|
71
|
+
start: number;
|
|
72
|
+
end: number;
|
|
73
|
+
text: string;
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/utils/color.d.ts
|
|
77
|
+
/**
|
|
78
|
+
* Get CSS color string from CSS string
|
|
79
|
+
*
|
|
80
|
+
* @example Input with CSS var
|
|
81
|
+
* ```css
|
|
82
|
+
*.dark [border="dark\:gray-700"] {
|
|
83
|
+
* --un-border-opacity: 1;
|
|
84
|
+
* border-color: rgb(55 65 81 / var(--un-border-opacity));
|
|
85
|
+
*}
|
|
86
|
+
* ```
|
|
87
|
+
* return `rgb(55 65 81 / 1)`
|
|
88
|
+
*
|
|
89
|
+
* @example Input with no-value CSS var and its fallback value
|
|
90
|
+
* ```css
|
|
91
|
+
*.bg-brand-primary {
|
|
92
|
+
* background-color: hsl(217 78% 51% / var(--no-value, 0.5));
|
|
93
|
+
*}
|
|
94
|
+
* ```
|
|
95
|
+
* return `hsl(217 78% 51% / 0.5)`
|
|
96
|
+
*
|
|
97
|
+
* @example Input with no-value CSS var
|
|
98
|
+
* ```css
|
|
99
|
+
*.bg-brand-primary {
|
|
100
|
+
* background-color: hsl(217 78% 51% / var(--no-value));
|
|
101
|
+
*}
|
|
102
|
+
* ```
|
|
103
|
+
* return `rgb(217 78% 51%)`
|
|
104
|
+
*
|
|
105
|
+
* @param str - CSS string
|
|
106
|
+
* @returns The **first** CSS color string (hex, rgb[a], hsl[a]) or `undefined`
|
|
107
|
+
*/
|
|
108
|
+
declare function getColorString(str: string): string | undefined;
|
|
109
|
+
declare function convertToRGBA(rgbColor: string): string;
|
|
110
|
+
declare function parseColorToRGBA(colorString: string): {
|
|
111
|
+
red: number;
|
|
112
|
+
green: number;
|
|
113
|
+
blue: number;
|
|
114
|
+
alpha: number;
|
|
115
|
+
} | undefined;
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/utils/css.d.ts
|
|
118
|
+
/**
|
|
119
|
+
* Credit to [@voorjaar](https://github.com/voorjaar)
|
|
120
|
+
*
|
|
121
|
+
* @see https://github.com/windicss/windicss-intellisense/issues/13
|
|
122
|
+
* @param str
|
|
123
|
+
*/
|
|
124
|
+
declare function addRemToPxComment(str?: string, remToPixel?: number): string;
|
|
125
|
+
declare function getCSS(uno: UnoGenerator, utilName: string | string[]): Promise<string>;
|
|
126
|
+
declare function getPrettiedCSS(uno: UnoGenerator, util: string | string[], remToPxRatio: number): Promise<{
|
|
127
|
+
prettified: string;
|
|
128
|
+
css: string;
|
|
129
|
+
layers: string[];
|
|
130
|
+
getLayer: (name?: string) => string | undefined;
|
|
131
|
+
getLayers: (includes?: string[], excludes?: string[]) => string;
|
|
132
|
+
setLayer: (layer: string, callback: (content: string) => Promise<string>) => Promise<string>;
|
|
133
|
+
matched: Set<string>;
|
|
134
|
+
}>;
|
|
135
|
+
declare function getPrettiedMarkdown(uno: UnoGenerator, util: string | string[], remToPxRatio: number): Promise<string>;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region ../../virtual-shared/integration/src/match-positions.d.ts
|
|
138
|
+
interface GetMatchedPositionsOptions {
|
|
139
|
+
isPug?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Regex to only limit the matched positions for certain code
|
|
142
|
+
*/
|
|
143
|
+
includeRegex?: RegExp[];
|
|
144
|
+
/**
|
|
145
|
+
* Regex to exclude the matched positions for certain code, excludeRegex has higher priority than includeRegex
|
|
146
|
+
*/
|
|
147
|
+
excludeRegex?: RegExp[];
|
|
148
|
+
}
|
|
149
|
+
declare function getMatchedPositionsFromCode(uno: UnoGenerator, code: string, id?: string, options?: GetMatchedPositionsOptions): Promise<(readonly [start: number, end: number, text: string])[]>;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/utils/position.d.ts
|
|
152
|
+
declare function shouldProvideAutocomplete(code: string, id: string, offset: number): boolean;
|
|
153
|
+
declare function isVueWithPug(code: string, id: string): boolean;
|
|
154
|
+
declare function isSubdir(parent: string, child: string): boolean | "";
|
|
155
|
+
//#endregion
|
|
156
|
+
export { ContextManager, type MatchedPosition, type ServerSettings, type UnoContext, addRemToPxComment, clearDocumentCache, convertToRGBA, defaultSettings, getCSS, getColorString, getMatchedPositionsFromCode, getMatchedPositionsFromDoc, getPrettiedCSS, getPrettiedMarkdown, isSubdir, isVueWithPug, parseColorToRGBA, shouldProvideAutocomplete };
|