@plaudit/webpack-extensions 2.93.0 → 2.94.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 +8 -0
- 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
|
@@ -60,6 +60,14 @@ 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.94.0] - 2026-07-17
|
|
64
|
+
### Changed
|
|
65
|
+
- 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
|
|
66
|
+
|
|
67
|
+
## [2.93.1] - 2026-07-15
|
|
68
|
+
### Fixed
|
|
69
|
+
- The new supported features code overriding unintended data in theme.json
|
|
70
|
+
|
|
63
71
|
## [2.93.0] - 2026-07-15
|
|
64
72
|
### Added
|
|
65
73
|
- 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) {
|
|
@@ -109,14 +109,19 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
109
109
|
const aPriority = typeof a[1].locations.clientEditor === 'boolean' ? 10 : a[1].locations.clientEditor;
|
|
110
110
|
const bPriority = typeof b[1].locations.clientEditor === 'boolean' ? 10 : b[1].locations.clientEditor;
|
|
111
111
|
return aPriority - bPriority;
|
|
112
|
-
})
|
|
113
|
-
.map(info => info[1].src);
|
|
112
|
+
});
|
|
114
113
|
if (sortedEditorStyleHandles.length > 0) {
|
|
115
114
|
writer.linebreak();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
const editorSettings = new expressions_1.Var("editor_settings");
|
|
116
|
+
writer.filter("block_editor_settings_all", writer => {
|
|
117
|
+
for (const [handle, data] of sortedEditorStyleHandles) {
|
|
118
|
+
const contents = data.inlinedAsset?.contents;
|
|
119
|
+
if (contents) {
|
|
120
|
+
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));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
writer.return(editorSettings);
|
|
124
|
+
}, { functionArgParameters: [editorSettings], accountForAlreadyDoing: false });
|
|
120
125
|
}
|
|
121
126
|
const lazyLoadedHandles = Object.values(handleLists)
|
|
122
127
|
.flatMap(handleList => handleList.map(handle => [handle.data.lazyLoader, handle]))
|
|
@@ -300,7 +305,7 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
|
|
|
300
305
|
const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
|
|
301
306
|
const { lazyLoader, locations } = this.dest;
|
|
302
307
|
const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
|
|
303
|
-
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));
|
|
308
|
+
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));
|
|
304
309
|
const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
|
|
305
310
|
const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
|
|
306
311
|
const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { 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";
|
|
@@ -258,6 +259,7 @@ export declare function resolveLegacyBlockScriptsInFolder(folder: string): strin
|
|
|
258
259
|
* @param file something that represents the file that is being inlined (this is purely for error-reporting purposes)
|
|
259
260
|
*/
|
|
260
261
|
export declare function appendAddInlineAssetCall(compilation: Compilation, writer: PHPWriter, handle: string, type: 'script' | 'style' | 'script_module', inlinedAsset: InlinedAsset, handleData: HandleData, file: string): void;
|
|
262
|
+
export declare function wrapInlineAssetContents(compilation: Compilation, wrapperIdPrefix: string, handle: string, contents: string): HereOrNowDoc;
|
|
261
263
|
export declare function synchronousDirIterator(dirPath: string): Generator<import("node:fs").Dirent<string>, void, unknown>;
|
|
262
264
|
/**
|
|
263
265
|
* A type-guarded version of `instanceof Error` for Node.js.
|
package/dist/shared.js
CHANGED
|
@@ -50,6 +50,7 @@ exports.emitPHPWriterAsAsset = emitPHPWriterAsAsset;
|
|
|
50
50
|
exports.dedent = dedent;
|
|
51
51
|
exports.resolveLegacyBlockScriptsInFolder = resolveLegacyBlockScriptsInFolder;
|
|
52
52
|
exports.appendAddInlineAssetCall = appendAddInlineAssetCall;
|
|
53
|
+
exports.wrapInlineAssetContents = wrapInlineAssetContents;
|
|
53
54
|
exports.synchronousDirIterator = synchronousDirIterator;
|
|
54
55
|
exports.instanceOfNodeError = instanceOfNodeError;
|
|
55
56
|
const node_crypto_1 = require("node:crypto");
|
|
@@ -358,19 +359,18 @@ function appendAddInlineAssetCall(compilation, writer, handle, type, inlinedAsse
|
|
|
358
359
|
if (handleData.rest[0]?.length) { // If there are any dependencies
|
|
359
360
|
compilation.errors.push(newWebpackErrorForFile("Inlined scripts MUST NOT have dependencies. It WILL cause runtime inconsistencies and potentially cause sever performance issues", handleData.src));
|
|
360
361
|
}
|
|
361
|
-
|
|
362
|
-
if (compilation.outputOptions.path?.endsWith("-dev")) {
|
|
363
|
-
contents = inlinedAsset.contents;
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
contents = inlinedAsset.contents.replaceAll(/\/\*#\s+sourceMappingURL=.*?\*\/|\/\/#\s+sourceMappingURL=[^\r\n]*?([\r\n]|$)/gis, "$1");
|
|
367
|
-
}
|
|
368
|
-
const args = [handle, new expressions_1.HereOrNowDoc(`plaudit_inlined_${type}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, contents.trim(), false)];
|
|
362
|
+
const args = [handle, wrapInlineAssetContents(compilation, `plaudit_inlined_${type}`, handle, inlinedAsset.contents)];
|
|
369
363
|
if (type === 'script' && inlinedAsset.position === 'before') {
|
|
370
364
|
args.push('before');
|
|
371
365
|
}
|
|
372
366
|
writer.call(`wp_add_inline_${type}`, args);
|
|
373
367
|
}
|
|
368
|
+
function wrapInlineAssetContents(compilation, wrapperIdPrefix, handle, contents) {
|
|
369
|
+
if (!compilation.outputOptions.path?.endsWith("-dev")) {
|
|
370
|
+
contents = contents.replaceAll(/\/\*#\s+sourceMappingURL=.*?\*\/|\/\/#\s+sourceMappingURL=[^\r\n]*?([\r\n]|$)/gis, "$1");
|
|
371
|
+
}
|
|
372
|
+
return new expressions_1.HereOrNowDoc(`${wrapperIdPrefix}_${(0, node_crypto_1.createHash)('md5').update(handle).digest("hex")}`, contents.trim(), false);
|
|
373
|
+
}
|
|
374
374
|
function* synchronousDirIterator(dirPath) {
|
|
375
375
|
try {
|
|
376
376
|
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": "2.
|
|
3
|
+
"version": "2.94.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",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"webpack-bundle-analyzer": "^4.10.2"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@plaudit/php-writer": "^1.5.
|
|
42
|
+
"@plaudit/php-writer": "^1.5.5",
|
|
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",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@plaudit/postcss-variables": "^1.1.0",
|
|
48
48
|
"@wordpress/dependency-extraction-webpack-plugin": "^6.51.0",
|
|
49
49
|
"@wordpress/scripts": "^32.6.0",
|
|
50
|
-
"autoprefixer": "^10.5.
|
|
50
|
+
"autoprefixer": "^10.5.4",
|
|
51
51
|
"browser-sync": "^3.0.4",
|
|
52
52
|
"copy-webpack-plugin": "10.2.4",
|
|
53
53
|
"css-minimizer-webpack-plugin": "^6.0.0",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
|
56
56
|
"http-proxy-middleware": "^3.0.7",
|
|
57
57
|
"jsdom": "^29.1.1",
|
|
58
|
-
"json2php": "
|
|
58
|
+
"json2php": "0.0.12",
|
|
59
59
|
"postcss": "^8.5.19",
|
|
60
60
|
"postcss-calc": "^9.0.1",
|
|
61
61
|
"postcss-discard-comments": "^6.0.2",
|