@plaudit/webpack-extensions 2.40.0 → 2.42.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.
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const json2php_1 = __importDefault(require("json2php"));
|
|
9
10
|
const webpack_1 = require("webpack");
|
|
10
|
-
const php_serializer_1 = __importDefault(require("./php-serializer"));
|
|
11
11
|
class BlockJSONManagingPlugin {
|
|
12
12
|
standaloneBlocks;
|
|
13
13
|
processingModules;
|
|
@@ -408,14 +408,17 @@ class BlockJSONManagingPlugin {
|
|
|
408
408
|
}
|
|
409
409
|
sortedBlockDirConfigData = Object.fromEntries([
|
|
410
410
|
["__metadata", { version: 2, ...Object.fromEntries(this.additionalMetadata.entries()), scriptHandles, styleHandles }],
|
|
411
|
-
...blockDirConfigs
|
|
411
|
+
...blockDirConfigs.map(entry => [entry[0], Object.fromEntries(Object.entries(entry[1]).filter(e => e[0] !== '$schema'))])
|
|
412
412
|
]);
|
|
413
413
|
compilation.deleteAsset("assets.json");
|
|
414
414
|
}
|
|
415
415
|
else {
|
|
416
|
-
sortedBlockDirConfigData = Object.fromEntries([
|
|
416
|
+
sortedBlockDirConfigData = Object.fromEntries([
|
|
417
|
+
["__metadata", { version: 1, ...Object.fromEntries(this.additionalMetadata.entries()) }],
|
|
418
|
+
...blockDirConfigs.map(entry => [entry[0], Object.fromEntries(Object.entries(entry[1]).filter(e => e[0] !== '$schema'))])
|
|
419
|
+
]);
|
|
417
420
|
}
|
|
418
|
-
compilation.emitAsset("blockdir.config", new webpack_1.sources.RawSource(
|
|
421
|
+
compilation.emitAsset("blockdir.config.php", new webpack_1.sources.RawSource("<?php return " + json2php_1.default.make({ stripSpaces: true, indent: "\t", linebreak: "\n", shortArraySyntax: true })(sortedBlockDirConfigData, "") + ";"));
|
|
419
422
|
});
|
|
420
423
|
}
|
|
421
424
|
static normalizeRenderTemplate(json, pathsNeedRemapping, sourceDir, outputDir, compilation) {
|
|
@@ -27,7 +27,7 @@ class WPMLConfigBuilder {
|
|
|
27
27
|
Promise.all(entrypoint.origins.map(origin => origin.request).filter(request => request.endsWith("wpml-config.xml"))
|
|
28
28
|
.map(async (request) => this.loadWPMLConfigXML(request, compilation))),
|
|
29
29
|
Promise.all(entrypoint.origins.map(origin => origin.request).filter(request => request.endsWith("block.json"))
|
|
30
|
-
.map(async (request) =>
|
|
30
|
+
.map(async (request) => JSON.parse(await promises_1.default.readFile(request, 'utf8'))))
|
|
31
31
|
]);
|
|
32
32
|
for (const name of Object.keys(assets)) {
|
|
33
33
|
if (name.startsWith("wpml-config.xml")) {
|
|
@@ -71,12 +71,12 @@ class WPMLConfigBuilder {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
for (const [blockJson
|
|
74
|
+
for (const [blockJson] of blockJsons) {
|
|
75
75
|
const type = blockJson["name"]?.toString();
|
|
76
76
|
if (typeof type !== 'string') {
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
|
-
const blockConfig = { type, translate: '1', keys: [], xPaths: [] };
|
|
79
|
+
const blockConfig = { type, translate: blockJson['supports']?.['translation'] ?? true ? '1' : '0', keys: [], xPaths: [] };
|
|
80
80
|
if (blockJson['plaudit']?.['properties']) {
|
|
81
81
|
const snps = blockJson['plaudit']['properties'];
|
|
82
82
|
if (Array.isArray(snps)) {
|
|
@@ -5,7 +5,7 @@ interface AdvancedOutputConfig {
|
|
|
5
5
|
destination: string;
|
|
6
6
|
withLegacyBlocksIn?: string | undefined;
|
|
7
7
|
additionalDependencies?: string[];
|
|
8
|
-
directoryLayout?: 'blocks' | 'extensions';
|
|
8
|
+
directoryLayout?: 'blocks' | 'extensions' | 'plain';
|
|
9
9
|
assumeGlobalizedPlauditLibraries?: boolean;
|
|
10
10
|
}
|
|
11
11
|
type PlauditWordpressWebpackConfig = {
|
|
@@ -314,7 +314,7 @@ function processIndividualWebpackConfig(config, webpackConfig, sources) {
|
|
|
314
314
|
if (variablesFilePath) {
|
|
315
315
|
plugins.push(new VariablesJSMonitorPlugin_1.default(variablesFilePath));
|
|
316
316
|
}
|
|
317
|
-
const forBlocksDirectory = copyFiles && (typeof dest === 'string' || dest.directoryLayout !== 'extensions');
|
|
317
|
+
const forBlocksDirectory = copyFiles && (typeof dest === 'string' || (dest.directoryLayout !== 'extensions' && dest.directoryLayout !== 'plain'));
|
|
318
318
|
if (forBlocksDirectory) {
|
|
319
319
|
const blockJSONManagingPlugin = new BlockJSONManagingPlugin_1.default(standaloneBlocks, processingModules);
|
|
320
320
|
plugins.push(blockJSONManagingPlugin);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plaudit/webpack-extensions",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.42.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"prepublishOnly": "rm -rf build && mkdir build && tsc",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"eslint-plugin-jsdoc": "^48.11.0",
|
|
50
50
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
51
51
|
"http-proxy-middleware": "^3.0.3",
|
|
52
|
+
"json2php": "^0.0.12",
|
|
52
53
|
"postcss": "^8.5.3",
|
|
53
54
|
"postcss-calc": "^9.0.1",
|
|
54
55
|
"postcss-discard-comments": "^6.0.2",
|