@wordpress/global-styles-engine 1.8.1-next.v.202603102151.0 → 1.9.0

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.
package/build/index.cjs CHANGED
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  // packages/global-styles-engine/src/index.ts
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
+ __unstableGeneratePreviewStateStyles: () => import_preview_state_styles.generatePreviewStateStyles,
33
34
  areGlobalStylesEqual: () => import_equal.areGlobalStylesEqual,
34
35
  generateGlobalStyles: () => import_render.generateGlobalStyles,
35
36
  getBlockSelector: () => import_selectors.getBlockSelector,
@@ -65,8 +66,10 @@ var import_selectors = require("./core/selectors.cjs");
65
66
  var import_typography = require("./utils/typography.cjs");
66
67
  var import_dimensions = require("./utils/dimensions.cjs");
67
68
  var import_common = require("./utils/common.cjs");
69
+ var import_preview_state_styles = require("./preview-state-styles.cjs");
68
70
  // Annotate the CommonJS export names for ESM import in node:
69
71
  0 && (module.exports = {
72
+ __unstableGeneratePreviewStateStyles,
70
73
  areGlobalStylesEqual,
71
74
  generateGlobalStyles,
72
75
  getBlockSelector,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["// High-level Settings API\nexport { getSetting } from './settings/get-setting';\nexport { setSetting } from './settings/set-setting';\nexport { getStyle } from './settings/get-style';\nexport { setStyle } from './settings/set-style';\nexport { default as getPalettes } from './settings/get-palette';\n\n// Utilities\nexport { areGlobalStylesEqual } from './core/equal';\nexport { mergeGlobalStyles } from './core/merge';\nexport { default as getGlobalStylesChanges } from './utils/get-global-styles-changes';\n\n// Core rendering\nexport { generateGlobalStyles } from './core/render';\nexport {\n\ttransformToStyles as toStyles,\n\tgetBlockSelectors,\n\tgetLayoutStyles,\n\tprocessCSSNesting,\n} from './core/render';\nexport { getBlockSelector } from './core/selectors';\n\n// Utilities (Ideally these shouldn't be exposed)\nexport { getTypographyFontSizeValue } from './utils/typography';\nexport { getDimensionPresetCssVar } from './utils/dimensions';\nexport {\n\tgetValueFromVariable,\n\tgetPresetVariableFromValue,\n\tgetResolvedValue,\n} from './utils/common';\n\n// Types\nexport type * from './types';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA2B;AAC3B,yBAA2B;AAC3B,uBAAyB;AACzB,uBAAyB;AACzB,yBAAuC;AAGvC,mBAAqC;AACrC,mBAAkC;AAClC,uCAAkD;AAGlD,oBAAqC;AACrC,IAAAA,iBAKO;AACP,uBAAiC;AAGjC,wBAA2C;AAC3C,wBAAyC;AACzC,oBAIO;",
4
+ "sourcesContent": ["// High-level Settings API\nexport { getSetting } from './settings/get-setting';\nexport { setSetting } from './settings/set-setting';\nexport { getStyle } from './settings/get-style';\nexport { setStyle } from './settings/set-style';\nexport { default as getPalettes } from './settings/get-palette';\n\n// Utilities\nexport { areGlobalStylesEqual } from './core/equal';\nexport { mergeGlobalStyles } from './core/merge';\nexport { default as getGlobalStylesChanges } from './utils/get-global-styles-changes';\n\n// Core rendering\nexport { generateGlobalStyles } from './core/render';\nexport {\n\ttransformToStyles as toStyles,\n\tgetBlockSelectors,\n\tgetLayoutStyles,\n\tprocessCSSNesting,\n} from './core/render';\nexport { getBlockSelector } from './core/selectors';\n\n// Utilities (Ideally these shouldn't be exposed)\nexport { getTypographyFontSizeValue } from './utils/typography';\nexport { getDimensionPresetCssVar } from './utils/dimensions';\nexport {\n\tgetValueFromVariable,\n\tgetPresetVariableFromValue,\n\tgetResolvedValue,\n} from './utils/common';\n\n// Types\nexport type * from './types';\n\nexport { generatePreviewStateStyles as __unstableGeneratePreviewStateStyles } from './preview-state-styles';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,yBAA2B;AAC3B,yBAA2B;AAC3B,uBAAyB;AACzB,uBAAyB;AACzB,yBAAuC;AAGvC,mBAAqC;AACrC,mBAAkC;AAClC,uCAAkD;AAGlD,oBAAqC;AACrC,IAAAA,iBAKO;AACP,uBAAiC;AAGjC,wBAA2C;AAC3C,wBAAyC;AACzC,oBAIO;AAKP,kCAAmF;",
6
6
  "names": ["import_render"]
7
7
  }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/global-styles-engine/src/preview-state-styles.ts
21
+ var preview_state_styles_exports = {};
22
+ __export(preview_state_styles_exports, {
23
+ generatePreviewStateStyles: () => generatePreviewStateStyles
24
+ });
25
+ module.exports = __toCommonJS(preview_state_styles_exports);
26
+ var import_render = require("./core/render.cjs");
27
+ function generatePreviewStateStyles(stateStyles, blockName) {
28
+ if (!stateStyles || !blockName) {
29
+ return "";
30
+ }
31
+ const previewConfig = {
32
+ settings: {},
33
+ // Empty settings to satisfy the config structure
34
+ styles: {
35
+ blocks: {
36
+ [blockName]: stateStyles
37
+ }
38
+ }
39
+ };
40
+ try {
41
+ const [generatedStyles] = (0, import_render.generateGlobalStyles)(previewConfig, []);
42
+ return generatedStyles.map((style) => style.css).join("\n");
43
+ } catch (error) {
44
+ return "";
45
+ }
46
+ }
47
+ // Annotate the CommonJS export names for ESM import in node:
48
+ 0 && (module.exports = {
49
+ generatePreviewStateStyles
50
+ });
51
+ //# sourceMappingURL=preview-state-styles.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/preview-state-styles.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { generateGlobalStyles } from './core/render';\nimport type { GlobalStylesConfig } from './types';\n\n/**\n * Generates CSS for preview contexts to display a specific state (hover, focus, etc.).\n * Takes state-specific styles and generates CSS as if they were the default styles,\n * allowing previews to show how a block will appear in that state.\n *\n * @param stateStyles - The styles for the specific state (e.g., hover styles)\n * @param blockName - The block name (e.g., 'core/button')\n * @return CSS string for the state preview\n */\nexport function generatePreviewStateStyles(\n\tstateStyles: any,\n\tblockName: string\n): string {\n\tif ( ! stateStyles || ! blockName ) {\n\t\treturn '';\n\t}\n\n\t// Create a minimal theme.json-like config with the state styles\n\t// positioned as if they were the default styles for this block\n\tconst previewConfig: GlobalStylesConfig = {\n\t\tsettings: {}, // Empty settings to satisfy the config structure\n\t\tstyles: {\n\t\t\tblocks: {\n\t\t\t\t[ blockName ]: stateStyles,\n\t\t\t},\n\t\t},\n\t};\n\n\ttry {\n\t\tconst [ generatedStyles ] = generateGlobalStyles( previewConfig, [] );\n\n\t\treturn generatedStyles.map( ( style ) => style.css ).join( '\\n' );\n\t} catch ( error ) {\n\t\t// If generation fails, return empty string to avoid breaking previews\n\t\treturn '';\n\t}\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqC;AAY9B,SAAS,2BACf,aACA,WACS;AACT,MAAK,CAAE,eAAe,CAAE,WAAY;AACnC,WAAO;AAAA,EACR;AAIA,QAAM,gBAAoC;AAAA,IACzC,UAAU,CAAC;AAAA;AAAA,IACX,QAAQ;AAAA,MACP,QAAQ;AAAA,QACP,CAAE,SAAU,GAAG;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AAEA,MAAI;AACH,UAAM,CAAE,eAAgB,QAAI,oCAAsB,eAAe,CAAC,CAAE;AAEpE,WAAO,gBAAgB,IAAK,CAAE,UAAW,MAAM,GAAI,EAAE,KAAM,IAAK;AAAA,EACjE,SAAU,OAAQ;AAEjB,WAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -22,7 +22,9 @@ import {
22
22
  getPresetVariableFromValue,
23
23
  getResolvedValue
24
24
  } from "./utils/common.mjs";
25
+ import { generatePreviewStateStyles } from "./preview-state-styles.mjs";
25
26
  export {
27
+ generatePreviewStateStyles as __unstableGeneratePreviewStateStyles,
26
28
  areGlobalStylesEqual,
27
29
  generateGlobalStyles,
28
30
  getBlockSelector,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["// High-level Settings API\nexport { getSetting } from './settings/get-setting';\nexport { setSetting } from './settings/set-setting';\nexport { getStyle } from './settings/get-style';\nexport { setStyle } from './settings/set-style';\nexport { default as getPalettes } from './settings/get-palette';\n\n// Utilities\nexport { areGlobalStylesEqual } from './core/equal';\nexport { mergeGlobalStyles } from './core/merge';\nexport { default as getGlobalStylesChanges } from './utils/get-global-styles-changes';\n\n// Core rendering\nexport { generateGlobalStyles } from './core/render';\nexport {\n\ttransformToStyles as toStyles,\n\tgetBlockSelectors,\n\tgetLayoutStyles,\n\tprocessCSSNesting,\n} from './core/render';\nexport { getBlockSelector } from './core/selectors';\n\n// Utilities (Ideally these shouldn't be exposed)\nexport { getTypographyFontSizeValue } from './utils/typography';\nexport { getDimensionPresetCssVar } from './utils/dimensions';\nexport {\n\tgetValueFromVariable,\n\tgetPresetVariableFromValue,\n\tgetResolvedValue,\n} from './utils/common';\n\n// Types\nexport type * from './types';\n"],
5
- "mappings": ";AACA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAoB,WAAXA,gBAA8B;AAGvC,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAClC,SAAoB,WAAXA,gBAAyC;AAGlD,SAAS,4BAA4B;AACrC;AAAA,EACsB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAGjC,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;",
4
+ "sourcesContent": ["// High-level Settings API\nexport { getSetting } from './settings/get-setting';\nexport { setSetting } from './settings/set-setting';\nexport { getStyle } from './settings/get-style';\nexport { setStyle } from './settings/set-style';\nexport { default as getPalettes } from './settings/get-palette';\n\n// Utilities\nexport { areGlobalStylesEqual } from './core/equal';\nexport { mergeGlobalStyles } from './core/merge';\nexport { default as getGlobalStylesChanges } from './utils/get-global-styles-changes';\n\n// Core rendering\nexport { generateGlobalStyles } from './core/render';\nexport {\n\ttransformToStyles as toStyles,\n\tgetBlockSelectors,\n\tgetLayoutStyles,\n\tprocessCSSNesting,\n} from './core/render';\nexport { getBlockSelector } from './core/selectors';\n\n// Utilities (Ideally these shouldn't be exposed)\nexport { getTypographyFontSizeValue } from './utils/typography';\nexport { getDimensionPresetCssVar } from './utils/dimensions';\nexport {\n\tgetValueFromVariable,\n\tgetPresetVariableFromValue,\n\tgetResolvedValue,\n} from './utils/common';\n\n// Types\nexport type * from './types';\n\nexport { generatePreviewStateStyles as __unstableGeneratePreviewStateStyles } from './preview-state-styles';\n"],
5
+ "mappings": ";AACA,SAAS,kBAAkB;AAC3B,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,SAAoB,WAAXA,gBAA8B;AAGvC,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAClC,SAAoB,WAAXA,gBAAyC;AAGlD,SAAS,4BAA4B;AACrC;AAAA,EACsB;AAAA,EACrB;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,wBAAwB;AAGjC,SAAS,kCAAkC;AAC3C,SAAS,gCAAgC;AACzC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAuC,kCAA4C;",
6
6
  "names": ["default"]
7
7
  }
@@ -0,0 +1,26 @@
1
+ // packages/global-styles-engine/src/preview-state-styles.ts
2
+ import { generateGlobalStyles } from "./core/render.mjs";
3
+ function generatePreviewStateStyles(stateStyles, blockName) {
4
+ if (!stateStyles || !blockName) {
5
+ return "";
6
+ }
7
+ const previewConfig = {
8
+ settings: {},
9
+ // Empty settings to satisfy the config structure
10
+ styles: {
11
+ blocks: {
12
+ [blockName]: stateStyles
13
+ }
14
+ }
15
+ };
16
+ try {
17
+ const [generatedStyles] = generateGlobalStyles(previewConfig, []);
18
+ return generatedStyles.map((style) => style.css).join("\n");
19
+ } catch (error) {
20
+ return "";
21
+ }
22
+ }
23
+ export {
24
+ generatePreviewStateStyles
25
+ };
26
+ //# sourceMappingURL=preview-state-styles.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/preview-state-styles.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { generateGlobalStyles } from './core/render';\nimport type { GlobalStylesConfig } from './types';\n\n/**\n * Generates CSS for preview contexts to display a specific state (hover, focus, etc.).\n * Takes state-specific styles and generates CSS as if they were the default styles,\n * allowing previews to show how a block will appear in that state.\n *\n * @param stateStyles - The styles for the specific state (e.g., hover styles)\n * @param blockName - The block name (e.g., 'core/button')\n * @return CSS string for the state preview\n */\nexport function generatePreviewStateStyles(\n\tstateStyles: any,\n\tblockName: string\n): string {\n\tif ( ! stateStyles || ! blockName ) {\n\t\treturn '';\n\t}\n\n\t// Create a minimal theme.json-like config with the state styles\n\t// positioned as if they were the default styles for this block\n\tconst previewConfig: GlobalStylesConfig = {\n\t\tsettings: {}, // Empty settings to satisfy the config structure\n\t\tstyles: {\n\t\t\tblocks: {\n\t\t\t\t[ blockName ]: stateStyles,\n\t\t\t},\n\t\t},\n\t};\n\n\ttry {\n\t\tconst [ generatedStyles ] = generateGlobalStyles( previewConfig, [] );\n\n\t\treturn generatedStyles.map( ( style ) => style.css ).join( '\\n' );\n\t} catch ( error ) {\n\t\t// If generation fails, return empty string to avoid breaking previews\n\t\treturn '';\n\t}\n}\n"],
5
+ "mappings": ";AAGA,SAAS,4BAA4B;AAY9B,SAAS,2BACf,aACA,WACS;AACT,MAAK,CAAE,eAAe,CAAE,WAAY;AACnC,WAAO;AAAA,EACR;AAIA,QAAM,gBAAoC;AAAA,IACzC,UAAU,CAAC;AAAA;AAAA,IACX,QAAQ;AAAA,MACP,QAAQ;AAAA,QACP,CAAE,SAAU,GAAG;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AAEA,MAAI;AACH,UAAM,CAAE,eAAgB,IAAI,qBAAsB,eAAe,CAAC,CAAE;AAEpE,WAAO,gBAAgB,IAAK,CAAE,UAAW,MAAM,GAAI,EAAE,KAAM,IAAK;AAAA,EACjE,SAAU,OAAQ;AAEjB,WAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -13,4 +13,5 @@ export { getTypographyFontSizeValue } from './utils/typography';
13
13
  export { getDimensionPresetCssVar } from './utils/dimensions';
14
14
  export { getValueFromVariable, getPresetVariableFromValue, getResolvedValue, } from './utils/common';
15
15
  export type * from './types';
16
+ export { generatePreviewStateStyles as __unstableGeneratePreviewStateStyles } from './preview-state-styles';
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACN,iBAAiB,IAAI,QAAQ,EAC7B,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACN,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,GAChB,MAAM,gBAAgB,CAAC;AAGxB,mBAAmB,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACN,iBAAiB,IAAI,QAAQ,EAC7B,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GACjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EACN,oBAAoB,EACpB,0BAA0B,EAC1B,gBAAgB,GAChB,MAAM,gBAAgB,CAAC;AAGxB,mBAAmB,SAAS,CAAC;AAE7B,OAAO,EAAE,0BAA0B,IAAI,oCAAoC,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Generates CSS for preview contexts to display a specific state (hover, focus, etc.).
3
+ * Takes state-specific styles and generates CSS as if they were the default styles,
4
+ * allowing previews to show how a block will appear in that state.
5
+ *
6
+ * @param stateStyles - The styles for the specific state (e.g., hover styles)
7
+ * @param blockName - The block name (e.g., 'core/button')
8
+ * @return CSS string for the state preview
9
+ */
10
+ export declare function generatePreviewStateStyles(stateStyles: any, blockName: string): string;
11
+ //# sourceMappingURL=preview-state-styles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview-state-styles.d.ts","sourceRoot":"","sources":["../src/preview-state-styles.ts"],"names":[],"mappings":"AAMA;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,CACzC,WAAW,EAAE,GAAG,EAChB,SAAS,EAAE,MAAM,GACf,MAAM,CAwBR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/global-styles-engine",
3
- "version": "1.8.1-next.v.202603102151.0+59e17f9ec",
3
+ "version": "1.9.0",
4
4
  "description": "Pure CSS generation engine for WordPress global styles.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -42,10 +42,10 @@
42
42
  "types": "build-types/index.d.ts",
43
43
  "sideEffects": false,
44
44
  "dependencies": {
45
- "@wordpress/blocks": "^15.14.1-next.v.202603102151.0+59e17f9ec",
46
- "@wordpress/data": "^10.41.1-next.v.202603102151.0+59e17f9ec",
47
- "@wordpress/i18n": "^6.14.1-next.v.202603102151.0+59e17f9ec",
48
- "@wordpress/style-engine": "^2.41.1-next.v.202603102151.0+59e17f9ec",
45
+ "@wordpress/blocks": "^15.15.0",
46
+ "@wordpress/data": "^10.42.0",
47
+ "@wordpress/i18n": "^6.15.0",
48
+ "@wordpress/style-engine": "^2.42.0",
49
49
  "colord": "^2.9.2",
50
50
  "deepmerge": "^4.3.0",
51
51
  "fast-deep-equal": "^3.1.3",
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "86db21e727d89e8f0dbba9300d2f97fd22b08693"
62
+ "gitHead": "c20787b1778ae64c2db65643b1c236309d68e6ba"
63
63
  }
package/src/index.ts CHANGED
@@ -31,3 +31,5 @@ export {
31
31
 
32
32
  // Types
33
33
  export type * from './types';
34
+
35
+ export { generatePreviewStateStyles as __unstableGeneratePreviewStateStyles } from './preview-state-styles';
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ import { generateGlobalStyles } from './core/render';
5
+ import type { GlobalStylesConfig } from './types';
6
+
7
+ /**
8
+ * Generates CSS for preview contexts to display a specific state (hover, focus, etc.).
9
+ * Takes state-specific styles and generates CSS as if they were the default styles,
10
+ * allowing previews to show how a block will appear in that state.
11
+ *
12
+ * @param stateStyles - The styles for the specific state (e.g., hover styles)
13
+ * @param blockName - The block name (e.g., 'core/button')
14
+ * @return CSS string for the state preview
15
+ */
16
+ export function generatePreviewStateStyles(
17
+ stateStyles: any,
18
+ blockName: string
19
+ ): string {
20
+ if ( ! stateStyles || ! blockName ) {
21
+ return '';
22
+ }
23
+
24
+ // Create a minimal theme.json-like config with the state styles
25
+ // positioned as if they were the default styles for this block
26
+ const previewConfig: GlobalStylesConfig = {
27
+ settings: {}, // Empty settings to satisfy the config structure
28
+ styles: {
29
+ blocks: {
30
+ [ blockName ]: stateStyles,
31
+ },
32
+ },
33
+ };
34
+
35
+ try {
36
+ const [ generatedStyles ] = generateGlobalStyles( previewConfig, [] );
37
+
38
+ return generatedStyles.map( ( style ) => style.css ).join( '\n' );
39
+ } catch ( error ) {
40
+ // If generation fails, return empty string to avoid breaking previews
41
+ return '';
42
+ }
43
+ }