市场夺宝奇兵
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

376 lines
12 KiB

  1. import { __commonJS } from "./dep-lCKrEJQm.js";
  2. //#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/parse.js
  3. var require_parse = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/parse.js": ((exports, module) => {
  4. var openParentheses = "(".charCodeAt(0);
  5. var closeParentheses = ")".charCodeAt(0);
  6. var singleQuote = "'".charCodeAt(0);
  7. var doubleQuote = "\"".charCodeAt(0);
  8. var backslash = "\\".charCodeAt(0);
  9. var slash = "/".charCodeAt(0);
  10. var comma = ",".charCodeAt(0);
  11. var colon = ":".charCodeAt(0);
  12. var star = "*".charCodeAt(0);
  13. var uLower = "u".charCodeAt(0);
  14. var uUpper = "U".charCodeAt(0);
  15. var plus$1 = "+".charCodeAt(0);
  16. var isUnicodeRange = /^[a-f0-9?-]+$/i;
  17. module.exports = function(input) {
  18. var tokens = [];
  19. var value = input;
  20. var next, quote, prev, token, escape, escapePos, whitespacePos, parenthesesOpenPos;
  21. var pos = 0;
  22. var code = value.charCodeAt(pos);
  23. var max = value.length;
  24. var stack = [{ nodes: tokens }];
  25. var balanced = 0;
  26. var parent;
  27. var name = "";
  28. var before = "";
  29. var after = "";
  30. while (pos < max) if (code <= 32) {
  31. next = pos;
  32. do {
  33. next += 1;
  34. code = value.charCodeAt(next);
  35. } while (code <= 32);
  36. token = value.slice(pos, next);
  37. prev = tokens[tokens.length - 1];
  38. if (code === closeParentheses && balanced) after = token;
  39. else if (prev && prev.type === "div") {
  40. prev.after = token;
  41. prev.sourceEndIndex += token.length;
  42. } else if (code === comma || code === colon || code === slash && value.charCodeAt(next + 1) !== star && (!parent || parent && parent.type === "function" && parent.value !== "calc")) before = token;
  43. else tokens.push({
  44. type: "space",
  45. sourceIndex: pos,
  46. sourceEndIndex: next,
  47. value: token
  48. });
  49. pos = next;
  50. } else if (code === singleQuote || code === doubleQuote) {
  51. next = pos;
  52. quote = code === singleQuote ? "'" : "\"";
  53. token = {
  54. type: "string",
  55. sourceIndex: pos,
  56. quote
  57. };
  58. do {
  59. escape = false;
  60. next = value.indexOf(quote, next + 1);
  61. if (~next) {
  62. escapePos = next;
  63. while (value.charCodeAt(escapePos - 1) === backslash) {
  64. escapePos -= 1;
  65. escape = !escape;
  66. }
  67. } else {
  68. value += quote;
  69. next = value.length - 1;
  70. token.unclosed = true;
  71. }
  72. } while (escape);
  73. token.value = value.slice(pos + 1, next);
  74. token.sourceEndIndex = token.unclosed ? next : next + 1;
  75. tokens.push(token);
  76. pos = next + 1;
  77. code = value.charCodeAt(pos);
  78. } else if (code === slash && value.charCodeAt(pos + 1) === star) {
  79. next = value.indexOf("*/", pos);
  80. token = {
  81. type: "comment",
  82. sourceIndex: pos,
  83. sourceEndIndex: next + 2
  84. };
  85. if (next === -1) {
  86. token.unclosed = true;
  87. next = value.length;
  88. token.sourceEndIndex = next;
  89. }
  90. token.value = value.slice(pos + 2, next);
  91. tokens.push(token);
  92. pos = next + 2;
  93. code = value.charCodeAt(pos);
  94. } else if ((code === slash || code === star) && parent && parent.type === "function" && parent.value === "calc") {
  95. token = value[pos];
  96. tokens.push({
  97. type: "word",
  98. sourceIndex: pos - before.length,
  99. sourceEndIndex: pos + token.length,
  100. value: token
  101. });
  102. pos += 1;
  103. code = value.charCodeAt(pos);
  104. } else if (code === slash || code === comma || code === colon) {
  105. token = value[pos];
  106. tokens.push({
  107. type: "div",
  108. sourceIndex: pos - before.length,
  109. sourceEndIndex: pos + token.length,
  110. value: token,
  111. before,
  112. after: ""
  113. });
  114. before = "";
  115. pos += 1;
  116. code = value.charCodeAt(pos);
  117. } else if (openParentheses === code) {
  118. next = pos;
  119. do {
  120. next += 1;
  121. code = value.charCodeAt(next);
  122. } while (code <= 32);
  123. parenthesesOpenPos = pos;
  124. token = {
  125. type: "function",
  126. sourceIndex: pos - name.length,
  127. value: name,
  128. before: value.slice(parenthesesOpenPos + 1, next)
  129. };
  130. pos = next;
  131. if (name === "url" && code !== singleQuote && code !== doubleQuote) {
  132. next -= 1;
  133. do {
  134. escape = false;
  135. next = value.indexOf(")", next + 1);
  136. if (~next) {
  137. escapePos = next;
  138. while (value.charCodeAt(escapePos - 1) === backslash) {
  139. escapePos -= 1;
  140. escape = !escape;
  141. }
  142. } else {
  143. value += ")";
  144. next = value.length - 1;
  145. token.unclosed = true;
  146. }
  147. } while (escape);
  148. whitespacePos = next;
  149. do {
  150. whitespacePos -= 1;
  151. code = value.charCodeAt(whitespacePos);
  152. } while (code <= 32);
  153. if (parenthesesOpenPos < whitespacePos) {
  154. if (pos !== whitespacePos + 1) token.nodes = [{
  155. type: "word",
  156. sourceIndex: pos,
  157. sourceEndIndex: whitespacePos + 1,
  158. value: value.slice(pos, whitespacePos + 1)
  159. }];
  160. else token.nodes = [];
  161. if (token.unclosed && whitespacePos + 1 !== next) {
  162. token.after = "";
  163. token.nodes.push({
  164. type: "space",
  165. sourceIndex: whitespacePos + 1,
  166. sourceEndIndex: next,
  167. value: value.slice(whitespacePos + 1, next)
  168. });
  169. } else {
  170. token.after = value.slice(whitespacePos + 1, next);
  171. token.sourceEndIndex = next;
  172. }
  173. } else {
  174. token.after = "";
  175. token.nodes = [];
  176. }
  177. pos = next + 1;
  178. token.sourceEndIndex = token.unclosed ? next : pos;
  179. code = value.charCodeAt(pos);
  180. tokens.push(token);
  181. } else {
  182. balanced += 1;
  183. token.after = "";
  184. token.sourceEndIndex = pos + 1;
  185. tokens.push(token);
  186. stack.push(token);
  187. tokens = token.nodes = [];
  188. parent = token;
  189. }
  190. name = "";
  191. } else if (closeParentheses === code && balanced) {
  192. pos += 1;
  193. code = value.charCodeAt(pos);
  194. parent.after = after;
  195. parent.sourceEndIndex += after.length;
  196. after = "";
  197. balanced -= 1;
  198. stack[stack.length - 1].sourceEndIndex = pos;
  199. stack.pop();
  200. parent = stack[balanced];
  201. tokens = parent.nodes;
  202. } else {
  203. next = pos;
  204. do {
  205. if (code === backslash) next += 1;
  206. next += 1;
  207. code = value.charCodeAt(next);
  208. } while (next < max && !(code <= 32 || code === singleQuote || code === doubleQuote || code === comma || code === colon || code === slash || code === openParentheses || code === star && parent && parent.type === "function" && parent.value === "calc" || code === slash && parent.type === "function" && parent.value === "calc" || code === closeParentheses && balanced));
  209. token = value.slice(pos, next);
  210. if (openParentheses === code) name = token;
  211. else if ((uLower === token.charCodeAt(0) || uUpper === token.charCodeAt(0)) && plus$1 === token.charCodeAt(1) && isUnicodeRange.test(token.slice(2))) tokens.push({
  212. type: "unicode-range",
  213. sourceIndex: pos,
  214. sourceEndIndex: next,
  215. value: token
  216. });
  217. else tokens.push({
  218. type: "word",
  219. sourceIndex: pos,
  220. sourceEndIndex: next,
  221. value: token
  222. });
  223. pos = next;
  224. }
  225. for (pos = stack.length - 1; pos; pos -= 1) {
  226. stack[pos].unclosed = true;
  227. stack[pos].sourceEndIndex = value.length;
  228. }
  229. return stack[0].nodes;
  230. };
  231. }) });
  232. //#endregion
  233. //#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/walk.js
  234. var require_walk = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/walk.js": ((exports, module) => {
  235. module.exports = function walk$1(nodes, cb, bubble) {
  236. var i, max, node, result;
  237. for (i = 0, max = nodes.length; i < max; i += 1) {
  238. node = nodes[i];
  239. if (!bubble) result = cb(node, i, nodes);
  240. if (result !== false && node.type === "function" && Array.isArray(node.nodes)) walk$1(node.nodes, cb, bubble);
  241. if (bubble) cb(node, i, nodes);
  242. }
  243. };
  244. }) });
  245. //#endregion
  246. //#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/stringify.js
  247. var require_stringify = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/stringify.js": ((exports, module) => {
  248. function stringifyNode(node, custom) {
  249. var type = node.type;
  250. var value = node.value;
  251. var buf;
  252. var customResult;
  253. if (custom && (customResult = custom(node)) !== void 0) return customResult;
  254. else if (type === "word" || type === "space") return value;
  255. else if (type === "string") {
  256. buf = node.quote || "";
  257. return buf + value + (node.unclosed ? "" : buf);
  258. } else if (type === "comment") return "/*" + value + (node.unclosed ? "" : "*/");
  259. else if (type === "div") return (node.before || "") + value + (node.after || "");
  260. else if (Array.isArray(node.nodes)) {
  261. buf = stringify$1(node.nodes, custom);
  262. if (type !== "function") return buf;
  263. return value + "(" + (node.before || "") + buf + (node.after || "") + (node.unclosed ? "" : ")");
  264. }
  265. return value;
  266. }
  267. function stringify$1(nodes, custom) {
  268. var result, i;
  269. if (Array.isArray(nodes)) {
  270. result = "";
  271. for (i = nodes.length - 1; ~i; i -= 1) result = stringifyNode(nodes[i], custom) + result;
  272. return result;
  273. }
  274. return stringifyNode(nodes, custom);
  275. }
  276. module.exports = stringify$1;
  277. }) });
  278. //#endregion
  279. //#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/unit.js
  280. var require_unit = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/unit.js": ((exports, module) => {
  281. var minus = "-".charCodeAt(0);
  282. var plus = "+".charCodeAt(0);
  283. var dot = ".".charCodeAt(0);
  284. var exp = "e".charCodeAt(0);
  285. var EXP = "E".charCodeAt(0);
  286. function likeNumber(value) {
  287. var code = value.charCodeAt(0);
  288. var nextCode;
  289. if (code === plus || code === minus) {
  290. nextCode = value.charCodeAt(1);
  291. if (nextCode >= 48 && nextCode <= 57) return true;
  292. var nextNextCode = value.charCodeAt(2);
  293. if (nextCode === dot && nextNextCode >= 48 && nextNextCode <= 57) return true;
  294. return false;
  295. }
  296. if (code === dot) {
  297. nextCode = value.charCodeAt(1);
  298. if (nextCode >= 48 && nextCode <= 57) return true;
  299. return false;
  300. }
  301. if (code >= 48 && code <= 57) return true;
  302. return false;
  303. }
  304. module.exports = function(value) {
  305. var pos = 0;
  306. var length = value.length;
  307. var code;
  308. var nextCode;
  309. var nextNextCode;
  310. if (length === 0 || !likeNumber(value)) return false;
  311. code = value.charCodeAt(pos);
  312. if (code === plus || code === minus) pos++;
  313. while (pos < length) {
  314. code = value.charCodeAt(pos);
  315. if (code < 48 || code > 57) break;
  316. pos += 1;
  317. }
  318. code = value.charCodeAt(pos);
  319. nextCode = value.charCodeAt(pos + 1);
  320. if (code === dot && nextCode >= 48 && nextCode <= 57) {
  321. pos += 2;
  322. while (pos < length) {
  323. code = value.charCodeAt(pos);
  324. if (code < 48 || code > 57) break;
  325. pos += 1;
  326. }
  327. }
  328. code = value.charCodeAt(pos);
  329. nextCode = value.charCodeAt(pos + 1);
  330. nextNextCode = value.charCodeAt(pos + 2);
  331. if ((code === exp || code === EXP) && (nextCode >= 48 && nextCode <= 57 || (nextCode === plus || nextCode === minus) && nextNextCode >= 48 && nextNextCode <= 57)) {
  332. pos += nextCode === plus || nextCode === minus ? 3 : 2;
  333. while (pos < length) {
  334. code = value.charCodeAt(pos);
  335. if (code < 48 || code > 57) break;
  336. pos += 1;
  337. }
  338. }
  339. return {
  340. number: value.slice(0, pos),
  341. unit: value.slice(pos)
  342. };
  343. };
  344. }) });
  345. //#endregion
  346. //#region ../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/index.js
  347. var require_lib = /* @__PURE__ */ __commonJS({ "../../node_modules/.pnpm/postcss-value-parser@4.2.0/node_modules/postcss-value-parser/lib/index.js": ((exports, module) => {
  348. var parse = require_parse();
  349. var walk = require_walk();
  350. var stringify = require_stringify();
  351. function ValueParser(value) {
  352. if (this instanceof ValueParser) {
  353. this.nodes = parse(value);
  354. return this;
  355. }
  356. return new ValueParser(value);
  357. }
  358. ValueParser.prototype.toString = function() {
  359. return Array.isArray(this.nodes) ? stringify(this.nodes) : "";
  360. };
  361. ValueParser.prototype.walk = function(cb, bubble) {
  362. walk(this.nodes, cb, bubble);
  363. return this;
  364. };
  365. ValueParser.unit = require_unit();
  366. ValueParser.walk = walk;
  367. ValueParser.stringify = stringify;
  368. module.exports = ValueParser;
  369. }) });
  370. //#endregion
  371. export { require_lib };