@plaudit/webpack-extensions 3.21.2 → 4.0.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 +13 -1
- package/USER-GUIDE.md +2 -1
- package/dist/api/asset-information-emission.d.ts +74 -0
- package/dist/api/asset-information-emission.d.ts.map +1 -0
- package/dist/api/asset-information-emission.js +398 -0
- package/dist/api/asset-information-emission.js.map +1 -0
- package/dist/api/configuration.d.ts +102 -0
- package/dist/api/configuration.d.ts.map +1 -0
- package/dist/api/configuration.js +83 -0
- package/dist/api/configuration.js.map +1 -0
- package/dist/api/coordinatable-emitter.d.ts +27 -0
- package/dist/api/coordinatable-emitter.d.ts.map +1 -0
- package/dist/api/coordinatable-emitter.js +20 -0
- package/dist/api/coordinatable-emitter.js.map +1 -0
- package/dist/api/entries/dependencies.d.ts +69 -0
- package/dist/api/entries/dependencies.d.ts.map +1 -0
- package/dist/api/entries/dependencies.js +61 -0
- package/dist/api/entries/dependencies.js.map +1 -0
- package/dist/api/entries/flag-logic.d.ts +37 -0
- package/dist/api/entries/flag-logic.d.ts.map +1 -0
- package/dist/api/entries/flag-logic.js +110 -0
- package/dist/api/entries/flag-logic.js.map +1 -0
- package/dist/api/entries/identifiers.d.ts +84 -0
- package/dist/api/entries/identifiers.d.ts.map +1 -0
- package/dist/api/entries/identifiers.js +590 -0
- package/dist/api/entries/identifiers.js.map +1 -0
- package/dist/api/entries/index.d.ts +6 -0
- package/dist/api/entries/index.d.ts.map +1 -0
- package/dist/{plugins → api/entries}/index.js +6 -8
- package/dist/api/entries/index.js.map +1 -0
- package/dist/api/entries/locations.d.ts +135 -0
- package/dist/api/entries/locations.d.ts.map +1 -0
- package/dist/api/entries/locations.js +174 -0
- package/dist/api/entries/locations.js.map +1 -0
- package/dist/api/entries/manager.d.ts +12 -0
- package/dist/api/entries/manager.d.ts.map +1 -0
- package/dist/api/entries/manager.js +35 -0
- package/dist/api/entries/manager.js.map +1 -0
- package/dist/api/handle-derivation.d.ts +32 -0
- package/dist/api/handle-derivation.d.ts.map +1 -0
- package/dist/api/handle-derivation.js +77 -0
- package/dist/api/handle-derivation.js.map +1 -0
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +23 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/shared-types.d.ts +86 -0
- package/dist/api/shared-types.d.ts.map +1 -0
- package/dist/api/shared-types.js +3 -0
- package/dist/api/shared-types.js.map +1 -0
- package/dist/internal-utils/auto-registering-plugins-loader.d.ts +3 -0
- package/dist/internal-utils/auto-registering-plugins-loader.d.ts.map +1 -0
- package/dist/internal-utils/auto-registering-plugins-loader.js +42 -0
- package/dist/internal-utils/auto-registering-plugins-loader.js.map +1 -0
- package/dist/internal-utils/common-config-helpers.d.ts +14 -0
- package/dist/internal-utils/common-config-helpers.d.ts.map +1 -0
- package/dist/internal-utils/common-config-helpers.js +140 -0
- package/dist/internal-utils/common-config-helpers.js.map +1 -0
- package/dist/internal-utils/entrypoint-resolution-logic.d.ts +14 -0
- package/dist/internal-utils/entrypoint-resolution-logic.d.ts.map +1 -0
- package/dist/internal-utils/entrypoint-resolution-logic.js +223 -0
- package/dist/internal-utils/entrypoint-resolution-logic.js.map +1 -0
- package/dist/internal-utils/internal-pseudo-plugin.d.ts +6 -0
- package/dist/internal-utils/internal-pseudo-plugin.d.ts.map +1 -0
- package/dist/internal-utils/internal-pseudo-plugin.js +46 -0
- package/dist/internal-utils/internal-pseudo-plugin.js.map +1 -0
- package/dist/mocks/blocks.d.ts +32 -0
- package/dist/mocks/blocks.d.ts.map +1 -0
- package/dist/mocks/blocks.js +3 -0
- package/dist/mocks/blocks.js.map +1 -0
- package/dist/mocks/index.d.ts +2 -0
- package/dist/mocks/index.d.ts.map +1 -0
- package/dist/mocks/index.js +18 -0
- package/dist/mocks/index.js.map +1 -0
- package/dist/plugins/AdditionalDependencyInjectorPlugin.d.ts +4 -10
- package/dist/plugins/AdditionalDependencyInjectorPlugin.d.ts.map +1 -0
- package/dist/plugins/AdditionalDependencyInjectorPlugin.js +48 -47
- package/dist/plugins/AdditionalDependencyInjectorPlugin.js.map +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.d.ts +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.d.ts.map +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js +1 -0
- package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js.map +1 -0
- package/dist/plugins/PackageConfigSanityChecker.d.ts +1 -0
- package/dist/plugins/PackageConfigSanityChecker.d.ts.map +1 -0
- package/dist/plugins/PackageConfigSanityChecker.js +1 -0
- package/dist/plugins/PackageConfigSanityChecker.js.map +1 -0
- package/dist/plugins/RootCoordinatorPluginImpl.d.ts +56 -0
- package/dist/plugins/RootCoordinatorPluginImpl.d.ts.map +1 -0
- package/dist/plugins/RootCoordinatorPluginImpl.js +767 -0
- package/dist/plugins/RootCoordinatorPluginImpl.js.map +1 -0
- package/dist/plugins/VariablesJSMonitorPlugin.d.ts +2 -1
- package/dist/plugins/VariablesJSMonitorPlugin.d.ts.map +1 -0
- package/dist/plugins/VariablesJSMonitorPlugin.js +1 -0
- package/dist/plugins/VariablesJSMonitorPlugin.js.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.d.ts +25 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.js +458 -0
- package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.js.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.d.ts +29 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.d.ts.map +1 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.js +290 -0
- package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.js.map +1 -0
- package/dist/plugins/blocks/register.d.ts +6 -0
- package/dist/plugins/blocks/register.d.ts.map +1 -0
- package/dist/plugins/blocks/register.js +14 -0
- package/dist/plugins/blocks/register.js.map +1 -0
- package/dist/plugins/blocks/registerEmitter.d.ts +4 -0
- package/dist/plugins/blocks/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/blocks/registerEmitter.js +13 -0
- package/dist/plugins/blocks/registerEmitter.js.map +1 -0
- package/dist/plugins/blocks/registerProcessor.d.ts +4 -0
- package/dist/plugins/blocks/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/blocks/registerProcessor.js +46 -0
- package/dist/plugins/blocks/registerProcessor.js.map +1 -0
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts +3 -2
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts.map +1 -0
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js +2 -1
- package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.d.ts +14 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.js +191 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.js.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.d.ts +14 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.d.ts.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.js +102 -0
- package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.js.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.d.ts +25 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.d.ts.map +1 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.js +229 -0
- package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.js.map +1 -0
- package/dist/plugins/extensions/register.d.ts +6 -0
- package/dist/plugins/extensions/register.d.ts.map +1 -0
- package/dist/plugins/extensions/register.js +14 -0
- package/dist/plugins/extensions/register.js.map +1 -0
- package/dist/plugins/extensions/registerEmitter.d.ts +4 -0
- package/dist/plugins/extensions/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/extensions/registerEmitter.js +18 -0
- package/dist/plugins/extensions/registerEmitter.js.map +1 -0
- package/dist/plugins/extensions/registerProcessor.d.ts +4 -0
- package/dist/plugins/extensions/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/extensions/registerProcessor.js +42 -0
- package/dist/plugins/extensions/registerProcessor.js.map +1 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.d.ts +18 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.d.ts.map +1 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.js +203 -0
- package/dist/plugins/plain/PlainEntrypointProcessingPlugin.js.map +1 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.d.ts +13 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.js +51 -0
- package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.js.map +1 -0
- package/dist/plugins/plain/register.d.ts +6 -0
- package/dist/plugins/plain/register.d.ts.map +1 -0
- package/dist/plugins/plain/register.js +14 -0
- package/dist/plugins/plain/register.js.map +1 -0
- package/dist/plugins/plain/registerEmitter.d.ts +4 -0
- package/dist/plugins/plain/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/plain/registerEmitter.js +21 -0
- package/dist/plugins/plain/registerEmitter.js.map +1 -0
- package/dist/plugins/plain/registerProcessor.d.ts +4 -0
- package/dist/plugins/plain/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/plain/registerProcessor.js +34 -0
- package/dist/plugins/plain/registerProcessor.js.map +1 -0
- package/dist/plugins/register.d.ts +3 -0
- package/dist/plugins/register.d.ts.map +1 -0
- package/dist/plugins/register.js +17 -0
- package/dist/plugins/register.js.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.d.ts +20 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.d.ts.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.js +56 -0
- package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.js.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.d.ts +13 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.d.ts.map +1 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.js +105 -0
- package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.js.map +1 -0
- package/dist/plugins/special-assets/register.d.ts +6 -0
- package/dist/plugins/special-assets/register.d.ts.map +1 -0
- package/dist/plugins/special-assets/register.js +14 -0
- package/dist/plugins/special-assets/register.js.map +1 -0
- package/dist/plugins/special-assets/registerEmitter.d.ts +4 -0
- package/dist/plugins/special-assets/registerEmitter.d.ts.map +1 -0
- package/dist/plugins/special-assets/registerEmitter.js +15 -0
- package/dist/plugins/special-assets/registerEmitter.js.map +1 -0
- package/dist/plugins/special-assets/registerProcessor.d.ts +4 -0
- package/dist/plugins/special-assets/registerProcessor.d.ts.map +1 -0
- package/dist/plugins/special-assets/registerProcessor.js +15 -0
- package/dist/plugins/special-assets/registerProcessor.js.map +1 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.d.ts +22 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.d.ts.map +1 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.js +95 -0
- package/dist/plugins/unified-loader/UnifiedLoaderGenerator.js.map +1 -0
- package/dist/plugins/wpml-config/WPMLConfigBuilder.d.ts +24 -0
- package/dist/plugins/wpml-config/WPMLConfigBuilder.d.ts.map +1 -0
- package/dist/plugins/{WPMLConfigBuilder.js → wpml-config/WPMLConfigBuilder.js} +123 -53
- package/dist/plugins/wpml-config/WPMLConfigBuilder.js.map +1 -0
- package/dist/plugins/wpml-config/register.d.ts +6 -0
- package/dist/plugins/wpml-config/register.d.ts.map +1 -0
- package/dist/plugins/wpml-config/register.js +25 -0
- package/dist/plugins/wpml-config/register.js.map +1 -0
- package/dist/shared.d.ts +10 -283
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +32 -405
- package/dist/shared.js.map +1 -0
- package/dist/utils/error-helpers.d.ts +7 -0
- package/dist/utils/error-helpers.d.ts.map +1 -0
- package/dist/utils/error-helpers.js +73 -0
- package/dist/utils/error-helpers.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/misc.d.ts +4 -0
- package/dist/utils/misc.d.ts.map +1 -0
- package/dist/utils/misc.js +18 -0
- package/dist/utils/misc.js.map +1 -0
- package/dist/utils/path-helpers.d.ts +16 -0
- package/dist/utils/path-helpers.d.ts.map +1 -0
- package/dist/utils/path-helpers.js +115 -0
- package/dist/utils/path-helpers.js.map +1 -0
- package/dist/utils/pseudo-semaphore.d.ts +1 -0
- package/dist/utils/pseudo-semaphore.d.ts.map +1 -0
- package/dist/utils/pseudo-semaphore.js +3 -5
- package/dist/utils/pseudo-semaphore.js.map +1 -0
- package/dist/utils/type-helpers.d.ts +27 -0
- package/dist/utils/type-helpers.d.ts.map +1 -0
- package/dist/utils/type-helpers.js +33 -0
- package/dist/utils/type-helpers.js.map +1 -0
- package/dist/utils/writer-utils.d.ts +8 -0
- package/dist/utils/writer-utils.d.ts.map +1 -0
- package/dist/utils/writer-utils.js +35 -0
- package/dist/utils/writer-utils.js.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts +2 -1
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js +5 -7
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts.map +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js +1 -0
- package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js.map +1 -0
- package/dist/wordpress-scripts-wrapper.d.ts +3 -2
- package/dist/wordpress-scripts-wrapper.d.ts.map +1 -0
- package/dist/wordpress-scripts-wrapper.js +137 -391
- package/dist/wordpress-scripts-wrapper.js.map +1 -0
- package/package.json +28 -50
- package/dist/plugins/AbstractBiPhasicGroupAndEntryPlugin.d.ts +0 -25
- package/dist/plugins/AbstractBiPhasicGroupAndEntryPlugin.js +0 -86
- package/dist/plugins/AbstractBiPhasicGroupPlugin.d.ts +0 -31
- package/dist/plugins/AbstractBiPhasicGroupPlugin.js +0 -91
- package/dist/plugins/EnhancedBlockJSONPlugin.d.ts +0 -47
- package/dist/plugins/EnhancedBlockJSONPlugin.js +0 -657
- package/dist/plugins/EnhancedDynamicEntryPlugin.d.ts +0 -8
- package/dist/plugins/EnhancedDynamicEntryPlugin.js +0 -14
- package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +0 -20
- package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.js +0 -191
- package/dist/plugins/ExtensionsConfigFileGeneratorPluginV1.d.ts +0 -9
- package/dist/plugins/ExtensionsConfigFileGeneratorPluginV1.js +0 -45
- package/dist/plugins/MixableBiPhasicGroupAndEntryPlugin.d.ts +0 -6
- package/dist/plugins/MixableBiPhasicGroupAndEntryPlugin.js +0 -13
- package/dist/plugins/MixableBiPhasicGroupPlugin.d.ts +0 -6
- package/dist/plugins/MixableBiPhasicGroupPlugin.js +0 -13
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +0 -26
- package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +0 -392
- package/dist/plugins/SpecialAssetHandlingPlugin.d.ts +0 -12
- package/dist/plugins/SpecialAssetHandlingPlugin.js +0 -134
- package/dist/plugins/UnifiedLoaderGenerator.d.ts +0 -21
- package/dist/plugins/UnifiedLoaderGenerator.js +0 -144
- package/dist/plugins/WPMLConfigBuilder.d.ts +0 -17
- package/dist/plugins/index.d.ts +0 -8
- package/dist/plugins/static-configs.d.ts +0 -3
- package/dist/plugins/static-configs.js +0 -44
- package/dist/utils/common-config-helpers.d.ts +0 -28
- package/dist/utils/common-config-helpers.js +0 -489
- package/dist/utils/css-writer.d.ts +0 -4
- package/dist/utils/css-writer.js +0 -46
- package/dist/utils/entrypoint-resolution-logic.d.ts +0 -13
- package/dist/utils/entrypoint-resolution-logic.js +0 -82
- package/dist/utils/location-encoding-filename-parser.d.ts +0 -30
- package/dist/utils/location-encoding-filename-parser.js +0 -120
- package/dist/utils/path-query-and-related-helpers.d.ts +0 -64
- package/dist/utils/path-query-and-related-helpers.js +0 -269
|
@@ -1,392 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlainEntrypointsConfigFileGeneratorPlugin = void 0;
|
|
4
|
-
const node_path_1 = require("node:path");
|
|
5
|
-
const php_writer_1 = require("@plaudit/php-writer");
|
|
6
|
-
const expressions_1 = require("@plaudit/php-writer/expressions");
|
|
7
|
-
const shared_1 = require("../shared");
|
|
8
|
-
const pseudo_semaphore_1 = require("../utils/pseudo-semaphore");
|
|
9
|
-
const path_query_and_related_helpers_1 = require("../utils/path-query-and-related-helpers");
|
|
10
|
-
const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
|
|
11
|
-
const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
|
|
12
|
-
const webpack_1 = require("webpack");
|
|
13
|
-
class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.AbstractBiPhasicGroupAndEntryPlugin {
|
|
14
|
-
config;
|
|
15
|
-
buildRoot;
|
|
16
|
-
outputDir;
|
|
17
|
-
dest;
|
|
18
|
-
useUnifiedLoader;
|
|
19
|
-
static semaphore = new pseudo_semaphore_1.PseudoSemaphore("Plain");
|
|
20
|
-
constructor(config, buildRoot, outputDir, dest, useUnifiedLoader, context, entry) {
|
|
21
|
-
super("plain-entrypoints-v2", [PlainEntrypointsConfigFileGeneratorPlugin.semaphore, UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore], context, entry);
|
|
22
|
-
this.config = config;
|
|
23
|
-
this.buildRoot = buildRoot;
|
|
24
|
-
this.outputDir = outputDir;
|
|
25
|
-
this.dest = dest;
|
|
26
|
-
this.useUnifiedLoader = useUnifiedLoader;
|
|
27
|
-
}
|
|
28
|
-
generatePlainEntrypointsLoader(compilation, assets) {
|
|
29
|
-
const emitDir = (0, node_path_1.join)(this.buildRoot, this.outputDir);
|
|
30
|
-
const handleLists = {
|
|
31
|
-
register: [],
|
|
32
|
-
inline: [],
|
|
33
|
-
...Object.fromEntries((0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta).map(sln => [sln, []]))
|
|
34
|
-
};
|
|
35
|
-
const plainEntrypointsConfig = PlainEntrypointsConfigFileGeneratorPlugin.collatePotentiallyMergeableAssets(assets);
|
|
36
|
-
PlainEntrypointsConfigFileGeneratorPlugin.addHandlesToHandleLists(compilation, 'script', plainEntrypointsConfig.scriptHandles
|
|
37
|
-
.toSorted(([a], [b]) => a.localeCompare(b)), handleLists);
|
|
38
|
-
PlainEntrypointsConfigFileGeneratorPlugin.addHandlesToHandleLists(compilation, 'script_module', plainEntrypointsConfig.script_moduleHandles
|
|
39
|
-
.toSorted(([a], [b]) => a.localeCompare(b)), handleLists);
|
|
40
|
-
const sortedStyleHandles = plainEntrypointsConfig.styleHandles
|
|
41
|
-
.toSorted(([a], [b]) => a.localeCompare(b));
|
|
42
|
-
PlainEntrypointsConfigFileGeneratorPlugin.addHandlesToHandleLists(compilation, 'style', sortedStyleHandles, handleLists);
|
|
43
|
-
const callItemSorter = (a, b) => a.handle.localeCompare(b.handle);
|
|
44
|
-
for (const list of Object.values(handleLists)) {
|
|
45
|
-
list.sort(callItemSorter);
|
|
46
|
-
}
|
|
47
|
-
const file = new php_writer_1.PHPFile();
|
|
48
|
-
const writer = file.getWriter("");
|
|
49
|
-
const hasRegisterScripts = handleLists.register.length > 0;
|
|
50
|
-
if (hasRegisterScripts || handleLists.inline.length > 0) {
|
|
51
|
-
if (hasRegisterScripts && !this.useUnifiedLoader) {
|
|
52
|
-
(0, shared_1.emitResolveBaseUriFunction)(writer);
|
|
53
|
-
}
|
|
54
|
-
const baseUriVar = new expressions_1.Var("base_uri");
|
|
55
|
-
const inlineAndRegisterHandleLists = [...handleLists.register, ...handleLists.inline];
|
|
56
|
-
for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(inlineAndRegisterHandleLists)) {
|
|
57
|
-
writer.action("init", writer => {
|
|
58
|
-
const state = { baseUriVar, emitDir, writer };
|
|
59
|
-
if (prioritizedHandleList.find(handleItem => handleItem.data.inlinedAsset === undefined)) {
|
|
60
|
-
writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar });
|
|
61
|
-
}
|
|
62
|
-
for (const handleItem of prioritizedHandleList) {
|
|
63
|
-
PlainEntrypointsConfigFileGeneratorPlugin.writeHandleItem(compilation, handleItem, state);
|
|
64
|
-
if (handleItem.data.associatedInlinedHandles !== undefined) {
|
|
65
|
-
for (const associatedHandle of handleItem.data.associatedInlinedHandles) {
|
|
66
|
-
PlainEntrypointsConfigFileGeneratorPlugin.writeHandleItem(compilation, { data: associatedHandle, handle: handleItem.handle, type: associatedHandle.type }, state);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}, { priority, accountForAlreadyDoing: this.config.includePostInitFallback });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
PlainEntrypointsConfigFileGeneratorPlugin.appendEnqueuingHandleLists(writer, handleLists);
|
|
74
|
-
const sortedEditorStyleHandles = sortedStyleHandles
|
|
75
|
-
.filter(([_, { locations: { clientEditor }, type }]) => type === 'style' && (clientEditor || typeof clientEditor === 'number'))
|
|
76
|
-
.sort((a, b) => {
|
|
77
|
-
const aPriority = typeof a[1].locations.clientEditor === 'boolean' ? 10 : a[1].locations.clientEditor;
|
|
78
|
-
const bPriority = typeof b[1].locations.clientEditor === 'boolean' ? 10 : b[1].locations.clientEditor;
|
|
79
|
-
return aPriority - bPriority;
|
|
80
|
-
});
|
|
81
|
-
if (sortedEditorStyleHandles.length > 0) {
|
|
82
|
-
writer.linebreak();
|
|
83
|
-
const editorSettings = new expressions_1.Var("editor_settings");
|
|
84
|
-
writer.filter("block_editor_settings_all", writer => {
|
|
85
|
-
for (const [handle, data] of sortedEditorStyleHandles) {
|
|
86
|
-
const contents = data.assetContents;
|
|
87
|
-
if (contents) {
|
|
88
|
-
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));
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
writer.return(editorSettings);
|
|
92
|
-
}, { functionArgParameters: [editorSettings], accountForAlreadyDoing: false });
|
|
93
|
-
}
|
|
94
|
-
// Only the register and inline lists, which are mutually exclusive, so each handle is collected
|
|
95
|
-
// exactly once. Flattening every list instead would collect a handle once per location it declares.
|
|
96
|
-
const lazyLoadedHandles = [...handleLists.register, ...handleLists.inline]
|
|
97
|
-
.map(handle => [handle.data.lazyLoader, handle])
|
|
98
|
-
.filter((entry) => entry[0] !== undefined)
|
|
99
|
-
.sort((a, b) => a[0].localeCompare(b[0]) || a[1].priority - b[1].priority);
|
|
100
|
-
if (lazyLoadedHandles.length > 0) {
|
|
101
|
-
writer.linebreak();
|
|
102
|
-
const groupedLazyLoadedHandles = Object.entries(lazyLoadedHandles
|
|
103
|
-
.reduce((a, b) => {
|
|
104
|
-
(a[b[0]] ??= []).push(b[1]);
|
|
105
|
-
return a;
|
|
106
|
-
}, {}));
|
|
107
|
-
for (const [lazyLoader, handles] of groupedLazyLoadedHandles) {
|
|
108
|
-
file.function(new expressions_1.NamespacedReference(this.config.targetNamespace, lazyLoader, 'function'), [], writer => {
|
|
109
|
-
for (const handle of handles) {
|
|
110
|
-
writer.call(`wp_enqueue_${handle.type}`, [handle.handle]);
|
|
111
|
-
}
|
|
112
|
-
}, { returnType: "void" });
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
(0, shared_1.emitPHPWriterAsAsset)(file, compilation, "plain-entrypoints-loader.php");
|
|
116
|
-
}
|
|
117
|
-
static writeHandleItem(compilation, { data, handle, type }, { baseUriVar, emitDir, writer }) {
|
|
118
|
-
if (data.inlinedAsset !== undefined) {
|
|
119
|
-
if (!data.inlinedAsset.omitRegistration) {
|
|
120
|
-
writer.call(`wp_register_${type}`, [handle, false, ...data.rest]);
|
|
121
|
-
}
|
|
122
|
-
(0, shared_1.appendAddInlineAssetCall)(compilation, writer, handle, type, data);
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
writer.call(`wp_register_${type}`, [handle, expressions_1.Op.concat(baseUriVar, (0, node_path_1.relative)(emitDir, data.src)), ...data.rest]);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
static collatePotentiallyMergeableAssets(assets) {
|
|
129
|
-
const collatedHandles = { scriptHandles: {}, script_moduleHandles: {}, styleHandles: {} };
|
|
130
|
-
for (const { handles, handlePrefix } of assets) {
|
|
131
|
-
for (const { src, rest, locations, type, handleName, lazyLoader, ...otherProps } of handles) {
|
|
132
|
-
const cleanBasename = (0, node_path_1.basename)(src).replace(/_(?:script(?:-\d+)?\.js|style(?:-\d+)?\.css)$|(?<!_(script|style))\.(js|css)$/, "");
|
|
133
|
-
let finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)({ niceName: (0, shared_1.kebabCase)(cleanBasename) }, handlePrefix, cleanBasename);
|
|
134
|
-
if (handleName !== undefined) {
|
|
135
|
-
finalHandleName = (0, shared_1.convertUsageLocationsHandleToEmittableHandle)(handleName, handlePrefix, finalHandleName.substring(handlePrefix.length + 1));
|
|
136
|
-
}
|
|
137
|
-
(collatedHandles[`${type}Handles`][finalHandleName] ??= []).push({ src, rest, locations, type, lazyLoader, ...otherProps });
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
const plainEntrypointsConfig = { scriptHandles: [], script_moduleHandles: [], styleHandles: [] };
|
|
141
|
-
for (const key of ['scriptHandles', 'script_moduleHandles', 'styleHandles']) {
|
|
142
|
-
for (const [baseFinalHandleName, handles] of Object.entries(collatedHandles[key])) {
|
|
143
|
-
if ((0, shared_1.arrayIsLength)(handles, 1)) {
|
|
144
|
-
plainEntrypointsConfig[key].push([baseFinalHandleName, handles[0]]);
|
|
145
|
-
}
|
|
146
|
-
else if ((0, shared_1.hasAtLeastOneItem)(handles)) {
|
|
147
|
-
const inlinedHandles = handles.filter(item => item.inlinedAsset !== undefined);
|
|
148
|
-
if (inlinedHandles.length === 0) {
|
|
149
|
-
plainEntrypointsConfig[key].push([baseFinalHandleName, handles[0]]);
|
|
150
|
-
let count = 1;
|
|
151
|
-
for (const handle of handles.slice(1)) {
|
|
152
|
-
plainEntrypointsConfig[key].push([`${baseFinalHandleName}-${count++}`, handle]);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
const emittedHandles = handles.filter(item => item.inlinedAsset === undefined);
|
|
157
|
-
inlinedHandlesLoop: for (const inlinedHandle of inlinedHandles) {
|
|
158
|
-
for (const emittedHandle of emittedHandles) {
|
|
159
|
-
const canMerge = (0, shared_1.canMergeHandles)(emittedHandle, inlinedHandle);
|
|
160
|
-
if (!canMerge) {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
if ((0, shared_1.hasDeferringStrategy)(emittedHandle)) {
|
|
164
|
-
inlinedHandle.inlinedAsset.position = 'before';
|
|
165
|
-
}
|
|
166
|
-
if (canMerge === 'dependent') {
|
|
167
|
-
emittedHandle.rest[0].push(`${baseFinalHandleName}-${emittedHandles.length}`);
|
|
168
|
-
emittedHandles.push(inlinedHandle);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
(emittedHandle.associatedInlinedHandles ??= []).push(inlinedHandle);
|
|
172
|
-
}
|
|
173
|
-
continue inlinedHandlesLoop;
|
|
174
|
-
}
|
|
175
|
-
emittedHandles.push(inlinedHandle);
|
|
176
|
-
}
|
|
177
|
-
if ((0, shared_1.hasAtLeastOneItem)(emittedHandles)) {
|
|
178
|
-
plainEntrypointsConfig[key].push([baseFinalHandleName, emittedHandles[0]]);
|
|
179
|
-
let count = 1;
|
|
180
|
-
for (const handle of emittedHandles.slice(1)) {
|
|
181
|
-
plainEntrypointsConfig[key].push([`${baseFinalHandleName}-${count++}`, handle]);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
return plainEntrypointsConfig;
|
|
189
|
-
}
|
|
190
|
-
static addHandlesToHandleLists(compilation, type, handles, handleLists) {
|
|
191
|
-
const defaultPriority = 10;
|
|
192
|
-
for (const [handle, data] of handles) {
|
|
193
|
-
if (data.inlinedAsset !== undefined) {
|
|
194
|
-
handleLists.inline.push({ handle, type, data, priority: typeof data.locations.inline === 'number' ? data.locations.inline : 10 });
|
|
195
|
-
}
|
|
196
|
-
else if (data.locations.register !== false) {
|
|
197
|
-
handleLists.register.push({ handle, type, data, priority: typeof data.locations.register === 'number' ? data.locations.register : 10 });
|
|
198
|
-
}
|
|
199
|
-
if (data.lazyLoader !== undefined) {
|
|
200
|
-
// A lazily loaded handle is enqueued by its generated function and never by an action, so it
|
|
201
|
-
// is deliberately kept out of the location lists. Those lists are also what the lazy function
|
|
202
|
-
// is built from, and a handle present in several of them would be enqueued once per list.
|
|
203
|
-
const declaredLocations = (0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta)
|
|
204
|
-
.filter(location => data.locations[location] || typeof data.locations[location] === 'number');
|
|
205
|
-
if (declaredLocations.length > 0) {
|
|
206
|
-
const locText = declaredLocations.length === 1 ? "location" : "locations";
|
|
207
|
-
compilation.warnings.push((0, shared_1.newWebpackErrorForFile)(`The handle "${handle}" declares both a lazyLoader (${data.lazyLoader}) and the ${declaredLocations.join(", ")} ${locText}.`
|
|
208
|
-
+ ` It will only be enqueued by ${data.lazyLoader}(); remove either the ${locText} or the lazyLoader.`, data.src));
|
|
209
|
-
}
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
for (const location of (0, shared_1.constantKeys)(shared_1.standardLocationNamesMeta)) {
|
|
213
|
-
let priority, hook_name;
|
|
214
|
-
const dataLocation = data.locations[location];
|
|
215
|
-
if (location === 'clientEditor' && type === 'style') {
|
|
216
|
-
// We don't include editor styles in the handle list because editor styles are enqueued via a completely separate mechanism at runtime and, therefore,
|
|
217
|
-
// cannot be handled by the same code as every other enqueueable item
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
if (typeof dataLocation === 'number') {
|
|
221
|
-
priority = dataLocation;
|
|
222
|
-
hook_name = undefined;
|
|
223
|
-
}
|
|
224
|
-
else if (dataLocation) {
|
|
225
|
-
if (typeof dataLocation === 'string') {
|
|
226
|
-
priority = defaultPriority;
|
|
227
|
-
hook_name = dataLocation;
|
|
228
|
-
}
|
|
229
|
-
else if (Array.isArray(dataLocation)) {
|
|
230
|
-
if (!(0, shared_1.hasAtLeastOneItem)(dataLocation)) {
|
|
231
|
-
continue;
|
|
232
|
-
}
|
|
233
|
-
priority = defaultPriority;
|
|
234
|
-
hook_name = dataLocation;
|
|
235
|
-
}
|
|
236
|
-
else if (typeof dataLocation === 'object') {
|
|
237
|
-
priority = dataLocation.priority ?? defaultPriority;
|
|
238
|
-
hook_name = Array.isArray(dataLocation.hook_name)
|
|
239
|
-
? (0, shared_1.hasAtLeastOneItem)(dataLocation.hook_name) ? dataLocation.hook_name : undefined
|
|
240
|
-
: dataLocation.hook_name ? dataLocation.hook_name : undefined;
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
priority = defaultPriority;
|
|
244
|
-
hook_name = undefined;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
continue;
|
|
249
|
-
}
|
|
250
|
-
handleLists[location].push({ data, handle, type, priority, hook_name });
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
static appendEnqueuingHandleLists(writer, handleLists) {
|
|
255
|
-
for (const [sln, { action, supports_hook_name, additional_action_code }] of (0, shared_1.iterableStandardLocationNamesMeta)()) {
|
|
256
|
-
const handleList = handleLists[sln];
|
|
257
|
-
if (handleList.length > 0) {
|
|
258
|
-
writer.linebreak();
|
|
259
|
-
for (const [priority, prioritizedHandleList] of PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByPriority(handleList)) {
|
|
260
|
-
if (supports_hook_name) {
|
|
261
|
-
const hookNamedHandleLists = PlainEntrypointsConfigFileGeneratorPlugin.separateHandleListByHookName(prioritizedHandleList);
|
|
262
|
-
if (hookNamedHandleLists.named.length > 0) {
|
|
263
|
-
const hook_name_var = new expressions_1.Var("hook_name", "?string");
|
|
264
|
-
writer.action(action, writer => {
|
|
265
|
-
additional_action_code?.before?.(writer);
|
|
266
|
-
if (hookNamedHandleLists.global.length > 0) {
|
|
267
|
-
for (const handle of hookNamedHandleLists.global) {
|
|
268
|
-
writer.call(`wp_enqueue_${handle.type}`, [handle.handle]);
|
|
269
|
-
}
|
|
270
|
-
writer.linebreak();
|
|
271
|
-
}
|
|
272
|
-
for (const [hook_name, handles] of hookNamedHandleLists.named) {
|
|
273
|
-
writer.if(expressions_1.Op.binary(hook_name_var, " === ", hook_name));
|
|
274
|
-
for (const handle of handles) {
|
|
275
|
-
writer.call(`wp_enqueue_${handle.type}`, [handle.handle]);
|
|
276
|
-
}
|
|
277
|
-
writer.endIf();
|
|
278
|
-
}
|
|
279
|
-
additional_action_code?.after?.(writer);
|
|
280
|
-
}, { priority, functionArgParameters: [hook_name_var] });
|
|
281
|
-
continue;
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
writer.action(action, writer => {
|
|
285
|
-
additional_action_code?.before?.(writer);
|
|
286
|
-
for (const handle of prioritizedHandleList) {
|
|
287
|
-
writer.call(`wp_enqueue_${handle.type}`, [handle.handle]);
|
|
288
|
-
}
|
|
289
|
-
additional_action_code?.after?.(writer);
|
|
290
|
-
}, { priority });
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
static separateHandleListByPriority(handleItems) {
|
|
296
|
-
const lists = new Map();
|
|
297
|
-
for (const handleItem of handleItems) {
|
|
298
|
-
const list = lists.get(handleItem.priority);
|
|
299
|
-
if (list) {
|
|
300
|
-
list.push(handleItem);
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
lists.set(handleItem.priority, [handleItem]);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return lists.entries().toArray().sort((a, b) => a[0] - b[0]);
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* This is used to allow scripts and styles to be grouped based on hook_name for the admin handle
|
|
310
|
-
* @param handleItems
|
|
311
|
-
* @private
|
|
312
|
-
*/
|
|
313
|
-
static separateHandleListByHookName(handleItems) {
|
|
314
|
-
const global = [];
|
|
315
|
-
const lists = new Map();
|
|
316
|
-
for (const handleItem of handleItems) {
|
|
317
|
-
const hook_name = handleItem.hook_name ?? "";
|
|
318
|
-
if (hook_name === "" || (Array.isArray(hook_name) && hook_name.includes(""))) {
|
|
319
|
-
// We're going to be handling global hooks (aka those without a name restriction) separately anyway,
|
|
320
|
-
// so there's no sense in mixing them in with the non-global ones
|
|
321
|
-
global.push(handleItem);
|
|
322
|
-
continue;
|
|
323
|
-
}
|
|
324
|
-
for (const hn of Array.isArray(hook_name) ? hook_name : [hook_name]) {
|
|
325
|
-
const list = lists.get(hn);
|
|
326
|
-
if (list) {
|
|
327
|
-
list.push(handleItem);
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
lists.set(hn, [handleItem]);
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return { global, named: lists.entries().toArray().sort((a, b) => a[0].localeCompare(b[0])) };
|
|
335
|
-
}
|
|
336
|
-
attachUniquePhase(compilation) {
|
|
337
|
-
compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
|
|
338
|
-
this.generatePlainEntrypointsLoader(compilation, (await PlainEntrypointsConfigFileGeneratorPlugin.semaphore.wait()).flat());
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
processAssets(compilation, parsedAssetJsonProvider) {
|
|
342
|
-
const isScriptRegex = /\.m?[jt]sx?(\?|$)/i;
|
|
343
|
-
const myAssetHandles = [];
|
|
344
|
-
const relevantEntrypoints = this.getRelevantEntrypoints(compilation).toArray();
|
|
345
|
-
for (const { entrypoint, srcPath, metadata } of relevantEntrypoints) {
|
|
346
|
-
const entrypointChunk = entrypoint.getEntrypointChunk();
|
|
347
|
-
const assetData = parsedAssetJsonProvider(entrypoint, metadata)?.assetData;
|
|
348
|
-
if (!assetData) {
|
|
349
|
-
continue;
|
|
350
|
-
}
|
|
351
|
-
const handles = [];
|
|
352
|
-
const entrypointChunkIsScript = isScriptRegex.test(srcPath);
|
|
353
|
-
const chunkFiles = entrypoint.chunks.flatMap(chunk => {
|
|
354
|
-
return [...chunk.files].filter(file => entrypointChunkIsScript || !isScriptRegex.test(file))
|
|
355
|
-
.map(file => [file, chunk === entrypointChunk]);
|
|
356
|
-
});
|
|
357
|
-
if (chunkFiles.length === 1) {
|
|
358
|
-
chunkFiles[0][1] = true;
|
|
359
|
-
}
|
|
360
|
-
for (const [file, useHandleName] of chunkFiles) {
|
|
361
|
-
const extension = (0, node_path_1.extname)(file).toLowerCase();
|
|
362
|
-
const type = extension === ".js" ? 'script' : (extension === ".mjs" ? 'script_module' : 'style');
|
|
363
|
-
const isScript = type !== 'style';
|
|
364
|
-
const { dependencies = [], module_dependencies = undefined } = isScript === entrypointChunkIsScript ? assetData : {};
|
|
365
|
-
const { lazyLoader, locations } = this.dest;
|
|
366
|
-
const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
|
|
367
|
-
const { assetMeta, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags, this.dest.locations.inline !== undefined ? { inline: true } : undefined), type === 'style' && (!!locations.clientEditor || locations.clientEditor === 0));
|
|
368
|
-
const completeScriptArgsObject = module_dependencies?.length ? { ...scriptArgsObject, module_dependencies } : scriptArgsObject;
|
|
369
|
-
const rest = isScript && completeScriptArgsObject !== undefined ? [dependencies, assetData.version, completeScriptArgsObject] : [dependencies, assetData.version];
|
|
370
|
-
const destPath = (0, node_path_1.join)(compilation.outputOptions.path, file);
|
|
371
|
-
handles.push({
|
|
372
|
-
src: destPath,
|
|
373
|
-
rest,
|
|
374
|
-
type,
|
|
375
|
-
locations,
|
|
376
|
-
handleName: useHandleName ? locations.handle : undefined,
|
|
377
|
-
lazyLoader,
|
|
378
|
-
...assetMeta
|
|
379
|
-
});
|
|
380
|
-
}
|
|
381
|
-
myAssetHandles.push({ handles, handlePrefix: this.config.targetHandlePrefix });
|
|
382
|
-
}
|
|
383
|
-
PlainEntrypointsConfigFileGeneratorPlugin.semaphore.resolve(this.id, myAssetHandles);
|
|
384
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, myAssetHandles.length
|
|
385
|
-
? {
|
|
386
|
-
group: this.group, requiresBaseURI: true, action: writer => writer.require("/plain-entrypoints-loader.php", { dirRelative: true, once: true }),
|
|
387
|
-
staticallyLoadedEntrypoints: relevantEntrypoints.flatMap(re => re.entrypoint.getEntrypointChunk().files.values().toArray())
|
|
388
|
-
}
|
|
389
|
-
: undefined);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
exports.PlainEntrypointsConfigFileGeneratorPlugin = PlainEntrypointsConfigFileGeneratorPlugin;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
2
|
-
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
3
|
-
import { Compilation } from "webpack";
|
|
4
|
-
export declare class SpecialAssetHandlingPlugin extends AbstractBiPhasicGroupPlugin {
|
|
5
|
-
private readonly config;
|
|
6
|
-
private static readonly semaphore;
|
|
7
|
-
private static validPathname?;
|
|
8
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig);
|
|
9
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
10
|
-
private collateAssets;
|
|
11
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
12
|
-
}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SpecialAssetHandlingPlugin = void 0;
|
|
7
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const php_writer_1 = require("@plaudit/php-writer");
|
|
9
|
-
const expressions_1 = require("@plaudit/php-writer/expressions");
|
|
10
|
-
const shared_1 = require("../shared");
|
|
11
|
-
const pseudo_semaphore_1 = require("../utils/pseudo-semaphore");
|
|
12
|
-
const AbstractBiPhasicGroupPlugin_1 = require("./AbstractBiPhasicGroupPlugin");
|
|
13
|
-
const UnifiedLoaderGenerator_1 = require("./UnifiedLoaderGenerator");
|
|
14
|
-
const webpack_1 = require("webpack");
|
|
15
|
-
class SpecialAssetHandlingPlugin extends AbstractBiPhasicGroupPlugin_1.AbstractBiPhasicGroupPlugin {
|
|
16
|
-
config;
|
|
17
|
-
static semaphore = new pseudo_semaphore_1.PseudoSemaphore("Special");
|
|
18
|
-
static validPathname = undefined;
|
|
19
|
-
constructor(config) {
|
|
20
|
-
super("special-assets", [SpecialAssetHandlingPlugin.semaphore, UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore]);
|
|
21
|
-
this.config = config;
|
|
22
|
-
}
|
|
23
|
-
attachStandardPhase(compilation) {
|
|
24
|
-
compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_ANALYSE }, async (assets) => {
|
|
25
|
-
try {
|
|
26
|
-
const specialAssetData = {};
|
|
27
|
-
for (const pathname of Object.keys(assets)) {
|
|
28
|
-
if (!SpecialAssetHandlingPlugin.validPathname) {
|
|
29
|
-
SpecialAssetHandlingPlugin.validPathname = pathname;
|
|
30
|
-
}
|
|
31
|
-
const assetInfo = compilation.assetsInfo.get(pathname);
|
|
32
|
-
if (!assetInfo?.sourceFilename) {
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
const filename = node_path_1.default.join(node_path_1.default.basename(node_path_1.default.dirname(pathname)), node_path_1.default.basename(pathname));
|
|
36
|
-
const queryStart = assetInfo.sourceFilename.indexOf('?');
|
|
37
|
-
if (queryStart < 0) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
const params = new URLSearchParams(assetInfo.sourceFilename.substring(queryStart + 1)
|
|
41
|
-
.replace(/(?:fetchPriority|crossOrigin)=/gi, str => str.toLowerCase()) //This ensures consistent capitalization of the fetchPriority parameter
|
|
42
|
-
);
|
|
43
|
-
if (params.has("preload")) {
|
|
44
|
-
SpecialAssetHandlingPlugin.validPathname = pathname;
|
|
45
|
-
specialAssetData[filename] = {
|
|
46
|
-
preload: true,
|
|
47
|
-
fetchpriority: params.get("fetchpriority"),
|
|
48
|
-
crossorigin: params.get("crossorigin")
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
SpecialAssetHandlingPlugin.semaphore.resolve(this.id, specialAssetData);
|
|
53
|
-
UnifiedLoaderGenerator_1.UnifiedLoaderGenerator.semaphore.resolve(this.id, Object.keys(specialAssetData).length > 0
|
|
54
|
-
? { group: 'special-assets', requiresBaseURI: true, action: file => file.require("/special-assets.php", { dirRelative: true, once: true }) }
|
|
55
|
-
: undefined);
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
console.error(e);
|
|
59
|
-
this.rejectSemaphores();
|
|
60
|
-
throw e;
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
async collateAssets(compilation) {
|
|
65
|
-
const collatedSpecialAssetData = (await SpecialAssetHandlingPlugin.semaphore.wait())
|
|
66
|
-
.reduce((collector, current) => ({ ...collector, ...current }), {});
|
|
67
|
-
const preloadedAssets = Object.entries(collatedSpecialAssetData)
|
|
68
|
-
.filter(([_, { preload }]) => preload)
|
|
69
|
-
.sort(([a], [b]) => a.localeCompare(b));
|
|
70
|
-
const outputFile = this.config.outputDir ? "special-assets.php" : node_path_1.default.join(node_path_1.default.dirname(node_path_1.default.dirname(SpecialAssetHandlingPlugin.validPathname)), "special-assets.php");
|
|
71
|
-
const writer = new php_writer_1.PHPWriter();
|
|
72
|
-
if (!preloadedAssets.length) {
|
|
73
|
-
if (!this.config.useUnifiedLoader) {
|
|
74
|
-
(0, shared_1.emitPHPWriterAsAsset)(writer, compilation, outputFile);
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
if (!this.config.useUnifiedLoader) {
|
|
79
|
-
(0, shared_1.emitResolveBaseUriFunction)(writer);
|
|
80
|
-
}
|
|
81
|
-
writer.action("wp_head", writer => {
|
|
82
|
-
const baseUriVar = new expressions_1.Var("base_uri");
|
|
83
|
-
writer.call("plaudit_webpack_extensions__resolve_base_uri", [expressions_1.Constants.__DIR__], { assignTo: baseUriVar }).closePHP();
|
|
84
|
-
for (let [filename, { preload, fetchpriority, crossorigin }] of preloadedAssets) {
|
|
85
|
-
if (!preload) {
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
let fileExtension = node_path_1.default.extname(filename);
|
|
89
|
-
if (fileExtension.startsWith(".")) {
|
|
90
|
-
fileExtension = fileExtension.substring(1).toLowerCase();
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
fileExtension = fileExtension.toLowerCase();
|
|
94
|
-
}
|
|
95
|
-
const attributes = [];
|
|
96
|
-
if (["woff", "woff2", "ttf", "otf", "eot"].includes(fileExtension)) {
|
|
97
|
-
if (!crossorigin) {
|
|
98
|
-
crossorigin = "anonymous";
|
|
99
|
-
}
|
|
100
|
-
attributes.push(["as", "font"], ["type", `font/${fileExtension}`]);
|
|
101
|
-
}
|
|
102
|
-
else if (fileExtension === "svg") {
|
|
103
|
-
attributes.push(["as", "image"], ["type", `image/svg+xml`]);
|
|
104
|
-
}
|
|
105
|
-
else if (fileExtension === "jpeg" || fileExtension === "jpg") {
|
|
106
|
-
attributes.push(["as", "image"], ["type", `image/jpeg`]);
|
|
107
|
-
}
|
|
108
|
-
else if (["png", "webp", "avif", "gif", "bmp"].includes(fileExtension)) {
|
|
109
|
-
attributes.push(["as", "image"], ["type", `image/${fileExtension}`]);
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
compilation.errors.push(new Error(`Encountered preloading markup on an unsupported file extension (${fileExtension})`));
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
if (fetchpriority && fetchpriority !== 'auto') {
|
|
116
|
-
attributes.push(["fetchpriority", fetchpriority]);
|
|
117
|
-
}
|
|
118
|
-
if (crossorigin || crossorigin === "") {
|
|
119
|
-
attributes.push(["crossorigin", crossorigin]);
|
|
120
|
-
}
|
|
121
|
-
const dynamicAttrs = attributes.map(([k, v]) => v ? `${k}="${v}"` : k).join(" ");
|
|
122
|
-
writer.append(`<link rel="preload" href="<?= ${expressions_1.Expr.call("esc_url", [expressions_1.Op.concat(baseUriVar, filename)])} ?>" ${dynamicAttrs}>`);
|
|
123
|
-
}
|
|
124
|
-
writer.openPHP();
|
|
125
|
-
});
|
|
126
|
-
(0, shared_1.emitPHPWriterAsAsset)(writer, compilation, outputFile);
|
|
127
|
-
}
|
|
128
|
-
attachUniquePhase(compilation) {
|
|
129
|
-
compilation.hooks.processAssets.tapPromise({ name: this.constructor.name, stage: webpack_1.Compilation.PROCESS_ASSETS_STAGE_REPORT }, async () => {
|
|
130
|
-
await this.collateAssets(compilation);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.SpecialAssetHandlingPlugin = SpecialAssetHandlingPlugin;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PHPFile } from "@plaudit/php-writer";
|
|
2
|
-
import { AbstractBiPhasicGroupPlugin } from "./AbstractBiPhasicGroupPlugin";
|
|
3
|
-
import { VerifiedPlauditWordpressWebpackConfig } from "../shared";
|
|
4
|
-
import { PseudoSemaphore } from "../utils/pseudo-semaphore";
|
|
5
|
-
import { Compilation } from "webpack";
|
|
6
|
-
export type LoaderInfo = {
|
|
7
|
-
group: string;
|
|
8
|
-
action(writer: PHPFile): void;
|
|
9
|
-
requiresBaseURI: boolean;
|
|
10
|
-
staticallyLoadedEntrypoints?: string[];
|
|
11
|
-
priority?: number;
|
|
12
|
-
};
|
|
13
|
-
export declare class UnifiedLoaderGenerator extends AbstractBiPhasicGroupPlugin {
|
|
14
|
-
private readonly config;
|
|
15
|
-
static readonly semaphore: PseudoSemaphore<LoaderInfo>;
|
|
16
|
-
constructor(config: VerifiedPlauditWordpressWebpackConfig);
|
|
17
|
-
protected attachStandardPhase(compilation: Compilation): void;
|
|
18
|
-
protected attachUniquePhase(compilation: Compilation): void;
|
|
19
|
-
private withDistDevLoader;
|
|
20
|
-
private ensureDistExists;
|
|
21
|
-
}
|