Greasy Fork镜像 支持简体中文。

dirty-json

A bundle of dirty-json in browser environment

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/438040/1005176/dirty-json.js

  1. (() => {
  2. var __webpack_modules__ = {
  3. 29: (module, __unused_webpack_exports, __webpack_require__) => {
  4. "use strict";
  5. let parser = __webpack_require__(121);
  6. module.exports.parse = parse;
  7. function parse(text, config) {
  8. let fallback = true;
  9. let duplicateKeys = false;
  10. if (config) {
  11. if ("fallback" in config && config[fallback] === false) {
  12. fallback = false;
  13. }
  14. duplicateKeys =
  15. "duplicateKeys" in config && config["duplicateKeys"] === true;
  16. }
  17. try {
  18. return parser.parse(text, duplicateKeys);
  19. } catch (e) {
  20. if (fallback === false) {
  21. throw e;
  22. }
  23. try {
  24. let json = JSON.parse(text);
  25. console.warn(
  26. "dirty-json got valid JSON that failed with the custom parser. We're returning the valid JSON, but please file a bug report here: https://github.com/RyanMarcus/dirty-json/issues -- the JSON that caused the failure was: " +
  27. text
  28. );
  29. return json;
  30. } catch (json_error) {
  31. throw e;
  32. }
  33. }
  34. }
  35. },
  36. 113: (module, __unused_webpack_exports, __webpack_require__) => {
  37. "use strict";
  38. const Lexer = __webpack_require__(885);
  39. const unescapeJs = __webpack_require__(840);
  40. const utf8 = __webpack_require__(458);
  41. const LEX_KV = 0;
  42. const LEX_KVLIST = 1;
  43. const LEX_VLIST = 2;
  44. const LEX_BOOLEAN = 3;
  45. const LEX_COVALUE = 4;
  46. const LEX_CVALUE = 5;
  47. const LEX_FLOAT = 6;
  48. const LEX_INT = 7;
  49. const LEX_KEY = 8;
  50. const LEX_LIST = 9;
  51. const LEX_OBJ = 10;
  52. const LEX_QUOTE = 11;
  53. const LEX_RB = 12;
  54. const LEX_RCB = 13;
  55. const LEX_TOKEN = 14;
  56. const LEX_VALUE = 15;
  57. const LEX_COLON = -1;
  58. const LEX_COMMA = -2;
  59. const LEX_LCB = -3;
  60. const LEX_LB = -4;
  61. const LEX_DOT = -5;
  62. const lexMap = {
  63. ":": {
  64. type: LEX_COLON,
  65. },
  66. ",": {
  67. type: LEX_COMMA,
  68. },
  69. "{": {
  70. type: LEX_LCB,
  71. },
  72. "}": {
  73. type: LEX_RCB,
  74. },
  75. "[": {
  76. type: LEX_LB,
  77. },
  78. "]": {
  79. type: LEX_RB,
  80. },
  81. ".": {
  82. type: LEX_DOT,
  83. },
  84. };
  85. const lexSpc = [
  86. [/\s*:\s*/, LEX_COLON],
  87. [/\s*,\s*/, LEX_COMMA],
  88. [/\s*{\s*/, LEX_LCB],
  89. [/\s*}\s*/, LEX_RCB],
  90. [/\s*\[\s*/, LEX_LB],
  91. [/\s*\]\s*/, LEX_RB],
  92. [/\s*\.\s*/, LEX_DOT],
  93. ];
  94. function parseString(str) {
  95. str = str.replace(/\\\//, "/");
  96. return unescapeJs(str);
  97. }
  98. function getLexer(string) {
  99. let lexer = new Lexer();
  100. let col = 0;
  101. let row = 0;
  102. lexer.addRule(/"((?:\\.|[^"])*?)($|")/, (lexeme, txt) => {
  103. col += lexeme.length;
  104. return {
  105. type: LEX_QUOTE,
  106. value: parseString(txt),
  107. row: row,
  108. col: col,
  109. single: false,
  110. };
  111. });
  112. lexer.addRule(/'((?:\\.|[^'])*?)($|'|(",?[ \t]*\n))/, (lexeme, txt) => {
  113. col += lexeme.length;
  114. return {
  115. type: LEX_QUOTE,
  116. value: parseString(txt),
  117. row: row,
  118. col: col,
  119. single: true,
  120. };
  121. });
  122. lexer.addRule(
  123. /[\-0-9]*\.[0-9]*([eE][\+\-]?)?[0-9]*(?:\s*)/,
  124. (lexeme) => {
  125. col += lexeme.length;
  126. return {
  127. type: LEX_FLOAT,
  128. value: parseFloat(lexeme),
  129. row: row,
  130. col: col,
  131. };
  132. }
  133. );
  134. lexer.addRule(/\-?[0-9]+([eE][\+\-]?)[0-9]*(?:\s*)/, (lexeme) => {
  135. col += lexeme.length;
  136. return {
  137. type: LEX_FLOAT,
  138. value: parseFloat(lexeme),
  139. row: row,
  140. col: col,
  141. };
  142. });
  143. lexer.addRule(/\-?[0-9]+(?:\s*)/, (lexeme) => {
  144. col += lexeme.length;
  145. return {
  146. type: LEX_INT,
  147. value: parseInt(lexeme),
  148. row: row,
  149. col: col,
  150. };
  151. });
  152. lexSpc.forEach((item) => {
  153. lexer.addRule(item[0], (lexeme) => {
  154. col += lexeme.length;
  155. return {
  156. type: item[1],
  157. value: lexeme,
  158. row: row,
  159. col: col,
  160. };
  161. });
  162. });
  163. lexer.addRule(/\s/, (lexeme) => {
  164. if (lexeme == "\n") {
  165. col = 0;
  166. row++;
  167. } else {
  168. col += lexeme.length;
  169. }
  170. });
  171. lexer.addRule(/\S[ \t]*/, (lexeme) => {
  172. col += lexeme.length;
  173. let lt = LEX_TOKEN;
  174. let val = lexeme;
  175. return {
  176. type: lt,
  177. value: val,
  178. row: row,
  179. col: col,
  180. };
  181. });
  182. lexer.setInput(string);
  183. return lexer;
  184. }
  185. module.exports.lexString = lexString;
  186. function lexString(str, emit) {
  187. let lex = getLexer(str);
  188. let token = "";
  189. while ((token = lex.lex())) {
  190. emit(token);
  191. }
  192. }
  193. module.exports.getAllTokens = getAllTokens;
  194. function getAllTokens(str) {
  195. let arr = [];
  196. let emit = function (i) {
  197. arr.push(i);
  198. };
  199. lexString(str, emit);
  200. return arr;
  201. }
  202. },
  203. 121: (module, __unused_webpack_exports, __webpack_require__) => {
  204. "use strict";
  205. let lexer = __webpack_require__(113);
  206. const LEX_KV = 0;
  207. const LEX_KVLIST = 1;
  208. const LEX_VLIST = 2;
  209. const LEX_BOOLEAN = 3;
  210. const LEX_COVALUE = 4;
  211. const LEX_CVALUE = 5;
  212. const LEX_FLOAT = 6;
  213. const LEX_INT = 7;
  214. const LEX_KEY = 8;
  215. const LEX_LIST = 9;
  216. const LEX_OBJ = 10;
  217. const LEX_QUOTE = 11;
  218. const LEX_RB = 12;
  219. const LEX_RCB = 13;
  220. const LEX_TOKEN = 14;
  221. const LEX_VALUE = 15;
  222. const LEX_COLON = -1;
  223. const LEX_COMMA = -2;
  224. const LEX_LCB = -3;
  225. const LEX_LB = -4;
  226. const LEX_DOT = null && -5;
  227. function extendArray(arr) {
  228. if (arr.peek == null) {
  229. Object.defineProperty(arr, "peek", {
  230. enumerable: false,
  231. value: function () {
  232. return this[this.length - 1];
  233. },
  234. });
  235. }
  236. if (arr.last == null) {
  237. Object.defineProperty(arr, "last", {
  238. enumerable: false,
  239. value: function (i) {
  240. return this[this.length - (1 + i)];
  241. },
  242. });
  243. }
  244. }
  245. function is(obj, prop) {
  246. return obj && obj.hasOwnProperty("type") && obj.type == prop;
  247. }
  248. function log(str) {}
  249. module.exports.parse = parse;
  250. function parse(text, dupKeys) {
  251. let stack = [];
  252. let tokens = [];
  253. extendArray(stack);
  254. extendArray(tokens);
  255. let emit = function (t) {
  256. tokens.push(t);
  257. };
  258. lexer.lexString(text, emit);
  259. if (tokens[0].type == LEX_LB && tokens.last(0).type != LEX_RB) {
  260. tokens.push({
  261. type: LEX_RB,
  262. value: "]",
  263. row: -1,
  264. col: -1,
  265. });
  266. }
  267. if (tokens[0].type == LEX_LCB && tokens.last(0).type != LEX_RCB) {
  268. tokens.push({
  269. type: LEX_RCB,
  270. value: "}",
  271. row: -1,
  272. col: -1,
  273. });
  274. }
  275. for (let i = 0; i < tokens.length; i++) {
  276. log("Shifting " + tokens[i].type);
  277. stack.push(tokens[i]);
  278. log(stack);
  279. log("Reducing...");
  280. while (reduce(stack)) {
  281. log(stack);
  282. log("Reducing...");
  283. }
  284. }
  285. if (stack.length == 1 && stack[0].type == LEX_KVLIST) {
  286. log("Pre-compile error fix 1");
  287. stack = [
  288. {
  289. type: LEX_OBJ,
  290. value: stack[0].value,
  291. },
  292. ];
  293. }
  294. return compileOST(stack[0], dupKeys);
  295. }
  296. function reduce(stack) {
  297. let next = stack.pop();
  298. switch (next.type) {
  299. case LEX_KEY:
  300. if (next.value.trim() == "true") {
  301. log("Rule 5");
  302. stack.push({
  303. type: LEX_BOOLEAN,
  304. value: "true",
  305. });
  306. return true;
  307. }
  308. if (next.value.trim() == "false") {
  309. log("Rule 6");
  310. stack.push({
  311. type: LEX_BOOLEAN,
  312. value: "false",
  313. });
  314. return true;
  315. }
  316. if (next.value.trim() == "null") {
  317. log("Rule 7");
  318. stack.push({
  319. type: LEX_VALUE,
  320. value: null,
  321. });
  322. return true;
  323. }
  324. break;
  325.  
  326. case LEX_TOKEN:
  327. if (is(stack.peek(), LEX_KEY)) {
  328. log("Rule 11a");
  329. stack.peek().value += next.value;
  330. return true;
  331. }
  332. log("Rule 11c");
  333. stack.push({
  334. type: LEX_KEY,
  335. value: next.value,
  336. });
  337. return true;
  338.  
  339. case LEX_INT:
  340. if (is(next, LEX_INT) && is(stack.peek(), LEX_KEY)) {
  341. log("Rule 11b");
  342. stack.peek().value += next.value;
  343. return true;
  344. }
  345. log("Rule 11f");
  346. next.type = LEX_VALUE;
  347. stack.push(next);
  348. return true;
  349.  
  350. case LEX_QUOTE:
  351. log("Rule 11d");
  352. next.type = LEX_VALUE;
  353. next.value = next.value;
  354. stack.push(next);
  355. return true;
  356.  
  357. case LEX_BOOLEAN:
  358. log("Rule 11e");
  359. next.type = LEX_VALUE;
  360. if (next.value == "true") {
  361. next.value = true;
  362. } else {
  363. next.value = false;
  364. }
  365. stack.push(next);
  366. return true;
  367.  
  368. case LEX_FLOAT:
  369. log("Rule 11g");
  370. next.type = LEX_VALUE;
  371. stack.push(next);
  372. return true;
  373.  
  374. case LEX_VALUE:
  375. if (is(stack.peek(), LEX_COMMA)) {
  376. log("Rule 12");
  377. next.type = LEX_CVALUE;
  378. stack.pop();
  379. stack.push(next);
  380. return true;
  381. }
  382. if (is(stack.peek(), LEX_COLON)) {
  383. log("Rule 13");
  384. next.type = LEX_COVALUE;
  385. stack.pop();
  386. stack.push(next);
  387. return true;
  388. }
  389. if (is(stack.peek(), LEX_KEY) && is(stack.last(1), LEX_VALUE)) {
  390. log("Error rule 1");
  391. let middleVal = stack.pop();
  392. stack.peek().value += '"' + middleVal.value + '"';
  393. stack.peek().value += next.value;
  394. return true;
  395. }
  396. if (is(stack.peek(), LEX_KEY) && is(stack.last(1), LEX_VLIST)) {
  397. log("Error rule 2");
  398. let middleVal = stack.pop();
  399. let oldLastVal = stack.peek().value.pop();
  400. oldLastVal += '"' + middleVal.value + '"';
  401. oldLastVal += next.value;
  402. stack.peek().value.push(oldLastVal);
  403. return true;
  404. }
  405. if (is(stack.peek(), LEX_KEY) && is(stack.last(1), LEX_KVLIST)) {
  406. log("Error rule 3");
  407. let middleVal = stack.pop();
  408. let oldLastVal = stack.peek().value.pop();
  409. const qChar = next.single ? "'" : '"';
  410. oldLastVal.value += qChar + middleVal.value + qChar;
  411. oldLastVal.value += next.value;
  412. stack.peek().value.push(oldLastVal);
  413. return true;
  414. }
  415. if (is(stack.peek(), LEX_KEY)) {
  416. log("Error rule 4");
  417. let keyValue = stack.pop().value;
  418. next.value = keyValue + next.value;
  419. stack.push(next);
  420. return true;
  421. }
  422. break;
  423.  
  424. case LEX_LIST:
  425. if (is(next, LEX_LIST) && is(stack.peek(), LEX_COMMA)) {
  426. log("Rule 12a");
  427. next.type = LEX_CVALUE;
  428. stack.pop();
  429. stack.push(next);
  430. return true;
  431. }
  432. if (is(stack.peek(), LEX_COLON)) {
  433. log("Rule 13a");
  434. next.type = LEX_COVALUE;
  435. stack.pop();
  436. stack.push(next);
  437. return true;
  438. }
  439. break;
  440.  
  441. case LEX_OBJ:
  442. if (is(stack.peek(), LEX_COMMA)) {
  443. log("Rule 12b");
  444. let toPush = {
  445. type: LEX_CVALUE,
  446. value: next,
  447. };
  448. stack.pop();
  449. stack.push(toPush);
  450. return true;
  451. }
  452. if (is(stack.peek(), LEX_COLON)) {
  453. log("Rule 13b");
  454. let toPush = {
  455. type: LEX_COVALUE,
  456. value: next,
  457. };
  458. stack.pop();
  459. stack.push(toPush);
  460. return true;
  461. }
  462. if (is(stack.peek(), LEX_KEY)) {
  463. log("Error rule 9");
  464. let key = stack.pop();
  465. stack.push({
  466. type: LEX_KV,
  467. key: key.value.trim(),
  468. value: next,
  469. });
  470. return true;
  471. }
  472. break;
  473.  
  474. case LEX_CVALUE:
  475. if (is(stack.peek(), LEX_VLIST)) {
  476. log("Rule 14");
  477. stack.peek().value.push(next.value);
  478. return true;
  479. }
  480. log("Rule 15");
  481. stack.push({
  482. type: LEX_VLIST,
  483. value: [next.value],
  484. });
  485. return true;
  486.  
  487. case LEX_VLIST:
  488. if (is(stack.peek(), LEX_VALUE)) {
  489. log("Rule 15a");
  490. next.value.unshift(stack.peek().value);
  491. stack.pop();
  492. stack.push(next);
  493. return true;
  494. }
  495. if (is(stack.peek(), LEX_LIST)) {
  496. log("Rule 15b");
  497. next.value.unshift(stack.peek().value);
  498. stack.pop();
  499. stack.push(next);
  500. return true;
  501. }
  502. if (is(stack.peek(), LEX_OBJ)) {
  503. log("Rule 15c");
  504. next.value.unshift(stack.peek());
  505. stack.pop();
  506. stack.push(next);
  507. return true;
  508. }
  509. if (is(stack.peek(), LEX_KEY) && (stack.last(1), LEX_COMMA)) {
  510. log("Error rule 7");
  511. let l = stack.pop();
  512. stack.push({
  513. type: LEX_VALUE,
  514. value: l.value,
  515. });
  516. log("Start subreduce... (" + l.value + ")");
  517. while (reduce(stack));
  518. log("End subreduce");
  519. stack.push(next);
  520. return true;
  521. }
  522. if (is(stack.peek(), LEX_VLIST)) {
  523. log("Error rule 8");
  524. stack.peek().value.push(next.value[0]);
  525. return true;
  526. }
  527. break;
  528.  
  529. case LEX_COVALUE:
  530. if (
  531. is(stack.peek(), LEX_KEY) ||
  532. is(stack.peek(), LEX_VALUE) ||
  533. is(stack.peek(), LEX_VLIST)
  534. ) {
  535. log("Rule 16");
  536. let key = stack.pop();
  537. stack.push({
  538. type: LEX_KV,
  539. key: key.value,
  540. value: next.value,
  541. });
  542. return true;
  543. }
  544. throw new Error(
  545. "Got a :value that can't be handled at line " +
  546. next.row +
  547. ":" +
  548. next.col
  549. );
  550.  
  551. case LEX_KV:
  552. if (is(stack.last(0), LEX_COMMA) && is(stack.last(1), LEX_KVLIST)) {
  553. log("Rule 17");
  554. stack.last(1).value.push(next);
  555. stack.pop();
  556. return true;
  557. }
  558. log("Rule 18");
  559. stack.push({
  560. type: LEX_KVLIST,
  561. value: [next],
  562. });
  563. return true;
  564.  
  565. case LEX_KVLIST:
  566. if (is(stack.peek(), LEX_KVLIST)) {
  567. log("Rule 17a");
  568. next.value.forEach(function (i) {
  569. stack.peek().value.push(i);
  570. });
  571. return true;
  572. }
  573. break;
  574.  
  575. case LEX_RB:
  576. if (is(stack.peek(), LEX_VLIST) && is(stack.last(1), LEX_LB)) {
  577. log("Rule 19");
  578. let l = stack.pop();
  579. stack.pop();
  580. stack.push({
  581. type: LEX_LIST,
  582. value: l.value,
  583. });
  584. return true;
  585. }
  586. if (is(stack.peek(), LEX_LIST) && is(stack.last(1), LEX_LB)) {
  587. log("Rule 19b");
  588. let l = stack.pop();
  589. stack.pop();
  590. stack.push({
  591. type: LEX_LIST,
  592. value: [l.value],
  593. });
  594. return true;
  595. }
  596. if (is(stack.peek(), LEX_LB)) {
  597. log("Rule 22");
  598. stack.pop();
  599. stack.push({
  600. type: LEX_LIST,
  601. value: [],
  602. });
  603. return true;
  604. }
  605. if (is(stack.peek(), LEX_VALUE) && is(stack.last(1), LEX_LB)) {
  606. log("Rule 23");
  607. let val = stack.pop().value;
  608. stack.pop();
  609. stack.push({
  610. type: LEX_LIST,
  611. value: [val],
  612. });
  613. return true;
  614. }
  615. if (is(stack.peek(), LEX_OBJ) && is(stack.last(1), LEX_LB)) {
  616. log("Rule 23b");
  617. let val = stack.pop();
  618. stack.pop();
  619. stack.push({
  620. type: LEX_LIST,
  621. value: [val],
  622. });
  623. return true;
  624. }
  625. if (is(stack.peek(), LEX_KEY) && is(stack.last(1), LEX_COMMA)) {
  626. log("Error rule 5");
  627. let l = stack.pop();
  628. stack.push({
  629. type: LEX_VALUE,
  630. value: l.value,
  631. });
  632. log("Start subreduce... (" + l.value + ")");
  633. while (reduce(stack));
  634. log("End subreduce");
  635. stack.push({
  636. type: LEX_RB,
  637. });
  638. return true;
  639. }
  640. if (
  641. is(stack.peek(), LEX_COMMA) &&
  642. (is(stack.last(1), LEX_KEY) ||
  643. is(stack.last(1), LEX_OBJ) ||
  644. is(stack.last(1), LEX_VALUE))
  645. ) {
  646. log("Error rule 5a");
  647. stack.pop();
  648. stack.push({
  649. type: LEX_RB,
  650. value: "]",
  651. });
  652. log("Start subreduce...");
  653. log("Content: " + JSON.stringify(stack));
  654. while (reduce(stack));
  655. log("End subreduce");
  656. return true;
  657. }
  658. if (is(stack.peek(), LEX_KEY) && is(stack.last(1), LEX_LB)) {
  659. log("Error rule 5b");
  660. let v = stack.pop();
  661. stack.pop();
  662. stack.push({
  663. type: LEX_LIST,
  664. value: [v.value],
  665. });
  666. return true;
  667. }
  668. if (is(stack.peek(), LEX_COMMA) && is(stack.last(1), LEX_VLIST)) {
  669. log("Error rule 5c");
  670. stack.pop();
  671. stack.push({
  672. type: LEX_RB,
  673. });
  674. log("Start subreduce...");
  675. log("Content: " + JSON.stringify(stack));
  676. while (reduce(stack));
  677. log("End subreduce");
  678. return true;
  679. }
  680. break;
  681.  
  682. case LEX_RCB:
  683. if (is(stack.peek(), LEX_KVLIST) && is(stack.last(1), LEX_LCB)) {
  684. log("Rule 20");
  685. let l = stack.pop();
  686. stack.pop();
  687. stack.push({
  688. type: LEX_OBJ,
  689. value: l.value,
  690. });
  691. return true;
  692. }
  693. if (is(stack.peek(), LEX_LCB)) {
  694. log("Rule 21");
  695. stack.pop();
  696. stack.push({
  697. type: LEX_OBJ,
  698. value: null,
  699. });
  700. return true;
  701. }
  702. if (is(stack.peek(), LEX_KEY) && is(stack.last(1), LEX_COLON)) {
  703. log("Error rule 4a");
  704. let l = stack.pop();
  705. stack.push({
  706. type: LEX_VALUE,
  707. value: l.value,
  708. });
  709. log("Start subreduce... (" + l.value + ")");
  710. while (reduce(stack));
  711. log("End subreduce");
  712. stack.push({
  713. type: LEX_RCB,
  714. });
  715. return true;
  716. }
  717. if (is(stack.peek(), LEX_COLON)) {
  718. log("Error rule 4b");
  719. stack.push({
  720. type: LEX_VALUE,
  721. value: null,
  722. });
  723. log("Starting subreduce...");
  724. while (reduce(stack));
  725. log("End subreduce.");
  726. stack.push({
  727. type: LEX_RCB,
  728. });
  729. return true;
  730. }
  731. if (is(stack.peek(), LEX_COMMA)) {
  732. log("Error rule 10a");
  733. stack.pop();
  734. stack.push({
  735. type: LEX_RCB,
  736. });
  737. return true;
  738. }
  739. throw new Error(
  740. "Found } that I can't handle at line " + next.row + ":" + next.col
  741. );
  742.  
  743. case LEX_COMMA:
  744. if (is(stack.peek(), LEX_COMMA)) {
  745. log("Comma error rule 1");
  746. return true;
  747. }
  748. if (is(stack.peek(), LEX_KEY)) {
  749. log("Comma error rule 2");
  750. const key = stack.pop();
  751. stack.push({
  752. type: LEX_VALUE,
  753. value: key.value,
  754. });
  755. log("Starting subreduce...");
  756. while (reduce(stack));
  757. log("End subreduce.");
  758. stack.push(next);
  759. return true;
  760. }
  761. if (is(stack.peek(), LEX_COLON)) {
  762. log("Comma error rule 3");
  763. stack.push({
  764. type: LEX_VALUE,
  765. value: null,
  766. });
  767. log("Starting subreduce...");
  768. while (reduce(stack));
  769. log("End subreduce.");
  770. stack.push(next);
  771. return true;
  772. }
  773. }
  774. stack.push(next);
  775. return false;
  776. }
  777. function compileOST(tree, dupKeys) {
  778. let rawTypes = ["boolean", "number", "string"];
  779. if (rawTypes.indexOf(typeof tree) != -1) return tree;
  780. if (tree === null) return null;
  781. if (Array.isArray(tree)) {
  782. let toR = [];
  783. while (tree.length > 0) toR.unshift(compileOST(tree.pop()));
  784. return toR;
  785. }
  786. if (is(tree, LEX_OBJ)) {
  787. let toR = {};
  788. if (tree.value === null) return {};
  789. tree.value.forEach(function (i) {
  790. const key = i.key;
  791. const val = compileOST(i.value);
  792. if (dupKeys && key in toR) {
  793. toR[key] = {
  794. value: toR[key],
  795. next: val,
  796. };
  797. } else {
  798. toR[key] = val;
  799. }
  800. });
  801. return toR;
  802. }
  803. if (is(tree, LEX_LIST)) {
  804. return compileOST(tree.value);
  805. }
  806. return tree.value;
  807. }
  808. },
  809. 885: (module) => {
  810. if (true && typeof module.exports === "object") module.exports = Lexer;
  811. Lexer.defunct = function (chr) {
  812. throw new Error(
  813. "Unexpected character at index " + (this.index - 1) + ": " + chr
  814. );
  815. };
  816. function Lexer(defunct) {
  817. if (typeof defunct !== "function") defunct = Lexer.defunct;
  818. var tokens = [];
  819. var rules = [];
  820. var remove = 0;
  821. this.state = 0;
  822. this.index = 0;
  823. this.input = "";
  824. this.addRule = function (pattern, action, start) {
  825. var global = pattern.global;
  826. if (!global) {
  827. var flags = "g";
  828. if (pattern.multiline) flags += "m";
  829. if (pattern.ignoreCase) flags += "i";
  830. pattern = new RegExp(pattern.source, flags);
  831. }
  832. if (Object.prototype.toString.call(start) !== "[object Array]")
  833. start = [0];
  834. rules.push({
  835. pattern: pattern,
  836. global: global,
  837. action: action,
  838. start: start,
  839. });
  840. return this;
  841. };
  842. this.setInput = function (input) {
  843. remove = 0;
  844. this.state = 0;
  845. this.index = 0;
  846. tokens.length = 0;
  847. this.input = input;
  848. return this;
  849. };
  850. this.lex = function () {
  851. if (tokens.length) return tokens.shift();
  852. this.reject = true;
  853. while (this.index <= this.input.length) {
  854. var matches = scan.call(this).splice(remove);
  855. var index = this.index;
  856. while (matches.length) {
  857. if (this.reject) {
  858. var match = matches.shift();
  859. var result = match.result;
  860. var length = match.length;
  861. this.index += length;
  862. this.reject = false;
  863. remove++;
  864. var token = match.action.apply(this, result);
  865. if (this.reject) this.index = result.index;
  866. else if (typeof token !== "undefined") {
  867. switch (Object.prototype.toString.call(token)) {
  868. case "[object Array]":
  869. tokens = token.slice(1);
  870. token = token[0];
  871.  
  872. default:
  873. if (length) remove = 0;
  874. return token;
  875. }
  876. }
  877. } else break;
  878. }
  879. var input = this.input;
  880. if (index < input.length) {
  881. if (this.reject) {
  882. remove = 0;
  883. var token = defunct.call(this, input.charAt(this.index++));
  884. if (typeof token !== "undefined") {
  885. if (
  886. Object.prototype.toString.call(token) === "[object Array]"
  887. ) {
  888. tokens = token.slice(1);
  889. return token[0];
  890. } else return token;
  891. }
  892. } else {
  893. if (this.index !== index) remove = 0;
  894. this.reject = true;
  895. }
  896. } else if (matches.length) this.reject = true;
  897. else break;
  898. }
  899. };
  900. function scan() {
  901. var matches = [];
  902. var index = 0;
  903. var state = this.state;
  904. var lastIndex = this.index;
  905. var input = this.input;
  906. for (var i = 0, length = rules.length; i < length; i++) {
  907. var rule = rules[i];
  908. var start = rule.start;
  909. var states = start.length;
  910. if (
  911. !states ||
  912. start.indexOf(state) >= 0 ||
  913. (state % 2 && states === 1 && !start[0])
  914. ) {
  915. var pattern = rule.pattern;
  916. pattern.lastIndex = lastIndex;
  917. var result = pattern.exec(input);
  918. if (result && result.index === lastIndex) {
  919. var j = matches.push({
  920. result: result,
  921. action: rule.action,
  922. length: result[0].length,
  923. });
  924. if (rule.global) index = j;
  925. while (--j > index) {
  926. var k = j - 1;
  927. if (matches[j].length > matches[k].length) {
  928. var temple = matches[j];
  929. matches[j] = matches[k];
  930. matches[k] = temple;
  931. }
  932. }
  933. }
  934. }
  935. }
  936. return matches;
  937. }
  938. }
  939. },
  940. 237: () => {
  941. if (!String.fromCodePoint) {
  942. (function () {
  943. var defineProperty = (function () {
  944. try {
  945. var object = {};
  946. var $defineProperty = Object.defineProperty;
  947. var result =
  948. $defineProperty(object, object, object) && $defineProperty;
  949. } catch (error) {}
  950. return result;
  951. })();
  952. var stringFromCharCode = String.fromCharCode;
  953. var floor = Math.floor;
  954. var fromCodePoint = function (_) {
  955. var MAX_SIZE = 16384;
  956. var codeUnits = [];
  957. var highSurrogate;
  958. var lowSurrogate;
  959. var index = -1;
  960. var length = arguments.length;
  961. if (!length) {
  962. return "";
  963. }
  964. var result = "";
  965. while (++index < length) {
  966. var codePoint = Number(arguments[index]);
  967. if (
  968. !isFinite(codePoint) ||
  969. codePoint < 0 ||
  970. codePoint > 1114111 ||
  971. floor(codePoint) != codePoint
  972. ) {
  973. throw RangeError("Invalid code point: " + codePoint);
  974. }
  975. if (codePoint <= 65535) {
  976. codeUnits.push(codePoint);
  977. } else {
  978. codePoint -= 65536;
  979. highSurrogate = (codePoint >> 10) + 55296;
  980. lowSurrogate = (codePoint % 1024) + 56320;
  981. codeUnits.push(highSurrogate, lowSurrogate);
  982. }
  983. if (index + 1 == length || codeUnits.length > MAX_SIZE) {
  984. result += stringFromCharCode.apply(null, codeUnits);
  985. codeUnits.length = 0;
  986. }
  987. }
  988. return result;
  989. };
  990. if (defineProperty) {
  991. defineProperty(String, "fromCodePoint", {
  992. value: fromCodePoint,
  993. configurable: true,
  994. writable: true,
  995. });
  996. } else {
  997. String.fromCodePoint = fromCodePoint;
  998. }
  999. })();
  1000. }
  1001. },
  1002. 840: (module, exports, __webpack_require__) => {
  1003. "use strict";
  1004. Object.defineProperty(exports, "__esModule", {
  1005. value: true,
  1006. });
  1007. exports["default"] = void 0;
  1008. __webpack_require__(237);
  1009. var jsEscapeRegex =
  1010. /\\(u\{([0-9A-Fa-f]+)\}|u([0-9A-Fa-f]{4})|x([0-9A-Fa-f]{2})|([1-7][0-7]{0,2}|[0-7]{2,3})|(['"tbrnfv0\\]))|\\U([0-9A-Fa-f]{8})/g;
  1011. var usualEscapeSequences = {
  1012. 0: "\0",
  1013. b: "\b",
  1014. f: "\f",
  1015. n: "\n",
  1016. r: "\r",
  1017. t: "\t",
  1018. v: "\v",
  1019. "'": "'",
  1020. '"': '"',
  1021. "\\": "\\",
  1022. };
  1023. var fromHex = function fromHex(str) {
  1024. return String.fromCodePoint(parseInt(str, 16));
  1025. };
  1026. var fromOct = function fromOct(str) {
  1027. return String.fromCodePoint(parseInt(str, 8));
  1028. };
  1029. var _default = function _default(string) {
  1030. return string.replace(
  1031. jsEscapeRegex,
  1032. function (
  1033. _,
  1034. __,
  1035. varHex,
  1036. longHex,
  1037. shortHex,
  1038. octal,
  1039. specialCharacter,
  1040. python
  1041. ) {
  1042. if (varHex !== undefined) {
  1043. return fromHex(varHex);
  1044. } else if (longHex !== undefined) {
  1045. return fromHex(longHex);
  1046. } else if (shortHex !== undefined) {
  1047. return fromHex(shortHex);
  1048. } else if (octal !== undefined) {
  1049. return fromOct(octal);
  1050. } else if (python !== undefined) {
  1051. return fromHex(python);
  1052. } else {
  1053. return usualEscapeSequences[specialCharacter];
  1054. }
  1055. }
  1056. );
  1057. };
  1058. exports["default"] = _default;
  1059. module.exports = exports.default;
  1060. },
  1061. 458: (__unused_webpack_module, exports) => {
  1062. (function (root) {
  1063. var stringFromCharCode = String.fromCharCode;
  1064. function ucs2decode(string) {
  1065. var output = [];
  1066. var counter = 0;
  1067. var length = string.length;
  1068. var value;
  1069. var extra;
  1070. while (counter < length) {
  1071. value = string.charCodeAt(counter++);
  1072. if (value >= 55296 && value <= 56319 && counter < length) {
  1073. extra = string.charCodeAt(counter++);
  1074. if ((extra & 64512) == 56320) {
  1075. output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
  1076. } else {
  1077. output.push(value);
  1078. counter--;
  1079. }
  1080. } else {
  1081. output.push(value);
  1082. }
  1083. }
  1084. return output;
  1085. }
  1086. function ucs2encode(array) {
  1087. var length = array.length;
  1088. var index = -1;
  1089. var value;
  1090. var output = "";
  1091. while (++index < length) {
  1092. value = array[index];
  1093. if (value > 65535) {
  1094. value -= 65536;
  1095. output += stringFromCharCode(((value >>> 10) & 1023) | 55296);
  1096. value = 56320 | (value & 1023);
  1097. }
  1098. output += stringFromCharCode(value);
  1099. }
  1100. return output;
  1101. }
  1102. function checkScalarValue(codePoint) {
  1103. if (codePoint >= 55296 && codePoint <= 57343) {
  1104. throw Error(
  1105. "Lone surrogate U+" +
  1106. codePoint.toString(16).toUpperCase() +
  1107. " is not a scalar value"
  1108. );
  1109. }
  1110. }
  1111. function createByte(codePoint, shift) {
  1112. return stringFromCharCode(((codePoint >> shift) & 63) | 128);
  1113. }
  1114. function encodeCodePoint(codePoint) {
  1115. if ((codePoint & 4294967168) == 0) {
  1116. return stringFromCharCode(codePoint);
  1117. }
  1118. var symbol = "";
  1119. if ((codePoint & 4294965248) == 0) {
  1120. symbol = stringFromCharCode(((codePoint >> 6) & 31) | 192);
  1121. } else if ((codePoint & 4294901760) == 0) {
  1122. checkScalarValue(codePoint);
  1123. symbol = stringFromCharCode(((codePoint >> 12) & 15) | 224);
  1124. symbol += createByte(codePoint, 6);
  1125. } else if ((codePoint & 4292870144) == 0) {
  1126. symbol = stringFromCharCode(((codePoint >> 18) & 7) | 240);
  1127. symbol += createByte(codePoint, 12);
  1128. symbol += createByte(codePoint, 6);
  1129. }
  1130. symbol += stringFromCharCode((codePoint & 63) | 128);
  1131. return symbol;
  1132. }
  1133. function utf8encode(string) {
  1134. var codePoints = ucs2decode(string);
  1135. var length = codePoints.length;
  1136. var index = -1;
  1137. var codePoint;
  1138. var byteString = "";
  1139. while (++index < length) {
  1140. codePoint = codePoints[index];
  1141. byteString += encodeCodePoint(codePoint);
  1142. }
  1143. return byteString;
  1144. }
  1145. function readContinuationByte() {
  1146. if (byteIndex >= byteCount) {
  1147. throw Error("Invalid byte index");
  1148. }
  1149. var continuationByte = byteArray[byteIndex] & 255;
  1150. byteIndex++;
  1151. if ((continuationByte & 192) == 128) {
  1152. return continuationByte & 63;
  1153. }
  1154. throw Error("Invalid continuation byte");
  1155. }
  1156. function decodeSymbol() {
  1157. var byte1;
  1158. var byte2;
  1159. var byte3;
  1160. var byte4;
  1161. var codePoint;
  1162. if (byteIndex > byteCount) {
  1163. throw Error("Invalid byte index");
  1164. }
  1165. if (byteIndex == byteCount) {
  1166. return false;
  1167. }
  1168. byte1 = byteArray[byteIndex] & 255;
  1169. byteIndex++;
  1170. if ((byte1 & 128) == 0) {
  1171. return byte1;
  1172. }
  1173. if ((byte1 & 224) == 192) {
  1174. byte2 = readContinuationByte();
  1175. codePoint = ((byte1 & 31) << 6) | byte2;
  1176. if (codePoint >= 128) {
  1177. return codePoint;
  1178. } else {
  1179. throw Error("Invalid continuation byte");
  1180. }
  1181. }
  1182. if ((byte1 & 240) == 224) {
  1183. byte2 = readContinuationByte();
  1184. byte3 = readContinuationByte();
  1185. codePoint = ((byte1 & 15) << 12) | (byte2 << 6) | byte3;
  1186. if (codePoint >= 2048) {
  1187. checkScalarValue(codePoint);
  1188. return codePoint;
  1189. } else {
  1190. throw Error("Invalid continuation byte");
  1191. }
  1192. }
  1193. if ((byte1 & 248) == 240) {
  1194. byte2 = readContinuationByte();
  1195. byte3 = readContinuationByte();
  1196. byte4 = readContinuationByte();
  1197. codePoint =
  1198. ((byte1 & 7) << 18) | (byte2 << 12) | (byte3 << 6) | byte4;
  1199. if (codePoint >= 65536 && codePoint <= 1114111) {
  1200. return codePoint;
  1201. }
  1202. }
  1203. throw Error("Invalid UTF-8 detected");
  1204. }
  1205. var byteArray;
  1206. var byteCount;
  1207. var byteIndex;
  1208. function utf8decode(byteString) {
  1209. byteArray = ucs2decode(byteString);
  1210. byteCount = byteArray.length;
  1211. byteIndex = 0;
  1212. var codePoints = [];
  1213. var tmp;
  1214. while ((tmp = decodeSymbol()) !== false) {
  1215. codePoints.push(tmp);
  1216. }
  1217. return ucs2encode(codePoints);
  1218. }
  1219. root.version = "3.0.0";
  1220. root.encode = utf8encode;
  1221. root.decode = utf8decode;
  1222. })(false ? 0 : exports);
  1223. },
  1224. 138: (module, __unused_webpack_exports, __webpack_require__) => {
  1225. const dJSON = __webpack_require__(29);
  1226. module.exports = {
  1227. dJSON: dJSON,
  1228. };
  1229. },
  1230. };
  1231. var __webpack_module_cache__ = {};
  1232. function __webpack_require__(moduleId) {
  1233. var cachedModule = __webpack_module_cache__[moduleId];
  1234. if (cachedModule !== undefined) {
  1235. return cachedModule.exports;
  1236. }
  1237. var module = (__webpack_module_cache__[moduleId] = {
  1238. exports: {},
  1239. });
  1240. __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  1241. return module.exports;
  1242. }
  1243. var __webpack_exports__ = __webpack_require__(138);
  1244. var __webpack_export_target__ = window;
  1245. for (var i in __webpack_exports__)
  1246. __webpack_export_target__[i] = __webpack_exports__[i];
  1247. if (__webpack_exports__.__esModule)
  1248. Object.defineProperty(__webpack_export_target__, "__esModule", {
  1249. value: true,
  1250. });
  1251. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址