@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.
Files changed (279) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/USER-GUIDE.md +2 -1
  3. package/dist/api/asset-information-emission.d.ts +74 -0
  4. package/dist/api/asset-information-emission.d.ts.map +1 -0
  5. package/dist/api/asset-information-emission.js +398 -0
  6. package/dist/api/asset-information-emission.js.map +1 -0
  7. package/dist/api/configuration.d.ts +102 -0
  8. package/dist/api/configuration.d.ts.map +1 -0
  9. package/dist/api/configuration.js +83 -0
  10. package/dist/api/configuration.js.map +1 -0
  11. package/dist/api/coordinatable-emitter.d.ts +27 -0
  12. package/dist/api/coordinatable-emitter.d.ts.map +1 -0
  13. package/dist/api/coordinatable-emitter.js +20 -0
  14. package/dist/api/coordinatable-emitter.js.map +1 -0
  15. package/dist/api/entries/dependencies.d.ts +69 -0
  16. package/dist/api/entries/dependencies.d.ts.map +1 -0
  17. package/dist/api/entries/dependencies.js +61 -0
  18. package/dist/api/entries/dependencies.js.map +1 -0
  19. package/dist/api/entries/flag-logic.d.ts +37 -0
  20. package/dist/api/entries/flag-logic.d.ts.map +1 -0
  21. package/dist/api/entries/flag-logic.js +110 -0
  22. package/dist/api/entries/flag-logic.js.map +1 -0
  23. package/dist/api/entries/identifiers.d.ts +84 -0
  24. package/dist/api/entries/identifiers.d.ts.map +1 -0
  25. package/dist/api/entries/identifiers.js +590 -0
  26. package/dist/api/entries/identifiers.js.map +1 -0
  27. package/dist/api/entries/index.d.ts +6 -0
  28. package/dist/api/entries/index.d.ts.map +1 -0
  29. package/dist/{plugins → api/entries}/index.js +6 -8
  30. package/dist/api/entries/index.js.map +1 -0
  31. package/dist/api/entries/locations.d.ts +135 -0
  32. package/dist/api/entries/locations.d.ts.map +1 -0
  33. package/dist/api/entries/locations.js +174 -0
  34. package/dist/api/entries/locations.js.map +1 -0
  35. package/dist/api/entries/manager.d.ts +12 -0
  36. package/dist/api/entries/manager.d.ts.map +1 -0
  37. package/dist/api/entries/manager.js +35 -0
  38. package/dist/api/entries/manager.js.map +1 -0
  39. package/dist/api/handle-derivation.d.ts +32 -0
  40. package/dist/api/handle-derivation.d.ts.map +1 -0
  41. package/dist/api/handle-derivation.js +77 -0
  42. package/dist/api/handle-derivation.js.map +1 -0
  43. package/dist/api/index.d.ts +7 -0
  44. package/dist/api/index.d.ts.map +1 -0
  45. package/dist/api/index.js +23 -0
  46. package/dist/api/index.js.map +1 -0
  47. package/dist/api/shared-types.d.ts +86 -0
  48. package/dist/api/shared-types.d.ts.map +1 -0
  49. package/dist/api/shared-types.js +3 -0
  50. package/dist/api/shared-types.js.map +1 -0
  51. package/dist/internal-utils/auto-registering-plugins-loader.d.ts +3 -0
  52. package/dist/internal-utils/auto-registering-plugins-loader.d.ts.map +1 -0
  53. package/dist/internal-utils/auto-registering-plugins-loader.js +42 -0
  54. package/dist/internal-utils/auto-registering-plugins-loader.js.map +1 -0
  55. package/dist/internal-utils/common-config-helpers.d.ts +14 -0
  56. package/dist/internal-utils/common-config-helpers.d.ts.map +1 -0
  57. package/dist/internal-utils/common-config-helpers.js +140 -0
  58. package/dist/internal-utils/common-config-helpers.js.map +1 -0
  59. package/dist/internal-utils/entrypoint-resolution-logic.d.ts +14 -0
  60. package/dist/internal-utils/entrypoint-resolution-logic.d.ts.map +1 -0
  61. package/dist/internal-utils/entrypoint-resolution-logic.js +223 -0
  62. package/dist/internal-utils/entrypoint-resolution-logic.js.map +1 -0
  63. package/dist/internal-utils/internal-pseudo-plugin.d.ts +6 -0
  64. package/dist/internal-utils/internal-pseudo-plugin.d.ts.map +1 -0
  65. package/dist/internal-utils/internal-pseudo-plugin.js +46 -0
  66. package/dist/internal-utils/internal-pseudo-plugin.js.map +1 -0
  67. package/dist/mocks/blocks.d.ts +32 -0
  68. package/dist/mocks/blocks.d.ts.map +1 -0
  69. package/dist/mocks/blocks.js +3 -0
  70. package/dist/mocks/blocks.js.map +1 -0
  71. package/dist/mocks/index.d.ts +2 -0
  72. package/dist/mocks/index.d.ts.map +1 -0
  73. package/dist/mocks/index.js +18 -0
  74. package/dist/mocks/index.js.map +1 -0
  75. package/dist/plugins/AdditionalDependencyInjectorPlugin.d.ts +4 -10
  76. package/dist/plugins/AdditionalDependencyInjectorPlugin.d.ts.map +1 -0
  77. package/dist/plugins/AdditionalDependencyInjectorPlugin.js +48 -47
  78. package/dist/plugins/AdditionalDependencyInjectorPlugin.js.map +1 -0
  79. package/dist/plugins/MiniCSSExtractPluginErrorCleaner.d.ts +1 -0
  80. package/dist/plugins/MiniCSSExtractPluginErrorCleaner.d.ts.map +1 -0
  81. package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js +1 -0
  82. package/dist/plugins/MiniCSSExtractPluginErrorCleaner.js.map +1 -0
  83. package/dist/plugins/PackageConfigSanityChecker.d.ts +1 -0
  84. package/dist/plugins/PackageConfigSanityChecker.d.ts.map +1 -0
  85. package/dist/plugins/PackageConfigSanityChecker.js +1 -0
  86. package/dist/plugins/PackageConfigSanityChecker.js.map +1 -0
  87. package/dist/plugins/RootCoordinatorPluginImpl.d.ts +56 -0
  88. package/dist/plugins/RootCoordinatorPluginImpl.d.ts.map +1 -0
  89. package/dist/plugins/RootCoordinatorPluginImpl.js +767 -0
  90. package/dist/plugins/RootCoordinatorPluginImpl.js.map +1 -0
  91. package/dist/plugins/VariablesJSMonitorPlugin.d.ts +2 -1
  92. package/dist/plugins/VariablesJSMonitorPlugin.d.ts.map +1 -0
  93. package/dist/plugins/VariablesJSMonitorPlugin.js +1 -0
  94. package/dist/plugins/VariablesJSMonitorPlugin.js.map +1 -0
  95. package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.d.ts +25 -0
  96. package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.d.ts.map +1 -0
  97. package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.js +458 -0
  98. package/dist/plugins/blocks/BlocksDirectoryLoaderEmitterPlugin.js.map +1 -0
  99. package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.d.ts +29 -0
  100. package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.d.ts.map +1 -0
  101. package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.js +290 -0
  102. package/dist/plugins/blocks/BlocksDirectoryProcessingPlugin.js.map +1 -0
  103. package/dist/plugins/blocks/register.d.ts +6 -0
  104. package/dist/plugins/blocks/register.d.ts.map +1 -0
  105. package/dist/plugins/blocks/register.js +14 -0
  106. package/dist/plugins/blocks/register.js.map +1 -0
  107. package/dist/plugins/blocks/registerEmitter.d.ts +4 -0
  108. package/dist/plugins/blocks/registerEmitter.d.ts.map +1 -0
  109. package/dist/plugins/blocks/registerEmitter.js +13 -0
  110. package/dist/plugins/blocks/registerEmitter.js.map +1 -0
  111. package/dist/plugins/blocks/registerProcessor.d.ts +4 -0
  112. package/dist/plugins/blocks/registerProcessor.d.ts.map +1 -0
  113. package/dist/plugins/blocks/registerProcessor.js +46 -0
  114. package/dist/plugins/blocks/registerProcessor.js.map +1 -0
  115. package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts +3 -2
  116. package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.d.ts.map +1 -0
  117. package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js +2 -1
  118. package/dist/plugins/dependency-extraction-webpack-plugin-config-builder.js.map +1 -0
  119. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.d.ts +14 -0
  120. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.d.ts.map +1 -0
  121. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.js +191 -0
  122. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPlugin.js.map +1 -0
  123. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.d.ts +14 -0
  124. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.d.ts.map +1 -0
  125. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.js +102 -0
  126. package/dist/plugins/extensions/ExtensionsDirectoryLoaderEmitterPluginV1.js.map +1 -0
  127. package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.d.ts +25 -0
  128. package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.d.ts.map +1 -0
  129. package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.js +229 -0
  130. package/dist/plugins/extensions/ExtensionsDirectoryProcessingPlugin.js.map +1 -0
  131. package/dist/plugins/extensions/register.d.ts +6 -0
  132. package/dist/plugins/extensions/register.d.ts.map +1 -0
  133. package/dist/plugins/extensions/register.js +14 -0
  134. package/dist/plugins/extensions/register.js.map +1 -0
  135. package/dist/plugins/extensions/registerEmitter.d.ts +4 -0
  136. package/dist/plugins/extensions/registerEmitter.d.ts.map +1 -0
  137. package/dist/plugins/extensions/registerEmitter.js +18 -0
  138. package/dist/plugins/extensions/registerEmitter.js.map +1 -0
  139. package/dist/plugins/extensions/registerProcessor.d.ts +4 -0
  140. package/dist/plugins/extensions/registerProcessor.d.ts.map +1 -0
  141. package/dist/plugins/extensions/registerProcessor.js +42 -0
  142. package/dist/plugins/extensions/registerProcessor.js.map +1 -0
  143. package/dist/plugins/plain/PlainEntrypointProcessingPlugin.d.ts +18 -0
  144. package/dist/plugins/plain/PlainEntrypointProcessingPlugin.d.ts.map +1 -0
  145. package/dist/plugins/plain/PlainEntrypointProcessingPlugin.js +203 -0
  146. package/dist/plugins/plain/PlainEntrypointProcessingPlugin.js.map +1 -0
  147. package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.d.ts +13 -0
  148. package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.d.ts.map +1 -0
  149. package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.js +51 -0
  150. package/dist/plugins/plain/PlainEntrypointsConfigEmitterPlugin.js.map +1 -0
  151. package/dist/plugins/plain/register.d.ts +6 -0
  152. package/dist/plugins/plain/register.d.ts.map +1 -0
  153. package/dist/plugins/plain/register.js +14 -0
  154. package/dist/plugins/plain/register.js.map +1 -0
  155. package/dist/plugins/plain/registerEmitter.d.ts +4 -0
  156. package/dist/plugins/plain/registerEmitter.d.ts.map +1 -0
  157. package/dist/plugins/plain/registerEmitter.js +21 -0
  158. package/dist/plugins/plain/registerEmitter.js.map +1 -0
  159. package/dist/plugins/plain/registerProcessor.d.ts +4 -0
  160. package/dist/plugins/plain/registerProcessor.d.ts.map +1 -0
  161. package/dist/plugins/plain/registerProcessor.js +34 -0
  162. package/dist/plugins/plain/registerProcessor.js.map +1 -0
  163. package/dist/plugins/register.d.ts +3 -0
  164. package/dist/plugins/register.d.ts.map +1 -0
  165. package/dist/plugins/register.js +17 -0
  166. package/dist/plugins/register.js.map +1 -0
  167. package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.d.ts +20 -0
  168. package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.d.ts.map +1 -0
  169. package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.js +56 -0
  170. package/dist/plugins/special-assets/SpecialAssetsCollectorPlugin.js.map +1 -0
  171. package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.d.ts +13 -0
  172. package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.d.ts.map +1 -0
  173. package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.js +105 -0
  174. package/dist/plugins/special-assets/SpecialAssetsLoaderEmitterPlugin.js.map +1 -0
  175. package/dist/plugins/special-assets/register.d.ts +6 -0
  176. package/dist/plugins/special-assets/register.d.ts.map +1 -0
  177. package/dist/plugins/special-assets/register.js +14 -0
  178. package/dist/plugins/special-assets/register.js.map +1 -0
  179. package/dist/plugins/special-assets/registerEmitter.d.ts +4 -0
  180. package/dist/plugins/special-assets/registerEmitter.d.ts.map +1 -0
  181. package/dist/plugins/special-assets/registerEmitter.js +15 -0
  182. package/dist/plugins/special-assets/registerEmitter.js.map +1 -0
  183. package/dist/plugins/special-assets/registerProcessor.d.ts +4 -0
  184. package/dist/plugins/special-assets/registerProcessor.d.ts.map +1 -0
  185. package/dist/plugins/special-assets/registerProcessor.js +15 -0
  186. package/dist/plugins/special-assets/registerProcessor.js.map +1 -0
  187. package/dist/plugins/unified-loader/UnifiedLoaderGenerator.d.ts +22 -0
  188. package/dist/plugins/unified-loader/UnifiedLoaderGenerator.d.ts.map +1 -0
  189. package/dist/plugins/unified-loader/UnifiedLoaderGenerator.js +95 -0
  190. package/dist/plugins/unified-loader/UnifiedLoaderGenerator.js.map +1 -0
  191. package/dist/plugins/wpml-config/WPMLConfigBuilder.d.ts +24 -0
  192. package/dist/plugins/wpml-config/WPMLConfigBuilder.d.ts.map +1 -0
  193. package/dist/plugins/{WPMLConfigBuilder.js → wpml-config/WPMLConfigBuilder.js} +123 -53
  194. package/dist/plugins/wpml-config/WPMLConfigBuilder.js.map +1 -0
  195. package/dist/plugins/wpml-config/register.d.ts +6 -0
  196. package/dist/plugins/wpml-config/register.d.ts.map +1 -0
  197. package/dist/plugins/wpml-config/register.js +25 -0
  198. package/dist/plugins/wpml-config/register.js.map +1 -0
  199. package/dist/shared.d.ts +10 -283
  200. package/dist/shared.d.ts.map +1 -0
  201. package/dist/shared.js +32 -405
  202. package/dist/shared.js.map +1 -0
  203. package/dist/utils/error-helpers.d.ts +7 -0
  204. package/dist/utils/error-helpers.d.ts.map +1 -0
  205. package/dist/utils/error-helpers.js +73 -0
  206. package/dist/utils/error-helpers.js.map +1 -0
  207. package/dist/utils/index.d.ts +6 -0
  208. package/dist/utils/index.d.ts.map +1 -0
  209. package/dist/utils/index.js +22 -0
  210. package/dist/utils/index.js.map +1 -0
  211. package/dist/utils/misc.d.ts +4 -0
  212. package/dist/utils/misc.d.ts.map +1 -0
  213. package/dist/utils/misc.js +18 -0
  214. package/dist/utils/misc.js.map +1 -0
  215. package/dist/utils/path-helpers.d.ts +16 -0
  216. package/dist/utils/path-helpers.d.ts.map +1 -0
  217. package/dist/utils/path-helpers.js +115 -0
  218. package/dist/utils/path-helpers.js.map +1 -0
  219. package/dist/utils/pseudo-semaphore.d.ts +1 -0
  220. package/dist/utils/pseudo-semaphore.d.ts.map +1 -0
  221. package/dist/utils/pseudo-semaphore.js +3 -5
  222. package/dist/utils/pseudo-semaphore.js.map +1 -0
  223. package/dist/utils/type-helpers.d.ts +27 -0
  224. package/dist/utils/type-helpers.d.ts.map +1 -0
  225. package/dist/utils/type-helpers.js +33 -0
  226. package/dist/utils/type-helpers.js.map +1 -0
  227. package/dist/utils/writer-utils.d.ts +8 -0
  228. package/dist/utils/writer-utils.d.ts.map +1 -0
  229. package/dist/utils/writer-utils.js +35 -0
  230. package/dist/utils/writer-utils.js.map +1 -0
  231. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts +2 -1
  232. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.d.ts.map +1 -0
  233. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js +5 -7
  234. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/index.js.map +1 -0
  235. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts +1 -0
  236. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.d.ts.map +1 -0
  237. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js +1 -0
  238. package/dist/wordpress-ports/dependency-extraction-webpack-plugin/util.js.map +1 -0
  239. package/dist/wordpress-scripts-wrapper.d.ts +3 -2
  240. package/dist/wordpress-scripts-wrapper.d.ts.map +1 -0
  241. package/dist/wordpress-scripts-wrapper.js +137 -391
  242. package/dist/wordpress-scripts-wrapper.js.map +1 -0
  243. package/package.json +28 -50
  244. package/dist/plugins/AbstractBiPhasicGroupAndEntryPlugin.d.ts +0 -25
  245. package/dist/plugins/AbstractBiPhasicGroupAndEntryPlugin.js +0 -86
  246. package/dist/plugins/AbstractBiPhasicGroupPlugin.d.ts +0 -31
  247. package/dist/plugins/AbstractBiPhasicGroupPlugin.js +0 -91
  248. package/dist/plugins/EnhancedBlockJSONPlugin.d.ts +0 -47
  249. package/dist/plugins/EnhancedBlockJSONPlugin.js +0 -657
  250. package/dist/plugins/EnhancedDynamicEntryPlugin.d.ts +0 -8
  251. package/dist/plugins/EnhancedDynamicEntryPlugin.js +0 -14
  252. package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.d.ts +0 -20
  253. package/dist/plugins/ExtensionsConfigFileGeneratorPlugin.js +0 -191
  254. package/dist/plugins/ExtensionsConfigFileGeneratorPluginV1.d.ts +0 -9
  255. package/dist/plugins/ExtensionsConfigFileGeneratorPluginV1.js +0 -45
  256. package/dist/plugins/MixableBiPhasicGroupAndEntryPlugin.d.ts +0 -6
  257. package/dist/plugins/MixableBiPhasicGroupAndEntryPlugin.js +0 -13
  258. package/dist/plugins/MixableBiPhasicGroupPlugin.d.ts +0 -6
  259. package/dist/plugins/MixableBiPhasicGroupPlugin.js +0 -13
  260. package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.d.ts +0 -26
  261. package/dist/plugins/PlainEntrypointsConfigFileGeneratorPlugin.js +0 -392
  262. package/dist/plugins/SpecialAssetHandlingPlugin.d.ts +0 -12
  263. package/dist/plugins/SpecialAssetHandlingPlugin.js +0 -134
  264. package/dist/plugins/UnifiedLoaderGenerator.d.ts +0 -21
  265. package/dist/plugins/UnifiedLoaderGenerator.js +0 -144
  266. package/dist/plugins/WPMLConfigBuilder.d.ts +0 -17
  267. package/dist/plugins/index.d.ts +0 -8
  268. package/dist/plugins/static-configs.d.ts +0 -3
  269. package/dist/plugins/static-configs.js +0 -44
  270. package/dist/utils/common-config-helpers.d.ts +0 -28
  271. package/dist/utils/common-config-helpers.js +0 -489
  272. package/dist/utils/css-writer.d.ts +0 -4
  273. package/dist/utils/css-writer.js +0 -46
  274. package/dist/utils/entrypoint-resolution-logic.d.ts +0 -13
  275. package/dist/utils/entrypoint-resolution-logic.js +0 -82
  276. package/dist/utils/location-encoding-filename-parser.d.ts +0 -30
  277. package/dist/utils/location-encoding-filename-parser.js +0 -120
  278. package/dist/utils/path-query-and-related-helpers.d.ts +0 -64
  279. package/dist/utils/path-query-and-related-helpers.js +0 -269
