仲裁视频会议H5

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. 'use strict';
  2. const valueParser = require('postcss-value-parser');
  3. const mappings = require('./lib/map.js');
  4. /**
  5. * @param {string} value
  6. * @return {string}
  7. */
  8. function transform(value) {
  9. const { nodes } = valueParser(value);
  10. if (nodes.length === 1) {
  11. return value;
  12. }
  13. const values = nodes
  14. .filter((list, index) => index % 2 === 0)
  15. .filter((node) => node.type === 'word')
  16. .map((n) => n.value.toLowerCase());
  17. if (values.length === 0) {
  18. return value;
  19. }
  20. const match = mappings.get(values.toString());
  21. if (!match) {
  22. return value;
  23. }
  24. return match;
  25. }
  26. /**
  27. * @type {import('postcss').PluginCreator<void>}
  28. * @return {import('postcss').Plugin}
  29. */
  30. function pluginCreator() {
  31. return {
  32. postcssPlugin: 'postcss-normalize-display-values',
  33. prepare() {
  34. const cache = new Map();
  35. return {
  36. OnceExit(css) {
  37. css.walkDecls(/^display$/i, (decl) => {
  38. const value = decl.value;
  39. if (!value) {
  40. return;
  41. }
  42. if (cache.has(value)) {
  43. decl.value = cache.get(value);
  44. return;
  45. }
  46. const result = transform(value);
  47. decl.value = result;
  48. cache.set(value, result);
  49. });
  50. },
  51. };
  52. },
  53. };
  54. }
  55. pluginCreator.postcss = true;
  56. module.exports = pluginCreator;