@plaudit/webpack-extensions 3.13.0 → 3.14.1

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/CHANGELOG.md CHANGED
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.14.1] - 2026-07-15
9
+ ### Fixed
10
+ - The new supported features code overriding unintended data in theme.json
11
+ - This comes from version `2.93.1`
12
+
13
+ ## [3.14.0] - 2026-07-15
14
+ ### Added
15
+ - Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
16
+ - This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
17
+ - This comes from version `2.93.0`
18
+ - The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
19
+ - This comes from version `2.93.0`
20
+
8
21
  ## [3.13.0] - 2026-07-14
9
22
  ### Added
10
23
  - Support for using some "experimental" properties early (primarily `border`)
@@ -196,6 +209,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
196
209
  - Legacy PostCSS features that have been integrated into modern CSS
197
210
  - `@extends` support
198
211
 
212
+ ## [2.93.1] - 2026-07-15
213
+ ### Fixed
214
+ - The new supported features code overriding unintended data in theme.json
215
+
216
+ ## [2.93.0] - 2026-07-15
217
+ ### Added
218
+ - Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
219
+ - This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
220
+ - The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
221
+
199
222
  ## [2.92.4] - 2026-06-10
200
223
  ### Fixed
201
224
  - Libraries externalizing in a way that does not account for the variable potentially being undeclared
@@ -22,6 +22,7 @@ export declare class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEnt
22
22
  constructor(config: VerifiedPlauditWordpressWebpackConfig, dest: VerifiedAdvancedOutputConfig, webpackRemoveEmptyScriptsPlugin: WebpackRemoveEmptyScriptsPlugin, context: string, entry: EntryProvider<BlockEntrypointInfo>);
23
23
  protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): Promise<void>;
24
24
  private emitBlockLoaderFile;
25
+ private static pickOutFlagPropsFromBlockSupports;
25
26
  private callRegisterFunction;
26
27
  private transformBlocks;
27
28
  private static extractAssetSource;
@@ -196,12 +196,72 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
196
196
  (0, shared_1.appendAddInlineAssetCall)(compilation, writer, ...inlinableStyle);
197
197
  }
198
198
  }, { accountForAlreadyDoing: this.config.includePostInitFallback });
199
+ if (this.config.useBlockSupportsAsThemeJsonDefaults) {
200
+ const copyableBlockSupports = [];
201
+ for (const { name, supports } of Object.values(blockData)) {
202
+ if (typeof name === 'string' && !!name && typeof supports === 'object' && !!supports && !Array.isArray(supports)) {
203
+ const flagProps = EnhancedBlockJSONPlugin.pickOutFlagPropsFromBlockSupports(supports);
204
+ if (flagProps) {
205
+ copyableBlockSupports.push([name, flagProps]);
206
+ }
207
+ }
208
+ }
209
+ if (copyableBlockSupports.length > 0) {
210
+ const themeJsonBlockSettings = new expressions_1.EnclosedLiteral((0, shared_1.makeEmittableConfigPHP)({
211
+ version: 3,
212
+ settings: {
213
+ blocks: Object.fromEntries(copyableBlockSupports)
214
+ }
215
+ }, false, "\t"));
216
+ const theme_json = new expressions_1.Var("theme_json");
217
+ writer.filter('wp_theme_json_data_blocks', writer => {
218
+ const updateCall = new expressions_1.Call(expressions_1.Literal.of("update_with", true), [themeJsonBlockSettings]);
219
+ writer.appendExpr(new expressions_1.InstanceAccess(theme_json, [updateCall]), { return: true });
220
+ }, { functionArgParameters: [theme_json] });
221
+ }
222
+ }
199
223
  (0, shared_1.emitPHPWriterAsAsset)(writer, compilation, (0, node_path_1.join)(this.dest.destination, "blockdir-loader.php"));
200
224
  }
201
225
  else {
202
226
  compilation.emitAsset((0, node_path_1.join)(this.dest.destination, "blockdir.config.php"), new webpack_1.sources.RawSource((0, shared_1.makeEmittableConfigPHP)(blockDirConfig, true)));
203
227
  }
204
228
  }
