@plaudit/webpack-extensions 2.85.3 → 2.87.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 CHANGED
@@ -5,6 +5,74 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [3.3.0] - 2026-03-16
9
+ ### Added
10
+ - A few helper methods for tools that reference this package and care about the entrypoint resolution logic
11
+
12
+ ## [3.2.2] - 2026-03-16
13
+ ### Changed
14
+ - Exposed additional aspects of the entrypoint resolution logic to tools that reference this package
15
+
16
+ ## [3.2.1] - 2026-03-16
17
+ ### Added
18
+ - A function to expose standard flag sets to tools that reference this package
19
+
20
+ ## [3.2.0] - 2026-03-16
21
+ ### Added
22
+ - Support for `Location-Encoding Filenames`
23
+ - This comes from version `2.86.0`
24
+ - Support for standardized flag sets
25
+ - This comes from version `2.86.0`
26
+
27
+ ## [3.1.2] - 2026-03-06
28
+ ### Fixed
29
+ - `defer` and `async` not being supported strategies in some pipelines
30
+ - This comes from version `2.85.3`
31
+
32
+ ## [3.1.1] - 2026-03-06
33
+ ### Fixed
34
+ - Inlined scripts without any other path query parameters not being placed in the footer by default
35
+ - This comes from version `2.85.2`
36
+
37
+ ## [3.1.0] - 2026-03-05
38
+ ### Added
39
+ - Support for inlining (and otherwise controlling the enqueuing of) assets
40
+ - This only applies to plain entrypoints and assets declared within block.json files at present
41
+ - This comes from version `2.85.0`
42
+
43
+ ## [3.0.1] - 2026-02-12
44
+ ### Added
45
+ - Release version!
46
+
47
+ ## [3.0.0-rc.3] - 2026-02-12
48
+ ### Fixed
49
+ - A missing dependency
50
+
51
+ ## [3.0.0-rc.2] - 2026-02-12
52
+ ### Fixed
53
+ - A missing dependency
54
+
55
+ ## [3.0.0-rc.1] - 2026-02-12
56
+ ### Changed
57
+ - Updated all postcss plugins to their latest available versions
58
+
59
+ ### Removed
60
+ - Legacy PostCSS features that have been integrated into modern CSS
61
+ - `@extends` support
62
+
63
+ ## [2.87.0] - 2026-03-16
64
+ ### Added
65
+ - Support for a directory-based `extensions` layout
66
+ - This only applies to sites using extensions v2 and higher
67
+
68
+ ### Internals
69
+ - Backported the features from `3.2.x` and `3.3.0`
70
+
71
+ ## [2.86.0] - 2026-03-16
72
+ ### Added
73
+ - Support for `Location-Encoding Filenames`
74
+ - Support for standardized flag sets
75
+
8
76
  ## [2.85.3] - 2026-03-06
9
77
  ### Fixed
10
78
  - `defer` and `async` not being supported strategies in some pipelines
