@wordpress/global-styles-engine 1.17.1-next.v.202607070741.0 → 1.18.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.
Files changed (52) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/core/render.cjs +36 -16
  3. package/build/core/render.cjs.map +2 -2
  4. package/build/index.cjs +3 -0
  5. package/build/index.cjs.map +2 -2
  6. package/build/lock-unlock.cjs +37 -0
  7. package/build/lock-unlock.cjs.map +7 -0
  8. package/build/private-apis.cjs +38 -0
  9. package/build/private-apis.cjs.map +7 -0
  10. package/build/settings/get-setting.cjs +3 -1
  11. package/build/settings/get-setting.cjs.map +2 -2
  12. package/build/types.cjs.map +1 -1
  13. package/build/utils/viewport.cjs +108 -0
  14. package/build/utils/viewport.cjs.map +7 -0
  15. package/build-module/core/render.mjs +36 -16
  16. package/build-module/core/render.mjs.map +2 -2
  17. package/build-module/index.mjs +2 -0
  18. package/build-module/index.mjs.map +2 -2
  19. package/build-module/lock-unlock.mjs +11 -0
  20. package/build-module/lock-unlock.mjs.map +7 -0
  21. package/build-module/private-apis.mjs +17 -0
  22. package/build-module/private-apis.mjs.map +7 -0
  23. package/build-module/settings/get-setting.mjs +3 -1
  24. package/build-module/settings/get-setting.mjs.map +2 -2
  25. package/build-module/utils/viewport.mjs +81 -0
  26. package/build-module/utils/viewport.mjs.map +7 -0
  27. package/build-types/core/render.d.ts +1 -1
  28. package/build-types/core/render.d.ts.map +1 -1
  29. package/build-types/index.d.ts +1 -0
  30. package/build-types/index.d.ts.map +1 -1
  31. package/build-types/lock-unlock.d.ts +2 -0
  32. package/build-types/lock-unlock.d.ts.map +1 -0
  33. package/build-types/private-apis.d.ts +2 -0
  34. package/build-types/private-apis.d.ts.map +1 -0
  35. package/build-types/settings/get-setting.d.ts.map +1 -1
  36. package/build-types/style-state-back-compat.d.ts.map +1 -1
  37. package/build-types/types.d.ts +4 -0
  38. package/build-types/types.d.ts.map +1 -1
  39. package/build-types/utils/fluid.d.ts +1 -1
  40. package/build-types/utils/fluid.d.ts.map +1 -1
  41. package/build-types/utils/viewport.d.ts +41 -0
  42. package/build-types/utils/viewport.d.ts.map +1 -0
  43. package/package.json +7 -6
  44. package/src/core/render.tsx +45 -21
  45. package/src/index.ts +1 -0
  46. package/src/lock-unlock.ts +10 -0
  47. package/src/private-apis.ts +16 -0
  48. package/src/settings/get-setting.ts +2 -0
  49. package/src/test/render.test.ts +182 -0
  50. package/src/test/viewport-utils.test.ts +168 -0
  51. package/src/types.ts +4 -0
  52. package/src/utils/viewport.ts +153 -0
package/build/index.cjs CHANGED
@@ -46,6 +46,7 @@ __export(index_exports, {
46
46
  getTypographyFontSizeValue: () => import_typography.getTypographyFontSizeValue,
47
47
  getValueFromVariable: () => import_common.getValueFromVariable,
48
48
  mergeGlobalStyles: () => import_merge.mergeGlobalStyles,
49
+ privateApis: () => import_private_apis.privateApis,
49
50
  processCSSNesting: () => import_render2.processCSSNesting,
50
51
  setSetting: () => import_set_setting.setSetting,
51
52
  setStyle: () => import_set_style.setStyle,
@@ -67,6 +68,7 @@ var import_selectors = require("./core/selectors.cjs");
67
68
  var import_typography = require("./utils/typography.cjs");
68
69
  var import_dimensions = require("./utils/dimensions.cjs");
69
70
  var import_common = require("./utils/common.cjs");
71
+ var import_private_apis = require("./private-apis.cjs");
70
72
  var import_preview_state_styles = require("./preview-state-styles.cjs");
71
73
  // Annotate the CommonJS export names for ESM import in node:
72
74
  0 && (module.exports = {
@@ -86,6 +88,7 @@ var import_preview_state_styles = require("./preview-state-styles.cjs");
86
88
  getTypographyFontSizeValue,
87
89
  getValueFromVariable,
88
90
  mergeGlobalStyles,
91
+ privateApis,
89
92
  processCSSNesting,
90
93
  setSetting,
91
94
  setStyle,
@@ -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\tsplitSelectorList,\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;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,oBAKO;AAKP,kCAAmF;",
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\tsplitSelectorList,\n} from './utils/common';\nexport { privateApis } from './private-apis';\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;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,oBAKO;AACP,0BAA4B;AAK5B,kCAAmF;",
6
6
  "names": ["import_render"]
7
7
  }
@@ -0,0 +1,37 @@
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/lock-unlock.ts
21
+ var lock_unlock_exports = {};
22
+ __export(lock_unlock_exports, {
23
+ lock: () => lock,
24
+ unlock: () => unlock
25
+ });
26
+ module.exports = __toCommonJS(lock_unlock_exports);
27
+ var import_private_apis = require("@wordpress/private-apis");
28
+ var { lock, unlock } = (0, import_private_apis.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
29
+ "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
30
+ "@wordpress/global-styles-engine"
31
+ );
32
+ // Annotate the CommonJS export names for ESM import in node:
33
+ 0 && (module.exports = {
34
+ lock,
35
+ unlock
36
+ });
37
+ //# sourceMappingURL=lock-unlock.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/lock-unlock.ts"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/global-styles-engine'\n\t);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAAiE;AAE1D,IAAM,EAAE,MAAM,OAAO,QAC3B;AAAA,EACC;AAAA,EACA;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,38 @@
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/private-apis.ts
21
+ var private_apis_exports = {};
22
+ __export(private_apis_exports, {
23
+ privateApis: () => privateApis
24
+ });
25
+ module.exports = __toCommonJS(private_apis_exports);
26
+ var import_viewport = require("./utils/viewport.cjs");
27
+ var import_lock_unlock = require("./lock-unlock.cjs");
28
+ var privateApis = {};
29
+ (0, import_lock_unlock.lock)(privateApis, {
30
+ getResponsiveMediaQueries: import_viewport.getResponsiveMediaQueries,
31
+ getViewportBreakpoints: import_viewport.getViewportBreakpoints,
32
+ getViewportBreakpointValueInPixels: import_viewport.getViewportBreakpointValueInPixels
33
+ });
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ privateApis
37
+ });
38
+ //# sourceMappingURL=private-apis.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/private-apis.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport {\n\tgetResponsiveMediaQueries,\n\tgetViewportBreakpoints,\n\tgetViewportBreakpointValueInPixels,\n} from './utils/viewport';\nimport { lock } from './lock-unlock';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tgetResponsiveMediaQueries,\n\tgetViewportBreakpoints,\n\tgetViewportBreakpointValueInPixels,\n} );\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAIO;AACP,yBAAqB;AAEd,IAAM,cAAc,CAAC;AAAA,IAC5B,yBAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
6
+ "names": []
7
+ }
@@ -91,7 +91,9 @@ var VALID_SETTINGS = [
91
91
  "typography.textDecoration",
92
92
  "typography.textIndent",
93
93
  "typography.textTransform",
94
- "typography.writingMode"
94
+ "typography.writingMode",
95
+ "viewport.mobile",
96
+ "viewport.tablet"
95
97
  ];
