generator-chisel 2.2.2 → 2.3.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
@@ -2,6 +2,11 @@
2
2
 
3
3
  <!-- INSERT-NEW-ENTRIES-HERE -->
4
4
 
5
+ ## 2.3.0 (2025-12-15)
6
+
7
+ - add wp exp-modules support, update wp scripts, build file size limits, auto clear patterns cache, no ([728f566](https://github.com/xfiveco/generator-chisel/commit/728f566))
8
+ - Publish ([0fc6fce](https://github.com/xfiveco/generator-chisel/commit/0fc6fce))
9
+
5
10
  ## <small>2.2.2 (2025-11-07)</small>
6
11
 
7
12
  - blocks adjustments, new patterns, fixes, block mods ([19f038f](https://github.com/xfiveco/generator-chisel/commit/19f038f))
@@ -1 +1 @@
1
- 20.12.2
1
+ >=20.12.2
@@ -187,13 +187,22 @@ final class RegisterBlocks {
187
187
 
188
188
  // Register ignored scripts in dev mode in order to watch changes.
189
189
  if ( ThemeHelpers::is_fast_refresh() || ( ! ThemeHelpers::is_fast_refresh() && ! in_array( $script, $ignore_scripts, true ) ) ) {
190
- wp_register_script(
191
- $block_handle,
192
- $file_url,
193
- $script_asset['dependencies'],
194
- $script_asset['version'],
195
- $register_script_args,
196
- );
190
+ if ( 'viewscriptmodule' === $script_handle ) {
191
+ wp_register_script_module(
192
+ $block_handle,
193
+ $file_url,
194
+ $script_asset['dependencies'],
195
+ $script_asset['version']
196
+ );
197
+ } else {
198
+ wp_register_script(
199
+ $block_handle,
200
+ $file_url,
201
+ $script_asset['dependencies'],
202
+ $script_asset['version'],
203
+ $register_script_args
204
+ );
205
+ }
197
206
  }
198
207
  }
199
208
  }
@@ -55,6 +55,8 @@ final class Woocommerce implements InstanceInterface, HooksInterface {
55
55
  public function action_hooks(): void {
56
56
  $this->remove_actions();
57
57
 
58
+ add_action( 'rest_api_init', array( $this, 'register_cart' ) );
59
+
58
60
  add_action( 'after_setup_theme', array( $this, 'add_woocommerce_support' ) );
59
61
 
60
62
  add_action( 'woocommerce_before_shop_loop', array( $this, 'before_shop_loop_div_open' ), 19 );
@@ -101,6 +103,22 @@ final class Woocommerce implements InstanceInterface, HooksInterface {
101
103
  remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
102
104
  }
103
105
 
106
+ /**
107
+ * Get access to cart in REST API endpoints.
108
+ *
109
+ * @return void
110
+ */
111
+ public function register_cart(): void {
112
+ include_once WC_ABSPATH . 'includes/wc-cart-functions.php';
113
+ include_once WC_ABSPATH . 'includes/wc-notice-functions.php';
114
+
115
+ WC()->initialize_session();
116
+ WC()->initialize_cart();
117
+ WC()->session->set_customer_session_cookie( true );
118
+
119
+ WC()->cart->get_cart();
120
+ }
121
+
104
122
  /**
105
123
  * Add WooCommerce support.
106
124
  */
@@ -29,6 +29,13 @@ final class Blocks implements InstanceInterface, HooksInterface {
29
29
  */
30
30
  private RegisterBlocks $register_blocks_factory;
31
31
 
32
+ /**
33
+ * Theme.
34
+ *
35
+ * @var \WP_Theme
36
+ */
37
+ private ?\WP_Theme $theme = null;
38
+
32
39
  /**
33
40
  * Blocks.
34
41
  *
@@ -51,6 +58,14 @@ final class Blocks implements InstanceInterface, HooksInterface {
51
58
  */
52
59
  private array $block_patterns_categories = array();
53
60
 
61
+
62
+ /**
63
+ * Blocks patterns categories namespace.
64
+ *
65
+ * @var string
66
+ */
67
+ private string $block_patterns_categories_namespace = '';
68
+
54
69
  /**
55
70
  * Blocks twig file base path.
56
71
  *
@@ -75,8 +90,10 @@ final class Blocks implements InstanceInterface, HooksInterface {
75
90
  * Set properties.
76
91
  */
77
92
  public function set_properties(): void {
78
- $this->blocks_category = 'chisel-blocks';
79
- $this->block_patterns_categories = array(
93
+ $this->theme = wp_get_theme();
94
+ $this->blocks_category = 'chisel-blocks';
95
+ $this->block_patterns_categories_namespace = 'chisel-patterns';
96
+ $this->block_patterns_categories = array(
80
97
  'cta' => array(
81
98
  'label' => __( 'Call to Action', 'chisel' ),
82
99
  'description' => __( 'Call to Action Sections.', 'chisel' ),
@@ -173,9 +190,11 @@ final class Blocks implements InstanceInterface, HooksInterface {
173
190
  return;
174
191
  }
175
192
 
193
+ $this->maybe_clear_patterns_cache();
194
+
176
195
  foreach ( $this->block_patterns_categories as $slug => $category ) {
177
196
  $category['label'] = sprintf( '[%s] %s', ThemeHelpers::get_theme_name(), esc_attr( $category['label'] ) );
178
- register_block_pattern_category( 'chisel-patterns/' . $slug, $category );
197
+ register_block_pattern_category( $this->block_patterns_categories_namespace . '/' . $slug, $category );
179
198
  }
180
199
  }
181
200
 
@@ -313,4 +332,33 @@ final class Blocks implements InstanceInterface, HooksInterface {
313
332
  }
314
333
  }
315
334
  }
335
+
336
+ /**
337
+ * Maybe clear patterns cache. Clear patterns cache if block patterns categories are changed / added.
338
+ *
339
+ * @return void
340
+ */
341
+ protected function maybe_clear_patterns_cache() {
342
+ if ( ! $this->block_patterns_categories ) {
343
+ return;
344
+ }
345
+
346
+ $theme_patterns = $this->block_patterns_categories;
347
+ $cached_patterns = $this->theme->get_block_patterns();
348
+ $patterns_categories = array();
349
+
350
+ foreach ( $cached_patterns as $pattern ) {
351
+ foreach ( $pattern['categories'] ?? array() as $category ) {
352
+ $category = str_replace( $this->block_patterns_categories_namespace . '/', '', $category );
353
+
354
+ if ( isset( $theme_patterns[ $category ] ) ) {
355
+ unset( $theme_patterns[ $category ] );
356
+ }
357
+ }
358
+ }
359
+
360
+ if ( ! empty( $theme_patterns ) ) {
361
+ $this->theme->delete_pattern_cache();
362
+ }
363
+ }
316
364
  }
@@ -2,7 +2,6 @@
2
2
 
3
3
  namespace Chisel\WP;
4
4
 
5
- use Automattic\WooCommerce\Internal\Admin\ProductForm\Component;
6
5
  use Timber\Timber;
7
6
  use Timber\Site as TimberSite;
8
7
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "<%= app.nameSlug %>",
3
- "version": "0.0.0",
3
+ "version": "2.0.0",
4
4
  "private": true,
5
5
  "license": "UNLICENSED",
6
6
  "author": "<%= app.author %>",
@@ -10,10 +10,10 @@
10
10
  "devcontainer:up": "npm run --silent devcontainer -- up --workspace-folder ../../..",
11
11
  "devcontainer:enter": "/usr/bin/env bash ../../../.devcontainer/exec bash",
12
12
  "devcontainer:start": "/usr/bin/env bash ../../../.devcontainer/exec npm run --silent start",
13
- "start": "chisel-scripts start",
13
+ "start": "chisel-scripts start --experimental-modules",
14
14
  "dev": "npm run --silent start",
15
- "build": "chisel-scripts build && npm run lint && npm run phpcs && npm run twigcs",
16
- "build-scripts": "chisel-scripts build",
15
+ "build-scripts": "chisel-scripts build --experimental-modules",
16
+ "build": "npm run build-scripts && npm run lint && npm run phpcs && npm run twigcs",
17
17
  "add-page": "chisel-scripts add-page",
18
18
  "create-block": "chisel-scripts create-block --category=chisel-blocks --namespace=chisel",
19
19
  "create-dynamic-block": "npm run create-block --variant=dynamic",
@@ -27,7 +27,7 @@
27
27
  "swiper": "^11.1.10"
28
28
  },
29
29
  "devDependencies": {
30
- "@wordpress/scripts": "^27.9.0",
30
+ "@wordpress/scripts": "^31.1.0",
31
31
  "chisel-scripts": "*",
32
32
  "cross-env": "^7.0.3"
33
33
  },
@@ -3,15 +3,4 @@ const { adjustWebpackConfig } = require('chisel-scripts');
3
3
 
4
4
  const updatedConfig = adjustWebpackConfig(defaultConfig, __dirname);
5
5
 
6
- updatedConfig.devServer = {
7
- ...updatedConfig.devServer,
8
- client: {
9
- overlay: {
10
- errors: true,
11
- warnings: false,
12
- runtimeErrors: false,
13
- },
14
- },
15
- };
16
-
17
6
  module.exports = updatedConfig;
@@ -1,5 +1,5 @@
1
1
  module.exports = {
2
- 'chisel-scripts': '2.0.0-2.0.0-alpha.8.1',
2
+ 'chisel-scripts': '2.1.0',
3
3
  'chisel-shared-utils': '2.0.0-alpha.1',
4
- 'generator-chisel': '2.2.2',
4
+ 'generator-chisel': '2.3.0',
5
5
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "generator-chisel",
3
- "version": "2.2.2",
3
+ "version": "2.3.0",
4
4
  "description": "A generator for scaffolding front-end and WordPress projects",
5
5
  "bin": {
6
6
  "chisel": "bin/chisel.js"
@@ -37,5 +37,5 @@
37
37
  "tinyqueue": "^2.0.3",
38
38
  "update-notifier": "^4.1.0"
39
39
  },
40
- "gitHead": "cf2dafab46be1d1598354db3420c3deb35ecd0bb"
40
+ "gitHead": "f5cb01894754a85b6842fa10412986bb745ea43a"
41
41
  }