@plaudit/webpack-extensions 2.91.0 → 2.92.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
@@ -60,6 +60,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
60
60
  - Legacy PostCSS features that have been integrated into modern CSS
61
61
  - `@extends` support
62
62
 
63
+ ## [2.92.0] - 2026-05-20
64
+ ### Added
65
+ - Support for marking `block.json` attributes with `"supports-bindings": true` to enable block binding support in the editor
66
+
63
67
  ## [2.91.0] - 2026-05-20
64
68
  ### Added
65
69
  - Support for the `module_dependencies` property on `script` assets
@@ -155,6 +155,33 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
155
155
  this.callRegisterFunction('script', writer, baseUriVar, Object.entries(finalizedScriptHandles));
156
156
  this.callRegisterFunction('style', writer, baseUriVar, Object.entries(finalizedStyleHandles));
157
157
  this.callRegisterFunction('script_module', writer, baseUriVar, Object.entries(metadata.scriptModuleHandles));
158
+ const entries = Object.entries(metadata.bindableBlockAttributes);
159
+ const supportedAttributes = new expressions_1.Var("supported_block_attributes", "?array");
160
+ if ((0, shared_1.arrayIsLength)(entries, 1)) {
161
+ writer.filter(`block_bindings_supported_attributes_${entries[0][0]}`, writer => {
162
+ const parameters = entries[0][1];
163
+ if (parameters.length === 1) {
164
+ writer.appendExpr(new expressions_1.Assignment(supportedAttributes, parameters[0], true));
165
+ }
166
+ else {
167
+ writer.call("array_push", [supportedAttributes, ...parameters]);
168
+ }
169
+ writer.return(supportedAttributes);
170
+ }, { functionArgParameters: [supportedAttributes] });
171
+ }
172
+ else if (entries.length > 1) {
173
+ const compiledBindingSupportingAttributes = new expressions_1.Var("compiled_binding_supporting_attributes");
174
+ writer.assign(compiledBindingSupportingAttributes, metadata.bindableBlockAttributes);
175
+ const blockType = new expressions_1.Var("block_type", "?string");
176
+ writer.filter(`block_bindings_supported_attributes`, writer => {
177
+ writer
178
+ .if(expressions_1.Op.binary(new expressions_1.Call("empty", [blockType]), " || ", new expressions_1.Call("empty", [new expressions_1.ArrayAccess(compiledBindingSupportingAttributes, blockType)])))
179
+ .return(supportedAttributes)
180
+ .endIf()
181
+ .call("array_push", [supportedAttributes, new expressions_1.Op("...", new expressions_1.ArrayAccess(compiledBindingSupportingAttributes, blockType))])
182
+ .return(supportedAttributes);
183
+ }, { functionArgParameters: [supportedAttributes, blockType], useVars: [compiledBindingSupportingAttributes] });
184
+ }
158
185
  writer.call("\\Plaudit\\Common\\ACF\\BlockManager::autoloadSubfoldersV3", [
159
186
  expressions_1.Constants.__DIR__, // string $dir
160
187
  new expressions_1.EnclosedLiteral((0, shared_1.makeEmittableConfigPHP)(blockData, false, "\t")), // array $blockdirConfig
@@ -185,6 +212,7 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
185
212
  .flatMap(bi => bi.workableBlockEntrypointsInfo)
186
213
  .sort((a, b) => a.handle.localeCompare(b.handle) || a.entrypointField.localeCompare(b.entrypointField));
187
214
  const blockData = {};
215
+ const bindableBlockAttributes = {};
188
216
  for (const [blockJsonAssetName, { sourcePath: blockJsonSourcePath, workableBlockEntrypointsInfo, blockJsonText }] of Object.entries(collatedWorkableBlockInfo)) {
189
217
  if (!blockJsonSourcePath) {
190
218
  compilation.errors.push((0, shared_1.newWebpackErrorForFile)(`${blockJsonAssetName} does not have a source path`, blockJsonAssetName));
@@ -208,6 +236,19 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
208
236
  else {
209
237
  blockJson["version"] = hashForVersion;
210
238
  }
239
+ if (typeof blockJson["name"] === 'string' && typeof blockJson["attributes"] === 'object' && blockJson["attributes"]) {
240
+ for (const [name, attr] of Object.entries(blockJson["attributes"])) {
241
+ if (attr["supports-bindings"]) {
242
+ delete attr["supports-bindings"];
243
+ if (bindableBlockAttributes[blockJson["name"]] !== undefined) {
244
+ bindableBlockAttributes[blockJson["name"]].push(name);
245
+ }
246
+ else {
247
+ bindableBlockAttributes[blockJson["name"]] = [name];
248
+ }
249
+ }
250
+ }
251
+ }
211
252
  EnhancedBlockJSONPlugin.normalizeRenderTemplate(blockJson, pathsNeedRemapping, sourceDir, outputDir, compilation);
212
253
  const blockDirName = (0, node_path_1.dirname)((0, node_path_1.relative)(this.dest.destination, blockJsonAssetName));
213
254
  blockData[blockDirName] = EnhancedBlockJSONPlugin
@@ -226,7 +267,8 @@ class EnhancedBlockJSONPlugin extends AbstractBiPhasicGroupAndEntryPlugin_1.Abst
226
267
  styleHandles: Object.fromEntries(handleData.filter(hd => (0, shared_1.isStyleField)(hd.entrypointField))
227
268
  .map(hd => {
228
269
  return [hd.handle, { src: hd.outputPath, rest: [hd.originalValue !== undefined ? hd.assetData.dependencies : [], hd.assetData.version], inlinedAsset: hd.inlinedAsset }];
229
- }))
270
+ })),
271
+ bindableBlockAttributes
230
272
  },
231
273
  ...Object.fromEntries(Object.entries(blockData).sort((a, b) => a[0].localeCompare(b[0])))
232
274
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plaudit/webpack-extensions",
3
- "version": "2.91.0",
3
+ "version": "2.92.0",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "files": [
6
6
  "/dist",