@plaudit/webpack-extensions 2.92.4 → 2.93.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
@@ -60,6 +60,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
60
60
  - Legacy PostCSS features that have been integrated into modern CSS
61
61
  - `@extends` support
62
62
 
63
+ ## [2.93.1] - 2026-07-15
64
+ ### Fixed
65
+ - The new supported features code overriding unintended data in theme.json
66
+
67
+ ## [2.93.0] - 2026-07-15
68
+ ### Added
69
+ - Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
70
+ - This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
71
+ - The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
72
+
63
73
  ## [2.92.4] - 2026-06-10
64
74
  ### Fixed
65
75
  - 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;
@@ -34,6 +35,8 @@ export declare class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEnt
34
35
  static findRelativeRouteBetween(path1: string, path2: string): string;
35
36
  private static remapReferencedPHPFilesOnKey;
36
37
  private static normalizeRenderTemplate;
38
+ private static readonly knownExperimentalProperties;
39
+ private static handleExperimentalBlockSupportsFlags;
37
40
  protected attachUniquePhase(compilation: Compilation): void;
38
41
  protected attachStandardPhase(compilation: Compilation): void;
39
42
  protected deduplicateEntrypointHandles(workableBlockInfo: CollatedWorkableBlockInfo): CollatedWorkableBlockInfo;
@@ -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]);
@@ -228,6 +288,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
228
288
  const pathsNeedRemapping = !this.config.standaloneBlocks && blockJson["plaudit"] !== "simple";
229
289
  EnhancedBlockJSONPlugin.remapReferencedPHPFilesOnKey(blockJson, "setup", pathsNeedRemapping, sourceDir, outputDir, compilation, true);
230
290
  EnhancedBlockJSONPlugin.remapReferencedPHPFilesOnKey(blockJson, "variations", pathsNeedRemapping, sourceDir, outputDir, compilation, false);
291
+ EnhancedBlockJSONPlugin.handleExperimentalBlockSupportsFlags(blockJson);
231
292
  const hashForVersion = EnhancedBlockJSONPlugin
232
293
  .hashThingForAsset([blockJsonText, ...workableBlockEntrypointsInfo.map(bi => bi.hash)].join("~"));
233
294
  if (blockJson["version"]) {
@@ -474,6 +535,28 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
474
535
  }
475
536
  }
476
537
  }
