wp/wp-includes/js/dist/style-engine.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
--- a/wp/wp-includes/js/dist/style-engine.js	Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/js/dist/style-engine.js	Fri Sep 05 18:52:52 2025 +0200
@@ -40,10 +40,11 @@
 // EXPORTS
 __webpack_require__.d(__webpack_exports__, {
   compileCSS: () => (/* binding */ compileCSS),
-  getCSSRules: () => (/* binding */ getCSSRules)
+  getCSSRules: () => (/* binding */ getCSSRules),
+  getCSSValueFromRawStyle: () => (/* reexport */ getCSSValueFromRawStyle)
 });
 
-;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
+;// ./node_modules/tslib/tslib.es6.mjs
 /******************************************************************************
 Copyright (c) Microsoft Corporation.
 
@@ -58,7 +59,7 @@
 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 PERFORMANCE OF THIS SOFTWARE.
 ***************************************************************************** */
-/* global Reflect, Promise, SuppressedError, Symbol */
+/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
 
 var extendStatics = function(d, b) {
   extendStatics = Object.setPrototypeOf ||
@@ -169,8 +170,8 @@
 }
 
 function __generator(thisArg, body) {
-  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
-  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
+  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
+  return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
   function verb(n) { return function (v) { return step([n, v]); }; }
   function step(op) {
       if (f) throw new TypeError("Generator is already executing.");
@@ -274,8 +275,9 @@
 function __asyncGenerator(thisArg, _arguments, generator) {
   if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
   var g = generator.apply(thisArg, _arguments || []), i, q = [];
-  return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
-  function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
+  return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
+  function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
+  function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
   function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
   function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
   function fulfill(value) { resume("next", value); }
@@ -308,10 +310,19 @@
   o["default"] = v;
 };
 
+var ownKeys = function(o) {
+  ownKeys = Object.getOwnPropertyNames || function (o) {
+    var ar = [];
+    for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
+    return ar;
+  };
+  return ownKeys(o);
+};
+
 function __importStar(mod) {
   if (mod && mod.__esModule) return mod;
   var result = {};
-  if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
+  if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
   __setModuleDefault(result, mod);
   return result;
 }
@@ -341,16 +352,18 @@
 function __addDisposableResource(env, value, async) {
   if (value !== null && value !== void 0) {
     if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
-    var dispose;
+    var dispose, inner;
     if (async) {
-        if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
-        dispose = value[Symbol.asyncDispose];
+      if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
+      dispose = value[Symbol.asyncDispose];
     }
     if (dispose === void 0) {
-        if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
-        dispose = value[Symbol.dispose];
+      if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
+      dispose = value[Symbol.dispose];
+      if (async) inner = dispose;
     }
     if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
+    if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
     env.stack.push({ value: value, dispose: dispose, async: async });
   }
   else if (async) {
@@ -369,28 +382,46 @@
     env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
     env.hasError = true;
   }
+  var r, s = 0;
   function next() {
-    while (env.stack.length) {
-      var rec = env.stack.pop();
+    while (r = env.stack.pop()) {
       try {
-        var result = rec.dispose && rec.dispose.call(rec.value);
-        if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
+        if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
+        if (r.dispose) {
+          var result = r.dispose.call(r.value);
+          if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
+        }
+        else s |= 1;
       }
       catch (e) {
-          fail(e);
+        fail(e);
       }
     }
+    if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
     if (env.hasError) throw env.error;
   }
   return next();
 }
 
+function __rewriteRelativeImportExtension(path, preserveJsx) {
+  if (typeof path === "string" && /^\.\.?\//.test(path)) {
+      return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
+          return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
+      });
+  }
+  return path;
+}
+
 /* harmony default export */ const tslib_es6 = ({
   __extends,
   __assign,
   __rest,
   __decorate,
   __param,
+  __esDecorate,
+  __runInitializers,
+  __propKey,
+  __setFunctionName,
   __metadata,
   __awaiter,
   __generator,
@@ -413,9 +444,10 @@
   __classPrivateFieldIn,
   __addDisposableResource,
   __disposeResources,
+  __rewriteRelativeImportExtension,
 });
 
-;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
+;// ./node_modules/lower-case/dist.es2015/index.js
 /**
  * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
  */
@@ -464,7 +496,7 @@
     return str.toLowerCase();
 }
 