package/USER-GUIDE.md CHANGED
@@ -28,6 +28,11 @@
28
28
  * [Pattern 4: Block Editor Styles](#pattern-4-block-editor-styles)
29
29
  * [Reference](#reference)
30
30
  * [Root Options](#root-options)
31
+ * [Standard Flag Sets](#standard-flag-sets)
32
+ * [Location-Encoding Filenames](#location-encoding-filenames)
33
+ * [Enqueuing Location](#enqueuing-location)
34
+ * [Examples](#examples-1)
35
+ * [Block- and Plain-compatible](#block--and-plain-compatible)
31
36
  * [Per-Entrypoint Options](#per-entrypoint-options)
32
37
  * [Path Queries](#path-queries)
33
38
  * [Boolean-form](#boolean-form)
@@ -138,85 +143,26 @@ The config tells webpack **what** to build and **where** to load it in WordPress
138
143
 
139
144
  ```javascript
140
145
  module.exports = require("@plaudit/webpack-extensions/wordpress-scripts-wrapper")({
141
- src: {
142
- // Build all blocks in src/blocks/
143
- "blocks": true,
144
-
145
- // Build block extensions from src/extensions/
146
- "extensions": {directoryLayout: 'extensions'},
147
-
148
- // Auto-load in the head on frontend
149
- "site/index-header.ts": {
150
- locations: {
151
- clientView: true,
152
- registerScriptArgs: false
153
- }
154
- },
155
-
156
- // Auto-load at the bottom of the body on frontend
157
- "site/index-footer.ts": {
158
- locations: {
159
- clientView: true,
160
- registerScriptArgs: 'lazy'
161
- }
162
- },
163
- // Auto-load in admin
164
- "site/wp-admin.ts": {
165
- locations: {
166
- admin: true
167
- }
168
- },
169
- // Auto-load in admin
170
- "site/wp-admin.pcss": {
171
- locations: {
172
- admin: true
173
- }
174
- },
175
- // Auto-load in the block editor
176
- "site/block-editor.pcss": {
177
- locations: {
178
- clientEditor: true
179
- }
180
- },
181
- // Auto-load in the head on frontend
182
- "site/public.pcss": {
183
- locations: {
184
- clientView: true
185
- }
186
- },
187
- // A script that can be enqueued via its handle, but is not autoloaded
188
- "site/manually-loaded.ts": {
189
- locations: "plaudit-theme/manually-loaded-script"
190
- },
191
- // A script that will be inlined into the footer
192
- "site/inlined-script.ts?inline=true": {
193
- locations: "plaudit-theme/inlined-script"
194
- }
195
- },
196
- useWebpackResourceFiltering: true, // Always use this!
197
- extensionsVersion: 3,
198
- plainEntrypointsVersion: 2,
199
- srcDir: "src", // Always use this!
200
- outputDir: "dist", // Always use this!
201
- useUnifiedLoader: true, // Always use this!
146
+ standard: '2026-03-16',
202
147
  variables: {
203
148
  font_size: 16 // Required for pxAsRem to work; replace the 16 with your site's base font size
204
149
  }
205
150
  });
206
151
  ```
152
+ The `standard` key is shorthand to the standard set of flags as of the given date. See the [Standard Flag Sets](#standard-flag-sets) section for details.
207
153
 
208
154
  ### 2. Set Up Your File Structure
209
155
 
210
156
  **Blocks** (subdirectories with block.json):
211
- - **Config:** `'blocks': true`
157
+ - **Config:** optional so long as the directory name is `blocks`; `'<dirname>': true` otherwise
212
158
  - **File Structure:** [See Here](#file-structure)
213
159
 
214
160
  **Extensions** (flat files that modify existing blocks):
215
- - **Config:** `'extensions': {directoryLayout: 'extensions'}`
161
+ - **Config:** optional so long as the directory name is `extensions`; `'<dirname>': {directoryLayout: 'extensions'}` otherwise
216
162
  - **File Structure:** [See Here](#file-structure-1)
217
163
 
218
164
  **Other Files** (scripts, styles):
219
- - **Config:** List each file individually in `src` object
165
+ - **Config:** Optional so long as you are using [Location-Encoding Filenames](#location-encoding-filenames); List each file that does not encode its own location in `src` object
220
166
  - **File Structure:** [See Here](#file-structure-2)
221
167
 
222
168
  ### 3. Include unified-loader.php in Your Plugin
@@ -357,21 +303,93 @@ src: {
357
303
  # Reference
358
304
 
359
305
  ## Root Options
360
- | Option | Type | Default | Description |
361
- |------------------------------------|-----------|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
362
- | `src` | `object` | **Required** | Files/directories to process (see the next section for what you can put in here) |
363
- | `srcDir` | `string` | `""` | Source directory (**Required** on new sites) |
364
- | `outputDir` | `string` | `""` | Output directory (**Required** on new sites) |
365
- | `useUnifiedLoader` | `boolean` | `false` | Generate unified-loader.php (always set to `true` on new sites!) |
366
- | `useWebpackResourceFiltering` | `boolean` | `false` | Generates versioned copies of images, fonts, etc (always set to `true` on new sites!) |
367
- | `plainEntrypointsVersion` | `1\|2` | `1` | Use 2 for new sites |
368
- | `extensionsVersion` | `1\|2\|3` | `1` | Use 3 for new sites |
369
- | `verbose` | `boolean` | `false` | Verbose logging |
370
- | `variables` | `object` | Auto | CSS/JS variables. If a variables.js file is present, this will automatically load from that file |
371
- | `onlyRunPostCSSOnPCSS` | `boolean` | `false` | If true, the PostCSS processor will not be run on CSS files. This is true for all new sites and can be safely enabled on most sites if desired. |
372
- | `assumeGlobalizedPlauditLibraries` | `boolean` | `true` | **[Advanced]** When `false`, normally-externalized plaudit libraries will be included.<br>**DO NOT USE THIS. IF YOU SEE IT BEING USED, CONTACT JOSH** |
373
- | `externals` | `object` | - | **[Advanced]** Allows dependencies to be marked as external. This prevents them from being included in the bundle under the assumption that they will be provided via an alternate mechanism |
374
- | `targetHandlePrefix` | `string` | Auto | **[Legacy]** Prefix for handles. Auto-detected from composer.json if omitted. Do not set this unless absolutely necessary |
306
+ | Option | Type | Default | Description |
307
+ |------------------------------------|-----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
308
+ | `standard` | `enum` | - | An identifier for the standard set of flags as of a given date. See the [Standards Flag Sets](#standard-flag-sets) section for values |
309
+ | `src` | `object` | `{}` | Files/directories to process (see the next section for what you can put in here) |
310
+ | `srcDir` | `string` | `""` | Source directory (**Required** on new sites) |
311
+ | `outputDir` | `string` | `""` | Output directory (**Required** on new sites) |
312
+ | `useUnifiedLoader` | `boolean` | `false` | Generate unified-loader.php (always set to `true` on new sites!) |
313
+ | `useWebpackResourceFiltering` | `boolean` | `false` | Generates versioned copies of images, fonts, etc (always set to `true` on new sites!) |
314
+ | `plainEntrypointsVersion` | `1\|2` | `1` | Use 2 for new sites |
315
+ | `extensionsVersion` | `1\|2\|3` | `1` | Use 3 for new sites |
316
+ | `verbose` | `boolean` | `false` | Verbose logging |
317
+ | `variables` | `object` | Auto | CSS/JS variables. If a variables.js file is present, this will automatically load from that file |
318
+ | `onlyRunPostCSSOnPCSS` | `boolean` | `false` | If true, the PostCSS processor will not be run on CSS files. This is true for all new sites and can be safely enabled on most sites if desired. |
319
+ | `assumeGlobalizedPlauditLibraries` | `boolean` | `true` | **[Advanced]** When `false`, normally-externalized plaudit libraries will be included.<br>**DO NOT USE THIS. IF YOU SEE IT BEING USED, CONTACT JOSH** |
320
+ | `externals` | `object` | - | **[Advanced]** Allows dependencies to be marked as external. This prevents them from being included in the bundle under the assumption that they will be provided via an alternate mechanism |
321
+ | `targetHandlePrefix` | `string` | Auto | **[Legacy]** Prefix for handles. Auto-detected from composer.json if omitted. Do not set this unless absolutely necessary |
322
+
323
+ ### Standard Flag Sets
324
+ Each flag set is identified by the date that it was added to the standards set. Individual values can be overridden by specifying them in the config file
325
+
326
+ **2026-03-13**
327
+ ```javascript
328
+ {
329
+ useWebpackResourceFiltering: true,
330
+ extensionsVersion: 3,
331
+ plainEntrypointsVersion: 2,
332
+ srcDir: "src",
333
+ outputDir: "dist",
334
+ useUnifiedLoader: true,
335
+ onlyRunPostCSSOnPCSS: true,
336
+ }
337
+ ```
338
+
339
+ ---
340
+
341
+ ## Location-Encoding Filenames
342
+ This section covers how asset emission locations can be encoded in filenames.
343
+ While every common flag is accounted for in this schema, there are some things that cannot be encoded in filenames that will require enumeration in the `webpack.config.js` file's `src` object.
344
+
345
+ Location-encoding filenames are composed of two or more `.`-separated segments (the file extension being one of those segments).
346
+ The following is a brief list of notes followed by a breakdown of the individual segments:
347
+ - The only required segments are the location and type segments (the type segment is the file extension).
348
+ - So long as there is at least one location and type segment (the type segment MUST be last), "invalid" segments are allowed (this is for the purposes of giving human-readable names to files)
349
+ - Each file can enumerate any combination enqueuing locations
350
+ - The first item is special in that, if it encodes a location, in can optionally be suffixed with a type override (see the [Enqueuing Location](#enqueuing-location) section for more details)
351
+
352
+ Notes on how to read the following table:
353
+ - Brackets in the token column mean "optional section"
354
+ - `(-|=)` means "this can be either a dash or an equal sign"
355
+ - Pipe-separated items in parentheses means "any one of these items can go here"
356
+
357
+ | Name | Token | Usage |
358
+ |--------------------|-------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
359
+ | Enqueuing Location | `(enqueuing-location)[(-\|=)priority]` | This is a special section that is actually a collection of values. See the [Enqueuing Location](#enqueuing-location) section for more details |
360
+ | Type Override | `script`, `style`, `script-module` | Can be used to override the detected of the asset. Must be the first token in the filename; if used directly, it is shorthand for `both-(Type Override)` |
361
+ | Inline | `inline[(-\|=)position]`, `strategy(-\|=)inline[-position]` | Indicates that the script should be inlined. `position` can be either `before` or `after` |
362
+ | Strategy | `lazy\|eager`, `strategy(-\|=)(lazy\|eager\|defer\|async)` | Controls the loading strategy. Lazy and eager have shorthand while the remaining values must be prefixed with `strategy` |
363
+ | Fetch Priority | `fetchpriority(-\|=)(low\|high\|auto)` | Controls the fetchpriority property; `auto` is the default |
364
+ | In Footer | `in-footer`, `in_footer` | Sets the `in_footer` value to `true`; incompatible with `in-header` |
365
+ | In Header | `in-header`, `in_header` | Sets the `in_footer` value to `false`; incompatible with `in-footer` |
366
+ | Extension | `([ps]?c\|sa)ss`, `m?[jt]sx?` | This determines the type unless it is overridden. This **MUST** be the last token in the name (it is the file extension) |
367
+
368
+ ### Enqueuing Location
369
+ If this is the first token, it can be suffixed with `-script`, `-style`, or `-script-module` to override the type.
370
+ Specifying the type override alone is interpreted as `both-(Type Override)` for compatibility with how blocks expect assets to be named.
371
+
372
+ Blocks do not support anything other than `view`, `editor`, and `both` (typically written as `script` or `style`).
373
+
374
+ **Valid Values**:
375
+
376
+ | Token | Meaning |
377
+ |-------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|
378
+ | `view`, `client-view`, `clientView` | Enqueue the asset on the frontend (the part of the site seen by visitors) |
379
+ | `editor`, `client-editor`, `clientEditor` | Enqueue the asset in the *display* portion of the block editor |
380
+ | `both` | Shorthand for `view.editor` |
381
+ | `block-assets`, `block-assets` | Enqueue the asset in the *wrapper* portion of the block editor |
382
+ | `admin` | Enqueue the asset in the admin area |
383
+ | `login` | Enqueue the asset on the standard login page |
384
+ | `customizer` | Enqueue the asset in the legacy customizer interface |
385
+ | `analytics` | Enqueue the asset when analytics scripts have been accepted by the visitor (this "location" is unique to Plaudit's systems) |
386
+ | `register` | Register the asset *without* enqueuing it anywhere (this is primarily useful when localizing the asset) |
387
+
388
+ ### Examples
389
+ #### Block- and Plain-compatible
390
+ - **A view script**: `view.ts`
391
+ - **An editor script**: `editor.ts`
392
+ - **A view and editor script**: `script.ts`
375
393
 
376
394
  ---
377
395
 
@@ -380,6 +398,7 @@ This section covers the shared options for entrypoints. See the [Entrypoint Type
380
398
 
381
399
  ### Path Queries
382
400
  - These are URL-style queries added to the end of entrypoint *source* paths and are used to set entrypoint-specific properties in Plain and Block contexts.
401
+ - If you find yourself using these, consider switching to [Location-Encoding Filenames](#location-encoding-filenames)
383
402
  - At present, this is only being used to configure inlining, but expansion to other systems is being considered
384
403
  - The available options are: `strategy`, `inline`, `in_footer`, `fetchpriority`, and `position`
385
404
 
@@ -482,8 +501,10 @@ This is used to associate additional assets with blocks that are not in control
482
501
  [Specially named files](#file-naming) in a single subdirectory of `src`
483
502
  ```
484
503
  src/extensions/
485
- ├── core-paragraph-view-script.ts
486
- └── core-paragraph-editor-style.pcss
504
+ ├─ core/paragraph/
505
+ │ ├─ view.ts
506
+ │ └─ editor.pcss
507
+ └─ plaudit/block-library/accordion/style.pcss
487
508
  ```
488
509
 
489
510
  #### File Naming
@@ -494,6 +515,9 @@ Filenames **must** follow the pattern: `{kebab-case-block-name}-{type}.{ext}`
494
515
  - `script-module`, `view-script-module`
495
516
  - `setup` (this allows for PHP code to be loaded only when certain blocks are enabled and is intended for use in plugins, not themes)
496
517
  - `ext` **must** be for a [supported file type](#supported-file-types) and **should** correspond with the extension type (basically, don't enqueue a `.css` file as a script)
518
+ - For convenience, everything before the `{type}` can be split into directories on the hyphens
519
+ - When using this format, the filenames must be [Location-Encoding Filenames](#location-encoding-filenames) or `setup.php`
520
+ - This is only available in extensions v2 and up
497
521
 
498
522
  #### Notes
499
523
  - In order to have a directory be treated as `extensions`, the config **must** include `directoryLayout: 'extensions'`
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.EnhancedBlockJSONPlugin = void 0;
7
7
  const node_crypto_1 = __importDefault(require("node:crypto"));
8
- const promises_1 = __importDefault(require("node:fs/promises"));
8
+ const promises_1 = require("node:fs/promises");
9
9
  const node_fs_1 = __importDefault(require("node:fs"));
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
@@ -37,8 +37,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
37
37
  if (asset) {
38
38
  const epBlockJson = entrypoint.name + ".json";
39
39
  if (!applicableBlockJsonFiles[epBlockJson]) {
40
- const blockJsonText = EnhancedBlockJSONPlugin.extractAssetSource(compilation, epBlockJson)
41
- ?? await promises_1.default.readFile(srcPath, 'utf-8');
40
+ const blockJsonText = EnhancedBlockJSONPlugin.extractAssetSource(compilation, epBlockJson) ?? await (0, promises_1.readFile)(srcPath, 'utf-8');
42
41
  if (!blockJsonText) {
43
42
  compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`Unable to extract the source for ${epBlockJson}`, srcPath));
44
43
  continue;
@@ -66,10 +65,8 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
66
65
  .map(file => [file, (0, shared_1.scriptOrStyleTest)(file, shared_1.scriptExtension)])
67
66
  .filter((item) => item[1] !== '')
68
67
  .map(([file, assetType]) => {
69
- const pathQueryParameters = metadata.pathQueryParameters !== undefined || this.dest.pathQueryParameters !== undefined
70
- ? { ...metadata.pathQueryParameters, ...this.dest.pathQueryParameters }
71
- : undefined;
72
- const { scriptArgsObject, inlinedAsset } = (0, path_query_and_related_helpers_1.parseScriptArgsObjectFromPathQueryParameters)(compilation, file, pathQueryParameters);
68
+ const enqueuingFlags = (0, path_query_and_related_helpers_1.mergeTwoScriptEnqueuingControlFlagSets)(file, metadata.enqueuingFlags, this.dest.enqueuingFlags);
69
+ const { scriptArgsObject, inlinedAsset } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, enqueuingFlags);
73
70
  const wasOriginallyAStyleField = (0, shared_1.isStyleField)(metadata.entrypointField);
74
71
  const outputPath = this.stripOffBlocksDestPrefix(file);
75
72
  if (wasOriginallyAStyleField !== (assetType === "style")) { // This means that the file is extracted
@@ -1,15 +1,19 @@
1
1
  import { AbstractBiPhasicGroupAndEntryPlugin, EntryProvider } from "./AbstractBiPhasicGroupAndEntryPlugin";
2
- import { ParsedAssetJsonProvider, VerifiedAdvancedOutputConfig } from "../shared";
2
+ import { MinimumViableMetadata, ParsedAssetJsonProvider, VerifiedAdvancedOutputConfig } from "../shared";
3
3
  import type { VerifiedPlauditWordpressWebpackConfig } from "../utils/common-config-helpers";
4
4
  import { Compilation, type Compiler } from "webpack";
5
- export declare class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin {
5
+ export type ExtensionConfigFileGeneratorMetadata = MinimumViableMetadata & {
6
+ extensionId: string;
7
+ };
8
+ export declare class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryPlugin<ExtensionConfigFileGeneratorMetadata> {
6
9
  private readonly extensionsSrcPath;
7
10
  private readonly dest;
8
11
  private static readonly semaphore;
9
12
  private setupFiles;
10
- constructor(config: VerifiedPlauditWordpressWebpackConfig, extensionsSrcPath: string, dest: VerifiedAdvancedOutputConfig, context: string, entry: EntryProvider);
13
+ constructor(config: VerifiedPlauditWordpressWebpackConfig, extensionsSrcPath: string, dest: VerifiedAdvancedOutputConfig, context: string, entry: EntryProvider<ExtensionConfigFileGeneratorMetadata>);
11
14
  get extensionsDestPath(): string;
12
15
  apply(compiler: Compiler): void;
16
+ private walkSubtreeForMetaInfo;
13
17
  private generateVersionThreeConfigFile;
14
18
  protected attachUniquePhase(compilation: Compilation): void;
15
19
  protected processAssets(compilation: Compilation, parsedAssetJsonProvider: ParsedAssetJsonProvider): void;
@@ -1,11 +1,41 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
5
35
  Object.defineProperty(exports, "__esModule", { value: true });
6
36
  exports.ExtensionsConfigFileGeneratorPlugin = void 0;
7
- const promises_1 = __importDefault(require("node:fs/promises"));
8
- const node_path_1 = __importDefault(require("node:path"));
37
+ const promises_1 = require("node:fs/promises");
38
+ const node_path_1 = __importStar(require("node:path"));
9
39
  const php_writer_1 = require("@plaudit/php-writer");
10
40
  const expressions_1 = require("@plaudit/php-writer/expressions");
11
41
  const AbstractBiPhasicGroupAndEntryPlugin_1 = require("./AbstractBiPhasicGroupAndEntryPlugin");
@@ -34,24 +64,49 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
34
64
  compilation.contextDependencies.add(this.extensionsSrcPath);
35
65
  }
36
66
  const emissionPromises = [];
37
- for await (const { name: setupFilePath } of await promises_1.default.opendir(this.extensionsSrcPath, { encoding: 'utf-8' })) {
67
+ for await (const { name: setupFilePath } of await (0, promises_1.opendir)(this.extensionsSrcPath, { encoding: 'utf-8' })) {
38
68
  if (setupFilePath.endsWith("-setup.php")) {
39
69
  const setupFileSourcePath = node_path_1.default.join(this.extensionsSrcPath, setupFilePath);
40
70
  compilation.fileDependencies.add(setupFileSourcePath);
41
- emissionPromises.push(promises_1.default.readFile(setupFileSourcePath).then(contents => {
71
+ emissionPromises.push((0, promises_1.readFile)(setupFileSourcePath).then(contents => {
42
72
  compilation.emitAsset(node_path_1.default.join(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
43
73
  const blockSlug = /^(.+?)-setup.php$/i.exec(setupFilePath)?.[1];
44
74
  return [blockSlug, setupFilePath];
45
75
  }));
46
76
  }
47
77
  }
78
+ await this.walkSubtreeForMetaInfo(compilation, this.extensionsSrcPath, this.dest, [], emissionPromises);
48
79
  this.setupFiles = (await Promise.all(emissionPromises))
49
80
  .filter((item) => item[0] !== undefined).sort((a, b) => a[0].localeCompare(b[0]));
50
81
  });
51
82
  }
83
+ async walkSubtreeForMetaInfo(compilation, srcRoot, dest, parents, emissionPromises) {
84
+ if (!compilation.contextDependencies.has(srcRoot)) {
85
+ compilation.contextDependencies.add(srcRoot);
86
+ }
87
+ for await (const dirent of await (0, promises_1.opendir)(srcRoot)) {
88
+ if (dirent.name.startsWith("~")) {
89
+ continue;
90
+ }
91
+ if (dirent.isFile()) {
92
+ if (dirent.name === "setup.php") {
93
+ const setupFilePath = (0, node_path_1.join)(...parents, dirent.name);
94
+ const setupFileSourcePath = node_path_1.default.join(this.extensionsSrcPath, setupFilePath);
95
+ compilation.fileDependencies.add(setupFileSourcePath);
96
+ emissionPromises.push((0, promises_1.readFile)(setupFileSourcePath).then(contents => {
97
+ compilation.emitAsset(node_path_1.default.join(this.dest.destination, setupFilePath), new webpack_1.sources.RawSource(contents), { size: Buffer.byteLength(contents) });
98
+ return [parents.join("-") /* blockSlug */, setupFilePath];
99
+ }));
100
+ }
101
+ }
102
+ else if (dirent.isDirectory()) {
103
+ await this.walkSubtreeForMetaInfo(compilation, (0, node_path_1.join)(srcRoot, dirent.name), dest, [...parents, dirent.name], emissionPromises);
104
+ }
105
+ }
106
+ }
52
107
  generateVersionThreeConfigFile(compilation, relevantAssetData, setupFilePaths) {
53
108
  const handlePrefix = `${this.config.targetHandlePrefix}_block-extensions`;
54
- const regex = /^(.+?)-((?:editor-|view-|)(?:style|script|script-module))\.(?:css|m?js)$/i;
109
+ const regex = /^(.+?)-((?:editor-|view-|)(?:style|script|script-module))$/i;
55
110
  const blockExtensionsConfig = {
56
111
  metadata: { version: this.config.extensionsVersion }, scriptHandles: {}, scriptModuleHandles: {}, styleHandles: {}, blocks: {}, setupFiles: {}
57
112
  };
@@ -62,7 +117,7 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
62
117
  return [assetPath, entry[1]];
63
118
  });
64
119
  for (const [assetPath, assetData] of normalizedAssetData) {
65
- const match = regex.exec(assetPath);
120
+ const match = regex.exec(assetData.extensionId);
66
121
  if (!match) {
67
122
  continue;
68
123
  }
@@ -127,7 +182,16 @@ class ExtensionsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAndEntryP
127
182
  });
128
183
  }
129
184
  processAssets(compilation, parsedAssetJsonProvider) {
130
- const relevantAssetData = this.extractRelevantAssetData(compilation, parsedAssetJsonProvider);
185
+ const relevantAssetData = Object.fromEntries(this.getRelevantEntrypoints(compilation)
186
+ .map(({ entrypoint, metadata, srcPath }) => {
187
+ const providedData = parsedAssetJsonProvider(entrypoint, metadata);
188
+ if (providedData === undefined) {
189
+ compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`assets.json did not contain information for ${srcPath}`, srcPath));
190
+ return undefined;
191
+ }
192
+ return [providedData.assetName, { ...providedData.assetData, extensionId: metadata.extensionId }];
193
+ })
194
+ .filter(item => item !== undefined));
131
195
  const staticallyLoadedEntrypoints = Object.keys(relevantAssetData);
132
196
  const generateLoader = (writer) => {
133
197
  writer.require(this.extensionsDestPath + "extensions-loader.php", { dirRelative: true, once: true });
@@ -302,7 +302,8 @@ class PlainEntrypointsConfigFileGeneratorPlugin extends AbstractBiPhasicGroupAnd
302
302
  const isScript = type !== 'style';
303
303
  const dependencies = isScript === entrypointChunkIsScript ? assetData.dependencies : [];
304
304
  const { lazyLoader, locations } = this.dest;
305
- const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.parseScriptArgsObjectFromPathQueryParameters)(compilation, file, (0, path_query_and_related_helpers_1.mergeInPathQueryParameters)(file, locations.registerScriptArgs, this.dest.pathQueryParameters));
305
+ const { flags } = (0, path_query_and_related_helpers_1.unpackEnqueuingControlFlagsFromPathQueryParameters)(typeof locations.registerScriptArgs === 'object' ? locations.registerScriptArgs : { strategy: locations.registerScriptArgs }, file, "registerScriptArgs");
306
+ const { inlinedAsset, scriptArgsObject } = (0, path_query_and_related_helpers_1.convertEnqueuingControlFlagsToScriptArgsObject)(compilation, file, (0, path_query_and_related_helpers_1.mergeTwoScriptEnqueuingControlFlagSets)(file, flags, this.dest.enqueuingFlags));
306
307
  const rest = isScript && scriptArgsObject !== undefined ? [dependencies, assetData.version, scriptArgsObject] : [dependencies, assetData.version];
307
308
  const destPath = node_path_1.default.join(compilation.outputOptions.path, file);
308
309
  handles.push({