@powerlines/plugin-automd 0.1.128 → 0.1.129
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/_virtual/rolldown_runtime.cjs +2 -0
- package/dist/_virtual/rolldown_runtime.mjs +32 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +7 -7
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +78 -0
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +77 -0
- package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.cjs +5032 -0
- package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.mjs +5031 -0
- package/dist/node_modules/.pnpm/automd@0.4.2_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.cjs +593 -0
- package/dist/node_modules/.pnpm/automd@0.4.2_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.mjs +590 -0
- package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.cjs +23 -0
- package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs +22 -0
- package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.cjs +405 -0
- package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs +404 -0
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +46 -0
- package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +45 -0
- package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.cjs +204 -0
- package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs +202 -0
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +1013 -0
- package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +1007 -0
- package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.cjs +128 -0
- package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs +123 -0
- package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.cjs +41464 -0
- package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs +41461 -0
- package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.cjs +4387 -0
- package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs +4384 -0
- package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.cjs +26 -0
- package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs +26 -0
- package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.cjs +370 -0
- package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs +367 -0
- package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +939 -0
- package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +939 -0
- package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.cjs +67 -0
- package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs +64 -0
- package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.cjs +1292 -0
- package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs +1284 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +179 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +179 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +20 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +18 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +3975 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +3961 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.cjs +16 -0
- package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +14 -0
- package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.cjs +36 -0
- package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs +33 -0
- package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.cjs +227 -0
- package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs +225 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +139 -0
- package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +133 -0
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +77 -0
- package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +76 -0
- package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.cjs +72 -0
- package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs +69 -0
- package/dist/node_modules/.pnpm/ufo@1.6.2/node_modules/ufo/dist/index.cjs +178 -0
- package/dist/node_modules/.pnpm/ufo@1.6.2/node_modules/ufo/dist/index.mjs +175 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.cjs +12337 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs +12337 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.cjs +19 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs +18 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.cjs +71 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs +71 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.cjs +110 -0
- package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs +100 -0
- package/dist/types/plugin.d.mts +3 -3
- package/package.json +4 -5
- /package/dist/{powerlines → packages/powerlines}/src/internal/helpers/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/api.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/babel.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/build.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/commands.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/config.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/context.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/fs.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/plugin.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/resolved.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/tsconfig.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/unplugin.d.mts +0 -0
|
@@ -0,0 +1,178 @@
|
|
|
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
|
+
exports.joinURL = joinURL;
|
|
177
|
+
exports.withBase = withBase;
|
|
178
|
+
exports.withQuery = withQuery;
|
|
@@ -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 { joinURL, withBase, withQuery };
|