Dashboard sipadu mbip
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

cache.cjs.prod.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. "use strict";
  2. function _interopDefault(ex) {
  3. return ex && "object" == typeof ex && "default" in ex ? ex.default : ex;
  4. }
  5. Object.defineProperty(exports, "__esModule", {
  6. value: !0
  7. });
  8. var sheet = require("@emotion/sheet"), Stylis = _interopDefault(require("@emotion/stylis")), weakMemoize = _interopDefault(require("@emotion/weak-memoize")), delimiter = "/*|*/", needle = delimiter + "}";
  9. function toSheet(block) {
  10. block && Sheet.current.insert(block + "}");
  11. }
  12. var Sheet = {
  13. current: null
  14. }, ruleSheet = function(context, content, selectors, parents, line, column, length, ns, depth, at) {
  15. switch (context) {
  16. case 1:
  17. switch (content.charCodeAt(0)) {
  18. case 64:
  19. return Sheet.current.insert(content + ";"), "";
  20. case 108:
  21. if (98 === content.charCodeAt(2)) return "";
  22. }
  23. break;
  24. case 2:
  25. if (0 === ns) return content + delimiter;
  26. break;
  27. case 3:
  28. switch (ns) {
  29. case 102:
  30. case 112:
  31. return Sheet.current.insert(selectors[0] + content), "";
  32. default:
  33. return content + (0 === at ? delimiter : "");
  34. }
  35. case -2:
  36. content.split(needle).forEach(toSheet);
  37. }
  38. }, removeLabel = function(context, content) {
  39. if (1 === context && 108 === content.charCodeAt(0) && 98 === content.charCodeAt(2)) return "";
  40. }, isBrowser = "undefined" != typeof document, rootServerStylisCache = {}, getServerStylisCache = isBrowser ? void 0 : weakMemoize(function() {
  41. var getCache = weakMemoize(function() {
  42. return {};
  43. }), prefixTrueCache = {}, prefixFalseCache = {};
  44. return function(prefix) {
  45. return void 0 === prefix || !0 === prefix ? prefixTrueCache : !1 === prefix ? prefixFalseCache : getCache(prefix);
  46. };
  47. }), createCache = function(options) {
  48. void 0 === options && (options = {});
  49. var stylisOptions, key = options.key || "css";
  50. void 0 !== options.prefix && (stylisOptions = {
  51. prefix: options.prefix
  52. });
  53. var container, _insert, stylis = new Stylis(stylisOptions), inserted = {};
  54. if (isBrowser) {
  55. container = options.container || document.head;
  56. var nodes = document.querySelectorAll("style[data-emotion-" + key + "]");
  57. Array.prototype.forEach.call(nodes, function(node) {
  58. node.getAttribute("data-emotion-" + key).split(" ").forEach(function(id) {
  59. inserted[id] = !0;
  60. }), node.parentNode !== container && container.appendChild(node);
  61. });
  62. }
  63. if (isBrowser) stylis.use(options.stylisPlugins)(ruleSheet), _insert = function(selector, serialized, sheet, shouldCache) {
  64. var name = serialized.name;
  65. Sheet.current = sheet, stylis(selector, serialized.styles), shouldCache && (cache.inserted[name] = !0);
  66. }; else {
  67. stylis.use(removeLabel);
  68. var serverStylisCache = rootServerStylisCache;
  69. (options.stylisPlugins || void 0 !== options.prefix) && (stylis.use(options.stylisPlugins),
  70. serverStylisCache = getServerStylisCache(options.stylisPlugins || rootServerStylisCache)(options.prefix));
  71. _insert = function(selector, serialized, sheet, shouldCache) {
  72. var name = serialized.name, rules = function(selector, serialized) {
  73. var name = serialized.name;
  74. return void 0 === serverStylisCache[name] && (serverStylisCache[name] = stylis(selector, serialized.styles)),
  75. serverStylisCache[name];
  76. }(selector, serialized);
  77. return void 0 === cache.compat ? (shouldCache && (cache.inserted[name] = !0), rules) : shouldCache ? void (cache.inserted[name] = rules) : rules;
  78. };
  79. }
  80. var cache = {
  81. key: key,
  82. sheet: new sheet.StyleSheet({
  83. key: key,
  84. container: container,
  85. nonce: options.nonce,
  86. speedy: options.speedy
  87. }),
  88. nonce: options.nonce,
  89. inserted: inserted,
  90. registered: {},
  91. insert: _insert
  92. };
  93. return cache;
  94. };
  95. exports.default = createCache;