@byteluck-fe/model-driven-engine 5.5.0-1-beta2 → 5.5.0-1-beta4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,6 +38,7 @@ function _define_property(obj, key, value) {
38
38
  }
39
39
  import postcss from 'postcss';
40
40
  import prefixSelector from 'postcss-prefix-selector';
41
+ import postcssNested from 'postcss-nested';
41
42
  export var StylePlugin = /*#__PURE__*/ function() {
42
43
  "use strict";
43
44
  function StylePlugin(config) {
@@ -53,7 +54,7 @@ export var StylePlugin = /*#__PURE__*/ function() {
53
54
  {
54
55
  key: "apply",
55
56
  value: function apply(engine) {
56
- var _this_config, _this_engine;
57
+ var _this_config;
57
58
  this.engine = engine;
58
59
  var _this_config_source;
59
60
  var compiledStyle = (_this_config_source = (_this_config = this.config) === null || _this_config === void 0 ? void 0 : _this_config.source) !== null && _this_config_source !== void 0 ? _this_config_source : '';
@@ -61,11 +62,23 @@ export var StylePlugin = /*#__PURE__*/ function() {
61
62
  style.className = 'edit-css-' + engine.id;
62
63
  var dom = document.querySelector('head');
63
64
  dom === null || dom === void 0 ? void 0 : dom.appendChild(style);
64
- var cssStyleText = postcss([
65
- prefixSelector({
66
- prefix: ".render-engine-".concat((_this_engine = this.engine) === null || _this_engine === void 0 ? void 0 : _this_engine.id)
67
- })
68
- ]).process(compiledStyle).css;
65
+ var plugins = [
66
+ postcssNested()
67
+ ];
68
+ if (this.isPc) {
69
+ var _this_engine;
70
+ plugins.push(prefixSelector({
71
+ prefix: ".render-engine-".concat((_this_engine = this.engine) === null || _this_engine === void 0 ? void 0 : _this_engine.id),
72
+ // 明确将前缀通过空格连接到每个选择器,避免重复前缀
73
+ transform: function transform(prefix, selector) {
74
+ if (selector.startsWith(prefix)) return selector;
75
+ return "".concat(prefix, " ").concat(selector);
76
+ }
77
+ }));
78
+ }
79
+ var cssStyleText = postcss(plugins).process(compiledStyle, {
80
+ from: undefined
81
+ }).css;
69
82
  style.appendChild(document.createTextNode(cssStyleText));
70
83
  }
71
84
  }