global.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. "use strict";
  2. var __values = (this && this.__values) || function(o) {
  3. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  4. if (m) return m.call(o);
  5. if (o && typeof o.length === "number") return {
  6. next: function () {
  7. if (o && i >= o.length) o = void 0;
  8. return { value: o && o[i++], done: !o };
  9. }
  10. };
  11. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  12. };
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. exports.MathJax = exports.combineWithMathJax = exports.combineDefaults = exports.combineConfig = exports.isObject = void 0;
  15. var version_js_1 = require("./version.js");
  16. function isObject(x) {
  17. return typeof x === 'object' && x !== null;
  18. }
  19. exports.isObject = isObject;
  20. function combineConfig(dst, src) {
  21. var e_1, _a;
  22. try {
  23. for (var _b = __values(Object.keys(src)), _c = _b.next(); !_c.done; _c = _b.next()) {
  24. var id = _c.value;
  25. if (id === '__esModule')
  26. continue;
  27. if (isObject(dst[id]) && isObject(src[id]) &&
  28. !(src[id] instanceof Promise)) {
  29. combineConfig(dst[id], src[id]);
  30. }
  31. else if (src[id] !== null && src[id] !== undefined) {
  32. dst[id] = src[id];
  33. }
  34. }
  35. }
  36. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  37. finally {
  38. try {
  39. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  40. }
  41. finally { if (e_1) throw e_1.error; }
  42. }
  43. return dst;
  44. }
  45. exports.combineConfig = combineConfig;
  46. function combineDefaults(dst, name, src) {
  47. var e_2, _a;
  48. if (!dst[name]) {
  49. dst[name] = {};
  50. }
  51. dst = dst[name];
  52. try {
  53. for (var _b = __values(Object.keys(src)), _c = _b.next(); !_c.done; _c = _b.next()) {
  54. var id = _c.value;
  55. if (isObject(dst[id]) && isObject(src[id])) {
  56. combineDefaults(dst, id, src[id]);
  57. }
  58. else if (dst[id] == null && src[id] != null) {
  59. dst[id] = src[id];
  60. }
  61. }
  62. }
  63. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  64. finally {
  65. try {
  66. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  67. }
  68. finally { if (e_2) throw e_2.error; }
  69. }
  70. return dst;
  71. }
  72. exports.combineDefaults = combineDefaults;
  73. function combineWithMathJax(config) {
  74. return combineConfig(exports.MathJax, config);
  75. }
  76. exports.combineWithMathJax = combineWithMathJax;
  77. if (typeof global.MathJax === 'undefined') {
  78. global.MathJax = {};
  79. }
  80. if (!global.MathJax.version) {
  81. global.MathJax = {
  82. version: version_js_1.VERSION,
  83. _: {},
  84. config: global.MathJax
  85. };
  86. }
  87. exports.MathJax = global.MathJax;
  88. //# sourceMappingURL=global.js.map