-;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
+;// ./node_modules/no-case/dist.es2015/index.js
 
 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
@@ -496,7 +528,7 @@
     return re.reduce(function (input, re) { return input.replace(re, value); }, input);
 }
 
-;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
+;// ./node_modules/dot-case/dist.es2015/index.js
 
 
 function dotCase(input, options) {
@@ -504,7 +536,7 @@
     return noCase(input, __assign({ delimiter: "." }, options));
 }
 
-;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
+;// ./node_modules/param-case/dist.es2015/index.js
 
 
 function paramCase(input, options) {
@@ -512,12 +544,12 @@
     return dotCase(input, __assign({ delimiter: "-" }, options));
 }
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/constants.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/constants.js
 const VARIABLE_REFERENCE_PREFIX = 'var:';
 const VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
 const VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/utils.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/utils.js
 /**
  * External dependencies
  */
@@ -560,7 +592,7 @@
   return styleValue ? [{
     selector: options?.selector,
     key: ruleKey,
-    value: getCSSVarFromStyleValue(styleValue)
+    value: getCSSValueFromRawStyle(styleValue)
   }] : [];
 }
 
@@ -589,7 +621,7 @@
     });
   } else {
     const sideRules = individualProperties.reduce((acc, side) => {
-      const value = getCSSVarFromStyleValue(getStyleValueByPath(boxStyle, [side]));
+      const value = getCSSValueFromRawStyle(getStyleValueByPath(boxStyle, [side]));
       if (value) {
         acc.push({
           selector: options?.selector,
@@ -605,13 +637,21 @@
 }
 
 /**
- * Returns a CSS var value from incoming style value following the pattern `var:description|context|slug`.
+ * Returns a WordPress CSS custom var value from incoming style preset value,
+ * if one is detected.
  *
- * @param styleValue A raw style value.
+ * The preset value is a string and follows the pattern `var:description|context|slug`.
+ *
+ * Example:
  *
- * @return string A CSS var value.
+ * `getCSSValueFromRawStyle( 'var:preset|color|heavenlyBlue' )` // returns 'var(--wp--preset--color--heavenly-blue)'
+ *
+ * @param styleValue A string representing a raw CSS value. Non-strings won't be processed.
+ *
+ * @return A CSS custom var value if the incoming style value is a preset value.
  */
-function getCSSVarFromStyleValue(styleValue) {
+
+function getCSSValueFromRawStyle(styleValue) {
   if (typeof styleValue === 'string' && styleValue.startsWith(VARIABLE_REFERENCE_PREFIX)) {
     const variable = styleValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).map(presetVariable => paramCase(presetVariable, {
       splitRegexp: [/([a-z0-9])([A-Z])/g,
@@ -673,7 +713,7 @@
   }
 }
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/border/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/border/index.js
 /**
  * Internal dependencies
  */
@@ -745,7 +785,7 @@
 };
 /* harmony default export */ const border = ([color, borderStyle, width, radius, borderTop, borderRight, borderBottom, borderLeft]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/background.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/color/background.js
 /**
  * Internal dependencies
  */
@@ -759,7 +799,7 @@
 };
 /* harmony default export */ const color_background = (background);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/gradient.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/color/gradient.js
 /**
  * Internal dependencies
  */
@@ -773,7 +813,7 @@
 };
 /* harmony default export */ const color_gradient = (gradient);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/text.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/color/text.js
 /**
  * Internal dependencies
  */
@@ -787,7 +827,7 @@
 };
 /* harmony default export */ const color_text = (text_text);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/color/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/color/index.js
 /**
  * Internal dependencies
  */
@@ -796,7 +836,7 @@
 
 /* harmony default export */ const styles_color = ([color_text, color_gradient, color_background]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/dimensions/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/dimensions/index.js
 /**
  * Internal dependencies
  */
@@ -816,7 +856,7 @@
 };
 /* harmony default export */ const dimensions = ([minHeight, aspectRatio]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/background/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/background/index.js
 /**
  * Internal dependencies
  */
@@ -826,6 +866,12 @@
   name: 'backgroundImage',
   generate: (style, options) => {
     const _backgroundImage = style?.background?.backgroundImage;
+
+    /*
+     * The background image can be a string or an object.
+     * If the background image is a string, it could already contain a url() function,
+     * or have a linear-gradient value.
+     */
     if (typeof _backgroundImage === 'object' && _backgroundImage?.url) {
       return [{
         selector: options.selector,
@@ -834,15 +880,7 @@
         value: `url( '${encodeURI(safeDecodeURI(_backgroundImage.url))}' )`
       }];
     }
-
-    /*
-     * If the background image is a string, it could already contain a url() function,
-     * or have a linear-gradient value.
-     */
-    if (typeof _backgroundImage === 'string') {
-      return generateRule(style, options, ['background', 'backgroundImage'], 'backgroundImage');
-    }
-    return [];
+    return generateRule(style, options, ['background', 'backgroundImage'], 'backgroundImage');
   }
 };
 const backgroundPosition = {
@@ -863,9 +901,15 @@
     return generateRule(style, options, ['background', 'backgroundSize'], 'backgroundSize');
   }
 };
-/* harmony default export */ const styles_background = ([backgroundImage, backgroundPosition, backgroundRepeat, backgroundSize]);
+const backgroundAttachment = {
+  name: 'backgroundAttachment',
+  generate: (style, options) => {
+    return generateRule(style, options, ['background', 'backgroundAttachment'], 'backgroundAttachment');
+  }
+};
+/* harmony default export */ const styles_background = ([backgroundImage, backgroundPosition, backgroundRepeat, backgroundSize, backgroundAttachment]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/shadow/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/shadow/index.js
 /**
  * Internal dependencies
  */
@@ -879,7 +923,7 @@
 };
 /* harmony default export */ const styles_shadow = ([shadow]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/outline/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/outline/index.js
 /**
  * Internal dependencies
  */
@@ -911,7 +955,7 @@
 };
 /* harmony default export */ const outline = ([outline_color, outlineStyle, offset, outline_width]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/padding.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/spacing/padding.js
 /**
  * Internal dependencies
  */
@@ -928,7 +972,7 @@
 };
 /* harmony default export */ const spacing_padding = (padding);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/margin.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/spacing/margin.js
 /**
  * Internal dependencies
  */
@@ -945,7 +989,7 @@
 };
 /* harmony default export */ const spacing_margin = (margin);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/spacing/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/spacing/index.js
 /**
  * Internal dependencies
  */
@@ -953,7 +997,7 @@
 
 /* harmony default export */ const spacing = ([spacing_margin, spacing_padding]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/typography/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/typography/index.js
 /**
  * Internal dependencies
  */
@@ -1021,7 +1065,7 @@
 };
 /* harmony default export */ const typography = ([fontFamily, fontSize, fontStyle, fontWeight, letterSpacing, lineHeight, textColumns, textDecoration, textTransform, writingMode]);
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/styles/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/styles/index.js
 /**
  * Internal dependencies
  */
@@ -1035,7 +1079,7 @@
 
 const styleDefinitions = [...border, ...styles_color, ...dimensions, ...outline, ...spacing, ...typography, ...styles_shadow, ...styles_background];
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/style-engine/build-module/index.js
+;// ./node_modules/@wordpress/style-engine/build-module/index.js
 /**
  * External dependencies
  */
@@ -1108,6 +1152,9 @@
   return rules;
 }
 
+// Export style utils.
+
+
 (window.wp = window.wp || {}).styleEngine = __webpack_exports__;
 /******/ })()
 ;
\ No newline at end of file