538
+ static knownExperimentalProperties = ['border', 'defaultControls', 'fontFamily', 'fontWeight', 'fontStyle', 'letterSpacing', 'textTransform', 'textDecoration']
539
+ .map(prop => [prop, "__experimental" + prop.substring(0, 1).toUpperCase() + prop.substring(1)]);
540
+ static handleExperimentalBlockSupportsFlags(blockSupports) {
541
+ for (const [key, value] of Object.entries(blockSupports)) {
542
+ if (typeof value === 'object' && !!value && !Array.isArray(value)) {
543
+ EnhancedBlockJSONPlugin.handleExperimentalBlockSupportsFlags(value);
544
+ }
545
+ if (!key.startsWith("__experimental")) {
546
+ continue;
547
+ }
548
+ const realKey = key.substring(14, 15).toLowerCase() + key.substring(15);
549
+ if (!(realKey in blockSupports)) {
550
+ blockSupports[realKey] = value;
551
+ }
552
+ }
553
+ // This handles known currently-experimental properties
554
+ for (const [eventualKey, experimentalKey] of EnhancedBlockJSONPlugin.knownExperimentalProperties) {
555
+ if (eventualKey in blockSupports && !(experimentalKey in blockSupports)) {
556
+ blockSupports[experimentalKey] = blockSupports[eventualKey];
557
+ }
558
+ }
559
+ }
477
560
  attachUniquePhase(compilation) {
478
561
  compilation.hooks.processAssets.tapPromise({ name: `${this.constructor.name}_CompileLoader`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
479
562
  const allSemaphoreData = (await EnhancedBlockJSONPlugin.semaphore.wait())
package/dist/shared.d.ts CHANGED
@@ -147,6 +147,7 @@ export type PlauditWordpressWebpackConfig = {
147
147
  includePostInitFallback?: boolean;
148
148
  omitDistDev?: boolean;
149
149
  onlyRunPostCSSOnPCSS?: boolean;
150
+ useBlockSupportsAsThemeJsonDefaults?: boolean;
150
151
  };
151
152
  export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
152
153
  readonly standard?: "2026-03-13";
@@ -173,6 +174,7 @@ export declare function applyStandards(config: PlauditWordpressWebpackConfig): {
173
174
  readonly includePostInitFallback?: boolean;
174
175
  readonly omitDistDev?: boolean;
175
176
  onlyRunPostCSSOnPCSS?: boolean;
177
+ readonly useBlockSupportsAsThemeJsonDefaults?: boolean;
176
178
  };
177
179
  export declare function resolveStandard(standard: PlauditWordpressWebpackConfig['standard']): {
178
180
  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";
@@ -206,7 +206,7 @@ function buildVerifiedConfig(config) {
206
206
  const cfg = {
207
207
  currentVariables, postcss, standaloneBlocks, stats, variablesFilePath, verbose, externals, assumeGlobalizedPlauditLibraries, processTranslationConfigs, combineAssetMetadata,
208
208
  useWebpackResourceFiltering, outputDir, extensionsVersion, plainEntrypointsVersion, srcDir, srcPrefixes, targetHandlePrefix, useUnifiedLoader, includePostInitFallback, omitDistDev,
209
- onlyRunPostCSSOnPCSS
209
+ onlyRunPostCSSOnPCSS, useBlockSupportsAsThemeJsonDefaults
210
210
  };
211
211
  // Destination -> source map
212
212
  const allocatedDestinations = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.92.4",
3
+ "version": "2.93.1",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",
@@ -31,7 +31,7 @@
31
31
  "@plaudit/gutenberg-api-extensions": "^2.97.1",
32
32
  "@types/browser-sync-webpack-plugin": "^2.2.5",
33
33
  "@types/jsdom": "^28.0.3",
34
- "@types/node": "^25.9.2",
34
+ "@types/node": "^25.9.5",
35
35
  "@types/postcss-functions": "^4.0.4",
36
36
  "@types/tapable": "^2.3.0",
37
37
  "@types/webpack-sources": "^3.2.3",
@@ -39,24 +39,24 @@
39
39
  "webpack-bundle-analyzer": "^4.10.2"
40
40
  },
41
41
  "dependencies": {
42
- "@plaudit/php-writer": "^1.4.5",
42
+ "@plaudit/php-writer": "^1.5.2",
43
43
  "@plaudit/postcss-color-function": "^5.1.0",
44
44
  "@plaudit/postcss-legacy-shorthand": "^1.0.0",
45
45
  "@plaudit/postcss-silent-extend": "^3.0.0",
46
46
  "@plaudit/postcss-strip-units": "^3.0.0",
47
47
  "@plaudit/postcss-variables": "^1.1.0",
48
- "@wordpress/dependency-extraction-webpack-plugin": "^6.48.0",
49
- "@wordpress/scripts": "^32.4.0",
50
- "autoprefixer": "^10.5.0",
48
+ "@wordpress/dependency-extraction-webpack-plugin": "^6.51.0",
49
+ "@wordpress/scripts": "^32.6.0",
50
+ "autoprefixer": "^10.5.3",
51
51
  "browser-sync": "^3.0.4",
52
52
  "copy-webpack-plugin": "10.2.4",
53
53
  "css-minimizer-webpack-plugin": "^6.0.0",
54
54
  "cssnano": "^6.1.2",
55
55
  "fork-ts-checker-webpack-plugin": "^9.1.0",
56
- "http-proxy-middleware": "^3.0.6",
56
+ "http-proxy-middleware": "^3.0.7",
57
57
  "jsdom": "^29.1.1",
58
58
  "json2php": "^0.0.12",
59
- "postcss": "^8.5.15",
59
+ "postcss": "^8.5.19",
60
60
  "postcss-calc": "^9.0.1",
61
61
  "postcss-discard-comments": "^6.0.2",
62
62
  "postcss-functions": "^4.0.2",
@@ -70,7 +70,7 @@
70
70
  "postcss-reporter": "^7.1.0",
71
71
  "postcss-simple-vars": "^7.0.1",
72
72
  "postcss-url": "^10.1.4",
73
- "webpack": "^5.107.2",
73
+ "webpack": "^5.108.4",
74
74
  "webpack-remove-empty-scripts": "^1.1.1",
75
75
  "xml-formatter": "^3.7.0"
76
76
  },