@plaudit/webpack-extensions 3.12.5 → 3.14.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/CHANGELOG.md CHANGED
@@ -5,6 +5,18 @@ 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.0] - 2026-07-15
9
+ ### Added
10
+ - Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
11
+ - This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
12
+ - This comes from version `2.92.4`
13
+ - The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
14
+ - This comes from version `2.92.4`
15
+
16
+ ## [3.13.0] - 2026-07-14
17
+ ### Added
18
+ - Support for using some "experimental" properties early (primarily `border`)
19
+
8
20
  ## [3.12.5] - 2026-07-07
9
21
  ### Fixed
10
22
  - `PlainEntrypointsConfigFileGeneratorPlugin` not handling niceName-based handles correctly
@@ -192,6 +204,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
192
204
  - Legacy PostCSS features that have been integrated into modern CSS
193
205
  - `@extends` support
194
206
 
207
+ ## [2.93.0] - 2026-07-15
208
+ ### Added
209
+ - Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
210
+ - This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
211
+ - The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
212
+
195
213
  ## [2.92.4] - 2026-06-10
196
214
  ### Fixed
197
215
  - Libraries externalizing in a way that does not account for the variable potentially being undeclared
@@ -22,6 +22,8 @@ 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 readonly IGNORED_THEME_JSON_FLAG_PROPS;
26
+ private static pickOutFlagPropsFromBlockSupports;
25
27
  private callRegisterFunction;
26
28
  private transformBlocks;
27
29
  private static extractAssetSource;
@@ -34,6 +36,8 @@ export declare class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEnt
34
36
  static findRelativeRouteBetween(path1: string, path2: string): string;
35
37
  private static remapReferencedPHPFilesOnKey;
36
38
  private static normalizeRenderTemplate;
39
+ private static readonly knownExperimentalProperties;
40
+ private static handleExperimentalBlockSupportsFlags;
37
41
  protected attachUniquePhase(compilation: Compilation): void;
38
42
  protected attachStandardPhase(compilation: Compilation): void;
39
43
  protected deduplicateEntrypointHandles(workableBlockInfo: CollatedWorkableBlockInfo): CollatedWorkableBlockInfo;
@@ -196,12 +196,57 @@ 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
+ static IGNORED_THEME_JSON_FLAG_PROPS = ['align', 'alignWide', 'anchor', 'contentRole', 'interactivity', 'listView', 'plaudit'];
231
+ static pickOutFlagPropsFromBlockSupports(supports) {
232
+ const entries = [];
233
+ for (const [key, value] of Object.entries(supports)) {
234
+ if (!key.startsWith("__") && !EnhancedBlockJSONPlugin.IGNORED_THEME_JSON_FLAG_PROPS.includes(key) && value) {
235
+ if (typeof value === 'object') {
236
+ if (!Array.isArray(value)) {
237
+ const v = EnhancedBlockJSONPlugin.pickOutFlagPropsFromBlockSupports(value);
238
+ if (v !== undefined) {
239
+ entries.push([key, v]);
240
+ }
241
+ }
242
+ }
243
+ else if (typeof value === 'boolean') {
244
+ entries.push([key, true]);
245
+ }
246
+ }
247
+ }
248
+ return entries.length > 0 ? Object.fromEntries(entries) : undefined;
249
+ }
205
250
  callRegisterFunction(type, writer, baseUriVar, handles) {
206
251
  for (const [name, { src, rest }] of handles) {
207
252
  writer.call(`wp_register_${type}`, [name, src === false ? false : expressions_1.Op.concat(baseUriVar, src), ...rest]);
@@ -228,6 +273,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
228
273
  const pathsNeedRemapping = !this.config.standaloneBlocks && blockJson["plaudit"] !== "simple";
229
274
  EnhancedBlockJSONPlugin.remapReferencedPHPFilesOnKey(blockJson, "setup", pathsNeedRemapping, sourceDir, outputDir, compilation, true);
230
275
  EnhancedBlockJSONPlugin.remapReferencedPHPFilesOnKey(blockJson, "variations", pathsNeedRemapping, sourceDir, outputDir, compilation, false);
276
+ EnhancedBlockJSONPlugin.handleExperimentalBlockSupportsFlags(blockJson);
231
277
  const hashForVersion = EnhancedBlockJSONPlugin
232
278
  .hashThingForAsset([blockJsonText, ...workableBlockEntrypointsInfo.map(bi => bi.hash)].join("~"));
233
279
  if (blockJson["version"]) {
@@ -474,6 +520,28 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
474
520
  }
475
521
  }
476
522
  }
523
+ static knownExperimentalProperties = ['border', 'defaultControls', 'fontFamily', 'fontWeight', 'fontStyle', 'letterSpacing', 'textTransform', 'textDecoration']
524
+ .map(prop => [prop, "__experimental" + prop.substring(0, 1).toUpperCase() + prop.substring(1)]);
525
+ static handleExperimentalBlockSupportsFlags(blockSupports) {
526
+ for (const [key, value] of Object.entries(blockSupports)) {
527
+ if (typeof value === 'object' && !!value && !Array.isArray(value)) {
528
+ EnhancedBlockJSONPlugin.handleExperimentalBlockSupportsFlags(value);
529
+ }
530
+ if (!key.startsWith("__experimental")) {
531
+ continue;
532
+ }
533
+ const realKey = key.substring(14, 15).toLowerCase() + key.substring(15);
534
+ if (!(realKey in blockSupports)) {
535
+ blockSupports[realKey] = value;
536
+ }
537
+ }
538
+ // This handles known currently-experimental properties
539
+ for (const [eventualKey, experimentalKey] of EnhancedBlockJSONPlugin.knownExperimentalProperties) {
540
+ if (eventualKey in blockSupports && !(experimentalKey in blockSupports)) {
541
+ blockSupports[experimentalKey] = blockSupports[eventualKey];
542
+ }
543
+ }
544
+ }
477
545
  attachUniquePhase(compilation) {
478
546
  compilation.hooks.processAssets.tapPromise({ name: `${this.constructor.name}_CompileLoader`, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
479
547
  const allSemaphoreData = (await EnhancedBlockJSONPlugin.semaphore.wait())
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.12.5",
3
+ "version": "3.14.0",
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.4",
34
+ "@types/node": "^25.9.5",
35
35
  "@types/postcss-functions": "^4.0.4",
36
36
  "@types/postcss-import": "^14.0.3",
37
37
  "@types/tapable": "^2.3.0",
@@ -39,16 +39,16 @@
39
39
  "react": "^18.3.1",
40
40
  "react-dom": "^18.3.1",
41
41
  "typescript": "^6.0.3",
42
- "webpack-bundle-analyzer": "^5.3.0"
42
+ "webpack-bundle-analyzer": "^5.3.1"
43
43
  },
44
44
  "dependencies": {
45
45
  "@plaudit/php-writer": "^1.5.2",
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",
@@ -57,7 +57,7 @@
57
57
  "http-proxy-middleware": "^3.0.7",
58
58
  "jsdom": "^29.1.1",
59
59
  "json2php": "^0.0.12",
60
- "postcss": "^8.5.16",
60
+ "postcss": "^8.5.19",
61
61
  "postcss-calc": "^10.1.1",
62
62
  "postcss-functions": "^4.0.2",
63
63
  "postcss-import": "^16.1.1",