@plaudit/webpack-extensions 3.14.0 → 3.15.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 +20 -2
- package/dist/plugins/EnhancedBlockJSONPlugin.d.ts +0 -1
- package/dist/plugins/EnhancedBlockJSONPlugin.js +28 -13
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +12 -7
- package/dist/shared.d.ts +2 -0
- package/dist/shared.js +8 -8
- package/dist/utils/path-query-and-related-helpers.d.ts +2 -1
- package/dist/utils/path-query-and-related-helpers.js +6 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,13 +5,23 @@ 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.15.0] - 2026-07-17
|
|
9
|
+
### Changed
|
|
10
|
+
- The `add_editor_style()` enqueue path to use `block_editor_settings_all` to avoid a litany of bugs courtesy of WordPress's high-quality code
|
|
11
|
+
- This comes from version `2.94.0`
|
|
12
|
+
|
|
13
|
+
## [3.14.1] - 2026-07-15
|
|
14
|
+
### Fixed
|
|
15
|
+
- The new supported features code overriding unintended data in theme.json
|
|
16
|
+
- This comes from version `2.93.1`
|
|
17
|
+
|
|
8
18
|
## [3.14.0] - 2026-07-15
|
|
9
19
|
### Added
|
|
10
20
|
- 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
21
|
- This uses filters to achieve the "defaulting", which means that it's plugin and theme agnostic
|
|
12
|
-
- This comes from version `2.
|
|
22
|
+
- This comes from version `2.93.0`
|
|
13
23
|
- The `useBlockSupportsAsThemeJsonDefaults` flag to allow the new logic to be disabled
|
|
14
|
-
- This comes from version `2.
|
|
24
|
+
- This comes from version `2.93.0`
|
|
15
25
|
|
|
16
26
|
## [3.13.0] - 2026-07-14
|
|
17
27
|
### Added
|
|
@@ -204,6 +214,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
204
214
|
- Legacy PostCSS features that have been integrated into modern CSS
|
|
205
215
|
- `@extends` support
|
|
206
216
|
|
|
217
|
+
## [2.94.0] - 2026-07-17
|
|
218
|
+
### Changed
|
|
219
|
+
- The `add_editor_style()` enqueue path to use `block_editor_settings_all` to avoid a litany of bugs courtesy of WordPress's high-quality code
|
|
220
|
+
|
|
221
|
+
## [2.93.1] - 2026-07-15
|
|
222
|
+
### Fixed
|
|
223
|
+
- The new supported features code overriding unintended data in theme.json
|
|
224
|
+
|
|
207
225
|
## [2.93.0] - 2026-07-15
|
|
208
226
|
### Added
|
|
209
227
|
- Logic to emit code that makes the supported features declared in block.json file the defaults for those blocks in the "theme.json" file
|
|
@@ -22,7 +22,6 @@ 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
25
|
private static pickOutFlagPropsFromBlockSupports;
|
|
27
26
|
private callRegisterFunction;
|
|
28
27
|
private transformBlocks;
|
|
@@ -227,25 +227,40 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
|
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
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'];
|
|
230
|
+
// private static readonly IGNORED_THEME_JSON_FLAG_PROPS = ['align', 'alignWide', 'anchor', 'contentRole', 'inserter', 'interactivity', 'listView', 'plaudit'];
|
|
231
231
|
static pickOutFlagPropsFromBlockSupports(supports) {
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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;
|
|
241
246
|
}
|
|
242
247
|
}
|
|
243
|
-
|
|
244
|
-
|
|
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
|
+
}
|
|
245
260
|
}
|
|
246
261
|
}
|
|
247
262
|
}
|
|
248
|
-
return
|
|
263
|
+
return addedProp ? res : undefined;
|
|
249
264
|
}
|
|
250
265
|
callRegisterFunction(type, writer, baseUriVar, handles) {
|
|
251
266
|
for (const [name, { src, rest }] of handles) {
|
|
@@ -101,14 +101,19 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
101
101
|
const aPriority = typeof a[1].locations.clientEditor === 'boolean' ? 10 : a[1].locations.clientEditor;
|
|
102
102
|
const bPriority = typeof b[1].locations.clientEditor === 'boolean' ? 10 : b[1].locations.clientEditor;
|
|
103
103
|
return aPriority - bPriority;
|
|
104
|
-
})
|
|
105
|
-
.map(info => info[1].src);
|
|
104
|
+
});
|
|
106
105
|
if (sortedEditorStyleHandles.length > 0) {
|
|
107
106
|
writer.linebreak();
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
const editorSettings = new expressions_1.Var("editor_settings");
|
|
108
|
+
writer.filter("block_editor_settings_all", writer => {
|
|
109
|
+
for (const [handle, data] of sortedEditorStyleHandles) {
|
|
110
|
+
const contents = data.inlinedAsset?.contents;
|
|
111
|
+
if (contents) {
|
|
112
|
+
writer.appendExpr(new expressions_1.Assignment(new expressions_1.ArrayAccess(editorSettings, "styles"), new expressions_1.PHPArray({ css: (0, shared_1.wrapInlineAssetContents)(compilation, "plaudit_editor_style", handle, contents) }), true));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
writer.return(editorSettings);
|
|
116
|
+
}, { functionArgParameters: [editorSettings], accountForAlreadyDoing: false });
|
|
112
117
|
}
|
|
113
118
|
const lazyLoadedHandles = Object.values(handleLists)
|
|
114
119
|
.flatMap(handleList => handleList.map(handle => [handle.data.lazyLoader, handle]))
|
|
@@ -297,7 +302,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
297
302
|
const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
|
|
298
303
|
const { lazyLoader, locations } = this.dest;
|
|
299
304
|
const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
|
|
300
|
-
const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags));
|
|
305
|
+
const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags), type === 'style' && (!!locations.clientEditor || locations.clientEditor === 0));
|
|
301
306
|
const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
|
|
302
307
|
const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
|
|
303
308
|
const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PHPFile, PHPWriter } from "@plaudit/php-writer";
|
|
2
|
+
import { HereOrNowDoc } from "@plaudit/php-writer/expressions";
|
|
2
3
|
import type { Options as PostcssFunctionsOptions } from "postcss-functions";
|
|
3
4
|
import { type AssetInfo, type Compilation, type Configuration, type Entrypoint, WebpackError, type Compiler } from "webpack";
|
|
4
5
|
import { SourceType } from "./utils/entrypoint-resolution-logic";
|
|
@@ -264,6 +265,7 @@ export declare function resolveLegacyBlockScriptsInFolder(folder: string): strin
|
|
|
264
265
|
* @param file something that represents the file that is being inlined (this is purely for error-reporting purposes)
|
|
265
266
|
*/
|
|
266
267
|
export declare function appendAddInlineAssetCall(compilation: Compilation, writer: PHPWriter, handle: string, type: 'script' | 'style' | 'script_module', inlinedAsset: InlinedAsset, handleData: HandleData, file: string): void;
|
|
268
|
+
export declare function wrapInlineAssetContents(compilation: Compilation, wrapperIdPrefix: string, handle: string, contents: string): HereOrNowDoc;
|
|
267
269
|
export declare function synchronousDirIterator(dirPath: string): Generator<import("node:fs").Dirent<string>, void, unknown>;
|
|
268
270
|
/**
|
|
269
271
|
* A type-guarded version of `instanceof Error` for Node.js.
|
package/dist/shared.js
CHANGED
|
@@ -52,6 +52,7 @@ exports.emitPHPWriterAsAsset = emitPHPWriterAsAsset;
|
|
|
52
52
|
exports.dedent = dedent;
|
|
53
53
|
exports.resolveLegacyBlockScriptsInFolder = resolveLegacyBlockScriptsInFolder;
|
|
54
54
|
exports.appendAddInlineAssetCall = appendAddInlineAssetCall;
|
|
55
|
+
exports.wrapInlineAssetContents = wrapInlineAssetContents;
|
|
55
56
|
exports.synchronousDirIterator = synchronousDirIterator;
|
|
56
57
|
exports.instanceOfNodeError = instanceOfNodeError;
|
|
57
58
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -400,19 +401,18 @@ function appendAddInlineAssetCall(compilation, writer, handle, type, inlinedAsse
|
|
|
400
401
|
if (handleData.rest[0]?.length) { // If there are any dependencies
|
|
401
402
|
compilation.errors.push(newWebpackErrorForFile("Inlined scripts MUST NOT have dependencies. It WILL cause runtime inconsistencies and potentially cause sever performance issues", handleData.src));
|
|
402
403
|
}
|
|
403
|
-
|
|
404
|
-
if (compilation.outputOptions.path?.endsWith("-dev")) {
|
|
405
|
-
contents = inlinedAsset.contents;
|
|
406
|
-
}
|
|
407
|
-
else {
|
|
408
|
-
contents = inlinedAsset.contents.replaceAll(/\/\*#\s+sourceMappingURL=.*?\*\/|\/\/#\s+sourceMappingURL=[^\r\n]*?([\r\n]|$)/gis, "$1");
|
|
409
|
-
}
|
|
410
|
-
const args = [handle, new expressions_1.HereOrNowDoc(`plaudit_inlined_${type}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, contents.trim(), false)];
|
|
404
|
+
const args = [handle, wrapInlineAssetContents(compilation, `plaudit_inlined_${type}`, handle, inlinedAsset.contents)];
|
|
411
405
|
if (type === 'script' && inlinedAsset.position === 'before') {
|
|
412
406
|
args.push('before');
|
|
413
407
|
}
|
|
414
408
|
writer.call(`wp_add_inline_${type}`, args);
|
|
415
409
|
}
|
|
410
|
+
function wrapInlineAssetContents(compilation, wrapperIdPrefix, handle, contents) {
|
|
411
|
+
if (!compilation.outputOptions.path?.endsWith("-dev")) {
|
|
412
|
+
contents = contents.replaceAll(/\/\*#\s+sourceMappingURL=.*?\*\/|\/\/#\s+sourceMappingURL=[^\r\n]*?([\r\n]|$)/gis, "$1");
|
|
413
|
+
}
|
|
414
|
+
return new expressions_1.HereOrNowDoc(`${wrapperIdPrefix}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, contents.trim(), false);
|
|
415
|
+
}
|
|
416
416
|
function* synchronousDirIterator(dirPath) {
|
|
417
417
|
try {
|
|
418
418
|
using dir = (0, node_fs_1.opendirSync)(dirPath);
|
|
@@ -51,8 +51,9 @@ export declare function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQ
|
|
|
51
51
|
* @param compilation
|
|
52
52
|
* @param file
|
|
53
53
|
* @param flags
|
|
54
|
+
* @param forceRecordContents
|
|
54
55
|
*/
|
|
55
|
-
export declare function convertEnqueuingControlFlagsToScriptArgsObject(compilation: Compilation, file: string, flags: NormalizedEnqueuingControlFlags | undefined): {
|
|
56
|
+
export declare function convertEnqueuingControlFlagsToScriptArgsObject(compilation: Compilation, file: string, flags: NormalizedEnqueuingControlFlags | undefined, forceRecordContents?: boolean): {
|
|
56
57
|
scriptArgsObject?: ScriptArgsObject;
|
|
57
58
|
inlinedAsset?: InlinedAsset;
|
|
58
59
|
};
|
|
@@ -192,8 +192,9 @@ function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters,
|
|
|
192
192
|
* @param compilation
|
|
193
193
|
* @param file
|
|
194
194
|
* @param flags
|
|
195
|
+
* @param forceRecordContents
|
|
195
196
|
*/
|
|
196
|
-
function convertEnqueuingControlFlagsToScriptArgsObject(compilation, file, flags) {
|
|
197
|
+
function convertEnqueuingControlFlagsToScriptArgsObject(compilation, file, flags, forceRecordContents = false) {
|
|
197
198
|
if (flags === undefined) {
|
|
198
199
|
return {};
|
|
199
200
|
}
|
|
@@ -245,11 +246,14 @@ function convertEnqueuingControlFlagsToScriptArgsObject(compilation, file, flags
|
|
|
245
246
|
scriptArgsObject.in_footer = true;
|
|
246
247
|
}
|
|
247
248
|
}
|
|
249
|
+
else if (forceRecordContents) {
|
|
250
|
+
inlinedAsset = { contents: getAssetFileContents(compilation, file) };
|
|
251
|
+
}
|
|
248
252
|
if (fetchpriority !== undefined) {
|
|
249
253
|
if (!isValidFetchPriority(fetchpriority)) {
|
|
250
254
|
throw newInvalidFetchPriorityError(fetchpriority, file);
|
|
251
255
|
}
|
|
252
|
-
if (
|
|
256
|
+
if (inline) {
|
|
253
257
|
compilation.warnings.push((0, shared_1.newWebpackErrorForFile)("Fetchpriority has no effect on inlined assets", file));
|
|
254
258
|
}
|
|
255
259
|
scriptArgsObject.fetchpriority = fetchpriority;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.15.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"files": [
|
|
6
6
|
"/dist",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@plaudit/gutenberg-api-extensions": "^2.
|
|
31
|
+
"@plaudit/gutenberg-api-extensions": "^2.98.0",
|
|
32
32
|
"@types/browser-sync-webpack-plugin": "^2.2.5",
|
|
33
33
|
"@types/jsdom": "^28.0.3",
|
|
34
34
|
"@types/node": "^25.9.5",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"webpack-bundle-analyzer": "^5.3.1"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@plaudit/php-writer": "^1.5.
|
|
45
|
+
"@plaudit/php-writer": "^1.5.5",
|
|
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
49
|
"@wordpress/dependency-extraction-webpack-plugin": "^6.51.0",
|
|
50
50
|
"@wordpress/scripts": "^32.6.0",
|
|
51
|
-
"autoprefixer": "^10.5.
|
|
51
|
+
"autoprefixer": "^10.5.4",
|
|
52
52
|
"browser-sync": "^3.0.4",
|
|
53
53
|
"copy-webpack-plugin": "10.2.4",
|
|
54
54
|
"css-minimizer-webpack-plugin": "^8.0.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
57
57
|
"http-proxy-middleware": "^3.0.7",
|
|
58
58
|
"jsdom": "^29.1.1",
|
|
59
|
-
"json2php": "
|
|
59
|
+
"json2php": "0.0.12",
|
|
60
60
|
"postcss": "^8.5.19",
|
|
61
61
|
"postcss-calc": "^10.1.1",
|
|
62
62
|
"postcss-functions": "^4.0.2",
|