@@ -1,30 +0,0 @@
1
- import { RealUsageLocations } from "../shared";
2
- import { NormalizedEnqueuingControlFlags } from "./path-query-and-related-helpers";
3
- export type ParsedLocationEncodingFilename = {
4
- type: 'script' | 'style' | 'script-module';
5
- locations: RealUsageLocations & {
6
- register?: boolean | number;
7
- } & {
8
- handle?: {
9
- niceName: string;
10
- };
11
- };
12
- flags: NormalizedEnqueuingControlFlags;
13
- };
14
- export declare function parseLocationEncodingFilename(filename: string): ParsedLocationEncodingFilename | undefined;
15
- export declare function parseLocationEncodingFilenameForBlock(filename: string, errorBuilder?: (message: string, filename: string) => unknown): (Omit<ParsedLocationEncodingFilename, 'locations'> & {
16
- locations: Pick<RealUsageLocations, 'clientEditor' | 'clientView'>;
17
- handle: ParsedLocationEncodingFilename['locations']['handle'];
18
- }) | undefined;
19
- /**
20
- * This handles detecting all keys of standardLocationNamesMeta as well as the values listed in their associated alternate_names properties
21
- * It MUST be kept in sync with standardLocationNamesMeta
22
- * @param segment
23
- */
24
- export declare function extractLocationFromPropertyEncodingFilenameSegment(segment: string): {
25
- readonly locationName: false;
26
- readonly priority?: undefined;
27
- } | {
28
- readonly locationName: "admin" | "analytics" | "blockAssets" | "clientEditor" | "clientView" | "customizer" | "login" | "register";
29
- readonly priority: number | true;
30
- };
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseLocationEncodingFilename = parseLocationEncodingFilename;
4
- exports.parseLocationEncodingFilenameForBlock = parseLocationEncodingFilenameForBlock;
5
- exports.extractLocationFromPropertyEncodingFilenameSegment = extractLocationFromPropertyEncodingFilenameSegment;
6
- const node_path_1 = require("node:path");
7
- const shared_1 = require("../shared");
8
- function parseLocationEncodingFilename(filename) {
9
- const { name, ext } = (0, node_path_1.parse)(filename);
10
- if ((0, shared_1.shouldBeSkipped)(name)) {
11
- return undefined;
12
- }
13
- let type = /^\.(?:s[ac]|p?c)ss$/i.test(ext) ? 'style' : /^\.m[jt]sx?/i.test(ext) ? 'script-module' : /^\.[jt]sx?/i.test(ext) ? 'script' : false;
14
- if (type === false) {
15
- return undefined;
16
- }
17
- const locations = {};
18
- const flags = {};
19
- const nameSegments = name.split("."); //Split always returns at least one string
20
- const typeOverrideMatch = /^(?<enqueuePosition>.+)-(?<typeOverride>script|style|script-module)$|^(?<typeOverride>script|style|script-module)$/.exec(nameSegments[0]);
21
- if (typeOverrideMatch) {
22
- nameSegments[0] = typeOverrideMatch.groups?.["enqueuePosition"] ?? "both"; // We override the first segment with the version without the type override
23
- type = typeOverrideMatch.groups?.["typeOverride"];
24
- }
25
- const inlinePattern = /^(?<inline>inline)(?:[-=](?<position>before|after))?$|^strategy[-=](?<inline>inline)(?:-(?<position>before|after))?$/;
26
- const strategyPattern = /^strategy[-=](?<strategy>eager|lazy|defer|async)$|^(?<strategy>lazy|eager)$/;
27
- const fetchpriorityPattern = /^fetchpriority[-=](auto|low|high)$/;
28
- const bothViewAndEditorLocationPattern = /^(?:client-)?(?<both>both)(?:[-=](?<priority>-?\d+))?$/;
29
- let niceName = undefined;
30
- for (const segment of nameSegments) {
31
- const { locationName, priority } = extractLocationFromPropertyEncodingFilenameSegment(segment);
32
- if (locationName) {
33
- locations[locationName] = priority;
34
- continue;
35
- }
36
- const lcSegment = segment.toLowerCase();
37
- const { both, priority: bothPriority } = bothViewAndEditorLocationPattern.exec(lcSegment)?.groups ?? {};
38
- if (both) {
39
- const priority = bothPriority !== undefined ? parseInt(bothPriority) : true;
40
- locations.clientView = priority;
41
- locations.clientEditor = priority;
42
- continue;
43
- }
44
- const { inline, position: inlinePosition } = (inlinePattern.exec(lcSegment)?.groups ?? {});
45
- if (inline) {
46
- flags.inline = true;
47
- flags.position = inlinePosition;
48
- continue;
49
- }
50
- const strategy = strategyPattern.exec(lcSegment)?.groups?.['strategy']?.toLowerCase();
51
- if (strategy) {
52
- flags.strategy = strategy;
53
- continue;
54
- }
55
- const fetchpriority = fetchpriorityPattern.exec(lcSegment)?.[1];
56
- if (fetchpriority !== undefined) {
57
- flags.fetchpriority = fetchpriority;
58
- continue;
59
- }
60
- switch (segment.toLowerCase()) {
61
- // Loading flags
62
- case "in-footer":
63
- case "in_footer":
64
- flags.in_footer = true;
65
- break;
66
- case "in-header":
67
- case "in_header":
68
- flags.in_footer = false;
69
- break;
70
- default:
71
- if (niceName === undefined) {
72
- niceName = segment;
73
- }
74
- break;
75
- }
76
- }
77
- // This means that it wasn't a location-encoding filename
78
- if (Object.values(locations).length === 0) {
79
- return undefined;
80
- }
81
- if (niceName !== undefined) {
82
- // We need to kebab-case the nice name value for web-safety
83
- locations.handle = { niceName: (0, shared_1.kebabCase)(niceName) };
84
- }
85
- return { type, locations, flags };
86
- }
87
- function parseLocationEncodingFilenameForBlock(filename, errorBuilder = shared_1.newWebpackErrorForFile) {
88
- const parsedFilename = parseLocationEncodingFilename(filename);
89
- if (parsedFilename !== undefined) {
90
- const { handle, ...locations } = parsedFilename.locations;
91
- if ((0, shared_1.constantKeys)(locations).some(value => value !== 'clientView' && value !== 'clientEditor')) {
92
- throw errorBuilder(`Block assets cannot be enqueued anywhere other than view, editor, or both. Saw: ${(0, shared_1.constantKeys)(parsedFilename.locations).join(", ")}`, filename);
93
- }
94
- if (Object.values(locations).some(value => typeof value === 'number')) {
95
- throw errorBuilder(`Block assets cannot be enqueued with a priority`, filename);
96
- }
97
- return { ...parsedFilename, handle, locations };
98
- }
99
- return parsedFilename;
100
- }
101
- let standardLocationNamesAndPriorityPatternInFilenameSegment;
102
- /**
103
- * This handles detecting all keys of standardLocationNamesMeta as well as the values listed in their associated alternate_names properties
104
- * It MUST be kept in sync with standardLocationNamesMeta
105
- * @param segment
106
- */
107
- function extractLocationFromPropertyEncodingFilenameSegment(segment) {
108
- if (!standardLocationNamesAndPriorityPatternInFilenameSegment) {
109
- const matchableLocationNames = (0, shared_1.iterableStandardLocationNamesMeta)()
110
- .flatMap(([standardName, { alternate_names = [] }]) => [standardName, ...alternate_names])
111
- .join("|");
112
- standardLocationNamesAndPriorityPatternInFilenameSegment = new RegExp(`^(?<locationName>${matchableLocationNames}|register)(?:[-=](?<priority>-?\\d+))?$`);
113
- }
114
- const { locationName, priority: rawPriority } = standardLocationNamesAndPriorityPatternInFilenameSegment.exec(segment)?.groups ?? {};
115
- if (!locationName) {
116
- return { locationName: false };
117
- }
118
- const priority = rawPriority !== undefined ? parseInt(rawPriority) : true;
119
- return { locationName: (0, shared_1.normalizeLocationName)(locationName), priority };
120
- }
@@ -1,64 +0,0 @@
1
- import type { Compilation } from "webpack";
2
- import { type InlinedAsset, type PathQueryParameters, type ScriptArgsObject, type UsageLocations } from "../shared";
3
- export declare function getAssetFileContents(compilation: Compilation, name: string): string;
4
- export declare function unpackPotentiallyPrefixedFilePath(filePath: string): [string, PathQueryParameters | undefined];
5
- /**
6
- * The following substitutions are performed:
7
- * <ul>
8
- * <li>parameters without an assigned value -> a boolean parameter set to true</li>
9
- * <li>true and false -> their boolean equivalents</li>
10
- * <li>numeric values -> their number equivalents</li>
11
- * </ul>
12
- *
13
- * @param pathQuery the part after the "?" in a webpack inclusion path
14
- * @return the query as an object with common string -> JS type conversions already performed
15
- */
16
- export declare function unpackPathQuery(pathQuery: string): PathQueryParameters | undefined;
17
- export type LoadingStrategy = boolean | 'defer' | 'async' | 'eager' | 'lazy' | 'inline';
18
- export declare function newInvalidLoadingStrategyError(strategy: unknown, file: string): import("webpack").WebpackError;
19
- export type InFooter = boolean;
20
- export declare function isValidInFooter(in_footer: unknown): in_footer is InFooter;
21
- export declare function newInvalidInFooterError(in_footer: unknown, file: string): import("webpack").WebpackError;
22
- export type FetchPriority = 'auto' | 'low' | 'high';
23
- export declare function isValidFetchPriority(fetchpriority: unknown): fetchpriority is FetchPriority;
24
- export declare function newInvalidFetchPriorityError(fetchpriority: unknown, file: string): import("webpack").WebpackError;
25
- export type PositionForInlineStrategy = 'before' | 'after';
26
- export declare function isValidPositionForInlineStrategy(position: unknown): position is PositionForInlineStrategy;
27
- export declare function newInvalidPositionForInlineStrategyError(position: unknown, file: string): import("webpack").WebpackError;
28
- /**
29
- * This function ensures that the passed pathQueryParameters are normalized for the config-loading step, NOT the emission step
30
- */
31
- export type NormalizedEnqueuingControlFlags = {
32
- strategy?: Exclude<LoadingStrategy, 'inline'>;
33
- in_footer?: InFooter;
34
- inline?: boolean;
35
- fetchpriority?: FetchPriority;
36
- position?: 'before' | 'after';
37
- };
38
- export declare function mergeTwoEnqueuingControlFlagSets(file: string, ...argsBlocks: (NormalizedEnqueuingControlFlags | undefined)[]): NormalizedEnqueuingControlFlags | undefined;
39
- export declare function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters: PathQueryParameters | undefined, file: string, sourceType: 'registerScriptArgs' | 'path query parameters'): {
40
- flags?: NormalizedEnqueuingControlFlags;
41
- handle?: UsageLocations['handle'];
42
- remainder?: PathQueryParameters;
43
- };
44
- /**
45
- * This function does a few things:
46
- * <ol>
47
- * <li>It converts the strategy, in_footer, and fetchpriority flags into a valid script args object</li>
48
- * <li>If inline is true, it records the contents of the asset and the value of the position flag for later injection and removes the asset from the compilation output</li>
49
- * </ol>
50
- * @param compilation
51
- * @param file
52
- * @param flags
53
- * @param forceRecordContents
54
- */
55
- export declare function convertEnqueuingControlFlagsToScriptArgsObject(compilation: Compilation, file: string, flags: NormalizedEnqueuingControlFlags | undefined, forceRecordContents?: boolean): {
56
- scriptArgsObject?: ScriptArgsObject;
57
- assetMeta?: {
58
- inlinedAsset: InlinedAsset;
59
- assetContents: string;
60
- } | {
61
- inlinedAsset?: undefined;
62
- assetContents: string | undefined;
63
- };
64
- };
@@ -1,269 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getAssetFileContents = getAssetFileContents;
4
- exports.unpackPotentiallyPrefixedFilePath = unpackPotentiallyPrefixedFilePath;
5
- exports.unpackPathQuery = unpackPathQuery;
6
- exports.newInvalidLoadingStrategyError = newInvalidLoadingStrategyError;
7
- exports.isValidInFooter = isValidInFooter;
8
- exports.newInvalidInFooterError = newInvalidInFooterError;
9
- exports.isValidFetchPriority = isValidFetchPriority;
10
- exports.newInvalidFetchPriorityError = newInvalidFetchPriorityError;
11
- exports.isValidPositionForInlineStrategy = isValidPositionForInlineStrategy;
12
- exports.newInvalidPositionForInlineStrategyError = newInvalidPositionForInlineStrategyError;
13
- exports.mergeTwoEnqueuingControlFlagSets = mergeTwoEnqueuingControlFlagSets;
14
- exports.unpackEnqueuingControlFlagsFromPathQueryParameters = unpackEnqueuingControlFlagsFromPathQueryParameters;
15
- exports.convertEnqueuingControlFlagsToScriptArgsObject = convertEnqueuingControlFlagsToScriptArgsObject;
16
- const node_path_1 = require("node:path");
17
- const shared_1 = require("../shared");
18
- function getAssetFileContents(compilation, name) {
19
- const asset = compilation.getAsset(name);
20
- if (!asset) {
21
- throw new Error(`${name} is unexpectedly missing`);
22
- }
23
- const assetSource = asset.source.source();
24
- return typeof assetSource === 'string' ? assetSource : assetSource?.toString('utf-8');
25
- }
26
- function unpackPotentiallyPrefixedFilePath(filePath) {
27
- if (filePath.startsWith("file:")) {
28
- filePath = filePath.substring(5);
29
- }
30
- const queryStart = filePath.indexOf("?");
31
- if (queryStart === -1) {
32
- return [filePath, undefined];
33
- }
34
- else {
35
- return [filePath.substring(0, queryStart), unpackPathQuery(filePath.substring(queryStart + 1))];
36
- }
37
- }
38
- /**
39
- * The following substitutions are performed:
40
- * <ul>
41
- * <li>parameters without an assigned value -> a boolean parameter set to true</li>
42
- * <li>true and false -> their boolean equivalents</li>
43
- * <li>numeric values -> their number equivalents</li>
44
- * </ul>
45
- *
46
- * @param pathQuery the part after the "?" in a webpack inclusion path
47
- * @return the query as an object with common string -> JS type conversions already performed
48
- */
49
- function unpackPathQuery(pathQuery) {
50
- if (!pathQuery) {
51
- return undefined;
52
- }
53
- return new URLSearchParams(pathQuery.replaceAll(/((?:[&?]|^)\w+)(&|$)/g, "$1=true$2")).entries()
54
- .map(([key, value]) => {
55
- if (value === 'true') {
56
- return [key, true];
57
- }
58
- if (value === 'false') {
59
- return [key, false];
60
- }
61
- if (Number.isFinite(+value)) {
62
- return [key, +value];
63
- }
64
- return [key, value];
65
- })
66
- .reduce((collector, [key, value]) => {
67
- if (collector[key] instanceof Array) {
68
- collector[key].push(value);
69
- }
70
- else if (key in collector) {
71
- collector[key] = [collector[key], value];
72
- }
73
- else {
74
- collector[key] = value;
75
- }
76
- return collector;
77
- }, {});
78
- }
79
- const namedStrategies = ['defer', 'async', 'eager', 'lazy', 'inline'];
80
- function newInvalidLoadingStrategyError(strategy, file) {
81
- return (0, shared_1.newWebpackErrorForFile)(`The strategy was invalid. Received: ${strategy}, Expected: undefined|boolean|'${namedStrategies.join("'|'")}'`, file);
82
- }
83
- function isValidInFooter(in_footer) {
84
- return typeof in_footer === 'boolean';
85
- }
86
- function newInvalidInFooterError(in_footer, file) {
87
- return (0, shared_1.newWebpackErrorForFile)(`The in_footer value was invalid. Received: ${in_footer}, Expected: undefined|boolean`, file);
88
- }
89
- function isValidFetchPriority(fetchpriority) {
90
- return typeof fetchpriority === 'string' && ["auto", "low", "high"].includes(fetchpriority);
91
- }
92
- function newInvalidFetchPriorityError(fetchpriority, file) {
93
- return (0, shared_1.newWebpackErrorForFile)(`The fetchpriority value was invalid. Received: ${fetchpriority}, Expected: undefined|'auto'|'low'|'high'`, file);
94
- }
95
- function isValidPositionForInlineStrategy(position) {
96
- return typeof position === 'string' && ["before", "after"].includes(position);
97
- }
98
- function newInvalidPositionForInlineStrategyError(position, file) {
99
- return (0, shared_1.newWebpackErrorForFile)(`The position value for the inlined asset was invalid. Received: ${position}, Expected: undefined|'before'|'after'`, file);
100
- }
101
- function mergeTwoEnqueuingControlFlagSets(file, ...argsBlocks) {
102
- const filteredArgsBlocks = argsBlocks.filter(argsBlock => argsBlock !== undefined);
103
- if (filteredArgsBlocks.length === 0) {
104
- return undefined;
105
- }
106
- if ((0, shared_1.arrayIsLength)(filteredArgsBlocks, 1)) {
107
- return filteredArgsBlocks[0];
108
- }
109
- const res = {};
110
- for (const key of ['strategy', 'in_footer', 'fetchpriority', 'inline', 'position']) {
111
- for (const argsBlock of filteredArgsBlocks) {
112
- if (key in argsBlock) {
113
- if (!(key in res)) {
114
- res[key] = argsBlock[key];
115
- }
116
- else if (argsBlock[key] !== res[key]) {
117
- throw (0, shared_1.newWebpackErrorForFile)(`The ${key} values in the control flag sets for the file conflict`, file);
118
- }
119
- }
120
- }
121
- }
122
- return res;
123
- }
124
- function unpackEnqueuingControlFlagsFromPathQueryParameters(pathQueryParameters, file, sourceType) {
125
- if (pathQueryParameters === undefined) {
126
- return {};
127
- }
128
- const { strategy, in_footer: normalizedInFooter, 'in-footer': alternateInFooter, fetchpriority, position, handle, ...remainder } = pathQueryParameters;
129
- let flags;
130
- switch (strategy) {
131
- case 'defer':
132
- case 'async':
133
- flags = { strategy };
134
- break;
135
- case 'eager':
136
- flags = { strategy: 'eager' };
137
- break;
138
- case 'lazy':
139
- flags = { strategy: 'defer', in_footer: true };
140
- break;
141
- case 'inline':
142
- flags = { inline: true };
143
- break;
144
- case true:
145
- case false:
146
- flags = { in_footer: strategy };
147
- break;
148
- case null:
149
- case undefined:
150
- flags = {};
151
- break;
152
- default:
153
- throw newInvalidLoadingStrategyError(strategy, file);
154
- }
155
- if (flags.inline === undefined && pathQueryParameters['inline'] !== undefined) {
156
- flags.inline = !!pathQueryParameters['inline'];
157
- }
158
- const in_footer = normalizedInFooter ?? alternateInFooter;
159
- if (in_footer !== undefined) {
160
- if (!isValidInFooter(in_footer)) {
161
- throw newInvalidInFooterError(in_footer, file);
162
- }
163
- flags.in_footer = in_footer;
164
- }
165
- if (pathQueryParameters['fetchpriority'] !== undefined) {
166
- if (!isValidFetchPriority(pathQueryParameters['fetchpriority'])) {
167
- throw newInvalidFetchPriorityError(pathQueryParameters['fetchpriority'], file);
168
- }
169
- if (flags.fetchpriority !== undefined && flags.fetchpriority !== pathQueryParameters['fetchpriority']) {
170
- throw (0, shared_1.newWebpackErrorForFile)(`The strategy and fetchpriority values in the ${sourceType} for the file conflict. Got ${strategy} and ${pathQueryParameters['fetchpriority']}`, file);
171
- }
172
- flags.fetchpriority = pathQueryParameters['fetchpriority'];
173
- }
174
- if (flags.inline && (pathQueryParameters['position'] === 'before' || pathQueryParameters['position'] === 'after')) {
175
- flags.position = pathQueryParameters['position'];
176
- }
177
- if (handle !== undefined && (typeof handle !== 'string' || handle.length < 5)) {
178
- throw (0, shared_1.newWebpackErrorForFile)(`The handle was invalid. Received: ${handle}. Expected: a string that is at least 5 characters long`, file);
179
- }
180
- return Object.keys(flags).length > 0 ? { flags, handle, remainder } : { handle, remainder };
181
- }
182
- /**
183
- * This function does a few things:
184
- * <ol>
185
- * <li>It converts the strategy, in_footer, and fetchpriority flags into a valid script args object</li>
186
- * <li>If inline is true, it records the contents of the asset and the value of the position flag for later injection and removes the asset from the compilation output</li>
187
- * </ol>
188
- * @param compilation
189
- * @param file
190
- * @param flags
191
- * @param forceRecordContents
192
- */
193
- function convertEnqueuingControlFlagsToScriptArgsObject(compilation, file, flags, forceRecordContents = false) {
194
- if (flags === undefined) {
195
- if (forceRecordContents) {
196
- return { assetMeta: { assetContents: getAssetFileContents(compilation, file) } };
197
- }
198
- return {};
199
- }
200
- const { strategy, in_footer, inline, position, fetchpriority } = flags;
201
- const scriptArgsObject = {};
202
- let inlinedAsset = undefined;
203
- let assetContents = undefined;
204
- switch (strategy) {
205
- case 'async':
206
- case 'defer':
207
- scriptArgsObject.strategy = strategy;
208
- break;
209
- case 'eager':
210
- scriptArgsObject.in_footer = false;
211
- break;
212
- case 'lazy':
213
- scriptArgsObject.strategy = 'defer';
214
- scriptArgsObject.in_footer = true;
215
- break;
216
- case true:
217
- case false:
218
- scriptArgsObject.in_footer = strategy;
219
- break;
220
- case null:
221
- case undefined:
222
- // This is included because are effectively validating the strategy value with this switch statement, and "not defined" is a valid state
223
- break;
224
- default:
225
- throw newInvalidLoadingStrategyError(strategy, file);
226
- }
227
- if (in_footer !== undefined) {
228
- if (!isValidInFooter(in_footer)) {
229
- throw newInvalidInFooterError(in_footer, file);
230
- }
231
- scriptArgsObject.in_footer = in_footer;
232
- }
233
- if (inline) {
234
- inlinedAsset = {};
235
- assetContents = getAssetFileContents(compilation, file);
236
- removeFileAndAssetPHP(compilation, file);
237
- if (position !== undefined) {
238
- if (!isValidPositionForInlineStrategy(position)) {
239
- throw newInvalidPositionForInlineStrategyError(position, file);
240
- }
241
- inlinedAsset.position = position;
242
- }
243
- if (inlinedAsset.position !== 'before' && scriptArgsObject.strategy !== undefined) {
244
- compilation.warnings.push((0, shared_1.newWebpackErrorForFile)("Deferred and async scripts that have inlined JS attached in the 'after' position will cause WordPress to convert all of their dependencies to eager scripts at runtime", file));
245
- }
246
- if (scriptArgsObject.in_footer === undefined) {
247
- scriptArgsObject.in_footer = true;
248
- }
249
- }
250
- else if (forceRecordContents) {
251
- assetContents = getAssetFileContents(compilation, file);
252
- }
253
- if (fetchpriority !== undefined) {
254
- if (!isValidFetchPriority(fetchpriority)) {
255
- throw newInvalidFetchPriorityError(fetchpriority, file);
256
- }
257
- if (inline) {
258
- compilation.warnings.push((0, shared_1.newWebpackErrorForFile)("Fetchpriority has no effect on inlined assets", file));
259
- }
260
- scriptArgsObject.fetchpriority = fetchpriority;
261
- }
262
- const assetMeta = inlinedAsset ? { inlinedAsset, assetContents: assetContents } : { assetContents };
263
- return Object.keys(scriptArgsObject).length > 0 ? { scriptArgsObject, assetMeta } : { assetMeta };
264
- }
265
- function removeFileAndAssetPHP(compilation, file) {
266
- const pathParts = (0, node_path_1.parse)(file);
267
- compilation.deleteAsset((0, node_path_1.join)(pathParts.dir, pathParts.name) + ".asset.php");
268
- compilation.deleteAsset(file);
269
- }