229
+ // This isn't strictly necessary, but it allows us to trivially eliminate commonly-used block supports flags that aren't used in theme.json
230
+ // private static readonly IGNORED_THEME_JSON_FLAG_PROPS = ['align', 'alignWide', 'anchor', 'contentRole', 'inserter', 'interactivity', 'listView', 'plaudit'];
231
+ static pickOutFlagPropsFromBlockSupports(supports) {
232
+ function isRecord(value) {
233
+ return typeof value === 'object' && !!value && !Array.isArray(value);
234
+ }
235
+ let addedProp = false;
236
+ const res = {};
237
+ if ('color' in supports) {
238
+ const color = supports.color;
239
+ if (isRecord(color)) {
240
+ const colorFlags = {};
241
+ for (const prop of ['background', 'link', 'text']) {
242
+ if (supports[prop]) {
243
+ colorFlags[prop] = true;
244
+ res.color = colorFlags;
245
+ addedProp = true;
246
+ }
247
+ }
248
+ }
249
+ }
250
+ if ('dimensions' in supports) {
251
+ const dimensions = supports.dimensions;
252
+ if (isRecord(dimensions)) {
253
+ const dimensionsFlags = {};
254
+ for (const prop of ['aspectRatio']) {
255
+ if (supports[prop]) {
256
+ dimensionsFlags[prop] = true;
257
+ res.color = dimensionsFlags;
258
+ addedProp = true;
259
+ }
260
+ }
261
+ }
262
+ }
263
+ return addedProp ? res : undefined;
264
+ }
205
265
  callRegisterFunction(type, writer, baseUriVar, handles) {
206
266
  for (const [name, { src, rest }] of handles) {
207
267
  writer.call(`wp_register_${type}`, [name, src === false ? false : expressions_1.Op.concat(baseUriVar, src), ...rest]);
package/dist/shared.d.ts CHANGED
@@ -150,6 +150,7 @@ export type PlauditWordpressWebpackConfig = {
150
150
  omitDistDev?: boolean;
151
151
  onlyRunPostCSSOnPCSS?: boolean;
152
152
  targetNamespace?: string;
153
+ useBlockSupportsAsThemeJsonDefaults?: boolean;
153
154
  };
154
155
  export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
155
156
  readonly standard?: "2026-03-13";
@@ -177,6 +178,7 @@ export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
177
178
  readonly omitDistDev?: boolean;
178
179
  onlyRunPostCSSOnPCSS?: boolean;
179
180
  readonly targetNamespace?: string;
181
+ readonly useBlockSupportsAsThemeJsonDefaults?: boolean;
180
182
  };
181
183
  export declare function resolveStandard(standard: PlauditWordpressWebpackConfig['standard']): {
182
184
  readonly useWebpackResourceFiltering: true;
@@ -167,7 +167,7 @@ function injectSupportForInliningSVGsAsStrings(rules) {
167
167
  }
168
168
  function buildVerifiedConfig(config) {
169
169
  config = (0, shared_1.applyStandards)(config);
170
- const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false, onlyRunPostCSSOnPCSS = false } = config;
170
+ const { standaloneBlocks = false, stats = 'errors-warnings', variables: rawVariables, verbose = process.argv.includes('--verbose') || process.env['VERBOSE'] === 'true', postcss = {}, externals, assumeGlobalizedPlauditLibraries = true, processTranslationConfigs = true, combineAssetMetadata = true, useWebpackResourceFiltering = true, plainEntrypointsVersion = 1, srcDir = "", useUnifiedLoader = false, includePostInitFallback = false, omitDistDev = false, onlyRunPostCSSOnPCSS = false, useBlockSupportsAsThemeJsonDefaults = true, } = config;
171
171
  let outputDir = config.outputDir ?? "";
172
172
  if (outputDir && useUnifiedLoader && !omitDistDev && (process.env['SERVER_MODE'] ?? 'development') === 'development') {
173
173
  outputDir += "-dev";
@@ -207,7 +207,7 @@ function buildVerifiedConfig(config) {
207
207
  const cfg = {
208
208
  currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
209
209
  useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback, omitDistDev,
210
- onlyRunPostCSSOnPCSS, targetNamespace
210
+ onlyRunPostCSSOnPCSS, targetNamespace, useBlockSupportsAsThemeJsonDefaults
211
211
  };
212
212
  // Destination -> source map
213
213
  const allocatedDestinations = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "3.13.0",
3
+ "version": "3.14.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -46,9 +46,9 @@
46
46
  "@plaudit/postcss-color-function": "^5.1.0",
47
47
  "@plaudit/postcss-strip-units": "^3.0.0",
48
48
  "@plaudit/postcss-variables": "^2.0.1",
49
- "@wordpress/dependency-extraction-webpack-plugin": "^6.50.0",
49
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.51.0",
50
50
  "@wordpress/scripts": "^32.6.0",
51
- "autoprefixer": "^10.5.2",
51
+ "autoprefixer": "^10.5.3",
52
52
  "browser-sync": "^3.0.4",
53
53
  "copy-webpack-plugin": "10.2.4",
54
54
  "css-minimizer-webpack-plugin": "^8.0.0",