96
98
  function getSetting(globalStyles, path, blockName) {
97
99
  const appendedBlockPath = blockName ? ".blocks." + blockName : "";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/settings/get-setting.ts"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\nimport type { GlobalStylesConfig } from '../types';\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'background.gradient',\n\t'border.color',\n\t'border.radius',\n\t'border.radiusSizes',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.height',\n\t'dimensions.minHeight',\n\t'dimensions.minWidth',\n\t'dimensions.width',\n\t'dimensions.dimensionSizes',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textIndent',\n\t'typography.textTransform',\n\t'typography.writingMode',\n];\n\nexport function getSetting< T = any >(\n\tglobalStyles: GlobalStylesConfig,\n\tpath: string,\n\tblockName?: string\n): T {\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = path ? '.' + path : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\n\tif ( path ) {\n\t\treturn ( getValueFromObjectPath( globalStyles, contextualPath ) ??\n\t\t\tgetValueFromObjectPath( globalStyles, globalPath ) ) as T;\n\t}\n\n\tlet result = {};\n\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\tconst value =\n\t\t\tgetValueFromObjectPath(\n\t\t\t\tglobalStyles,\n\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t) ??\n\t\t\tgetValueFromObjectPath( globalStyles, `settings.${ setting }` );\n\t\tif ( value !== undefined ) {\n\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t}\n\t} );\n\treturn result as T;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqD;AAGrD,IAAM,iBAAiB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,WACf,cACA,MACA,WACI;AACJ,QAAM,oBAAoB,YAAY,aAAa,YAAY;AAC/D,QAAM,uBAAuB,OAAO,MAAM,OAAO;AACjD,QAAM,iBAAiB,WAAY,iBAAkB,GAAI,oBAAqB;AAC9E,QAAM,aAAa,WAAY,oBAAqB;AAEpD,MAAK,MAAO;AACX,eAAS,sCAAwB,cAAc,cAAe,SAC7D,sCAAwB,cAAc,UAAW;AAAA,EACnD;AAEA,MAAI,SAAS,CAAC;AACd,iBAAe,QAAS,CAAE,YAAa;AACtC,UAAM,YACL;AAAA,MACC;AAAA,MACA,WAAY,iBAAkB,IAAK,OAAQ;AAAA,IAC5C,SACA,sCAAwB,cAAc,YAAa,OAAQ,EAAG;AAC/D,QAAK,UAAU,QAAY;AAC1B,mBAAS,4BAAc,QAAQ,QAAQ,MAAO,GAAI,GAAG,KAAM;AAAA,IAC5D;AAAA,EACD,CAAE;AACF,SAAO;AACR;",
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { getValueFromObjectPath, setImmutably } from '../utils/object';\nimport type { GlobalStylesConfig } from '../types';\n\nconst VALID_SETTINGS = [\n\t'appearanceTools',\n\t'useRootPaddingAwareAlignments',\n\t'background.backgroundImage',\n\t'background.backgroundRepeat',\n\t'background.backgroundSize',\n\t'background.backgroundPosition',\n\t'background.gradient',\n\t'border.color',\n\t'border.radius',\n\t'border.radiusSizes',\n\t'border.style',\n\t'border.width',\n\t'shadow.presets',\n\t'shadow.defaultPresets',\n\t'color.background',\n\t'color.button',\n\t'color.caption',\n\t'color.custom',\n\t'color.customDuotone',\n\t'color.customGradient',\n\t'color.defaultDuotone',\n\t'color.defaultGradients',\n\t'color.defaultPalette',\n\t'color.duotone',\n\t'color.gradients',\n\t'color.heading',\n\t'color.link',\n\t'color.palette',\n\t'color.text',\n\t'custom',\n\t'dimensions.aspectRatio',\n\t'dimensions.height',\n\t'dimensions.minHeight',\n\t'dimensions.minWidth',\n\t'dimensions.width',\n\t'dimensions.dimensionSizes',\n\t'layout.contentSize',\n\t'layout.definitions',\n\t'layout.wideSize',\n\t'lightbox.enabled',\n\t'lightbox.allowEditing',\n\t'position.fixed',\n\t'position.sticky',\n\t'spacing.customSpacingSize',\n\t'spacing.defaultSpacingSizes',\n\t'spacing.spacingSizes',\n\t'spacing.spacingScale',\n\t'spacing.blockGap',\n\t'spacing.margin',\n\t'spacing.padding',\n\t'spacing.units',\n\t'typography.fluid',\n\t'typography.customFontSize',\n\t'typography.defaultFontSizes',\n\t'typography.dropCap',\n\t'typography.fontFamilies',\n\t'typography.fontSizes',\n\t'typography.fontStyle',\n\t'typography.fontWeight',\n\t'typography.letterSpacing',\n\t'typography.lineHeight',\n\t'typography.textAlign',\n\t'typography.textColumns',\n\t'typography.textDecoration',\n\t'typography.textIndent',\n\t'typography.textTransform',\n\t'typography.writingMode',\n\t'viewport.mobile',\n\t'viewport.tablet',\n];\n\nexport function getSetting< T = any >(\n\tglobalStyles: GlobalStylesConfig,\n\tpath: string,\n\tblockName?: string\n): T {\n\tconst appendedBlockPath = blockName ? '.blocks.' + blockName : '';\n\tconst appendedPropertyPath = path ? '.' + path : '';\n\tconst contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;\n\tconst globalPath = `settings${ appendedPropertyPath }`;\n\n\tif ( path ) {\n\t\treturn ( getValueFromObjectPath( globalStyles, contextualPath ) ??\n\t\t\tgetValueFromObjectPath( globalStyles, globalPath ) ) as T;\n\t}\n\n\tlet result = {};\n\tVALID_SETTINGS.forEach( ( setting ) => {\n\t\tconst value =\n\t\t\tgetValueFromObjectPath(\n\t\t\t\tglobalStyles,\n\t\t\t\t`settings${ appendedBlockPath }.${ setting }`\n\t\t\t) ??\n\t\t\tgetValueFromObjectPath( globalStyles, `settings.${ setting }` );\n\t\tif ( value !== undefined ) {\n\t\t\tresult = setImmutably( result, setting.split( '.' ), value );\n\t\t}\n\t} );\n\treturn result as T;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAqD;AAGrD,IAAM,iBAAiB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEO,SAAS,WACf,cACA,MACA,WACI;AACJ,QAAM,oBAAoB,YAAY,aAAa,YAAY;AAC/D,QAAM,uBAAuB,OAAO,MAAM,OAAO;AACjD,QAAM,iBAAiB,WAAY,iBAAkB,GAAI,oBAAqB;AAC9E,QAAM,aAAa,WAAY,oBAAqB;AAEpD,MAAK,MAAO;AACX,eAAS,sCAAwB,cAAc,cAAe,SAC7D,sCAAwB,cAAc,UAAW;AAAA,EACnD;AAEA,MAAI,SAAS,CAAC;AACd,iBAAe,QAAS,CAAE,YAAa;AACtC,UAAM,YACL;AAAA,MACC;AAAA,MACA,WAAY,iBAAkB,IAAK,OAAQ;AAAA,IAC5C,SACA,sCAAwB,cAAc,YAAa,OAAQ,EAAG;AAC/D,QAAK,UAAU,QAAY;AAC1B,mBAAS,4BAAc,QAAQ,QAAQ,MAAO,GAAI,GAAG,KAAM;AAAA,IAC5D;AAAA,EACD,CAAE;AACF,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/types.ts"],
4
- "sourcesContent": ["// =============================================================================\n// CORE PRIMITIVE TYPES\n// =============================================================================\n\n/**\n * Value that can be resolved from various sources (direct value, reference, or URL)\n */\nexport type UnresolvedValue =\n\t| string\n\t| number\n\t| { ref: string }\n\t| { url: string }\n\t| undefined\n\t| null;\n\n/**\n * Origin of a preset (theme, user customizations, or WordPress defaults)\n */\nexport type PresetOrigin = 'theme' | 'custom' | 'default';\n\n/**\n * Common properties for all preset types\n */\nexport interface BasePreset {\n\tname: string;\n\tslug: string;\n}\n\n// =============================================================================\n// COLOR SYSTEM TYPES\n// =============================================================================\n\n/**\n * Color preset definition\n */\nexport interface Color extends BasePreset {\n\tcolor: string;\n}\n\n/**\n * Gradient preset definition\n */\nexport interface Gradient extends BasePreset {\n\tgradient: string;\n}\n\n/**\n * Duotone filter preset definition\n */\nexport interface Duotone extends BasePreset {\n\tcolors: string[];\n}\n\n/**\n * Palette collection for a specific origin (theme, custom, default)\n */\nexport interface Palette {\n\tname: string;\n\tslug: PresetOrigin;\n\tcolors?: Color[];\n\tgradients?: Gradient[];\n\tduotones?: Duotone[];\n}\n\n/**\n * Multi-origin palette structure used by StyleBook\n */\nexport interface MultiOriginPalettes {\n\tcolors?: Palette[];\n\tgradients?: Palette[];\n\tduotones?: Palette[];\n\tdisableCustomColors?: boolean;\n\tdisableCustomGradients?: boolean;\n\thasColorsOrGradients?: boolean;\n}\n\n/**\n * Background style properties\n */\nexport interface BackgroundStyle {\n\tbackgroundColor?: UnresolvedValue;\n\tbackgroundImage?:\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\tid?: number;\n\t\t }\n\t\t| UnresolvedValue;\n\tbackgroundSize?: UnresolvedValue;\n\tbackgroundPosition?: UnresolvedValue;\n\tbackgroundRepeat?: UnresolvedValue;\n\tbackgroundAttachment?: UnresolvedValue;\n\tbackgroundBlendMode?: UnresolvedValue;\n\tbackgroundOpacity?: UnresolvedValue;\n}\n\n// =============================================================================\n// TYPOGRAPHY SYSTEM TYPES\n// =============================================================================\n\n/**\n * Fluid typography settings for responsive font sizes\n */\nexport interface FluidTypographyConfig {\n\tmin?: string;\n\tmax?: string;\n}\n\n/**\n * Typography preset (font size) definition\n */\nexport interface TypographyPreset extends BasePreset {\n\tsize: string | number | null;\n\tpreviewFontSize?: string;\n\tfluid?: boolean | FluidTypographyConfig;\n}\n\n/**\n * Font size preset definition (alias for TypographyPreset for clarity)\n */\nexport interface FontSizePreset extends TypographyPreset {}\n\n/**\n * Convenience type alias for font size data\n */\nexport type FontSize = FontSizePreset;\n\n/**\n * Font face definition as found in theme.json\n */\nexport interface FontFace {\n\tfontFamily: string;\n\tfontWeight?: string | number;\n\tfontStyle?: string;\n\tfontStretch?: string;\n\tfontDisplay?: string;\n\tsrc?: string | string[];\n}\n\n/**\n * Font family preset definition as found in theme.json\n */\nexport interface FontFamilyPreset extends BasePreset {\n\tfontFamily: string;\n\tfontFace?: FontFace[];\n}\n\n/**\n * Global fluid typography settings\n */\nexport interface FluidTypographySettings {\n\tmaxViewportWidth?: string;\n\tminFontSize?: string;\n\tminViewportWidth?: string;\n}\n\n/**\n * Typography settings collection\n */\nexport interface TypographySettings {\n\tfluid?: boolean | FluidTypographySettings;\n\tfontSizes?: TypographyPreset[] | Record< string, TypographyPreset[] >;\n\tfontFamilies?: Record< string, FontFamilyPreset[] >;\n\tdefaultFontSizes?: boolean;\n}\n\n// =============================================================================\n// LAYOUT SYSTEM TYPES\n// =============================================================================\n\n/**\n * Layout constraint settings\n */\nexport interface LayoutSettings {\n\twideSize?: string;\n\tcontentSize?: string;\n}\n\n/**\n * Spacing settings\n */\nexport interface SpacingSettings {\n\tpadding?: string | Record< string, string >;\n\tmargin?: string | Record< string, string >;\n\tblockGap?: string;\n}\n\n// =============================================================================\n// GLOBAL STYLES STRUCTURE TYPES\n// =============================================================================\n\n/**\n * Global styles settings node\n */\nexport interface GlobalStylesSettings {\n\tuseRootPaddingAwareAlignments?: boolean;\n\ttypography?: TypographySettings;\n\tlayout?: LayoutSettings;\n\tspacing?: SpacingSettings;\n\tcolor?: {\n\t\tpalette?:\n\t\t\t| Color[]\n\t\t\t| {\n\t\t\t\t\ttheme?: Color[];\n\t\t\t\t\tcustom?: Color[];\n\t\t\t\t\tdefault?: Color[];\n\t\t\t };\n\t\tgradients?: {\n\t\t\ttheme?: Gradient[];\n\t\t\tcustom?: Gradient[];\n\t\t\tdefault?: Gradient[];\n\t\t};\n\t\tduotone?: {\n\t\t\ttheme?: Duotone[];\n\t\t\tcustom?: Duotone[];\n\t\t\tdefault?: Duotone[];\n\t\t};\n\t\tlink?: boolean;\n\t\tcustom?: boolean;\n\t\tcustomGradient?: boolean;\n\t\tcustomDuotone?: boolean;\n\t\tdefaultPalette?: boolean;\n\t\tdefaultGradients?: boolean;\n\t\tdefaultDuotone?: boolean;\n\t};\n\tcustom?: Record<\n\t\tstring,\n\t\tstring | number | Record< string, string | number >\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesSettings, 'blocks' > >;\n}\n\n/**\n * Global styles values node\n */\nexport interface GlobalStylesStyles {\n\tcolor?: {\n\t\tbackground?: UnresolvedValue;\n\t\ttext?: UnresolvedValue;\n\t};\n\ttypography?: {\n\t\tfontFamily?: UnresolvedValue;\n\t\tfontSize?: UnresolvedValue;\n\t\tfontWeight?: UnresolvedValue;\n\t\tlineHeight?: UnresolvedValue;\n\t\tletterSpacing?: UnresolvedValue;\n\t\ttextTransform?: UnresolvedValue;\n\t\ttextIndent?: UnresolvedValue;\n\t};\n\tspacing?: {\n\t\tpadding?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tmargin?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tblockGap?: string;\n\t};\n\tbackground?: BackgroundStyle;\n\tborder?: {\n\t\tcolor?: UnresolvedValue;\n\t\twidth?: UnresolvedValue;\n\t\tstyle?: UnresolvedValue;\n\t\tradius?:\n\t\t\t| UnresolvedValue\n\t\t\t| {\n\t\t\t\t\ttopLeft?: UnresolvedValue;\n\t\t\t\t\ttopRight?: UnresolvedValue;\n\t\t\t\t\tbottomRight?: UnresolvedValue;\n\t\t\t\t\tbottomLeft?: UnresolvedValue;\n\t\t\t };\n\t\ttop?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tright?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tbottom?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tleft?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t};\n\tfilter?: {\n\t\tduotone?: UnresolvedValue;\n\t\topacity?: UnresolvedValue;\n\t};\n\tdimensions?: {\n\t\twidth?: UnresolvedValue;\n\t\theight?: UnresolvedValue;\n\t\tminWidth?: UnresolvedValue;\n\t\tminHeight?: UnresolvedValue;\n\t\tmaxWidth?: UnresolvedValue;\n\t\tmaxHeight?: UnresolvedValue;\n\t};\n\telements?: Record<\n\t\tstring,\n\t\tOmit< GlobalStylesStyles, 'blocks' | 'elements' | 'variations' > & {\n\t\t\t':hover'?: Omit<\n\t\t\t\tGlobalStylesStyles,\n\t\t\t\t'blocks' | 'elements' | 'variations'\n\t\t\t>;\n\t\t}\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tvariations?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tcss?: string;\n}\n\n/**\n * Complete global styles configuration\n */\nexport interface GlobalStylesConfig {\n\tversion?: number;\n\tsettings?: GlobalStylesSettings;\n\tstyles?: GlobalStylesStyles;\n\t_links?: {\n\t\t[ 'wp:theme-file' ]?: ThemeFileLink[];\n\t\t[ 'wp:action-edit-css' ]?: Array< { href: string } >;\n\t};\n}\n\n/**\n * Style variation (extends GlobalStylesConfig with metadata)\n */\nexport interface StyleVariation extends GlobalStylesConfig {\n\ttitle?: string;\n\tdescription?: string;\n}\n\n/**\n * WordPress theme file link\n */\nexport interface ThemeFileLink {\n\tname: string;\n\thref: string;\n\ttarget?: string;\n}\n\n// =============================================================================\n// UTILITY TYPES\n// =============================================================================\n\n/**\n * Deep partial type for global styles merging\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\n/**\n * CSS selector string\n */\nexport type CSSSelector = string;\n\n/**\n * CSS property value\n */\nexport type CSSValue = string | number | undefined;\n\n/**\n * CSS rules object\n */\nexport type CSSRules = Record< string, CSSValue >;\n"],
4
+ "sourcesContent": ["// =============================================================================\n// CORE PRIMITIVE TYPES\n// =============================================================================\n\n/**\n * Value that can be resolved from various sources (direct value, reference, or URL)\n */\nexport type UnresolvedValue =\n\t| string\n\t| number\n\t| { ref: string }\n\t| { url: string }\n\t| undefined\n\t| null;\n\n/**\n * Origin of a preset (theme, user customizations, or WordPress defaults)\n */\nexport type PresetOrigin = 'theme' | 'custom' | 'default';\n\n/**\n * Common properties for all preset types\n */\nexport interface BasePreset {\n\tname: string;\n\tslug: string;\n}\n\n// =============================================================================\n// COLOR SYSTEM TYPES\n// =============================================================================\n\n/**\n * Color preset definition\n */\nexport interface Color extends BasePreset {\n\tcolor: string;\n}\n\n/**\n * Gradient preset definition\n */\nexport interface Gradient extends BasePreset {\n\tgradient: string;\n}\n\n/**\n * Duotone filter preset definition\n */\nexport interface Duotone extends BasePreset {\n\tcolors: string[];\n}\n\n/**\n * Palette collection for a specific origin (theme, custom, default)\n */\nexport interface Palette {\n\tname: string;\n\tslug: PresetOrigin;\n\tcolors?: Color[];\n\tgradients?: Gradient[];\n\tduotones?: Duotone[];\n}\n\n/**\n * Multi-origin palette structure used by StyleBook\n */\nexport interface MultiOriginPalettes {\n\tcolors?: Palette[];\n\tgradients?: Palette[];\n\tduotones?: Palette[];\n\tdisableCustomColors?: boolean;\n\tdisableCustomGradients?: boolean;\n\thasColorsOrGradients?: boolean;\n}\n\n/**\n * Background style properties\n */\nexport interface BackgroundStyle {\n\tbackgroundColor?: UnresolvedValue;\n\tbackgroundImage?:\n\t\t| {\n\t\t\t\turl: string;\n\t\t\t\tid?: number;\n\t\t }\n\t\t| UnresolvedValue;\n\tbackgroundSize?: UnresolvedValue;\n\tbackgroundPosition?: UnresolvedValue;\n\tbackgroundRepeat?: UnresolvedValue;\n\tbackgroundAttachment?: UnresolvedValue;\n\tbackgroundBlendMode?: UnresolvedValue;\n\tbackgroundOpacity?: UnresolvedValue;\n}\n\n// =============================================================================\n// TYPOGRAPHY SYSTEM TYPES\n// =============================================================================\n\n/**\n * Fluid typography settings for responsive font sizes\n */\nexport interface FluidTypographyConfig {\n\tmin?: string;\n\tmax?: string;\n}\n\n/**\n * Typography preset (font size) definition\n */\nexport interface TypographyPreset extends BasePreset {\n\tsize: string | number | null;\n\tpreviewFontSize?: string;\n\tfluid?: boolean | FluidTypographyConfig;\n}\n\n/**\n * Font size preset definition (alias for TypographyPreset for clarity)\n */\nexport interface FontSizePreset extends TypographyPreset {}\n\n/**\n * Convenience type alias for font size data\n */\nexport type FontSize = FontSizePreset;\n\n/**\n * Font face definition as found in theme.json\n */\nexport interface FontFace {\n\tfontFamily: string;\n\tfontWeight?: string | number;\n\tfontStyle?: string;\n\tfontStretch?: string;\n\tfontDisplay?: string;\n\tsrc?: string | string[];\n}\n\n/**\n * Font family preset definition as found in theme.json\n */\nexport interface FontFamilyPreset extends BasePreset {\n\tfontFamily: string;\n\tfontFace?: FontFace[];\n}\n\n/**\n * Global fluid typography settings\n */\nexport interface FluidTypographySettings {\n\tmaxViewportWidth?: string;\n\tminFontSize?: string;\n\tminViewportWidth?: string;\n}\n\n/**\n * Typography settings collection\n */\nexport interface TypographySettings {\n\tfluid?: boolean | FluidTypographySettings;\n\tfontSizes?: TypographyPreset[] | Record< string, TypographyPreset[] >;\n\tfontFamilies?: Record< string, FontFamilyPreset[] >;\n\tdefaultFontSizes?: boolean;\n}\n\n// =============================================================================\n// LAYOUT SYSTEM TYPES\n// =============================================================================\n\n/**\n * Layout constraint settings\n */\nexport interface LayoutSettings {\n\twideSize?: string;\n\tcontentSize?: string;\n}\n\n/**\n * Spacing settings\n */\nexport interface SpacingSettings {\n\tpadding?: string | Record< string, string >;\n\tmargin?: string | Record< string, string >;\n\tblockGap?: string;\n}\n\n// =============================================================================\n// GLOBAL STYLES STRUCTURE TYPES\n// =============================================================================\n\n/**\n * Global styles settings node\n */\nexport interface GlobalStylesSettings {\n\tuseRootPaddingAwareAlignments?: boolean;\n\tviewport?: {\n\t\tmobile?: string;\n\t\ttablet?: string;\n\t};\n\ttypography?: TypographySettings;\n\tlayout?: LayoutSettings;\n\tspacing?: SpacingSettings;\n\tcolor?: {\n\t\tpalette?:\n\t\t\t| Color[]\n\t\t\t| {\n\t\t\t\t\ttheme?: Color[];\n\t\t\t\t\tcustom?: Color[];\n\t\t\t\t\tdefault?: Color[];\n\t\t\t };\n\t\tgradients?: {\n\t\t\ttheme?: Gradient[];\n\t\t\tcustom?: Gradient[];\n\t\t\tdefault?: Gradient[];\n\t\t};\n\t\tduotone?: {\n\t\t\ttheme?: Duotone[];\n\t\t\tcustom?: Duotone[];\n\t\t\tdefault?: Duotone[];\n\t\t};\n\t\tlink?: boolean;\n\t\tcustom?: boolean;\n\t\tcustomGradient?: boolean;\n\t\tcustomDuotone?: boolean;\n\t\tdefaultPalette?: boolean;\n\t\tdefaultGradients?: boolean;\n\t\tdefaultDuotone?: boolean;\n\t};\n\tcustom?: Record<\n\t\tstring,\n\t\tstring | number | Record< string, string | number >\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesSettings, 'blocks' > >;\n}\n\n/**\n * Global styles values node\n */\nexport interface GlobalStylesStyles {\n\tcolor?: {\n\t\tbackground?: UnresolvedValue;\n\t\ttext?: UnresolvedValue;\n\t};\n\ttypography?: {\n\t\tfontFamily?: UnresolvedValue;\n\t\tfontSize?: UnresolvedValue;\n\t\tfontWeight?: UnresolvedValue;\n\t\tlineHeight?: UnresolvedValue;\n\t\tletterSpacing?: UnresolvedValue;\n\t\ttextTransform?: UnresolvedValue;\n\t\ttextIndent?: UnresolvedValue;\n\t};\n\tspacing?: {\n\t\tpadding?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tmargin?: UnresolvedValue | Record< string, UnresolvedValue >;\n\t\tblockGap?: string;\n\t};\n\tbackground?: BackgroundStyle;\n\tborder?: {\n\t\tcolor?: UnresolvedValue;\n\t\twidth?: UnresolvedValue;\n\t\tstyle?: UnresolvedValue;\n\t\tradius?:\n\t\t\t| UnresolvedValue\n\t\t\t| {\n\t\t\t\t\ttopLeft?: UnresolvedValue;\n\t\t\t\t\ttopRight?: UnresolvedValue;\n\t\t\t\t\tbottomRight?: UnresolvedValue;\n\t\t\t\t\tbottomLeft?: UnresolvedValue;\n\t\t\t };\n\t\ttop?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tright?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tbottom?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t\tleft?: {\n\t\t\tcolor?: UnresolvedValue;\n\t\t\twidth?: UnresolvedValue;\n\t\t\tstyle?: UnresolvedValue;\n\t\t};\n\t};\n\tfilter?: {\n\t\tduotone?: UnresolvedValue;\n\t\topacity?: UnresolvedValue;\n\t};\n\tdimensions?: {\n\t\twidth?: UnresolvedValue;\n\t\theight?: UnresolvedValue;\n\t\tminWidth?: UnresolvedValue;\n\t\tminHeight?: UnresolvedValue;\n\t\tmaxWidth?: UnresolvedValue;\n\t\tmaxHeight?: UnresolvedValue;\n\t};\n\telements?: Record<\n\t\tstring,\n\t\tOmit< GlobalStylesStyles, 'blocks' | 'elements' | 'variations' > & {\n\t\t\t':hover'?: Omit<\n\t\t\t\tGlobalStylesStyles,\n\t\t\t\t'blocks' | 'elements' | 'variations'\n\t\t\t>;\n\t\t}\n\t>;\n\tblocks?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tvariations?: Record< string, Omit< GlobalStylesStyles, 'blocks' > >;\n\tcss?: string;\n}\n\n/**\n * Complete global styles configuration\n */\nexport interface GlobalStylesConfig {\n\tversion?: number;\n\tsettings?: GlobalStylesSettings;\n\tstyles?: GlobalStylesStyles;\n\t_links?: {\n\t\t[ 'wp:theme-file' ]?: ThemeFileLink[];\n\t\t[ 'wp:action-edit-css' ]?: Array< { href: string } >;\n\t};\n}\n\n/**\n * Style variation (extends GlobalStylesConfig with metadata)\n */\nexport interface StyleVariation extends GlobalStylesConfig {\n\ttitle?: string;\n\tdescription?: string;\n}\n\n/**\n * WordPress theme file link\n */\nexport interface ThemeFileLink {\n\tname: string;\n\thref: string;\n\ttarget?: string;\n}\n\n// =============================================================================\n// UTILITY TYPES\n// =============================================================================\n\n/**\n * Deep partial type for global styles merging\n */\nexport type DeepPartial< T > = {\n\t[ P in keyof T ]?: T[ P ] extends object ? DeepPartial< T[ P ] > : T[ P ];\n};\n\n/**\n * CSS selector string\n */\nexport type CSSSelector = string;\n\n/**\n * CSS property value\n */\nexport type CSSValue = string | number | undefined;\n\n/**\n * CSS rules object\n */\nexport type CSSRules = Record< string, CSSValue >;\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,108 @@
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/utils/viewport.ts
21
+ var viewport_exports = {};
22
+ __export(viewport_exports, {
23
+ getResponsiveMediaQueries: () => getResponsiveMediaQueries,
24
+ getViewportBreakpointValueInPixels: () => getViewportBreakpointValueInPixels,
25
+ getViewportBreakpoints: () => getViewportBreakpoints
26
+ });
27
+ module.exports = __toCommonJS(viewport_exports);
28
+ var DEFAULT_VIEWPORT_BREAKPOINTS = {
29
+ mobile: "480px",
30
+ tablet: "782px"
31
+ };
32
+ var VIEWPORT_SIZE_REGEXP = /^(\d+|\d*\.\d+)(px|em|rem)$/;
33
+ var DEFAULT_FONT_SIZE = 16;
34
+ function isViewportSettings(configOrSettings) {
35
+ return "mobile" in configOrSettings || "tablet" in configOrSettings;
36
+ }
37
+ function getViewportSettings(configOrSettings) {
38
+ if (!configOrSettings || typeof configOrSettings !== "object") {
39
+ return {};
40
+ }
41
+ if (isViewportSettings(configOrSettings)) {
42
+ return configOrSettings;
43
+ }
44
+ return configOrSettings.settings?.viewport ?? {};
45
+ }
46
+ function isValidViewportSize(value) {
47
+ return typeof value === "string" && VIEWPORT_SIZE_REGEXP.test(value.trim());
48
+ }
49
+ function getViewportBreakpointValueInPixels(value) {
50
+ if (typeof value === "number") {
51
+ return value;
52
+ }
53
+ if (typeof value !== "string") {
54
+ return void 0;
55
+ }
56
+ const match = value.trim().match(VIEWPORT_SIZE_REGEXP);
57
+ if (!match) {
58
+ return void 0;
59
+ }
60
+ const numericValue = Number.parseFloat(match[1]);
61
+ const unit = match[2];
62
+ return unit === "px" ? numericValue : numericValue * DEFAULT_FONT_SIZE;
63
+ }
64
+ function getViewportBreakpoints(configOrSettings) {
65
+ const viewportSettings = getViewportSettings(configOrSettings);
66
+ const breakpoints = {};
67
+ const breakpointValuesInPixels = {};
68
+ Object.keys(DEFAULT_VIEWPORT_BREAKPOINTS).forEach((breakpoint) => {
69
+ const key = breakpoint;
70
+ const value = viewportSettings[key];
71
+ const px = getViewportBreakpointValueInPixels(value);
72
+ if (px !== void 0 && isValidViewportSize(value)) {
73
+ breakpoints[key] = value.trim();
74
+ breakpointValuesInPixels[key] = px;
75
+ }
76
+ });
77
+ const breakpointNames = Object.keys(breakpoints);
78
+ if (!breakpointNames.length) {
79
+ return { ...DEFAULT_VIEWPORT_BREAKPOINTS };
80
+ }
81
+ if (1 === breakpointNames.length) {
82
+ return breakpoints;
83
+ }
84
+ const mobile = breakpoints.mobile;
85
+ const tablet = breakpoints.tablet;
86
+ if (breakpointValuesInPixels.mobile >= breakpointValuesInPixels.tablet) {
87
+ return { mobile };
88
+ }
89
+ return { mobile, tablet };
90
+ }
91
+ function getResponsiveMediaQueries(configOrSettings) {
92
+ const breakpoints = getViewportBreakpoints(configOrSettings);
93
+ const mediaQueries = {};
94
+ if (breakpoints.mobile) {
95
+ mediaQueries["@mobile"] = `@media (width <= ${breakpoints.mobile})`;
96
+ }
97
+ if (breakpoints.tablet) {
98
+ mediaQueries["@tablet"] = breakpoints.mobile ? `@media (${breakpoints.mobile} < width <= ${breakpoints.tablet})` : `@media (width <= ${breakpoints.tablet})`;
99
+ }
100
+ return mediaQueries;
101
+ }
102
+ // Annotate the CommonJS export names for ESM import in node:
103
+ 0 && (module.exports = {
104
+ getResponsiveMediaQueries,
105
+ getViewportBreakpointValueInPixels,
106
+ getViewportBreakpoints
107
+ });
108
+ //# sourceMappingURL=viewport.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/utils/viewport.ts"],
4
+ "sourcesContent": ["import type { GlobalStylesConfig } from '../types';\n\nconst DEFAULT_VIEWPORT_BREAKPOINTS = {\n\tmobile: '480px',\n\ttablet: '782px',\n};\n\ntype ViewportBreakpoint = keyof typeof DEFAULT_VIEWPORT_BREAKPOINTS;\ntype ViewportSettings = Partial< Record< ViewportBreakpoint, string > >;\ntype ViewportBreakpoints = Partial< Record< ViewportBreakpoint, string > >;\n\n// Matches positive CSS length values supported for viewport breakpoints, and\n// captures the numeric value and unit for conversion to pixels.\nconst VIEWPORT_SIZE_REGEXP = /^(\\d+|\\d*\\.\\d+)(px|em|rem)$/;\nconst DEFAULT_FONT_SIZE = 16;\n\nfunction isViewportSettings(\n\tconfigOrSettings: GlobalStylesConfig | ViewportSettings\n): configOrSettings is ViewportSettings {\n\treturn 'mobile' in configOrSettings || 'tablet' in configOrSettings;\n}\n\nfunction getViewportSettings(\n\tconfigOrSettings?: GlobalStylesConfig | ViewportSettings\n): ViewportSettings {\n\tif ( ! configOrSettings || typeof configOrSettings !== 'object' ) {\n\t\treturn {};\n\t}\n\n\tif ( isViewportSettings( configOrSettings ) ) {\n\t\treturn configOrSettings;\n\t}\n\n\treturn configOrSettings.settings?.viewport ?? {};\n}\n\nfunction isValidViewportSize( value: unknown ): value is string {\n\treturn (\n\t\ttypeof value === 'string' && VIEWPORT_SIZE_REGEXP.test( value.trim() )\n\t);\n}\n\n/**\n * Converts a viewport breakpoint value to pixels.\n *\n * Numeric values are returned as-is. CSS length values are only supported when\n * expressed in px, em, or rem units.\n *\n * @param value Breakpoint value as a number or CSS length.\n * @return The breakpoint value in pixels, or undefined when invalid.\n */\nexport function getViewportBreakpointValueInPixels(\n\tvalue: number | string | undefined\n): number | undefined {\n\tif ( typeof value === 'number' ) {\n\t\treturn value;\n\t}\n\n\tif ( typeof value !== 'string' ) {\n\t\treturn undefined;\n\t}\n\n\tconst match = value.trim().match( VIEWPORT_SIZE_REGEXP );\n\tif ( ! match ) {\n\t\treturn undefined;\n\t}\n\n\tconst numericValue = Number.parseFloat( match[ 1 ] );\n\tconst unit = match[ 2 ];\n\n\t// Use the most common browser default font size as the base for em/rem\n\t// media query conversions. This pixel value is used to compare breakpoint\n\t// order and calculate preview sizes; generated media queries keep the\n\t// original units.\n\treturn unit === 'px' ? numericValue : numericValue * DEFAULT_FONT_SIZE;\n}\n\n/**\n * Returns sanitized viewport breakpoints keyed by viewport state.\n *\n * Falls back to default breakpoints when no valid values are provided. If the\n * mobile breakpoint is missing, a valid tablet breakpoint remains keyed as\n * tablet so the editor can present it as a tablet breakpoint. If the tablet\n * breakpoint is missing, invalid, or not larger than the mobile breakpoint, the\n * result only includes the mobile breakpoint.\n *\n * @param configOrSettings Global styles config or viewport settings.\n * @return Sanitized viewport breakpoints.\n */\nexport function getViewportBreakpoints(\n\tconfigOrSettings?: GlobalStylesConfig | ViewportSettings\n): ViewportBreakpoints {\n\tconst viewportSettings = getViewportSettings( configOrSettings );\n\tconst breakpoints: ViewportBreakpoints = {};\n\tconst breakpointValuesInPixels: Partial<\n\t\tRecord< ViewportBreakpoint, number >\n\t> = {};\n\n\tObject.keys( DEFAULT_VIEWPORT_BREAKPOINTS ).forEach( ( breakpoint ) => {\n\t\tconst key = breakpoint as ViewportBreakpoint;\n\t\tconst value = viewportSettings[ key ];\n\t\tconst px = getViewportBreakpointValueInPixels( value );\n\t\tif ( px !== undefined && isValidViewportSize( value ) ) {\n\t\t\tbreakpoints[ key ] = value.trim();\n\t\t\tbreakpointValuesInPixels[ key ] = px;\n\t\t}\n\t} );\n\n\tconst breakpointNames = Object.keys( breakpoints );\n\tif ( ! breakpointNames.length ) {\n\t\treturn { ...DEFAULT_VIEWPORT_BREAKPOINTS };\n\t}\n\n\tif ( 1 === breakpointNames.length ) {\n\t\treturn breakpoints;\n\t}\n\n\tconst mobile = breakpoints.mobile!;\n\tconst tablet = breakpoints.tablet!;\n\tif (\n\t\tbreakpointValuesInPixels.mobile! >= breakpointValuesInPixels.tablet!\n\t) {\n\t\treturn { mobile };\n\t}\n\n\treturn { mobile, tablet };\n}\n\n/**\n * Returns responsive media query aliases for the configured viewport\n * breakpoints.\n *\n * @param configOrSettings Global styles config or viewport settings.\n * @return Responsive media queries keyed by alias.\n */\nexport function getResponsiveMediaQueries(\n\tconfigOrSettings?: GlobalStylesConfig | ViewportSettings\n): Record< string, string > {\n\tconst breakpoints = getViewportBreakpoints( configOrSettings );\n\tconst mediaQueries: Record< string, string > = {};\n\n\tif ( breakpoints.mobile ) {\n\t\tmediaQueries[ '@mobile' ] = `@media (width <= ${ breakpoints.mobile })`;\n\t}\n\n\tif ( breakpoints.tablet ) {\n\t\tmediaQueries[ '@tablet' ] = breakpoints.mobile\n\t\t\t? `@media (${ breakpoints.mobile } < width <= ${ breakpoints.tablet })`\n\t\t\t: `@media (width <= ${ breakpoints.tablet })`;\n\t}\n\n\treturn mediaQueries;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,IAAM,+BAA+B;AAAA,EACpC,QAAQ;AAAA,EACR,QAAQ;AACT;AAQA,IAAM,uBAAuB;AAC7B,IAAM,oBAAoB;AAE1B,SAAS,mBACR,kBACuC;AACvC,SAAO,YAAY,oBAAoB,YAAY;AACpD;AAEA,SAAS,oBACR,kBACmB;AACnB,MAAK,CAAE,oBAAoB,OAAO,qBAAqB,UAAW;AACjE,WAAO,CAAC;AAAA,EACT;AAEA,MAAK,mBAAoB,gBAAiB,GAAI;AAC7C,WAAO;AAAA,EACR;AAEA,SAAO,iBAAiB,UAAU,YAAY,CAAC;AAChD;AAEA,SAAS,oBAAqB,OAAkC;AAC/D,SACC,OAAO,UAAU,YAAY,qBAAqB,KAAM,MAAM,KAAK,CAAE;AAEvE;AAWO,SAAS,mCACf,OACqB;AACrB,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO;AAAA,EACR;AAEA,MAAK,OAAO,UAAU,UAAW;AAChC,WAAO;AAAA,EACR;AAEA,QAAM,QAAQ,MAAM,KAAK,EAAE,MAAO,oBAAqB;AACvD,MAAK,CAAE,OAAQ;AACd,WAAO;AAAA,EACR;AAEA,QAAM,eAAe,OAAO,WAAY,MAAO,CAAE,CAAE;AACnD,QAAM,OAAO,MAAO,CAAE;AAMtB,SAAO,SAAS,OAAO,eAAe,eAAe;AACtD;AAcO,SAAS,uBACf,kBACsB;AACtB,QAAM,mBAAmB,oBAAqB,gBAAiB;AAC/D,QAAM,cAAmC,CAAC;AAC1C,QAAM,2BAEF,CAAC;AAEL,SAAO,KAAM,4BAA6B,EAAE,QAAS,CAAE,eAAgB;AACtE,UAAM,MAAM;AACZ,UAAM,QAAQ,iBAAkB,GAAI;AACpC,UAAM,KAAK,mCAAoC,KAAM;AACrD,QAAK,OAAO,UAAa,oBAAqB,KAAM,GAAI;AACvD,kBAAa,GAAI,IAAI,MAAM,KAAK;AAChC,+BAA0B,GAAI,IAAI;AAAA,IACnC;AAAA,EACD,CAAE;AAEF,QAAM,kBAAkB,OAAO,KAAM,WAAY;AACjD,MAAK,CAAE,gBAAgB,QAAS;AAC/B,WAAO,EAAE,GAAG,6BAA6B;AAAA,EAC1C;AAEA,MAAK,MAAM,gBAAgB,QAAS;AACnC,WAAO;AAAA,EACR;AAEA,QAAM,SAAS,YAAY;AAC3B,QAAM,SAAS,YAAY;AAC3B,MACC,yBAAyB,UAAW,yBAAyB,QAC5D;AACD,WAAO,EAAE,OAAO;AAAA,EACjB;AAEA,SAAO,EAAE,QAAQ,OAAO;AACzB;AASO,SAAS,0BACf,kBAC2B;AAC3B,QAAM,cAAc,uBAAwB,gBAAiB;AAC7D,QAAM,eAAyC,CAAC;AAEhD,MAAK,YAAY,QAAS;AACzB,iBAAc,SAAU,IAAI,oBAAqB,YAAY,MAAO;AAAA,EACrE;AAEA,MAAK,YAAY,QAAS;AACzB,iBAAc,SAAU,IAAI,YAAY,SACrC,WAAY,YAAY,MAAO,eAAgB,YAAY,MAAO,MAClE,oBAAqB,YAAY,MAAO;AAAA,EAC5C;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -27,6 +27,7 @@ import { getGapCSSValue } from "../utils/gap.mjs";
27
27
  import { setBackgroundStyleDefaults } from "../utils/background.mjs";
28
28
  import { LAYOUT_DEFINITIONS } from "../utils/layout.mjs";
29
29
  import { getValueFromObjectPath, setImmutably } from "../utils/object.mjs";
30
+ import { getResponsiveMediaQueries } from "../utils/viewport.mjs";
30
31
  import { getSetting } from "../settings/get-setting.mjs";
31
32
  import { normalizeStyleStateAliases } from "../style-state-back-compat.mjs";
32
33
  var ELEMENT_CLASS_NAMES = {
@@ -64,10 +65,6 @@ var VALID_ELEMENT_PSEUDO_SELECTORS = {
64
65
  ":active"
65
66
  ]
66
67
  };
67
- var RESPONSIVE_BREAKPOINTS = {
68
- "@mobile": "@media (width <= 480px)",
69
- "@tablet": "@media (480px < width <= 782px)"
70
- };
71
68
  function getPresetsClasses(blockSelector = "*", blockPresets = {}) {
72
69
  return PRESET_METADATA.reduce(
73
70
  (declarations, { path, cssVarInfix, classes }) => {
@@ -429,17 +426,21 @@ var STYLE_KEYS = [
429
426
  "shadow",
430
427
  "background"
431
428
  ];
432
- function pickStyleKeys(treeToPickFrom) {
433
- return pickStyleAndPseudoKeys(treeToPickFrom);
429
+ function pickStyleKeys(treeToPickFrom, responsiveMediaQueries) {
430
+ return pickStyleAndPseudoKeys(
431
+ treeToPickFrom,
432
+ void 0,
433
+ responsiveMediaQueries
434
+ );
434
435
  }
435
- function pickStyleAndPseudoKeys(treeToPickFrom, blockName) {
436
+ function pickStyleAndPseudoKeys(treeToPickFrom, blockName, responsiveMediaQueries) {
436
437
  if (!treeToPickFrom) {
437
438
  return {};
438
439
  }
439
440
  const entries = Object.entries(treeToPickFrom);
440
441
  const allowedPseudoSelectors = blockName ? VALID_BLOCK_PSEUDO_SELECTORS[blockName] ?? [] : [];
441
442
  const pickedEntries = entries.filter(
442
- ([key]) => STYLE_KEYS.includes(key) || allowedPseudoSelectors.includes(key) || RESPONSIVE_BREAKPOINTS[key]
443
+ ([key]) => STYLE_KEYS.includes(key) || allowedPseudoSelectors.includes(key) || responsiveMediaQueries[key]
443
444
  );
444
445
  const clonedEntries = pickedEntries.map(([key, style]) => [
445
446
  key,
@@ -480,11 +481,15 @@ function getPseudoStyleNodes(node) {
480
481
  ];
481
482
  });
482
483
  }
483
- function getResponsiveStyleNodes(node) {
484
+ function getResponsiveStyleNodes(node, responsiveMediaQueries) {
484
485
  const {
485
486
  styles,
486
487
  selector,
488
+ fallbackGapValue,
487
489
  featureSelectors,
490
+ hasLayoutSupport,
491
+ layoutHasBlockGapSupport,
492
+ layoutSelector,
488
493
  name,
489
494
  elementName,
490
495
  isStyleVariation,
@@ -493,7 +498,7 @@ function getResponsiveStyleNodes(node) {
493
498
  if (!name && !elementName) {
494
499
  return [];
495
500
  }
496
- return Object.entries(RESPONSIVE_BREAKPOINTS).flatMap(
501
+ return Object.entries(responsiveMediaQueries).flatMap(
497
502
  ([breakpointKey, mediaQuery]) => {
498
503
  const breakpointStyles = styles?.[breakpointKey];
499
504
  if (!breakpointStyles || typeof breakpointStyles !== "object") {
@@ -505,10 +510,14 @@ function getResponsiveStyleNodes(node) {
505
510
  selector,
506
511
  mediaQuery,
507
512
  featureSelectors: featureSelectors && typeof featureSelectors !== "string" ? featureSelectors : void 0,
513
+ fallbackGapValue,
514
+ hasLayoutSupport,
508
515
  name,
509
516
  elementName,
510
517
  isStyleVariation,
511
- variationName
518
+ variationName,
519
+ layoutSelector,
520
+ layoutHasBlockGapSupport
512
521
  }
513
522
  ];
514
523
  }
@@ -519,7 +528,8 @@ var getNodesWithStyles = (tree, blockSelectors) => {
519
528
  if (!tree?.styles) {
520
529
  return nodes;
521
530
  }
522
- const styles = pickStyleKeys(tree.styles);
531
+ const responsiveMediaQueries = getResponsiveMediaQueries(tree);
532
+ const styles = pickStyleKeys(tree.styles, responsiveMediaQueries);
523
533
  if (styles) {
524
534
  nodes.push({
525
535
  styles,
@@ -543,7 +553,11 @@ var getNodesWithStyles = (tree, blockSelectors) => {
543
553
  });
544
554
  Object.entries(tree.styles?.blocks ?? {}).forEach(
545
555
  ([blockName, node]) => {
546
- const blockStyles = pickStyleAndPseudoKeys(node, blockName);
556
+ const blockStyles = pickStyleAndPseudoKeys(
557
+ node,
558
+ blockName,
559
+ responsiveMediaQueries
560
+ );
547
561
  const typedNode = node;
548
562
  const variationNodesToAdd = [];
549
563
  const variationStyleNodesToAdd = [];
@@ -553,7 +567,8 @@ var getNodesWithStyles = (tree, blockSelectors) => {
553
567
  const typedVariation = variation;
554
568
  const variationStyles = pickStyleAndPseudoKeys(
555
569
  typedVariation,
556
- blockName
570
+ blockName,
571
+ responsiveMediaQueries
557
572
  );
558
573
  if (typedVariation?.css) {
559
574
  variationStyles.css = typedVariation.css;
@@ -608,7 +623,8 @@ var getNodesWithStyles = (tree, blockSelectors) => {
608
623
  ) : void 0;
609
624
  const variationBlockStyleNodes = pickStyleAndPseudoKeys(
610
625
  variationBlockStyles,
611
- variationBlockName
626
+ variationBlockName,
627
+ responsiveMediaQueries
612
628
  );
613
629
  if (variationBlockStyles?.css) {
614
630
  variationBlockStyleNodes.css = variationBlockStyles.css;
@@ -954,11 +970,15 @@ var transformToStyles = (tree, blockSelectors, hasBlockGapSupport, hasFallbackGa
954
970
  ruleset += "}";
955
971
  }
956
972
  if (options.blockStyles) {
973
+ const responsiveMediaQueries = getResponsiveMediaQueries(tree);
957
974
  nodesWithStyles.forEach((node) => {
958
975
  if (node.isStyleVariation && !options.variationStyles) {
959
976
  return;
960
977
  }
961
- const responsiveNodes = getResponsiveStyleNodes(node);
978
+ const responsiveNodes = getResponsiveStyleNodes(
979
+ node,
980
+ responsiveMediaQueries
981
+ );
962
982
  [
963
983
  node,
964
984
  ...responsiveNodes,